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