1 /* 2 * Copyright (c) 1982, 1986 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)time.h 7.9 (Berkeley) 06/19/92 8 */ 9 10 #ifndef _SYS_TIME_H_ 11 #define _SYS_TIME_H_ 12 13 /* 14 * Structure returned by gettimeofday(2) system call, 15 * and used in other calls. 16 */ 17 struct timeval { 18 long tv_sec; /* seconds */ 19 long tv_usec; /* and microseconds */ 20 }; 21 22 /* 23 * Structure defined by POSIX.4 to be like a timeval. 24 */ 25 struct timespec { 26 long ts_sec; /* seconds */ 27 long ts_nsec; /* and nanoseconds */ 28 }; 29 30 struct timezone { 31 int tz_minuteswest; /* minutes west of Greenwich */ 32 int tz_dsttime; /* type of dst correction */ 33 }; 34 #define DST_NONE 0 /* not on dst */ 35 #define DST_USA 1 /* USA style dst */ 36 #define DST_AUST 2 /* Australian style dst */ 37 #define DST_WET 3 /* Western European dst */ 38 #define DST_MET 4 /* Middle European dst */ 39 #define DST_EET 5 /* Eastern European dst */ 40 #define DST_CAN 6 /* Canada */ 41 42 /* 43 * Operations on timevals. 44 * 45 * NB: timercmp does not work for >= or <=. 46 */ 47 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 48 #define timercmp(tvp, uvp, cmp) \ 49 ((tvp)->tv_sec cmp (uvp)->tv_sec || \ 50 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) 51 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 52 53 /* 54 * Names of the interval timers, and structure 55 * defining a timer setting. 56 */ 57 #define ITIMER_REAL 0 58 #define ITIMER_VIRTUAL 1 59 #define ITIMER_PROF 2 60 61 struct itimerval { 62 struct timeval it_interval; /* timer interval */ 63 struct timeval it_value; /* current value */ 64 }; 65 66 /* 67 * Getkerninfo clock information structure 68 */ 69 struct clockinfo { 70 int hz; /* clock frequency */ 71 int tick; /* micro-seconds per hz tick */ 72 int stathz; /* statistics clock frequency */ 73 int profhz; /* profiling clock frequency */ 74 }; 75 76 #ifndef KERNEL 77 #include <time.h> 78 79 #ifndef _POSIX_SOURCE 80 #include <sys/cdefs.h> 81 82 __BEGIN_DECLS 83 int adjtime __P((const struct timeval *, struct timeval *)); 84 int getitimer __P((int, struct itimerval *)); 85 int gettimeofday __P((struct timeval *, struct timezone *)); 86 int setitimer __P((int, const struct itimerval *, struct itimerval *)); 87 int settimeofday __P((const struct timeval *, const struct timezone *)); 88 int utimes __P((const char *, const struct timeval *)); 89 __END_DECLS 90 #endif /* !POSIX */ 91 92 #endif /* !KERNEL */ 93 94 #endif /* !_SYS_TIME_H_ */ 95