search for: timespec_to_timeval

Displaying 1 result from an estimated 1 matches for "timespec_to_timeval".

2003 Mar 17
3
nanosleep() replacement
...nbsd-compat/bsd-misc.c 2003-03-16 14:49:58.740480006 -0800 @@ -135,3 +135,34 @@ } #endif +#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) +int nanosleep(const struct timespec *req, struct timespec *rem) +{ + int rc; + extern int errno; + struct timeval tsave, ttmp, time2wait; + + TIMESPEC_TO_TIMEVAL(&time2wait, req) + + gettimeofday(&tsave, NULL); + rc = select(0, NULL, NULL, NULL, &time2wait); + if (rc) { + gettimeofday (&ttmp, NULL); + ttmp.tv_sec -= tsave.tv_sec; + ttmp.tv_usec -= tsave.tv_usec; + tsave.tv_sec = (time2wait.tv_sec - ttmp.tv_sec); + tsave.tv_usec = (t...