xref: /netbsd-src/include/time.h (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 /*	$NetBSD: time.h,v 1.14 1997/11/02 18:31:38 kleink Exp $	*/
2 
3 /*
4  * Copyright (c) 1989 The Regents of the University of California.
5  * All rights reserved.
6  *
7  * (c) UNIX System Laboratories, Inc.
8  * All or some portions of this file are derived from material licensed
9  * to the University of California by American Telephone and Telegraph
10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11  * the permission of UNIX System Laboratories, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. All advertising materials mentioning features or use of this software
22  *    must display the following acknowledgement:
23  *	This product includes software developed by the University of
24  *	California, Berkeley and its contributors.
25  * 4. Neither the name of the University nor the names of its contributors
26  *    may be used to endorse or promote products derived from this software
27  *    without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  *	@(#)time.h	5.12 (Berkeley) 3/9/91
42  */
43 
44 #ifndef _TIME_H_
45 #define	_TIME_H_
46 
47 #include <machine/ansi.h>
48 
49 #ifndef	NULL
50 #define	NULL	0
51 #endif
52 
53 #ifdef	_BSD_CLOCK_T_
54 typedef	_BSD_CLOCK_T_	clock_t;
55 #undef	_BSD_CLOCK_T_
56 #endif
57 
58 #ifdef	_BSD_TIME_T_
59 typedef	_BSD_TIME_T_	time_t;
60 #undef	_BSD_TIME_T_
61 #endif
62 
63 #ifdef	_BSD_SIZE_T_
64 typedef	_BSD_SIZE_T_	size_t;
65 #undef	_BSD_SIZE_T_
66 #endif
67 
68 #ifdef	_BSD_CLOCKID_T_
69 typedef	_BSD_CLOCKID_T_	clockid_t;
70 #undef	_BSD_CLOCKID_T_
71 #endif
72 
73 #ifdef	_BSD_TIMER_T_
74 typedef	_BSD_TIMER_T_	timer_t;
75 #undef	_BSD_TIMER_T_
76 #endif
77 
78 #define CLOCKS_PER_SEC	100
79 
80 struct tm {
81 	int	tm_sec;		/* seconds after the minute [0-61] */
82 	int	tm_min;		/* minutes after the hour [0-59] */
83 	int	tm_hour;	/* hours since midnight [0-23] */
84 	int	tm_mday;	/* day of the month [1-31] */
85 	int	tm_mon;		/* months since January [0-11] */
86 	int	tm_year;	/* years since 1900 */
87 	int	tm_wday;	/* days since Sunday [0-6] */
88 	int	tm_yday;	/* days since January 1 [0-365] */
89 	int	tm_isdst;	/* Daylight Savings Time flag */
90 	long	tm_gmtoff;	/* offset from CUT in seconds */
91 	char	*tm_zone;	/* timezone abbreviation */
92 };
93 
94 #include <sys/cdefs.h>
95 
96 __BEGIN_DECLS
97 char *asctime __P((const struct tm *));
98 clock_t clock __P((void));
99 char *ctime __P((const time_t *));
100 double difftime __P((time_t, time_t));
101 struct tm *gmtime __P((const time_t *));
102 struct tm *localtime __P((const time_t *));
103 time_t mktime __P((struct tm *));
104 size_t strftime __P((char *, size_t, const char *, const struct tm *));
105 time_t time __P((time_t *));
106 
107 #if !defined(_ANSI_SOURCE)
108 #define CLK_TCK		100
109 extern char *tzname[2];
110 void tzset __P((void));
111 #endif /* not ANSI */
112 
113 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
114 char *strptime __P((const char *, const char *, struct tm *));
115 char *timezone __P((int, int));
116 void tzsetwall __P((void));
117 struct tm *offtime __P((const time_t *const, const long));
118 time_t timelocal __P((struct tm *const));
119 time_t timegm __P((struct tm *const));
120 time_t timeoff __P((struct tm *const, const long));
121 long gtime __P((struct tm *const));
122 time_t time2posix __P((time_t));
123 time_t posix2time __P((time_t));
124 #endif /* neither ANSI nor POSIX */
125 
126 #if (!defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) && \
127      !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
128     ((_POSIX_C_SOURCE - 0) >= 199309L)
129 #include <sys/time.h>		/* for struct timespec */
130 struct sigevent;
131 struct itimerspec;
132 int clock_getres __P((clockid_t, struct timespec *));
133 int clock_gettime __P((clockid_t, struct timespec *));
134 int clock_settime __P((clockid_t, const struct timespec *));
135 int nanosleep __P((const struct timespec *, struct timespec *));
136 int timer_create __P((clockid_t, struct sigevent *, timer_t *));
137 int timer_delete __P((timer_t));
138 int timer_getoverrun __P((timer_t));
139 int timer_gettime __P((timer_t, struct itimerspec *));
140 int timer_settime __P((timer_t, int, const struct itimerspec *,
141     struct itimerspec *));
142 #endif
143 __END_DECLS
144 
145 #endif /* !_TIME_H_ */
146