aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-01-18 10:44:58 +0000
committerRon Yorston <rmy@pobox.com>2017-01-18 10:44:58 +0000
commitc6ec14a39aa1a6fe98fe4bec1ee3d545be9d5410 (patch)
tree0418751d350ea0190c4f1516d4bc8bc4e9350bcf
parent373ca863f65de0c572faf80fab5586755d073fc8 (diff)
downloadbusybox-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.
-rw-r--r--configs/mingw32_defconfig2
-rw-r--r--configs/mingw64_defconfig2
-rw-r--r--include/mingw.h2
-rw-r--r--win32/mingw.c18
4 files changed, 22 insertions, 2 deletions
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig
index a9fa2ee4b..2d0e24891 100644
--- a/configs/mingw32_defconfig
+++ b/configs/mingw32_defconfig
@@ -279,7 +279,7 @@ CONFIG_SEQ=y
279CONFIG_SHUF=y 279CONFIG_SHUF=y
280CONFIG_SLEEP=y 280CONFIG_SLEEP=y
281CONFIG_FEATURE_FANCY_SLEEP=y 281CONFIG_FEATURE_FANCY_SLEEP=y
282# CONFIG_FEATURE_FLOAT_SLEEP is not set 282CONFIG_FEATURE_FLOAT_SLEEP=y
283CONFIG_SORT=y 283CONFIG_SORT=y
284CONFIG_FEATURE_SORT_BIG=y 284CONFIG_FEATURE_SORT_BIG=y
285CONFIG_SPLIT=y 285CONFIG_SPLIT=y
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig
index 085158971..7ee4e58f9 100644
--- a/configs/mingw64_defconfig
+++ b/configs/mingw64_defconfig
@@ -279,7 +279,7 @@ CONFIG_SEQ=y
279CONFIG_SHUF=y 279CONFIG_SHUF=y
280CONFIG_SLEEP=y 280CONFIG_SLEEP=y
281CONFIG_FEATURE_FANCY_SLEEP=y 281CONFIG_FEATURE_FANCY_SLEEP=y
282# CONFIG_FEATURE_FLOAT_SLEEP is not set 282CONFIG_FEATURE_FLOAT_SLEEP=y
283CONFIG_SORT=y 283CONFIG_SORT=y
284CONFIG_FEATURE_SORT_BIG=y 284CONFIG_FEATURE_SORT_BIG=y
285CONFIG_SPLIT=y 285CONFIG_SPLIT=y
diff --git a/include/mingw.h b/include/mingw.h
index 04700963c..6d4d2b31c 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -341,6 +341,8 @@ struct timespec {
341}; 341};
342#endif 342#endif
343 343
344int nanosleep(const struct timespec *req, struct timespec *rem);
345
344/* 346/*
345 * sys/wait.h 347 * sys/wait.h
346 */ 348 */
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
455int 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.