summaryrefslogtreecommitdiffstats
path: root/src/H5timer.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2020-06-27 14:47:55 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2020-06-27 14:47:55 (GMT)
commit7bdab523b3eb8eb5a83c3a6eca622171b88856ab (patch)
tree7350a40fd00056ca37125f10efc2f799e2aaadba /src/H5timer.c
parente767f44e953047297fece364218147c908e8b585 (diff)
downloadhdf5-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/H5timer.c')
-rw-r--r--src/H5timer.c41
1 files changed, 41 insertions, 0 deletions
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
*