]> git.ipfire.org Git - thirdparty/glibc.git/blame - include/time.h
nptl: Move pthread_attr_setschedparam implementation into libc
[thirdparty/glibc.git] / include / time.h
CommitLineData
6796bc80 1#ifndef _TIME_H
05b68e14
ZW
2#include <time/time.h>
3
4#ifndef _ISOMAC
4973abcb 5# include <bits/types/struct_timeval.h>
f0be25b6 6# include <bits/types/locale_t.h>
20aa5819
PE
7# include <stdbool.h>
8# include <time/mktime-internal.h>
464cd3a9 9# include <endian.h>
bdbf022d 10
da4cfe38 11extern __typeof (strftime_l) __strftime_l;
ee2a5ae8 12libc_hidden_proto (__strftime_l)
da4cfe38
RM
13extern __typeof (strptime_l) __strptime_l;
14
c5598d47
RM
15libc_hidden_proto (time)
16libc_hidden_proto (asctime)
17libc_hidden_proto (mktime)
18libc_hidden_proto (timelocal)
19libc_hidden_proto (localtime)
20libc_hidden_proto (strftime)
21libc_hidden_proto (strptime)
22
6e6249d0 23extern __typeof (clock_gettime) __clock_gettime;
89fb6835 24libc_hidden_proto (__clock_gettime)
6e6249d0 25extern __typeof (clock_settime) __clock_settime;
7b5af2d8 26libc_hidden_proto (__clock_settime)
a9564ae9 27
bdbf022d
UD
28/* Now define the internal interfaces. */
29struct tm;
30
8632b240 31/* Defined in mktime.c. */
ab26a24a 32extern const unsigned short int __mon_yday[2][13] attribute_hidden;
8632b240
UD
33
34/* Defined in localtime.c. */
418f1701 35extern struct tm _tmbuf attribute_hidden;
8632b240
UD
36
37/* Defined in tzset.c. */
b0f56784 38extern char *__tzstring (const char *string) attribute_hidden;
8632b240 39
418f1701 40extern int __use_tzfile attribute_hidden;
8632b240 41
fe559c5e 42extern void __tzfile_read (const char *file, size_t extra,
b0f56784 43 char **extrap) attribute_hidden;
d51f99ce 44extern void __tzfile_compute (__time64_t timer, int use_localtime,
38e68573 45 long int *leap_correct, int *leap_hit,
b0f56784 46 struct tm *tp) attribute_hidden;
fe559c5e 47extern void __tzfile_default (const char *std, const char *dst,
77c7d55e 48 int stdoff, int dstoff)
b0f56784
L
49 attribute_hidden;
50extern void __tzset_parse_tz (const char *tz) attribute_hidden;
72b8692d 51extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
8bcdb7e0 52 __THROW attribute_hidden;
8632b240 53
464cd3a9
LM
54#if __TIMESIZE == 64
55# define __timespec64 timespec
56#else
57/* The glibc Y2038-proof struct __timespec64 structure for a time value.
58 To keep things Posix-ish, we keep the nanoseconds field a 32-bit
59 signed long, but since the Linux field is a 64-bit signed int, we
60 pad our tv_nsec with a 32-bit unnamed bit-field padding.
61
62 As a general rule the Linux kernel is ignoring upper 32 bits of
63 tv_nsec field. */
64struct __timespec64
65{
66 __time64_t tv_sec; /* Seconds */
67# if BYTE_ORDER == BIG_ENDIAN
68 __int32_t :32; /* Padding */
69 __int32_t tv_nsec; /* Nanoseconds */
70# else
71 __int32_t tv_nsec; /* Nanoseconds */
72 __int32_t :32; /* Padding */
73# endif
74};
75#endif
76
7755e504
AA
77#if __TIMESIZE == 64
78# define __ctime64 ctime
79#else
80extern char *__ctime64 (const __time64_t *__timer) __THROW;
20aa5819 81libc_hidden_proto (__ctime64)
7755e504
AA
82#endif
83
c4c2836a
AA
84#if __TIMESIZE == 64
85# define __ctime64_r ctime_r
86#else
87extern char *__ctime64_r (const __time64_t *__restrict __timer,
88 char *__restrict __buf) __THROW;
20aa5819 89libc_hidden_proto (__ctime64_r)
c4c2836a
AA
90#endif
91
6e15f3e2
AA
92#if __TIMESIZE == 64
93# define __localtime64 localtime
94#else
95extern struct tm *__localtime64 (const __time64_t *__timer);
96libc_hidden_proto (__localtime64)
97#endif
98
a784e502 99extern struct tm *__localtime_r (const time_t *__timer,
dff07c4b 100 struct tm *__tp) attribute_hidden;
20aa5819 101#if __TIMESIZE != 64
64c2277d
AA
102extern struct tm *__localtime64_r (const __time64_t *__timer,
103 struct tm *__tp);
104libc_hidden_proto (__localtime64_r)
20aa5819
PE
105
106extern __time64_t __mktime64 (struct tm *__tp) __THROW;
107libc_hidden_proto (__mktime64)
64c2277d
AA
108#endif
109
a784e502 110extern struct tm *__gmtime_r (const time_t *__restrict __timer,
c19559b0 111 struct tm *__restrict __tp);
230491f0 112libc_hidden_proto (__gmtime_r)
811ba236 113
131db8b0
AA
114#if __TIMESIZE == 64
115# define __gmtime64 gmtime
116#else
117extern struct tm *__gmtime64 (const __time64_t *__timer);
118libc_hidden_proto (__gmtime64)
131db8b0 119
a1d346ce
AA
120extern struct tm *__gmtime64_r (const __time64_t *__restrict __timer,
121 struct tm *__restrict __tp);
20aa5819
PE
122libc_hidden_proto (__gmtime64_r)
123
124extern __time64_t __timegm64 (struct tm *__tp) __THROW;
125libc_hidden_proto (__timegm64)
a1d346ce
AA
126#endif
127
72b8692d 128/* Compute the `struct tm' representation of T,
bdbf022d
UD
129 offset OFFSET seconds east of UTC,
130 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
131 Return nonzero if successful. */
72b8692d 132extern int __offtime (__time64_t __timer,
fe559c5e 133 long int __offset,
b0f56784 134 struct tm *__tp) attribute_hidden;
bdbf022d 135
b0f56784
L
136extern char *__asctime_r (const struct tm *__tp, char *__buf)
137 attribute_hidden;
138extern void __tzset (void) attribute_hidden;
bdbf022d 139
8632b240 140/* Prototype for the internal function to get information based on TZ. */
72b8692d 141extern struct tm *__tz_convert (__time64_t timer, int use_localtime,
b0f56784 142 struct tm *tp) attribute_hidden;
8632b240 143
a784e502 144extern int __nanosleep (const struct timespec *__requested_time,
c19559b0 145 struct timespec *__remaining);
fa872e1b 146hidden_proto (__nanosleep)
b0f56784
L
147extern int __getdate_r (const char *__string, struct tm *__resbufp)
148 attribute_hidden;
25b3dd49
UD
149
150
151/* Determine CLK_TCK value. */
b0f56784 152extern int __getclktck (void) attribute_hidden;
4165d44d
UD
153
154
ccadf7b5 155/* strptime support. */
ccadf7b5 156extern char * __strptime_internal (const char *rp, const char *fmt,
fa69dc9c 157 struct tm *tm, void *statep,
8bcdb7e0 158 locale_t locparam) attribute_hidden;
ccadf7b5 159
ac253355
AA
160#if __TIMESIZE == 64
161# define __difftime64 __difftime
162#else
163extern double __difftime64 (__time64_t time1, __time64_t time0);
164libc_hidden_proto (__difftime64)
165#endif
166
abca9f7f 167extern double __difftime (time_t time1, time_t time0);
ccadf7b5
UD
168
169
4165d44d
UD
170/* Use in the clock_* functions. Size of the field representing the
171 actual clock ID. */
31341567 172#define CLOCK_IDFIELD_SIZE 3
7735afa2 173
20aa5819
PE
174/* Check whether T fits in time_t. */
175static inline bool
176in_time_t_range (__time64_t t)
177{
178 time_t s = t;
179 return s == t;
180}
181
9c44c6a9
LM
182/* Convert a known valid struct timeval into a struct __timespec64. */
183static inline struct __timespec64
184valid_timeval_to_timespec64 (const struct timeval tv)
185{
186 struct __timespec64 ts64;
187
188 ts64.tv_sec = tv.tv_sec;
189 ts64.tv_nsec = tv.tv_usec * 1000;
190
191 return ts64;
192}
193
194/* Convert a known valid struct timespec into a struct __timespec64. */
195static inline struct __timespec64
196valid_timespec_to_timespec64 (const struct timespec ts)
197{
198 struct __timespec64 ts64;
199
200 ts64.tv_sec = ts.tv_sec;
201 ts64.tv_nsec = ts.tv_nsec;
202
203 return ts64;
204}
205
206/* Convert a valid and within range of struct timespec, struct
207 __timespec64 into a struct timespec. */
208static inline struct timespec
209valid_timespec64_to_timespec (const struct __timespec64 ts64)
210{
211 struct timespec ts;
212
213 ts.tv_sec = (time_t) ts64.tv_sec;
214 ts.tv_nsec = ts64.tv_nsec;
215
216 return ts;
217}
218
219/* Convert a valid and within range of struct timeval struct
220 __timespec64 into a struct timeval. */
221static inline struct timeval
222valid_timespec64_to_timeval (const struct __timespec64 ts64)
223{
224 struct timeval tv;
225
226 tv.tv_sec = (time_t) ts64.tv_sec;
227 tv.tv_usec = ts64.tv_nsec / 1000;
228
229 return tv;
230}
bdbf022d 231#endif
6796bc80 232#endif