1/*	$OpenBSD: time.h,v 1.32 2022/10/25 16:30:30 millert Exp $	*/
2/*	$NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $	*/
3
4/*
5 * Copyright (c) 1989 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * (c) UNIX System Laboratories, Inc.
9 * All or some portions of this file are derived from material licensed
10 * to the University of California by American Telephone and Telegraph
11 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
12 * the permission of UNIX System Laboratories, Inc.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 * 3. Neither the name of the University nor the names of its contributors
23 *    may be used to endorse or promote products derived from this software
24 *    without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 *	@(#)time.h	5.12 (Berkeley) 3/9/91
39 */
40
41#ifndef _TIME_H_
42#define	_TIME_H_
43
44#include <sys/cdefs.h>
45#include <sys/_null.h>
46#include <sys/_types.h>
47#include <sys/_time.h>
48
49#ifndef	_CLOCK_T_DEFINED_
50#define	_CLOCK_T_DEFINED_
51typedef	__clock_t	clock_t;
52#endif
53
54#ifndef	_TIME_T_DEFINED_
55#define	_TIME_T_DEFINED_
56typedef	__time_t	time_t;
57#endif
58
59#ifndef	_SIZE_T_DEFINED_
60#define	_SIZE_T_DEFINED_
61typedef	__size_t	size_t;
62#endif
63
64#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
65/*
66 * Frequency of the clock ticks reported by times().  Deprecated - use
67 * sysconf(_SC_CLK_TCK) instead.  (Removed in 1003.1-2001.)
68 */
69#define CLK_TCK		100
70#endif
71
72#if __POSIX_VISIBLE >= 199309
73#ifndef	_CLOCKID_T_DEFINED_
74#define	_CLOCKID_T_DEFINED_
75typedef	__clockid_t	clockid_t;
76#endif
77
78#ifndef	_TIMER_T_DEFINED_
79#define	_TIMER_T_DEFINED_
80typedef	__timer_t	timer_t;
81#endif
82#endif
83
84#if __POSIX_VISIBLE >= 200112
85#ifndef	_PID_T_DEFINED_
86#define	_PID_T_DEFINED_
87typedef	__pid_t		pid_t;
88#endif
89#endif
90
91#if __POSIX_VISIBLE >= 200809
92#ifndef	_LOCALE_T_DEFINED_
93#define	_LOCALE_T_DEFINED_
94typedef void	*locale_t;
95#endif
96#endif
97
98struct tm {
99	int	tm_sec;		/* seconds after the minute [0-60] */
100	int	tm_min;		/* minutes after the hour [0-59] */
101	int	tm_hour;	/* hours since midnight [0-23] */
102	int	tm_mday;	/* day of the month [1-31] */
103	int	tm_mon;		/* months since January [0-11] */
104	int	tm_year;	/* years since 1900 */
105	int	tm_wday;	/* days since Sunday [0-6] */
106	int	tm_yday;	/* days since January 1 [0-365] */
107	int	tm_isdst;	/* Daylight Saving Time flag */
108	long	tm_gmtoff;	/* offset from UTC in seconds */
109	char	*tm_zone;	/* timezone abbreviation */
110};
111
112__BEGIN_DECLS
113char *asctime(const struct tm *);
114clock_t clock(void);
115char *ctime(const time_t *);
116double difftime(time_t, time_t);
117struct tm *gmtime(const time_t *);
118struct tm *localtime(const time_t *);
119time_t mktime(struct tm *);
120size_t strftime(char *__restrict, size_t, const char *__restrict,
121		const struct tm *__restrict)
122		__attribute__ ((__bounded__(__string__,1,2)));
123time_t time(time_t *);
124
125#if __XPG_VISIBLE >= 300
126extern int daylight;
127extern long timezone;
128#endif
129#if __XPG_VISIBLE >= 400
130char *strptime(const char *__restrict, const char *__restrict,
131		struct tm *__restrict);
132#endif
133
134#if __POSIX_VISIBLE >= 199506
135char *asctime_r(const struct tm *__restrict, char *__restrict)
136		__attribute__ ((__bounded__(__minbytes__,2,26)));
137char *ctime_r(const time_t *, char *)
138		__attribute__ ((__bounded__(__minbytes__,2,26)));
139struct tm *gmtime_r(const time_t *__restrict, struct tm *__restrict);
140struct tm *localtime_r(const time_t *__restrict, struct tm *__restrict);
141#endif
142
143#if __POSIX_VISIBLE
144extern char *tzname[2];
145void tzset(void);
146#endif
147
148#if __POSIX_VISIBLE >= 199309
149int clock_getres(clockid_t, struct timespec *);
150int clock_gettime(clockid_t, struct timespec *);
151int clock_settime(clockid_t, const struct timespec *);
152int nanosleep(const struct timespec *, struct timespec *);
153#endif
154
155#if __POSIX_VISIBLE >= 200112
156int clock_getcpuclockid(pid_t, clockid_t *);
157#endif
158
159#if __POSIX_VISIBLE >= 200809
160size_t strftime_l(char *__restrict, size_t, const char *__restrict,
161		const struct tm *__restrict, locale_t)
162		__attribute__ ((__bounded__(__string__,1,2)));
163#endif
164
165#if __ISO_C_VISIBLE >= 2011
166#define TIME_UTC	1	/* time elapsed since epoch */
167int timespec_get(struct timespec *_ts, int _base);
168#endif
169
170#if __BSD_VISIBLE
171void tzsetwall(void);
172time_t timelocal(struct tm *);
173time_t timegm(struct tm *);
174time_t timeoff(struct tm *, const long);
175#endif
176__END_DECLS
177
178#endif /* !_TIME_H_ */
179