1*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*0Sstevel@tonic-gate /* All Rights Reserved */ 3*0Sstevel@tonic-gate 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gate /* 6*0Sstevel@tonic-gate * Copyright (c) 1982, 1986 Regents of the University of California. 7*0Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*0Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*0Sstevel@tonic-gate */ 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate /* 12*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 13*0Sstevel@tonic-gate * Use is subject to license terms. 14*0Sstevel@tonic-gate */ 15*0Sstevel@tonic-gate 16*0Sstevel@tonic-gate #ifndef _SYS_TIME_H 17*0Sstevel@tonic-gate #define _SYS_TIME_H 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.16 */ 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate #include <sys/feature_tests.h> 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate /* 24*0Sstevel@tonic-gate * Structure returned by gettimeofday(2) system call, 25*0Sstevel@tonic-gate * and used in other calls. 26*0Sstevel@tonic-gate */ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #ifdef __cplusplus 29*0Sstevel@tonic-gate extern "C" { 30*0Sstevel@tonic-gate #endif 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ 33*0Sstevel@tonic-gate defined(__EXTENSIONS__) 34*0Sstevel@tonic-gate #ifndef _ASM 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #if !defined(_TIME_T) || __cplusplus >= 199711L 37*0Sstevel@tonic-gate #define _TIME_T 38*0Sstevel@tonic-gate typedef long time_t; /* time of day in seconds */ 39*0Sstevel@tonic-gate #endif /* _TIME_T */ 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate #ifndef _SUSECONDS_T 42*0Sstevel@tonic-gate #define _SUSECONDS_T 43*0Sstevel@tonic-gate typedef long suseconds_t; /* signed # of microseconds */ 44*0Sstevel@tonic-gate #endif /* _SUSECONDS_T */ 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate struct timeval { 47*0Sstevel@tonic-gate time_t tv_sec; /* seconds */ 48*0Sstevel@tonic-gate suseconds_t tv_usec; /* and microseconds */ 49*0Sstevel@tonic-gate }; 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #if defined(_SYSCALL32) 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate #include <sys/types32.h> 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #define TIMEVAL32_TO_TIMEVAL(tv, tv32) { \ 56*0Sstevel@tonic-gate (tv)->tv_sec = (time_t)(tv32)->tv_sec; \ 57*0Sstevel@tonic-gate (tv)->tv_usec = (tv32)->tv_usec; \ 58*0Sstevel@tonic-gate } 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate #define TIMEVAL_TO_TIMEVAL32(tv32, tv) { \ 61*0Sstevel@tonic-gate (tv32)->tv_sec = (time32_t)(tv)->tv_sec; \ 62*0Sstevel@tonic-gate (tv32)->tv_usec = (tv)->tv_usec; \ 63*0Sstevel@tonic-gate } 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate #define TIME32_MAX INT32_MAX 66*0Sstevel@tonic-gate #define TIME32_MIN INT32_MIN 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate #define TIMEVAL_OVERFLOW(tv) \ 69*0Sstevel@tonic-gate ((tv)->tv_sec < TIME32_MIN || (tv)->tv_sec > TIME32_MAX) 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate #endif /* _SYSCALL32 || _KERNEL */ 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate #endif /* _ASM */ 74*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 77*0Sstevel@tonic-gate #ifndef _ASM 78*0Sstevel@tonic-gate struct timezone { 79*0Sstevel@tonic-gate int tz_minuteswest; /* minutes west of Greenwich */ 80*0Sstevel@tonic-gate int tz_dsttime; /* type of dst correction */ 81*0Sstevel@tonic-gate }; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate #endif /* _ASM */ 84*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate #ifdef __cplusplus 87*0Sstevel@tonic-gate } 88*0Sstevel@tonic-gate #endif 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate /* 91*0Sstevel@tonic-gate * Needed for longlong_t type. Placement of this due to <sys/types.h> 92*0Sstevel@tonic-gate * including <sys/select.h> which relies on the presense of the itimerval 93*0Sstevel@tonic-gate * structure. 94*0Sstevel@tonic-gate */ 95*0Sstevel@tonic-gate #ifndef _ASM 96*0Sstevel@tonic-gate #include <sys/types.h> 97*0Sstevel@tonic-gate #endif /* _ASM */ 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate #ifdef __cplusplus 100*0Sstevel@tonic-gate extern "C" { 101*0Sstevel@tonic-gate #endif 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate #define DST_NONE 0 /* not on dst */ 106*0Sstevel@tonic-gate #define DST_USA 1 /* USA style dst */ 107*0Sstevel@tonic-gate #define DST_AUST 2 /* Australian style dst */ 108*0Sstevel@tonic-gate #define DST_WET 3 /* Western European dst */ 109*0Sstevel@tonic-gate #define DST_MET 4 /* Middle European dst */ 110*0Sstevel@tonic-gate #define DST_EET 5 /* Eastern European dst */ 111*0Sstevel@tonic-gate #define DST_CAN 6 /* Canada */ 112*0Sstevel@tonic-gate #define DST_GB 7 /* Great Britain and Eire */ 113*0Sstevel@tonic-gate #define DST_RUM 8 /* Rumania */ 114*0Sstevel@tonic-gate #define DST_TUR 9 /* Turkey */ 115*0Sstevel@tonic-gate #define DST_AUSTALT 10 /* Australian style with shift in 1986 */ 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate /* 118*0Sstevel@tonic-gate * Operations on timevals. 119*0Sstevel@tonic-gate */ 120*0Sstevel@tonic-gate #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 121*0Sstevel@tonic-gate #define timercmp(tvp, uvp, cmp) \ 122*0Sstevel@tonic-gate (((tvp)->tv_sec == (uvp)->tv_sec) ? \ 123*0Sstevel@tonic-gate /* CSTYLED */ \ 124*0Sstevel@tonic-gate ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ 125*0Sstevel@tonic-gate /* CSTYLED */ \ 126*0Sstevel@tonic-gate ((tvp)->tv_sec cmp (uvp)->tv_sec)) 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 133*0Sstevel@tonic-gate /* 134*0Sstevel@tonic-gate * Names of the interval timers, and structure 135*0Sstevel@tonic-gate * defining a timer setting. 136*0Sstevel@tonic-gate */ 137*0Sstevel@tonic-gate #define ITIMER_REAL 0 /* Decrements in real time */ 138*0Sstevel@tonic-gate #define ITIMER_VIRTUAL 1 /* Decrements in process virtual time */ 139*0Sstevel@tonic-gate #define ITIMER_PROF 2 /* Decrements both in process virtual */ 140*0Sstevel@tonic-gate /* time and when system is running on */ 141*0Sstevel@tonic-gate /* behalf of the process. */ 142*0Sstevel@tonic-gate #define ITIMER_REALPROF 3 /* Decrements in real time for real- */ 143*0Sstevel@tonic-gate /* time profiling of multithreaded */ 144*0Sstevel@tonic-gate /* programs. */ 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate #ifndef _ASM 147*0Sstevel@tonic-gate struct itimerval { 148*0Sstevel@tonic-gate struct timeval it_interval; /* timer interval */ 149*0Sstevel@tonic-gate struct timeval it_value; /* current value */ 150*0Sstevel@tonic-gate }; 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate #if defined(_SYSCALL32) 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate struct itimerval32 { 155*0Sstevel@tonic-gate struct timeval32 it_interval; 156*0Sstevel@tonic-gate struct timeval32 it_value; 157*0Sstevel@tonic-gate }; 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate #define ITIMERVAL32_TO_ITIMERVAL(itv, itv32) { \ 160*0Sstevel@tonic-gate TIMEVAL32_TO_TIMEVAL(&(itv)->it_interval, &(itv32)->it_interval); \ 161*0Sstevel@tonic-gate TIMEVAL32_TO_TIMEVAL(&(itv)->it_value, &(itv32)->it_value); \ 162*0Sstevel@tonic-gate } 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate #define ITIMERVAL_TO_ITIMERVAL32(itv32, itv) { \ 165*0Sstevel@tonic-gate TIMEVAL_TO_TIMEVAL32(&(itv32)->it_interval, &(itv)->it_interval); \ 166*0Sstevel@tonic-gate TIMEVAL_TO_TIMEVAL32(&(itv32)->it_value, &(itv)->it_value); \ 167*0Sstevel@tonic-gate } 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate #define ITIMERVAL_OVERFLOW(itv) \ 170*0Sstevel@tonic-gate (TIMEVAL_OVERFLOW(&(itv)->it_interval) || \ 171*0Sstevel@tonic-gate TIMEVAL_OVERFLOW(&(itv)->it_value)) 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate #endif /* _SYSCALL32 */ 174*0Sstevel@tonic-gate #endif /* _ASM */ 175*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */ 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 179*0Sstevel@tonic-gate /* 180*0Sstevel@tonic-gate * Definitions for commonly used resolutions. 181*0Sstevel@tonic-gate */ 182*0Sstevel@tonic-gate #define SEC 1 183*0Sstevel@tonic-gate #define MILLISEC 1000 184*0Sstevel@tonic-gate #define MICROSEC 1000000 185*0Sstevel@tonic-gate #define NANOSEC 1000000000 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate #ifndef _ASM 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate /* 192*0Sstevel@tonic-gate * Time expressed as a 64-bit nanosecond counter. 193*0Sstevel@tonic-gate */ 194*0Sstevel@tonic-gate typedef longlong_t hrtime_t; 195*0Sstevel@tonic-gate 196*0Sstevel@tonic-gate #ifdef _KERNEL 197*0Sstevel@tonic-gate 198*0Sstevel@tonic-gate #include <sys/time_impl.h> 199*0Sstevel@tonic-gate #include <sys/mutex.h> 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate extern int tick_per_msec; /* clock ticks per millisecond (may be zero) */ 202*0Sstevel@tonic-gate extern int msec_per_tick; /* milliseconds per clock tick (may be zero) */ 203*0Sstevel@tonic-gate extern int usec_per_tick; /* microseconds per clock tick */ 204*0Sstevel@tonic-gate extern int nsec_per_tick; /* nanoseconds per clock tick */ 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate /* 207*0Sstevel@tonic-gate * Macros to convert from common units of time (sec, msec, usec, nsec, 208*0Sstevel@tonic-gate * timeval, timestruc) to clock ticks and vice versa. 209*0Sstevel@tonic-gate */ 210*0Sstevel@tonic-gate #define TICK_TO_SEC(tick) ((tick) / hz) 211*0Sstevel@tonic-gate #define SEC_TO_TICK(sec) ((sec) * hz) 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate #define TICK_TO_MSEC(tick) \ 214*0Sstevel@tonic-gate (msec_per_tick ? (tick) * msec_per_tick : (tick) / tick_per_msec) 215*0Sstevel@tonic-gate #define MSEC_TO_TICK(msec) \ 216*0Sstevel@tonic-gate (msec_per_tick ? (msec) / msec_per_tick : (msec) * tick_per_msec) 217*0Sstevel@tonic-gate #define MSEC_TO_TICK_ROUNDUP(msec) \ 218*0Sstevel@tonic-gate (msec_per_tick ? \ 219*0Sstevel@tonic-gate ((msec) == 0 ? 0 : ((msec) - 1) / msec_per_tick + 1) : \ 220*0Sstevel@tonic-gate (msec) * tick_per_msec) 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate #define TICK_TO_USEC(tick) ((tick) * usec_per_tick) 223*0Sstevel@tonic-gate #define USEC_TO_TICK(usec) ((usec) / usec_per_tick) 224*0Sstevel@tonic-gate #define USEC_TO_TICK_ROUNDUP(usec) \ 225*0Sstevel@tonic-gate ((usec) == 0 ? 0 : USEC_TO_TICK((usec) - 1) + 1) 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate #define TICK_TO_NSEC(tick) ((tick) * nsec_per_tick) 228*0Sstevel@tonic-gate #define NSEC_TO_TICK(nsec) ((nsec) / nsec_per_tick) 229*0Sstevel@tonic-gate #define NSEC_TO_TICK_ROUNDUP(nsec) \ 230*0Sstevel@tonic-gate ((nsec) == 0 ? 0 : NSEC_TO_TICK((nsec) - 1) + 1) 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate #define TICK_TO_TIMEVAL(tick, tvp) { \ 233*0Sstevel@tonic-gate clock_t __tmptck = (tick); \ 234*0Sstevel@tonic-gate (tvp)->tv_sec = TICK_TO_SEC(__tmptck); \ 235*0Sstevel@tonic-gate (tvp)->tv_usec = TICK_TO_USEC(__tmptck - SEC_TO_TICK((tvp)->tv_sec)); \ 236*0Sstevel@tonic-gate } 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gate #define TICK_TO_TIMEVAL32(tick, tvp) { \ 239*0Sstevel@tonic-gate clock_t __tmptck = (tick); \ 240*0Sstevel@tonic-gate time_t __tmptm = TICK_TO_SEC(__tmptck); \ 241*0Sstevel@tonic-gate (tvp)->tv_sec = (time32_t)__tmptm; \ 242*0Sstevel@tonic-gate (tvp)->tv_usec = TICK_TO_USEC(__tmptck - SEC_TO_TICK(__tmptm)); \ 243*0Sstevel@tonic-gate } 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate #define TICK_TO_TIMESTRUC(tick, tsp) { \ 246*0Sstevel@tonic-gate clock_t __tmptck = (tick); \ 247*0Sstevel@tonic-gate (tsp)->tv_sec = TICK_TO_SEC(__tmptck); \ 248*0Sstevel@tonic-gate (tsp)->tv_nsec = TICK_TO_NSEC(__tmptck - SEC_TO_TICK((tsp)->tv_sec)); \ 249*0Sstevel@tonic-gate } 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate #define TICK_TO_TIMESTRUC32(tick, tsp) { \ 252*0Sstevel@tonic-gate clock_t __tmptck = (tick); \ 253*0Sstevel@tonic-gate time_t __tmptm = TICK_TO_SEC(__tmptck); \ 254*0Sstevel@tonic-gate (tsp)->tv_sec = (time32_t)__tmptm; \ 255*0Sstevel@tonic-gate (tsp)->tv_nsec = TICK_TO_NSEC(__tmptck - SEC_TO_TICK(__tmptm)); \ 256*0Sstevel@tonic-gate } 257*0Sstevel@tonic-gate 258*0Sstevel@tonic-gate #define TIMEVAL_TO_TICK(tvp) \ 259*0Sstevel@tonic-gate (SEC_TO_TICK((tvp)->tv_sec) + USEC_TO_TICK((tvp)->tv_usec)) 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gate #define TIMESTRUC_TO_TICK(tsp) \ 262*0Sstevel@tonic-gate (SEC_TO_TICK((tsp)->tv_sec) + NSEC_TO_TICK((tsp)->tv_nsec)) 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate typedef struct todinfo { 265*0Sstevel@tonic-gate int tod_sec; /* seconds 0-59 */ 266*0Sstevel@tonic-gate int tod_min; /* minutes 0-59 */ 267*0Sstevel@tonic-gate int tod_hour; /* hours 0-23 */ 268*0Sstevel@tonic-gate int tod_dow; /* day of week 1-7 */ 269*0Sstevel@tonic-gate int tod_day; /* day of month 1-31 */ 270*0Sstevel@tonic-gate int tod_month; /* month 1-12 */ 271*0Sstevel@tonic-gate int tod_year; /* year 70+ */ 272*0Sstevel@tonic-gate } todinfo_t; 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gate extern int64_t timedelta; 275*0Sstevel@tonic-gate extern int timechanged; 276*0Sstevel@tonic-gate extern int tod_needsync; 277*0Sstevel@tonic-gate extern kmutex_t tod_lock; 278*0Sstevel@tonic-gate extern timestruc_t hrestime; 279*0Sstevel@tonic-gate extern hrtime_t hres_last_tick; 280*0Sstevel@tonic-gate extern int64_t hrestime_adj; 281*0Sstevel@tonic-gate extern uint_t adj_shift; 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate extern timestruc_t tod_get(void); 284*0Sstevel@tonic-gate extern void tod_set(timestruc_t); 285*0Sstevel@tonic-gate extern void set_hrestime(timestruc_t *); 286*0Sstevel@tonic-gate extern todinfo_t utc_to_tod(time_t); 287*0Sstevel@tonic-gate extern time_t tod_to_utc(todinfo_t); 288*0Sstevel@tonic-gate extern int hr_clock_lock(void); 289*0Sstevel@tonic-gate extern void hr_clock_unlock(int); 290*0Sstevel@tonic-gate extern hrtime_t gethrtime(void); 291*0Sstevel@tonic-gate extern hrtime_t gethrtime_unscaled(void); 292*0Sstevel@tonic-gate extern hrtime_t gethrtime_max(void); 293*0Sstevel@tonic-gate extern hrtime_t gethrtime_waitfree(void); 294*0Sstevel@tonic-gate extern void scalehrtime(hrtime_t *); 295*0Sstevel@tonic-gate extern uint64_t unscalehrtime(hrtime_t); 296*0Sstevel@tonic-gate extern void gethrestime(timespec_t *); 297*0Sstevel@tonic-gate extern time_t gethrestime_sec(void); 298*0Sstevel@tonic-gate extern void gethrestime_lasttick(timespec_t *); 299*0Sstevel@tonic-gate extern void hrt2ts(hrtime_t, timestruc_t *); 300*0Sstevel@tonic-gate extern hrtime_t ts2hrt(const timestruc_t *); 301*0Sstevel@tonic-gate extern void hrt2tv(hrtime_t, struct timeval *); 302*0Sstevel@tonic-gate extern hrtime_t tv2hrt(struct timeval *); 303*0Sstevel@tonic-gate extern int itimerfix(struct timeval *, int); 304*0Sstevel@tonic-gate extern int itimerdecr(struct itimerval *, int); 305*0Sstevel@tonic-gate extern void timevaladd(struct timeval *, struct timeval *); 306*0Sstevel@tonic-gate extern void timevalsub(struct timeval *, struct timeval *); 307*0Sstevel@tonic-gate extern void timevalfix(struct timeval *); 308*0Sstevel@tonic-gate extern void dtrace_hres_tick(void); 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate #if defined(_SYSCALL32) 311*0Sstevel@tonic-gate extern void hrt2ts32(hrtime_t, timestruc32_t *); 312*0Sstevel@tonic-gate #endif 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate #endif /* _KERNEL */ 315*0Sstevel@tonic-gate 316*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 317*0Sstevel@tonic-gate #if defined(__STDC__) 318*0Sstevel@tonic-gate int adjtime(struct timeval *, struct timeval *); 319*0Sstevel@tonic-gate #else 320*0Sstevel@tonic-gate int adjtime(); 321*0Sstevel@tonic-gate #endif 322*0Sstevel@tonic-gate #endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */ 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || \ 325*0Sstevel@tonic-gate defined(_ATFILE_SOURCE) || defined(__EXTENSIONS__) 326*0Sstevel@tonic-gate #if defined(__STDC__) 327*0Sstevel@tonic-gate int futimesat(int, const char *, const struct timeval *); 328*0Sstevel@tonic-gate #else 329*0Sstevel@tonic-gate int futimesat(); 330*0Sstevel@tonic-gate #endif /* defined(__STDC__) */ 331*0Sstevel@tonic-gate #endif /* defined(__ATFILE_SOURCE) */ 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ 334*0Sstevel@tonic-gate defined(__EXTENSIONS__) 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gate #if defined(__STDC__) 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate int getitimer(int, struct itimerval *); 339*0Sstevel@tonic-gate int utimes(const char *, const struct timeval *); 340*0Sstevel@tonic-gate #if defined(_XPG4_2) 341*0Sstevel@tonic-gate int setitimer(int, const struct itimerval *_RESTRICT_KYWD, 342*0Sstevel@tonic-gate struct itimerval *_RESTRICT_KYWD); 343*0Sstevel@tonic-gate #else 344*0Sstevel@tonic-gate int setitimer(int, struct itimerval *_RESTRICT_KYWD, 345*0Sstevel@tonic-gate struct itimerval *_RESTRICT_KYWD); 346*0Sstevel@tonic-gate #endif /* defined(_XPG2_2) */ 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate #else /* __STDC__ */ 349*0Sstevel@tonic-gate 350*0Sstevel@tonic-gate int gettimer(); 351*0Sstevel@tonic-gate int settimer(); 352*0Sstevel@tonic-gate int utimes(); 353*0Sstevel@tonic-gate #endif /* __STDC__ */ 354*0Sstevel@tonic-gate #endif /* !defined(_KERNEL) ... defined(_XPG4_2) */ 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate /* 357*0Sstevel@tonic-gate * gettimeofday() and settimeofday() were included in SVr4 due to their 358*0Sstevel@tonic-gate * common use in BSD based applications. They were to be included exactly 359*0Sstevel@tonic-gate * as in BSD, with two parameters. However, AT&T/USL noted that the second 360*0Sstevel@tonic-gate * parameter was unused and deleted it, thereby making a routine included 361*0Sstevel@tonic-gate * for compatibility, incompatible. 362*0Sstevel@tonic-gate * 363*0Sstevel@tonic-gate * XSH4.2 (spec 1170) defines gettimeofday and settimeofday to have two 364*0Sstevel@tonic-gate * parameters. 365*0Sstevel@tonic-gate * 366*0Sstevel@tonic-gate * This has caused general disagreement in the application community as to 367*0Sstevel@tonic-gate * the syntax of these routines. Solaris defaults to the XSH4.2 definition. 368*0Sstevel@tonic-gate * The flag _SVID_GETTOD may be used to force the SVID version. 369*0Sstevel@tonic-gate */ 370*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate #if defined(__STDC__) 373*0Sstevel@tonic-gate #if defined(_SVID_GETTOD) 374*0Sstevel@tonic-gate int settimeofday(struct timeval *); 375*0Sstevel@tonic-gate #else 376*0Sstevel@tonic-gate int settimeofday(struct timeval *, void *); 377*0Sstevel@tonic-gate #endif 378*0Sstevel@tonic-gate hrtime_t gethrtime(void); 379*0Sstevel@tonic-gate hrtime_t gethrvtime(void); 380*0Sstevel@tonic-gate #else /* __STDC__ */ 381*0Sstevel@tonic-gate int settimeofday(); 382*0Sstevel@tonic-gate hrtime_t gethrtime(); 383*0Sstevel@tonic-gate hrtime_t gethrvtime(); 384*0Sstevel@tonic-gate #endif /* __STDC__ */ 385*0Sstevel@tonic-gate 386*0Sstevel@tonic-gate #endif /* !(defined _KERNEL) && !defined(__XOPEN_OR_POSIX) ... */ 387*0Sstevel@tonic-gate 388*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ 389*0Sstevel@tonic-gate defined(__EXTENSIONS__) 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gate #if defined(__STDC__) 392*0Sstevel@tonic-gate #if defined(_SVID_GETTOD) 393*0Sstevel@tonic-gate int gettimeofday(struct timeval *); 394*0Sstevel@tonic-gate #else 395*0Sstevel@tonic-gate int gettimeofday(struct timeval *_RESTRICT_KYWD, void *_RESTRICT_KYWD); 396*0Sstevel@tonic-gate #endif 397*0Sstevel@tonic-gate #else /* __STDC__ */ 398*0Sstevel@tonic-gate int gettimeofday(); 399*0Sstevel@tonic-gate #endif /* __STDC__ */ 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gate #endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */ 402*0Sstevel@tonic-gate 403*0Sstevel@tonic-gate /* 404*0Sstevel@tonic-gate * The inclusion of <time.h> is historical and was added for 405*0Sstevel@tonic-gate * backward compatibility in delta 1.2 when a number of definitions 406*0Sstevel@tonic-gate * were moved out of <sys/time.h>. More recently, the timespec and 407*0Sstevel@tonic-gate * itimerspec structure definitions, along with the _CLOCK_*, CLOCK_*, 408*0Sstevel@tonic-gate * _TIMER_*, and TIMER_* symbols were moved to <sys/time_impl.h>, 409*0Sstevel@tonic-gate * which is now included by <time.h>. This change was due to POSIX 410*0Sstevel@tonic-gate * 1003.1b-1993 and X/Open UNIX 98 requirements. For non-POSIX and 411*0Sstevel@tonic-gate * non-X/Open applications, including this header will still make 412*0Sstevel@tonic-gate * visible these definitions. 413*0Sstevel@tonic-gate */ 414*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 415*0Sstevel@tonic-gate #include <time.h> 416*0Sstevel@tonic-gate #endif 417*0Sstevel@tonic-gate 418*0Sstevel@tonic-gate /* 419*0Sstevel@tonic-gate * The inclusion of <sys/select.h> is needed for the FD_CLR, 420*0Sstevel@tonic-gate * FD_ISSET, FD_SET, and FD_SETSIZE macros as well as the 421*0Sstevel@tonic-gate * select() prototype defined in the XOpen specifications 422*0Sstevel@tonic-gate * beginning with XSH4v2. Placement required after definition 423*0Sstevel@tonic-gate * for itimerval. 424*0Sstevel@tonic-gate */ 425*0Sstevel@tonic-gate #if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ 426*0Sstevel@tonic-gate defined(__EXTENSIONS__) 427*0Sstevel@tonic-gate #include <sys/select.h> 428*0Sstevel@tonic-gate #endif 429*0Sstevel@tonic-gate 430*0Sstevel@tonic-gate #endif /* _ASM */ 431*0Sstevel@tonic-gate 432*0Sstevel@tonic-gate #ifdef __cplusplus 433*0Sstevel@tonic-gate } 434*0Sstevel@tonic-gate #endif 435*0Sstevel@tonic-gate 436*0Sstevel@tonic-gate #endif /* _SYS_TIME_H */ 437