• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef	_TIME_H
2 #define _TIME_H
3 
4 #ifdef __cplusplus
5 extern "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 
43 struct 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 
57 clock_t clock (void);
58 time_t time (time_t *);
59 double difftime (time_t, time_t);
60 time_t mktime (struct tm *);
61 size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
62 struct tm *gmtime (const time_t *);
63 struct tm *localtime (const time_t *);
64 char *asctime (const struct tm *);
65 char *ctime (const time_t *);
66 int 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 
76 size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
77 
78 struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
79 struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
80 char *asctime_r (const struct tm *__restrict, char *__restrict);
81 char *ctime_r (const time_t *, char *);
82 
83 void tzset (void);
84 
85 struct itimerspec {
86 	struct timespec it_interval;
87 	struct timespec it_value;
88 };
89 
90 #if !defined(__LP64__)
91 struct 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 
116 int nanosleep (const struct timespec *, struct timespec *);
117 int clock_getres (clockid_t, struct timespec *);
118 int clock_gettime (clockid_t, struct timespec *);
119 int clock_settime (clockid_t, const struct timespec *);
120 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
121 int clock_getcpuclockid (pid_t, clockid_t *);
122 
123 struct sigevent;
124 int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
125 int timer_delete (timer_t);
126 int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
127 int timer_gettime (timer_t, struct itimerspec *);
128 int timer_getoverrun (timer_t);
129 
130 extern char *tzname[2];
131 
132 #endif
133 
134 
135 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
136 char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
137 extern int daylight;
138 extern long timezone;
139 extern int getdate_err;
140 struct tm *getdate (const char *);
141 #endif
142 
143 
144 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
145 int stime(const time_t *);
146 time_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