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