1 /* 2 * time.h 3 * 4 * Struct and function declarations for dealing with time. 5 */ 6 7 #ifndef _TIME_H_ 8 #define _TIME_H_ 9 10 #include "_ansi.h" 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #ifndef NULL 17 #define NULL 0 18 #endif 19 20 /* Get _CLOCKS_PER_SEC_ */ 21 #include <machine/time.h> 22 23 #ifndef _CLOCKS_PER_SEC_ 24 #define _CLOCKS_PER_SEC_ 1000 25 #endif 26 27 #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_ 28 #define CLK_TCK CLOCKS_PER_SEC 29 #define __need_size_t 30 #include <stddef.h> 31 32 #include <sys/types.h> 33 34 struct tm 35 { 36 int tm_sec; 37 int tm_min; 38 int tm_hour; 39 int tm_mday; 40 int tm_mon; 41 int tm_year; 42 int tm_wday; 43 int tm_yday; 44 int tm_isdst; 45 }; 46 47 clock_t _EXFUN(clock, (void)); 48 double _EXFUN(difftime, (time_t _time2, time_t _time1)); 49 time_t _EXFUN(mktime, (struct tm *_timeptr)); 50 time_t _EXFUN(time, (time_t *_timer)); 51 #ifndef _REENT_ONLY 52 char *_EXFUN(asctime, (const struct tm *_tblock)); 53 char *_EXFUN(ctime, (const time_t *_time)); 54 struct tm *_EXFUN(gmtime, (const time_t *_timer)); 55 struct tm *_EXFUN(localtime,(const time_t *_timer)); 56 #endif 57 size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t)); 58 59 char *_EXFUN(asctime_r, (const struct tm *, char *)); 60 char *_EXFUN(ctime_r, (const time_t *, char *)); 61 struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); 62 struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); 63 64 #ifdef __CYGWIN__ 65 #ifndef __STRICT_ANSI__ 66 extern __IMPORT time_t _timezone; 67 extern __IMPORT int _daylight; 68 extern __IMPORT char *_tzname[2]; 69 70 char *_EXFUN(timezone, (void)); 71 void _EXFUN(tzset, (void)); 72 #endif 73 #endif /* __CYGWIN__ */ 74 75 #include <sys/features.h> 76 77 78 #if defined(_POSIX_TIMERS) 79 80 #include <signal.h> 81 82 /* Clocks, P1003.1b-1993, p. 263 */ 83 84 int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); 85 int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); 86 int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); 87 88 /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */ 89 90 int _EXFUN(timer_create, 91 (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)); 92 93 /* Delete a Per_process Timer, P1003.1b-1993, p. 266 */ 94 95 int _EXFUN(timer_delete, (timer_t timerid)); 96 97 /* Per-Process Timers, P1003.1b-1993, p. 267 */ 98 99 int _EXFUN(timer_settime, 100 (timer_t timerid, int flags, const struct itimerspec *value, 101 struct itimerspec *ovalue)); 102 int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value)); 103 int _EXFUN(timer_getoverrun, (timer_t timerid)); 104 105 /* High Resolution Sleep, P1003.1b-1993, p. 269 */ 106 107 int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); 108 109 #endif /* _POSIX_TIMERS */ 110 111 /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */ 112 113 /* values for the clock enable attribute */ 114 115 #define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */ 116 #define CLOCK_DISABLED 0 /* clock is disabled */ 117 118 /* values for the pthread cputime_clock_allowed attribute */ 119 120 #define CLOCK_ALLOWED 1 /* If a thread is created with this value a */ 121 /* CPU-time clock attached to that thread */ 122 /* shall be accessible. */ 123 #define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */ 124 /* thread shall not have a CPU-time clock */ 125 /* accessible. */ 126 127 /* Manifest Constants, P1003.1b-1993, p. 262 */ 128 129 #define CLOCK_REALTIME (clockid_t)1 130 131 /* Flag indicating time is "absolute" with respect to the clock 132 associated with a time. */ 133 134 #define TIMER_ABSTIME 4 135 136 /* Manifest Constants, P1003.4b/D8, p. 55 */ 137 138 #if defined(_POSIX_CPUTIME) 139 140 /* When used in a clock or timer function call, this is interpreted as 141 the identifier of the CPU_time clock associated with the PROCESS 142 making the function call. */ 143 144 #define CLOCK_PROCESS_CPUTIME (clockid_t)2 145 146 #endif 147 148 #if defined(_POSIX_THREAD_CPUTIME) 149 150 /* When used in a clock or timer function call, this is interpreted as 151 the identifier of the CPU_time clock associated with the THREAD 152 making the function call. */ 153 154 #define CLOCK_THREAD_CPUTIME (clockid_t)3 155 156 #endif 157 158 #if defined(_POSIX_CPUTIME) 159 160 /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */ 161 162 int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id)); 163 164 #endif /* _POSIX_CPUTIME */ 165 166 #if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME) 167 168 /* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */ 169 170 int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr)); 171 int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr)); 172 173 #endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */ 174 175 #ifdef __cplusplus 176 } 177 #endif 178 #endif /* _TIME_H_ */ |