28 #define XRT_HAVE_TIMESPEC
29 #define XRT_HAVE_TIMEVAL
31 #elif defined(XRT_OS_WINDOWS)
32 #if defined(XRT_ENV_MINGW)
36 #define byte win_byte_override
43 #define XRT_HAVE_TIMESPEC
45 #elif defined(XRT_DOXYGEN)
47 #define XRT_HAVE_TIMESPEC
48 #define XRT_HAVE_TIMEVAL
51 #error "No time support on non-Linux platforms yet."
78 static inline uint64_t
128 #if defined(XRT_HAVE_TIMESPEC) || defined(XRT_DOXYGEN)
136 static inline uint64_t
149 #if defined(XRT_HAVE_TIMEVAL) || defined(XRT_DOXYGEN)
154 static inline uint64_t
158 #if defined(XRT_OS_LINUX) || defined(XRT_DOXYGEN)
164 static inline uint64_t
168 #if defined(XRT_OS_WINDOWS)
178 #if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN)
183 static inline int64_t
197 #if defined(XRT_OS_LINUX)
198 struct timespec spec;
201 nanosleep(&spec, NULL);
202 #elif defined(XRT_OS_WINDOWS)
209 #if defined(XRT_OS_WINDOWS)
219 #if defined(XRT_OS_WINDOWS)
220 ops->timer = CreateWaitableTimer(NULL, TRUE, NULL);
227 #if defined(XRT_OS_WINDOWS)
229 CloseHandle(ops->timer);
238 #if defined(XRT_OS_WINDOWS)
241 LARGE_INTEGER timeperiod;
242 timeperiod.QuadPart = -(nsec / 100);
243 if (SetWaitableTimer(ops->timer, &timeperiod, 0, NULL, NULL, FALSE)) {
245 WaitForSingleObject(ops->timer, INFINITE);
255 #if defined(XRT_OS_WINDOWS)
260 #if defined(XRT_HAVE_TIMESPEC)
261 static inline uint64_t
266 ns += (uint64_t)spec->tv_nsec;
279 #if defined(XRT_HAVE_TIMEVAL) && defined(XRT_OS_LINUX)
281 #define OS_NS_PER_USEC (1000)
283 static inline uint64_t
288 ns += (uint64_t)val->tv_usec * OS_NS_PER_USEC;
293 #if defined(XRT_OS_WINDOWS)
294 static inline int64_t
297 static int64_t ns_per_qpc_tick = 0;
298 if (ns_per_qpc_tick == 0) {
301 QueryPerformanceFrequency(&freq);
304 return ns_per_qpc_tick;
308 static inline uint64_t
311 #if defined(XRT_OS_LINUX)
313 int ret = clock_gettime(CLOCK_MONOTONIC, &ts);
319 #elif defined(XRT_OS_WINDOWS)
321 QueryPerformanceCounter(&qpc);
329 static inline uint64_t
333 int ret = clock_gettime(CLOCK_REALTIME, &ts);
static int64_t os_ns_per_qpc_tick_get(void)
Return a qpc freq in nanoseconds.
static uint64_t os_monotonic_get_ns(void)
Return a monotonic clock in nanoseconds.
Definition: os_time.h:309
static void os_nanosleep(int64_t nsec)
Sleep the given number of nanoseconds.
Definition: os_time.h:195
Definition: os_time.h:208
static void os_precise_sleeper_deinit(struct os_precise_sleeper *ops)
De-initialize members of os_precise_sleeper, and free resources, without actually freeing the given p...
Definition: os_time.h:225
static void os_precise_sleeper_init(struct os_precise_sleeper *ops)
Initialize members of os_precise_sleeper.
Definition: os_time.h:217
static void os_precise_sleeper_nanosleep(struct os_precise_sleeper *ops, int32_t nsec)
Sleep the given number of nanoseconds, trying harder to be precise.
Definition: os_time.h:236
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.
#define U_1_000_000_000
Helper define to make code more readable.
Definition: u_time.h:39
#define U_TIME_1MS_IN_NS
The number of nanoseconds in a millisecond.
Definition: u_time.h:54
Header holding common defines.
Auto detect OS and certain features.