1 #ifndef _TIME_H 2 #define _TIME_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <features.h> 9 10 #ifndef NULL 11 #ifdef __cplusplus 12 #define NULL 0L 13 #else 14 #define NULL ((void*)0) 15 #endif 16 #endif 17 18 #define __NEED_size_t 19 #define __NEED_time_t 20 #define __NEED_clock_t 21 #define __NEED_struct_timespec 22 23 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 24 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 25 || defined(_BSD_SOURCE) 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 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 35 #define __tm_gmtoff tm_gmtoff 36 #define __tm_zone tm_zone 37 #endif 38 39 struct tm { 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 int timespec_get(struct timespec *, int); 63 64 #define CLOCKS_PER_SEC 1000000L 65 66 #define TIME_UTC 1 67 68 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 69 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 70 || defined(_BSD_SOURCE) 71 72 size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t); 73 74 struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict); 75 struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict); 76 char *asctime_r (const struct tm *__restrict, char *__restrict); 77 char *ctime_r (const time_t *, char *); 78 79 void tzset (void); 80 81 struct itimerspec { 82 struct timespec it_interval; 83 struct timespec it_value; 84 }; 85 86 #define CLOCK_REALTIME 0 87 #define CLOCK_MONOTONIC 1 88 #define CLOCK_PROCESS_CPUTIME_ID 2 89 #define CLOCK_THREAD_CPUTIME_ID 3 90 #define CLOCK_MONOTONIC_RAW 4 91 #define CLOCK_REALTIME_COARSE 5 92 #define CLOCK_MONOTONIC_COARSE 6 93 #define CLOCK_BOOTTIME 7 94 #define CLOCK_REALTIME_ALARM 8 95 #define CLOCK_BOOTTIME_ALARM 9 96 #define CLOCK_SGI_CYCLE 10 97 #define CLOCK_TAI 11 98 99 #define TIMER_ABSTIME 1 100 101 int nanosleep (const struct timespec *, struct timespec *); 102 int clock_getres (clockid_t, struct timespec *); 103 int clock_gettime (clockid_t, struct timespec *); 104 int clock_settime (clockid_t, const struct timespec *); 105 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *); 106 int clock_getcpuclockid (pid_t, clockid_t *); 107 108 struct sigevent; 109 int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict); 110 int timer_delete (timer_t); 111 int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); 112 int timer_gettime (timer_t, struct itimerspec *); 113 int timer_getoverrun (timer_t); 114 115 extern char *tzname[2]; 116 117 #endif 118 119 120 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 121 char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict); 122 extern int daylight; 123 extern long timezone; 124 extern int getdate_err; 125 struct tm *getdate (const char *); 126 #endif 127 128 129 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 130 int stime(const time_t *); 131 time_t timegm(struct tm *); 132 #endif 133 134 #if _REDIR_TIME64 135 __REDIR(time, __time64); 136 __REDIR(difftime, __difftime64); 137 __REDIR(mktime, __mktime64); 138 __REDIR(gmtime, __gmtime64); 139 __REDIR(localtime, __localtime64); 140 __REDIR(ctime, __ctime64); 141 __REDIR(timespec_get, __timespec_get_time64); 142 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 143 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 144 || defined(_BSD_SOURCE) 145 __REDIR(gmtime_r, __gmtime64_r); 146 __REDIR(localtime_r, __localtime64_r); 147 __REDIR(ctime_r, __ctime64_r); 148 __REDIR(nanosleep, __nanosleep_time64); 149 __REDIR(clock_getres, __clock_getres_time64); 150 __REDIR(clock_gettime, __clock_gettime64); 151 __REDIR(clock_settime, __clock_settime64); 152 __REDIR(clock_nanosleep, __clock_nanosleep_time64); 153 __REDIR(timer_settime, __timer_settime64); 154 __REDIR(timer_gettime, __timer_gettime64); 155 #endif 156 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 157 __REDIR(stime, __stime64); 158 __REDIR(timegm, __timegm_time64); 159 #endif 160 #endif 161 162 #ifdef __cplusplus 163 } 164 #endif 165 166 167 #endif 168