aux/util: Add time_ns_to_s and time_s_to_ns

This commit is contained in:
Ryan Pavlik committed 2019-03-25 12:28:54 -05:00
1 parent 992c176143
commit 94cd1908db
1 file changed
+33
+33
View File
@@ -22,9 +22,42 @@ extern "C" {
* Integer timestamp type.
*
* @see time_state
* @see time_duration_ns
*/
typedef int64_t timepoint_ns;
/*!
* Integer duration type in nanoseconds.
*
* Logical type of timepoint differences.
*
* @see time_state
* @see timepoint_ns
*/
typedef int64_t time_duration_ns;
/*!
* Convert nanoseconds duration to float seconds.
*
* @see timepoint_ns
*/
static inline float
time_ns_to_s(time_duration_ns ns)
{
return (float)(ns) / 1000000000.0f;
}
/*!
* Convert float seconds to nanoseconds.
*
* @see timepoint_ns
*/
static inline time_duration_ns
time_s_to_ns(float duration)
{
return (time_duration_ns)(duration * 1000000000.0f);
}
/*!
* @struct time_state util/u_time.h
* @brief Time-keeping state structure.