Monado OpenXR Runtime
os_time.h File Reference

Wrapper around OS native time functions. More...

#include "xrt/xrt_config_os.h"
#include "xrt/xrt_compiler.h"
#include "util/u_time.h"
#include <time.h>
#include <sys/time.h>
Include dependency graph for os_time.h:

Go to the source code of this file.

Data Structures

struct  os_precise_sleeper
 

Macros

#define XRT_HAVE_TIMESPEC
 
#define XRT_HAVE_TIMEVAL
 
#define OS_NS_PER_USEC   (1000)
 

Functions

static int64_t os_monotonic_get_ns (void)
 Return a monotonic clock in nanoseconds. More...
 
static void os_nanosleep (int64_t nsec)
 Sleep the given number of nanoseconds. More...
 
static int64_t os_timespec_to_ns (const struct timespec *spec)
 Convert a timespec struct to nanoseconds. More...
 
static void os_ns_to_timespec (int64_t ns, struct timespec *spec)
 Convert an nanosecond integer to a timespec struct. More...
 
static int64_t os_timeval_to_ns (struct timeval *val)
 Convert a timeval struct to nanoseconds. More...
 
static int64_t os_realtime_get_ns (void)
 Return a realtime clock in nanoseconds (Linux-only) More...
 
static int64_t os_ns_per_qpc_tick_get (void)
 Return a qpc freq in nanoseconds. More...
 
static void os_precise_sleeper_init (struct os_precise_sleeper *ops)
 
static void os_precise_sleeper_deinit (struct os_precise_sleeper *ops)
 
static void os_precise_sleeper_nanosleep (struct os_precise_sleeper *ops, int32_t nsec)
 

Detailed Description

Wrapper around OS native time functions.

These should be preferred over directly using native OS time functions in potentially-portable code. Additionally, in most cases these are preferred over timepoints from time_state for general usage in drivers, etc.

Author
Drew DeVault sir@c.nosp@m.mpwn.nosp@m..com
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m
Rylie Pavlik rylie.nosp@m..pav.nosp@m.lik@c.nosp@m.olla.nosp@m.bora..nosp@m.com