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