aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2020-07-31 21:30:31 -0700
committerGitHub <[email protected]>2020-07-31 21:30:31 -0700
commit47ed79ff60945e0c5d8ccb56f0d29a893e1261ac (patch)
treeaf032038ad66d947e333ea55cf1383ce2627ea8b /include
parent0cc3454821879396c38d8c557ab918a70afd919b (diff)
Changes to make openzfs build within FreeBSD buildworld
A collection of header changes to enable FreeBSD to build with vendored OpenZFS. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #10635
Diffstat (limited to 'include')
-rw-r--r--include/os/freebsd/spl/sys/byteorder.h14
-rw-r--r--include/os/freebsd/spl/sys/ccompile.h7
-rw-r--r--include/os/freebsd/spl/sys/kmem.h2
-rw-r--r--include/os/freebsd/spl/sys/simd_x86.h4
-rw-r--r--include/os/freebsd/spl/sys/types.h2
-rw-r--r--include/os/freebsd/spl/sys/vnode.h7
-rw-r--r--include/os/freebsd/zfs/sys/sha2.h2
-rw-r--r--include/os/freebsd/zfs/sys/zfs_context_os.h4
8 files changed, 34 insertions, 8 deletions
diff --git a/include/os/freebsd/spl/sys/byteorder.h b/include/os/freebsd/spl/sys/byteorder.h
index fd6b0269d..ae767242b 100644
--- a/include/os/freebsd/spl/sys/byteorder.h
+++ b/include/os/freebsd/spl/sys/byteorder.h
@@ -84,9 +84,23 @@
#define htonll(x) BMASK_64(x)
#define ntohll(x) BMASK_64(x)
#else
+#ifndef __LP64__
+static __inline__ uint64_t
+htonll(uint64_t n)
+{
+ return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32));
+}
+
+static __inline__ uint64_t
+ntohll(uint64_t n)
+{
+ return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32));
+}
+#else
#define htonll(x) BSWAP_64(x)
#define ntohll(x) BSWAP_64(x)
#endif
+#endif
#define BE_IN32(xa) htonl(*((uint32_t *)(void *)(xa)))
diff --git a/include/os/freebsd/spl/sys/ccompile.h b/include/os/freebsd/spl/sys/ccompile.h
index c594c928f..c90813b04 100644
--- a/include/os/freebsd/spl/sys/ccompile.h
+++ b/include/os/freebsd/spl/sys/ccompile.h
@@ -202,11 +202,14 @@ typedef int enum_t;
#define ENODATA EINVAL
-#define __XSI_VISIBLE 1000
#define __BSD_VISIBLE 1
+#ifndef IN_BASE
#define __POSIX_VISIBLE 201808
+#define __XSI_VISIBLE 1000
+#endif
#define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
#define open64 open
+#define mmap64 mmap
#define pwrite64 pwrite
#define ftruncate64 ftruncate
#define lseek64 lseek
@@ -257,7 +260,9 @@ typedef int enum_t;
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
#define RLIM64_INFINITY RLIM_INFINITY
+#ifndef HAVE_ERESTART
#define ERESTART EAGAIN
+#endif
#define ABS(a) ((a) < 0 ? -(a) : (a))
#endif
diff --git a/include/os/freebsd/spl/sys/kmem.h b/include/os/freebsd/spl/sys/kmem.h
index 943b18f03..6155ce6b0 100644
--- a/include/os/freebsd/spl/sys/kmem.h
+++ b/include/os/freebsd/spl/sys/kmem.h
@@ -32,7 +32,7 @@
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/vmem.h>
-#include <sys/vmmeter.h>
+#include <sys/counter.h>
#include <vm/uma.h>
#include <vm/vm.h>
diff --git a/include/os/freebsd/spl/sys/simd_x86.h b/include/os/freebsd/spl/sys/simd_x86.h
index da846fcbe..a35e205d5 100644
--- a/include/os/freebsd/spl/sys/simd_x86.h
+++ b/include/os/freebsd/spl/sys/simd_x86.h
@@ -29,7 +29,11 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/systm.h>
+#ifdef __i386__
+#include <x86/fpu.h>
+#else
#include <machine/fpu.h>
+#endif
#include <x86/x86_var.h>
#include <x86/specialreg.h>
diff --git a/include/os/freebsd/spl/sys/types.h b/include/os/freebsd/spl/sys/types.h
index c06c963d6..3f8953628 100644
--- a/include/os/freebsd/spl/sys/types.h
+++ b/include/os/freebsd/spl/sys/types.h
@@ -73,7 +73,7 @@ typedef off_t off64_t;
typedef id_t taskid_t;
typedef id_t projid_t;
typedef id_t poolid_t;
-typedef id_t zoneid_t;
+typedef uint_t zoneid_t;
typedef id_t ctid_t;
typedef mode_t o_mode_t;
typedef uint64_t pgcnt_t;
diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h
index b9fae99ad..6a6146132 100644
--- a/include/os/freebsd/spl/sys/vnode.h
+++ b/include/os/freebsd/spl/sys/vnode.h
@@ -49,7 +49,9 @@ enum symfollow { NO_FOLLOW = NOFOLLOW };
#include <sys/proc.h>
#include <sys/vnode_impl.h>
+#ifndef IN_BASE
#include_next <sys/vnode.h>
+#endif
#include <sys/mount.h>
#include <sys/cred.h>
#include <sys/fcntl.h>
@@ -70,11 +72,14 @@ typedef struct vop_vector vnodeops_t;
#define rootvfs (rootvnode == NULL ? NULL : rootvnode->v_mount)
+
+#ifndef IN_BASE
static __inline int
vn_is_readonly(vnode_t *vp)
{
return (vp->v_mount->mnt_flag & MNT_RDONLY);
}
+#endif
#define vn_vfswlock(vp) (0)
#define vn_vfsunlock(vp) do { } while (0)
#define vn_ismntpt(vp) \
@@ -166,6 +171,7 @@ vn_is_readonly(vnode_t *vp)
#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|\
AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
+#ifndef IN_BASE
static __inline void
vattr_init_mask(vattr_t *vap)
{
@@ -187,6 +193,7 @@ vattr_init_mask(vattr_t *vap)
if (vap->va_flags != VNOVAL)
vap->va_mask |= AT_XVATTR;
}
+#endif
#define RLIM64_INFINITY 0
diff --git a/include/os/freebsd/zfs/sys/sha2.h b/include/os/freebsd/zfs/sys/sha2.h
index 9d848e1fc..e3923e4ca 100644
--- a/include/os/freebsd/zfs/sys/sha2.h
+++ b/include/os/freebsd/zfs/sys/sha2.h
@@ -116,7 +116,7 @@ SHA2Init(uint64_t mech, SHA2_CTX *c)
SHA512_256_Init(&c->SHA512_ctx);
break;
default:
- panic("unknown mechanism %lu", mech);
+ panic("unknown mechanism %ju", (uintmax_t)mech);
}
c->algotype = (uint32_t)mech;
}
diff --git a/include/os/freebsd/zfs/sys/zfs_context_os.h b/include/os/freebsd/zfs/sys/zfs_context_os.h
index 8da3374a6..7dd298564 100644
--- a/include/os/freebsd/zfs/sys/zfs_context_os.h
+++ b/include/os/freebsd/zfs/sys/zfs_context_os.h
@@ -88,8 +88,4 @@ typedef int fstrans_cookie_t;
typedef struct opensolaris_utsname utsname_t;
extern utsname_t *utsname(void);
extern int spa_import_rootpool(const char *name);
-#else
-#if BYTE_ORDER != BIG_ENDIAN
-#undef _BIG_ENDIAN
-#endif
#endif