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