5 # include <bits/types/locale_t.h>
7 # include <time/mktime-internal.h>
10 extern __typeof (strftime_l
) __strftime_l
;
11 libc_hidden_proto (__strftime_l
)
12 extern __typeof (strptime_l
) __strptime_l
;
14 libc_hidden_proto (time
)
15 libc_hidden_proto (asctime
)
16 libc_hidden_proto (mktime
)
17 libc_hidden_proto (timelocal
)
18 libc_hidden_proto (localtime
)
19 libc_hidden_proto (strftime
)
20 libc_hidden_proto (strptime
)
22 extern __typeof (clock_gettime
) __clock_gettime
;
23 libc_hidden_proto (__clock_gettime
)
24 extern __typeof (clock_settime
) __clock_settime
;
25 libc_hidden_proto (__clock_settime
)
27 /* Now define the internal interfaces. */
30 /* Defined in mktime.c. */
31 extern const unsigned short int __mon_yday
[2][13] attribute_hidden
;
33 /* Defined in localtime.c. */
34 extern struct tm _tmbuf attribute_hidden
;
36 /* Defined in tzset.c. */
37 extern char *__tzstring (const char *string
) attribute_hidden
;
39 extern int __use_tzfile attribute_hidden
;
41 extern void __tzfile_read (const char *file
, size_t extra
,
42 char **extrap
) attribute_hidden
;
43 extern void __tzfile_compute (__time64_t timer
, int use_localtime
,
44 long int *leap_correct
, int *leap_hit
,
45 struct tm
*tp
) attribute_hidden
;
46 extern void __tzfile_default (const char *std
, const char *dst
,
47 int stdoff
, int dstoff
)
49 extern void __tzset_parse_tz (const char *tz
) attribute_hidden
;
50 extern void __tz_compute (__time64_t timer
, struct tm
*tm
, int use_localtime
)
51 __THROW attribute_hidden
;
54 # define __timespec64 timespec
56 /* The glibc Y2038-proof struct __timespec64 structure for a time value.
57 To keep things Posix-ish, we keep the nanoseconds field a 32-bit
58 signed long, but since the Linux field is a 64-bit signed int, we
59 pad our tv_nsec with a 32-bit unnamed bit-field padding.
61 As a general rule the Linux kernel is ignoring upper 32 bits of
65 __time64_t tv_sec
; /* Seconds */
66 # if BYTE_ORDER == BIG_ENDIAN
67 __int32_t
:32; /* Padding */
68 __int32_t tv_nsec
; /* Nanoseconds */
70 __int32_t tv_nsec
; /* Nanoseconds */
71 __int32_t
:32; /* Padding */
77 # define __ctime64 ctime
79 extern char *__ctime64 (const __time64_t
*__timer
) __THROW
;
80 libc_hidden_proto (__ctime64
)
84 # define __ctime64_r ctime_r
86 extern char *__ctime64_r (const __time64_t
*__restrict __timer
,
87 char *__restrict __buf
) __THROW
;
88 libc_hidden_proto (__ctime64_r
)
92 # define __localtime64 localtime
94 extern struct tm
*__localtime64 (const __time64_t
*__timer
);
95 libc_hidden_proto (__localtime64
)
98 extern struct tm
*__localtime_r (const time_t *__timer
,
99 struct tm
*__tp
) attribute_hidden
;
101 extern struct tm
*__localtime64_r (const __time64_t
*__timer
,
103 libc_hidden_proto (__localtime64_r
)
105 extern __time64_t
__mktime64 (struct tm
*__tp
) __THROW
;
106 libc_hidden_proto (__mktime64
)
109 extern struct tm
*__gmtime_r (const time_t *__restrict __timer
,
110 struct tm
*__restrict __tp
);
111 libc_hidden_proto (__gmtime_r
)
114 # define __gmtime64 gmtime
116 extern struct tm
*__gmtime64 (const __time64_t
*__timer
);
117 libc_hidden_proto (__gmtime64
)
119 extern struct tm
*__gmtime64_r (const __time64_t
*__restrict __timer
,
120 struct tm
*__restrict __tp
);
121 libc_hidden_proto (__gmtime64_r
)
123 extern __time64_t
__timegm64 (struct tm
*__tp
) __THROW
;
124 libc_hidden_proto (__timegm64
)
127 /* Compute the `struct tm' representation of T,
128 offset OFFSET seconds east of UTC,
129 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
130 Return nonzero if successful. */
131 extern int __offtime (__time64_t __timer
,
133 struct tm
*__tp
) attribute_hidden
;
135 extern char *__asctime_r (const struct tm
*__tp
, char *__buf
)
137 extern void __tzset (void) attribute_hidden
;
139 /* Prototype for the internal function to get information based on TZ. */
140 extern struct tm
*__tz_convert (__time64_t timer
, int use_localtime
,
141 struct tm
*tp
) attribute_hidden
;
143 extern int __nanosleep (const struct timespec
*__requested_time
,
144 struct timespec
*__remaining
);
145 hidden_proto (__nanosleep
)
146 extern int __getdate_r (const char *__string
, struct tm
*__resbufp
)
150 /* Determine CLK_TCK value. */
151 extern int __getclktck (void) attribute_hidden
;
154 /* strptime support. */
155 extern char * __strptime_internal (const char *rp
, const char *fmt
,
156 struct tm
*tm
, void *statep
,
157 locale_t locparam
) attribute_hidden
;
160 # define __difftime64 __difftime
162 extern double __difftime64 (__time64_t time1
, __time64_t time0
);
163 libc_hidden_proto (__difftime64
)
166 extern double __difftime (time_t time1
, time_t time0
);
169 /* Use in the clock_* functions. Size of the field representing the
171 #define CLOCK_IDFIELD_SIZE 3
173 /* Check whether T fits in time_t. */
175 in_time_t_range (__time64_t t
)
181 /* Convert a known valid struct timeval into a struct __timespec64. */
182 static inline struct __timespec64
183 valid_timeval_to_timespec64 (const struct timeval tv
)
185 struct __timespec64 ts64
;
187 ts64
.tv_sec
= tv
.tv_sec
;
188 ts64
.tv_nsec
= tv
.tv_usec
* 1000;
193 /* Convert a known valid struct timespec into a struct __timespec64. */
194 static inline struct __timespec64
195 valid_timespec_to_timespec64 (const struct timespec ts
)
197 struct __timespec64 ts64
;
199 ts64
.tv_sec
= ts
.tv_sec
;
200 ts64
.tv_nsec
= ts
.tv_nsec
;
205 /* Convert a valid and within range of struct timespec, struct
206 __timespec64 into a struct timespec. */
207 static inline struct timespec
208 valid_timespec64_to_timespec (const struct __timespec64 ts64
)
212 ts
.tv_sec
= (time_t) ts64
.tv_sec
;
213 ts
.tv_nsec
= ts64
.tv_nsec
;
218 /* Convert a valid and within range of struct timeval struct
219 __timespec64 into a struct timeval. */
220 static inline struct timeval
221 valid_timespec64_to_timeval (const struct __timespec64 ts64
)
225 tv
.tv_sec
= (time_t) ts64
.tv_sec
;
226 tv
.tv_usec
= ts64
.tv_nsec
/ 1000;