]> git.ipfire.org Git - thirdparty/glibc.git/blob - include/time.h
Finish move of clock_* functions to libc. [BZ #24959]
[thirdparty/glibc.git] / include / time.h
1 #ifndef _TIME_H
2 #include <time/time.h>
3
4 #ifndef _ISOMAC
5 # include <bits/types/locale_t.h>
6 # include <stdbool.h>
7 # include <time/mktime-internal.h>
8
9 extern __typeof (strftime_l) __strftime_l;
10 libc_hidden_proto (__strftime_l)
11 extern __typeof (strptime_l) __strptime_l;
12
13 libc_hidden_proto (time)
14 libc_hidden_proto (asctime)
15 libc_hidden_proto (mktime)
16 libc_hidden_proto (timelocal)
17 libc_hidden_proto (localtime)
18 libc_hidden_proto (strftime)
19 libc_hidden_proto (strptime)
20
21 extern __typeof (clock_gettime) __clock_gettime;
22 libc_hidden_proto (__clock_gettime)
23 extern __typeof (clock_settime) __clock_settime;
24 libc_hidden_proto (__clock_settime)
25
26 /* Now define the internal interfaces. */
27 struct tm;
28
29 /* Defined in mktime.c. */
30 extern const unsigned short int __mon_yday[2][13] attribute_hidden;
31
32 /* Defined in localtime.c. */
33 extern struct tm _tmbuf attribute_hidden;
34
35 /* Defined in tzset.c. */
36 extern char *__tzstring (const char *string) attribute_hidden;
37
38 extern int __use_tzfile attribute_hidden;
39
40 extern void __tzfile_read (const char *file, size_t extra,
41 char **extrap) attribute_hidden;
42 extern void __tzfile_compute (__time64_t timer, int use_localtime,
43 long int *leap_correct, int *leap_hit,
44 struct tm *tp) attribute_hidden;
45 extern void __tzfile_default (const char *std, const char *dst,
46 int stdoff, int dstoff)
47 attribute_hidden;
48 extern void __tzset_parse_tz (const char *tz) attribute_hidden;
49 extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
50 __THROW attribute_hidden;
51
52 #if __TIMESIZE == 64
53 # define __ctime64 ctime
54 #else
55 extern char *__ctime64 (const __time64_t *__timer) __THROW;
56 libc_hidden_proto (__ctime64)
57 #endif
58
59 #if __TIMESIZE == 64
60 # define __ctime64_r ctime_r
61 #else
62 extern char *__ctime64_r (const __time64_t *__restrict __timer,
63 char *__restrict __buf) __THROW;
64 libc_hidden_proto (__ctime64_r)
65 #endif
66
67 #if __TIMESIZE == 64
68 # define __localtime64 localtime
69 #else
70 extern struct tm *__localtime64 (const __time64_t *__timer);
71 libc_hidden_proto (__localtime64)
72 #endif
73
74 extern struct tm *__localtime_r (const time_t *__timer,
75 struct tm *__tp) attribute_hidden;
76 #if __TIMESIZE != 64
77 extern struct tm *__localtime64_r (const __time64_t *__timer,
78 struct tm *__tp);
79 libc_hidden_proto (__localtime64_r)
80
81 extern __time64_t __mktime64 (struct tm *__tp) __THROW;
82 libc_hidden_proto (__mktime64)
83 #endif
84
85 extern struct tm *__gmtime_r (const time_t *__restrict __timer,
86 struct tm *__restrict __tp);
87 libc_hidden_proto (__gmtime_r)
88
89 #if __TIMESIZE == 64
90 # define __gmtime64 gmtime
91 #else
92 extern struct tm *__gmtime64 (const __time64_t *__timer);
93 libc_hidden_proto (__gmtime64)
94
95 extern struct tm *__gmtime64_r (const __time64_t *__restrict __timer,
96 struct tm *__restrict __tp);
97 libc_hidden_proto (__gmtime64_r)
98
99 extern __time64_t __timegm64 (struct tm *__tp) __THROW;
100 libc_hidden_proto (__timegm64)
101 #endif
102
103 /* Compute the `struct tm' representation of T,
104 offset OFFSET seconds east of UTC,
105 and store year, yday, mon, mday, wday, hour, min, sec into *TP.
106 Return nonzero if successful. */
107 extern int __offtime (__time64_t __timer,
108 long int __offset,
109 struct tm *__tp) attribute_hidden;
110
111 extern char *__asctime_r (const struct tm *__tp, char *__buf)
112 attribute_hidden;
113 extern void __tzset (void) attribute_hidden;
114
115 /* Prototype for the internal function to get information based on TZ. */
116 extern struct tm *__tz_convert (__time64_t timer, int use_localtime,
117 struct tm *tp) attribute_hidden;
118
119 extern int __nanosleep (const struct timespec *__requested_time,
120 struct timespec *__remaining);
121 hidden_proto (__nanosleep)
122 extern int __getdate_r (const char *__string, struct tm *__resbufp)
123 attribute_hidden;
124
125
126 /* Determine CLK_TCK value. */
127 extern int __getclktck (void) attribute_hidden;
128
129
130 /* strptime support. */
131 extern char * __strptime_internal (const char *rp, const char *fmt,
132 struct tm *tm, void *statep,
133 locale_t locparam) attribute_hidden;
134
135 #if __TIMESIZE == 64
136 # define __difftime64 __difftime
137 #else
138 extern double __difftime64 (__time64_t time1, __time64_t time0);
139 libc_hidden_proto (__difftime64)
140 #endif
141
142 extern double __difftime (time_t time1, time_t time0);
143
144
145 /* Use in the clock_* functions. Size of the field representing the
146 actual clock ID. */
147 #define CLOCK_IDFIELD_SIZE 3
148
149 /* Check whether T fits in time_t. */
150 static inline bool
151 in_time_t_range (__time64_t t)
152 {
153 time_t s = t;
154 return s == t;
155 }
156
157 #endif
158 #endif