17777dab0Sopenharmony_ci#ifndef	_TIME_H
27777dab0Sopenharmony_ci#define _TIME_H
37777dab0Sopenharmony_ci
47777dab0Sopenharmony_ci#ifdef __cplusplus
57777dab0Sopenharmony_ciextern "C" {
67777dab0Sopenharmony_ci#endif
77777dab0Sopenharmony_ci
87777dab0Sopenharmony_ci#include <features.h>
97777dab0Sopenharmony_ci
107777dab0Sopenharmony_ci#ifdef __cplusplus
117777dab0Sopenharmony_ci#define NULL 0L
127777dab0Sopenharmony_ci#else
137777dab0Sopenharmony_ci#define NULL ((void*)0)
147777dab0Sopenharmony_ci#endif
157777dab0Sopenharmony_ci
167777dab0Sopenharmony_ci
177777dab0Sopenharmony_ci#define __NEED_size_t
187777dab0Sopenharmony_ci#define __NEED_time_t
197777dab0Sopenharmony_ci#define __NEED_clock_t
207777dab0Sopenharmony_ci#define __NEED_struct_timespec
217777dab0Sopenharmony_ci
227777dab0Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
237777dab0Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
247777dab0Sopenharmony_ci || defined(_BSD_SOURCE)
257777dab0Sopenharmony_ci#define __NEED_clockid_t
267777dab0Sopenharmony_ci#define __NEED_timer_t
277777dab0Sopenharmony_ci#define __NEED_pid_t
287777dab0Sopenharmony_ci#define __NEED_locale_t
297777dab0Sopenharmony_ci#endif
307777dab0Sopenharmony_ci
317777dab0Sopenharmony_ci#include <bits/alltypes.h>
327777dab0Sopenharmony_ci
337777dab0Sopenharmony_ci#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
347777dab0Sopenharmony_ci#define __tm_gmtoff tm_gmtoff
357777dab0Sopenharmony_ci#define __tm_zone tm_zone
367777dab0Sopenharmony_ci#endif
377777dab0Sopenharmony_ci
387777dab0Sopenharmony_cistruct tm {
397777dab0Sopenharmony_ci	int tm_sec;
407777dab0Sopenharmony_ci	int tm_min;
417777dab0Sopenharmony_ci	int tm_hour;
427777dab0Sopenharmony_ci	int tm_mday;
437777dab0Sopenharmony_ci	int tm_mon;
447777dab0Sopenharmony_ci	int tm_year;
457777dab0Sopenharmony_ci	int tm_wday;
467777dab0Sopenharmony_ci	int tm_yday;
477777dab0Sopenharmony_ci	int tm_isdst;
487777dab0Sopenharmony_ci	long __tm_gmtoff;
497777dab0Sopenharmony_ci	const char *__tm_zone;
507777dab0Sopenharmony_ci};
517777dab0Sopenharmony_ci
527777dab0Sopenharmony_ciclock_t clock (void);
537777dab0Sopenharmony_citime_t time (time_t *);
547777dab0Sopenharmony_cidouble difftime (time_t, time_t);
557777dab0Sopenharmony_citime_t mktime (struct tm *);
567777dab0Sopenharmony_cisize_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
577777dab0Sopenharmony_cistruct tm *gmtime (const time_t *);
587777dab0Sopenharmony_cistruct tm *localtime (const time_t *);
597777dab0Sopenharmony_cichar *asctime (const struct tm *);
607777dab0Sopenharmony_cichar *ctime (const time_t *);
617777dab0Sopenharmony_ciint timespec_get(struct timespec *, int);
627777dab0Sopenharmony_ci
637777dab0Sopenharmony_ci#define CLOCKS_PER_SEC 1000000L
647777dab0Sopenharmony_ci
657777dab0Sopenharmony_ci#define TIME_UTC 1
667777dab0Sopenharmony_ci
677777dab0Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
687777dab0Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
697777dab0Sopenharmony_ci || defined(_BSD_SOURCE)
707777dab0Sopenharmony_ci
717777dab0Sopenharmony_cisize_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
727777dab0Sopenharmony_ci
737777dab0Sopenharmony_cistruct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
747777dab0Sopenharmony_cistruct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
757777dab0Sopenharmony_cichar *asctime_r (const struct tm *__restrict, char *__restrict);
767777dab0Sopenharmony_cichar *ctime_r (const time_t *, char *);
777777dab0Sopenharmony_ci
787777dab0Sopenharmony_civoid tzset (void);
797777dab0Sopenharmony_ci
807777dab0Sopenharmony_cistruct itimerspec {
817777dab0Sopenharmony_ci	struct timespec it_interval;
827777dab0Sopenharmony_ci	struct timespec it_value;
837777dab0Sopenharmony_ci};
847777dab0Sopenharmony_ci
857777dab0Sopenharmony_ci#define CLOCK_REALTIME           0
867777dab0Sopenharmony_ci#define CLOCK_MONOTONIC          1
877777dab0Sopenharmony_ci#define CLOCK_PROCESS_CPUTIME_ID 2
887777dab0Sopenharmony_ci#define CLOCK_THREAD_CPUTIME_ID  3
897777dab0Sopenharmony_ci#define CLOCK_MONOTONIC_RAW      4
907777dab0Sopenharmony_ci#define CLOCK_REALTIME_COARSE    5
917777dab0Sopenharmony_ci#define CLOCK_MONOTONIC_COARSE   6
927777dab0Sopenharmony_ci#define CLOCK_BOOTTIME           7
937777dab0Sopenharmony_ci#define CLOCK_REALTIME_ALARM     8
947777dab0Sopenharmony_ci#define CLOCK_BOOTTIME_ALARM     9
957777dab0Sopenharmony_ci#define CLOCK_SGI_CYCLE         10
967777dab0Sopenharmony_ci#define CLOCK_TAI               11
977777dab0Sopenharmony_ci
987777dab0Sopenharmony_ci#define TIMER_ABSTIME 1
997777dab0Sopenharmony_ci
1007777dab0Sopenharmony_ciint nanosleep (const struct timespec *, struct timespec *);
1017777dab0Sopenharmony_ciint clock_getres (clockid_t, struct timespec *);
1027777dab0Sopenharmony_ciint clock_gettime (clockid_t, struct timespec *);
1037777dab0Sopenharmony_ciint clock_settime (clockid_t, const struct timespec *);
1047777dab0Sopenharmony_ciint clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
1057777dab0Sopenharmony_ciint clock_getcpuclockid (pid_t, clockid_t *);
1067777dab0Sopenharmony_ci
1077777dab0Sopenharmony_cistruct sigevent;
1087777dab0Sopenharmony_ciint timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
1097777dab0Sopenharmony_ciint timer_delete (timer_t);
1107777dab0Sopenharmony_ciint timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
1117777dab0Sopenharmony_ciint timer_gettime (timer_t, struct itimerspec *);
1127777dab0Sopenharmony_ciint timer_getoverrun (timer_t);
1137777dab0Sopenharmony_ci
1147777dab0Sopenharmony_ciextern char *tzname[2];
1157777dab0Sopenharmony_ci
1167777dab0Sopenharmony_ci#endif
1177777dab0Sopenharmony_ci
1187777dab0Sopenharmony_ci
1197777dab0Sopenharmony_ci#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
1207777dab0Sopenharmony_cichar *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
1217777dab0Sopenharmony_ciextern int daylight;
1227777dab0Sopenharmony_ciextern long timezone;
1237777dab0Sopenharmony_ciextern int getdate_err;
1247777dab0Sopenharmony_ci#endif
1257777dab0Sopenharmony_ci
1267777dab0Sopenharmony_ci
1277777dab0Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
1287777dab0Sopenharmony_citime_t timegm(struct tm *);
1297777dab0Sopenharmony_ci#endif
1307777dab0Sopenharmony_ci
1317777dab0Sopenharmony_ci#if _REDIR_TIME64
1327777dab0Sopenharmony_ci__REDIR(time, __time64);
1337777dab0Sopenharmony_ci__REDIR(difftime, __difftime64);
1347777dab0Sopenharmony_ci__REDIR(mktime, __mktime64);
1357777dab0Sopenharmony_ci__REDIR(gmtime, __gmtime64);
1367777dab0Sopenharmony_ci__REDIR(localtime, __localtime64);
1377777dab0Sopenharmony_ci__REDIR(ctime, __ctime64);
1387777dab0Sopenharmony_ci__REDIR(timespec_get, __timespec_get_time64);
1397777dab0Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
1407777dab0Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
1417777dab0Sopenharmony_ci || defined(_BSD_SOURCE)
1427777dab0Sopenharmony_ci__REDIR(gmtime_r, __gmtime64_r);
1437777dab0Sopenharmony_ci__REDIR(localtime_r, __localtime64_r);
1447777dab0Sopenharmony_ci__REDIR(ctime_r, __ctime64_r);
1457777dab0Sopenharmony_ci__REDIR(nanosleep, __nanosleep_time64);
1467777dab0Sopenharmony_ci__REDIR(clock_getres, __clock_getres_time64);
1477777dab0Sopenharmony_ci__REDIR(clock_gettime, __clock_gettime64);
1487777dab0Sopenharmony_ci__REDIR(clock_settime, __clock_settime64);
1497777dab0Sopenharmony_ci__REDIR(clock_nanosleep, __clock_nanosleep_time64);
1507777dab0Sopenharmony_ci__REDIR(timer_settime, __timer_settime64);
1517777dab0Sopenharmony_ci__REDIR(timer_gettime, __timer_gettime64);
1527777dab0Sopenharmony_ci#endif
1537777dab0Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
1547777dab0Sopenharmony_ci__REDIR(timegm, __timegm_time64);
1557777dab0Sopenharmony_ci#endif
1567777dab0Sopenharmony_ci#endif
1577777dab0Sopenharmony_ci
1587777dab0Sopenharmony_ci#ifdef __cplusplus
1597777dab0Sopenharmony_ci}
1607777dab0Sopenharmony_ci#endif
1617777dab0Sopenharmony_ci
1627777dab0Sopenharmony_ci
1637777dab0Sopenharmony_ci#endif
164