4 * Struct and function declarations for dealing with time.
11 #include <sys/cdefs.h>
12 #include <sys/reent.h>
18 /* Get _CLOCKS_PER_SEC_ */
19 #include <machine/time.h>
21 #ifndef _CLOCKS_PER_SEC_
22 #define _CLOCKS_PER_SEC_ 1000
25 #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
26 #define CLK_TCK CLOCKS_PER_SEC
28 #include <sys/types.h>
29 #include <sys/timespec.h>
31 #if __POSIX_VISIBLE >= 200809
32 #include <sys/_locale.h>
52 const char *__TM_ZONE
;
57 double difftime (time_t _time2
, time_t _time1
);
58 time_t mktime (struct tm
*_timeptr
);
59 time_t time (time_t *_timer
);
61 char *asctime (const struct tm
*_tblock
);
62 char *ctime (const time_t *_time
);
63 struct tm
*gmtime (const time_t *_timer
);
64 struct tm
*localtime (const time_t *_timer
);
66 size_t strftime (char *__restrict _s
,
67 size_t _maxsize
, const char *__restrict _fmt
,
68 const struct tm
*__restrict _t
);
70 #if __POSIX_VISIBLE >= 200809
71 extern size_t strftime_l (char *__restrict _s
, size_t _maxsize
,
72 const char *__restrict _fmt
,
73 const struct tm
*__restrict _t
, locale_t _l
);
76 char *asctime_r (const struct tm
*__restrict
,
78 char *ctime_r (const time_t *, char *);
79 struct tm
*gmtime_r (const time_t *__restrict
,
80 struct tm
*__restrict
);
81 struct tm
*localtime_r (const time_t *__restrict
,
82 struct tm
*__restrict
);
91 char *strptime (const char *__restrict
,
92 const char *__restrict
,
93 struct tm
*__restrict
);
96 char *strptime_l (const char *__restrict
, const char *__restrict
,
97 struct tm
*__restrict
, locale_t
);
103 void _tzset_r (struct _reent
*);
105 /* getdate functions */
108 #if __XSI_VISIBLE >= 4
110 #define getdate_err (*__getdate_err())
111 int *__getdate_err (void);
113 struct tm
* getdate (const char *);
114 /* getdate_err is set to one of the following values to indicate the error.
115 1 the DATEMSK environment variable is null or undefined,
116 2 the template file cannot be opened for reading,
117 3 failed to get file status information,
118 4 the template file is not a regular file,
119 5 an error is encountered while reading the template file,
120 6 memory allication failed (not enough memory available),
121 7 there is no line in the template that matches the input,
122 8 invalid input specification */
123 #endif /* !_REENT_ONLY */
124 #endif /* __XSI_VISIBLE >= 4 */
127 /* getdate_r returns the error code as above */
128 int getdate_r (const char *, struct tm
*);
129 #endif /* __GNU_VISIBLE */
130 #endif /* HAVE_GETDATE */
132 /* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
133 #if __SVID_VISIBLE || __XSI_VISIBLE
134 extern __IMPORT
long _timezone
;
135 extern __IMPORT
int _daylight
;
138 extern __IMPORT
char *_tzname
[2];
140 /* POSIX defines the external tzname being defined in time.h */
142 #define tzname _tzname
144 #endif /* __POSIX_VISIBLE */
150 #include <sys/features.h>
153 #include <cygwin/time.h>
154 #endif /*__CYGWIN__*/
156 #if defined(_POSIX_TIMERS)
164 /* Clocks, P1003.1b-1993, p. 263 */
166 int clock_settime (clockid_t clock_id
, const struct timespec
*tp
);
167 int clock_gettime (clockid_t clock_id
, struct timespec
*tp
);
168 int clock_getres (clockid_t clock_id
, struct timespec
*res
);
170 /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
172 int timer_create (clockid_t clock_id
,
173 struct sigevent
*__restrict evp
,
174 timer_t
*__restrict timerid
);
176 /* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
178 int timer_delete (timer_t timerid
);
180 /* Per-Process Timers, P1003.1b-1993, p. 267 */
182 int timer_settime (timer_t timerid
, int flags
,
183 const struct itimerspec
*__restrict value
,
184 struct itimerspec
*__restrict ovalue
);
185 int timer_gettime (timer_t timerid
, struct itimerspec
*value
);
186 int timer_getoverrun (timer_t timerid
);
188 /* High Resolution Sleep, P1003.1b-1993, p. 269 */
190 int nanosleep (const struct timespec
*rqtp
, struct timespec
*rmtp
);
195 #endif /* _POSIX_TIMERS */
197 #if defined(_POSIX_CLOCK_SELECTION)
203 int clock_nanosleep (clockid_t clock_id
, int flags
,
204 const struct timespec
*rqtp
, struct timespec
*rmtp
);
210 #endif /* _POSIX_CLOCK_SELECTION */
216 /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
218 /* values for the clock enable attribute */
220 #define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */
221 #define CLOCK_DISABLED 0 /* clock is disabled */
223 /* values for the pthread cputime_clock_allowed attribute */
225 #define CLOCK_ALLOWED 1 /* If a thread is created with this value a */
226 /* CPU-time clock attached to that thread */
227 /* shall be accessible. */
228 #define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
229 /* thread shall not have a CPU-time clock */
232 /* Flag indicating time is "absolute" with respect to the clock
233 associated with a time. Value 4 is historic. */
235 #define TIMER_ABSTIME 4
237 /* Manifest Constants, P1003.1b-1993, p. 262 */
240 #define CLOCK_REALTIME_COARSE (0)
243 #define CLOCK_REALTIME (1)
245 /* Manifest Constants, P1003.4b/D8, p. 55 */
247 #if defined(_POSIX_CPUTIME)
249 /* When used in a clock or timer function call, this is interpreted as
250 the identifier of the CPU_time clock associated with the PROCESS
251 making the function call. */
253 #define CLOCK_PROCESS_CPUTIME_ID (2)
257 #if defined(_POSIX_THREAD_CPUTIME)
259 /* When used in a clock or timer function call, this is interpreted as
260 the identifier of the CPU_time clock associated with the THREAD
261 making the function call. */
263 #define CLOCK_THREAD_CPUTIME_ID (3)
267 #if defined(_POSIX_MONOTONIC_CLOCK)
269 /* The identifier for the system-wide monotonic clock, which is defined
270 * as a clock whose value cannot be set via clock_settime() and which
271 * cannot have backward clock jumps. */
273 #define CLOCK_MONOTONIC (4)
279 #define CLOCK_MONOTONIC_RAW (5)
281 #define CLOCK_MONOTONIC_COARSE (6)
283 #define CLOCK_BOOTTIME (7)
285 #define CLOCK_REALTIME_ALARM (8)
287 #define CLOCK_BOOTTIME_ALARM (9)
291 #if defined(_POSIX_CPUTIME)
293 /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
295 int clock_getcpuclockid (pid_t pid
, clockid_t
*clock_id
);
297 #endif /* _POSIX_CPUTIME */
299 #if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
301 /* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
303 int clock_setenable_attr (clockid_t clock_id
, int attr
);
304 int clock_getenable_attr (clockid_t clock_id
, int *attr
);
306 #endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
312 #endif /* _TIME_H_ */