The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/os: use int64_t to represent timestamps

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2298>

authored by

Simon Zeni and committed by
Rylie Pavlik
54fe2c0e 825de0ec

+21 -21
+17 -17
src/xrt/auxiliary/os/os_time.h
··· 75 75 * Return a monotonic clock in nanoseconds. 76 76 * @ingroup aux_os_time 77 77 */ 78 - static inline uint64_t 78 + static inline int64_t 79 79 os_monotonic_get_ns(void); 80 80 81 81 /*! ··· 133 133 * 134 134 * @ingroup aux_os_time_extra 135 135 */ 136 - static inline uint64_t 136 + static inline int64_t 137 137 os_timespec_to_ns(const struct timespec *spec); 138 138 139 139 /*! ··· 143 143 * @ingroup aux_os_time_extra 144 144 */ 145 145 static inline void 146 - os_ns_to_timespec(uint64_t ns, struct timespec *spec); 146 + os_ns_to_timespec(int64_t ns, struct timespec *spec); 147 147 #endif 148 148 149 149 #if defined(XRT_HAVE_TIMEVAL) || defined(XRT_DOXYGEN) ··· 151 151 * Convert a timeval struct to nanoseconds. 152 152 * @ingroup aux_os_time_extra 153 153 */ 154 - static inline uint64_t 154 + static inline int64_t 155 155 os_timeval_to_ns(struct timeval *val); 156 156 #endif 157 157 ··· 161 161 * 162 162 * @ingroup aux_os_time_extra 163 163 */ 164 - static inline uint64_t 164 + static inline int64_t 165 165 os_realtime_get_ns(void); 166 166 #endif 167 167 ··· 171 171 * 172 172 * @ingroup aux_os_time_extra 173 173 */ 174 - uint64_t 174 + int64_t 175 175 os_realtime_get_ns(void); 176 176 #endif 177 177 ··· 258 258 } 259 259 260 260 #if defined(XRT_HAVE_TIMESPEC) 261 - static inline uint64_t 261 + static inline int64_t 262 262 os_timespec_to_ns(const struct timespec *spec) 263 263 { 264 - uint64_t ns = 0; 265 - ns += (uint64_t)spec->tv_sec * U_1_000_000_000; 266 - ns += (uint64_t)spec->tv_nsec; 264 + int64_t ns = 0; 265 + ns += (int64_t)spec->tv_sec * U_1_000_000_000; 266 + ns += (int64_t)spec->tv_nsec; 267 267 return ns; 268 268 } 269 269 270 270 static inline void 271 - os_ns_to_timespec(uint64_t ns, struct timespec *spec) 271 + os_ns_to_timespec(int64_t ns, struct timespec *spec) 272 272 { 273 273 spec->tv_sec = (ns / U_1_000_000_000); 274 274 spec->tv_nsec = (ns % U_1_000_000_000); ··· 280 280 281 281 #define OS_NS_PER_USEC (1000) 282 282 283 - static inline uint64_t 283 + static inline int64_t 284 284 os_timeval_to_ns(struct timeval *val) 285 285 { 286 - uint64_t ns = 0; 287 - ns += (uint64_t)val->tv_sec * U_1_000_000_000; 288 - ns += (uint64_t)val->tv_usec * OS_NS_PER_USEC; 286 + int64_t ns = 0; 287 + ns += (int64_t)val->tv_sec * U_1_000_000_000; 288 + ns += (int64_t)val->tv_usec * OS_NS_PER_USEC; 289 289 return ns; 290 290 } 291 291 #endif // defined(XRT_HAVE_TIMEVAL) && defined(XRT_OS_LINUX) ··· 305 305 } 306 306 #endif // defined(XRT_OS_WINDOWS) 307 307 308 - static inline uint64_t 308 + static inline int64_t 309 309 os_monotonic_get_ns(void) 310 310 { 311 311 #if defined(XRT_OS_LINUX) ··· 326 326 } 327 327 328 328 #ifdef XRT_OS_LINUX 329 - static inline uint64_t 329 + static inline int64_t 330 330 os_realtime_get_ns(void) 331 331 { 332 332 struct timespec ts;
+2 -2
src/xrt/drivers/vive/vive_device.c
··· 882 882 * read packets with a noop function for 50ms. 883 883 */ 884 884 885 - uint64_t then_ns = os_monotonic_get_ns(); 886 - uint64_t future_50ms_ns = then_ns + U_TIME_1MS_IN_NS * (uint64_t)50; 885 + int64_t then_ns = os_monotonic_get_ns(); 886 + int64_t future_50ms_ns = then_ns + U_TIME_1MS_IN_NS * (int64_t)50; 887 887 888 888 while (future_50ms_ns > os_monotonic_get_ns() && os_thread_helper_is_running(&d->sensors_thread)) { 889 889 // Lock not held.
+2 -2
src/xrt/drivers/wmr/wmr_controller_base.c
··· 125 125 // comms timeout. Replies are usually in 10ms or so but the first can take longer 126 126 const int timeout_ms = 250; 127 127 const int timeout_ns = timeout_ms * U_TIME_1MS_IN_NS; 128 - uint64_t timeout_start = os_monotonic_get_ns(); 129 - uint64_t timeout_end_ns = timeout_start + timeout_ns; 128 + int64_t timeout_start = os_monotonic_get_ns(); 129 + int64_t timeout_end_ns = timeout_start + timeout_ns; 130 130 131 131 if (!wmr_controller_send_bytes(wcb, fw_cmd->buf, sizeof(fw_cmd->buf))) { 132 132 return -1;