1139825Simp/*- 21541Srgrimes * Copyright (c) 1982, 1986, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 2914487Shsu * @(#)time.h 8.5 (Berkeley) 5/4/95 3050477Speter * $FreeBSD$ 311541Srgrimes */ 321541Srgrimes 331541Srgrimes#ifndef _SYS_TIME_H_ 34239973Sed#define _SYS_TIME_H_ 351541Srgrimes 36108477Smike#include <sys/_timeval.h> 3714487Shsu#include <sys/types.h> 3898270Swollman#include <sys/timespec.h> 3914487Shsu 401541Srgrimesstruct timezone { 411541Srgrimes int tz_minuteswest; /* minutes west of Greenwich */ 421541Srgrimes int tz_dsttime; /* type of dst correction */ 431541Srgrimes}; 441541Srgrimes#define DST_NONE 0 /* not on dst */ 451541Srgrimes#define DST_USA 1 /* USA style dst */ 461541Srgrimes#define DST_AUST 2 /* Australian style dst */ 471541Srgrimes#define DST_WET 3 /* Western European dst */ 481541Srgrimes#define DST_MET 4 /* Middle European dst */ 491541Srgrimes#define DST_EET 5 /* Eastern European dst */ 501541Srgrimes#define DST_CAN 6 /* Canada */ 511541Srgrimes 5298270Swollman#if __BSD_VISIBLE 5390362Sphkstruct bintime { 5495817Sphk time_t sec; 5595817Sphk uint64_t frac; 5690362Sphk}; 5790362Sphk 5890362Sphkstatic __inline void 59255135Sdavidebintime_addx(struct bintime *_bt, uint64_t _x) 6090362Sphk{ 61255135Sdavide uint64_t _u; 6290362Sphk 63255135Sdavide _u = _bt->frac; 64255135Sdavide _bt->frac += _x; 65255135Sdavide if (_u > _bt->frac) 66255135Sdavide _bt->sec++; 6790362Sphk} 6890362Sphk 6990362Sphkstatic __inline void 70255135Sdavidebintime_add(struct bintime *_bt, const struct bintime *_bt2) 7190362Sphk{ 72255135Sdavide uint64_t _u; 7390362Sphk 74255135Sdavide _u = _bt->frac; 75255135Sdavide _bt->frac += _bt2->frac; 76255135Sdavide if (_u > _bt->frac) 77255135Sdavide _bt->sec++; 78255135Sdavide _bt->sec += _bt2->sec; 7990362Sphk} 8090362Sphk 8190362Sphkstatic __inline void 82255135Sdavidebintime_sub(struct bintime *_bt, const struct bintime *_bt2) 8390362Sphk{ 84255135Sdavide uint64_t _u; 8590362Sphk 86255135Sdavide _u = _bt->frac; 87255135Sdavide _bt->frac -= _bt2->frac; 88255135Sdavide if (_u < _bt->frac) 89255135Sdavide _bt->sec--; 90255135Sdavide _bt->sec -= _bt2->sec; 9190362Sphk} 9290362Sphk 93212336Smavstatic __inline void 94255135Sdavidebintime_mul(struct bintime *_bt, u_int _x) 95212336Smav{ 96255135Sdavide uint64_t _p1, _p2; 97212336Smav 98255135Sdavide _p1 = (_bt->frac & 0xffffffffull) * _x; 99255135Sdavide _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32); 100255135Sdavide _bt->sec *= _x; 101255135Sdavide _bt->sec += (_p2 >> 32); 102255135Sdavide _bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull); 103212336Smav} 104212336Smav 105247777Sdavidestatic __inline void 106255135Sdavidebintime_shift(struct bintime *_bt, int _exp) 107247777Sdavide{ 108247777Sdavide 109255135Sdavide if (_exp > 0) { 110255135Sdavide _bt->sec <<= _exp; 111255135Sdavide _bt->sec |= _bt->frac >> (64 - _exp); 112255135Sdavide _bt->frac <<= _exp; 113255135Sdavide } else if (_exp < 0) { 114255135Sdavide _bt->frac >>= -_exp; 115255135Sdavide _bt->frac |= (uint64_t)_bt->sec << (64 + _exp); 116255135Sdavide _bt->sec >>= -_exp; 117247777Sdavide } 118247777Sdavide} 119247777Sdavide 120212336Smav#define bintime_clear(a) ((a)->sec = (a)->frac = 0) 121212336Smav#define bintime_isset(a) ((a)->sec || (a)->frac) 122212336Smav#define bintime_cmp(a, b, cmp) \ 123212336Smav (((a)->sec == (b)->sec) ? \ 124212336Smav ((a)->frac cmp (b)->frac) : \ 125212336Smav ((a)->sec cmp (b)->sec)) 126212336Smav 127247452Smav#define SBT_1S ((sbintime_t)1 << 32) 128247452Smav#define SBT_1M (SBT_1S * 60) 129247452Smav#define SBT_1MS (SBT_1S / 1000) 130247452Smav#define SBT_1US (SBT_1S / 1000000) 131247673Smav#define SBT_1NS (SBT_1S / 1000000000) 132270240Sdavide#define SBT_MAX 0x7fffffffffffffff 133247452Smav 134247452Smavstatic __inline int 135255135Sdavidesbintime_getsec(sbintime_t _sbt) 136247452Smav{ 137247452Smav 138255135Sdavide return (_sbt >> 32); 139247452Smav} 140247452Smav 141247452Smavstatic __inline sbintime_t 142255135Sdavidebttosbt(const struct bintime _bt) 143247452Smav{ 144247452Smav 145255135Sdavide return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32)); 146247452Smav} 147247452Smav 148247452Smavstatic __inline struct bintime 149255135Sdavidesbttobt(sbintime_t _sbt) 150247452Smav{ 151255135Sdavide struct bintime _bt; 152247673Smav 153255135Sdavide _bt.sec = _sbt >> 32; 154255135Sdavide _bt.frac = _sbt << 32; 155255135Sdavide return (_bt); 156247452Smav} 157247452Smav 158210226Strasz/*- 15992769Sphk * Background information: 16092769Sphk * 16192769Sphk * When converting between timestamps on parallel timescales of differing 16292769Sphk * resolutions it is historical and scientific practice to round down rather 16392769Sphk * than doing 4/5 rounding. 16492769Sphk * 16592769Sphk * The date changes at midnight, not at noon. 16692769Sphk * 16792769Sphk * Even at 15:59:59.999999999 it's not four'o'clock. 16892769Sphk * 16992769Sphk * time_second ticks after N.999999999 not after N.4999999999 17092769Sphk */ 17192769Sphk 17290362Sphkstatic __inline void 173255135Sdavidebintime2timespec(const struct bintime *_bt, struct timespec *_ts) 17490362Sphk{ 17590362Sphk 176255135Sdavide _ts->tv_sec = _bt->sec; 177255135Sdavide _ts->tv_nsec = ((uint64_t)1000000000 * 178255135Sdavide (uint32_t)(_bt->frac >> 32)) >> 32; 17990362Sphk} 18090362Sphk 18190362Sphkstatic __inline void 182255135Sdavidetimespec2bintime(const struct timespec *_ts, struct bintime *_bt) 18390362Sphk{ 18490362Sphk 185255135Sdavide _bt->sec = _ts->tv_sec; 18692769Sphk /* 18446744073 = int(2^64 / 1000000000) */ 187255135Sdavide _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; 18890362Sphk} 18990362Sphk 19090362Sphkstatic __inline void 191255135Sdavidebintime2timeval(const struct bintime *_bt, struct timeval *_tv) 19290362Sphk{ 19390362Sphk 194255135Sdavide _tv->tv_sec = _bt->sec; 195255135Sdavide _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32; 19690362Sphk} 19790362Sphk 19890362Sphkstatic __inline void 199255135Sdavidetimeval2bintime(const struct timeval *_tv, struct bintime *_bt) 20090362Sphk{ 20190362Sphk 202255135Sdavide _bt->sec = _tv->tv_sec; 20392769Sphk /* 18446744073709 = int(2^64 / 1000000) */ 204255135Sdavide _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL; 20590362Sphk} 206247452Smav 207247452Smavstatic __inline struct timespec 208255135Sdavidesbttots(sbintime_t _sbt) 209247452Smav{ 210255135Sdavide struct timespec _ts; 211247452Smav 212255135Sdavide _ts.tv_sec = _sbt >> 32; 213255135Sdavide _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32; 214255135Sdavide return (_ts); 215247452Smav} 216247452Smav 217247452Smavstatic __inline sbintime_t 218255135Sdavidetstosbt(struct timespec _ts) 219247452Smav{ 220247452Smav 221255135Sdavide return (((sbintime_t)_ts.tv_sec << 32) + 222255135Sdavide (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32)); 223247452Smav} 224247452Smav 225247452Smavstatic __inline struct timeval 226255135Sdavidesbttotv(sbintime_t _sbt) 227247452Smav{ 228255135Sdavide struct timeval _tv; 229247452Smav 230255135Sdavide _tv.tv_sec = _sbt >> 32; 231255135Sdavide _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32; 232255135Sdavide return (_tv); 233247452Smav} 234247452Smav 235247452Smavstatic __inline sbintime_t 236255135Sdavidetvtosbt(struct timeval _tv) 237247452Smav{ 238247452Smav 239255135Sdavide return (((sbintime_t)_tv.tv_sec << 32) + 240255135Sdavide (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32)); 241247452Smav} 242247338Sdelphij#endif /* __BSD_VISIBLE */ 24390362Sphk 244247338Sdelphij#ifdef _KERNEL 245247338Sdelphij 24635029Sphk/* Operations on timespecs */ 24735401Seivind#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) 24835029Sphk#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) 24935029Sphk#define timespeccmp(tvp, uvp, cmp) \ 25035029Sphk (((tvp)->tv_sec == (uvp)->tv_sec) ? \ 25135029Sphk ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ 25235029Sphk ((tvp)->tv_sec cmp (uvp)->tv_sec)) 253239973Sed#define timespecadd(vvp, uvp) \ 25435029Sphk do { \ 25535058Sphk (vvp)->tv_sec += (uvp)->tv_sec; \ 25635058Sphk (vvp)->tv_nsec += (uvp)->tv_nsec; \ 25735029Sphk if ((vvp)->tv_nsec >= 1000000000) { \ 25835029Sphk (vvp)->tv_sec++; \ 25935029Sphk (vvp)->tv_nsec -= 1000000000; \ 26035029Sphk } \ 26135029Sphk } while (0) 262239973Sed#define timespecsub(vvp, uvp) \ 26335029Sphk do { \ 26435058Sphk (vvp)->tv_sec -= (uvp)->tv_sec; \ 26535058Sphk (vvp)->tv_nsec -= (uvp)->tv_nsec; \ 26635029Sphk if ((vvp)->tv_nsec < 0) { \ 26735029Sphk (vvp)->tv_sec--; \ 26835029Sphk (vvp)->tv_nsec += 1000000000; \ 26935029Sphk } \ 27035029Sphk } while (0) 27135058Sphk 2721541Srgrimes/* Operations on timevals. */ 27335058Sphk 27474574Smarkm#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) 27535058Sphk#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 27635029Sphk#define timevalcmp(tvp, uvp, cmp) \ 27735029Sphk (((tvp)->tv_sec == (uvp)->tv_sec) ? \ 27835029Sphk ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ 27935029Sphk ((tvp)->tv_sec cmp (uvp)->tv_sec)) 28035058Sphk 28135058Sphk/* timevaladd and timevalsub are not inlined */ 28235058Sphk 283247338Sdelphij#endif /* _KERNEL */ 28435029Sphk 28572093Sasmodai#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */ 28635058Sphk 28774574Smarkm#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) 2881541Srgrimes#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 28935058Sphk#define timercmp(tvp, uvp, cmp) \ 2901541Srgrimes (((tvp)->tv_sec == (uvp)->tv_sec) ? \ 2911541Srgrimes ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ 2921541Srgrimes ((tvp)->tv_sec cmp (uvp)->tv_sec)) 293239973Sed#define timeradd(tvp, uvp, vvp) \ 29421099Speter do { \ 29521099Speter (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ 29621099Speter (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ 29721099Speter if ((vvp)->tv_usec >= 1000000) { \ 29821099Speter (vvp)->tv_sec++; \ 29921099Speter (vvp)->tv_usec -= 1000000; \ 30021099Speter } \ 30121099Speter } while (0) 302239973Sed#define timersub(tvp, uvp, vvp) \ 30321099Speter do { \ 30421099Speter (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ 30521099Speter (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ 30621099Speter if ((vvp)->tv_usec < 0) { \ 30721099Speter (vvp)->tv_sec--; \ 30821099Speter (vvp)->tv_usec += 1000000; \ 30921099Speter } \ 31021099Speter } while (0) 31121099Speter#endif 3121541Srgrimes 3131541Srgrimes/* 3141541Srgrimes * Names of the interval timers, and structure 3151541Srgrimes * defining a timer setting. 3161541Srgrimes */ 3171541Srgrimes#define ITIMER_REAL 0 3181541Srgrimes#define ITIMER_VIRTUAL 1 3191541Srgrimes#define ITIMER_PROF 2 3201541Srgrimes 32183045Sobrienstruct itimerval { 3221541Srgrimes struct timeval it_interval; /* timer interval */ 3231541Srgrimes struct timeval it_value; /* current value */ 3241541Srgrimes}; 3251541Srgrimes 3261541Srgrimes/* 3271541Srgrimes * Getkerninfo clock information structure 3281541Srgrimes */ 3291541Srgrimesstruct clockinfo { 3301541Srgrimes int hz; /* clock frequency */ 3311541Srgrimes int tick; /* micro-seconds per hz tick */ 33296052Sbde int spare; 3331541Srgrimes int stathz; /* statistics clock frequency */ 3341541Srgrimes int profhz; /* profiling clock frequency */ 3351541Srgrimes}; 3361541Srgrimes 337144529Sdas/* These macros are also in time.h. */ 33834030Sdufault#ifndef CLOCK_REALTIME 339239973Sed#define CLOCK_REALTIME 0 340239973Sed#define CLOCK_VIRTUAL 1 341239973Sed#define CLOCK_PROF 2 342239973Sed#define CLOCK_MONOTONIC 4 343239973Sed#define CLOCK_UPTIME 5 /* FreeBSD-specific. */ 344239973Sed#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ 345239973Sed#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ 346239973Sed#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ 347239973Sed#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ 348239973Sed#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ 349239973Sed#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ 350239973Sed#define CLOCK_SECOND 13 /* FreeBSD-specific. */ 351239973Sed#define CLOCK_THREAD_CPUTIME_ID 14 352239973Sed#define CLOCK_PROCESS_CPUTIME_ID 15 353144529Sdas#endif 35425578Speter 355144529Sdas#ifndef TIMER_ABSTIME 356239973Sed#define TIMER_RELTIME 0x0 /* relative timer */ 357239973Sed#define TIMER_ABSTIME 0x1 /* absolute timer */ 35834030Sdufault#endif 35925578Speter 360239347Sdavidxu#if __BSD_VISIBLE 361239347Sdavidxu#define CPUCLOCK_WHICH_PID 0 362239347Sdavidxu#define CPUCLOCK_WHICH_TID 1 363239347Sdavidxu#endif 364239347Sdavidxu 36555205Speter#ifdef _KERNEL 366178429Sphk 367178429Sphk/* 368178429Sphk * Kernel to clock driver interface. 369178429Sphk */ 370178429Sphkvoid inittodr(time_t base); 371178429Sphkvoid resettodr(void); 372178429Sphk 373246037Sjhbextern volatile time_t time_second; 374246037Sjhbextern volatile time_t time_uptime; 375209216Sjkimextern struct bintime boottimebin; 376126401Sphkextern struct timeval boottime; 377247777Sdavideextern struct bintime tc_tick_bt; 378247777Sdavideextern sbintime_t tc_tick_sbt; 379247777Sdavideextern struct bintime tick_bt; 380247777Sdavideextern sbintime_t tick_sbt; 381247777Sdavideextern int tc_precexp; 382247777Sdavideextern int tc_timepercentage; 383247777Sdavideextern struct bintime bt_timethreshold; 384247777Sdavideextern struct bintime bt_tickthreshold; 385247777Sdavideextern sbintime_t sbt_timethreshold; 386247777Sdavideextern sbintime_t sbt_tickthreshold; 38733690Sphk 38895817Sphk/* 38995491Sphk * Functions for looking at our clock: [get]{bin,nano,micro}[up]time() 39095491Sphk * 39195491Sphk * Functions without the "get" prefix returns the best timestamp 39295491Sphk * we can produce in the given format. 39395491Sphk * 39495491Sphk * "bin" == struct bintime == seconds + 64 bit fraction of seconds. 39595491Sphk * "nano" == struct timespec == seconds + nanoseconds. 39695491Sphk * "micro" == struct timeval == seconds + microseconds. 397239973Sed * 39895491Sphk * Functions containing "up" returns time relative to boot and 39995491Sphk * should be used for calculating time intervals. 40095491Sphk * 40195491Sphk * Functions without "up" returns GMT time. 40295491Sphk * 40395491Sphk * Functions with the "get" prefix returns a less precise result 40495491Sphk * much faster than the functions without "get" prefix and should 405198570Sru * be used where a precision of 1/hz seconds is acceptable or where 406239973Sed * performance is priority. (NB: "precision", _not_ "resolution" !) 40795491Sphk */ 40895491Sphk 40990362Sphkvoid binuptime(struct bintime *bt); 41095817Sphkvoid nanouptime(struct timespec *tsp); 41195817Sphkvoid microuptime(struct timeval *tvp); 41295491Sphk 413247452Smavstatic __inline sbintime_t 414247452Smavsbinuptime(void) 415247452Smav{ 416255135Sdavide struct bintime _bt; 417247452Smav 418255135Sdavide binuptime(&_bt); 419255135Sdavide return (bttosbt(_bt)); 420247452Smav} 421247452Smav 42290362Sphkvoid bintime(struct bintime *bt); 42395817Sphkvoid nanotime(struct timespec *tsp); 42495817Sphkvoid microtime(struct timeval *tvp); 42595491Sphk 42695491Sphkvoid getbinuptime(struct bintime *bt); 42795491Sphkvoid getnanouptime(struct timespec *tsp); 42895817Sphkvoid getmicrouptime(struct timeval *tvp); 42995491Sphk 430247452Smavstatic __inline sbintime_t 431247452Smavgetsbinuptime(void) 432247452Smav{ 433255135Sdavide struct bintime _bt; 434247452Smav 435255135Sdavide getbinuptime(&_bt); 436255135Sdavide return (bttosbt(_bt)); 437247452Smav} 438247452Smav 43995491Sphkvoid getbintime(struct bintime *bt); 44095491Sphkvoid getnanotime(struct timespec *tsp); 44195817Sphkvoid getmicrotime(struct timeval *tvp); 44295491Sphk 44395817Sphk/* Other functions */ 44492719Salfredint itimerdecr(struct itimerval *itp, int usec); 44592719Salfredint itimerfix(struct timeval *tv); 446108142Ssamint ppsratecheck(struct timeval *, int *, int); 447108142Ssamint ratecheck(struct timeval *, const struct timeval *); 448121523Salfredvoid timevaladd(struct timeval *t1, const struct timeval *t2); 449121523Salfredvoid timevalsub(struct timeval *t1, const struct timeval *t2); 45095817Sphkint tvtohz(struct timeval *tv); 451247777Sdavide 452247777Sdavide#define TC_DEFAULTPERC 5 453247777Sdavide 454247777Sdavide#define BT2FREQ(bt) \ 455247777Sdavide (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ 456247777Sdavide ((bt)->frac >> 1)) 457247777Sdavide 458247777Sdavide#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) 459247777Sdavide 460247777Sdavide#define FREQ2BT(freq, bt) \ 461247777Sdavide{ \ 462247777Sdavide (bt)->sec = 0; \ 463247777Sdavide (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ 464247777Sdavide} 465247777Sdavide 466247777Sdavide#define TIMESEL(sbt, sbt2) \ 467247777Sdavide (((sbt2) >= sbt_timethreshold) ? \ 468247777Sdavide ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0)) 469247777Sdavide 47055205Speter#else /* !_KERNEL */ 4711541Srgrimes#include <time.h> 4721541Srgrimes 4731541Srgrimes#include <sys/cdefs.h> 474189821Sdas#include <sys/select.h> 4751541Srgrimes 4761541Srgrimes__BEGIN_DECLS 477189821Sdasint setitimer(int, const struct itimerval *, struct itimerval *); 478189821Sdasint utimes(const char *, const struct timeval *); 479189821Sdas 480189821Sdas#if __BSD_VISIBLE 48192719Salfredint adjtime(const struct timeval *, struct timeval *); 482239347Sdavidxuint clock_getcpuclockid2(id_t, int, clockid_t *); 48392719Salfredint futimes(int, const struct timeval *); 484189821Sdasint futimesat(int, const char *, const struct timeval [2]); 485189821Sdasint lutimes(const char *, const struct timeval *); 486189821Sdasint settimeofday(const struct timeval *, const struct timezone *); 487189821Sdas#endif 488189821Sdas 489189821Sdas#if __XSI_VISIBLE 49092719Salfredint getitimer(int, struct itimerval *); 49192719Salfredint gettimeofday(struct timeval *, struct timezone *); 492189821Sdas#endif 493189821Sdas 4941541Srgrimes__END_DECLS 4951541Srgrimes 49655205Speter#endif /* !_KERNEL */ 4971541Srgrimes 4981541Srgrimes#endif /* !_SYS_TIME_H_ */ 499