time.h revision 98930
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 98930 2002-06-27 20:18:45Z wollman $
4375033Sphk */
4475033Sphk
451539Srgrimes#ifndef _TIME_H_
461539Srgrimes#define	_TIME_H_
471539Srgrimes
4898269Swollman#include <sys/cdefs.h>
491539Srgrimes#include <machine/ansi.h>
501539Srgrimes
5198312Swollman#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
526164Sbde/*
536164Sbde * Frequency of the clock ticks reported by times().  Deprecated - use
5498269Swollman * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
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
8198269Swollman#if __POSIX_VISIBLE >= 199309
8225773Speter/*
8325773Speter * New in POSIX 1003.1b-1993.
8425773Speter */
8525769Sache#ifdef	_BSD_CLOCKID_T_
8625769Sachetypedef	_BSD_CLOCKID_T_	clockid_t;
8725769Sache#undef	_BSD_CLOCKID_T_
8825769Sache#endif
8925769Sache
9025773Speter#ifdef	_BSD_TIMER_T_
9125773Spetertypedef	_BSD_TIMER_T_	timer_t;
9225773Speter#undef	_BSD_TIMER_T_
931539Srgrimes#endif
941539Srgrimes
9598269Swollman#include <sys/timespec.h>
9698269Swollman#endif /* __POSIX_VISIBLE >= 199309 */
9725773Speter
981539Srgrimesstruct tm {
991539Srgrimes	int	tm_sec;		/* seconds after the minute [0-60] */
1001539Srgrimes	int	tm_min;		/* minutes after the hour [0-59] */
1011539Srgrimes	int	tm_hour;	/* hours since midnight [0-23] */
1021539Srgrimes	int	tm_mday;	/* day of the month [1-31] */
1031539Srgrimes	int	tm_mon;		/* months since January [0-11] */
1041539Srgrimes	int	tm_year;	/* years since 1900 */
1051539Srgrimes	int	tm_wday;	/* days since Sunday [0-6] */
1061539Srgrimes	int	tm_yday;	/* days since January 1 [0-365] */
1071539Srgrimes	int	tm_isdst;	/* Daylight Savings Time flag */
10875033Sphk	long	tm_gmtoff;	/* offset from UTC in seconds */
1091539Srgrimes	char	*tm_zone;	/* timezone abbreviation */
1101539Srgrimes};
1111539Srgrimes
11298269Swollman#if __POSIX_VISIBLE
11338464Sjkoshyextern char *tzname[];
11438464Sjkoshy#endif
11538464Sjkoshy
1161539Srgrimes__BEGIN_DECLS
11793032Simpchar *asctime(const struct tm *);
11893032Simpclock_t clock(void);
11993032Simpchar *ctime(const time_t *);
12093032Simpdouble difftime(time_t, time_t);
12193032Simpstruct tm *gmtime(const time_t *);
12293032Simpstruct tm *localtime(const time_t *);
12393032Simptime_t mktime(struct tm *);
12493032Simpsize_t strftime(char *, size_t, const char *, const struct tm *);
12593032Simptime_t time(time_t *);
1261539Srgrimes
12798269Swollman#if __POSIX_VISIBLE
12893032Simpvoid tzset(void);
12998269Swollman#endif
13098269Swollman
13198923Swollman#if __POSIX_VISIBLE >= 199309
13298923Swollmanint clock_getres(clockid_t, struct timespec *);
13398923Swollmanint clock_gettime(clockid_t, struct timespec *);
13498923Swollmanint clock_settime(clockid_t, const struct timespec *);
13598923Swollmanint nanosleep(const struct timespec *, struct timespec *);
13698923Swollman#endif /* __POSIX_VISIBLE >= 199309 */
13798923Swollman
13898930Swollman#if __POSIX_VISIBLE >= 199506
13998930Swollmanchar *asctime_r(const struct tm *, char *);
14098930Swollmanchar *ctime_r(const time_t *, char *);
14198930Swollmanstruct tm *gmtime_r(const time_t *, struct tm *);
14298930Swollmanstruct tm *localtime_r(const time_t *, struct tm *);
14398930Swollman#endif
14498930Swollman
14598269Swollman#if __XSI_VISIBLE
14693032Simpchar *strptime(const char *, const char *, struct tm *);
14798269Swollman#endif
14898269Swollman
14998269Swollman#if __BSD_VISIBLE
15093032Simpchar *timezone(int, int);
15193032Simpvoid tzsetwall(void);
15293032Simptime_t timelocal(struct tm * const);
15393032Simptime_t timegm(struct tm * const);
15498269Swollman#endif /* __BSD_VISIBLE */
1551539Srgrimes__END_DECLS
1561539Srgrimes
1571539Srgrimes#endif /* !_TIME_H_ */
158