implement mbtowc directly, not as a wrapper for mbrtowc
[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 struct tm
29 {
30         int tm_sec;
31         int tm_min;
32         int tm_hour;
33         int tm_mday;
34         int tm_mon;
35         int tm_year;
36         int tm_wday;
37         int tm_yday;
38         int tm_isdst;
39         long __tm_gmtoff;
40         const char *__tm_zone;
41 };
42 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
43 #define tm_gmtoff __tm_gmtoff
44 #define tm_zone __tm_zone
45 #endif
46
47 clock_t clock (void);
48 time_t time (time_t *);
49 double difftime (time_t, time_t);
50 time_t mktime (struct tm *);
51 size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
52 struct tm *gmtime (const time_t *);
53 struct tm *localtime (const time_t *);
54 char *asctime (const struct tm *);
55 char *ctime (const time_t *);
56
57 #define CLOCKS_PER_SEC 1000000UL
58
59
60 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
61  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
62  || defined(_BSD_SOURCE)
63
64 size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
65
66 struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
67 struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
68 char *asctime_r (const struct tm *__restrict, char *__restrict);
69 char *ctime_r (const time_t *, char *);
70
71 void tzset (void);
72
73 struct itimerspec
74 {
75         struct timespec it_interval;
76         struct timespec it_value;
77 };
78
79 #define CLOCK_REALTIME           0
80 #define CLOCK_MONOTONIC          1
81 #define CLOCK_PROCESS_CPUTIME_ID 2
82 #define CLOCK_THREAD_CPUTIME_ID  3
83
84 #define TIMER_ABSTIME 1
85
86 int nanosleep (const struct timespec *, struct timespec *);
87 int clock_getres (clockid_t, struct timespec *);
88 int clock_gettime (clockid_t, struct timespec *);
89 int clock_settime (clockid_t, const struct timespec *);
90 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
91 int clock_getcpuclockid (pid_t, clockid_t *);
92
93 struct sigevent;
94 int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
95 int timer_delete (timer_t);
96 int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
97 int timer_gettime (timer_t, struct itimerspec *);
98 int timer_getoverrun (timer_t);
99
100 #endif
101
102
103 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
104 char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
105 extern int daylight;
106 extern long timezone;
107 extern char *tzname[2];
108 extern int getdate_err;
109 struct tm *getdate (const char *);
110 #endif
111
112
113 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
114 int stime(time_t *);
115 time_t timegm(struct tm *);
116 #endif
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122
123 #endif