The open source OpenXR runtime
0
fork

Configure Feed

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

aux/util: use int64_t to represent timestamps in u_time

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

authored by

Simon Zeni and committed by
Rylie Pavlik
bc131e65 54fe2c0e

+15 -15
+7 -7
src/xrt/auxiliary/util/u_time.cpp
··· 39 39 */ 40 40 41 41 extern "C" struct time_state * 42 - time_state_create(uint64_t offset) 42 + time_state_create(int64_t offset) 43 43 { 44 44 time_state *state = new (std::nothrow) time_state; 45 45 if (!state) { ··· 84 84 assert(state != NULL); 85 85 assert(out != NULL); 86 86 87 - uint64_t ns = time_state_ts_to_monotonic_ns(state, timestamp); 87 + int64_t ns = time_state_ts_to_monotonic_ns(state, timestamp); 88 88 89 89 out->tv_sec = ns / (U_1_000_000_000); 90 90 out->tv_nsec = ns % (U_1_000_000_000); ··· 96 96 assert(state != NULL); 97 97 assert(timespecTime != NULL); 98 98 99 - uint64_t ns = 0; 99 + int64_t ns = 0; 100 100 ns += timespecTime->tv_nsec; 101 101 ns += timespecTime->tv_sec * U_1_000_000_000; 102 102 ··· 104 104 } 105 105 106 106 extern "C" timepoint_ns 107 - time_state_monotonic_to_ts_ns(struct time_state const *state, uint64_t monotonic_ns) 107 + time_state_monotonic_to_ts_ns(struct time_state const *state, int64_t monotonic_ns) 108 108 { 109 109 assert(state != NULL); 110 110 111 111 return monotonic_ns - state->offset; 112 112 } 113 113 114 - extern "C" uint64_t 114 + extern "C" int64_t 115 115 time_state_ts_to_monotonic_ns(struct time_state const *state, timepoint_ns timestamp) 116 116 { 117 117 assert(state != NULL); ··· 126 126 assert(state != NULL); 127 127 assert(out_qpc_ticks != NULL); 128 128 129 - uint64_t ns = time_state_ts_to_monotonic_ns(state, timestamp); 129 + int64_t ns = time_state_ts_to_monotonic_ns(state, timestamp); 130 130 131 131 out_qpc_ticks->QuadPart = ns / os_ns_per_qpc_tick_get(); 132 132 } ··· 137 137 assert(state != NULL); 138 138 assert(qpc_ticks != NULL); 139 139 140 - uint64_t ns = qpc_ticks->QuadPart * os_ns_per_qpc_tick_get(); 140 + int64_t ns = qpc_ticks->QuadPart * os_ns_per_qpc_tick_get(); 141 141 142 142 return time_state_monotonic_to_ts_ns(state, ns); 143 143 }
+8 -8
src/xrt/auxiliary/util/u_time.h
··· 136 136 * @ingroup aux_util 137 137 */ 138 138 static inline bool 139 - time_is_within_range_of_each_other(timepoint_ns a, timepoint_ns b, uint64_t range) 139 + time_is_within_range_of_each_other(timepoint_ns a, timepoint_ns b, int64_t range) 140 140 { 141 - int64_t t = (int64_t)a - (int64_t)b; 142 - return (-(int64_t)range < t) && (t < (int64_t)range); 141 + int64_t t = a - b; 142 + return (-range < t) && (t < range); 143 143 } 144 144 145 145 /*! ··· 161 161 * @ingroup aux_util 162 162 */ 163 163 static inline bool 164 - time_is_less_then_or_within_range(timepoint_ns a, timepoint_ns b, uint64_t range) 164 + time_is_less_then_or_within_range(timepoint_ns a, timepoint_ns b, int64_t range) 165 165 { 166 166 return a < b || time_is_within_range_of_each_other(a, b, range); 167 167 } ··· 185 185 * @ingroup aux_util 186 186 */ 187 187 static inline bool 188 - time_is_greater_then_or_within_range(timepoint_ns a, timepoint_ns b, uint64_t range) 188 + time_is_greater_then_or_within_range(timepoint_ns a, timepoint_ns b, int64_t range) 189 189 { 190 190 return a > b || time_is_within_range_of_each_other(a, b, range); 191 191 } ··· 220 220 * @ingroup aux_util 221 221 */ 222 222 struct time_state * 223 - time_state_create(uint64_t offset); 223 + time_state_create(int64_t offset); 224 224 225 225 226 226 /*! ··· 295 295 * @ingroup aux_util 296 296 */ 297 297 timepoint_ns 298 - time_state_monotonic_to_ts_ns(struct time_state const *state, uint64_t monotonic_ns); 298 + time_state_monotonic_to_ts_ns(struct time_state const *state, int64_t monotonic_ns); 299 299 300 300 /*! 301 301 * Convert a adjusted integer timestamp to an monotonic system time (such as ··· 306 306 * @public @memberof time_state 307 307 * @ingroup aux_util 308 308 */ 309 - uint64_t 309 + int64_t 310 310 time_state_ts_to_monotonic_ns(struct time_state const *state, timepoint_ns timestamp); 311 311 312 312 #if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN)