Annotation of prex-old/include/sys/time.h, Revision 1.1
1.1 ! nbrk 1: /*
! 2: * Copyright (c) 1982, 1986, 1993
! 3: * The Regents of the University of California. All rights reserved.
! 4: *
! 5: * Redistribution and use in source and binary forms, with or without
! 6: * modification, are permitted provided that the following conditions
! 7: * are met:
! 8: * 1. Redistributions of source code must retain the above copyright
! 9: * notice, this list of conditions and the following disclaimer.
! 10: * 2. Redistributions in binary form must reproduce the above copyright
! 11: * notice, this list of conditions and the following disclaimer in the
! 12: * documentation and/or other materials provided with the distribution.
! 13: * 3. Neither the name of the University nor the names of its contributors
! 14: * may be used to endorse or promote products derived from this software
! 15: * without specific prior written permission.
! 16: *
! 17: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 20: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 27: * SUCH DAMAGE.
! 28: *
! 29: * @(#)time.h 8.5 (Berkeley) 5/4/95
! 30: */
! 31:
! 32: #ifndef _SYS_TIME_H_
! 33: #define _SYS_TIME_H_
! 34:
! 35: #include <sys/types.h>
! 36:
! 37: /*
! 38: * Structure returned by gettimeofday(2) system call,
! 39: * and used in other calls.
! 40: */
! 41: struct timeval {
! 42: long tv_sec; /* seconds */
! 43: long tv_usec; /* and microseconds */
! 44: };
! 45:
! 46: /*
! 47: * Structure defined by POSIX.4 to be like a timeval.
! 48: */
! 49: struct timespec {
! 50: time_t ts_sec; /* seconds */
! 51: long ts_nsec; /* and nanoseconds */
! 52: };
! 53:
! 54: #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
! 55: (ts)->ts_sec = (tv)->tv_sec; \
! 56: (ts)->ts_nsec = (tv)->tv_usec * 1000; \
! 57: }
! 58: #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
! 59: (tv)->tv_sec = (ts)->ts_sec; \
! 60: (tv)->tv_usec = (ts)->ts_nsec / 1000; \
! 61: }
! 62:
! 63: struct timezone {
! 64: int tz_minuteswest; /* minutes west of Greenwich */
! 65: int tz_dsttime; /* type of dst correction */
! 66: };
! 67: #define DST_NONE 0 /* not on dst */
! 68: #define DST_USA 1 /* USA style dst */
! 69: #define DST_AUST 2 /* Australian style dst */
! 70: #define DST_WET 3 /* Western European dst */
! 71: #define DST_MET 4 /* Middle European dst */
! 72: #define DST_EET 5 /* Eastern European dst */
! 73: #define DST_CAN 6 /* Canada */
! 74:
! 75: /* Operations on timevals. */
! 76: #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
! 77: #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
! 78: #define timercmp(tvp, uvp, cmp) \
! 79: (((tvp)->tv_sec == (uvp)->tv_sec) ? \
! 80: ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
! 81: ((tvp)->tv_sec cmp (uvp)->tv_sec))
! 82:
! 83: /*
! 84: * Names of the interval timers, and structure
! 85: * defining a timer setting.
! 86: */
! 87: #define ITIMER_REAL 0
! 88: #define ITIMER_VIRTUAL 1
! 89: #define ITIMER_PROF 2
! 90:
! 91: struct itimerval {
! 92: struct timeval it_interval; /* timer interval */
! 93: struct timeval it_value; /* current value */
! 94: };
! 95:
! 96: /*
! 97: * Getkerninfo clock information structure
! 98: */
! 99: struct clockinfo {
! 100: int hz; /* clock frequency */
! 101: int tick; /* micro-seconds per hz tick */
! 102: int stathz; /* statistics clock frequency */
! 103: int profhz; /* profiling clock frequency */
! 104: };
! 105:
! 106: #ifndef KERNEL
! 107: #include <time.h>
! 108:
! 109: #ifndef _POSIX_SOURCE
! 110: #include <sys/cdefs.h>
! 111:
! 112: __BEGIN_DECLS
! 113: int adjtime(const struct timeval *, struct timeval *);
! 114: int getitimer(int, struct itimerval *);
! 115: int gettimeofday(struct timeval *, struct timezone *);
! 116: int setitimer(int, const struct itimerval *, struct itimerval *);
! 117: int settimeofday(const struct timeval *, const struct timezone *);
! 118: int utimes(const char *, const struct timeval *);
! 119: __END_DECLS
! 120: #endif /* !POSIX */
! 121: #endif /* !KERNEL */
! 122:
! 123:
! 124: #endif /* !_SYS_TIME_H_ */
CVSweb