xref: /onnv-gate/usr/src/uts/common/sys/time.h (revision 3446:5903aece022d)
10Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
20Sstevel@tonic-gate /*	  All Rights Reserved  	*/
30Sstevel@tonic-gate 
40Sstevel@tonic-gate 
50Sstevel@tonic-gate /*
60Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
70Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
80Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
90Sstevel@tonic-gate  */
100Sstevel@tonic-gate 
110Sstevel@tonic-gate /*
12*3446Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
130Sstevel@tonic-gate  * Use is subject to license terms.
140Sstevel@tonic-gate  */
150Sstevel@tonic-gate 
160Sstevel@tonic-gate #ifndef _SYS_TIME_H
170Sstevel@tonic-gate #define	_SYS_TIME_H
180Sstevel@tonic-gate 
190Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.16	*/
200Sstevel@tonic-gate 
210Sstevel@tonic-gate #include <sys/feature_tests.h>
220Sstevel@tonic-gate 
230Sstevel@tonic-gate /*
240Sstevel@tonic-gate  * Structure returned by gettimeofday(2) system call,
250Sstevel@tonic-gate  * and used in other calls.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifdef	__cplusplus
290Sstevel@tonic-gate extern "C" {
300Sstevel@tonic-gate #endif
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
330Sstevel@tonic-gate 	defined(__EXTENSIONS__)
340Sstevel@tonic-gate #ifndef	_ASM
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #if !defined(_TIME_T) || __cplusplus >= 199711L
370Sstevel@tonic-gate #define	_TIME_T
380Sstevel@tonic-gate typedef	long	time_t;		/* time of day in seconds */
390Sstevel@tonic-gate #endif	/* _TIME_T */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #ifndef	_SUSECONDS_T
420Sstevel@tonic-gate #define	_SUSECONDS_T
430Sstevel@tonic-gate typedef	long	suseconds_t;	/* signed # of microseconds */
440Sstevel@tonic-gate #endif	/* _SUSECONDS_T */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate struct timeval {
470Sstevel@tonic-gate 	time_t		tv_sec;		/* seconds */
480Sstevel@tonic-gate 	suseconds_t	tv_usec;	/* and microseconds */
490Sstevel@tonic-gate };
500Sstevel@tonic-gate 
510Sstevel@tonic-gate #if defined(_SYSCALL32)
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #include <sys/types32.h>
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #define	TIMEVAL32_TO_TIMEVAL(tv, tv32)	{	\
560Sstevel@tonic-gate 	(tv)->tv_sec = (time_t)(tv32)->tv_sec;	\
570Sstevel@tonic-gate 	(tv)->tv_usec = (tv32)->tv_usec;	\
580Sstevel@tonic-gate }
590Sstevel@tonic-gate 
600Sstevel@tonic-gate #define	TIMEVAL_TO_TIMEVAL32(tv32, tv)	{		\
610Sstevel@tonic-gate 	(tv32)->tv_sec = (time32_t)(tv)->tv_sec;	\
620Sstevel@tonic-gate 	(tv32)->tv_usec = (tv)->tv_usec;		\
630Sstevel@tonic-gate }
640Sstevel@tonic-gate 
650Sstevel@tonic-gate #define	TIME32_MAX	INT32_MAX
660Sstevel@tonic-gate #define	TIME32_MIN	INT32_MIN
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	TIMEVAL_OVERFLOW(tv)	\
690Sstevel@tonic-gate 	((tv)->tv_sec < TIME32_MIN || (tv)->tv_sec > TIME32_MAX)
700Sstevel@tonic-gate 
710Sstevel@tonic-gate #endif	/* _SYSCALL32 || _KERNEL */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #endif	/* _ASM */
740Sstevel@tonic-gate #endif	/* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
770Sstevel@tonic-gate #ifndef	_ASM
780Sstevel@tonic-gate struct timezone {
790Sstevel@tonic-gate 	int	tz_minuteswest;	/* minutes west of Greenwich */
800Sstevel@tonic-gate 	int	tz_dsttime;	/* type of dst correction */
810Sstevel@tonic-gate };
820Sstevel@tonic-gate 
830Sstevel@tonic-gate #endif	/* _ASM */
840Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #ifdef	__cplusplus
870Sstevel@tonic-gate }
880Sstevel@tonic-gate #endif
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * Needed for longlong_t type.  Placement of this due to <sys/types.h>
920Sstevel@tonic-gate  * including <sys/select.h> which relies on the presense of the itimerval
930Sstevel@tonic-gate  * structure.
940Sstevel@tonic-gate  */
950Sstevel@tonic-gate #ifndef	_ASM
960Sstevel@tonic-gate #include <sys/types.h>
970Sstevel@tonic-gate #endif	/* _ASM */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate #ifdef	__cplusplus
1000Sstevel@tonic-gate extern "C" {
1010Sstevel@tonic-gate #endif
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate #define	DST_NONE	0	/* not on dst */
1060Sstevel@tonic-gate #define	DST_USA		1	/* USA style dst */
1070Sstevel@tonic-gate #define	DST_AUST	2	/* Australian style dst */
1080Sstevel@tonic-gate #define	DST_WET		3	/* Western European dst */
1090Sstevel@tonic-gate #define	DST_MET		4	/* Middle European dst */
1100Sstevel@tonic-gate #define	DST_EET		5	/* Eastern European dst */
1110Sstevel@tonic-gate #define	DST_CAN		6	/* Canada */
1120Sstevel@tonic-gate #define	DST_GB		7	/* Great Britain and Eire */
1130Sstevel@tonic-gate #define	DST_RUM		8	/* Rumania */
1140Sstevel@tonic-gate #define	DST_TUR		9	/* Turkey */
1150Sstevel@tonic-gate #define	DST_AUSTALT	10	/* Australian style with shift in 1986 */
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /*
1180Sstevel@tonic-gate  * Operations on timevals.
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate #define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
1210Sstevel@tonic-gate #define	timercmp(tvp, uvp, cmp) \
1220Sstevel@tonic-gate 	(((tvp)->tv_sec == (uvp)->tv_sec) ? \
1230Sstevel@tonic-gate 	    /* CSTYLED */ \
1240Sstevel@tonic-gate 	    ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
1250Sstevel@tonic-gate 	    /* CSTYLED */ \
1260Sstevel@tonic-gate 	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate #define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * Names of the interval timers, and structure
1350Sstevel@tonic-gate  * defining a timer setting.
1360Sstevel@tonic-gate  */
1370Sstevel@tonic-gate #define	ITIMER_REAL	0	/* Decrements in real time */
1380Sstevel@tonic-gate #define	ITIMER_VIRTUAL	1	/* Decrements in process virtual time */
1390Sstevel@tonic-gate #define	ITIMER_PROF	2	/* Decrements both in process virtual */
1400Sstevel@tonic-gate 				/* time and when system is running on */
1410Sstevel@tonic-gate 				/* behalf of the process. */
1420Sstevel@tonic-gate #define	ITIMER_REALPROF	3	/* Decrements in real time for real- */
1430Sstevel@tonic-gate 				/* time profiling of multithreaded */
1440Sstevel@tonic-gate 				/* programs. */
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate #ifndef	_ASM
1470Sstevel@tonic-gate struct	itimerval {
1480Sstevel@tonic-gate 	struct	timeval it_interval;	/* timer interval */
1490Sstevel@tonic-gate 	struct	timeval it_value;	/* current value */
1500Sstevel@tonic-gate };
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate #if defined(_SYSCALL32)
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate struct itimerval32 {
1550Sstevel@tonic-gate 	struct	timeval32 it_interval;
1560Sstevel@tonic-gate 	struct	timeval32 it_value;
1570Sstevel@tonic-gate };
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate #define	ITIMERVAL32_TO_ITIMERVAL(itv, itv32)	{	\
1600Sstevel@tonic-gate 	TIMEVAL32_TO_TIMEVAL(&(itv)->it_interval, &(itv32)->it_interval); \
1610Sstevel@tonic-gate 	TIMEVAL32_TO_TIMEVAL(&(itv)->it_value, &(itv32)->it_value);	\
1620Sstevel@tonic-gate }
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate #define	ITIMERVAL_TO_ITIMERVAL32(itv32, itv)	{	\
1650Sstevel@tonic-gate 	TIMEVAL_TO_TIMEVAL32(&(itv32)->it_interval, &(itv)->it_interval); \
1660Sstevel@tonic-gate 	TIMEVAL_TO_TIMEVAL32(&(itv32)->it_value, &(itv)->it_value);	\
1670Sstevel@tonic-gate }
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate #define	ITIMERVAL_OVERFLOW(itv)				\
1700Sstevel@tonic-gate 	(TIMEVAL_OVERFLOW(&(itv)->it_interval) ||	\
1710Sstevel@tonic-gate 	TIMEVAL_OVERFLOW(&(itv)->it_value))
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate #endif	/* _SYSCALL32 */
1740Sstevel@tonic-gate #endif	/* _ASM */
1750Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
1790Sstevel@tonic-gate /*
1800Sstevel@tonic-gate  *	Definitions for commonly used resolutions.
1810Sstevel@tonic-gate  */
1820Sstevel@tonic-gate #define	SEC		1
1830Sstevel@tonic-gate #define	MILLISEC	1000
1840Sstevel@tonic-gate #define	MICROSEC	1000000
1850Sstevel@tonic-gate #define	NANOSEC		1000000000
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate #ifndef	_ASM
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /*
1920Sstevel@tonic-gate  * Time expressed as a 64-bit nanosecond counter.
1930Sstevel@tonic-gate  */
1940Sstevel@tonic-gate typedef	longlong_t	hrtime_t;
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate #ifdef _KERNEL
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate #include <sys/time_impl.h>
1990Sstevel@tonic-gate #include <sys/mutex.h>
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate extern int tick_per_msec;	/* clock ticks per millisecond (may be zero) */
2020Sstevel@tonic-gate extern int msec_per_tick;	/* milliseconds per clock tick (may be zero) */
2030Sstevel@tonic-gate extern int usec_per_tick;	/* microseconds per clock tick */
2040Sstevel@tonic-gate extern int nsec_per_tick;	/* nanoseconds per clock tick */
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate /*
2070Sstevel@tonic-gate  * Macros to convert from common units of time (sec, msec, usec, nsec,
2080Sstevel@tonic-gate  * timeval, timestruc) to clock ticks and vice versa.
2090Sstevel@tonic-gate  */
2100Sstevel@tonic-gate #define	TICK_TO_SEC(tick)	((tick) / hz)
2110Sstevel@tonic-gate #define	SEC_TO_TICK(sec)	((sec) * hz)
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate #define	TICK_TO_MSEC(tick)	\
2140Sstevel@tonic-gate 	(msec_per_tick ? (tick) * msec_per_tick : (tick) / tick_per_msec)
2150Sstevel@tonic-gate #define	MSEC_TO_TICK(msec)	\
2160Sstevel@tonic-gate 	(msec_per_tick ? (msec) / msec_per_tick : (msec) * tick_per_msec)
2170Sstevel@tonic-gate #define	MSEC_TO_TICK_ROUNDUP(msec)	\
2180Sstevel@tonic-gate 	(msec_per_tick ? \
2190Sstevel@tonic-gate 	((msec) == 0 ? 0 : ((msec) - 1) / msec_per_tick + 1) : \
2200Sstevel@tonic-gate 	(msec) * tick_per_msec)
2210Sstevel@tonic-gate 
2220Sstevel@tonic-gate #define	TICK_TO_USEC(tick)		((tick) * usec_per_tick)
2230Sstevel@tonic-gate #define	USEC_TO_TICK(usec)		((usec) / usec_per_tick)
2240Sstevel@tonic-gate #define	USEC_TO_TICK_ROUNDUP(usec)	\
2250Sstevel@tonic-gate 	((usec) == 0 ? 0 : USEC_TO_TICK((usec) - 1) + 1)
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate #define	TICK_TO_NSEC(tick)		((tick) * nsec_per_tick)
2280Sstevel@tonic-gate #define	NSEC_TO_TICK(nsec)		((nsec) / nsec_per_tick)
2290Sstevel@tonic-gate #define	NSEC_TO_TICK_ROUNDUP(nsec)	\
2300Sstevel@tonic-gate 	((nsec) == 0 ? 0 : NSEC_TO_TICK((nsec) - 1) + 1)
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #define	TICK_TO_TIMEVAL(tick, tvp) {	\
2330Sstevel@tonic-gate 	clock_t __tmptck = (tick);	\
2340Sstevel@tonic-gate 	(tvp)->tv_sec = TICK_TO_SEC(__tmptck);	\
2350Sstevel@tonic-gate 	(tvp)->tv_usec = TICK_TO_USEC(__tmptck - SEC_TO_TICK((tvp)->tv_sec)); \
2360Sstevel@tonic-gate }
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate #define	TICK_TO_TIMEVAL32(tick, tvp) {	\
2390Sstevel@tonic-gate 	clock_t __tmptck = (tick);	\
2400Sstevel@tonic-gate 	time_t __tmptm = TICK_TO_SEC(__tmptck);	\
2410Sstevel@tonic-gate 	(tvp)->tv_sec = (time32_t)__tmptm;	\
2420Sstevel@tonic-gate 	(tvp)->tv_usec = TICK_TO_USEC(__tmptck - SEC_TO_TICK(__tmptm)); \
2430Sstevel@tonic-gate }
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate #define	TICK_TO_TIMESTRUC(tick, tsp) {	\
2460Sstevel@tonic-gate 	clock_t __tmptck = (tick);	\
2470Sstevel@tonic-gate 	(tsp)->tv_sec = TICK_TO_SEC(__tmptck);	\
2480Sstevel@tonic-gate 	(tsp)->tv_nsec = TICK_TO_NSEC(__tmptck - SEC_TO_TICK((tsp)->tv_sec)); \
2490Sstevel@tonic-gate }
2500Sstevel@tonic-gate 
2510Sstevel@tonic-gate #define	TICK_TO_TIMESTRUC32(tick, tsp) {	\
2520Sstevel@tonic-gate 	clock_t __tmptck = (tick);			\
2530Sstevel@tonic-gate 	time_t __tmptm = TICK_TO_SEC(__tmptck);		\
2540Sstevel@tonic-gate 	(tsp)->tv_sec = (time32_t)__tmptm;		\
2550Sstevel@tonic-gate 	(tsp)->tv_nsec = TICK_TO_NSEC(__tmptck - SEC_TO_TICK(__tmptm));	\
2560Sstevel@tonic-gate }
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate #define	TIMEVAL_TO_TICK(tvp)	\
2590Sstevel@tonic-gate 	(SEC_TO_TICK((tvp)->tv_sec) + USEC_TO_TICK((tvp)->tv_usec))
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate #define	TIMESTRUC_TO_TICK(tsp)	\
2620Sstevel@tonic-gate 	(SEC_TO_TICK((tsp)->tv_sec) + NSEC_TO_TICK((tsp)->tv_nsec))
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate typedef struct todinfo {
2650Sstevel@tonic-gate 	int	tod_sec;	/* seconds 0-59 */
2660Sstevel@tonic-gate 	int	tod_min;	/* minutes 0-59 */
2670Sstevel@tonic-gate 	int	tod_hour;	/* hours 0-23 */
2680Sstevel@tonic-gate 	int	tod_dow;	/* day of week 1-7 */
2690Sstevel@tonic-gate 	int	tod_day;	/* day of month 1-31 */
2700Sstevel@tonic-gate 	int	tod_month;	/* month 1-12 */
2710Sstevel@tonic-gate 	int	tod_year;	/* year 70+ */
2720Sstevel@tonic-gate } todinfo_t;
2730Sstevel@tonic-gate 
2740Sstevel@tonic-gate extern	int64_t		timedelta;
2750Sstevel@tonic-gate extern	int		timechanged;
2760Sstevel@tonic-gate extern	int		tod_needsync;
2770Sstevel@tonic-gate extern	kmutex_t	tod_lock;
2780Sstevel@tonic-gate extern	timestruc_t	hrestime;
2790Sstevel@tonic-gate extern	hrtime_t	hres_last_tick;
2800Sstevel@tonic-gate extern	int64_t		hrestime_adj;
2810Sstevel@tonic-gate extern	uint_t		adj_shift;
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate extern	timestruc_t	tod_get(void);
2840Sstevel@tonic-gate extern	void		tod_set(timestruc_t);
2850Sstevel@tonic-gate extern	void		set_hrestime(timestruc_t *);
2860Sstevel@tonic-gate extern	todinfo_t	utc_to_tod(time_t);
2870Sstevel@tonic-gate extern	time_t		tod_to_utc(todinfo_t);
2880Sstevel@tonic-gate extern	int		hr_clock_lock(void);
2890Sstevel@tonic-gate extern	void		hr_clock_unlock(int);
2900Sstevel@tonic-gate extern	hrtime_t 	gethrtime(void);
2910Sstevel@tonic-gate extern	hrtime_t 	gethrtime_unscaled(void);
2920Sstevel@tonic-gate extern	hrtime_t	gethrtime_max(void);
2930Sstevel@tonic-gate extern	hrtime_t	gethrtime_waitfree(void);
2940Sstevel@tonic-gate extern	void		scalehrtime(hrtime_t *);
2950Sstevel@tonic-gate extern  uint64_t	unscalehrtime(hrtime_t);
2960Sstevel@tonic-gate extern	void 		gethrestime(timespec_t *);
2970Sstevel@tonic-gate extern	time_t 		gethrestime_sec(void);
2980Sstevel@tonic-gate extern	void		gethrestime_lasttick(timespec_t *);
2990Sstevel@tonic-gate extern	void		hrt2ts(hrtime_t, timestruc_t *);
3000Sstevel@tonic-gate extern	hrtime_t	ts2hrt(const timestruc_t *);
3010Sstevel@tonic-gate extern	void		hrt2tv(hrtime_t, struct timeval *);
3020Sstevel@tonic-gate extern	hrtime_t	tv2hrt(struct timeval *);
3030Sstevel@tonic-gate extern	int		itimerfix(struct timeval *, int);
3040Sstevel@tonic-gate extern	int		itimerdecr(struct itimerval *, int);
3050Sstevel@tonic-gate extern	void		timevaladd(struct timeval *, struct timeval *);
3060Sstevel@tonic-gate extern	void		timevalsub(struct timeval *, struct timeval *);
3070Sstevel@tonic-gate extern	void		timevalfix(struct timeval *);
3080Sstevel@tonic-gate extern	void		dtrace_hres_tick(void);
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate #if defined(_SYSCALL32)
3110Sstevel@tonic-gate extern	void		hrt2ts32(hrtime_t, timestruc32_t *);
3120Sstevel@tonic-gate #endif
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate #endif /* _KERNEL */
3150Sstevel@tonic-gate 
3160Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3170Sstevel@tonic-gate #if defined(__STDC__)
3180Sstevel@tonic-gate int adjtime(struct timeval *, struct timeval *);
3190Sstevel@tonic-gate #else
3200Sstevel@tonic-gate int adjtime();
3210Sstevel@tonic-gate #endif
3220Sstevel@tonic-gate #endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || \
3250Sstevel@tonic-gate 	defined(_ATFILE_SOURCE) || defined(__EXTENSIONS__)
3260Sstevel@tonic-gate #if defined(__STDC__)
3270Sstevel@tonic-gate int futimesat(int, const char *, const struct timeval *);
3280Sstevel@tonic-gate #else
3290Sstevel@tonic-gate int futimesat();
3300Sstevel@tonic-gate #endif /* defined(__STDC__) */
3310Sstevel@tonic-gate #endif /* defined(__ATFILE_SOURCE) */
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
3340Sstevel@tonic-gate 	defined(__EXTENSIONS__)
3350Sstevel@tonic-gate 
3360Sstevel@tonic-gate #if defined(__STDC__)
3370Sstevel@tonic-gate 
3380Sstevel@tonic-gate int getitimer(int, struct itimerval *);
3390Sstevel@tonic-gate int utimes(const char *, const struct timeval *);
3400Sstevel@tonic-gate #if defined(_XPG4_2)
3410Sstevel@tonic-gate int setitimer(int, const struct itimerval *_RESTRICT_KYWD,
3420Sstevel@tonic-gate 	struct itimerval *_RESTRICT_KYWD);
3430Sstevel@tonic-gate #else
3440Sstevel@tonic-gate int setitimer(int, struct itimerval *_RESTRICT_KYWD,
3450Sstevel@tonic-gate 	struct itimerval *_RESTRICT_KYWD);
3460Sstevel@tonic-gate #endif /* defined(_XPG2_2) */
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate #else /* __STDC__ */
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate int gettimer();
3510Sstevel@tonic-gate int settimer();
3520Sstevel@tonic-gate int utimes();
3530Sstevel@tonic-gate #endif /* __STDC__ */
3540Sstevel@tonic-gate #endif /* !defined(_KERNEL) ... defined(_XPG4_2) */
3550Sstevel@tonic-gate 
3560Sstevel@tonic-gate /*
3570Sstevel@tonic-gate  * gettimeofday() and settimeofday() were included in SVr4 due to their
3580Sstevel@tonic-gate  * common use in BSD based applications.  They were to be included exactly
3590Sstevel@tonic-gate  * as in BSD, with two parameters.  However, AT&T/USL noted that the second
3600Sstevel@tonic-gate  * parameter was unused and deleted it, thereby making a routine included
3610Sstevel@tonic-gate  * for compatibility, incompatible.
3620Sstevel@tonic-gate  *
3630Sstevel@tonic-gate  * XSH4.2 (spec 1170) defines gettimeofday and settimeofday to have two
3640Sstevel@tonic-gate  * parameters.
3650Sstevel@tonic-gate  *
3660Sstevel@tonic-gate  * This has caused general disagreement in the application community as to
3670Sstevel@tonic-gate  * the syntax of these routines.  Solaris defaults to the XSH4.2 definition.
3680Sstevel@tonic-gate  * The flag _SVID_GETTOD may be used to force the SVID version.
3690Sstevel@tonic-gate  */
3700Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate #if defined(__STDC__)
3730Sstevel@tonic-gate #if defined(_SVID_GETTOD)
3740Sstevel@tonic-gate int settimeofday(struct timeval *);
3750Sstevel@tonic-gate #else
3760Sstevel@tonic-gate int settimeofday(struct timeval *, void *);
3770Sstevel@tonic-gate #endif
3780Sstevel@tonic-gate hrtime_t	gethrtime(void);
3790Sstevel@tonic-gate hrtime_t	gethrvtime(void);
3800Sstevel@tonic-gate #else /* __STDC__ */
3810Sstevel@tonic-gate int settimeofday();
3820Sstevel@tonic-gate hrtime_t	gethrtime();
3830Sstevel@tonic-gate hrtime_t	gethrvtime();
3840Sstevel@tonic-gate #endif /* __STDC__ */
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate #endif /* !(defined _KERNEL) && !defined(__XOPEN_OR_POSIX) ... */
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
3890Sstevel@tonic-gate 	defined(__EXTENSIONS__)
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate #if defined(__STDC__)
3920Sstevel@tonic-gate #if defined(_SVID_GETTOD)
3930Sstevel@tonic-gate int gettimeofday(struct timeval *);
3940Sstevel@tonic-gate #else
3950Sstevel@tonic-gate int gettimeofday(struct timeval *_RESTRICT_KYWD, void *_RESTRICT_KYWD);
3960Sstevel@tonic-gate #endif
3970Sstevel@tonic-gate #else /* __STDC__ */
3980Sstevel@tonic-gate int gettimeofday();
3990Sstevel@tonic-gate #endif /* __STDC__ */
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate #endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate /*
4040Sstevel@tonic-gate  * The inclusion of <time.h> is historical and was added for
4050Sstevel@tonic-gate  * backward compatibility in delta 1.2 when a number of definitions
4060Sstevel@tonic-gate  * were moved out of <sys/time.h>.  More recently, the timespec and
4070Sstevel@tonic-gate  * itimerspec structure definitions, along with the _CLOCK_*, CLOCK_*,
4080Sstevel@tonic-gate  * _TIMER_*, and TIMER_* symbols were moved to <sys/time_impl.h>,
4090Sstevel@tonic-gate  * which is now included by <time.h>.  This change was due to POSIX
4100Sstevel@tonic-gate  * 1003.1b-1993 and X/Open UNIX 98 requirements.  For non-POSIX and
4110Sstevel@tonic-gate  * non-X/Open applications, including this header will still make
4120Sstevel@tonic-gate  * visible these definitions.
4130Sstevel@tonic-gate  */
414*3446Smrj #if !defined(_BOOT) && !defined(_KERNEL) && \
415*3446Smrj 	!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
4160Sstevel@tonic-gate #include <time.h>
4170Sstevel@tonic-gate #endif
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate /*
4200Sstevel@tonic-gate  * The inclusion of <sys/select.h> is needed for the FD_CLR,
4210Sstevel@tonic-gate  * FD_ISSET, FD_SET, and FD_SETSIZE macros as well as the
4220Sstevel@tonic-gate  * select() prototype defined in the XOpen specifications
4230Sstevel@tonic-gate  * beginning with XSH4v2.  Placement required after definition
4240Sstevel@tonic-gate  * for itimerval.
4250Sstevel@tonic-gate  */
4260Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
4270Sstevel@tonic-gate 	defined(__EXTENSIONS__)
4280Sstevel@tonic-gate #include <sys/select.h>
4290Sstevel@tonic-gate #endif
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate #endif	/* _ASM */
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate #ifdef	__cplusplus
4340Sstevel@tonic-gate }
4350Sstevel@tonic-gate #endif
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate #endif	/* _SYS_TIME_H */
438