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