time.h revision 93032
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1989, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes * (c) UNIX System Laboratories, Inc.
51539Srgrimes * All or some portions of this file are derived from material licensed
61539Srgrimes * to the University of California by American Telephone and Telegraph
71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81539Srgrimes * the permission of UNIX System Laboratories, Inc.
91539Srgrimes *
101539Srgrimes * Redistribution and use in source and binary forms, with or without
111539Srgrimes * modification, are permitted provided that the following conditions
121539Srgrimes * are met:
131539Srgrimes * 1. Redistributions of source code must retain the above copyright
141539Srgrimes *    notice, this list of conditions and the following disclaimer.
151539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161539Srgrimes *    notice, this list of conditions and the following disclaimer in the
171539Srgrimes *    documentation and/or other materials provided with the distribution.
181539Srgrimes * 3. All advertising materials mentioning features or use of this software
191539Srgrimes *    must display the following acknowledgement:
201539Srgrimes *	This product includes software developed by the University of
211539Srgrimes *	California, Berkeley and its contributors.
221539Srgrimes * 4. Neither the name of the University nor the names of its contributors
231539Srgrimes *    may be used to endorse or promote products derived from this software
241539Srgrimes *    without specific prior written permission.
251539Srgrimes *
261539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361539Srgrimes * SUCH DAMAGE.
371539Srgrimes *
381539Srgrimes *	@(#)time.h	8.3 (Berkeley) 1/21/94
391539Srgrimes */
401539Srgrimes
4175033Sphk/*
4275033Sphk * $FreeBSD: head/include/time.h 93032 2002-03-23 17:24:55Z imp $
4375033Sphk */
4475033Sphk
451539Srgrimes#ifndef _TIME_H_
461539Srgrimes#define	_TIME_H_
471539Srgrimes
481539Srgrimes#include <machine/ansi.h>
4934925Sdufault#include <sys/_posix.h>
501539Srgrimes
516164Sbde#ifndef _ANSI_SOURCE
526164Sbde/*
536164Sbde * Frequency of the clock ticks reported by times().  Deprecated - use
546164Sbde * sysconf(_SC_CLK_TCK) instead.
556164Sbde */
566243Sbde#define	CLK_TCK		_BSD_CLK_TCK_
576164Sbde#endif
586164Sbde
596164Sbde/* Frequency of the clock ticks reported by clock().  */
606164Sbde#define	CLOCKS_PER_SEC	_BSD_CLOCKS_PER_SEC_
616164Sbde
621539Srgrimes#ifndef	NULL
631539Srgrimes#define	NULL	0
641539Srgrimes#endif
651539Srgrimes
661539Srgrimes#ifdef	_BSD_CLOCK_T_
671539Srgrimestypedef	_BSD_CLOCK_T_	clock_t;
681539Srgrimes#undef	_BSD_CLOCK_T_
691539Srgrimes#endif
701539Srgrimes
711539Srgrimes#ifdef	_BSD_TIME_T_
721539Srgrimestypedef	_BSD_TIME_T_	time_t;
731539Srgrimes#undef	_BSD_TIME_T_
741539Srgrimes#endif
751539Srgrimes
7625773Speter#ifdef	_BSD_SIZE_T_
7725773Spetertypedef	_BSD_SIZE_T_	size_t;
7825773Speter#undef	_BSD_SIZE_T_
7925773Speter#endif
8025773Speter
8134925Sdufault/* XXX I'm not sure if _ANSI_SOURCE is playing properly
8234925Sdufault *     with the setups in _posix.h:
8334925Sdufault */
8434925Sdufault#if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY)
8525773Speter/*
8625773Speter * New in POSIX 1003.1b-1993.
8725773Speter */
8825769Sache#ifdef	_BSD_CLOCKID_T_
8925769Sachetypedef	_BSD_CLOCKID_T_	clockid_t;
9025769Sache#undef	_BSD_CLOCKID_T_
9125769Sache#endif
9225769Sache
9325773Speter#ifdef	_BSD_TIMER_T_
9425773Spetertypedef	_BSD_TIMER_T_	timer_t;
9525773Speter#undef	_BSD_TIMER_T_
961539Srgrimes#endif
971539Srgrimes
9825773Speter#ifndef _TIMESPEC_DECLARED
9925773Speter#define _TIMESPEC_DECLARED
10025773Speterstruct timespec {
10125773Speter	time_t	tv_sec;		/* seconds */
10225773Speter	long	tv_nsec;	/* and nanoseconds */
10325773Speter};
10425773Speter#endif
10525773Speter#endif /* Neither ANSI nor POSIX */
10625773Speter
1071539Srgrimesstruct tm {
1081539Srgrimes	int	tm_sec;		/* seconds after the minute [0-60] */
1091539Srgrimes	int	tm_min;		/* minutes after the hour [0-59] */
1101539Srgrimes	int	tm_hour;	/* hours since midnight [0-23] */
1111539Srgrimes	int	tm_mday;	/* day of the month [1-31] */
1121539Srgrimes	int	tm_mon;		/* months since January [0-11] */
1131539Srgrimes	int	tm_year;	/* years since 1900 */
1141539Srgrimes	int	tm_wday;	/* days since Sunday [0-6] */
1151539Srgrimes	int	tm_yday;	/* days since January 1 [0-365] */
1161539Srgrimes	int	tm_isdst;	/* Daylight Savings Time flag */
11775033Sphk	long	tm_gmtoff;	/* offset from UTC in seconds */
1181539Srgrimes	char	*tm_zone;	/* timezone abbreviation */
1191539Srgrimes};
1201539Srgrimes
1211539Srgrimes#include <sys/cdefs.h>
1221539Srgrimes
12338464Sjkoshy#ifndef	_ANSI_SOURCE
12438464Sjkoshyextern char *tzname[];
12538464Sjkoshy#endif
12638464Sjkoshy
1271539Srgrimes__BEGIN_DECLS
12893032Simpchar *asctime(const struct tm *);
12993032Simpclock_t clock(void);
13093032Simpchar *ctime(const time_t *);
13193032Simpdouble difftime(time_t, time_t);
13293032Simpstruct tm *gmtime(const time_t *);
13393032Simpstruct tm *localtime(const time_t *);
13493032Simptime_t mktime(struct tm *);
13593032Simpsize_t strftime(char *, size_t, const char *, const struct tm *);
13693032Simptime_t time(time_t *);
1371539Srgrimes
1381539Srgrimes#ifndef _ANSI_SOURCE
13993032Simptime_t _time32_to_time(__int32_t t32);
14093032Simp__int32_t _time_to_time32(time_t t);
14193032Simptime_t _time64_to_time(__int64_t t64);
14293032Simp__int64_t _time_to_time64(time_t t);
14393032Simplong _time_to_long(time_t t);
14493032Simptime_t _long_to_time(long tlong);
14593032Simpint _time_to_int(time_t t);
14693032Simptime_t _int_to_time(int tint);
14785634Sdillon#endif /* not ANSI */
14885634Sdillon
14985634Sdillon#ifndef _ANSI_SOURCE
15093032Simpvoid tzset(void);
1511539Srgrimes#endif /* not ANSI */
1521539Srgrimes
1531539Srgrimes#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
15493032Simpchar *asctime_r(const struct tm *, char *);
15593032Simpchar *ctime_r(const time_t *, char *);
15693032Simpstruct tm *gmtime_r(const time_t *, struct tm *);
15793032Simpstruct tm *localtime_r(const time_t *, struct tm *);
15893032Simpchar *strptime(const char *, const char *, struct tm *);
15993032Simpchar *timezone(int, int);
16093032Simpvoid tzsetwall(void);
16193032Simptime_t timelocal(struct tm * const);
16293032Simptime_t timegm(struct tm * const);
16334925Sdufault#endif /* neither ANSI nor POSIX */
16425773Speter
16534925Sdufault#if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY)
16625773Speter/* Introduced in POSIX 1003.1b-1993, not part of 1003.1-1990. */
16793032Simpint clock_getres(clockid_t, struct timespec *);
16893032Simpint clock_gettime(clockid_t, struct timespec *);
16993032Simpint clock_settime(clockid_t, const struct timespec *);
17093032Simpint nanosleep(const struct timespec *, struct timespec *);
1711539Srgrimes#endif /* neither ANSI nor POSIX */
1721539Srgrimes__END_DECLS
1731539Srgrimes
1741539Srgrimes#endif /* !_TIME_H_ */
175