diff options
author | Ron Yorston <rmy@pobox.com> | 2017-01-18 10:44:58 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-01-18 10:44:58 +0000 |
commit | c6ec14a39aa1a6fe98fe4bec1ee3d545be9d5410 (patch) | |
tree | 0418751d350ea0190c4f1516d4bc8bc4e9350bcf /win32 | |
parent | 373ca863f65de0c572faf80fab5586755d073fc8 (diff) | |
download | busybox-w32-c6ec14a39aa1a6fe98fe4bec1ee3d545be9d5410.tar.gz busybox-w32-c6ec14a39aa1a6fe98fe4bec1ee3d545be9d5410.tar.bz2 busybox-w32-c6ec14a39aa1a6fe98fe4bec1ee3d545be9d5410.zip |
win32: implement nanosleep and enable float sleep by default
Don't expect sleeping for fractions of a second to be very accurate.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 23ca5d3dd..1170cd9d5 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -452,6 +452,24 @@ unsigned int sleep (unsigned int seconds) | |||
452 | return 0; | 452 | return 0; |
453 | } | 453 | } |
454 | 454 | ||
455 | int nanosleep(const struct timespec *req, struct timespec *rem) | ||
456 | { | ||
457 | if (req->tv_nsec < 0 || 1000000000 <= req->tv_nsec) { | ||
458 | errno = EINVAL; | ||
459 | return -1; | ||
460 | } | ||
461 | |||
462 | Sleep(req->tv_sec*1000 + req->tv_nsec/1000000); | ||
463 | |||
464 | /* Sleep is not interruptible. So there is no remaining delay. */ | ||
465 | if (rem != NULL) { | ||
466 | rem->tv_sec = 0; | ||
467 | rem->tv_nsec = 0; | ||
468 | } | ||
469 | |||
470 | return 0; | ||
471 | } | ||
472 | |||
455 | /* | 473 | /* |
456 | * Windows' mktemp returns NULL on error whereas POSIX always returns the | 474 | * Windows' mktemp returns NULL on error whereas POSIX always returns the |
457 | * template and signals an error by making it an empty string. | 475 | * template and signals an error by making it an empty string. |