Monado OpenXR Runtime
u_time.h File Reference

Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution. More...

#include "xrt/xrt_compiler.h"
#include <stdint.h>
#include <time.h>
Include dependency graph for u_time.h:

Go to the source code of this file.

Macros

#define U_1_000_000_000   (1000 * 1000 * 1000)
 Helper define to make code more readable. More...
 
#define U_TIME_1S_IN_NS   U_1_000_000_000
 The number of nanoseconds in a second. More...
 
#define U_TIME_1MS_IN_NS   (1000 * 1000)
 The number of nanoseconds in a millisecond. More...
 
#define U_TIME_HALF_MS_IN_NS   (U_TIME_1MS_IN_NS / 2)
 The number of nanoseconds in half a millisecond. More...
 

Typedefs

typedef int64_t timepoint_ns
 Integer timestamp type. More...
 
typedef int64_t time_duration_ns
 Integer duration type in nanoseconds. More...
 

Functions

static double time_ns_to_s (time_duration_ns ns)
 Convert nanoseconds duration to double seconds. More...
 
static time_duration_ns time_s_to_ns (double duration)
 Convert float seconds to nanoseconds. More...
 
static double time_ns_to_ms_f (time_duration_ns ns)
 Convert nanoseconds to double float milliseconds, useful for printing. More...
 
static timepoint_ns time_ms_f_to_ns (double ms_f)
 Convert double float milliseconds to nanoseconds, human comprehensible config inputs. More...
 
static bool time_is_within_range_of_each_other (timepoint_ns a, timepoint_ns b, int64_t range)
 Checks if two timepoints are with a certain range of each other. More...
 
static bool time_is_within_half_ms (timepoint_ns a, timepoint_ns b)
 Checks if two timepoints are with half a millisecond of each other. More...
 
static bool time_is_less_then_or_within_range (timepoint_ns a, timepoint_ns b, int64_t range)
 Fuzzy comparisons. More...
 
static bool time_is_less_then_or_within_half_ms (timepoint_ns a, timepoint_ns b)
 Fuzzy comparisons. More...
 
static bool time_is_greater_then_or_within_range (timepoint_ns a, timepoint_ns b, int64_t range)
 Fuzzy comparisons. More...
 
static bool time_is_greater_then_or_within_half_ms (timepoint_ns a, timepoint_ns b)
 Fuzzy comparisons. More...
 

Detailed Description

Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.

Designed to suit the needs of OpenXR: you can and should use something simpler (like Portable Timekeeping) for most purposes that aren't in OpenXR interface code.

Author
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com
See also
time_state

Macro Definition Documentation

◆ U_1_000_000_000

#define U_1_000_000_000   (1000 * 1000 * 1000)

Helper define to make code more readable.

◆ U_TIME_1MS_IN_NS

#define U_TIME_1MS_IN_NS   (1000 * 1000)

The number of nanoseconds in a millisecond.

See also
timepoint_ns

◆ U_TIME_1S_IN_NS

#define U_TIME_1S_IN_NS   U_1_000_000_000

The number of nanoseconds in a second.

See also
timepoint_ns

◆ U_TIME_HALF_MS_IN_NS

#define U_TIME_HALF_MS_IN_NS   (U_TIME_1MS_IN_NS / 2)

The number of nanoseconds in half a millisecond.

See also
timepoint_ns