Commit 1d9316bf authored by Joanne Hugé's avatar Joanne Hugé

WIP

parent 5b020a50
......@@ -68,7 +68,24 @@ static inline struct timespec add_ns(struct timespec t, int64_t ns) {
return ret;
}
static inline struct timespec sub_ns(struct timespec t, int64_t ns) {
struct timespec ret;
ret.tv_nsec = t.tv_nsec - ns;
ret.tv_sec = t.tv_sec;
if(ret.tv_nsec < 0) {
ret.tv_sec--;
ret.tv_nsec += NSECS_PER_SECOND;
}
return ret;
}
static void sleep_poll(struct timespec * next, struct timespec * current) {
struct timespec pre_next;
pre_next = sub_ns(next, 3000000);
clock_nanosleep(CLOCK_ID, TIMER_ABSTIME,
for(;;) {
clock_gettime(CLOCK_ID, current);
if( current->tv_sec > next->tv_sec || (current->tv_sec == next->tv_sec && current->tv_nsec >= next->tv_nsec) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment