Adds an implementation for nanosleep on Windows (#483)

* Adds an implementation for nanosleep on Windows

* Committing clang-format changes

* Fix insane formatter issue

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Dana Robinson 2021-03-22 03:55:40 -07:00 committed by GitHub
parent 03864c675c
commit 05bc1905cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 30 deletions

View File

@ -3843,7 +3843,7 @@ H5T__conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
size_t half_size; /*half the type size */
size_t olap; /*num overlapping elements */
uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t dbuf[64] = {0}; /*temp destination buffer */
size_t first;
ssize_t sfirst; /*a signed version of `first' */
@ -4286,7 +4286,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
size_t olap; /*num overlapping elements */
ssize_t bitno = 0; /*bit number */
uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t dbuf[64] = {0}; /*temp destination buffer */
uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/
@ -8401,7 +8401,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
size_t tsize; /*type size for swapping bytes */
size_t olap; /*num overlapping elements */
uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t dbuf[64] = {0}; /*temp destination buffer */
uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/
@ -9027,7 +9027,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
size_t tsize; /*type size for swapping bytes */
size_t olap; /*num overlapping elements */
uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t * src_rev = NULL; /*order-reversed source buffer */
uint8_t dbuf[64] = {0}; /*temp destination buffer */
uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/

View File

@ -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
HDnanosleep(&sleeptime, NULL);
/* 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));
#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() */

View File

@ -174,7 +174,6 @@ H5_DLL int Wflock(int fd, int operation);
H5_DLL char * Wgetlogin(void);
H5_DLL int c99_snprintf(char *str, size_t size, const char *format, ...);
H5_DLL int c99_vsnprintf(char *str, size_t size, const char *format, va_list ap);
H5_DLL int Wnanosleep(const struct timespec *req, struct timespec *rem);
H5_DLL herr_t H5_expand_windows_env_vars(char **env_var);
H5_DLL wchar_t *H5_get_utf16_str(const char *s);
H5_DLL int Wopen_utf8(const char *path, int oflag, ...);