11539Srgrimes/* 21539Srgrimes * Copyright (c) 1989, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * (c) UNIX System Laboratories, Inc. 51539Srgrimes * All or some portions of this file are derived from material licensed 61539Srgrimes * to the University of California by American Telephone and Telegraph 71539Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81539Srgrimes * the permission of UNIX System Laboratories, Inc. 91539Srgrimes * 101539Srgrimes * Redistribution and use in source and binary forms, with or without 111539Srgrimes * modification, are permitted provided that the following conditions 121539Srgrimes * are met: 131539Srgrimes * 1. Redistributions of source code must retain the above copyright 141539Srgrimes * notice, this list of conditions and the following disclaimer. 151539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161539Srgrimes * notice, this list of conditions and the following disclaimer in the 171539Srgrimes * documentation and/or other materials provided with the distribution. 18203964Simp * 3. Neither the name of the University nor the names of its contributors 191539Srgrimes * may be used to endorse or promote products derived from this software 201539Srgrimes * without specific prior written permission. 211539Srgrimes * 221539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321539Srgrimes * SUCH DAMAGE. 331539Srgrimes * 341539Srgrimes * @(#)time.h 8.3 (Berkeley) 1/21/94 351539Srgrimes */ 361539Srgrimes 3775033Sphk/* 3875033Sphk * $FreeBSD$ 3975033Sphk */ 4075033Sphk 411539Srgrimes#ifndef _TIME_H_ 421539Srgrimes#define _TIME_H_ 431539Srgrimes 4498269Swollman#include <sys/cdefs.h> 45123257Smarcel#include <sys/_null.h> 46102227Smike#include <sys/_types.h> 47102227Smike 4898312Swollman#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE 496164Sbde/* 506164Sbde * Frequency of the clock ticks reported by times(). Deprecated - use 5198269Swollman * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.) 526164Sbde */ 53102874Smike#define CLK_TCK 128 546164Sbde#endif 556164Sbde 566164Sbde/* Frequency of the clock ticks reported by clock(). */ 57102874Smike#define CLOCKS_PER_SEC 128 586164Sbde 59102227Smike#ifndef _CLOCK_T_DECLARED 60102227Smiketypedef __clock_t clock_t; 61102227Smike#define _CLOCK_T_DECLARED 621539Srgrimes#endif 631539Srgrimes 64102227Smike#ifndef _TIME_T_DECLARED 65102227Smiketypedef __time_t time_t; 66102227Smike#define _TIME_T_DECLARED 671539Srgrimes#endif 681539Srgrimes 69102227Smike#ifndef _SIZE_T_DECLARED 70102227Smiketypedef __size_t size_t; 71102227Smike#define _SIZE_T_DECLARED 7225773Speter#endif 7325773Speter 7498269Swollman#if __POSIX_VISIBLE >= 199309 7525773Speter/* 7625773Speter * New in POSIX 1003.1b-1993. 7725773Speter */ 78102227Smike#ifndef _CLOCKID_T_DECLARED 79102227Smiketypedef __clockid_t clockid_t; 80102227Smike#define _CLOCKID_T_DECLARED 8125769Sache#endif 8225769Sache 83102227Smike#ifndef _TIMER_T_DECLARED 84102227Smiketypedef __timer_t timer_t; 85102227Smike#define _TIMER_T_DECLARED 861539Srgrimes#endif 871539Srgrimes 8898269Swollman#include <sys/timespec.h> 8998269Swollman#endif /* __POSIX_VISIBLE >= 199309 */ 9025773Speter 91240295Sdavidxu#if __POSIX_VISIBLE >= 200112 92240295Sdavidxu#ifndef _PID_T_DECLARED 93240295Sdavidxutypedef __pid_t pid_t; 94240295Sdavidxu#define _PID_T_DECLARED 95240295Sdavidxu#endif 96240295Sdavidxu#endif 97240295Sdavidxu 98144529Sdas/* These macros are also in sys/time.h. */ 99144529Sdas#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 100144529Sdas#define CLOCK_REALTIME 0 101144529Sdas#ifdef __BSD_VISIBLE 102144529Sdas#define CLOCK_VIRTUAL 1 103144529Sdas#define CLOCK_PROF 2 104144529Sdas#endif 105144529Sdas#define CLOCK_MONOTONIC 4 106157766Sjb#define CLOCK_UPTIME 5 /* FreeBSD-specific. */ 107157766Sjb#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ 108157766Sjb#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ 109157766Sjb#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ 110157766Sjb#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ 111157766Sjb#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ 112157766Sjb#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ 113157766Sjb#define CLOCK_SECOND 13 /* FreeBSD-specific. */ 114177494Sdavidxu#define CLOCK_THREAD_CPUTIME_ID 14 115245428Sdim#define CLOCK_PROCESS_CPUTIME_ID 15 116144529Sdas#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */ 117144529Sdas 118144529Sdas#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 119144529Sdas#if __BSD_VISIBLE 120144529Sdas#define TIMER_RELTIME 0x0 /* relative timer */ 121144529Sdas#endif 122144529Sdas#define TIMER_ABSTIME 0x1 /* absolute timer */ 123144529Sdas#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */ 124144529Sdas 1251539Srgrimesstruct tm { 1261539Srgrimes int tm_sec; /* seconds after the minute [0-60] */ 1271539Srgrimes int tm_min; /* minutes after the hour [0-59] */ 1281539Srgrimes int tm_hour; /* hours since midnight [0-23] */ 1291539Srgrimes int tm_mday; /* day of the month [1-31] */ 1301539Srgrimes int tm_mon; /* months since January [0-11] */ 1311539Srgrimes int tm_year; /* years since 1900 */ 1321539Srgrimes int tm_wday; /* days since Sunday [0-6] */ 1331539Srgrimes int tm_yday; /* days since January 1 [0-365] */ 1341539Srgrimes int tm_isdst; /* Daylight Savings Time flag */ 13575033Sphk long tm_gmtoff; /* offset from UTC in seconds */ 1361539Srgrimes char *tm_zone; /* timezone abbreviation */ 1371539Srgrimes}; 1381539Srgrimes 13998269Swollman#if __POSIX_VISIBLE 14038464Sjkoshyextern char *tzname[]; 14138464Sjkoshy#endif 14238464Sjkoshy 1431539Srgrimes__BEGIN_DECLS 14493032Simpchar *asctime(const struct tm *); 14593032Simpclock_t clock(void); 14693032Simpchar *ctime(const time_t *); 14793032Simpdouble difftime(time_t, time_t); 148144529Sdas/* XXX missing: getdate() */ 14993032Simpstruct tm *gmtime(const time_t *); 15093032Simpstruct tm *localtime(const time_t *); 15193032Simptime_t mktime(struct tm *); 152103012Stjrsize_t strftime(char * __restrict, size_t, const char * __restrict, 153103012Stjr const struct tm * __restrict); 15493032Simptime_t time(time_t *); 155151870Sdavidxu#if __POSIX_VISIBLE >= 200112 156151870Sdavidxustruct sigevent; 157151870Sdavidxuint timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); 158151870Sdavidxuint timer_delete(timer_t); 159151870Sdavidxuint timer_gettime(timer_t, struct itimerspec *); 160151870Sdavidxuint timer_getoverrun(timer_t); 161151870Sdavidxuint timer_settime(timer_t, int, const struct itimerspec *__restrict, 162151870Sdavidxu struct itimerspec *__restrict); 163151870Sdavidxu#endif 16498269Swollman#if __POSIX_VISIBLE 16593032Simpvoid tzset(void); 16698269Swollman#endif 16798269Swollman 16898923Swollman#if __POSIX_VISIBLE >= 199309 16998923Swollmanint clock_getres(clockid_t, struct timespec *); 17098923Swollmanint clock_gettime(clockid_t, struct timespec *); 17198923Swollmanint clock_settime(clockid_t, const struct timespec *); 172144529Sdas/* XXX missing: clock_nanosleep() */ 17398923Swollmanint nanosleep(const struct timespec *, struct timespec *); 17498923Swollman#endif /* __POSIX_VISIBLE >= 199309 */ 17598923Swollman 176240295Sdavidxu#if __POSIX_VISIBLE >= 200112 177240295Sdavidxuint clock_getcpuclockid(pid_t, clockid_t *); 178240295Sdavidxu#endif 179240295Sdavidxu 18098930Swollman#if __POSIX_VISIBLE >= 199506 18198930Swollmanchar *asctime_r(const struct tm *, char *); 18298930Swollmanchar *ctime_r(const time_t *, char *); 18398930Swollmanstruct tm *gmtime_r(const time_t *, struct tm *); 18498930Swollmanstruct tm *localtime_r(const time_t *, struct tm *); 18598930Swollman#endif 18698930Swollman 18798269Swollman#if __XSI_VISIBLE 188103012Stjrchar *strptime(const char * __restrict, const char * __restrict, 189103012Stjr struct tm * __restrict); 19098269Swollman#endif 19198269Swollman 19298269Swollman#if __BSD_VISIBLE 193144529Sdaschar *timezone(int, int); /* XXX XSI conflict */ 19493032Simpvoid tzsetwall(void); 19593032Simptime_t timelocal(struct tm * const); 19693032Simptime_t timegm(struct tm * const); 19798269Swollman#endif /* __BSD_VISIBLE */ 198232498Stheraven 199233600Stheraven#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) 200232498Stheraven#include <xlocale/_time.h> 201232498Stheraven#endif 2021539Srgrimes__END_DECLS 2031539Srgrimes 2041539Srgrimes#endif /* !_TIME_H_ */ 205