Subversion Repositories Kolibri OS

Rev

Rev 6099 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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