Subversion Repositories Kolibri OS

Rev

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