time.h revision 240295
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: head/include/time.h 240295 2012-09-10 05:00:29Z davidxu $ 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 115144529Sdas#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */ 116144529Sdas 117144529Sdas#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 118144529Sdas#if __BSD_VISIBLE 119144529Sdas#define TIMER_RELTIME 0x0 /* relative timer */ 120144529Sdas#endif 121144529Sdas#define TIMER_ABSTIME 0x1 /* absolute timer */ 122144529Sdas#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */ 123144529Sdas 1241539Srgrimesstruct tm { 1251539Srgrimes int tm_sec; /* seconds after the minute [0-60] */ 1261539Srgrimes int tm_min; /* minutes after the hour [0-59] */ 1271539Srgrimes int tm_hour; /* hours since midnight [0-23] */ 1281539Srgrimes int tm_mday; /* day of the month [1-31] */ 1291539Srgrimes int tm_mon; /* months since January [0-11] */ 1301539Srgrimes int tm_year; /* years since 1900 */ 1311539Srgrimes int tm_wday; /* days since Sunday [0-6] */ 1321539Srgrimes int tm_yday; /* days since January 1 [0-365] */ 1331539Srgrimes int tm_isdst; /* Daylight Savings Time flag */ 13475033Sphk long tm_gmtoff; /* offset from UTC in seconds */ 1351539Srgrimes char *tm_zone; /* timezone abbreviation */ 1361539Srgrimes}; 1371539Srgrimes 13898269Swollman#if __POSIX_VISIBLE 13938464Sjkoshyextern char *tzname[]; 14038464Sjkoshy#endif 14138464Sjkoshy 1421539Srgrimes__BEGIN_DECLS 14393032Simpchar *asctime(const struct tm *); 14493032Simpclock_t clock(void); 14593032Simpchar *ctime(const time_t *); 14693032Simpdouble difftime(time_t, time_t); 147144529Sdas/* XXX missing: getdate() */ 14893032Simpstruct tm *gmtime(const time_t *); 14993032Simpstruct tm *localtime(const time_t *); 15093032Simptime_t mktime(struct tm *); 151103012Stjrsize_t strftime(char * __restrict, size_t, const char * __restrict, 152103012Stjr const struct tm * __restrict); 15393032Simptime_t time(time_t *); 154151870Sdavidxu#if __POSIX_VISIBLE >= 200112 155151870Sdavidxustruct sigevent; 156151870Sdavidxuint timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); 157151870Sdavidxuint timer_delete(timer_t); 158151870Sdavidxuint timer_gettime(timer_t, struct itimerspec *); 159151870Sdavidxuint timer_getoverrun(timer_t); 160151870Sdavidxuint timer_settime(timer_t, int, const struct itimerspec *__restrict, 161151870Sdavidxu struct itimerspec *__restrict); 162151870Sdavidxu#endif 16398269Swollman#if __POSIX_VISIBLE 16493032Simpvoid tzset(void); 16598269Swollman#endif 16698269Swollman 16798923Swollman#if __POSIX_VISIBLE >= 199309 16898923Swollmanint clock_getres(clockid_t, struct timespec *); 16998923Swollmanint clock_gettime(clockid_t, struct timespec *); 17098923Swollmanint clock_settime(clockid_t, const struct timespec *); 171144529Sdas/* XXX missing: clock_nanosleep() */ 17298923Swollmanint nanosleep(const struct timespec *, struct timespec *); 17398923Swollman#endif /* __POSIX_VISIBLE >= 199309 */ 17498923Swollman 175240295Sdavidxu#if __POSIX_VISIBLE >= 200112 176240295Sdavidxuint clock_getcpuclockid(pid_t, clockid_t *); 177240295Sdavidxu#endif 178240295Sdavidxu 17998930Swollman#if __POSIX_VISIBLE >= 199506 18098930Swollmanchar *asctime_r(const struct tm *, char *); 18198930Swollmanchar *ctime_r(const time_t *, char *); 18298930Swollmanstruct tm *gmtime_r(const time_t *, struct tm *); 18398930Swollmanstruct tm *localtime_r(const time_t *, struct tm *); 18498930Swollman#endif 18598930Swollman 18698269Swollman#if __XSI_VISIBLE 187103012Stjrchar *strptime(const char * __restrict, const char * __restrict, 188103012Stjr struct tm * __restrict); 18998269Swollman#endif 19098269Swollman 19198269Swollman#if __BSD_VISIBLE 192144529Sdaschar *timezone(int, int); /* XXX XSI conflict */ 19393032Simpvoid tzsetwall(void); 19493032Simptime_t timelocal(struct tm * const); 19593032Simptime_t timegm(struct tm * const); 19698269Swollman#endif /* __BSD_VISIBLE */ 197232498Stheraven 198233600Stheraven#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) 199232498Stheraven#include <xlocale/_time.h> 200232498Stheraven#endif 2011539Srgrimes__END_DECLS 2021539Srgrimes 2031539Srgrimes#endif /* !_TIME_H_ */ 204