diff --git a/include/os/freebsd/spl/sys/time.h b/include/os/freebsd/spl/sys/time.h index fbc679aacf93..47d64c34756a 100644 --- a/include/os/freebsd/spl/sys/time.h +++ b/include/os/freebsd/spl/sys/time.h @@ -1,96 +1,94 @@ /* * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _OPENSOLARIS_SYS_TIME_H_ #define _OPENSOLARIS_SYS_TIME_H_ #pragma once #include_next #include #ifndef _SYS_KERNEL_H_ extern int hz; #endif #define SEC 1 #define MILLISEC 1000UL #define MICROSEC 1000000UL #define NANOSEC 1000000000UL #define TIME_MAX LLONG_MAX #define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) #define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC)) #define NSEC2USEC(n) ((n) / (NANOSEC / MICROSEC)) #define NSEC2SEC(n) ((n) / (NANOSEC / SEC)) #define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC)) typedef longlong_t hrtime_t; #if defined(__i386__) || defined(__powerpc__) #define TIMESPEC_OVERFLOW(ts) \ ((ts)->tv_sec < INT32_MIN || (ts)->tv_sec > INT32_MAX) #else #define TIMESPEC_OVERFLOW(ts) \ ((ts)->tv_sec < INT64_MIN || (ts)->tv_sec > INT64_MAX) #endif #define SEC_TO_TICK(sec) ((sec) * hz) #define NSEC_TO_TICK(nsec) ((nsec) / (NANOSEC / hz)) static __inline hrtime_t gethrtime(void) { struct timespec ts; hrtime_t nsec; nanouptime(&ts); nsec = ((hrtime_t)ts.tv_sec * NANOSEC) + ts.tv_nsec; return (nsec); } #define gethrestime_sec() (time_second) #define gethrestime(ts) getnanotime(ts) #define gethrtime_waitfree() gethrtime() extern int nsec_per_tick; /* nanoseconds per clock tick */ #define ddi_get_lbolt64() \ (int64_t)(((getsbinuptime() >> 16) * hz) >> 16) #define ddi_get_lbolt() (clock_t)ddi_get_lbolt64() #else static __inline hrtime_t gethrtime(void) { struct timespec ts; clock_gettime(CLOCK_UPTIME, &ts); - return (((u_int64_t)ts.tv_sec) * NANOSEC + ts.tv_nsec); + return (((uint64_t)ts.tv_sec) * NANOSEC + ts.tv_nsec); } #endif /* !_OPENSOLARIS_SYS_TIME_H_ */ diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h index e692415a041c..0f7d5196b31c 100644 --- a/lib/libspl/include/sys/time.h +++ b/lib/libspl/include/sys/time.h @@ -1,107 +1,107 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef _LIBSPL_SYS_TIME_H #define _LIBSPL_SYS_TIME_H #include #include #include_next #ifndef SEC #define SEC 1 #endif #ifndef MILLISEC #define MILLISEC 1000 #endif #ifndef MICROSEC #define MICROSEC 1000000 #endif #ifndef NANOSEC #define NANOSEC 1000000000 #endif #ifndef NSEC_PER_USEC #define NSEC_PER_USEC 1000L #endif #ifndef MSEC2NSEC #define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) #endif #ifndef NSEC2MSEC #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) #endif #ifndef USEC2NSEC #define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC)) #endif #ifndef NSEC2USEC #define NSEC2USEC(n) ((n) / (NANOSEC / MICROSEC)) #endif #ifndef NSEC2SEC #define NSEC2SEC(n) ((n) / (NANOSEC / SEC)) #endif #ifndef SEC2NSEC #define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC)) #endif typedef long long hrtime_t; typedef struct timespec timespec_t; typedef struct timespec inode_timespec_t; static inline void gethrestime(inode_timespec_t *ts) { struct timeval tv; (void) gettimeofday(&tv, NULL); ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC; } static inline uint64_t gethrestime_sec(void) { struct timeval tv; (void) gettimeofday(&tv, NULL); return (tv.tv_sec); } static inline hrtime_t gethrtime(void) { struct timespec ts; (void) clock_gettime(CLOCK_MONOTONIC, &ts); - return ((((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec); + return ((((uint64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec); } #endif /* _LIBSPL_SYS_TIME_H */