further use of _Noreturn, for non-plain-C functions
[musl] / include / time.h
1 #ifndef _TIME_H
2 #define _TIME_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #if __STDC_VERSION__ >= 199901L
9 #define __restrict restrict
10 #elif !defined(__GNUC__)
11 #define __restrict
12 #endif
13
14 #undef NULL
15 #ifdef __cplusplus
16 #define NULL 0
17 #else
18 #define NULL ((void*)0)
19 #endif
20
21
22 #define __NEED_size_t
23 #define __NEED_time_t
24 #define __NEED_clock_t
25
26 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
27  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
28  || defined(_BSD_SOURCE)
29 #define __NEED_struct_timespec
30 #define __NEED_clockid_t
31 #define __NEED_timer_t
32 #define __NEED_pid_t
33 #define __NEED_locale_t
34 #endif
35
36 #include <bits/alltypes.h>
37
38 struct tm
39 {
40         int tm_sec;
41         int tm_min;
42         int tm_hour;
43         int tm_mday;
44         int tm_mon;
45         int tm_year;
46         int tm_wday;
47         int tm_yday;
48         int tm_isdst;
49         long __tm_gmtoff;
50         const char *__tm_zone;
51 };
52
53 clock_t clock (void);
54 time_t time (time_t *);
55 double difftime (time_t, time_t);
56 time_t mktime (struct tm *);
57 size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
58 struct tm *gmtime (const time_t *);
59 struct tm *localtime (const time_t *);
60 char *asctime (const struct tm *);
61 char *ctime (const time_t *);
62
63 #define CLOCKS_PER_SEC 1000000UL
64
65
66 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
67  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
68  || defined(_BSD_SOURCE)
69
70 size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
71
72 struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
73 struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
74 char *asctime_r (const struct tm *__restrict, char *__restrict);
75 char *ctime_r (const time_t *, char *);
76
77 void tzset (void);
78
79 struct itimerspec
80 {
81         struct timespec it_interval;
82         struct timespec it_value;
83 };
84
85 #define CLOCK_REALTIME           0
86 #define CLOCK_MONOTONIC          1
87 #define CLOCK_PROCESS_CPUTIME_ID 2
88 #define CLOCK_THREAD_CPUTIME_ID  3
89
90 #define TIMER_ABSTIME 1
91
92 int nanosleep (const struct timespec *, struct timespec *);
93 int clock_getres (clockid_t, struct timespec *);
94 int clock_gettime (clockid_t, struct timespec *);
95 int clock_settime (clockid_t, const struct timespec *);
96 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
97 int clock_getcpuclockid (pid_t, clockid_t *);
98
99 struct sigevent;
100 int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
101 int timer_delete (timer_t);
102 int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
103 int timer_gettime (timer_t, struct itimerspec *);
104 int timer_getoverrun (timer_t);
105
106 #endif
107
108
109 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
110 char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
111 extern int daylight;
112 extern long timezone;
113 extern char *tzname[2];
114 extern int getdate_err;
115 struct tm *getdate (const char *);
116 #endif
117
118
119 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
120 int stime(time_t *);
121 time_t timegm(struct tm *);
122 #endif
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128
129 #endif