summaryrefslogtreecommitdiffstats
path: root/src/H5system.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5system.c')
-rw-r--r--src/H5system.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/H5system.c b/src/H5system.c
index 53307a8..1d94816 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -655,25 +655,6 @@ Wflock(int fd, int operation) {
return 0;
} /* end Wflock() */
-/*--------------------------------------------------------------------------
- * Function: Wnanosleep
- *
- * Purpose: Sleep for a given # of nanoseconds (Windows version)
- *
- * Return: SUCCEED/FAIL
- *
- * Programmer: Dana Robinson
- * Fall 2016
- *--------------------------------------------------------------------------
- */
-int
-Wnanosleep(const struct timespec *req, struct timespec *rem)
-{
- /* XXX: Currently just a placeholder */
- return 0;
-
-} /* end Wnanosleep() */
-
/*-------------------------------------------------------------------------
* Function: Wllround, Wllroundf, Wlround, Wlroundf, Wround, Wroundf
*
@@ -1052,6 +1033,9 @@ done:
*
* Purpose: Sleep for a given # of nanoseconds
*
+ * Note that commodity hardware is probably going to have a
+ * resolution of milliseconds, not nanoseconds.
+ *
* Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
@@ -1061,15 +1045,26 @@ done:
void
H5_nanosleep(uint64_t nanosec)
{
- struct timespec sleeptime; /* Struct to hold time to sleep */
-
FUNC_ENTER_NOAPI_NOINIT_NOERR
- /* Set up time to sleep */
- sleeptime.tv_sec = 0;
- sleeptime.tv_nsec = (long)nanosec;
+#ifdef H5_HAVE_WIN32_API
+
+ /* On Windows, Sleep() is in milliseconds. Passing 0 to Sleep()
+ * causes the thread to relinquish the rest of its time slice.
+ */
+ Sleep(nanosec / (1000 * 1000));
- HDnanosleep(&sleeptime, NULL);
+#else
+ {
+ struct timespec sleeptime; /* Struct to hold time to sleep */
+
+ /* Set up time to sleep */
+ sleeptime.tv_sec = 0;
+ sleeptime.tv_nsec = (long)nanosec;
+
+ HDnanosleep(&sleeptime, NULL);
+ }
+#endif
FUNC_LEAVE_NOAPI_VOID
} /* end H5_nanosleep() */