xref: /titanic_52/usr/src/boot/include/time.h (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
1*4a5d661aSToomas Soome /*
2*4a5d661aSToomas Soome  * Copyright (c) 1989, 1993
3*4a5d661aSToomas Soome  *	The Regents of the University of California.  All rights reserved.
4*4a5d661aSToomas Soome  * (c) UNIX System Laboratories, Inc.
5*4a5d661aSToomas Soome  * All or some portions of this file are derived from material licensed
6*4a5d661aSToomas Soome  * to the University of California by American Telephone and Telegraph
7*4a5d661aSToomas Soome  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8*4a5d661aSToomas Soome  * the permission of UNIX System Laboratories, Inc.
9*4a5d661aSToomas Soome  *
10*4a5d661aSToomas Soome  * Redistribution and use in source and binary forms, with or without
11*4a5d661aSToomas Soome  * modification, are permitted provided that the following conditions
12*4a5d661aSToomas Soome  * are met:
13*4a5d661aSToomas Soome  * 1. Redistributions of source code must retain the above copyright
14*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer.
15*4a5d661aSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
16*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
17*4a5d661aSToomas Soome  *    documentation and/or other materials provided with the distribution.
18*4a5d661aSToomas Soome  * 3. Neither the name of the University nor the names of its contributors
19*4a5d661aSToomas Soome  *    may be used to endorse or promote products derived from this software
20*4a5d661aSToomas Soome  *    without specific prior written permission.
21*4a5d661aSToomas Soome  *
22*4a5d661aSToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*4a5d661aSToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*4a5d661aSToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*4a5d661aSToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*4a5d661aSToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*4a5d661aSToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*4a5d661aSToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*4a5d661aSToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*4a5d661aSToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*4a5d661aSToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*4a5d661aSToomas Soome  * SUCH DAMAGE.
33*4a5d661aSToomas Soome  *
34*4a5d661aSToomas Soome  *	@(#)time.h	8.3 (Berkeley) 1/21/94
35*4a5d661aSToomas Soome  */
36*4a5d661aSToomas Soome 
37*4a5d661aSToomas Soome /*
38*4a5d661aSToomas Soome  * $FreeBSD$
39*4a5d661aSToomas Soome  */
40*4a5d661aSToomas Soome 
41*4a5d661aSToomas Soome #ifndef _TIME_H_
42*4a5d661aSToomas Soome #define	_TIME_H_
43*4a5d661aSToomas Soome 
44*4a5d661aSToomas Soome #include <sys/cdefs.h>
45*4a5d661aSToomas Soome #include <sys/_null.h>
46*4a5d661aSToomas Soome #include <sys/_types.h>
47*4a5d661aSToomas Soome 
48*4a5d661aSToomas Soome #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
49*4a5d661aSToomas Soome /*
50*4a5d661aSToomas Soome  * Frequency of the clock ticks reported by times().  Deprecated - use
51*4a5d661aSToomas Soome  * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
52*4a5d661aSToomas Soome  */
53*4a5d661aSToomas Soome #define	CLK_TCK		128
54*4a5d661aSToomas Soome #endif
55*4a5d661aSToomas Soome 
56*4a5d661aSToomas Soome /* Frequency of the clock ticks reported by clock().  */
57*4a5d661aSToomas Soome #define	CLOCKS_PER_SEC	128
58*4a5d661aSToomas Soome 
59*4a5d661aSToomas Soome #ifndef _CLOCK_T_DECLARED
60*4a5d661aSToomas Soome typedef	__clock_t	clock_t;
61*4a5d661aSToomas Soome #define	_CLOCK_T_DECLARED
62*4a5d661aSToomas Soome #endif
63*4a5d661aSToomas Soome 
64*4a5d661aSToomas Soome #ifndef _TIME_T_DECLARED
65*4a5d661aSToomas Soome typedef	__time_t	time_t;
66*4a5d661aSToomas Soome #define	_TIME_T_DECLARED
67*4a5d661aSToomas Soome #endif
68*4a5d661aSToomas Soome 
69*4a5d661aSToomas Soome #ifndef _SIZE_T_DECLARED
70*4a5d661aSToomas Soome typedef	__size_t	size_t;
71*4a5d661aSToomas Soome #define	_SIZE_T_DECLARED
72*4a5d661aSToomas Soome #endif
73*4a5d661aSToomas Soome 
74*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 199309
75*4a5d661aSToomas Soome /*
76*4a5d661aSToomas Soome  * New in POSIX 1003.1b-1993.
77*4a5d661aSToomas Soome  */
78*4a5d661aSToomas Soome #ifndef _CLOCKID_T_DECLARED
79*4a5d661aSToomas Soome typedef	__clockid_t	clockid_t;
80*4a5d661aSToomas Soome #define	_CLOCKID_T_DECLARED
81*4a5d661aSToomas Soome #endif
82*4a5d661aSToomas Soome 
83*4a5d661aSToomas Soome #ifndef _TIMER_T_DECLARED
84*4a5d661aSToomas Soome typedef	__timer_t	timer_t;
85*4a5d661aSToomas Soome #define	_TIMER_T_DECLARED
86*4a5d661aSToomas Soome #endif
87*4a5d661aSToomas Soome 
88*4a5d661aSToomas Soome #include <sys/timespec.h>
89*4a5d661aSToomas Soome #endif /* __POSIX_VISIBLE >= 199309 */
90*4a5d661aSToomas Soome 
91*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 200112
92*4a5d661aSToomas Soome #ifndef _PID_T_DECLARED
93*4a5d661aSToomas Soome typedef	__pid_t		pid_t;
94*4a5d661aSToomas Soome #define	_PID_T_DECLARED
95*4a5d661aSToomas Soome #endif
96*4a5d661aSToomas Soome #endif
97*4a5d661aSToomas Soome 
98*4a5d661aSToomas Soome /* These macros are also in sys/time.h. */
99*4a5d661aSToomas Soome #if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
100*4a5d661aSToomas Soome #define CLOCK_REALTIME	0
101*4a5d661aSToomas Soome #ifdef __BSD_VISIBLE
102*4a5d661aSToomas Soome #define CLOCK_VIRTUAL	1
103*4a5d661aSToomas Soome #define CLOCK_PROF	2
104*4a5d661aSToomas Soome #endif
105*4a5d661aSToomas Soome #define CLOCK_MONOTONIC	4
106*4a5d661aSToomas Soome #define CLOCK_UPTIME	5		/* FreeBSD-specific. */
107*4a5d661aSToomas Soome #define CLOCK_UPTIME_PRECISE	7	/* FreeBSD-specific. */
108*4a5d661aSToomas Soome #define CLOCK_UPTIME_FAST	8	/* FreeBSD-specific. */
109*4a5d661aSToomas Soome #define CLOCK_REALTIME_PRECISE	9	/* FreeBSD-specific. */
110*4a5d661aSToomas Soome #define CLOCK_REALTIME_FAST	10	/* FreeBSD-specific. */
111*4a5d661aSToomas Soome #define CLOCK_MONOTONIC_PRECISE	11	/* FreeBSD-specific. */
112*4a5d661aSToomas Soome #define CLOCK_MONOTONIC_FAST	12	/* FreeBSD-specific. */
113*4a5d661aSToomas Soome #define CLOCK_SECOND	13		/* FreeBSD-specific. */
114*4a5d661aSToomas Soome #define CLOCK_THREAD_CPUTIME_ID	14
115*4a5d661aSToomas Soome #define	CLOCK_PROCESS_CPUTIME_ID	15
116*4a5d661aSToomas Soome #endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
117*4a5d661aSToomas Soome 
118*4a5d661aSToomas Soome #if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
119*4a5d661aSToomas Soome #if __BSD_VISIBLE
120*4a5d661aSToomas Soome #define TIMER_RELTIME	0x0	/* relative timer */
121*4a5d661aSToomas Soome #endif
122*4a5d661aSToomas Soome #define TIMER_ABSTIME	0x1	/* absolute timer */
123*4a5d661aSToomas Soome #endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
124*4a5d661aSToomas Soome 
125*4a5d661aSToomas Soome struct tm {
126*4a5d661aSToomas Soome 	int	tm_sec;		/* seconds after the minute [0-60] */
127*4a5d661aSToomas Soome 	int	tm_min;		/* minutes after the hour [0-59] */
128*4a5d661aSToomas Soome 	int	tm_hour;	/* hours since midnight [0-23] */
129*4a5d661aSToomas Soome 	int	tm_mday;	/* day of the month [1-31] */
130*4a5d661aSToomas Soome 	int	tm_mon;		/* months since January [0-11] */
131*4a5d661aSToomas Soome 	int	tm_year;	/* years since 1900 */
132*4a5d661aSToomas Soome 	int	tm_wday;	/* days since Sunday [0-6] */
133*4a5d661aSToomas Soome 	int	tm_yday;	/* days since January 1 [0-365] */
134*4a5d661aSToomas Soome 	int	tm_isdst;	/* Daylight Savings Time flag */
135*4a5d661aSToomas Soome 	long	tm_gmtoff;	/* offset from UTC in seconds */
136*4a5d661aSToomas Soome 	char	*tm_zone;	/* timezone abbreviation */
137*4a5d661aSToomas Soome };
138*4a5d661aSToomas Soome 
139*4a5d661aSToomas Soome #if __POSIX_VISIBLE
140*4a5d661aSToomas Soome extern char *tzname[];
141*4a5d661aSToomas Soome #endif
142*4a5d661aSToomas Soome 
143*4a5d661aSToomas Soome __BEGIN_DECLS
144*4a5d661aSToomas Soome char *asctime(const struct tm *);
145*4a5d661aSToomas Soome clock_t clock(void);
146*4a5d661aSToomas Soome char *ctime(const time_t *);
147*4a5d661aSToomas Soome double difftime(time_t, time_t);
148*4a5d661aSToomas Soome /* XXX missing: getdate() */
149*4a5d661aSToomas Soome struct tm *gmtime(const time_t *);
150*4a5d661aSToomas Soome struct tm *localtime(const time_t *);
151*4a5d661aSToomas Soome time_t mktime(struct tm *);
152*4a5d661aSToomas Soome size_t strftime(char * __restrict, size_t, const char * __restrict,
153*4a5d661aSToomas Soome     const struct tm * __restrict);
154*4a5d661aSToomas Soome time_t time(time_t *);
155*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 200112
156*4a5d661aSToomas Soome struct sigevent;
157*4a5d661aSToomas Soome int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
158*4a5d661aSToomas Soome int timer_delete(timer_t);
159*4a5d661aSToomas Soome int timer_gettime(timer_t, struct itimerspec *);
160*4a5d661aSToomas Soome int timer_getoverrun(timer_t);
161*4a5d661aSToomas Soome int timer_settime(timer_t, int, const struct itimerspec *__restrict,
162*4a5d661aSToomas Soome 	struct itimerspec *__restrict);
163*4a5d661aSToomas Soome #endif
164*4a5d661aSToomas Soome #if __POSIX_VISIBLE
165*4a5d661aSToomas Soome void tzset(void);
166*4a5d661aSToomas Soome #endif
167*4a5d661aSToomas Soome 
168*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 199309
169*4a5d661aSToomas Soome int clock_getres(clockid_t, struct timespec *);
170*4a5d661aSToomas Soome int clock_gettime(clockid_t, struct timespec *);
171*4a5d661aSToomas Soome int clock_settime(clockid_t, const struct timespec *);
172*4a5d661aSToomas Soome /* XXX missing: clock_nanosleep() */
173*4a5d661aSToomas Soome int nanosleep(const struct timespec *, struct timespec *);
174*4a5d661aSToomas Soome #endif /* __POSIX_VISIBLE >= 199309 */
175*4a5d661aSToomas Soome 
176*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 200112
177*4a5d661aSToomas Soome int clock_getcpuclockid(pid_t, clockid_t *);
178*4a5d661aSToomas Soome #endif
179*4a5d661aSToomas Soome 
180*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 199506
181*4a5d661aSToomas Soome char *asctime_r(const struct tm *, char *);
182*4a5d661aSToomas Soome char *ctime_r(const time_t *, char *);
183*4a5d661aSToomas Soome struct tm *gmtime_r(const time_t *, struct tm *);
184*4a5d661aSToomas Soome struct tm *localtime_r(const time_t *, struct tm *);
185*4a5d661aSToomas Soome #endif
186*4a5d661aSToomas Soome 
187*4a5d661aSToomas Soome #if __XSI_VISIBLE
188*4a5d661aSToomas Soome char *strptime(const char * __restrict, const char * __restrict,
189*4a5d661aSToomas Soome     struct tm * __restrict);
190*4a5d661aSToomas Soome #endif
191*4a5d661aSToomas Soome 
192*4a5d661aSToomas Soome #if __BSD_VISIBLE
193*4a5d661aSToomas Soome char *timezone(int, int);	/* XXX XSI conflict */
194*4a5d661aSToomas Soome void tzsetwall(void);
195*4a5d661aSToomas Soome time_t timelocal(struct tm * const);
196*4a5d661aSToomas Soome time_t timegm(struct tm * const);
197*4a5d661aSToomas Soome #endif /* __BSD_VISIBLE */
198*4a5d661aSToomas Soome 
199*4a5d661aSToomas Soome #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
200*4a5d661aSToomas Soome #include <xlocale/_time.h>
201*4a5d661aSToomas Soome #endif
202*4a5d661aSToomas Soome __END_DECLS
203*4a5d661aSToomas Soome 
204*4a5d661aSToomas Soome #endif /* !_TIME_H_ */
205