1#ifndef	_TIME_H
2#define _TIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#if __cplusplus >= 201103L
11#define NULL nullptr
12#elif defined(__cplusplus)
13#define NULL 0L
14#else
15#define NULL ((void*)0)
16#endif
17
18
19#define __NEED_size_t
20#define __NEED_time_t
21#define __NEED_clock_t
22#define __NEED_struct_timespec
23#define __NEED_suseconds_t
24#define __NEED_struct_timeval
25
26#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
27 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
28 || defined(_BSD_SOURCE)
29#define __NEED_clockid_t
30#define __NEED_timer_t
31#define __NEED_pid_t
32#define __NEED_locale_t
33#endif
34
35#include <bits/alltypes.h>
36#include <sys/time.h>
37
38#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
39#define __tm_gmtoff tm_gmtoff
40#define __tm_zone tm_zone
41#endif
42
43struct tm {
44	int tm_sec;
45	int tm_min;
46	int tm_hour;
47	int tm_mday;
48	int tm_mon;
49	int tm_year;
50	int tm_wday;
51	int tm_yday;
52	int tm_isdst;
53	long __tm_gmtoff;
54	const char *__tm_zone;
55};
56
57clock_t clock (void);
58time_t time (time_t *);
59double difftime (time_t, time_t);
60time_t mktime (struct tm *);
61size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
62struct tm *gmtime (const time_t *);
63struct tm *localtime (const time_t *);
64char *asctime (const struct tm *);
65char *ctime (const time_t *);
66int timespec_get(struct timespec *, int);
67
68#define CLOCKS_PER_SEC 1000000L
69
70#define TIME_UTC 1
71
72#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
73 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
74 || defined(_BSD_SOURCE)
75
76size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
77
78struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
79struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
80char *asctime_r (const struct tm *__restrict, char *__restrict);
81char *ctime_r (const time_t *, char *);
82
83void tzset (void);
84
85struct itimerspec {
86	struct timespec it_interval;
87	struct timespec it_value;
88};
89
90#if !defined(__LP64__)
91struct itimerspec64 {
92  struct timespec64 it_interval;
93  struct timespec64 it_value;
94};
95#else
96#define itimerspec64 itimerspec
97#endif
98
99#define CLOCK_REALTIME           0
100#define CLOCK_MONOTONIC          1
101#define CLOCK_PROCESS_CPUTIME_ID 2
102#define CLOCK_THREAD_CPUTIME_ID  3
103#define CLOCK_MONOTONIC_RAW      4
104#define CLOCK_REALTIME_COARSE    5
105#define CLOCK_MONOTONIC_COARSE   6
106#define CLOCK_BOOTTIME           7
107#define CLOCK_REALTIME_ALARM     8
108#define CLOCK_BOOTTIME_ALARM     9
109#define CLOCK_SGI_CYCLE         10
110#define CLOCK_TAI               11
111
112#define MAX_CLOCKS 16
113
114#define TIMER_ABSTIME 1
115
116int nanosleep (const struct timespec *, struct timespec *);
117int clock_getres (clockid_t, struct timespec *);
118int clock_gettime (clockid_t, struct timespec *);
119int clock_settime (clockid_t, const struct timespec *);
120int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
121int clock_getcpuclockid (pid_t, clockid_t *);
122
123struct sigevent;
124int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
125int timer_delete (timer_t);
126int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
127int timer_gettime (timer_t, struct itimerspec *);
128int timer_getoverrun (timer_t);
129
130extern char *tzname[2];
131
132#endif
133
134
135#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
136char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
137extern int daylight;
138extern long timezone;
139extern int getdate_err;
140struct tm *getdate (const char *);
141#endif
142
143
144#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
145int stime(const time_t *);
146time_t timegm(struct tm *);
147#endif
148
149#if _REDIR_TIME64
150__REDIR(time, __time64);
151__REDIR(difftime, __difftime64);
152__REDIR(mktime, __mktime64);
153__REDIR(gmtime, __gmtime64);
154__REDIR(localtime, __localtime64);
155__REDIR(ctime, __ctime64);
156__REDIR(timespec_get, __timespec_get_time64);
157#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
158 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
159 || defined(_BSD_SOURCE)
160__REDIR(gmtime_r, __gmtime64_r);
161__REDIR(localtime_r, __localtime64_r);
162__REDIR(ctime_r, __ctime64_r);
163__REDIR(nanosleep, __nanosleep_time64);
164__REDIR(clock_getres, __clock_getres_time64);
165__REDIR(clock_gettime, __clock_gettime64);
166__REDIR(clock_settime, __clock_settime64);
167__REDIR(clock_nanosleep, __clock_nanosleep_time64);
168__REDIR(timer_settime, __timer_settime64);
169__REDIR(timer_gettime, __timer_gettime64);
170#endif
171#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
172__REDIR(stime, __stime64);
173__REDIR(timegm, __timegm_time64);
174#endif
175#endif
176
177#ifdef __cplusplus
178}
179#endif
180
181
182#endif
183