159deaec5SRodney W. Grimes /* 259deaec5SRodney W. Grimes * Copyright (c) 1989, 1993 359deaec5SRodney W. Grimes * The Regents of the University of California. All rights reserved. 459deaec5SRodney W. Grimes * (c) UNIX System Laboratories, Inc. 559deaec5SRodney W. Grimes * All or some portions of this file are derived from material licensed 659deaec5SRodney W. Grimes * to the University of California by American Telephone and Telegraph 759deaec5SRodney W. Grimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 859deaec5SRodney W. Grimes * the permission of UNIX System Laboratories, Inc. 959deaec5SRodney W. Grimes * 1059deaec5SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 1159deaec5SRodney W. Grimes * modification, are permitted provided that the following conditions 1259deaec5SRodney W. Grimes * are met: 1359deaec5SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 1459deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 1559deaec5SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 1659deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 1759deaec5SRodney W. Grimes * documentation and/or other materials provided with the distribution. 1859deaec5SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 1959deaec5SRodney W. Grimes * must display the following acknowledgement: 2059deaec5SRodney W. Grimes * This product includes software developed by the University of 2159deaec5SRodney W. Grimes * California, Berkeley and its contributors. 2259deaec5SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 2359deaec5SRodney W. Grimes * may be used to endorse or promote products derived from this software 2459deaec5SRodney W. Grimes * without specific prior written permission. 2559deaec5SRodney W. Grimes * 2659deaec5SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2759deaec5SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2859deaec5SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2959deaec5SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3059deaec5SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3159deaec5SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3259deaec5SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3359deaec5SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3459deaec5SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3559deaec5SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3659deaec5SRodney W. Grimes * SUCH DAMAGE. 3759deaec5SRodney W. Grimes * 3859deaec5SRodney W. Grimes * @(#)time.h 8.3 (Berkeley) 1/21/94 3959deaec5SRodney W. Grimes */ 4059deaec5SRodney W. Grimes 415b32a38aSPoul-Henning Kamp /* 425b32a38aSPoul-Henning Kamp * $FreeBSD$ 435b32a38aSPoul-Henning Kamp */ 445b32a38aSPoul-Henning Kamp 4559deaec5SRodney W. Grimes #ifndef _TIME_H_ 4659deaec5SRodney W. Grimes #define _TIME_H_ 4759deaec5SRodney W. Grimes 4859deaec5SRodney W. Grimes #include <machine/ansi.h> 498a6472b7SPeter Dufault #include <sys/_posix.h> 5059deaec5SRodney W. Grimes 51339b0f68SBruce Evans #ifndef _ANSI_SOURCE 52339b0f68SBruce Evans /* 53339b0f68SBruce Evans * Frequency of the clock ticks reported by times(). Deprecated - use 54339b0f68SBruce Evans * sysconf(_SC_CLK_TCK) instead. 55339b0f68SBruce Evans */ 5602a7dd76SBruce Evans #define CLK_TCK _BSD_CLK_TCK_ 57339b0f68SBruce Evans #endif 58339b0f68SBruce Evans 59339b0f68SBruce Evans /* Frequency of the clock ticks reported by clock(). */ 60339b0f68SBruce Evans #define CLOCKS_PER_SEC _BSD_CLOCKS_PER_SEC_ 61339b0f68SBruce Evans 6259deaec5SRodney W. Grimes #ifndef NULL 6359deaec5SRodney W. Grimes #define NULL 0 6459deaec5SRodney W. Grimes #endif 6559deaec5SRodney W. Grimes 6659deaec5SRodney W. Grimes #ifdef _BSD_CLOCK_T_ 6759deaec5SRodney W. Grimes typedef _BSD_CLOCK_T_ clock_t; 6859deaec5SRodney W. Grimes #undef _BSD_CLOCK_T_ 6959deaec5SRodney W. Grimes #endif 7059deaec5SRodney W. Grimes 7159deaec5SRodney W. Grimes #ifdef _BSD_TIME_T_ 7259deaec5SRodney W. Grimes typedef _BSD_TIME_T_ time_t; 7359deaec5SRodney W. Grimes #undef _BSD_TIME_T_ 7459deaec5SRodney W. Grimes #endif 7559deaec5SRodney W. Grimes 76f154fbdaSPeter Wemm #ifdef _BSD_SIZE_T_ 77f154fbdaSPeter Wemm typedef _BSD_SIZE_T_ size_t; 78f154fbdaSPeter Wemm #undef _BSD_SIZE_T_ 79f154fbdaSPeter Wemm #endif 80f154fbdaSPeter Wemm 818a6472b7SPeter Dufault /* XXX I'm not sure if _ANSI_SOURCE is playing properly 828a6472b7SPeter Dufault * with the setups in _posix.h: 838a6472b7SPeter Dufault */ 848a6472b7SPeter Dufault #if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY) 85f154fbdaSPeter Wemm /* 86f154fbdaSPeter Wemm * New in POSIX 1003.1b-1993. 87f154fbdaSPeter Wemm */ 889e0eb33eSAndrey A. Chernov #ifdef _BSD_CLOCKID_T_ 899e0eb33eSAndrey A. Chernov typedef _BSD_CLOCKID_T_ clockid_t; 909e0eb33eSAndrey A. Chernov #undef _BSD_CLOCKID_T_ 919e0eb33eSAndrey A. Chernov #endif 929e0eb33eSAndrey A. Chernov 93f154fbdaSPeter Wemm #ifdef _BSD_TIMER_T_ 94f154fbdaSPeter Wemm typedef _BSD_TIMER_T_ timer_t; 95f154fbdaSPeter Wemm #undef _BSD_TIMER_T_ 9659deaec5SRodney W. Grimes #endif 9759deaec5SRodney W. Grimes 98f154fbdaSPeter Wemm #ifndef _TIMESPEC_DECLARED 99f154fbdaSPeter Wemm #define _TIMESPEC_DECLARED 100f154fbdaSPeter Wemm struct timespec { 101f154fbdaSPeter Wemm time_t tv_sec; /* seconds */ 102f154fbdaSPeter Wemm long tv_nsec; /* and nanoseconds */ 103f154fbdaSPeter Wemm }; 104f154fbdaSPeter Wemm #endif 105f154fbdaSPeter Wemm #endif /* Neither ANSI nor POSIX */ 106f154fbdaSPeter Wemm 10759deaec5SRodney W. Grimes struct tm { 10859deaec5SRodney W. Grimes int tm_sec; /* seconds after the minute [0-60] */ 10959deaec5SRodney W. Grimes int tm_min; /* minutes after the hour [0-59] */ 11059deaec5SRodney W. Grimes int tm_hour; /* hours since midnight [0-23] */ 11159deaec5SRodney W. Grimes int tm_mday; /* day of the month [1-31] */ 11259deaec5SRodney W. Grimes int tm_mon; /* months since January [0-11] */ 11359deaec5SRodney W. Grimes int tm_year; /* years since 1900 */ 11459deaec5SRodney W. Grimes int tm_wday; /* days since Sunday [0-6] */ 11559deaec5SRodney W. Grimes int tm_yday; /* days since January 1 [0-365] */ 11659deaec5SRodney W. Grimes int tm_isdst; /* Daylight Savings Time flag */ 1175b32a38aSPoul-Henning Kamp long tm_gmtoff; /* offset from UTC in seconds */ 11859deaec5SRodney W. Grimes char *tm_zone; /* timezone abbreviation */ 11959deaec5SRodney W. Grimes }; 12059deaec5SRodney W. Grimes 12159deaec5SRodney W. Grimes #include <sys/cdefs.h> 12259deaec5SRodney W. Grimes 1232bd32397SJoseph Koshy #ifndef _ANSI_SOURCE 1242bd32397SJoseph Koshy extern char *tzname[]; 1252bd32397SJoseph Koshy #endif 1262bd32397SJoseph Koshy 12759deaec5SRodney W. Grimes __BEGIN_DECLS 12859deaec5SRodney W. Grimes char *asctime __P((const struct tm *)); 12959deaec5SRodney W. Grimes clock_t clock __P((void)); 13059deaec5SRodney W. Grimes char *ctime __P((const time_t *)); 13159deaec5SRodney W. Grimes double difftime __P((time_t, time_t)); 13259deaec5SRodney W. Grimes struct tm *gmtime __P((const time_t *)); 13359deaec5SRodney W. Grimes struct tm *localtime __P((const time_t *)); 13459deaec5SRodney W. Grimes time_t mktime __P((struct tm *)); 13559deaec5SRodney W. Grimes size_t strftime __P((char *, size_t, const char *, const struct tm *)); 13659deaec5SRodney W. Grimes time_t time __P((time_t *)); 13759deaec5SRodney W. Grimes 13859deaec5SRodney W. Grimes #ifndef _ANSI_SOURCE 13959deaec5SRodney W. Grimes void tzset __P((void)); 14059deaec5SRodney W. Grimes #endif /* not ANSI */ 14159deaec5SRodney W. Grimes 14259deaec5SRodney W. Grimes #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 143de160001SDmitrij Tejblum char *asctime_r __P((const struct tm *, char *)); 144de160001SDmitrij Tejblum char *ctime_r __P((const time_t *, char *)); 145de160001SDmitrij Tejblum struct tm *gmtime_r __P((const time_t *, struct tm *)); 146de160001SDmitrij Tejblum struct tm *localtime_r __P((const time_t *, struct tm *)); 147f0cefaccSDmitrij Tejblum char *strptime __P((const char *, const char *, struct tm *)); 14859deaec5SRodney W. Grimes char *timezone __P((int, int)); 14959deaec5SRodney W. Grimes void tzsetwall __P((void)); 1508c2f5ad7SAndrey A. Chernov time_t timelocal __P((struct tm * const)); 1518c2f5ad7SAndrey A. Chernov time_t timegm __P((struct tm * const)); 1528a6472b7SPeter Dufault #endif /* neither ANSI nor POSIX */ 153f154fbdaSPeter Wemm 1548a6472b7SPeter Dufault #if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY) 155f154fbdaSPeter Wemm /* Introduced in POSIX 1003.1b-1993, not part of 1003.1-1990. */ 156f154fbdaSPeter Wemm int clock_getres __P((clockid_t, struct timespec *)); 157f154fbdaSPeter Wemm int clock_gettime __P((clockid_t, struct timespec *)); 158f154fbdaSPeter Wemm int clock_settime __P((clockid_t, const struct timespec *)); 159f154fbdaSPeter Wemm int nanosleep __P((const struct timespec *, struct timespec *)); 16059deaec5SRodney W. Grimes #endif /* neither ANSI nor POSIX */ 16159deaec5SRodney W. Grimes __END_DECLS 16259deaec5SRodney W. Grimes 16359deaec5SRodney W. Grimes #endif /* !_TIME_H_ */ 164