4
* Struct and function declarations for dealing with time.
11
#include <sys/reent.h>
17
/* Get _CLOCKS_PER_SEC_ */
18
#include <machine/time.h>
20
#ifndef _CLOCKS_PER_SEC_
21
#define _CLOCKS_PER_SEC_ 1000
24
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
25
#define CLK_TCK CLOCKS_PER_SEC
29
#include <sys/types.h>
49
clock_t _EXFUN(clock, (void));
50
double _EXFUN(difftime, (time_t _time2, time_t _time1));
51
time_t _EXFUN(mktime, (struct tm *_timeptr));
52
time_t _EXFUN(time, (time_t *_timer));
54
char *_EXFUN(asctime, (const struct tm *_tblock));
55
char *_EXFUN(ctime, (const time_t *_time));
56
struct tm *_EXFUN(gmtime, (const time_t *_timer));
57
struct tm *_EXFUN(localtime,(const time_t *_timer));
59
size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t));
61
char *_EXFUN(asctime_r, (const struct tm *, char *));
62
char *_EXFUN(ctime_r, (const time_t *, char *));
63
struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *));
64
struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *));
72
#ifndef __STRICT_ANSI__
73
char *_EXFUN(strptime, (const char *, const char *, struct tm *));
74
_VOID _EXFUN(tzset, (_VOID));
75
_VOID _EXFUN(_tzset_r, (struct _reent *));
77
typedef struct __tzrule_struct
85
long offset; /* Match type of _timezone. */
88
typedef struct __tzinfo_struct
92
__tzrule_type __tzrule[2];
95
__tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
97
/* getdate functions */
101
#define getdate_err (*__getdate_err())
102
int *_EXFUN(__getdate_err,(_VOID));
104
struct tm * _EXFUN(getdate, (const char *));
105
/* getdate_err is set to one of the following values to indicate the error.
106
1 the DATEMSK environment variable is null or undefined,
107
2 the template file cannot be opened for reading,
108
3 failed to get file status information,
109
4 the template file is not a regular file,
110
5 an error is encountered while reading the template file,
111
6 memory allication failed (not enough memory available),
112
7 there is no line in the template that matches the input,
113
8 invalid input specification */
114
#endif /* !_REENT_ONLY */
116
/* getdate_r returns the error code as above */
117
int _EXFUN(getdate_r, (const char *, struct tm *));
118
#endif /* HAVE_GETDATE */
120
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
121
extern __IMPORT long _timezone;
122
extern __IMPORT int _daylight;
123
extern __IMPORT char *_tzname[2];
125
/* POSIX defines the external tzname being defined in time.h */
127
#define tzname _tzname
129
#endif /* !__STRICT_ANSI__ */
135
#include <sys/features.h>
138
#include <cygwin/time.h>
139
#endif /*__CYGWIN__*/
141
#if defined(EMSCRIPTEN) || defined(_POSIX_TIMERS)
149
/* Clocks, P1003.1b-1993, p. 263 */
151
int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp));
152
int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp));
153
int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res));
155
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
157
int _EXFUN(timer_create,
158
(clockid_t clock_id, struct sigevent *evp, timer_t *timerid));
160
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
162
int _EXFUN(timer_delete, (timer_t timerid));
164
/* Per-Process Timers, P1003.1b-1993, p. 267 */
166
int _EXFUN(timer_settime,
167
(timer_t timerid, int flags, const struct itimerspec *value,
168
struct itimerspec *ovalue));
169
int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value));
170
int _EXFUN(timer_getoverrun, (timer_t timerid));
172
/* High Resolution Sleep, P1003.1b-1993, p. 269 */
174
int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
179
#endif /* _POSIX_TIMERS */
185
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
187
/* values for the clock enable attribute */
189
#define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */
190
#define CLOCK_DISABLED 0 /* clock is disabled */
192
/* values for the pthread cputime_clock_allowed attribute */
194
#define CLOCK_ALLOWED 1 /* If a thread is created with this value a */
195
/* CPU-time clock attached to that thread */
196
/* shall be accessible. */
197
#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
198
/* thread shall not have a CPU-time clock */
201
/* Manifest Constants, P1003.1b-1993, p. 262 */
203
#define CLOCK_REALTIME (clockid_t)1
205
/* Flag indicating time is "absolute" with respect to the clock
206
associated with a time. */
208
#define TIMER_ABSTIME 4
210
/* Manifest Constants, P1003.4b/D8, p. 55 */
212
#if defined(_POSIX_CPUTIME)
214
/* When used in a clock or timer function call, this is interpreted as
215
the identifier of the CPU_time clock associated with the PROCESS
216
making the function call. */
218
#define CLOCK_PROCESS_CPUTIME (clockid_t)2
222
#if defined(_POSIX_THREAD_CPUTIME)
224
/* When used in a clock or timer function call, this is interpreted as
225
the identifier of the CPU_time clock associated with the THREAD
226
making the function call. */
228
#define CLOCK_THREAD_CPUTIME (clockid_t)3
232
#if defined(_POSIX_MONOTONIC_CLOCK) || defined(EMSCRIPTEN)
234
/* The identifier for the system-wide monotonic clock, which is defined
235
* as a clock whose value cannot be set via clock_settime() and which
236
* cannot have backward clock jumps. */
238
#define CLOCK_MONOTONIC (clockid_t)4
242
#if defined(_POSIX_CPUTIME)
244
/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
246
int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id));
248
#endif /* _POSIX_CPUTIME */
250
#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
252
/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
254
int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr));
255
int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr));
257
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
261
int _EXFUN(stime, (time_t *t));
262
time_t _EXFUN(timegm, (struct tm *t));
263
int _EXFUN(dysize, (int year));
269
#endif /* _TIME_H_ */