From be627fc84711d2382d179392e3313f9fda8d24a3 Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Wed, 4 Dec 2019 13:12:57 -0800 Subject: [PATCH] Refactor zfs_context.h to build on FreeBSD - on Linux move Linux specific headers to zfs_context_os.h - on FreeBSD move FreeBSD specific definitions to zfs_context_os.h - remove duplicate tsd_ definitions - remove unused AT_TYPE Reviewed-by: Jorgen Lundman Reviewed-by: Brian Behlendorf Reviewed-by: Don Brady Signed-off-by: Matt Macy Closes #9668 --- include/os/linux/zfs/sys/Makefile.am | 1 + .../os/linux/zfs/sys/zfs_context_os.h | 12 ++++----- include/sys/zfs_context.h | 22 +++------------- lib/libspl/include/os/linux/sys/Makefile.am | 3 ++- .../include/os/linux/sys/zfs_context_os.h | 25 +++++++++++++++++++ lib/libspl/include/sys/Makefile.am | 1 - 6 files changed, 38 insertions(+), 26 deletions(-) rename lib/libspl/include/sys/bitmap.h => include/os/linux/zfs/sys/zfs_context_os.h (83%) create mode 100644 lib/libspl/include/os/linux/sys/zfs_context_os.h diff --git a/include/os/linux/zfs/sys/Makefile.am b/include/os/linux/zfs/sys/Makefile.am index cb309d7fc9..16df22c6c0 100644 --- a/include/os/linux/zfs/sys/Makefile.am +++ b/include/os/linux/zfs/sys/Makefile.am @@ -16,6 +16,7 @@ KERNEL_H = \ $(top_srcdir)/include/os/linux/zfs/sys/trace_zil.h \ $(top_srcdir)/include/os/linux/zfs/sys/trace_zio.h \ $(top_srcdir)/include/os/linux/zfs/sys/trace_zrlock.h \ + $(top_srcdir)/include/os/linux/zfs/sys/zfs_context_os.h \ $(top_srcdir)/include/os/linux/zfs/sys/zfs_ctldir.h \ $(top_srcdir)/include/os/linux/zfs/sys/zfs_dir.h \ $(top_srcdir)/include/os/linux/zfs/sys/zfs_vfsops.h \ diff --git a/lib/libspl/include/sys/bitmap.h b/include/os/linux/zfs/sys/zfs_context_os.h similarity index 83% rename from lib/libspl/include/sys/bitmap.h rename to include/os/linux/zfs/sys/zfs_context_os.h index 95122ab8b4..9e5fdd79f0 100644 --- a/lib/libspl/include/sys/bitmap.h +++ b/include/os/linux/zfs/sys/zfs_context_os.h @@ -19,12 +19,12 @@ * * CDDL HEADER END */ -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#ifndef _LIBSPL_SYS_BITMAP_H -#define _LIBSPL_SYS_BITMAP_H +#ifndef ZFS_CONTEXT_OS_H +#define ZFS_CONTEXT_OS_H + +#include +#include +#include #endif diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index c14d92a2cb..5a67ca677b 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -29,7 +29,6 @@ #define _SYS_ZFS_CONTEXT_H #ifdef __KERNEL__ - #include #include #include @@ -48,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -61,11 +59,8 @@ #include #include #include -#include -#include #include -#include - +#include #else /* _KERNEL */ #define _SYS_MUTEX_H @@ -88,7 +83,6 @@ #include #include #include -#include #include #include #include @@ -101,7 +95,6 @@ #include #include #include -#include #include #include #include @@ -117,6 +110,8 @@ #include #include +#include + /* * Stack */ @@ -333,15 +328,7 @@ extern void cv_broadcast(kcondvar_t *cv); */ #define tsd_get(k) pthread_getspecific(k) #define tsd_set(k, v) pthread_setspecific(k, v) -#define tsd_create(kp, d) pthread_key_create(kp, d) -#define tsd_destroy(kp) /* nothing */ - -/* - * Thread-specific data - */ -#define tsd_get(k) pthread_getspecific(k) -#define tsd_set(k, v) pthread_setspecific(k, v) -#define tsd_create(kp, d) pthread_key_create(kp, d) +#define tsd_create(kp, d) pthread_key_create((pthread_key_t *)kp, d) #define tsd_destroy(kp) /* nothing */ /* @@ -562,7 +549,6 @@ typedef struct vsecattr { size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ } vsecattr_t; -#define AT_TYPE 0x00001 #define AT_MODE 0x00002 #define AT_UID 0x00004 #define AT_GID 0x00008 diff --git a/lib/libspl/include/os/linux/sys/Makefile.am b/lib/libspl/include/os/linux/sys/Makefile.am index f8b6d9fae8..49e9f730ef 100644 --- a/lib/libspl/include/os/linux/sys/Makefile.am +++ b/lib/libspl/include/os/linux/sys/Makefile.am @@ -7,4 +7,5 @@ libspl_HEADERS = \ $(top_srcdir)/lib/libspl/include/os/linux/sys/param.h \ $(top_srcdir)/lib/libspl/include/os/linux/sys/stat.h \ $(top_srcdir)/lib/libspl/include/os/linux/sys/sysmacros.h \ - $(top_srcdir)/lib/libspl/include/os/linux/sys/uio.h + $(top_srcdir)/lib/libspl/include/os/linux/sys/uio.h \ + $(top_srcdir)/lib/libspl/include/os/linux/sys/zfs_context_os.h diff --git a/lib/libspl/include/os/linux/sys/zfs_context_os.h b/lib/libspl/include/os/linux/sys/zfs_context_os.h new file mode 100644 index 0000000000..008e57df4e --- /dev/null +++ b/lib/libspl/include/os/linux/sys/zfs_context_os.h @@ -0,0 +1,25 @@ +/* + * 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 http://www.opensolaris.org/os/licensing. + * 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 + */ + +#ifndef ZFS_CONTEXT_OS_H +#define ZFS_CONTEXT_OS_H +#endif diff --git a/lib/libspl/include/sys/Makefile.am b/lib/libspl/include/sys/Makefile.am index a83fc025eb..8f9c2fa991 100644 --- a/lib/libspl/include/sys/Makefile.am +++ b/lib/libspl/include/sys/Makefile.am @@ -4,7 +4,6 @@ libspldir = $(includedir)/libspl/sys libspl_HEADERS = \ $(top_srcdir)/lib/libspl/include/sys/acl.h \ $(top_srcdir)/lib/libspl/include/sys/acl_impl.h \ - $(top_srcdir)/lib/libspl/include/sys/bitmap.h \ $(top_srcdir)/lib/libspl/include/sys/callb.h \ $(top_srcdir)/lib/libspl/include/sys/cmn_err.h \ $(top_srcdir)/lib/libspl/include/sys/cred.h \