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