Add hg_time_from_ms() for making an hg_time_t from an integer duration
in milliseconds.  The UCX plugin will use this.
@@ -97,6 +97,16 @@ hg_time_to_double(hg_time_t tv);
static HG_UTIL_INLINE hg_time_t
hg_time_from_double(double d);
+/**
+ * Convert (integer) milliseconds to hg_time_t.
+ *
+ * \param ms [IN] time in milliseconds
+ *
+ * \return Converted time structure
+ */
+static HG_UTIL_INLINE hg_time_t
+hg_time_from_ms(unsigned int ms);
+
/**
* Compare time values.
*
@@ -314,6 +324,16 @@ hg_time_to_double(hg_time_t tv)
#endif
}
+static HG_UTIL_INLINE hg_time_t
+hg_time_from_ms(unsigned int ms)
+{
+#if defined(HG_UTIL_HAS_TIME_H) && defined(HG_UTIL_HAS_CLOCK_GETTIME)
+ return (hg_time_t){.tv_sec = ms / 1000, .tv_nsec = 1000 * 1000 * ms};
+#else
+ return (hg_time_t){.tv_sec = ms / 1000, .tv_usec = 1000 * ms};
+#endif
+}
+
/*---------------------------------------------------------------------------*/
static HG_UTIL_INLINE hg_time_t
hg_time_from_double(double d)
