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: #include <sys/reent.h> 12: 13: #ifndef NULL 14: #define NULL 0 15: #endif 16: 17: /* Get _CLOCKS_PER_SEC_ */ 18: #include <machine/time.h> 19: 20: #ifndef _CLOCKS_PER_SEC_ 21: #define _CLOCKS_PER_SEC_ 1000 22: #endif 23: 24: #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_ 25: #define CLK_TCK CLOCKS_PER_SEC 26: #define __need_size_t 27: #include <stddef.h> 28: 29: #include <sys/types.h> 30: 31: _BEGIN_STD_C 32: 33: struct tm 34: { 35: int tm_sec; 36: int tm_min; 37: int tm_hour; 38: int tm_mday; 39: int tm_mon; 40: int tm_year; 41: int tm_wday; 42: int tm_yday; 43: int tm_isdst; 44: }; 45: 46: clock_t _EXFUN(clock, (void)); 47: double _EXFUN(difftime, (time_t _time2, time_t _time1)); 48: time_t _EXFUN(mktime, (struct tm *_timeptr)); 49: time_t _EXFUN(time, (time_t *_timer)); 50: #ifndef _REENT_ONLY 51: char *_EXFUN(asctime, (const struct tm *_tblock)); 52: char *_EXFUN(ctime, (const time_t *_time)); 53: struct tm *_EXFUN(gmtime, (const time_t *_timer)); 54: struct tm *_EXFUN(localtime,(const time_t *_timer)); 55: #endif 56: size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t)); 57: 58: char *_EXFUN(asctime_r, (const struct tm *, char *)); 59: char *_EXFUN(ctime_r, (const time_t *, char *)); 60: struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); 61: struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); 62: 63: _END_STD_C 64: 65: #ifdef __cplusplus 66: extern "C" { 67: #endif 68: 69: #ifndef __STRICT_ANSI__ 70: char *_EXFUN(strptime, (const char *, const char *, struct tm *)); 71: _VOID _EXFUN(tzset, (_VOID)); 72: _VOID _EXFUN(_tzset_r, (struct _reent *)); 73: 74: /* getdate functions */ 75: 76: #ifdef HAVE_GETDATE 77: #ifndef _REENT_ONLY 78: #define getdate_err (*__getdate_err()) 79: int *_EXFUN(__getdate_err,(_VOID)); 80: 81: struct tm * _EXFUN(getdate, (const char *)); 82: /* getdate_err is set to one of the following values to indicate the error. 83: 1 the DATEMSK environment variable is null or undefined, 84: 2 the template file cannot be opened for reading, 85: 3 failed to get file status information, 86: 4 the template file is not a regular file, 87: 5 an error is encountered while reading the template file, 88: 6 memory allication failed (not enough memory available), 89: 7 there is no line in the template that matches the input, 90: 8 invalid input specification */ 91: #endif /* !_REENT_ONLY */ 92: 93: /* getdate_r returns the error code as above */ 94: int _EXFUN(getdate_r, (const char *, struct tm *)); 95: #endif /* HAVE_GETDATE */ 96: 97: /* defines for the opengroup specifications Derived from Issue 1 of the SVID. */ 98: extern __IMPORT time_t _timezone; 99: extern __IMPORT int _daylight; 100: extern __IMPORT char *_tzname[2]; 101: 102: /* POSIX defines the external tzname being defined in time.h */ 103: #ifndef tzname 104: #define tzname _tzname 105: #endif 106: 107: /* CYGWIN also exposes daylight and timezone in the name space */ 108: #ifdef __CYGWIN__ 109: #ifndef daylight 110: #define daylight _daylight 111: #endif 112: #ifdef timezonevar 113: #ifndef timezone 114: #define timezone ((long int) _timezone) 115: #endif 116: #else 117: char *_EXFUN(timezone, (void)); 118: #endif 119: #endif /* __CYGWIN__ */ 120: #endif /* !__STRICT_ANSI__ */ 121: 122: #ifdef __cplusplus 123: } 124: #endif 125: 126: #include <sys/features.h> 127: 128: #if defined(_POSIX_TIMERS) 129: 130: #include <signal.h> 131: 132: #ifdef __cplusplus 133: extern "C" { 134: #endif 135: 136: /* Clocks, P1003.1b-1993, p. 263 */ 137: 138: int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); 139: int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); 140: int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); 141: 142: /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */ 143: 144: int _EXFUN(timer_create, 145: (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)); 146: 147: /* Delete a Per_process Timer, P1003.1b-1993, p. 266 */ 148: 149: int _EXFUN(timer_delete, (timer_t timerid)); 150: 151: /* Per-Process Timers, P1003.1b-1993, p. 267 */ 152: 153: int _EXFUN(timer_settime, 154: (timer_t timerid, int flags, const struct itimerspec *value, 155: struct itimerspec *ovalue)); 156: int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value)); 157: int _EXFUN(timer_getoverrun, (timer_t timerid)); 158: 159: /* High Resolution Sleep, P1003.1b-1993, p. 269 */ 160: 161: int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); 162: 163: #ifdef __cplusplus 164: } 165: #endif 166: #else 167: #ifdef __CYGWIN__ 168: #ifdef __cplusplus 169: extern "C" { 170: #endif 171: int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); 172: #ifdef __cplusplus 173: } 174: #endif 175: #endif /* __CYGWIN__ */ 176: #endif /* _POSIX_TIMERS */ 177: 178: #ifdef __cplusplus 179: extern "C" { 180: #endif 181: 182: /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */ 183: 184: /* values for the clock enable attribute */ 185: 186: #define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */ 187: #define CLOCK_DISABLED 0 /* clock is disabled */ 188: 189: /* values for the pthread cputime_clock_allowed attribute */ 190: 191: #define CLOCK_ALLOWED 1 /* If a thread is created with this value a */ 192: /* CPU-time clock attached to that thread */ 193: /* shall be accessible. */ 194: #define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */ 195: /* thread shall not have a CPU-time clock */ 196: /* accessible. */ 197: 198: /* Manifest Constants, P1003.1b-1993, p. 262 */ 199: 200: #define CLOCK_REALTIME (clockid_t)1 201: 202: /* Flag indicating time is "absolute" with respect to the clock 203: associated with a time. */ 204: 205: #define TIMER_ABSTIME 4 206: #ifdef __CYGWIN__ 207: # define TIMER_RELTIME 0 /* For compatibility with HP/UX, Solaris, 208: others? */ 209: #endif 210: 211: /* Manifest Constants, P1003.4b/D8, p. 55 */ 212: 213: #if defined(_POSIX_CPUTIME) 214: 215: /* When used in a clock or timer function call, this is interpreted as 216: the identifier of the CPU_time clock associated with the PROCESS 217: making the function call. */ 218: 219: #define CLOCK_PROCESS_CPUTIME (clockid_t)2 220: 221: #endif 222: 223: #if defined(_POSIX_THREAD_CPUTIME) 224: 225: /* When used in a clock or timer function call, this is interpreted as 226: the identifier of the CPU_time clock associated with the THREAD 227: making the function call. */ 228: 229: #define CLOCK_THREAD_CPUTIME (clockid_t)3 230: 231: #endif 232: 233: #if defined(_POSIX_CPUTIME) 234: 235: /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */ 236: 237: int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id)); 238: 239: #endif /* _POSIX_CPUTIME */ 240: 241: #if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME) 242: 243: /* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */ 244: 245: int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr)); 246: int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr)); 247: 248: #endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */ 249: 250: #ifdef __cplusplus 251: } 252: #endif 253: 254: #endif /* _TIME_H_ */ 255: 256: