From e64cc4954c7862db6a6b4dc978a091ebc3f870da Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Sat, 25 Jul 2020 20:09:50 -0700 Subject: [PATCH] Refactor ccompile.h to not include system headers This is a step toward being able to vendor the OpenZFS code in FreeBSD. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Matt Macy Closes #10625 --- include/os/freebsd/linux/types.h | 5 +- include/os/freebsd/spl/sys/ccompat.h | 138 +++++++++++++++++++ include/os/freebsd/spl/sys/ccompile.h | 139 ++------------------ include/os/freebsd/spl/sys/condvar.h | 1 + include/os/freebsd/spl/sys/kstat.h | 1 + include/os/freebsd/spl/sys/param.h | 7 +- include/os/freebsd/spl/sys/systm.h | 2 +- include/os/freebsd/spl/sys/types.h | 17 ++- include/os/freebsd/zfs/sys/zfs_context_os.h | 3 + include/sys/zfs_context.h | 3 + module/Makefile.bsd | 4 +- module/nvpair/nvpair.c | 1 + module/os/freebsd/spl/callb.c | 2 +- module/os/freebsd/spl/spl_acl.c | 1 + module/os/freebsd/spl/spl_cmn_err.c | 3 + module/os/freebsd/spl/spl_dtrace.c | 1 + module/os/freebsd/spl/spl_kmem.c | 1 + module/os/freebsd/spl/spl_kstat.c | 1 + module/os/freebsd/spl/spl_misc.c | 1 + module/os/freebsd/spl/spl_policy.c | 1 + module/os/freebsd/spl/spl_string.c | 1 + module/os/freebsd/spl/spl_sunddi.c | 1 + module/os/freebsd/spl/spl_sysevent.c | 1 + module/os/freebsd/spl/spl_taskq.c | 1 + module/os/freebsd/spl/spl_uio.c | 2 +- module/os/freebsd/spl/spl_vfs.c | 3 + module/os/freebsd/spl/spl_vm.c | 1 + module/os/freebsd/spl/spl_zlib.c | 1 + module/os/freebsd/spl/spl_zone.c | 1 + module/os/freebsd/zfs/abd_os.c | 1 + module/os/freebsd/zfs/dmu_os.c | 3 + module/os/freebsd/zfs/zfs_ctldir.c | 4 + module/os/freebsd/zfs/zfs_dir.c | 2 + module/zcommon/zfeature_common.c | 1 + module/zcommon/zfs_fletcher_avx512.c | 2 + module/zcommon/zfs_fletcher_superscalar.c | 1 + module/zcommon/zfs_fletcher_superscalar4.c | 1 + module/zfs/vdev_raidz_math_avx512bw.c | 4 + module/zfs/vdev_raidz_math_ssse3.c | 2 + 39 files changed, 224 insertions(+), 141 deletions(-) create mode 100644 include/os/freebsd/spl/sys/ccompat.h diff --git a/include/os/freebsd/linux/types.h b/include/os/freebsd/linux/types.h index 301163c03..d290317cc 100644 --- a/include/os/freebsd/linux/types.h +++ b/include/os/freebsd/linux/types.h @@ -31,9 +31,6 @@ #ifndef _LINUX_TYPES_H_ #define _LINUX_TYPES_H_ -#include -#include -#include #include @@ -53,7 +50,7 @@ typedef uint64_t __le64; typedef uint64_t __be64; typedef unsigned gfp_t; -typedef uint64_t loff_t; +typedef off_t loff_t; typedef vm_paddr_t resource_size_t; typedef uint16_t __bitwise__ __sum16; typedef unsigned long pgoff_t; diff --git a/include/os/freebsd/spl/sys/ccompat.h b/include/os/freebsd/spl/sys/ccompat.h new file mode 100644 index 000000000..6c8767635 --- /dev/null +++ b/include/os/freebsd/spl/sys/ccompat.h @@ -0,0 +1,138 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * 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 AUTHOR 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 AUTHOR 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 _SYS_CCOMPAT_H +#define _SYS_CCOMPAT_H + +#if __FreeBSD_version < 1300051 +#define vm_page_valid(m) (m)->valid = VM_PAGE_BITS_ALL +#define vm_page_do_sunbusy(m) +#define vm_page_none_valid(m) ((m)->valid == 0) +#else +#define vm_page_do_sunbusy(m) vm_page_sunbusy(m) +#endif + +#if __FreeBSD_version < 1300074 +#define VOP_UNLOCK1(x) VOP_UNLOCK(x, 0) +#else +#define VOP_UNLOCK1(x) VOP_UNLOCK(x) +#endif + +#if __FreeBSD_version < 1300064 +#define VN_IS_DOOMED(vp) ((vp)->v_iflag & VI_DOOMED) +#endif + +#if __FreeBSD_version < 1300068 +#define VFS_VOP_VECTOR_REGISTER(x) +#endif + +#if __FreeBSD_version >= 1300076 +#define getnewvnode_reserve_() getnewvnode_reserve() +#else +#define getnewvnode_reserve_() getnewvnode_reserve(1) +#endif +struct hlist_node { + struct hlist_node *next, **pprev; +}; + +struct hlist_head { + struct hlist_node *first; +}; + +typedef struct { + volatile int counter; +} atomic_t; + + /* BEGIN CSTYLED */ +#define hlist_for_each(p, head) \ + for (p = (head)->first; p; p = (p)->next) + +#define hlist_entry(ptr, type, field) container_of(ptr, type, field) + +#define container_of(ptr, type, member) \ +({ \ + const __typeof(((type *)0)->member) *__p = (ptr); \ + (type *)((uintptr_t)__p - offsetof(type, member)); \ +}) + /* END CSTYLED */ + +static inline void +hlist_add_head(struct hlist_node *n, struct hlist_head *h) +{ + n->next = h->first; + if (h->first != NULL) + h->first->pprev = &n->next; + WRITE_ONCE(h->first, n); + n->pprev = &h->first; +} + +static inline void +hlist_del(struct hlist_node *n) +{ + WRITE_ONCE(*(n->pprev), n->next); + if (n->next != NULL) + n->next->pprev = n->pprev; +} + /* BEGIN CSTYLED */ +#define READ_ONCE(x) ({ \ + __typeof(x) __var = ({ \ + barrier(); \ + ACCESS_ONCE(x); \ + }); \ + barrier(); \ + __var; \ +}) + +#define HLIST_HEAD_INIT { } +#define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT +#define INIT_HLIST_HEAD(head) (head)->first = NULL + +#define INIT_HLIST_NODE(node) \ + do { \ + (node)->next = NULL; \ + (node)->pprev = NULL; \ + } while (0) + +/* END CSTYLED */ +static inline int +atomic_read(const atomic_t *v) +{ + return (READ_ONCE(v->counter)); +} + +static inline int +atomic_inc(atomic_t *v) +{ + return (atomic_fetchadd_int(&v->counter, 1) + 1); +} + +static inline int +atomic_dec(atomic_t *v) +{ + return (atomic_fetchadd_int(&v->counter, -1) - 1); +} +#endif diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h index 116612b61..cfb94268b 100644 --- a/include/os/freebsd/spl/sys/ccompile.h +++ b/include/os/freebsd/spl/sys/ccompile.h @@ -164,14 +164,19 @@ extern "C" { #define KMALLOC_MAX_SIZE MAXPHYS -#ifdef _KERNEL -#if !defined(LOCORE) && !defined(_ASM) -typedef unsigned long long u_longlong_t; -typedef long long longlong_t; - - -typedef void zfs_kernel_param_t; +#ifndef LOCORE +#ifndef HAVE_RPC_TYPES +typedef int bool_t; +typedef int enum_t; #endif +#endif + +#ifndef __cplusplus +#define __init +#define __exit +#endif + +#ifdef _KERNEL #define param_set_charp(a, b) (0) #define ATTR_UID AT_UID #define ATTR_GID AT_GID @@ -186,127 +191,7 @@ typedef void zfs_kernel_param_t; #define MUTEX_NOLOCKDEP 0 #define RW_NOLOCKDEP 0 -#if !defined(LOCORE) && !defined(_ASM) -#include -#include - -#if __FreeBSD_version < 1300051 -#define vm_page_valid(m) (m)->valid = VM_PAGE_BITS_ALL -#define vm_page_do_sunbusy(m) -#define vm_page_none_valid(m) ((m)->valid == 0) #else -#define vm_page_do_sunbusy(m) vm_page_sunbusy(m) -#endif - -#if __FreeBSD_version < 1300074 -#define VOP_UNLOCK1(x) VOP_UNLOCK(x, 0) -#else -#define VOP_UNLOCK1(x) VOP_UNLOCK(x) -#endif - -#if __FreeBSD_version < 1300064 -#define VN_IS_DOOMED(vp) ((vp)->v_iflag & VI_DOOMED) -#endif - -#if __FreeBSD_version < 1300068 -#define VFS_VOP_VECTOR_REGISTER(x) -#endif - -#if __FreeBSD_version >= 1300076 -#define getnewvnode_reserve_() getnewvnode_reserve() -#else -#define getnewvnode_reserve_() getnewvnode_reserve(1) -#endif -struct hlist_node { - struct hlist_node *next, **pprev; -}; - -struct hlist_head { - struct hlist_node *first; -}; - -typedef struct { - volatile int counter; -} atomic_t; - - /* BEGIN CSTYLED */ -#define hlist_for_each(p, head) \ - for (p = (head)->first; p; p = (p)->next) - -#define hlist_entry(ptr, type, field) container_of(ptr, type, field) - -#define container_of(ptr, type, member) \ -({ \ - const __typeof(((type *)0)->member) *__p = (ptr); \ - (type *)((uintptr_t)__p - offsetof(type, member)); \ -}) - /* END CSTYLED */ - -static inline void -hlist_add_head(struct hlist_node *n, struct hlist_head *h) -{ - n->next = h->first; - if (h->first != NULL) - h->first->pprev = &n->next; - WRITE_ONCE(h->first, n); - n->pprev = &h->first; -} - -static inline void -hlist_del(struct hlist_node *n) -{ - WRITE_ONCE(*(n->pprev), n->next); - if (n->next != NULL) - n->next->pprev = n->pprev; -} - /* BEGIN CSTYLED */ -#define READ_ONCE(x) ({ \ - __typeof(x) __var = ({ \ - barrier(); \ - ACCESS_ONCE(x); \ - }); \ - barrier(); \ - __var; \ -}) - -#define HLIST_HEAD_INIT { } -#define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT -#define INIT_HLIST_HEAD(head) (head)->first = NULL - -#define INIT_HLIST_NODE(node) \ - do { \ - (node)->next = NULL; \ - (node)->pprev = NULL; \ - } while (0) - -/* END CSTYLED */ -static inline int -atomic_read(const atomic_t *v) -{ - return (READ_ONCE(v->counter)); -} - -static inline int -atomic_inc(atomic_t *v) -{ - return (atomic_fetchadd_int(&v->counter, 1) + 1); -} - -static inline int -atomic_dec(atomic_t *v) -{ - return (atomic_fetchadd_int(&v->counter, -1) - 1); -} -#endif -#else -typedef long loff_t; -typedef long rlim64_t; -typedef int bool_t; -typedef int enum_t; -#ifndef __cplusplus -#define __init -#endif -#define __exit #define FALSE 0 #define TRUE 1 /* diff --git a/include/os/freebsd/spl/sys/condvar.h b/include/os/freebsd/spl/sys/condvar.h index 2e99a1a34..a42995793 100644 --- a/include/os/freebsd/spl/sys/condvar.h +++ b/include/os/freebsd/spl/sys/condvar.h @@ -31,6 +31,7 @@ #define _OPENSOLARIS_SYS_CONDVAR_H_ #include +#include #include #include diff --git a/include/os/freebsd/spl/sys/kstat.h b/include/os/freebsd/spl/sys/kstat.h index 740f24b70..74c3da8ec 100644 --- a/include/os/freebsd/spl/sys/kstat.h +++ b/include/os/freebsd/spl/sys/kstat.h @@ -24,6 +24,7 @@ #ifndef _SPL_KSTAT_H #define _SPL_KSTAT_H +#include #include struct list_head {}; #include diff --git a/include/os/freebsd/spl/sys/param.h b/include/os/freebsd/spl/sys/param.h index 01392dd67..92724e332 100644 --- a/include/os/freebsd/spl/sys/param.h +++ b/include/os/freebsd/spl/sys/param.h @@ -30,9 +30,12 @@ #ifndef _COMPAT_OPENSOLARIS_SYS_PARAM_H_ #define _COMPAT_OPENSOLARIS_SYS_PARAM_H_ +#include #include_next - #define PAGESIZE PAGE_SIZE #define ptob(x) ((uint64_t)(x) << PAGE_SHIFT) - +#ifdef _KERNEL +#include +#include +#endif #endif diff --git a/include/os/freebsd/spl/sys/systm.h b/include/os/freebsd/spl/sys/systm.h index 53cc6f527..98ee95575 100644 --- a/include/os/freebsd/spl/sys/systm.h +++ b/include/os/freebsd/spl/sys/systm.h @@ -29,7 +29,7 @@ #ifndef _OPENSOLARIS_SYS_SYSTM_H_ #define _OPENSOLARIS_SYS_SYSTM_H_ -#include +#include #include_next #include diff --git a/include/os/freebsd/spl/sys/types.h b/include/os/freebsd/spl/sys/types.h index ed5e8ef80..c06c963d6 100644 --- a/include/os/freebsd/spl/sys/types.h +++ b/include/os/freebsd/spl/sys/types.h @@ -33,18 +33,29 @@ /* * This is a bag of dirty hacks to keep things compiling. */ +#include_next +#ifdef __ILP32__ +typedef __uint64_t u_longlong_t; +typedef __int64_t longlong_t; +#else +typedef unsigned long long u_longlong_t; +typedef long long longlong_t; +#endif #include -typedef int64_t clock_t; #define _CLOCK_T_DECLARED -#include_next #include #include +#include #define MAXNAMELEN 256 + + +typedef void zfs_kernel_param_t; + typedef struct timespec timestruc_t; typedef struct timespec timespec_t; typedef struct timespec inode_timespec_t; @@ -93,5 +104,5 @@ typedef u_longlong_t len_t; typedef longlong_t diskaddr_t; - +#include #endif /* !_OPENSOLARIS_SYS_TYPES_H_ */ diff --git a/include/os/freebsd/zfs/sys/zfs_context_os.h b/include/os/freebsd/zfs/sys/zfs_context_os.h index 529ba7204..8da3374a6 100644 --- a/include/os/freebsd/zfs/sys/zfs_context_os.h +++ b/include/os/freebsd/zfs/sys/zfs_context_os.h @@ -37,6 +37,9 @@ #include #include #include +#include +#include +#include #define cv_wait_io(cv, mp) cv_wait(cv, mp) #define cv_wait_io_sig(cv, mp) cv_wait_sig(cv, mp) diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 95f963e73..ccae941b4 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -335,6 +335,9 @@ extern void cv_broadcast(kcondvar_t *cv); #define tsd_set(k, v) pthread_setspecific(k, v) #define tsd_create(kp, d) pthread_key_create((pthread_key_t *)kp, d) #define tsd_destroy(kp) /* nothing */ +#ifdef __FreeBSD__ +typedef off_t loff_t; +#endif /* * kstat creation, installation and deletion diff --git a/module/Makefile.bsd b/module/Makefile.bsd index 6fd00f474..517054b0e 100644 --- a/module/Makefile.bsd +++ b/module/Makefile.bsd @@ -32,7 +32,7 @@ CFLAGS+= -DHAVE_UIO_ZEROCOPY -DWITHOUT_NETDUMP -D__KERNEL -D_SYS_CONDVAR_H_ CFLAGS+= -D_SYS_VMEM_H_ -D_MACHINE_ENDIAN_H_ -DKDTRACE_HOOKS -DSMP .if ${MACHINE_ARCH} == "amd64" -CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F +CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F -DHAVE_SSSE3 .endif .if defined(WITH_DEBUG) && ${WITH_DEBUG} == "true" @@ -310,7 +310,7 @@ CFLAGS.lcompat.c= -Wno-cast-qual CFLAGS.lobject.c= -Wno-cast-qual CFLAGS.ltable.c= -Wno-cast-qual CFLAGS.lvm.c= -Wno-cast-qual -CFLAGS.nvpair.c= -Wno-cast-qual +CFLAGS.nvpair.c= -DHAVE_RPC_TYPES -Wno-cast-qual CFLAGS.spl_string.c= -Wno-cast-qual CFLAGS.spl_vm.c= -Wno-cast-qual CFLAGS.spl_zlib.c= -Wno-cast-qual diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 8691aaf2c..6c0261f08 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/module/os/freebsd/spl/callb.c b/module/os/freebsd/spl/callb.c index 633e85bc0..fffa85b6b 100644 --- a/module/os/freebsd/spl/callb.c +++ b/module/os/freebsd/spl/callb.c @@ -23,8 +23,8 @@ * Use is subject to license terms. */ -#include #include +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_acl.c b/module/os/freebsd/spl/spl_acl.c index bb4c30728..18188ca0a 100644 --- a/module/os/freebsd/spl/spl_acl.c +++ b/module/os/freebsd/spl/spl_acl.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_cmn_err.c b/module/os/freebsd/spl/spl_cmn_err.c index 23566603f..22c7338b7 100644 --- a/module/os/freebsd/spl/spl_cmn_err.c +++ b/module/os/freebsd/spl/spl_cmn_err.c @@ -25,6 +25,9 @@ * Copyright 2012 Martin Matuska . All rights reserved. */ +#include +#include +#include #include void diff --git a/module/os/freebsd/spl/spl_dtrace.c b/module/os/freebsd/spl/spl_dtrace.c index e7b2ff823..6b2872bcc 100644 --- a/module/os/freebsd/spl/spl_dtrace.c +++ b/module/os/freebsd/spl/spl_dtrace.c @@ -29,6 +29,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_kmem.c b/module/os/freebsd/spl/spl_kmem.c index af3747c27..cfc61dd7f 100644 --- a/module/os/freebsd/spl/spl_kmem.c +++ b/module/os/freebsd/spl/spl_kmem.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_kstat.c b/module/os/freebsd/spl/spl_kstat.c index 234b56a49..756667045 100644 --- a/module/os/freebsd/spl/spl_kstat.c +++ b/module/os/freebsd/spl/spl_kstat.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_misc.c b/module/os/freebsd/spl/spl_misc.c index 8d33916d8..0354b986c 100644 --- a/module/os/freebsd/spl/spl_misc.c +++ b/module/os/freebsd/spl/spl_misc.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_policy.c b/module/os/freebsd/spl/spl_policy.c index 8ef4ca88b..5cd5c69ef 100644 --- a/module/os/freebsd/spl/spl_policy.c +++ b/module/os/freebsd/spl/spl_policy.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_string.c b/module/os/freebsd/spl/spl_string.c index 14d816b5c..d13b64b4c 100644 --- a/module/os/freebsd/spl/spl_string.c +++ b/module/os/freebsd/spl/spl_string.c @@ -25,6 +25,7 @@ * Use is subject to license terms. */ +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_sunddi.c b/module/os/freebsd/spl/spl_sunddi.c index 1fa4f56f1..ebec77bdb 100644 --- a/module/os/freebsd/spl/spl_sunddi.c +++ b/module/os/freebsd/spl/spl_sunddi.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_sysevent.c b/module/os/freebsd/spl/spl_sysevent.c index 4bb0658c8..53520eeaf 100644 --- a/module/os/freebsd/spl/spl_sysevent.c +++ b/module/os/freebsd/spl/spl_sysevent.c @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c index f32dad2a2..9cdf93ea9 100644 --- a/module/os/freebsd/spl/spl_taskq.c +++ b/module/os/freebsd/spl/spl_taskq.c @@ -29,6 +29,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_uio.c b/module/os/freebsd/spl/spl_uio.c index 05dbfd06d..c6b610394 100644 --- a/module/os/freebsd/spl/spl_uio.c +++ b/module/os/freebsd/spl/spl_uio.c @@ -40,7 +40,7 @@ * $FreeBSD$ */ -#include +#include #include #include diff --git a/module/os/freebsd/spl/spl_vfs.c b/module/os/freebsd/spl/spl_vfs.c index 99da8c976..d42835c20 100644 --- a/module/os/freebsd/spl/spl_vfs.c +++ b/module/os/freebsd/spl/spl_vfs.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -40,6 +41,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + MALLOC_DECLARE(M_MOUNT); void diff --git a/module/os/freebsd/spl/spl_vm.c b/module/os/freebsd/spl/spl_vm.c index 9f7acab74..b5649d519 100644 --- a/module/os/freebsd/spl/spl_vm.c +++ b/module/os/freebsd/spl/spl_vm.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_zlib.c b/module/os/freebsd/spl/spl_zlib.c index 4d53f42d3..079801f2d 100644 --- a/module/os/freebsd/spl/spl_zlib.c +++ b/module/os/freebsd/spl/spl_zlib.c @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/spl/spl_zone.c b/module/os/freebsd/spl/spl_zone.c index 40f21934e..0b3b04d2a 100644 --- a/module/os/freebsd/spl/spl_zone.c +++ b/module/os/freebsd/spl/spl_zone.c @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include diff --git a/module/os/freebsd/zfs/abd_os.c b/module/os/freebsd/zfs/abd_os.c index b4d43b96a..6b325affa 100644 --- a/module/os/freebsd/zfs/abd_os.c +++ b/module/os/freebsd/zfs/abd_os.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/module/os/freebsd/zfs/dmu_os.c b/module/os/freebsd/zfs/dmu_os.c index 4d367af31..8e412d9c1 100644 --- a/module/os/freebsd/zfs/dmu_os.c +++ b/module/os/freebsd/zfs/dmu_os.c @@ -28,6 +28,8 @@ #include __FBSDID("$FreeBSD$"); +#include +#include #include #include #include @@ -55,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifndef IDX_TO_OFF #define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT) diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c index 2738f5399..8481a9d75 100644 --- a/module/os/freebsd/zfs/zfs_ctldir.c +++ b/module/os/freebsd/zfs/zfs_ctldir.c @@ -65,6 +65,9 @@ * so that it cannot be freed until all snapshots have been unmounted. */ +#include +#include +#include #include #include #include @@ -83,6 +86,7 @@ #include "zfs_namecheck.h" #include +#include /* Common access mode for all virtual directories under the ctldir */ const uint16_t zfsctl_ctldir_mode = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | diff --git a/module/os/freebsd/zfs/zfs_dir.c b/module/os/freebsd/zfs/zfs_dir.c index 5aa4cd525..4b1f4a883 100644 --- a/module/os/freebsd/zfs/zfs_dir.c +++ b/module/os/freebsd/zfs/zfs_dir.c @@ -60,6 +60,8 @@ #include #include +#include + /* * zfs_match_find() is used by zfs_dirent_lookup() to perform zap lookups * of names after deciding which is the appropriate lookup interface. diff --git a/module/zcommon/zfeature_common.c b/module/zcommon/zfeature_common.c index 302d48570..ed7967dc1 100644 --- a/module/zcommon/zfeature_common.c +++ b/module/zcommon/zfeature_common.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "zfeature_common.h" diff --git a/module/zcommon/zfs_fletcher_avx512.c b/module/zcommon/zfs_fletcher_avx512.c index d33d2dc33..300ec4c1f 100644 --- a/module/zcommon/zfs_fletcher_avx512.c +++ b/module/zcommon/zfs_fletcher_avx512.c @@ -31,7 +31,9 @@ #include #include +#ifdef __linux__ #define __asm __asm__ __volatile__ +#endif static void fletcher_4_avx512f_init(fletcher_4_ctx_t *ctx) diff --git a/module/zcommon/zfs_fletcher_superscalar.c b/module/zcommon/zfs_fletcher_superscalar.c index fbbbf8060..153f5c7d7 100644 --- a/module/zcommon/zfs_fletcher_superscalar.c +++ b/module/zcommon/zfs_fletcher_superscalar.c @@ -41,6 +41,7 @@ * SOFTWARE. */ +#include #include #include #include diff --git a/module/zcommon/zfs_fletcher_superscalar4.c b/module/zcommon/zfs_fletcher_superscalar4.c index 97fdb7b7d..75e6a3baf 100644 --- a/module/zcommon/zfs_fletcher_superscalar4.c +++ b/module/zcommon/zfs_fletcher_superscalar4.c @@ -41,6 +41,7 @@ * SOFTWARE. */ +#include #include #include #include diff --git a/module/zfs/vdev_raidz_math_avx512bw.c b/module/zfs/vdev_raidz_math_avx512bw.c index 38cdbedf7..f06b46902 100644 --- a/module/zfs/vdev_raidz_math_avx512bw.c +++ b/module/zfs/vdev_raidz_math_avx512bw.c @@ -27,10 +27,14 @@ #if defined(__x86_64) && defined(HAVE_AVX512BW) +#include #include #include + +#ifdef __linux__ #define __asm __asm__ __volatile__ +#endif #define _REG_CNT(_0, _1, _2, _3, _4, _5, _6, _7, N, ...) N #define REG_CNT(r...) _REG_CNT(r, 8, 7, 6, 5, 4, 3, 2, 1) diff --git a/module/zfs/vdev_raidz_math_ssse3.c b/module/zfs/vdev_raidz_math_ssse3.c index d5776a38a..5ddc079a4 100644 --- a/module/zfs/vdev_raidz_math_ssse3.c +++ b/module/zfs/vdev_raidz_math_ssse3.c @@ -29,7 +29,9 @@ #include #include +#ifdef __linux__ #define __asm __asm__ __volatile__ +#endif #define _REG_CNT(_0, _1, _2, _3, _4, _5, _6, _7, N, ...) N #define REG_CNT(r...) _REG_CNT(r, 8, 7, 6, 5, 4, 3, 2, 1)