diff options
author | Quincey Koziol <koziol@koziol.gov> | 2020-06-27 14:47:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@koziol.gov> | 2020-06-27 14:47:55 (GMT) |
commit | 7bdab523b3eb8eb5a83c3a6eca622171b88856ab (patch) | |
tree | 7350a40fd00056ca37125f10efc2f799e2aaadba /src | |
parent | e767f44e953047297fece364218147c908e8b585 (diff) | |
download | hdf5-7bdab523b3eb8eb5a83c3a6eca622171b88856ab.zip hdf5-7bdab523b3eb8eb5a83c3a6eca622171b88856ab.tar.gz hdf5-7bdab523b3eb8eb5a83c3a6eca622171b88856ab.tar.bz2 |
Refactor code to remove remaining checks for H5_HAVE_GETTIMEOFDAY scattered around in various places. Also clean up iopipe.c.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5system.c | 32 | ||||
-rw-r--r-- | src/H5timer.c | 41 |
2 files changed, 41 insertions, 32 deletions
diff --git a/src/H5system.c b/src/H5system.c index 7f953d7..a918571 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -1461,38 +1461,6 @@ H5_nanosleep(uint64_t nanosec) FUNC_LEAVE_NOAPI_VOID } /* end H5_nanosleep() */ - -/*-------------------------------------------------------------------------- - * Function: H5_get_time - * - * Purpose: Get the current time, as the time of seconds after the UNIX epoch - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * October 05, 2016 - *-------------------------------------------------------------------------- - */ -double -H5_get_time(void) -{ -#ifdef H5_HAVE_GETTIMEOFDAY - struct timeval curr_time; -#endif /* H5_HAVE_GETTIMEOFDAY */ - double ret_value = (double)0.0f; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - -#ifdef H5_HAVE_GETTIMEOFDAY - HDgettimeofday(&curr_time, NULL); - - ret_value = (double)curr_time.tv_sec + ((double)curr_time.tv_usec / (double)1000000.0f); -#endif /* H5_HAVE_GETTIMEOFDAY */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5_get_time() */ - - #ifdef H5_HAVE_WIN32_API #define H5_WIN32_ENV_VAR_BUFFER_SIZE 32767 diff --git a/src/H5timer.c b/src/H5timer.c index 8603b1c..180c774 100644 --- a/src/H5timer.c +++ b/src/H5timer.c @@ -215,6 +215,47 @@ H5_now_usec(void) } /* end H5_now_usec() */ +/*-------------------------------------------------------------------------- + * Function: H5_get_time + * + * Purpose: Get the current time, as the time of seconds after the UNIX epoch + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * October 05, 2016 + *-------------------------------------------------------------------------- + */ +double +H5_get_time(void) +{ + double ret_value = (double)0.0f; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#if defined(H5_HAVE_CLOCK_GETTIME) + { + struct timespec ts; + + HDclock_gettime(CLOCK_MONOTONIC, &ts); + ret_value = (double)ts.tv_sec + ((double)ts.tv_nsec / (double)1000000000.0f); + } +#elif defined(H5_HAVE_GETTIMEOFDAY) + { + struct timeval now_tv; + + HDgettimeofday(&now_tv, NULL); + ret_value = (double)now_tv.tv_sec + ((double)now_tv.tv_usec / (double)1000000.0f); + } +#else /* H5_HAVE_GETTIMEOFDAY */ + ret_value = (double)HDtime(NULL); +#endif /* H5_HAVE_GETTIMEOFDAY */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5_get_time() */ + + + /*------------------------------------------------------------------------- * Function: H5__timer_get_timevals * |