Replace previous change by different test
[minix.git] / include / time.h
blob563168074f48aaecdc913cf4282db0848a568aff
1 /* $NetBSD: time.h,v 1.41 2012/10/02 01:42:06 christos Exp $ */
3 /*
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
39 #ifndef _TIME_H_
40 #define _TIME_H_
42 #include <sys/cdefs.h>
43 #include <sys/featuretest.h>
44 #include <machine/ansi.h>
46 #include <sys/null.h>
48 #ifdef _BSD_CLOCK_T_
49 typedef _BSD_CLOCK_T_ clock_t;
50 #undef _BSD_CLOCK_T_
51 #endif
53 #ifdef _BSD_TIME_T_
54 typedef _BSD_TIME_T_ time_t;
55 #undef _BSD_TIME_T_
56 #endif
58 #ifdef _BSD_SIZE_T_
59 typedef _BSD_SIZE_T_ size_t;
60 #undef _BSD_SIZE_T_
61 #endif
63 #ifdef _BSD_CLOCKID_T_
64 typedef _BSD_CLOCKID_T_ clockid_t;
65 #undef _BSD_CLOCKID_T_
66 #endif
68 #ifndef __minix
69 #ifdef _BSD_TIMER_T_
70 typedef _BSD_TIMER_T_ timer_t;
71 #undef _BSD_TIMER_T_
72 #endif
73 #endif /* !__minix */
75 #ifdef __minix
76 #define CLOCKS_PER_SEC 60
77 #else
78 #define CLOCKS_PER_SEC 100
79 #endif
81 struct tm {
82 int tm_sec; /* seconds after the minute [0-61] */
83 int tm_min; /* minutes after the hour [0-59] */
84 int tm_hour; /* hours since midnight [0-23] */
85 int tm_mday; /* day of the month [1-31] */
86 int tm_mon; /* months since January [0-11] */
87 int tm_year; /* years since 1900 */
88 int tm_wday; /* days since Sunday [0-6] */
89 int tm_yday; /* days since January 1 [0-365] */
90 int tm_isdst; /* Daylight Savings Time flag */
91 long tm_gmtoff; /* offset from UTC in seconds */
92 __aconst char *tm_zone; /* timezone abbreviation */
95 __BEGIN_DECLS
96 char *asctime(const struct tm *);
97 clock_t clock(void);
98 #ifndef __LIBC12_SOURCE__
99 char *ctime(const time_t *) __RENAME(__ctime50);
100 double difftime(time_t, time_t) __RENAME(__difftime50);
101 struct tm *gmtime(const time_t *) __RENAME(__gmtime50);
102 #ifndef __MINIX
103 struct tm *localtime(const time_t *) __RENAME(__locatime50);
104 #else
105 struct tm *localtime(const time_t *) __RENAME(__localtime50);
106 #endif
107 time_t time(time_t *) __RENAME(__time50);
108 time_t mktime(struct tm *) __RENAME(__mktime50);
109 #endif
110 size_t strftime(char * __restrict, size_t, const char * __restrict,
111 const struct tm * __restrict)
112 __attribute__((__format__(__strftime__, 3, 0)));
114 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
115 defined(_NETBSD_SOURCE)
116 #ifndef __LIBC12_SOURCE__
118 * CLK_TCK uses libc's internal __sysconf() to retrieve the machine's
119 * HZ. The value of _SC_CLK_TCK is 39 -- we hard code it so we do not
120 * need to include unistd.h
122 long __sysconf(int);
123 #ifdef __minix
124 #define CLK_TCK (__sysconf(3))
125 #else
126 #define CLK_TCK (__sysconf(39))
127 #endif /* !__minix */
128 #endif
129 #endif
131 extern __aconst char *tzname[2];
132 #ifndef __LIBC12_SOURCE__
133 void tzset(void) __RENAME(__tzset50);
134 #endif
137 * X/Open Portability Guide >= Issue 4
139 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
140 extern int daylight;
141 #ifndef __LIBC12_SOURCE__
142 extern long int timezone __RENAME(__timezone13);
143 #endif
144 char *strptime(const char * __restrict, const char * __restrict,
145 struct tm * __restrict);
146 #endif
148 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
149 defined(_NETBSD_SOURCE)
150 struct tm *getdate(const char *);
151 extern int getdate_err;
152 #endif
154 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
155 defined(_NETBSD_SOURCE)
156 #include <sys/time.h> /* XXX for struct timespec */
157 struct sigevent;
158 struct itimerspec;
159 int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
160 #ifndef __LIBC12_SOURCE__
161 #ifndef __minix
162 int clock_getres(clockid_t, struct timespec *)
163 __RENAME(__clock_getres50);
164 int clock_gettime(clockid_t, struct timespec *)
165 __RENAME(__clock_gettime50);
166 int clock_settime(clockid_t, const struct timespec *)
167 __RENAME(__clock_settime50);
168 #endif /* !__minix */
169 int nanosleep(const struct timespec *, struct timespec *)
170 __RENAME(__nanosleep50);
171 #ifndef __minix
172 int timer_gettime(timer_t, struct itimerspec *) __RENAME(__timer_gettime50);
173 int timer_settime(timer_t, int, const struct itimerspec * __restrict,
174 struct itimerspec * __restrict) __RENAME(__timer_settime50);
175 #endif /* !__minix */
176 #endif
177 #ifndef __minix
178 int timer_create(clockid_t, struct sigevent * __restrict,
179 timer_t * __restrict);
180 int timer_delete(timer_t);
181 int timer_getoverrun(timer_t);
182 #endif /* __minix */
183 #endif /* _POSIX_C_SOURCE >= 199309 || _XOPEN_SOURCE >= 500 || ... */
185 #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
186 defined(_REENTRANT) || defined(_NETBSD_SOURCE)
187 char *asctime_r(const struct tm * __restrict, char * __restrict);
188 #ifndef __LIBC12_SOURCE__
189 char *ctime_r(const time_t *, char *) __RENAME(__ctime_r50);
190 struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict)
191 __RENAME(__gmtime_r50);
192 struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict)
193 __RENAME(__localtime_r50);
194 #endif
195 #endif
197 #if defined(_NETBSD_SOURCE)
199 typedef struct __state *timezone_t;
201 #ifndef __LIBC12_SOURCE__
202 time_t time2posix(time_t) __RENAME(__time2posix50);
203 time_t posix2time(time_t) __RENAME(__posix2time50);
204 time_t timegm(struct tm *) __RENAME(__timegm50);
205 time_t timeoff(struct tm *, long) __RENAME(__timeoff50);
206 time_t timelocal(struct tm *) __RENAME(__timelocal50);
207 struct tm *offtime(const time_t *, long) __RENAME(__offtime50);
208 void tzsetwall(void) __RENAME(__tzsetwall50);
210 struct tm *offtime_r(const time_t *, long, struct tm *) __RENAME(__offtime_r50);
211 struct tm *localtime_rz(const timezone_t, const time_t * __restrict,
212 struct tm * __restrict) __RENAME(__localtime_rz50);
213 char *ctime_rz(const timezone_t, const time_t *, char *) __RENAME(__ctime_rz50);
214 time_t mktime_z(const timezone_t, struct tm *) __RENAME(__mktime_z50);
215 time_t timelocal_z(const timezone_t, struct tm *) __RENAME(__timelocal_z50);
216 time_t time2posix_z(const timezone_t, time_t) __RENAME(__time2posix_z50);
217 time_t posix2time_z(const timezone_t, time_t) __RENAME(__posix2time_z50);
218 timezone_t tzalloc(const char *) __RENAME(__tzalloc50);
219 void tzfree(const timezone_t) __RENAME(__tzfree50);
220 const char *tzgetname(const timezone_t, int) __RENAME(__tzgetname50);
221 #endif
223 size_t strftime_z(const timezone_t, char * __restrict, size_t,
224 const char * __restrict, const struct tm * __restrict)
225 __attribute__((__format__(__strftime__, 4, 0)));
227 #endif /* _NETBSD_SOURCE */
229 #ifdef __minix
230 int stime(time_t *_top);
231 #endif /* __minix */
233 __END_DECLS
235 #endif /* !_TIME_H_ */