time.h revision 102874
1239922Sgonzo/*
2239922Sgonzo * Copyright (c) 1989, 1993
3266022Sian *	The Regents of the University of California.  All rights reserved.
4239922Sgonzo * (c) UNIX System Laboratories, Inc.
5239922Sgonzo * All or some portions of this file are derived from material licensed
6266022Sian * to the University of California by American Telephone and Telegraph
7266022Sian * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8266022Sian * the permission of UNIX System Laboratories, Inc.
9239922Sgonzo *
10239922Sgonzo * Redistribution and use in source and binary forms, with or without
11239922Sgonzo * modification, are permitted provided that the following conditions
12239922Sgonzo * are met:
13239922Sgonzo * 1. Redistributions of source code must retain the above copyright
14239922Sgonzo *    notice, this list of conditions and the following disclaimer.
15239922Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
16239922Sgonzo *    notice, this list of conditions and the following disclaimer in the
17239922Sgonzo *    documentation and/or other materials provided with the distribution.
18239922Sgonzo * 3. All advertising materials mentioning features or use of this software
19239922Sgonzo *    must display the following acknowledgement:
20239922Sgonzo *	This product includes software developed by the University of
21239922Sgonzo *	California, Berkeley and its contributors.
22239922Sgonzo * 4. Neither the name of the University nor the names of its contributors
23239922Sgonzo *    may be used to endorse or promote products derived from this software
24239922Sgonzo *    without specific prior written permission.
25239922Sgonzo *
26239922Sgonzo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27239922Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28239922Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29239922Sgonzo * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30239922Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31239922Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32239922Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33239922Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34239922Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35239922Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36239922Sgonzo * SUCH DAMAGE.
37239922Sgonzo *
38322724Smarius *	@(#)time.h	8.3 (Berkeley) 1/21/94
39239922Sgonzo */
40239922Sgonzo
41239922Sgonzo/*
42239922Sgonzo * $FreeBSD: head/include/time.h 102874 2002-09-03 00:06:58Z mike $
43322724Smarius */
44322724Smarius
45239922Sgonzo#ifndef _TIME_H_
46239922Sgonzo#define	_TIME_H_
47239922Sgonzo
48239922Sgonzo#include <sys/cdefs.h>
49239922Sgonzo#include <sys/_types.h>
50239922Sgonzo
51259517Sray#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
52322724Smarius/*
53239922Sgonzo * Frequency of the clock ticks reported by times().  Deprecated - use
54322724Smarius * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
55239922Sgonzo */
56259517Sray#define	CLK_TCK		128
57253006Srpaulo#endif
58253006Srpaulo
59322724Smarius/* Frequency of the clock ticks reported by clock().  */
60239922Sgonzo#define	CLOCKS_PER_SEC	128
61322724Smarius
62322724Smarius#ifndef	NULL
63322724Smarius#define	NULL	0
64322724Smarius#endif
65322724Smarius
66239922Sgonzo#ifndef _CLOCK_T_DECLARED
67239922Sgonzotypedef	__clock_t	clock_t;
68322724Smarius#define	_CLOCK_T_DECLARED
69322724Smarius#endif
70322724Smarius
71322724Smarius#ifndef _TIME_T_DECLARED
72239922Sgonzotypedef	__time_t	time_t;
73239922Sgonzo#define	_TIME_T_DECLARED
74239922Sgonzo#endif
75239922Sgonzo
76239922Sgonzo#ifndef _SIZE_T_DECLARED
77322724Smariustypedef	__size_t	size_t;
78322724Smarius#define	_SIZE_T_DECLARED
79239922Sgonzo#endif
80322724Smarius
81239922Sgonzo#if __POSIX_VISIBLE >= 199309
82322724Smarius/*
83243423Sgonzo * New in POSIX 1003.1b-1993.
84322724Smarius */
85322724Smarius#ifndef _CLOCKID_T_DECLARED
86322724Smariustypedef	__clockid_t	clockid_t;
87322724Smarius#define	_CLOCKID_T_DECLARED
88243423Sgonzo#endif
89322724Smarius
90322724Smarius#ifndef _TIMER_T_DECLARED
91322724Smariustypedef	__timer_t	timer_t;
92243423Sgonzo#define	_TIMER_T_DECLARED
93322724Smarius#endif
94322724Smarius
95322724Smarius#include <sys/timespec.h>
96322724Smarius#endif /* __POSIX_VISIBLE >= 199309 */
97243423Sgonzo
98322724Smariusstruct tm {
99322724Smarius	int	tm_sec;		/* seconds after the minute [0-60] */
100243423Sgonzo	int	tm_min;		/* minutes after the hour [0-59] */
101322724Smarius	int	tm_hour;	/* hours since midnight [0-23] */
102322724Smarius	int	tm_mday;	/* day of the month [1-31] */
103322724Smarius	int	tm_mon;		/* months since January [0-11] */
104322724Smarius	int	tm_year;	/* years since 1900 */
105322724Smarius	int	tm_wday;	/* days since Sunday [0-6] */
106322724Smarius	int	tm_yday;	/* days since January 1 [0-365] */
107253006Srpaulo	int	tm_isdst;	/* Daylight Savings Time flag */
108322724Smarius	long	tm_gmtoff;	/* offset from UTC in seconds */
109322724Smarius	char	*tm_zone;	/* timezone abbreviation */
110322724Smarius};
111322724Smarius
112322724Smarius#if __POSIX_VISIBLE
113322724Smariusextern char *tzname[];
114322724Smarius#endif
115322724Smarius
116322724Smarius__BEGIN_DECLS
117322724Smariuschar *asctime(const struct tm *);
118322724Smariusclock_t clock(void);
119322724Smariuschar *ctime(const time_t *);
120322724Smariusdouble difftime(time_t, time_t);
121322724Smariusstruct tm *gmtime(const time_t *);
122322724Smariusstruct tm *localtime(const time_t *);
123322724Smariustime_t mktime(struct tm *);
124322724Smariussize_t strftime(char *__restrict, size_t, const char *__restrict,
125322724Smarius    const struct tm *__restrict);
126322724Smariustime_t time(time_t *);
127322724Smarius
128322724Smarius#if __POSIX_VISIBLE
129322724Smariusvoid tzset(void);
130322724Smarius#endif
131322724Smarius
132322724Smarius#if __POSIX_VISIBLE >= 199309
133322724Smariusint clock_getres(clockid_t, struct timespec *);
134322724Smariusint clock_gettime(clockid_t, struct timespec *);
135322724Smariusint clock_settime(clockid_t, const struct timespec *);
136322724Smariusint nanosleep(const struct timespec *, struct timespec *);
137322724Smarius#endif /* __POSIX_VISIBLE >= 199309 */
138322724Smarius
139322724Smarius#if __POSIX_VISIBLE >= 199506
140253006Srpaulochar *asctime_r(const struct tm *, char *);
141239922Sgonzochar *ctime_r(const time_t *, char *);
142322724Smariusstruct tm *gmtime_r(const time_t *, struct tm *);
143322724Smariusstruct tm *localtime_r(const time_t *, struct tm *);
144322724Smarius#endif
145322724Smarius
146322724Smarius#if __XSI_VISIBLE
147322724Smariuschar *strptime(const char *__restrict, const char *__restrict,
148322724Smarius    struct tm *__restrict);
149322724Smarius#endif
150322724Smarius
151322724Smarius#if __BSD_VISIBLE
152322724Smariuschar *timezone(int, int);
153239922Sgonzovoid tzsetwall(void);
154322724Smariustime_t timelocal(struct tm * const);
155322724Smariustime_t timegm(struct tm * const);
156322724Smarius#endif /* __BSD_VISIBLE */
157322724Smarius__END_DECLS
158322724Smarius
159239922Sgonzo#endif /* !_TIME_H_ */
160322724Smarius