time.h revision 123257
1299966Sjkim/*
2299966Sjkim * Copyright (c) 1989, 1993
3299966Sjkim *	The Regents of the University of California.  All rights reserved.
4299966Sjkim * (c) UNIX System Laboratories, Inc.
595967Speter * All or some portions of this file are derived from material licensed
6238405Sjkim * to the University of California by American Telephone and Telegraph
7238405Sjkim * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8238405Sjkim * the permission of UNIX System Laboratories, Inc.
9238405Sjkim *
10238405Sjkim * Redistribution and use in source and binary forms, with or without
1195967Speter * modification, are permitted provided that the following conditions
12238405Sjkim * are met:
13238405Sjkim * 1. Redistributions of source code must retain the above copyright
14238405Sjkim *    notice, this list of conditions and the following disclaimer.
15238405Sjkim * 2. Redistributions in binary form must reproduce the above copyright
16238405Sjkim *    notice, this list of conditions and the following disclaimer in the
17238405Sjkim *    documentation and/or other materials provided with the distribution.
18238405Sjkim * 3. All advertising materials mentioning features or use of this software
19238405Sjkim *    must display the following acknowledgement:
20238405Sjkim *	This product includes software developed by the University of
21238405Sjkim *	California, Berkeley and its contributors.
22238405Sjkim * 4. Neither the name of the University nor the names of its contributors
23238405Sjkim *    may be used to endorse or promote products derived from this software
24238405Sjkim *    without specific prior written permission.
25238405Sjkim *
26238405Sjkim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27238405Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28238405Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29238405Sjkim * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30238405Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31238405Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32238405Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33238405Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34238405Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35238405Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36238405Sjkim * SUCH DAMAGE.
37238405Sjkim *
38238405Sjkim *	@(#)time.h	8.3 (Berkeley) 1/21/94
39238405Sjkim */
40127326Smarkm
41238405Sjkim/*
42238405Sjkim * $FreeBSD: head/include/time.h 123257 2003-12-07 21:10:06Z marcel $
43238405Sjkim */
44238405Sjkim
45238405Sjkim#ifndef _TIME_H_
46238405Sjkim#define	_TIME_H_
47238405Sjkim
48238405Sjkim#include <sys/cdefs.h>
49238405Sjkim#include <sys/_null.h>
50238405Sjkim#include <sys/_types.h>
51238405Sjkim
52238405Sjkim#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
53238405Sjkim/*
54238405Sjkim * Frequency of the clock ticks reported by times().  Deprecated - use
55238405Sjkim * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
56238405Sjkim */
57238405Sjkim#define	CLK_TCK		128
58238405Sjkim#endif
59238405Sjkim
60238405Sjkim/* Frequency of the clock ticks reported by clock().  */
61238405Sjkim#define	CLOCKS_PER_SEC	128
62238405Sjkim
63238405Sjkim#ifndef _CLOCK_T_DECLARED
64238405Sjkimtypedef	__clock_t	clock_t;
65238405Sjkim#define	_CLOCK_T_DECLARED
66238405Sjkim#endif
67238405Sjkim
68238405Sjkim#ifndef _TIME_T_DECLARED
6995967Spetertypedef	__time_t	time_t;
70238405Sjkim#define	_TIME_T_DECLARED
71238405Sjkim#endif
72238405Sjkim
73238405Sjkim#ifndef _SIZE_T_DECLARED
74238405Sjkimtypedef	__size_t	size_t;
75238405Sjkim#define	_SIZE_T_DECLARED
76238405Sjkim#endif
77238405Sjkim
78238405Sjkim#if __POSIX_VISIBLE >= 199309
79238405Sjkim/*
80238405Sjkim * New in POSIX 1003.1b-1993.
81238405Sjkim */
82238405Sjkim#ifndef _CLOCKID_T_DECLARED
83238405Sjkimtypedef	__clockid_t	clockid_t;
84238405Sjkim#define	_CLOCKID_T_DECLARED
85238405Sjkim#endif
86238405Sjkim
87238405Sjkim#ifndef _TIMER_T_DECLARED
88238405Sjkimtypedef	__timer_t	timer_t;
89238405Sjkim#define	_TIMER_T_DECLARED
90238405Sjkim#endif
91238405Sjkim
92238405Sjkim#include <sys/timespec.h>
93238405Sjkim#endif /* __POSIX_VISIBLE >= 199309 */
94238405Sjkim
95238405Sjkimstruct tm {
96238405Sjkim	int	tm_sec;		/* seconds after the minute [0-60] */
97238405Sjkim	int	tm_min;		/* minutes after the hour [0-59] */
98127326Smarkm	int	tm_hour;	/* hours since midnight [0-23] */
99238405Sjkim	int	tm_mday;	/* day of the month [1-31] */
100238405Sjkim	int	tm_mon;		/* months since January [0-11] */
101238405Sjkim	int	tm_year;	/* years since 1900 */
102238405Sjkim	int	tm_wday;	/* days since Sunday [0-6] */
103238405Sjkim	int	tm_yday;	/* days since January 1 [0-365] */
104238405Sjkim	int	tm_isdst;	/* Daylight Savings Time flag */
105238405Sjkim	long	tm_gmtoff;	/* offset from UTC in seconds */
106238405Sjkim	char	*tm_zone;	/* timezone abbreviation */
107238405Sjkim};
108238405Sjkim
109238405Sjkim#if __POSIX_VISIBLE
110238405Sjkimextern char *tzname[];
111238405Sjkim#endif
112238405Sjkim
113238405Sjkim__BEGIN_DECLS
114238405Sjkimchar *asctime(const struct tm *);
115238405Sjkimclock_t clock(void);
116238405Sjkimchar *ctime(const time_t *);
117238405Sjkimdouble difftime(time_t, time_t);
118238405Sjkimstruct tm *gmtime(const time_t *);
119238405Sjkimstruct tm *localtime(const time_t *);
120238405Sjkimtime_t mktime(struct tm *);
121238405Sjkimsize_t strftime(char * __restrict, size_t, const char * __restrict,
122238405Sjkim    const struct tm * __restrict);
123238405Sjkimtime_t time(time_t *);
124238405Sjkim
125238405Sjkim#if __POSIX_VISIBLE
126238405Sjkimvoid tzset(void);
12795967Speter#endif
128238405Sjkim
129238405Sjkim#if __POSIX_VISIBLE >= 199309
130238405Sjkimint clock_getres(clockid_t, struct timespec *);
131238405Sjkimint clock_gettime(clockid_t, struct timespec *);
132238405Sjkimint clock_settime(clockid_t, const struct timespec *);
133238405Sjkimint nanosleep(const struct timespec *, struct timespec *);
134238405Sjkim#endif /* __POSIX_VISIBLE >= 199309 */
135238405Sjkim
136238405Sjkim#if __POSIX_VISIBLE >= 199506
137238405Sjkimchar *asctime_r(const struct tm *, char *);
138238405Sjkimchar *ctime_r(const time_t *, char *);
139238405Sjkimstruct tm *gmtime_r(const time_t *, struct tm *);
140238405Sjkimstruct tm *localtime_r(const time_t *, struct tm *);
141238405Sjkim#endif
142238405Sjkim
143238405Sjkim#if __XSI_VISIBLE
144238405Sjkimchar *strptime(const char * __restrict, const char * __restrict,
145238405Sjkim    struct tm * __restrict);
146238405Sjkim#endif
147238405Sjkim
148238405Sjkim#if __BSD_VISIBLE
149238405Sjkimchar *timezone(int, int);
150238405Sjkimvoid tzsetwall(void);
151238405Sjkimtime_t timelocal(struct tm * const);
152238405Sjkimtime_t timegm(struct tm * const);
153238405Sjkim#endif /* __BSD_VISIBLE */
154238405Sjkim__END_DECLS
155238405Sjkim
15695967Speter#endif /* !_TIME_H_ */
157238405Sjkim