time.h revision 203964
1160814Ssimon/*
2296465Sdelphij * Copyright (c) 1989, 1993
3296465Sdelphij *	The Regents of the University of California.  All rights reserved.
4296465Sdelphij * (c) UNIX System Laboratories, Inc.
5160814Ssimon * All or some portions of this file are derived from material licensed
6160814Ssimon * to the University of California by American Telephone and Telegraph
7160814Ssimon * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8160814Ssimon * the permission of UNIX System Laboratories, Inc.
9160814Ssimon *
10160814Ssimon * Redistribution and use in source and binary forms, with or without
11160814Ssimon * modification, are permitted provided that the following conditions
12160814Ssimon * are met:
13160814Ssimon * 1. Redistributions of source code must retain the above copyright
14296465Sdelphij *    notice, this list of conditions and the following disclaimer.
15160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright
16160814Ssimon *    notice, this list of conditions and the following disclaimer in the
17160814Ssimon *    documentation and/or other materials provided with the distribution.
18160814Ssimon * 3. Neither the name of the University nor the names of its contributors
19160814Ssimon *    may be used to endorse or promote products derived from this software
20160814Ssimon *    without specific prior written permission.
21160814Ssimon *
22160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23160814Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25160814Ssimon * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26160814Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27160814Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28160814Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30160814Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31160814Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32160814Ssimon * SUCH DAMAGE.
33160814Ssimon *
34160814Ssimon *	@(#)time.h	8.3 (Berkeley) 1/21/94
35160814Ssimon */
36160814Ssimon
37160814Ssimon/*
38160814Ssimon * $FreeBSD: head/include/time.h 203964 2010-02-16 19:39:50Z imp $
39160814Ssimon */
40160814Ssimon
41160814Ssimon#ifndef _TIME_H_
42160814Ssimon#define	_TIME_H_
43160814Ssimon
44160814Ssimon#include <sys/cdefs.h>
45160814Ssimon#include <sys/_null.h>
46160814Ssimon#include <sys/_types.h>
47160814Ssimon
48160814Ssimon#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
49160814Ssimon/*
50160814Ssimon * Frequency of the clock ticks reported by times().  Deprecated - use
51160814Ssimon * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
52160814Ssimon */
53160814Ssimon#define	CLK_TCK		128
54160814Ssimon#endif
55160814Ssimon
56160814Ssimon/* Frequency of the clock ticks reported by clock().  */
57160814Ssimon#define	CLOCKS_PER_SEC	128
58160814Ssimon
59160814Ssimon#ifndef _CLOCK_T_DECLARED
60160814Ssimontypedef	__clock_t	clock_t;
61160814Ssimon#define	_CLOCK_T_DECLARED
62160814Ssimon#endif
63160814Ssimon
64160814Ssimon#ifndef _TIME_T_DECLARED
65160814Ssimontypedef	__time_t	time_t;
66296465Sdelphij#define	_TIME_T_DECLARED
67296465Sdelphij#endif
68160814Ssimon
69160814Ssimon#ifndef _SIZE_T_DECLARED
70296465Sdelphijtypedef	__size_t	size_t;
71296465Sdelphij#define	_SIZE_T_DECLARED
72296465Sdelphij#endif
73160814Ssimon
74160814Ssimon#if __POSIX_VISIBLE >= 199309
75160814Ssimon/*
76296465Sdelphij * New in POSIX 1003.1b-1993.
77296465Sdelphij */
78296465Sdelphij#ifndef _CLOCKID_T_DECLARED
79296465Sdelphijtypedef	__clockid_t	clockid_t;
80296465Sdelphij#define	_CLOCKID_T_DECLARED
81296465Sdelphij#endif
82296465Sdelphij
83296465Sdelphij#ifndef _TIMER_T_DECLARED
84296465Sdelphijtypedef	__timer_t	timer_t;
85296465Sdelphij#define	_TIMER_T_DECLARED
86296465Sdelphij#endif
87296465Sdelphij
88296465Sdelphij#include <sys/timespec.h>
89296465Sdelphij#endif /* __POSIX_VISIBLE >= 199309 */
90296465Sdelphij
91296465Sdelphij/* These macros are also in sys/time.h. */
92296465Sdelphij#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
93296465Sdelphij#define CLOCK_REALTIME	0
94296465Sdelphij#ifdef __BSD_VISIBLE
95296465Sdelphij#define CLOCK_VIRTUAL	1
96296465Sdelphij#define CLOCK_PROF	2
97296465Sdelphij#endif
98296465Sdelphij#define CLOCK_MONOTONIC	4
99296465Sdelphij#define CLOCK_UPTIME	5		/* FreeBSD-specific. */
100296465Sdelphij#define CLOCK_UPTIME_PRECISE	7	/* FreeBSD-specific. */
101296465Sdelphij#define CLOCK_UPTIME_FAST	8	/* FreeBSD-specific. */
102296465Sdelphij#define CLOCK_REALTIME_PRECISE	9	/* FreeBSD-specific. */
103296465Sdelphij#define CLOCK_REALTIME_FAST	10	/* FreeBSD-specific. */
104296465Sdelphij#define CLOCK_MONOTONIC_PRECISE	11	/* FreeBSD-specific. */
105296465Sdelphij#define CLOCK_MONOTONIC_FAST	12	/* FreeBSD-specific. */
106296465Sdelphij#define CLOCK_SECOND	13		/* FreeBSD-specific. */
107296465Sdelphij#define CLOCK_THREAD_CPUTIME_ID	14
108296465Sdelphij#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
109296465Sdelphij
110296465Sdelphij#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
111296465Sdelphij#if __BSD_VISIBLE
112296465Sdelphij#define TIMER_RELTIME	0x0	/* relative timer */
113296465Sdelphij#endif
114296465Sdelphij#define TIMER_ABSTIME	0x1	/* absolute timer */
115296465Sdelphij#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
116296465Sdelphij
117296465Sdelphijstruct tm {
118296465Sdelphij	int	tm_sec;		/* seconds after the minute [0-60] */
119296465Sdelphij	int	tm_min;		/* minutes after the hour [0-59] */
120296465Sdelphij	int	tm_hour;	/* hours since midnight [0-23] */
121296465Sdelphij	int	tm_mday;	/* day of the month [1-31] */
122160814Ssimon	int	tm_mon;		/* months since January [0-11] */
123160814Ssimon	int	tm_year;	/* years since 1900 */
124296465Sdelphij	int	tm_wday;	/* days since Sunday [0-6] */
125296465Sdelphij	int	tm_yday;	/* days since January 1 [0-365] */
126296465Sdelphij	int	tm_isdst;	/* Daylight Savings Time flag */
127296465Sdelphij	long	tm_gmtoff;	/* offset from UTC in seconds */
128296465Sdelphij	char	*tm_zone;	/* timezone abbreviation */
129296465Sdelphij};
130296465Sdelphij
131296465Sdelphij#if __POSIX_VISIBLE
132296465Sdelphijextern char *tzname[];
133296465Sdelphij#endif
134296465Sdelphij
135296465Sdelphij__BEGIN_DECLS
136296465Sdelphijchar *asctime(const struct tm *);
137296465Sdelphijclock_t clock(void);
138296465Sdelphijchar *ctime(const time_t *);
139296465Sdelphijdouble difftime(time_t, time_t);
140160814Ssimon/* XXX missing: getdate() */
141296465Sdelphijstruct tm *gmtime(const time_t *);
142160814Ssimonstruct tm *localtime(const time_t *);
143296465Sdelphijtime_t mktime(struct tm *);
144296465Sdelphijsize_t strftime(char * __restrict, size_t, const char * __restrict,
145296465Sdelphij    const struct tm * __restrict);
146296465Sdelphijtime_t time(time_t *);
147296465Sdelphij#if __POSIX_VISIBLE >= 200112
148160814Ssimonstruct sigevent;
149296465Sdelphijint timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
150296465Sdelphijint timer_delete(timer_t);
151296465Sdelphijint timer_gettime(timer_t, struct itimerspec *);
152296465Sdelphijint timer_getoverrun(timer_t);
153296465Sdelphijint timer_settime(timer_t, int, const struct itimerspec *__restrict,
154296465Sdelphij	struct itimerspec *__restrict);
155296465Sdelphij#endif
156296465Sdelphij#if __POSIX_VISIBLE
157296465Sdelphijvoid tzset(void);
158296465Sdelphij#endif
159296465Sdelphij
160296465Sdelphij#if __POSIX_VISIBLE >= 199309
161296465Sdelphijint clock_getres(clockid_t, struct timespec *);
162296465Sdelphijint clock_gettime(clockid_t, struct timespec *);
163160814Ssimonint clock_settime(clockid_t, const struct timespec *);
164296465Sdelphij/* XXX missing: clock_nanosleep() */
165160814Ssimonint nanosleep(const struct timespec *, struct timespec *);
166296465Sdelphij#endif /* __POSIX_VISIBLE >= 199309 */
167296465Sdelphij
168296465Sdelphij#if __POSIX_VISIBLE >= 199506
169296465Sdelphijchar *asctime_r(const struct tm *, char *);
170296465Sdelphijchar *ctime_r(const time_t *, char *);
171296465Sdelphijstruct tm *gmtime_r(const time_t *, struct tm *);
172296465Sdelphijstruct tm *localtime_r(const time_t *, struct tm *);
173296465Sdelphij#endif
174296465Sdelphij
175296465Sdelphij#if __XSI_VISIBLE
176296465Sdelphijchar *strptime(const char * __restrict, const char * __restrict,
177160814Ssimon    struct tm * __restrict);
178296465Sdelphij#endif
179160814Ssimon
180296465Sdelphij#if __BSD_VISIBLE
181160814Ssimonchar *timezone(int, int);	/* XXX XSI conflict */
182296465Sdelphijvoid tzsetwall(void);
183296465Sdelphijtime_t timelocal(struct tm * const);
184160814Ssimontime_t timegm(struct tm * const);
185296465Sdelphij#endif /* __BSD_VISIBLE */
186160814Ssimon__END_DECLS
187296465Sdelphij
188296465Sdelphij#endif /* !_TIME_H_ */
189296465Sdelphij