Subversion Repositories Kolibri OS

Rev

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

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