time.h revision 102227
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 102227 2002-08-21 16:20:02Z mike $
4375033Sphk */
4475033Sphk
451539Srgrimes#ifndef _TIME_H_
461539Srgrimes#define	_TIME_H_
471539Srgrimes
4898269Swollman#include <sys/cdefs.h>
49102227Smike#include <sys/_types.h>
50102227Smike
511539Srgrimes#include <machine/ansi.h>
521539Srgrimes
5398312Swollman#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
546164Sbde/*
556164Sbde * Frequency of the clock ticks reported by times().  Deprecated - use
5698269Swollman * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
576164Sbde */
586243Sbde#define	CLK_TCK		_BSD_CLK_TCK_
596164Sbde#endif
606164Sbde
616164Sbde/* Frequency of the clock ticks reported by clock().  */
626164Sbde#define	CLOCKS_PER_SEC	_BSD_CLOCKS_PER_SEC_
636164Sbde
641539Srgrimes#ifndef	NULL
651539Srgrimes#define	NULL	0
661539Srgrimes#endif
671539Srgrimes
68102227Smike#ifndef _CLOCK_T_DECLARED
69102227Smiketypedef	__clock_t	clock_t;
70102227Smike#define	_CLOCK_T_DECLARED
711539Srgrimes#endif
721539Srgrimes
73102227Smike#ifndef _TIME_T_DECLARED
74102227Smiketypedef	__time_t	time_t;
75102227Smike#define	_TIME_T_DECLARED
761539Srgrimes#endif
771539Srgrimes
78102227Smike#ifndef _SIZE_T_DECLARED
79102227Smiketypedef	__size_t	size_t;
80102227Smike#define	_SIZE_T_DECLARED
8125773Speter#endif
8225773Speter
8398269Swollman#if __POSIX_VISIBLE >= 199309
8425773Speter/*
8525773Speter * New in POSIX 1003.1b-1993.
8625773Speter */
87102227Smike#ifndef _CLOCKID_T_DECLARED
88102227Smiketypedef	__clockid_t	clockid_t;
89102227Smike#define	_CLOCKID_T_DECLARED
9025769Sache#endif
9125769Sache
92102227Smike#ifndef _TIMER_T_DECLARED
93102227Smiketypedef	__timer_t	timer_t;
94102227Smike#define	_TIMER_T_DECLARED
951539Srgrimes#endif
961539Srgrimes
9798269Swollman#include <sys/timespec.h>
9898269Swollman#endif /* __POSIX_VISIBLE >= 199309 */
9925773Speter
1001539Srgrimesstruct tm {
1011539Srgrimes	int	tm_sec;		/* seconds after the minute [0-60] */
1021539Srgrimes	int	tm_min;		/* minutes after the hour [0-59] */
1031539Srgrimes	int	tm_hour;	/* hours since midnight [0-23] */
1041539Srgrimes	int	tm_mday;	/* day of the month [1-31] */
1051539Srgrimes	int	tm_mon;		/* months since January [0-11] */
1061539Srgrimes	int	tm_year;	/* years since 1900 */
1071539Srgrimes	int	tm_wday;	/* days since Sunday [0-6] */
1081539Srgrimes	int	tm_yday;	/* days since January 1 [0-365] */
1091539Srgrimes	int	tm_isdst;	/* Daylight Savings Time flag */
11075033Sphk	long	tm_gmtoff;	/* offset from UTC in seconds */
1111539Srgrimes	char	*tm_zone;	/* timezone abbreviation */
1121539Srgrimes};
1131539Srgrimes
11498269Swollman#if __POSIX_VISIBLE
11538464Sjkoshyextern char *tzname[];
11638464Sjkoshy#endif
11738464Sjkoshy
1181539Srgrimes__BEGIN_DECLS
11993032Simpchar *asctime(const struct tm *);
12093032Simpclock_t clock(void);
12193032Simpchar *ctime(const time_t *);
12293032Simpdouble difftime(time_t, time_t);
12393032Simpstruct tm *gmtime(const time_t *);
12493032Simpstruct tm *localtime(const time_t *);
12593032Simptime_t mktime(struct tm *);
126101888Srobertsize_t strftime(char *__restrict, size_t, const char *__restrict,
127101888Srobert    const struct tm *__restrict);
12893032Simptime_t time(time_t *);
1291539Srgrimes
13098269Swollman#if __POSIX_VISIBLE
13193032Simpvoid tzset(void);
13298269Swollman#endif
13398269Swollman
13498923Swollman#if __POSIX_VISIBLE >= 199309
13598923Swollmanint clock_getres(clockid_t, struct timespec *);
13698923Swollmanint clock_gettime(clockid_t, struct timespec *);
13798923Swollmanint clock_settime(clockid_t, const struct timespec *);
13898923Swollmanint nanosleep(const struct timespec *, struct timespec *);
13998923Swollman#endif /* __POSIX_VISIBLE >= 199309 */
14098923Swollman
14198930Swollman#if __POSIX_VISIBLE >= 199506
14298930Swollmanchar *asctime_r(const struct tm *, char *);
14398930Swollmanchar *ctime_r(const time_t *, char *);
14498930Swollmanstruct tm *gmtime_r(const time_t *, struct tm *);
14598930Swollmanstruct tm *localtime_r(const time_t *, struct tm *);
14698930Swollman#endif
14798930Swollman
14898269Swollman#if __XSI_VISIBLE
149101886Srobertchar *strptime(const char *__restrict, const char *__restrict,
150101886Srobert    struct tm *__restrict);
15198269Swollman#endif
15298269Swollman
15398269Swollman#if __BSD_VISIBLE
15493032Simpchar *timezone(int, int);
15593032Simpvoid tzsetwall(void);
15693032Simptime_t timelocal(struct tm * const);
15793032Simptime_t timegm(struct tm * const);
15898269Swollman#endif /* __BSD_VISIBLE */
1591539Srgrimes__END_DECLS
1601539Srgrimes
1611539Srgrimes#endif /* !_TIME_H_ */
162