2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)time.h 8.3 (Berkeley) 1/21/94
46 #include <sys/cdefs.h>
47 #include <sys/_null.h>
48 #include <sys/_types.h>
49 #include <sys/_clock_id.h>
51 #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
53 * Frequency of the clock ticks reported by times(). Deprecated - use
54 * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
59 /* Frequency of the clock ticks reported by clock(). */
60 #define CLOCKS_PER_SEC 128
62 #ifndef _CLOCK_T_DECLARED
63 typedef __clock_t clock_t;
64 #define _CLOCK_T_DECLARED
67 #ifndef _TIME_T_DECLARED
68 typedef __time_t time_t;
69 #define _TIME_T_DECLARED
72 #ifndef _SIZE_T_DECLARED
73 typedef __size_t size_t;
74 #define _SIZE_T_DECLARED
77 #if __POSIX_VISIBLE >= 199309
79 * New in POSIX 1003.1b-1993.
81 #ifndef _CLOCKID_T_DECLARED
82 typedef __clockid_t clockid_t;
83 #define _CLOCKID_T_DECLARED
86 #ifndef _TIMER_T_DECLARED
87 typedef __timer_t timer_t;
88 #define _TIMER_T_DECLARED
91 #include <sys/timespec.h>
92 #endif /* __POSIX_VISIBLE >= 199309 */
94 #if __POSIX_VISIBLE >= 200112
95 #ifndef _PID_T_DECLARED
96 typedef __pid_t pid_t;
97 #define _PID_T_DECLARED
102 int tm_sec; /* seconds after the minute [0-60] */
103 int tm_min; /* minutes after the hour [0-59] */
104 int tm_hour; /* hours since midnight [0-23] */
105 int tm_mday; /* day of the month [1-31] */
106 int tm_mon; /* months since January [0-11] */
107 int tm_year; /* years since 1900 */
108 int tm_wday; /* days since Sunday [0-6] */
109 int tm_yday; /* days since January 1 [0-365] */
110 int tm_isdst; /* Daylight Savings Time flag */
111 long tm_gmtoff; /* offset from UTC in seconds */
112 char *tm_zone; /* timezone abbreviation */
116 extern char *tzname[];
120 char *asctime(const struct tm *);
122 char *ctime(const time_t *);
124 double difftime(time_t, time_t);
126 /* XXX missing: getdate() */
127 struct tm *gmtime(const time_t *);
128 struct tm *localtime(const time_t *);
129 time_t mktime(struct tm *);
130 size_t strftime(char * __restrict, size_t, const char * __restrict,
131 const struct tm * __restrict);
132 time_t time(time_t *);
133 #if __POSIX_VISIBLE >= 200112
135 int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
136 int timer_delete(timer_t);
137 int timer_gettime(timer_t, struct itimerspec *);
138 int timer_getoverrun(timer_t);
139 int timer_settime(timer_t, int, const struct itimerspec *__restrict,
140 struct itimerspec *__restrict);
146 #if __POSIX_VISIBLE >= 199309
147 int clock_getres(clockid_t, struct timespec *);
148 int clock_gettime(clockid_t, struct timespec *);
149 int clock_settime(clockid_t, const struct timespec *);
150 int nanosleep(const struct timespec *, struct timespec *);
151 #endif /* __POSIX_VISIBLE >= 199309 */
153 #if __POSIX_VISIBLE >= 200112
154 int clock_getcpuclockid(pid_t, clockid_t *);
155 int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
158 #if __POSIX_VISIBLE >= 199506
159 char *asctime_r(const struct tm *, char *);
160 char *ctime_r(const time_t *, char *);
161 struct tm *gmtime_r(const time_t *, struct tm *);
162 struct tm *localtime_r(const time_t *, struct tm *);
166 char *strptime(const char * __restrict, const char * __restrict,
167 struct tm * __restrict);
171 char *timezone(int, int); /* XXX XSI conflict */
172 void tzsetwall(void);
173 time_t timelocal(struct tm * const);
174 time_t timegm(struct tm * const);
175 int timer_oshandle_np(timer_t timerid);
176 time_t time2posix(time_t t);
177 time_t posix2time(time_t t);
178 #endif /* __BSD_VISIBLE */
180 #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
181 #include <xlocale/_time.h>
184 #if defined(__BSD_VISIBLE) || __ISO_C_VISIBLE >= 2011 || \
185 (defined(__cplusplus) && __cplusplus >= 201703)
186 #include <sys/_timespec.h>
187 /* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */
188 #define TIME_UTC 1 /* time elapsed since epoch */
189 int timespec_get(struct timespec *ts, int base);
194 #endif /* !_TIME_H_ */