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