25 #define XRT_HAVE_TIMESPEC 26 #define XRT_HAVE_TIMEVAL 28 #elif defined(XRT_DOXYGEN) 30 #define XRT_HAVE_TIMESPEC 31 #define XRT_HAVE_TIMEVAL 34 #error "No time support on non-Linux platforms yet." 63 os_nanosleep(
long nsec)
66 struct timespec spec = {
70 nanosleep(&spec, NULL);
74 #ifdef XRT_HAVE_TIMESPEC 79 static inline uint64_t
80 os_timespec_to_ns(
struct timespec *spec)
83 ns += (uint64_t)spec->tv_sec * 1000 * 1000 * 1000;
84 ns += (uint64_t)spec->tv_nsec;
87 #endif // XRT_HAVE_TIMESPEC 90 #ifdef XRT_HAVE_TIMEVAL 95 static inline uint64_t
96 os_timeval_to_ns(
struct timeval *val)
99 ns += (uint64_t)val->tv_sec * 1000 * 1000 * 1000;
100 ns += (uint64_t)val->tv_usec * 1000;
103 #endif // XRT_HAVE_TIMEVAL 110 static inline uint64_t
111 os_monotonic_get_ns(
void)
115 int ret = clock_gettime(CLOCK_MONOTONIC, &ts);
120 return os_timespec_to_ns(&ts);
Auto detect OS and certain features.
Header holding common defines.