scoutos / prex-0.9.0 / include / sys / time.h @ 03e9c04a
History | View | Annotate | Download (3.96 KB)
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 |
|
68 |
#define DST_NONE 0 /* not on dst */ |
69 |
#define DST_USA 1 /* USA style dst */ |
70 |
#define DST_AUST 2 /* Australian style dst */ |
71 |
#define DST_WET 3 /* Western European dst */ |
72 |
#define DST_MET 4 /* Middle European dst */ |
73 |
#define DST_EET 5 /* Eastern European dst */ |
74 |
#define DST_CAN 6 /* Canada */ |
75 |
|
76 |
/* Operations on timevals. */
|
77 |
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 |
78 |
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
79 |
#define timercmp(tvp, uvp, cmp) \
|
80 |
(((tvp)->tv_sec == (uvp)->tv_sec) ? \ |
81 |
((tvp)->tv_usec cmp (uvp)->tv_usec) : \ |
82 |
((tvp)->tv_sec cmp (uvp)->tv_sec)) |
83 |
|
84 |
/*
|
85 |
* Names of the interval timers, and structure
|
86 |
* defining a timer setting.
|
87 |
*/
|
88 |
#define ITIMER_REAL 0 |
89 |
#define ITIMER_VIRTUAL 1 |
90 |
#define ITIMER_PROF 2 |
91 |
|
92 |
struct itimerval {
|
93 |
struct timeval it_interval; /* timer interval */ |
94 |
struct timeval it_value; /* current value */ |
95 |
}; |
96 |
|
97 |
/*
|
98 |
* Getkerninfo clock information structure
|
99 |
*/
|
100 |
struct clockinfo {
|
101 |
int hz; /* clock frequency */ |
102 |
int tick; /* micro-seconds per hz tick */ |
103 |
int stathz; /* statistics clock frequency */ |
104 |
int profhz; /* profiling clock frequency */ |
105 |
}; |
106 |
|
107 |
#ifndef KERNEL
|
108 |
#include <time.h> |
109 |
|
110 |
#ifndef _POSIX_SOURCE
|
111 |
#include <sys/cdefs.h> |
112 |
|
113 |
__BEGIN_DECLS |
114 |
int gettimeofday(struct timeval *, struct timezone *); |
115 |
#if 0
|
116 |
int adjtime(const struct timeval *, struct timeval *);
|
117 |
int getitimer(int, struct itimerval *);
|
118 |
int setitimer(int, const struct itimerval *, struct itimerval *);
|
119 |
int settimeofday(const struct timeval *, const struct timezone *);
|
120 |
int utimes(const char *, const struct timeval *);
|
121 |
#endif
|
122 |
__END_DECLS |
123 |
#endif /* !POSIX */ |
124 |
#endif /* !KERNEL */ |
125 |
|
126 |
|
127 |
#endif /* !_SYS_TIME_H_ */ |