199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1989, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (c) UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All or some portions of this file are derived from material licensed
199767f8919635c4928607450d9e0abb932109ceToomas Soome * to the University of California by American Telephone and Telegraph
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Co. or Unix System Laboratories, Inc. and are reproduced herein with
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the permission of UNIX System Laboratories, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 3. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)time.h 8.3 (Berkeley) 1/21/94
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _TIME_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _TIME_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/cdefs.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_null.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/_types.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Frequency of the clock ticks reported by times(). Deprecated - use
199767f8919635c4928607450d9e0abb932109ceToomas Soome * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLK_TCK 128
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Frequency of the clock ticks reported by clock(). */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCKS_PER_SEC 128
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _CLOCK_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __clock_t clock_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _CLOCK_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _TIME_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __time_t time_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _TIME_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SIZE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __size_t size_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SIZE_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 199309
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * New in POSIX 1003.1b-1993.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _CLOCKID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __clockid_t clockid_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _CLOCKID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _TIMER_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __timer_t timer_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _TIMER_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/timespec.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __POSIX_VISIBLE >= 199309 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _PID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef __pid_t pid_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _PID_T_DECLARED
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* These macros are also in sys/time.h. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_REALTIME 0
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_VIRTUAL 1
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_PROF 2
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_MONOTONIC 4
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_SECOND 13 /* FreeBSD-specific. */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_THREAD_CPUTIME_ID 14
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define CLOCK_PROCESS_CPUTIME_ID 15
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define TIMER_RELTIME 0x0 /* relative timer */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define TIMER_ABSTIME 0x1 /* absolute timer */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct tm {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_sec; /* seconds after the minute [0-60] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_min; /* minutes after the hour [0-59] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_hour; /* hours since midnight [0-23] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_mday; /* day of the month [1-31] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_mon; /* months since January [0-11] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_year; /* years since 1900 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_wday; /* days since Sunday [0-6] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_yday; /* days since January 1 [0-365] */
199767f8919635c4928607450d9e0abb932109ceToomas Soome int tm_isdst; /* Daylight Savings Time flag */
199767f8919635c4928607450d9e0abb932109ceToomas Soome long tm_gmtoff; /* offset from UTC in seconds */
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *tm_zone; /* timezone abbreviation */
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern char *tzname[];
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome__BEGIN_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *asctime(const struct tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeclock_t clock(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *ctime(const time_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomedouble difftime(time_t, time_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* XXX missing: getdate() */
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct tm *gmtime(const time_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct tm *localtime(const time_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soometime_t mktime(struct tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomesize_t strftime(char * __restrict, size_t, const char * __restrict,
199767f8919635c4928607450d9e0abb932109ceToomas Soome const struct tm * __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soometime_t time(time_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct sigevent;
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint timer_delete(timer_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint timer_gettime(timer_t, struct itimerspec *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint timer_getoverrun(timer_t);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint timer_settime(timer_t, int, const struct itimerspec *__restrict,
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct itimerspec *__restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid tzset(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 199309
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint clock_getres(clockid_t, struct timespec *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint clock_gettime(clockid_t, struct timespec *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint clock_settime(clockid_t, const struct timespec *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* XXX missing: clock_nanosleep() */
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint nanosleep(const struct timespec *, struct timespec *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __POSIX_VISIBLE >= 199309 */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200112
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint clock_getcpuclockid(pid_t, clockid_t *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 199506
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *asctime_r(const struct tm *, char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *ctime_r(const time_t *, char *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct tm *gmtime_r(const time_t *, struct tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct tm *localtime_r(const time_t *, struct tm *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __XSI_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *strptime(const char * __restrict, const char * __restrict,
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct tm * __restrict);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __BSD_VISIBLE
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *timezone(int, int); /* XXX XSI conflict */
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid tzsetwall(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soometime_t timelocal(struct tm * const);
199767f8919635c4928607450d9e0abb932109ceToomas Soometime_t timegm(struct tm * const);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __BSD_VISIBLE */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <xlocale/_time.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome__END_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_TIME_H_ */