1 /* $NetBSD: time.h,v 1.36 2008/04/01 19:23:28 drochner Exp $ */
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
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
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
42 #include <sys/cdefs.h>
43 #include <sys/featuretest.h>
44 #include <machine/ansi.h>
49 typedef _BSD_CLOCK_T_
clock_t;
54 typedef _BSD_TIME_T_
time_t;
59 typedef _BSD_SIZE_T_
size_t;
63 #ifdef _BSD_CLOCKID_T_
64 typedef _BSD_CLOCKID_T_ clockid_t
;
65 #undef _BSD_CLOCKID_T_
69 typedef _BSD_TIMER_T_ timer_t
;
73 #define CLOCKS_PER_SEC 100
76 int tm_sec
; /* seconds after the minute [0-61] */
77 int tm_min
; /* minutes after the hour [0-59] */
78 int tm_hour
; /* hours since midnight [0-23] */
79 int tm_mday
; /* day of the month [1-31] */
80 int tm_mon
; /* months since January [0-11] */
81 int tm_year
; /* years since 1900 */
82 int tm_wday
; /* days since Sunday [0-6] */
83 int tm_yday
; /* days since January 1 [0-365] */
84 int tm_isdst
; /* Daylight Savings Time flag */
85 long tm_gmtoff
; /* offset from UTC in seconds */
86 __aconst
char *tm_zone
; /* timezone abbreviation */
90 char *asctime(const struct tm
*);
92 char *ctime(const time_t *);
93 double difftime(time_t, time_t);
94 struct tm
*gmtime(const time_t *);
95 struct tm
*localtime(const time_t *);
96 time_t mktime(struct tm
*);
97 size_t strftime(char * __restrict
, size_t, const char * __restrict
,
98 const struct tm
* __restrict
)
99 __attribute__((__format__(__strftime__
, 3, 0)));
100 time_t time(time_t *);
102 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
103 defined(_NETBSD_SOURCE)
104 #ifndef __LIBC12_SOURCE__
106 * CLK_TCK uses libc's internal __sysconf() to retrieve the machine's
107 * HZ. The value of _SC_CLK_TCK is 39 -- we hard code it so we do not
108 * need to include unistd.h
111 #define CLK_TCK (__sysconf(39))
115 extern __aconst
char *tzname
[2];
119 * X/Open Portability Guide >= Issue 4
121 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
123 #ifndef __LIBC12_SOURCE__
124 extern long int timezone
__RENAME(__timezone13
);
126 char *strptime(const char * __restrict
, const char * __restrict
,
127 struct tm
* __restrict
);
130 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
131 defined(_NETBSD_SOURCE)
132 #include <sys/time.h> /* XXX for struct timespec */
135 int clock_getres(clockid_t
, struct timespec
*);
136 int clock_gettime(clockid_t
, struct timespec
*);
137 int clock_settime(clockid_t
, const struct timespec
*);
138 int nanosleep(const struct timespec
*, struct timespec
*);
139 int timer_create(clockid_t
, struct sigevent
* __restrict
,
140 timer_t
* __restrict
);
141 int timer_delete(timer_t
);
142 int timer_getoverrun(timer_t
);
143 int timer_gettime(timer_t
, struct itimerspec
*);
144 int timer_settime(timer_t
, int, const struct itimerspec
* __restrict
,
145 struct itimerspec
* __restrict
);
146 #endif /* _POSIX_C_SOURCE >= 199309 || _XOPEN_SOURCE >= 500 || ... */
148 #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
149 defined(_REENTRANT) || defined(_NETBSD_SOURCE)
150 char *asctime_r(const struct tm
* __restrict
, char * __restrict
);
151 char *ctime_r(const time_t *, char *);
152 struct tm
*gmtime_r(const time_t * __restrict
, struct tm
* __restrict
);
153 struct tm
*localtime_r(const time_t * __restrict
, struct tm
* __restrict
);
156 #if defined(_NETBSD_SOURCE)
157 time_t time2posix(time_t);
158 time_t posix2time(time_t);
159 time_t timegm(struct tm
*);
160 time_t timeoff(struct tm
*, long);
161 time_t timelocal(struct tm
*);
162 void tzsetwall(void);
163 struct tm
*offtime(const time_t *, long);
164 #endif /* _NETBSD_SOURCE */
168 #endif /* !_TIME_H_ */