xref: /original-bsd/sys/sys/time.h (revision 753853ba)
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.7 (Berkeley) 03/09/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 struct timezone {
23 	int	tz_minuteswest;	/* minutes west of Greenwich */
24 	int	tz_dsttime;	/* type of dst correction */
25 };
26 #define	DST_NONE	0	/* not on dst */
27 #define	DST_USA		1	/* USA style dst */
28 #define	DST_AUST	2	/* Australian style dst */
29 #define	DST_WET		3	/* Western European dst */
30 #define	DST_MET		4	/* Middle European dst */
31 #define	DST_EET		5	/* Eastern European dst */
32 #define	DST_CAN		6	/* Canada */
33 
34 /*
35  * Operations on timevals.
36  *
37  * NB: timercmp does not work for >= or <=.
38  */
39 #define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
40 #define	timercmp(tvp, uvp, cmp)	\
41 	((tvp)->tv_sec cmp (uvp)->tv_sec || \
42 	 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
43 #define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
44 
45 /*
46  * Names of the interval timers, and structure
47  * defining a timer setting.
48  */
49 #define	ITIMER_REAL	0
50 #define	ITIMER_VIRTUAL	1
51 #define	ITIMER_PROF	2
52 
53 struct	itimerval {
54 	struct	timeval it_interval;	/* timer interval */
55 	struct	timeval it_value;	/* current value */
56 };
57 
58 /*
59  * Getkerninfo clock information structure
60  */
61 struct clockinfo {
62 	int hz;		/* clock frequency */
63 	int tick;	/* micro-seconds per hz tick */
64 	int phz;	/* alternate clock frequency */
65 	int profhz;	/* profiling clock frequency */
66 };
67 
68 #ifndef KERNEL
69 #include <time.h>
70 
71 #ifndef _POSIX_SOURCE
72 #include <sys/cdefs.h>
73 
74 __BEGIN_DECLS
75 int	adjtime __P((const struct timeval *, struct timeval *));
76 int	getitimer __P((int, struct itimerval *));
77 int	gettimeofday __P((struct timeval *, struct timezone *));
78 int	setitimer __P((int, const struct itimerval *, struct itimerval *));
79 int	settimeofday __P((const struct timeval *, const struct timezone *));
80 int	utimes __P((const char *, const struct timeval *));
81 __END_DECLS
82 #endif /* !POSIX */
83 
84 #endif /* !KERNEL */
85 
86 #endif /* !_SYS_TIME_H_ */
87