Lines Matching refs:ts
51 struct timespec ts; in now() local
53 assert_se(clock_gettime(map_clock_id(clock_id), &ts) == 0); in now()
55 return timespec_load(&ts); in now()
59 struct timespec ts; in now_nsec() local
61 assert_se(clock_gettime(map_clock_id(clock_id), &ts) == 0); in now_nsec()
63 return timespec_load_nsec(&ts); in now_nsec()
66 dual_timestamp* dual_timestamp_get(dual_timestamp *ts) { in dual_timestamp_get() argument
67 assert(ts); in dual_timestamp_get()
69 ts->realtime = now(CLOCK_REALTIME); in dual_timestamp_get()
70 ts->monotonic = now(CLOCK_MONOTONIC); in dual_timestamp_get()
72 return ts; in dual_timestamp_get()
75 triple_timestamp* triple_timestamp_get(triple_timestamp *ts) { in triple_timestamp_get() argument
76 assert(ts); in triple_timestamp_get()
78 ts->realtime = now(CLOCK_REALTIME); in triple_timestamp_get()
79 ts->monotonic = now(CLOCK_MONOTONIC); in triple_timestamp_get()
80 ts->boottime = now(CLOCK_BOOTTIME); in triple_timestamp_get()
82 return ts; in triple_timestamp_get()
126 dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) { in dual_timestamp_from_realtime() argument
127 assert(ts); in dual_timestamp_from_realtime()
130 ts->realtime = ts->monotonic = u; in dual_timestamp_from_realtime()
131 return ts; in dual_timestamp_from_realtime()
134 ts->realtime = u; in dual_timestamp_from_realtime()
135 ts->monotonic = map_clock_usec(u, CLOCK_REALTIME, CLOCK_MONOTONIC); in dual_timestamp_from_realtime()
136 return ts; in dual_timestamp_from_realtime()
139 triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u) { in triple_timestamp_from_realtime() argument
142 assert(ts); in triple_timestamp_from_realtime()
145 ts->realtime = ts->monotonic = ts->boottime = u; in triple_timestamp_from_realtime()
146 return ts; in triple_timestamp_from_realtime()
151 ts->realtime = u; in triple_timestamp_from_realtime()
152 ts->monotonic = map_clock_usec_internal(u, nowr, now(CLOCK_MONOTONIC)); in triple_timestamp_from_realtime()
153 ts->boottime = map_clock_usec_internal(u, nowr, now(CLOCK_BOOTTIME)); in triple_timestamp_from_realtime()
155 return ts; in triple_timestamp_from_realtime()
158 dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) { in dual_timestamp_from_monotonic() argument
159 assert(ts); in dual_timestamp_from_monotonic()
162 ts->realtime = ts->monotonic = USEC_INFINITY; in dual_timestamp_from_monotonic()
163 return ts; in dual_timestamp_from_monotonic()
166 ts->monotonic = u; in dual_timestamp_from_monotonic()
167 ts->realtime = map_clock_usec(u, CLOCK_MONOTONIC, CLOCK_REALTIME); in dual_timestamp_from_monotonic()
168 return ts; in dual_timestamp_from_monotonic()
171 dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u) { in dual_timestamp_from_boottime() argument
175 ts->realtime = ts->monotonic = USEC_INFINITY; in dual_timestamp_from_boottime()
176 return ts; in dual_timestamp_from_boottime()
180 ts->monotonic = map_clock_usec_internal(u, nowm, now(CLOCK_MONOTONIC)); in dual_timestamp_from_boottime()
181 ts->realtime = map_clock_usec_internal(u, nowm, now(CLOCK_REALTIME)); in dual_timestamp_from_boottime()
182 return ts; in dual_timestamp_from_boottime()
185 usec_t triple_timestamp_by_clock(triple_timestamp *ts, clockid_t clock) { in triple_timestamp_by_clock() argument
191 return ts->realtime; in triple_timestamp_by_clock()
194 return ts->monotonic; in triple_timestamp_by_clock()
198 return ts->boottime; in triple_timestamp_by_clock()
205 usec_t timespec_load(const struct timespec *ts) { in timespec_load() argument
206 assert(ts); in timespec_load()
208 if (ts->tv_sec < 0 || ts->tv_nsec < 0) in timespec_load()
211 if ((usec_t) ts->tv_sec > (UINT64_MAX - (ts->tv_nsec / NSEC_PER_USEC)) / USEC_PER_SEC) in timespec_load()
215 (usec_t) ts->tv_sec * USEC_PER_SEC + in timespec_load()
216 (usec_t) ts->tv_nsec / NSEC_PER_USEC; in timespec_load()
219 nsec_t timespec_load_nsec(const struct timespec *ts) { in timespec_load_nsec() argument
220 assert(ts); in timespec_load_nsec()
222 if (ts->tv_sec < 0 || ts->tv_nsec < 0) in timespec_load_nsec()
225 if ((nsec_t) ts->tv_sec >= (UINT64_MAX - ts->tv_nsec) / NSEC_PER_SEC) in timespec_load_nsec()
228 return (nsec_t) ts->tv_sec * NSEC_PER_SEC + (nsec_t) ts->tv_nsec; in timespec_load_nsec()
231 struct timespec *timespec_store(struct timespec *ts, usec_t u) { in timespec_store() argument
232 assert(ts); in timespec_store()
236 ts->tv_sec = (time_t) -1; in timespec_store()
237 ts->tv_nsec = -1L; in timespec_store()
238 return ts; in timespec_store()
241 ts->tv_sec = (time_t) (u / USEC_PER_SEC); in timespec_store()
242 ts->tv_nsec = (long) ((u % USEC_PER_SEC) * NSEC_PER_USEC); in timespec_store()
244 return ts; in timespec_store()
247 struct timespec *timespec_store_nsec(struct timespec *ts, nsec_t n) { in timespec_store_nsec() argument
248 assert(ts); in timespec_store_nsec()
252 ts->tv_sec = (time_t) -1; in timespec_store_nsec()
253 ts->tv_nsec = -1L; in timespec_store_nsec()
254 return ts; in timespec_store_nsec()
257 ts->tv_sec = (time_t) (n / NSEC_PER_SEC); in timespec_store_nsec()
258 ts->tv_nsec = (long) (n % NSEC_PER_SEC); in timespec_store_nsec()
260 return ts; in timespec_store_nsec()
1459 struct timespec ts; in clock_supported() local
1471 return clock_gettime(clock, &ts) >= 0; in clock_supported()