1 #ifndef _SYS_TIME_H 2 #define _SYS_TIME_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #include <features.h> 8 9 #define __NEED_size_t 10 #define __NEED_time_t 11 #define __NEED_clock_t 12 #define __NEED_struct_timespec 13 #define __NEED_suseconds_t 14 #define __NEED_struct_timeval 15 #define __NEED_clockid_t 16 #define __NEED_timer_t 17 18 #include <bits/alltypes.h> 19 20 #include <sys/select.h> 21 22 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 23 struct timezone { 24 int tz_minuteswest; 25 int tz_dsttime; 26 }; 27 #endif 28 #if !defined(__LP64__) 29 int settimeofday64(const struct timeval64 *, const struct timezone *__restrict); 30 int gettimeofday64(struct timeval64 *, struct timezone *__restrict); 31 #endif 32 33 int gettimeofday (struct timeval *__restrict, struct timezone *__restrict); 34 35 #define ITIMER_REAL 0 36 #define ITIMER_VIRTUAL 1 37 #define ITIMER_PROF 2 38 39 struct itimerval { 40 struct timeval it_interval; 41 struct timeval it_value; 42 }; 43 44 #if !defined(__LP64__) 45 struct itimerval64 { 46 struct timeval64 it_interval; 47 struct timeval64 it_value; 48 }; 49 #else 50 #define itimerval64 itimerval 51 #endif 52 53 int getitimer (int, struct itimerval *); 54 int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict); 55 int utimes (const char *, const struct timeval [2]); 56 57 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 58 int futimes(int, const struct timeval [2]); 59 int futimesat(int, const char *, const struct timeval [2]); 60 int lutimes(const char *, const struct timeval [2]); 61 int settimeofday(const struct timeval *, const struct timezone *); 62 int adjtime (const struct timeval *, struct timeval *); 63 #define timerisset(t) ((t)->tv_sec || (t)->tv_usec) 64 #define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0) 65 #define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \ 66 (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec) 67 #define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \ 68 ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \ 69 ((a)->tv_usec -= 1000000, (a)->tv_sec++) ) 70 #define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \ 71 ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \ 72 ((a)->tv_usec += 1000000, (a)->tv_sec--) ) 73 #endif 74 75 #if defined(_GNU_SOURCE) 76 #define TIMEVAL_TO_TIMESPEC(tv, ts) ( \ 77 (ts)->tv_sec = (tv)->tv_sec, \ 78 (ts)->tv_nsec = (tv)->tv_usec * 1000, \ 79 (void)0 ) 80 #define TIMESPEC_TO_TIMEVAL(tv, ts) ( \ 81 (tv)->tv_sec = (ts)->tv_sec, \ 82 (tv)->tv_usec = (ts)->tv_nsec / 1000, \ 83 (void)0 ) 84 #endif 85 86 #if _REDIR_TIME64 87 __REDIR(gettimeofday, __gettimeofday_time64); 88 __REDIR(getitimer, __getitimer_time64); 89 __REDIR(setitimer, __setitimer_time64); 90 __REDIR(utimes, __utimes_time64); 91 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 92 __REDIR(futimes, __futimes_time64); 93 __REDIR(futimesat, __futimesat_time64); 94 __REDIR(lutimes, __lutimes_time64); 95 __REDIR(settimeofday, __settimeofday_time64); 96 __REDIR(adjtime, __adjtime64); 97 #endif 98 #endif 99 100 #ifdef __cplusplus 101 } 102 #endif 103 #endif 104