| 66 | } |
| 67 | |
| 68 | struct timerel time_multiply(struct timerel t, unsigned long mult) |
| 69 | { |
| 70 | struct timerel res; |
| 71 | |
| 72 | /* Are we going to overflow if we multiply nsec? */ |
| 73 | if (mult & ~((1UL << 30) - 1)) { |
| 74 | /* FIXME: fp is cheating! */ |
| 75 | double nsec = (double)t.ts.tv_nsec * mult; |
| 76 | |
| 77 | res.ts.tv_sec = nsec / 1000000000.0; |
| 78 | res.ts.tv_nsec = nsec - (res.ts.tv_sec * 1000000000.0); |
| 79 | } else { |
| 80 | uint64_t nsec = t.ts.tv_nsec * mult; |
| 81 | |
| 82 | res.ts.tv_nsec = nsec % 1000000000; |
| 83 | res.ts.tv_sec = nsec / 1000000000; |
| 84 | } |
| 85 | res.ts.tv_sec += TIMEREL_CHECK(t).ts.tv_sec * mult; |
| 86 | return TIMEREL_CHECK(res); |
| 87 | } |
| 88 | |
| 89 | struct timespec time_check_(struct timespec t, const char *abortstr) |
| 90 | { |
no outgoing calls