source: trunk/libs/newlib/src/newlib/libc/sys/linux/include/time.h

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 6.1 KB
Line 
1/*
2 * time.h
3 *
4 * Struct and function declarations for dealing with time.
5 */
6
7#ifndef _TIME_H_
8
9#include "_ansi.h"
10#include <sys/reent.h>
11#include <sys/linux_time.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#ifndef NULL
18#define NULL    0
19#endif
20
21/* Get _CLOCKS_PER_SEC_ */
22#include <machine/time.h>
23#include <sys/types.h>
24
25/* Time Value Specification Structures, P1003.1b-1993, p. 261 */
26#ifndef _STRUCT_TIMESPEC
27#define _STRUCT_TIMESPEC
28struct timespec {
29  time_t  tv_sec;   /* Seconds */
30  long    tv_nsec;  /* Nanoseconds */
31};
32#endif /* !_STRUCT_TIMESPEC */
33
34#ifndef __need_timespec
35
36#define _TIME_H_ 1
37
38#ifndef _CLOCKS_PER_SEC_
39#define _CLOCKS_PER_SEC_ 1000
40#endif
41
42#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
43#define CLK_TCK CLOCKS_PER_SEC
44#define __need_size_t
45#include <stddef.h>
46
47struct tm
48{
49  int   tm_sec;
50  int   tm_min;
51  int   tm_hour;
52  int   tm_mday;
53  int   tm_mon;
54  int   tm_year;
55  int   tm_wday;
56  int   tm_yday;
57  int   tm_isdst;
58};
59
60#ifndef __timer_t_defined
61# define __timer_t_defined      1
62typedef __timer_t timer_t;
63#endif
64
65clock_t    clock (void);
66double     difftime (time_t _time2, time_t _time1);
67time_t     mktime (struct tm *_timeptr);
68time_t     time (time_t *_timer);
69#ifndef _REENT_ONLY
70char      *asctime (const struct tm *_tblock);
71char      *ctime (const time_t *_time);
72struct tm *gmtime (const time_t *_timer);
73struct tm *localtime (const time_t *_timer);
74#endif
75size_t     strftime (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t);
76
77char      *asctime_r    (const struct tm *, char *);
78char      *ctime_r      (const time_t *, char *);
79struct tm *gmtime_r     (const time_t *, struct tm *);
80struct tm *localtime_r  (const time_t *, struct tm *);
81
82#ifndef __STRICT_ANSI__
83char      *strptime (const char *, const char *, struct tm *);
84void      tzset         (void);
85void      _tzset_r      (struct _reent *);
86
87typedef struct __tzrule_struct
88{
89  char ch;
90  int m;
91  int n;
92  int d;
93  int s;
94  time_t change;
95  long offset; /* Match type of _timezone. */
96} __tzrule_type;
97
98typedef struct __tzinfo_struct
99{
100  int __tznorth;
101  int __tzyear;
102  __tzrule_type __tzrule[2];
103} __tzinfo_type;
104
105__tzinfo_type *__gettzinfo (void);
106
107/* getdate functions */
108
109#ifndef _REENT_ONLY
110#define getdate_err (*__getdate_err())
111int *__getdate_err (void);
112
113struct tm *     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 */
126int             getdate_r (const char *, struct tm *);
127
128/* defines for the opengroup specifications Derived from Issue 1 of the SVID.  */
129extern __IMPORT long _timezone;
130extern __IMPORT int _daylight;
131extern __IMPORT char *_tzname[2];
132
133/* POSIX defines the external tzname being defined in time.h */
134#ifndef tzname
135#define tzname _tzname
136#endif
137
138#endif /* !__STRICT_ANSI__ */
139
140#include <sys/features.h>
141
142#if defined(_POSIX_TIMERS)
143
144#include <signal.h>
145
146/* Clocks, P1003.1b-1993, p. 263 */
147
148int clock_settime (clockid_t clock_id, const struct timespec *tp);
149int clock_gettime (clockid_t clock_id, struct timespec *tp);
150int clock_getres (clockid_t clock_id, struct timespec *res);
151
152/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
153
154int timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid);
155
156/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
157
158int timer_delete (timer_t timerid);
159
160/* Per-Process Timers, P1003.1b-1993, p. 267 */
161
162int timer_settime (timer_t timerid, int flags, const struct itimerspec *value,
163   struct itimerspec *ovalue);
164int timer_gettime (timer_t timerid, struct itimerspec *value);
165int timer_getoverrun (timer_t timerid);
166
167/* High Resolution Sleep, P1003.1b-1993, p. 269 */
168
169int nanosleep (const struct timespec  *rqtp, struct timespec *rmtp);
170
171#endif /* _POSIX_TIMERS */
172
173/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
174
175/* values for the clock enable attribute */
176
177#define CLOCK_ENABLED  1  /* clock is enabled, i.e. counting execution time */
178#define CLOCK_DISABLED 0  /* clock is disabled */
179
180/* values for the pthread cputime_clock_allowed attribute */
181
182#define CLOCK_ALLOWED    1 /* If a thread is created with this value a */
183                           /*   CPU-time clock attached to that thread */
184                           /*   shall be accessible. */
185#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
186                           /*   thread shall not have a CPU-time clock */
187                           /*   accessible. */
188
189/* Manifest Constants, P1003.1b-1993, p. 262 */
190
191#define CLOCK_REALTIME (clockid_t)1
192
193/* Flag indicating time is "absolute" with respect to the clock
194   associated with a time.  */
195
196#define TIMER_ABSTIME  4
197
198/* Manifest Constants, P1003.4b/D8, p. 55 */
199
200#if defined(_POSIX_CPUTIME)
201
202/* When used in a clock or timer function call, this is interpreted as
203   the identifier of the CPU_time clock associated with the PROCESS
204   making the function call.  */
205
206#define CLOCK_PROCESS_CPUTIME_ID (clockid_t)2
207
208#endif
209
210#if defined(_POSIX_THREAD_CPUTIME)
211
212/*  When used in a clock or timer function call, this is interpreted as
213    the identifier of the CPU_time clock associated with the THREAD
214    making the function call.  */
215
216#define CLOCK_THREAD_CPUTIME_ID (clockid_t)3
217
218#endif
219
220#if defined(_POSIX_CPUTIME)
221
222/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
223
224int clock_getcpuclockid (pid_t pid, clockid_t *clock_id);
225
226#endif /* _POSIX_CPUTIME */
227
228#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
229
230/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
231
232int clock_setenable_attr (clockid_t clock_id, int attr);
233int clock_getenable_attr (clockid_t clock_id, int *attr);
234
235#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
236
237#ifdef __cplusplus
238}
239#endif
240
241#endif /* ! __need_timespec */
242
243#undef __need_timespec
244
245#endif /* _TIME_H_ */
246
Note: See TracBrowser for help on using the repository browser.