]> git.proxmox.com Git - mirror_spl-debian.git/blob - include/sys/time.h
Public Release Prep
[mirror_spl-debian.git] / include / sys / time.h
1 /*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6 * UCRL-CODE-235197
7 *
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://github.com/behlendorf/spl/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 \*****************************************************************************/
24
25 #ifndef _SPL_TIME_H
26 #define _SPL_TIME_H
27
28 /*
29 * Structure returned by gettimeofday(2) system call,
30 * and used in other calls.
31 */
32 #include <linux/module.h>
33 #include <linux/time.h>
34 #include <sys/types.h>
35 #include <sys/timer.h>
36
37 #define TIME32_MAX INT32_MAX
38 #define TIME32_MIN INT32_MIN
39
40 #define SEC 1
41 #define MILLISEC 1000
42 #define MICROSEC 1000000
43 #define NANOSEC 1000000000
44
45 /* Already defined in include/linux/time.h */
46 #undef CLOCK_THREAD_CPUTIME_ID
47 #undef CLOCK_REALTIME
48 #undef CLOCK_MONOTONIC
49 #undef CLOCK_PROCESS_CPUTIME_ID
50
51 typedef enum clock_type {
52 __CLOCK_REALTIME0 = 0, /* obsolete; same as CLOCK_REALTIME */
53 CLOCK_VIRTUAL = 1, /* thread's user-level CPU clock */
54 CLOCK_THREAD_CPUTIME_ID = 2, /* thread's user+system CPU clock */
55 CLOCK_REALTIME = 3, /* wall clock */
56 CLOCK_MONOTONIC = 4, /* high resolution monotonic clock */
57 CLOCK_PROCESS_CPUTIME_ID = 5, /* process's user+system CPU clock */
58 CLOCK_HIGHRES = CLOCK_MONOTONIC, /* alternate name */
59 CLOCK_PROF = CLOCK_THREAD_CPUTIME_ID,/* alternate name */
60 } clock_type_t;
61
62 #define hz \
63 ({ \
64 ASSERT(HZ >= 100 && HZ <= MICROSEC); \
65 HZ; \
66 })
67
68 extern void __gethrestime(timestruc_t *);
69 extern int __clock_gettime(clock_type_t, timespec_t *);
70 extern hrtime_t __gethrtime(void);
71
72 #define gethrestime(ts) __gethrestime(ts)
73 #define clock_gettime(fl, tp) __clock_gettime(fl, tp)
74 #define gethrtime() __gethrtime()
75
76 static __inline__ time_t
77 gethrestime_sec(void)
78 {
79 timestruc_t now;
80
81 __gethrestime(&now);
82 return now.tv_sec;
83 }
84
85 #endif /* _SPL_TIME_H */