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