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