4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or https://opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _LIBSPL_SYS_TIME_H
28 #define _LIBSPL_SYS_TIME_H
31 #include <sys/types.h>
32 #include_next <sys/time.h>
43 #define MICROSEC 1000000
47 #define NANOSEC 1000000000
51 #define NSEC_PER_USEC 1000L
55 #define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
59 #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
63 #define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC))
67 #define NSEC2USEC(n) ((n) / (NANOSEC / MICROSEC))
71 #define NSEC2SEC(n) ((n) / (NANOSEC / SEC))
75 #define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC))
78 typedef long long hrtime_t
;
79 typedef struct timespec timespec_t
;
80 typedef struct timespec inode_timespec_t
;
83 gethrestime(inode_timespec_t
*ts
)
86 (void) gettimeofday(&tv
, NULL
);
87 ts
->tv_sec
= tv
.tv_sec
;
88 ts
->tv_nsec
= tv
.tv_usec
* NSEC_PER_USEC
;
91 static inline uint64_t
95 (void) gettimeofday(&tv
, NULL
);
99 static inline hrtime_t
103 (void) clock_gettime(CLOCK_MONOTONIC
, &ts
);
104 return ((((uint64_t)ts
.tv_sec
) * NANOSEC
) + ts
.tv_nsec
);
107 #endif /* _LIBSPL_SYS_TIME_H */