~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to system/include/libc/time.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <sys/reent.h>
 
12
 
 
13
#ifndef NULL
 
14
#define NULL    0
 
15
#endif
 
16
 
 
17
/* Get _CLOCKS_PER_SEC_ */
 
18
#include <machine/time.h>
 
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 <stddef.h>
 
28
 
 
29
#include <sys/types.h>
 
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
  /* XXX Emscripten */
 
45
  int tm_gmtoff;
 
46
  char *tm_zone;
 
47
};
 
48
 
 
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));
 
53
#ifndef _REENT_ONLY
 
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));
 
58
#endif
 
59
size_t     _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t));
 
60
 
 
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 *));
 
65
 
 
66
_END_STD_C
 
67
 
 
68
#ifdef __cplusplus
 
69
extern "C" {
 
70
#endif
 
71
 
 
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 *));
 
76
 
 
77
typedef struct __tzrule_struct
 
78
{
 
79
  char ch;
 
80
  int m;
 
81
  int n;
 
82
  int d;
 
83
  int s;
 
84
  time_t change;
 
85
  long offset; /* Match type of _timezone. */
 
86
} __tzrule_type;
 
87
 
 
88
typedef struct __tzinfo_struct
 
89
{
 
90
  int __tznorth;
 
91
  int __tzyear;
 
92
  __tzrule_type __tzrule[2];
 
93
} __tzinfo_type;
 
94
 
 
95
__tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
 
96
 
 
97
/* getdate functions */
 
98
 
 
99
#ifdef HAVE_GETDATE
 
100
#ifndef _REENT_ONLY
 
101
#define getdate_err (*__getdate_err())
 
102
int *_EXFUN(__getdate_err,(_VOID));
 
103
 
 
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 */
 
115
 
 
116
/* getdate_r returns the error code as above */
 
117
int             _EXFUN(getdate_r, (const char *, struct tm *));
 
118
#endif /* HAVE_GETDATE */
 
119
 
 
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];
 
124
 
 
125
/* POSIX defines the external tzname being defined in time.h */
 
126
#ifndef tzname
 
127
#define tzname _tzname
 
128
#endif
 
129
#endif /* !__STRICT_ANSI__ */
 
130
 
 
131
#ifdef __cplusplus
 
132
}
 
133
#endif
 
134
 
 
135
#include <sys/features.h>
 
136
 
 
137
#ifdef __CYGWIN__
 
138
#include <cygwin/time.h>
 
139
#endif /*__CYGWIN__*/
 
140
 
 
141
#if defined(EMSCRIPTEN) || defined(_POSIX_TIMERS)
 
142
 
 
143
#include <signal.h>
 
144
 
 
145
#ifdef __cplusplus
 
146
extern "C" {
 
147
#endif
 
148
 
 
149
/* Clocks, P1003.1b-1993, p. 263 */
 
150
 
 
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));
 
154
 
 
155
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
 
156
 
 
157
int _EXFUN(timer_create,
 
158
  (clockid_t clock_id, struct sigevent *evp, timer_t *timerid));
 
159
 
 
160
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
 
161
 
 
162
int _EXFUN(timer_delete, (timer_t timerid));
 
163
 
 
164
/* Per-Process Timers, P1003.1b-1993, p. 267 */
 
165
 
 
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));
 
171
 
 
172
/* High Resolution Sleep, P1003.1b-1993, p. 269 */
 
173
 
 
174
int _EXFUN(nanosleep, (const struct timespec  *rqtp, struct timespec *rmtp));
 
175
 
 
176
#ifdef __cplusplus
 
177
}
 
178
#endif
 
179
#endif /* _POSIX_TIMERS */
 
180
 
 
181
#ifdef __cplusplus
 
182
extern "C" {
 
183
#endif
 
184
 
 
185
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
 
186
 
 
187
/* values for the clock enable attribute */
 
188
 
 
189
#define CLOCK_ENABLED  1  /* clock is enabled, i.e. counting execution time */
 
190
#define CLOCK_DISABLED 0  /* clock is disabled */
 
191
 
 
192
/* values for the pthread cputime_clock_allowed attribute */
 
193
 
 
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 */
 
199
                           /*   accessible. */
 
200
 
 
201
/* Manifest Constants, P1003.1b-1993, p. 262 */
 
202
 
 
203
#define CLOCK_REALTIME (clockid_t)1
 
204
 
 
205
/* Flag indicating time is "absolute" with respect to the clock
 
206
   associated with a time.  */
 
207
 
 
208
#define TIMER_ABSTIME   4
 
209
 
 
210
/* Manifest Constants, P1003.4b/D8, p. 55 */
 
211
 
 
212
#if defined(_POSIX_CPUTIME)
 
213
 
 
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.  */
 
217
 
 
218
#define CLOCK_PROCESS_CPUTIME (clockid_t)2
 
219
 
 
220
#endif
 
221
 
 
222
#if defined(_POSIX_THREAD_CPUTIME)
 
223
 
 
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.  */
 
227
 
 
228
#define CLOCK_THREAD_CPUTIME (clockid_t)3
 
229
 
 
230
#endif
 
231
 
 
232
#if defined(_POSIX_MONOTONIC_CLOCK) || defined(EMSCRIPTEN)
 
233
 
 
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. */
 
237
 
 
238
#define CLOCK_MONOTONIC (clockid_t)4
 
239
 
 
240
#endif
 
241
 
 
242
#if defined(_POSIX_CPUTIME)
 
243
 
 
244
/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
 
245
 
 
246
int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id));
 
247
 
 
248
#endif /* _POSIX_CPUTIME */
 
249
 
 
250
#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
 
251
 
 
252
/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
 
253
 
 
254
int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr));
 
255
int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr));
 
256
 
 
257
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
 
258
 
 
259
/* XXX Emscripten */
 
260
 
 
261
int _EXFUN(stime, (time_t *t));
 
262
time_t _EXFUN(timegm, (struct tm *t));
 
263
int _EXFUN(dysize, (int year));
 
264
 
 
265
#ifdef __cplusplus
 
266
}
 
267
#endif
 
268
 
 
269
#endif /* _TIME_H_ */
 
270