]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/include/time.h
10 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11 #if __cplusplus >= 201103L
13 #elif defined(__cplusplus)
16 #define NULL ((void*)0)
26 #define __NEED_clock_t
27 #define __NEED_struct_timespec
29 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
30 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
31 || defined(_BSD_SOURCE)
32 #define __NEED_clockid_t
33 #define __NEED_timer_t
35 #define __NEED_locale_t
38 #include <bits/alltypes.h>
40 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
41 #define __tm_gmtoff tm_gmtoff
42 #define __tm_zone tm_zone
45 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
57 const char *__tm_zone
;
60 #include <__header_time.h>
63 #if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_PROCESS_CLOCKS)
66 __attribute__((__deprecated__(
67 "WASI lacks process-associated clocks; to enable emulation of the `clock` function using "
68 "the wall clock, which isn't sensitive to whether the program is running or suspended, "
69 "compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks"
73 time_t time (time_t *);
74 double difftime (time_t, time_t);
75 time_t mktime (struct tm
*);
76 size_t strftime (char *__restrict
, size_t, const char *__restrict
, const struct tm
*__restrict
);
77 struct tm
*gmtime (const time_t *);
78 struct tm
*localtime (const time_t *);
79 char *asctime (const struct tm
*);
80 char *ctime (const time_t *);
81 int timespec_get(struct timespec
*, int);
83 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
84 #define CLOCKS_PER_SEC 1000000L
89 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
90 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
91 || defined(_BSD_SOURCE)
93 size_t strftime_l (char * __restrict
, size_t, const char * __restrict
, const struct tm
* __restrict
, locale_t
);
95 struct tm
*gmtime_r (const time_t *__restrict
, struct tm
*__restrict
);
96 struct tm
*localtime_r (const time_t *__restrict
, struct tm
*__restrict
);
97 char *asctime_r (const struct tm
*__restrict
, char *__restrict
);
98 char *ctime_r (const time_t *, char *);
100 #ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
105 struct timespec it_interval
;
106 struct timespec it_value
;
109 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
110 #define CLOCK_REALTIME 0
111 #define CLOCK_MONOTONIC 1
112 #define CLOCK_PROCESS_CPUTIME_ID 2
113 #define CLOCK_THREAD_CPUTIME_ID 3
114 #define CLOCK_MONOTONIC_RAW 4
115 #define CLOCK_REALTIME_COARSE 5
116 #define CLOCK_MONOTONIC_COARSE 6
117 #define CLOCK_BOOTTIME 7
118 #define CLOCK_REALTIME_ALARM 8
119 #define CLOCK_BOOTTIME_ALARM 9
120 #define CLOCK_SGI_CYCLE 10
123 #define TIMER_ABSTIME 1
126 int nanosleep (const struct timespec
*, struct timespec
*);
127 int clock_getres (clockid_t
, struct timespec
*);
128 int clock_gettime (clockid_t
, struct timespec
*);
129 #ifdef __wasilibc_unmodified_upstream /* WASI has no clock_settime */
130 int clock_settime (clockid_t
, const struct timespec
*);
132 int clock_nanosleep (clockid_t
, int, const struct timespec
*, struct timespec
*);
133 #ifdef __wasilibc_unmodified_upstream /* WASI has no clock_getcpuclockid */
134 int clock_getcpuclockid (pid_t
, clockid_t
*);
137 #ifdef __wasilibc_unmodified_upstream /* WASI has no timers */
139 int timer_create (clockid_t
, struct sigevent
*__restrict
, timer_t
*__restrict
);
140 int timer_delete (timer_t
);
141 int timer_settime (timer_t
, int, const struct itimerspec
*__restrict
, struct itimerspec
*__restrict
);
142 int timer_gettime (timer_t
, struct itimerspec
*);
143 int timer_getoverrun (timer_t
);
146 #ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
147 extern char *tzname
[2];
153 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
154 char *strptime (const char *__restrict
, const char *__restrict
, struct tm
*__restrict
);
155 #ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
157 extern long timezone
;
159 extern int getdate_err
;
160 struct tm
*getdate (const char *);
164 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
165 #ifdef __wasilibc_unmodified_upstream /* WASI has no stime */
166 int stime(const time_t *);
168 time_t timegm(struct tm
*);
172 __REDIR(time
, __time64
);
173 __REDIR(difftime
, __difftime64
);
174 __REDIR(mktime
, __mktime64
);
175 __REDIR(gmtime
, __gmtime64
);
176 __REDIR(localtime
, __localtime64
);
177 __REDIR(ctime
, __ctime64
);
178 __REDIR(timespec_get
, __timespec_get_time64
);
179 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
180 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
181 || defined(_BSD_SOURCE)
182 __REDIR(gmtime_r
, __gmtime64_r
);
183 __REDIR(localtime_r
, __localtime64_r
);
184 __REDIR(ctime_r
, __ctime64_r
);
185 __REDIR(nanosleep
, __nanosleep_time64
);
186 __REDIR(clock_getres
, __clock_getres_time64
);
187 __REDIR(clock_gettime
, __clock_gettime64
);
188 __REDIR(clock_settime
, __clock_settime64
);
189 __REDIR(clock_nanosleep
, __clock_nanosleep_time64
);
190 __REDIR(timer_settime
, __timer_settime64
);
191 __REDIR(timer_gettime
, __timer_gettime64
);
193 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
194 __REDIR(stime
, __stime64
);
195 __REDIR(timegm
, __timegm_time64
);