blob: 6bf31bc35194a00db85191c04a1e22838c128990 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Elliott Hughes3503ce22013-11-05 13:28:36 -080028
Elliott Hughes52541ee2023-04-24 17:04:49 -070029#pragma once
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080030
Elliott Hughesd192dbe2023-05-25 11:17:56 -070031/**
32 * @file time.h
33 * @brief Clock and timer functionality.
34 */
35
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080036#include <sys/cdefs.h>
37#include <sys/time.h>
Dan Albertdfb5ce42014-07-09 22:51:34 +000038#include <xlocale.h>
David 'Digit' Turnerc1b44ec2012-10-17 19:10:11 +020039
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080040__BEGIN_DECLS
41
Elliott Hughesd192dbe2023-05-25 11:17:56 -070042/** Divisor to compute seconds from the result of a call to clock(). */
Elliott Hughes3503ce22013-11-05 13:28:36 -080043#define CLOCKS_PER_SEC 1000000
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080044
Elliott Hughesd192dbe2023-05-25 11:17:56 -070045/**
46 * The name of the current time zone's non-daylight savings (`tzname[0]`) and
47 * daylight savings (`tzname[1]`) variants. See tzset().
48 */
zijunzhaoe6202662023-01-03 23:32:18 +000049extern char* _Nonnull tzname[];
Elliott Hughesd192dbe2023-05-25 11:17:56 -070050
51/** Whether the current time zone ever uses daylight savings time. See tzset(). */
Elliott Hughesf47514d2016-07-19 13:56:46 -070052extern int daylight;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070053
54/** The difference in seconds between UTC and the current time zone. See tzset(). */
Elliott Hughesf47514d2016-07-19 13:56:46 -070055extern long int timezone;
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080056
Elliott Hughes61fb3fc2013-11-07 12:28:46 -080057struct sigevent;
58
Elliott Hughesd192dbe2023-05-25 11:17:56 -070059/**
60 * A "broken-down" time, useful for parsing/formatting times for human consumption.
61 */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080062struct tm {
Elliott Hughesd192dbe2023-05-25 11:17:56 -070063 /** Seconds, 0-60. (60 is a leap second.) */
Elliott Hughes3503ce22013-11-05 13:28:36 -080064 int tm_sec;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070065 /** Minutes, 0-59. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080066 int tm_min;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070067 /** Hours, 0-23. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080068 int tm_hour;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070069 /** Day of month, 1-31. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080070 int tm_mday;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070071 /** Month of year, 0-11. (Not 1-12!) */
Elliott Hughes3503ce22013-11-05 13:28:36 -080072 int tm_mon;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070073 /** Years since 1900. (So 2023 is 123, not 2023!) */
Elliott Hughes3503ce22013-11-05 13:28:36 -080074 int tm_year;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070075 /** Day of week, 0-6. (Sunday is 0, Saturday is 6.) */
Elliott Hughes3503ce22013-11-05 13:28:36 -080076 int tm_wday;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070077 /** Day of year, 0-365. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080078 int tm_yday;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070079 /** Daylight savings flag, positive for DST in effect, 0 for DST not in effect, and -1 for unknown. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080080 int tm_isdst;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070081 /** Offset from UTC (GMT) in seconds for this time. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080082 long int tm_gmtoff;
Elliott Hughesd192dbe2023-05-25 11:17:56 -070083 /** Name of the time zone for this time. */
zijunzhaoe6202662023-01-03 23:32:18 +000084 const char* _Nullable tm_zone;
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080085};
86
Elliott Hughesd192dbe2023-05-25 11:17:56 -070087/** Alternative name for `tm_zone` in `struct tm`. */
Elliott Hughes3503ce22013-11-05 13:28:36 -080088#define TM_ZONE tm_zone
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080089
Elliott Hughesd192dbe2023-05-25 11:17:56 -070090/**
91 * [time(2)](http://man7.org/linux/man-pages/man2/time.2.html) returns
92 * the number of seconds since the Unix epoch (1970-01-01 00:00:00 +0000).
93 *
94 * Returns the time in seconds on success, and returns -1 and sets `errno` on failure.
95 */
zijunzhaoe6202662023-01-03 23:32:18 +000096time_t time(time_t* _Nullable __t);
Elliott Hughesd192dbe2023-05-25 11:17:56 -070097
98/**
99 * [nanosleep(2)](http://man7.org/linux/man-pages/man2/nanosleep.2.html) sleeps
100 * for at least the given time (or until a signal arrives).
101 *
102 * Returns 0 on success, and returns -1 and sets `errno` on failure. If the sleep
103 * was interrupted by a signal, `errno` will be `EINTR` and `remainder` will be
104 * the amount of time remaining.
105 */
zijunzhaoe6202662023-01-03 23:32:18 +0000106int nanosleep(const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800107
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700108/**
109 * [asctime(3)](http://man7.org/linux/man-pages/man3/asctime.3p.html) formats
110 * the time `tm` as a string.
111 *
112 * Returns a pointer to a string on success, and returns NULL on failure.
113 *
114 * That string will be overwritten by later calls to this function.
115 *
116 * New code should prefer strftime().
117 */
zijunzhaoe6202662023-01-03 23:32:18 +0000118char* _Nullable asctime(const struct tm* _Nonnull __tm);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700119
120/**
121 * [asctime_r(3)](http://man7.org/linux/man-pages/man3/asctime_r.3p.html) formats
122 * the time `tm` as a string in the given buffer `buf`.
123 *
124 * Returns a pointer to a string on success, and returns NULL on failure.
125 *
126 * New code should prefer strftime().
127 */
zijunzhaoe6202662023-01-03 23:32:18 +0000128char* _Nullable asctime_r(const struct tm* _Nonnull __tm, char* _Nonnull __buf);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800129
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700130/**
131 * [difftime(3)](http://man7.org/linux/man-pages/man3/difftime.3.html) returns
132 * the difference between two times.
133 *
134 * Returns the difference in seconds.
135 */
Elliott Hughesff26a162017-08-17 22:34:21 +0000136double difftime(time_t __lhs, time_t __rhs);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700137
138/**
139 * [mktime(3)](http://man7.org/linux/man-pages/man3/mktime.3p.html) converts
140 * broken-down time `tm` into the number of seconds since the Unix epoch.
141 *
142 * Returns the time in seconds on success, and returns -1 and sets `errno` on failure.
143 */
zijunzhaoe6202662023-01-03 23:32:18 +0000144time_t mktime(struct tm* _Nonnull __tm);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800145
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700146/**
147 * [localtime(3)](http://man7.org/linux/man-pages/man3/localtime.3p.html) converts
148 * the number of seconds since the Unix epoch in `t` to a broken-down time, taking
149 * the device's timezone into account.
150 *
151 * That broken-down time will be overwritten by later calls to this function.
152 *
153 * Returns a pointer to a broken-down time on success, and returns null and sets `errno` on failure.
154 */
zijunzhaoe6202662023-01-03 23:32:18 +0000155struct tm* _Nullable localtime(const time_t* _Nonnull __t);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700156
157/**
158 * [localtime_r(3)](http://man7.org/linux/man-pages/man3/localtime_r.3p.html) converts
159 * the number of seconds since the Unix epoch in `t` to a broken-down time.
160 * That broken-down time will be written to the given struct `tm`.
161 *
162 * Returns a pointer to a broken-down time on success, and returns null and sets `errno` on failure.
163 */
zijunzhaoe6202662023-01-03 23:32:18 +0000164struct tm* _Nullable localtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800165
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700166/**
167 * Inverse of localtime().
168 */
169time_t timelocal(struct tm* _Nonnull __tm);
170
171/**
172 * [gmtime(3)](http://man7.org/linux/man-pages/man3/gmtime.3p.html) converts
173 * the number of seconds since the Unix epoch in `t` to a broken-down time, using
174 * UTC (historically also known as GMT).
175 *
176 * That broken-down time will be overwritten by later calls to this function.
177 *
178 * Returns a pointer to a broken-down time on success, and returns null and sets `errno` on failure.
179 */
zijunzhaoe6202662023-01-03 23:32:18 +0000180struct tm* _Nullable gmtime(const time_t* _Nonnull __t);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700181
182/**
183 * [gmtime_r(3)](http://man7.org/linux/man-pages/man3/gmtime_r.3p.html) converts
184 * the number of seconds since the Unix epoch in `t` to a broken-down time, using
185 * UTC (historically also known as GMT).
186 *
187 * That broken-down time will be written to the provided struct `tm`.
188 *
189 * Returns a pointer to a broken-down time on success, and returns null and sets `errno` on failure.
190 */
zijunzhaoe6202662023-01-03 23:32:18 +0000191struct tm* _Nullable gmtime_r(const time_t* _Nonnull __t, struct tm* _Nonnull __tm);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800192
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700193/**
194 * Inverse of gmtime().
195 */
196time_t timegm(struct tm* _Nonnull __tm);
197
198/**
199 * [strptime(3)](http://man7.org/linux/man-pages/man3/strptime.3.html) parses
200 * a string `s` assuming format `fmt` into broken-down time `tm`.
201 *
202 * Returns a pointer to the first character _not_ parsed, or null if no characters were parsed.
203 */
zijunzhaoe6202662023-01-03 23:32:18 +0000204char* _Nullable strptime(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm) __strftimelike(2);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700205
206/**
207 * Equivalent to strptime() on Android where only C/POSIX locales are available.
208 */
zijunzhaoe6202662023-01-03 23:32:18 +0000209char* _Nullable strptime_l(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm, locale_t _Nonnull __l) __strftimelike(2) __INTRODUCED_IN(28);
Josh Gao6cd9fb02016-09-23 14:06:05 -0700210
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700211/**
212 * [strftime(3)](http://man7.org/linux/man-pages/man3/strftime.3.html) formats
213 * a broken-down time `tm` into the buffer `buf` using format `fmt`.
214 *
215 * Returns a pointer to the first character _not_ parsed, or null if no characters were parsed.
216 */
zijunzhaoe6202662023-01-03 23:32:18 +0000217size_t strftime(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm) __strftimelike(3);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700218
219/**
220 * Equivalent to strftime() on Android where only C/POSIX locales are available.
221 */
zijunzhaoe6202662023-01-03 23:32:18 +0000222size_t strftime_l(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm, locale_t _Nonnull __l) __strftimelike(3) __INTRODUCED_IN(21);
zijunzhaoe6202662023-01-03 23:32:18 +0000223
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700224/**
225 * [ctime(3)](http://man7.org/linux/man-pages/man3/ctime.3p.html) formats
226 * the time `tm` as a string.
227 *
228 * Returns a pointer to a string on success, and returns NULL on failure.
229 *
230 * That string will be overwritten by later calls to this function.
231 *
232 * New code should prefer strftime().
233 */
zijunzhaoe6202662023-01-03 23:32:18 +0000234char* _Nullable ctime(const time_t* _Nonnull __t);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700235
236/**
237 * [ctime_r(3)](http://man7.org/linux/man-pages/man3/ctime.3p.html) formats
238 * the time `tm` as a string in the given buffer `buf`.
239 *
240 * Returns a pointer to a string on success, and returns NULL on failure.
241 *
242 * New code should prefer strftime().
243 */
zijunzhaoe6202662023-01-03 23:32:18 +0000244char* _Nullable ctime_r(const time_t* _Nonnull __t, char* _Nonnull __buf);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800245
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700246/**
247 * [tzset(3)](http://man7.org/linux/man-pages/man3/tzset.3.html) tells
248 * libc that the time zone has changed.
249 */
Elliott Hughes3b2096a2016-07-22 18:57:12 -0700250void tzset(void);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800251
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700252/**
253 * [clock(3)](http://man7.org/linux/man-pages/man3/clock.3.html)
254 * returns an approximation of CPU time used, equivalent to
255 * `clock_gettime(CLOCK_PROCESS_CPUTIME_ID)` but with more confusing
256 * units. Use `CLOCKS_PER_SEC` to convert the result to seconds.
257 *
258 * Returns the time in seconds on success, and returns -1 and sets `errno` on failure.
259 *
260 * New code should prefer `clock_gettime(CLOCK_PROCESS_CPUTIME_ID)`.
261 */
Elliott Hughes3b2096a2016-07-22 18:57:12 -0700262clock_t clock(void);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800263
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700264/**
265 * [clock_getcpuclockid(3)](http://man7.org/linux/man-pages/man3/clock_getcpuclockid.3.html)
266 * gets the clock id of the cpu-time clock for the given `pid`.
267 *
268 * Returns 0 on success, and returns -1 and returns an error number on failure.
269 */
zijunzhaoe6202662023-01-03 23:32:18 +0000270int clock_getcpuclockid(pid_t __pid, clockid_t* _Nonnull __clock) __INTRODUCED_IN(23);
Yabin Cuid5c65272014-11-26 14:04:26 -0800271
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700272/**
273 * [clock_getres(2)](http://man7.org/linux/man-pages/man2/clock_getres.2.html)
274 * gets the resolution of the given clock.
275 *
276 * Returns 0 on success, and returns -1 and returns an error number on failure.
277 */
zijunzhaoe6202662023-01-03 23:32:18 +0000278int clock_getres(clockid_t __clock, struct timespec* _Nullable __resolution);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700279
280/**
281 * [clock_gettime(2)](http://man7.org/linux/man-pages/man2/clock_gettime.2.html)
282 * gets the time according to the given clock.
283 *
284 * Returns 0 on success, and returns -1 and returns an error number on failure.
285 */
zijunzhaoe6202662023-01-03 23:32:18 +0000286int clock_gettime(clockid_t __clock, struct timespec* _Nonnull __ts);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700287
288/**
289 * [clock_nanosleep(2)](http://man7.org/linux/man-pages/man2/clock_nanosleep.2.html)
290 * sleeps for the given time as measured by the given clock.
291 *
292 * Returns 0 on success, and returns -1 and returns an error number on failure.
293 * If the sleep was interrupted by a signal, the return value will be `EINTR`
294 * and `remainder` will be the amount of time remaining.
295 */
zijunzhaoe6202662023-01-03 23:32:18 +0000296int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __request, struct timespec* _Nullable __remainder);
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700297
298/**
299 * [clock_settime(2)](http://man7.org/linux/man-pages/man2/clock_settime.2.html)
300 * sets the time for the given clock.
301 *
302 * Returns 0 on success, and returns -1 and returns an error number on failure.
303 */
zijunzhaoe6202662023-01-03 23:32:18 +0000304int clock_settime(clockid_t __clock, const struct timespec* _Nonnull __ts);
305
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700306/**
307 * [timer_create(2)](http://man7.org/linux/man-pages/man2/timer_create.2.html)
308 * creates a POSIX timer.
309 *
310 * Returns 0 on success, and returns -1 and sets `errno` on failure.
311 */
zijunzhaoe6202662023-01-03 23:32:18 +0000312int timer_create(clockid_t __clock, struct sigevent* _Nullable __event, timer_t _Nonnull * _Nonnull __timer_ptr);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800313
Elliott Hughesd192dbe2023-05-25 11:17:56 -0700314/**
315 * [timer_delete(2)](http://man7.org/linux/man-pages/man2/timer_delete.2.html)
316 * destroys a POSIX timer.
317 *
318 * Returns 0 on success, and returns -1 and sets `errno` on failure.
319 */
320int timer_delete(timer_t _Nonnull __timer);
321
322/**
323 * [timer_settime(2)](http://man7.org/linux/man-pages/man2/timer_settime.2.html)
324 * starts or stops a POSIX timer.
325 *
326 * Returns 0 on success, and returns -1 and sets `errno` on failure.
327 */
328int timer_settime(timer_t _Nonnull __timer, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value);
329
330/**
331 * [timer_gettime(2)](http://man7.org/linux/man-pages/man2/timer_gettime.2.html)
332 * gets the time until the given timer next fires.
333 *
334 * Returns 0 on success, and returns -1 and sets `errno` on failure.
335 */
336int timer_gettime(timer_t _Nonnull _timer, struct itimerspec* _Nonnull __ts);
337
338/**
339 * [timer_getoverrun(2)](http://man7.org/linux/man-pages/man2/timer_getoverrun.2.html)
340 * gets the overrun count (the number of times the timer should have fired, but
341 * didn't) for the last time the timer fired.
342 *
343 * Returns the overrun count on success, and returns -1 and sets `errno` on failure.
344 */
345int timer_getoverrun(timer_t _Nonnull __timer);
David 'Digit' Turner6481b912010-12-06 12:23:16 +0100346
Elliott Hughes52541ee2023-04-24 17:04:49 -0700347/**
348 * The timebase for timespec_get() and timespec_getres() corresponding to CLOCK_REALTIME.
349 *
350 * Available since API level 29.
351 */
Elliott Hughes7db0a6c2023-05-03 15:37:46 -0700352#define TIME_UTC (CLOCK_REALTIME+1)
Elliott Hughes52541ee2023-04-24 17:04:49 -0700353
354/**
355 * The timebase for timespec_get() and timespec_getres() corresponding to CLOCK_MONOTONIC.
356 *
357 * Available since API level 35.
358 */
Elliott Hughes7db0a6c2023-05-03 15:37:46 -0700359#define TIME_MONOTONIC (CLOCK_MONOTONIC+1)
Elliott Hughes52541ee2023-04-24 17:04:49 -0700360
361/**
362 * The timebase for timespec_get() and timespec_getres() corresponding to CLOCK_PROCESS_CPUTIME_ID.
363 *
364 * Available since API level 35.
365 */
Elliott Hughes7db0a6c2023-05-03 15:37:46 -0700366#define TIME_ACTIVE (CLOCK_PROCESS_CPUTIME_ID+1)
Elliott Hughes52541ee2023-04-24 17:04:49 -0700367
368/**
369 * The timebase for timespec_get() and timespec_getres() corresponding to CLOCK_THREAD_CPUTIME_ID.
370 *
371 * Available since API level 35.
372 */
Elliott Hughes7db0a6c2023-05-03 15:37:46 -0700373#define TIME_THREAD_ACTIVE (CLOCK_THREAD_CPUTIME_ID+1)
Elliott Hughes52541ee2023-04-24 17:04:49 -0700374
375/**
376 * timespec_get(3) is equivalent to clock_gettime() for the clock corresponding to the given base.
377 *
378 * Returns the base on success and returns 0 on failure.
379 *
380 * Available since API level 29 for TIME_UTC; other bases arrived later.
381 * Code for Android should prefer clock_gettime().
382 */
zijunzhaoe6202662023-01-03 23:32:18 +0000383int timespec_get(struct timespec* _Nonnull __ts, int __base) __INTRODUCED_IN(29);
Elliott Hughesf98d87b2018-07-17 13:21:05 -0700384
Elliott Hughes52541ee2023-04-24 17:04:49 -0700385/**
386 * timespec_getres(3) is equivalent to clock_getres() for the clock corresponding to the given base.
387 *
388 * Returns the base on success and returns 0 on failure.
389 *
390 * Available since API level 35.
391 * Code for Android should prefer clock_gettime().
392 */
393int timespec_getres(struct timespec* _Nonnull __ts, int __base) __INTRODUCED_IN(35);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800394
Elliott Hughes52541ee2023-04-24 17:04:49 -0700395__END_DECLS