xref: /minix3/include/time.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: time.h,v 1.44 2014/10/07 21:50:36 christos Exp $	*/
22fe8fb19SBen Gras 
32fe8fb19SBen Gras /*
42fe8fb19SBen Gras  * Copyright (c) 1989, 1993
52fe8fb19SBen Gras  *	The Regents of the University of California.  All rights reserved.
62fe8fb19SBen Gras  * (c) UNIX System Laboratories, Inc.
72fe8fb19SBen Gras  * All or some portions of this file are derived from material licensed
82fe8fb19SBen Gras  * to the University of California by American Telephone and Telegraph
92fe8fb19SBen Gras  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
102fe8fb19SBen Gras  * the permission of UNIX System Laboratories, Inc.
112fe8fb19SBen Gras  *
122fe8fb19SBen Gras  * Redistribution and use in source and binary forms, with or without
132fe8fb19SBen Gras  * modification, are permitted provided that the following conditions
142fe8fb19SBen Gras  * are met:
152fe8fb19SBen Gras  * 1. Redistributions of source code must retain the above copyright
162fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer.
172fe8fb19SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
182fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer in the
192fe8fb19SBen Gras  *    documentation and/or other materials provided with the distribution.
202fe8fb19SBen Gras  * 3. Neither the name of the University nor the names of its contributors
212fe8fb19SBen Gras  *    may be used to endorse or promote products derived from this software
222fe8fb19SBen Gras  *    without specific prior written permission.
232fe8fb19SBen Gras  *
242fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
252fe8fb19SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
262fe8fb19SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
272fe8fb19SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
282fe8fb19SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
292fe8fb19SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
302fe8fb19SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
312fe8fb19SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
322fe8fb19SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
332fe8fb19SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
342fe8fb19SBen Gras  * SUCH DAMAGE.
352fe8fb19SBen Gras  *
362fe8fb19SBen Gras  *	@(#)time.h	8.3 (Berkeley) 1/21/94
379865aeaaSBen Gras  */
389865aeaaSBen Gras 
392fe8fb19SBen Gras #ifndef _TIME_H_
402fe8fb19SBen Gras #define	_TIME_H_
412fe8fb19SBen Gras 
422fe8fb19SBen Gras #include <sys/cdefs.h>
432fe8fb19SBen Gras #include <sys/featuretest.h>
442fe8fb19SBen Gras #include <machine/ansi.h>
459865aeaaSBen Gras 
46dbde088dSArun Thomas #include <sys/null.h>
47dbde088dSArun Thomas 
482fe8fb19SBen Gras #ifdef	_BSD_CLOCK_T_
492fe8fb19SBen Gras typedef	_BSD_CLOCK_T_	clock_t;
502fe8fb19SBen Gras #undef	_BSD_CLOCK_T_
512fe8fb19SBen Gras #endif
522fe8fb19SBen Gras 
532fe8fb19SBen Gras #ifdef	_BSD_TIME_T_
542fe8fb19SBen Gras typedef	_BSD_TIME_T_	time_t;
552fe8fb19SBen Gras #undef	_BSD_TIME_T_
562fe8fb19SBen Gras #endif
572fe8fb19SBen Gras 
582fe8fb19SBen Gras #ifdef	_BSD_SIZE_T_
592fe8fb19SBen Gras typedef	_BSD_SIZE_T_	size_t;
602fe8fb19SBen Gras #undef	_BSD_SIZE_T_
612fe8fb19SBen Gras #endif
622fe8fb19SBen Gras 
632fe8fb19SBen Gras #ifdef	_BSD_CLOCKID_T_
642fe8fb19SBen Gras typedef	_BSD_CLOCKID_T_	clockid_t;
652fe8fb19SBen Gras #undef	_BSD_CLOCKID_T_
662fe8fb19SBen Gras #endif
672fe8fb19SBen Gras 
682fe8fb19SBen Gras #ifdef	_BSD_TIMER_T_
692fe8fb19SBen Gras typedef	_BSD_TIMER_T_	timer_t;
702fe8fb19SBen Gras #undef	_BSD_TIMER_T_
712fe8fb19SBen Gras #endif
722fe8fb19SBen Gras 
732fe8fb19SBen Gras #define CLOCKS_PER_SEC	100
749865aeaaSBen Gras 
759865aeaaSBen Gras struct tm {
762fe8fb19SBen Gras 	int	tm_sec;		/* seconds after the minute [0-61] */
772fe8fb19SBen Gras 	int	tm_min;		/* minutes after the hour [0-59] */
782fe8fb19SBen Gras 	int	tm_hour;	/* hours since midnight [0-23] */
792fe8fb19SBen Gras 	int	tm_mday;	/* day of the month [1-31] */
802fe8fb19SBen Gras 	int	tm_mon;		/* months since January [0-11] */
819865aeaaSBen Gras 	int	tm_year;	/* years since 1900 */
822fe8fb19SBen Gras 	int	tm_wday;	/* days since Sunday [0-6] */
832fe8fb19SBen Gras 	int	tm_yday;	/* days since January 1 [0-365] */
842fe8fb19SBen Gras 	int	tm_isdst;	/* Daylight Savings Time flag */
852fe8fb19SBen Gras 	long	tm_gmtoff;	/* offset from UTC in seconds */
862fe8fb19SBen Gras 	__aconst char *tm_zone;	/* timezone abbreviation */
879865aeaaSBen Gras };
889865aeaaSBen Gras 
892fe8fb19SBen Gras __BEGIN_DECLS
902fe8fb19SBen Gras char *asctime(const struct tm *);
912fe8fb19SBen Gras clock_t clock(void);
922fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
932fe8fb19SBen Gras char *ctime(const time_t *) __RENAME(__ctime50);
942fe8fb19SBen Gras double difftime(time_t, time_t) __RENAME(__difftime50);
952fe8fb19SBen Gras struct tm *gmtime(const time_t *) __RENAME(__gmtime50);
962fe8fb19SBen Gras struct tm *localtime(const time_t *) __RENAME(__locatime50);
972fe8fb19SBen Gras time_t time(time_t *) __RENAME(__time50);
982fe8fb19SBen Gras time_t mktime(struct tm *) __RENAME(__mktime50);
992fe8fb19SBen Gras #endif
1002fe8fb19SBen Gras size_t strftime(char * __restrict, size_t, const char * __restrict,
1012fe8fb19SBen Gras     const struct tm * __restrict)
1022fe8fb19SBen Gras     __attribute__((__format__(__strftime__, 3, 0)));
1039865aeaaSBen Gras 
1042fe8fb19SBen Gras #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
1052fe8fb19SBen Gras     defined(_NETBSD_SOURCE)
1062fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1072fe8fb19SBen Gras /*
1082fe8fb19SBen Gras  * CLK_TCK uses libc's internal __sysconf() to retrieve the machine's
1092fe8fb19SBen Gras  * HZ. The value of _SC_CLK_TCK is 39 -- we hard code it so we do not
1102fe8fb19SBen Gras  * need to include unistd.h
1112fe8fb19SBen Gras  */
1122fe8fb19SBen Gras long __sysconf(int);
1132fe8fb19SBen Gras #define CLK_TCK		(__sysconf(39))
1142fe8fb19SBen Gras #endif
1159865aeaaSBen Gras #endif
1169865aeaaSBen Gras 
1172fe8fb19SBen Gras extern __aconst char *tzname[2];
1182fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1192fe8fb19SBen Gras void tzset(void) __RENAME(__tzset50);
1209865aeaaSBen Gras #endif
1219865aeaaSBen Gras 
1222fe8fb19SBen Gras /*
1232fe8fb19SBen Gras  * X/Open Portability Guide >= Issue 4
1242fe8fb19SBen Gras  */
1252fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
1262fe8fb19SBen Gras extern int daylight;
1272fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1282fe8fb19SBen Gras extern long int timezone __RENAME(__timezone13);
1292fe8fb19SBen Gras #endif
1302fe8fb19SBen Gras char *strptime(const char * __restrict, const char * __restrict,
1312fe8fb19SBen Gras     struct tm * __restrict);
1322fe8fb19SBen Gras #endif
1332fe8fb19SBen Gras 
1342fe8fb19SBen Gras #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
1352fe8fb19SBen Gras     defined(_NETBSD_SOURCE)
1362fe8fb19SBen Gras struct tm *getdate(const char *);
1372fe8fb19SBen Gras extern int getdate_err;
1382fe8fb19SBen Gras #endif
1392fe8fb19SBen Gras 
1402fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
1412fe8fb19SBen Gras     defined(_NETBSD_SOURCE)
1422fe8fb19SBen Gras #include <sys/time.h>		/* XXX for struct timespec */
1432fe8fb19SBen Gras struct sigevent;
1442fe8fb19SBen Gras struct itimerspec;
145f14fb602SLionel Sambuc int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
1462fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1472fe8fb19SBen Gras int clock_getres(clockid_t, struct timespec *)
1482fe8fb19SBen Gras     __RENAME(__clock_getres50);
1492fe8fb19SBen Gras int clock_gettime(clockid_t, struct timespec *)
1502fe8fb19SBen Gras     __RENAME(__clock_gettime50);
1512fe8fb19SBen Gras int clock_settime(clockid_t, const struct timespec *)
1522fe8fb19SBen Gras     __RENAME(__clock_settime50);
1532fe8fb19SBen Gras int nanosleep(const struct timespec *, struct timespec *)
1542fe8fb19SBen Gras     __RENAME(__nanosleep50);
1552fe8fb19SBen Gras int timer_gettime(timer_t, struct itimerspec *) __RENAME(__timer_gettime50);
1562fe8fb19SBen Gras int timer_settime(timer_t, int, const struct itimerspec * __restrict,
1572fe8fb19SBen Gras     struct itimerspec * __restrict) __RENAME(__timer_settime50);
1582fe8fb19SBen Gras #endif
1592fe8fb19SBen Gras int timer_create(clockid_t, struct sigevent * __restrict,
1602fe8fb19SBen Gras     timer_t * __restrict);
1612fe8fb19SBen Gras int timer_delete(timer_t);
1622fe8fb19SBen Gras int timer_getoverrun(timer_t);
1632fe8fb19SBen Gras #endif /* _POSIX_C_SOURCE >= 199309 || _XOPEN_SOURCE >= 500 || ... */
1642fe8fb19SBen Gras 
1652fe8fb19SBen Gras #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
1662fe8fb19SBen Gras     defined(_REENTRANT) || defined(_NETBSD_SOURCE)
1672fe8fb19SBen Gras char *asctime_r(const struct tm * __restrict, char * __restrict);
1682fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1692fe8fb19SBen Gras char *ctime_r(const time_t *, char *) __RENAME(__ctime_r50);
1702fe8fb19SBen Gras struct tm *gmtime_r(const time_t * __restrict, struct tm * __restrict)
1712fe8fb19SBen Gras     __RENAME(__gmtime_r50);
1722fe8fb19SBen Gras struct tm *localtime_r(const time_t * __restrict, struct tm * __restrict)
1732fe8fb19SBen Gras     __RENAME(__localtime_r50);
1742fe8fb19SBen Gras #endif
1752fe8fb19SBen Gras #endif
1762fe8fb19SBen Gras 
17784d9c625SLionel Sambuc #if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
17884d9c625SLionel Sambuc #  ifndef __LOCALE_T_DECLARED
17984d9c625SLionel Sambuc typedef struct _locale		*locale_t;
18084d9c625SLionel Sambuc #  define __LOCALE_T_DECLARED
18184d9c625SLionel Sambuc #  endif
18284d9c625SLionel Sambuc size_t strftime_l(char * __restrict, size_t, const char * __restrict,
18384d9c625SLionel Sambuc     const struct tm * __restrict, locale_t)
18484d9c625SLionel Sambuc     __attribute__((__format__(__strftime__, 3, 0)));
18584d9c625SLionel Sambuc #endif
18684d9c625SLionel Sambuc 
1872fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
1882fe8fb19SBen Gras 
1892fe8fb19SBen Gras typedef struct __state *timezone_t;
1902fe8fb19SBen Gras 
1912fe8fb19SBen Gras #ifndef __LIBC12_SOURCE__
1922fe8fb19SBen Gras time_t time2posix(time_t) __RENAME(__time2posix50);
1932fe8fb19SBen Gras time_t posix2time(time_t) __RENAME(__posix2time50);
1942fe8fb19SBen Gras time_t timegm(struct tm *) __RENAME(__timegm50);
1952fe8fb19SBen Gras time_t timeoff(struct tm *, long) __RENAME(__timeoff50);
1962fe8fb19SBen Gras time_t timelocal(struct tm *) __RENAME(__timelocal50);
1972fe8fb19SBen Gras struct tm *offtime(const time_t *, long) __RENAME(__offtime50);
1982fe8fb19SBen Gras void tzsetwall(void) __RENAME(__tzsetwall50);
1992fe8fb19SBen Gras 
2002fe8fb19SBen Gras struct tm *offtime_r(const time_t *, long, struct tm *) __RENAME(__offtime_r50);
201*0a6a1f1dSLionel Sambuc struct tm *localtime_rz(timezone_t __restrict, const time_t * __restrict,
2022fe8fb19SBen Gras     struct tm * __restrict) __RENAME(__localtime_rz50);
203*0a6a1f1dSLionel Sambuc char *ctime_rz(timezone_t __restrict, const time_t *, char *)
204*0a6a1f1dSLionel Sambuc     __RENAME(__ctime_rz50);
205*0a6a1f1dSLionel Sambuc time_t mktime_z(timezone_t __restrict, struct tm * __restrict)
206*0a6a1f1dSLionel Sambuc     __RENAME(__mktime_z50);
207*0a6a1f1dSLionel Sambuc time_t timelocal_z(timezone_t __restrict, struct tm *)
208*0a6a1f1dSLionel Sambuc     __RENAME(__timelocal_z50);
209*0a6a1f1dSLionel Sambuc time_t time2posix_z(timezone_t __restrict, time_t) __RENAME(__time2posix_z50);
210*0a6a1f1dSLionel Sambuc time_t posix2time_z(timezone_t __restrict, time_t) __RENAME(__posix2time_z50);
2112fe8fb19SBen Gras timezone_t tzalloc(const char *) __RENAME(__tzalloc50);
212*0a6a1f1dSLionel Sambuc void tzfree(timezone_t __restrict) __RENAME(__tzfree50);
213*0a6a1f1dSLionel Sambuc const char *tzgetname(timezone_t __restrict, int) __RENAME(__tzgetname50);
2142fe8fb19SBen Gras #endif
2152fe8fb19SBen Gras 
216*0a6a1f1dSLionel Sambuc size_t strftime_lz(timezone_t __restrict, char * __restrict, size_t,
21784d9c625SLionel Sambuc     const char * __restrict, const struct tm * __restrict, locale_t)
21884d9c625SLionel Sambuc     __attribute__((__format__(__strftime__, 4, 0)));
219*0a6a1f1dSLionel Sambuc size_t strftime_z(timezone_t __restrict, char * __restrict, size_t,
2202fe8fb19SBen Gras     const char * __restrict, const struct tm * __restrict)
2212fe8fb19SBen Gras     __attribute__((__format__(__strftime__, 4, 0)));
22284d9c625SLionel Sambuc char *strptime_l(const char * __restrict, const char * __restrict,
22384d9c625SLionel Sambuc     struct tm * __restrict, locale_t);
2242fe8fb19SBen Gras 
2252fe8fb19SBen Gras #endif /* _NETBSD_SOURCE */
2262fe8fb19SBen Gras 
2272fe8fb19SBen Gras __END_DECLS
228dfe2b451SBen Gras 
2292fe8fb19SBen Gras #endif /* !_TIME_H_ */
230