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 #define __NEED_suseconds_t 22 #define __NEED_struct_timeval 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 #include <sys/time.h> 35 36 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 37 #define __tm_gmtoff tm_gmtoff 38 #define __tm_zone tm_zone 39 #endif 40 41 struct tm { 42 int tm_sec; 43 int tm_min; 44 int tm_hour; 45 int tm_mday; 46 int tm_mon; 47 int tm_year; 48 int tm_wday; 49 int tm_yday; 50 int tm_isdst; 51 long __tm_gmtoff; 52 const char *__tm_zone; 53 }; 54 55 clock_t clock (void); 56 time_t time (time_t *); 57 double difftime (time_t, time_t); 58 time_t mktime (struct tm *); 59 size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict); 60 struct tm *gmtime (const time_t *); 61 struct tm *localtime (const time_t *); 62 char *asctime (const struct tm *); 63 char *ctime (const time_t *); 64 int timespec_get(struct timespec *, int); 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 char *asctime_r (const struct tm *__restrict, char *__restrict); 79 char *ctime_r (const time_t *, char *); 80 81 void tzset (void); 82 83 struct itimerspec { 84 struct timespec it_interval; 85 struct timespec it_value; 86 }; 87 88 #if !defined(__LP64__) 89 struct itimerspec64 { 90 struct timespec64 it_interval; 91 struct timespec64 it_value; 92 }; 93 #else 94 #define itimerspec64 itimerspec 95 #endif 96 97 #define CLOCK_REALTIME 0 98 #define CLOCK_MONOTONIC 1 99 #define CLOCK_PROCESS_CPUTIME_ID 2 100 #define CLOCK_THREAD_CPUTIME_ID 3 101 #define CLOCK_MONOTONIC_RAW 4 102 #define CLOCK_REALTIME_COARSE 5 103 #define CLOCK_MONOTONIC_COARSE 6 104 #define CLOCK_BOOTTIME 7 105 #define CLOCK_REALTIME_ALARM 8 106 #define CLOCK_BOOTTIME_ALARM 9 107 #define CLOCK_SGI_CYCLE 10 108 #define CLOCK_TAI 11 109 110 #define MAX_CLOCKS 16 111 112 #define TIMER_ABSTIME 1 113 114 int nanosleep (const struct timespec *, struct timespec *); 115 int clock_getres (clockid_t, struct timespec *); 116 int clock_gettime (clockid_t, struct timespec *); 117 int clock_settime (clockid_t, const struct timespec *); 118 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *); 119 int clock_getcpuclockid (pid_t, clockid_t *); 120 121 struct sigevent; 122 int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict); 123 int timer_delete (timer_t); 124 int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); 125 int timer_gettime (timer_t, struct itimerspec *); 126 int timer_getoverrun (timer_t); 127 128 extern char *tzname[2]; 129 130 #endif 131 132 133 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 134 char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict); 135 extern int daylight; 136 extern long timezone; 137 extern int getdate_err; 138 struct tm *getdate (const char *); 139 #endif 140 141 142 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 143 int stime(const time_t *); 144 time_t timegm(struct tm *); 145 #endif 146 147 #if _REDIR_TIME64 148 __REDIR(time, __time64); 149 __REDIR(difftime, __difftime64); 150 __REDIR(mktime, __mktime64); 151 __REDIR(gmtime, __gmtime64); 152 __REDIR(localtime, __localtime64); 153 __REDIR(ctime, __ctime64); 154 __REDIR(timespec_get, __timespec_get_time64); 155 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 156 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 157 || defined(_BSD_SOURCE) 158 __REDIR(gmtime_r, __gmtime64_r); 159 __REDIR(localtime_r, __localtime64_r); 160 __REDIR(ctime_r, __ctime64_r); 161 __REDIR(nanosleep, __nanosleep_time64); 162 __REDIR(clock_getres, __clock_getres_time64); 163 __REDIR(clock_gettime, __clock_gettime64); 164 __REDIR(clock_settime, __clock_settime64); 165 __REDIR(clock_nanosleep, __clock_nanosleep_time64); 166 __REDIR(timer_settime, __timer_settime64); 167 __REDIR(timer_gettime, __timer_gettime64); 168 #endif 169 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 170 __REDIR(stime, __stime64); 171 __REDIR(timegm, __timegm_time64); 172 #endif 173 #endif 174 175 #ifdef __cplusplus 176 } 177 #endif 178 179 180 #endif 181