1*199767f8SToomas Soome /* 2*199767f8SToomas Soome * Copyright (c) 1989, 1993 3*199767f8SToomas Soome * The Regents of the University of California. All rights reserved. 4*199767f8SToomas Soome * (c) UNIX System Laboratories, Inc. 5*199767f8SToomas Soome * All or some portions of this file are derived from material licensed 6*199767f8SToomas Soome * to the University of California by American Telephone and Telegraph 7*199767f8SToomas Soome * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8*199767f8SToomas Soome * the permission of UNIX System Laboratories, Inc. 9*199767f8SToomas Soome * 10*199767f8SToomas Soome * Redistribution and use in source and binary forms, with or without 11*199767f8SToomas Soome * modification, are permitted provided that the following conditions 12*199767f8SToomas Soome * are met: 13*199767f8SToomas Soome * 1. Redistributions of source code must retain the above copyright 14*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer. 15*199767f8SToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 16*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer in the 17*199767f8SToomas Soome * documentation and/or other materials provided with the distribution. 18*199767f8SToomas Soome * 3. Neither the name of the University nor the names of its contributors 19*199767f8SToomas Soome * may be used to endorse or promote products derived from this software 20*199767f8SToomas Soome * without specific prior written permission. 21*199767f8SToomas Soome * 22*199767f8SToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23*199767f8SToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*199767f8SToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*199767f8SToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26*199767f8SToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*199767f8SToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*199767f8SToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*199767f8SToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*199767f8SToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*199767f8SToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*199767f8SToomas Soome * SUCH DAMAGE. 33*199767f8SToomas Soome * 34*199767f8SToomas Soome * @(#)time.h 8.3 (Berkeley) 1/21/94 35*199767f8SToomas Soome */ 36*199767f8SToomas Soome 37*199767f8SToomas Soome /* 38*199767f8SToomas Soome * $FreeBSD$ 39*199767f8SToomas Soome */ 40*199767f8SToomas Soome 41*199767f8SToomas Soome #ifndef _TIME_H_ 42*199767f8SToomas Soome #define _TIME_H_ 43*199767f8SToomas Soome 44*199767f8SToomas Soome #include <sys/cdefs.h> 45*199767f8SToomas Soome #include <sys/_null.h> 46*199767f8SToomas Soome #include <sys/_types.h> 47*199767f8SToomas Soome 48*199767f8SToomas Soome #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE 49*199767f8SToomas Soome /* 50*199767f8SToomas Soome * Frequency of the clock ticks reported by times(). Deprecated - use 51*199767f8SToomas Soome * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.) 52*199767f8SToomas Soome */ 53*199767f8SToomas Soome #define CLK_TCK 128 54*199767f8SToomas Soome #endif 55*199767f8SToomas Soome 56*199767f8SToomas Soome /* Frequency of the clock ticks reported by clock(). */ 57*199767f8SToomas Soome #define CLOCKS_PER_SEC 128 58*199767f8SToomas Soome 59*199767f8SToomas Soome #ifndef _CLOCK_T_DECLARED 60*199767f8SToomas Soome typedef __clock_t clock_t; 61*199767f8SToomas Soome #define _CLOCK_T_DECLARED 62*199767f8SToomas Soome #endif 63*199767f8SToomas Soome 64*199767f8SToomas Soome #ifndef _TIME_T_DECLARED 65*199767f8SToomas Soome typedef __time_t time_t; 66*199767f8SToomas Soome #define _TIME_T_DECLARED 67*199767f8SToomas Soome #endif 68*199767f8SToomas Soome 69*199767f8SToomas Soome #ifndef _SIZE_T_DECLARED 70*199767f8SToomas Soome typedef __size_t size_t; 71*199767f8SToomas Soome #define _SIZE_T_DECLARED 72*199767f8SToomas Soome #endif 73*199767f8SToomas Soome 74*199767f8SToomas Soome #if __POSIX_VISIBLE >= 199309 75*199767f8SToomas Soome /* 76*199767f8SToomas Soome * New in POSIX 1003.1b-1993. 77*199767f8SToomas Soome */ 78*199767f8SToomas Soome #ifndef _CLOCKID_T_DECLARED 79*199767f8SToomas Soome typedef __clockid_t clockid_t; 80*199767f8SToomas Soome #define _CLOCKID_T_DECLARED 81*199767f8SToomas Soome #endif 82*199767f8SToomas Soome 83*199767f8SToomas Soome #ifndef _TIMER_T_DECLARED 84*199767f8SToomas Soome typedef __timer_t timer_t; 85*199767f8SToomas Soome #define _TIMER_T_DECLARED 86*199767f8SToomas Soome #endif 87*199767f8SToomas Soome 88*199767f8SToomas Soome #include <sys/timespec.h> 89*199767f8SToomas Soome #endif /* __POSIX_VISIBLE >= 199309 */ 90*199767f8SToomas Soome 91*199767f8SToomas Soome #if __POSIX_VISIBLE >= 200112 92*199767f8SToomas Soome #ifndef _PID_T_DECLARED 93*199767f8SToomas Soome typedef __pid_t pid_t; 94*199767f8SToomas Soome #define _PID_T_DECLARED 95*199767f8SToomas Soome #endif 96*199767f8SToomas Soome #endif 97*199767f8SToomas Soome 98*199767f8SToomas Soome /* These macros are also in sys/time.h. */ 99*199767f8SToomas Soome #if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 100*199767f8SToomas Soome #define CLOCK_REALTIME 0 101*199767f8SToomas Soome #ifdef __BSD_VISIBLE 102*199767f8SToomas Soome #define CLOCK_VIRTUAL 1 103*199767f8SToomas Soome #define CLOCK_PROF 2 104*199767f8SToomas Soome #endif 105*199767f8SToomas Soome #define CLOCK_MONOTONIC 4 106*199767f8SToomas Soome #define CLOCK_UPTIME 5 /* FreeBSD-specific. */ 107*199767f8SToomas Soome #define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ 108*199767f8SToomas Soome #define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ 109*199767f8SToomas Soome #define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ 110*199767f8SToomas Soome #define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ 111*199767f8SToomas Soome #define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ 112*199767f8SToomas Soome #define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ 113*199767f8SToomas Soome #define CLOCK_SECOND 13 /* FreeBSD-specific. */ 114*199767f8SToomas Soome #define CLOCK_THREAD_CPUTIME_ID 14 115*199767f8SToomas Soome #define CLOCK_PROCESS_CPUTIME_ID 15 116*199767f8SToomas Soome #endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */ 117*199767f8SToomas Soome 118*199767f8SToomas Soome #if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 119*199767f8SToomas Soome #if __BSD_VISIBLE 120*199767f8SToomas Soome #define TIMER_RELTIME 0x0 /* relative timer */ 121*199767f8SToomas Soome #endif 122*199767f8SToomas Soome #define TIMER_ABSTIME 0x1 /* absolute timer */ 123*199767f8SToomas Soome #endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */ 124*199767f8SToomas Soome 125*199767f8SToomas Soome struct tm { 126*199767f8SToomas Soome int tm_sec; /* seconds after the minute [0-60] */ 127*199767f8SToomas Soome int tm_min; /* minutes after the hour [0-59] */ 128*199767f8SToomas Soome int tm_hour; /* hours since midnight [0-23] */ 129*199767f8SToomas Soome int tm_mday; /* day of the month [1-31] */ 130*199767f8SToomas Soome int tm_mon; /* months since January [0-11] */ 131*199767f8SToomas Soome int tm_year; /* years since 1900 */ 132*199767f8SToomas Soome int tm_wday; /* days since Sunday [0-6] */ 133*199767f8SToomas Soome int tm_yday; /* days since January 1 [0-365] */ 134*199767f8SToomas Soome int tm_isdst; /* Daylight Savings Time flag */ 135*199767f8SToomas Soome long tm_gmtoff; /* offset from UTC in seconds */ 136*199767f8SToomas Soome char *tm_zone; /* timezone abbreviation */ 137*199767f8SToomas Soome }; 138*199767f8SToomas Soome 139*199767f8SToomas Soome #if __POSIX_VISIBLE 140*199767f8SToomas Soome extern char *tzname[]; 141*199767f8SToomas Soome #endif 142*199767f8SToomas Soome 143*199767f8SToomas Soome __BEGIN_DECLS 144*199767f8SToomas Soome char *asctime(const struct tm *); 145*199767f8SToomas Soome clock_t clock(void); 146*199767f8SToomas Soome char *ctime(const time_t *); 147*199767f8SToomas Soome double difftime(time_t, time_t); 148*199767f8SToomas Soome /* XXX missing: getdate() */ 149*199767f8SToomas Soome struct tm *gmtime(const time_t *); 150*199767f8SToomas Soome struct tm *localtime(const time_t *); 151*199767f8SToomas Soome time_t mktime(struct tm *); 152*199767f8SToomas Soome size_t strftime(char * __restrict, size_t, const char * __restrict, 153*199767f8SToomas Soome const struct tm * __restrict); 154*199767f8SToomas Soome time_t time(time_t *); 155*199767f8SToomas Soome #if __POSIX_VISIBLE >= 200112 156*199767f8SToomas Soome struct sigevent; 157*199767f8SToomas Soome int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); 158*199767f8SToomas Soome int timer_delete(timer_t); 159*199767f8SToomas Soome int timer_gettime(timer_t, struct itimerspec *); 160*199767f8SToomas Soome int timer_getoverrun(timer_t); 161*199767f8SToomas Soome int timer_settime(timer_t, int, const struct itimerspec *__restrict, 162*199767f8SToomas Soome struct itimerspec *__restrict); 163*199767f8SToomas Soome #endif 164*199767f8SToomas Soome #if __POSIX_VISIBLE 165*199767f8SToomas Soome void tzset(void); 166*199767f8SToomas Soome #endif 167*199767f8SToomas Soome 168*199767f8SToomas Soome #if __POSIX_VISIBLE >= 199309 169*199767f8SToomas Soome int clock_getres(clockid_t, struct timespec *); 170*199767f8SToomas Soome int clock_gettime(clockid_t, struct timespec *); 171*199767f8SToomas Soome int clock_settime(clockid_t, const struct timespec *); 172*199767f8SToomas Soome /* XXX missing: clock_nanosleep() */ 173*199767f8SToomas Soome int nanosleep(const struct timespec *, struct timespec *); 174*199767f8SToomas Soome #endif /* __POSIX_VISIBLE >= 199309 */ 175*199767f8SToomas Soome 176*199767f8SToomas Soome #if __POSIX_VISIBLE >= 200112 177*199767f8SToomas Soome int clock_getcpuclockid(pid_t, clockid_t *); 178*199767f8SToomas Soome #endif 179*199767f8SToomas Soome 180*199767f8SToomas Soome #if __POSIX_VISIBLE >= 199506 181*199767f8SToomas Soome char *asctime_r(const struct tm *, char *); 182*199767f8SToomas Soome char *ctime_r(const time_t *, char *); 183*199767f8SToomas Soome struct tm *gmtime_r(const time_t *, struct tm *); 184*199767f8SToomas Soome struct tm *localtime_r(const time_t *, struct tm *); 185*199767f8SToomas Soome #endif 186*199767f8SToomas Soome 187*199767f8SToomas Soome #if __XSI_VISIBLE 188*199767f8SToomas Soome char *strptime(const char * __restrict, const char * __restrict, 189*199767f8SToomas Soome struct tm * __restrict); 190*199767f8SToomas Soome #endif 191*199767f8SToomas Soome 192*199767f8SToomas Soome #if __BSD_VISIBLE 193*199767f8SToomas Soome char *timezone(int, int); /* XXX XSI conflict */ 194*199767f8SToomas Soome void tzsetwall(void); 195*199767f8SToomas Soome time_t timelocal(struct tm * const); 196*199767f8SToomas Soome time_t timegm(struct tm * const); 197*199767f8SToomas Soome #endif /* __BSD_VISIBLE */ 198*199767f8SToomas Soome 199*199767f8SToomas Soome #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) 200*199767f8SToomas Soome #include <xlocale/_time.h> 201*199767f8SToomas Soome #endif 202*199767f8SToomas Soome __END_DECLS 203*199767f8SToomas Soome 204*199767f8SToomas Soome #endif /* !_TIME_H_ */ 205