Skip to content

Commit b9d2e77

Browse files
robnbehlendorf
authored andcommitted
libspl: common sysmacros.h
Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #17861
1 parent 248c7ed commit b9d2e77

File tree

5 files changed

+35
-36
lines changed

5 files changed

+35
-36
lines changed

include/sys/zfs_context.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,29 +145,8 @@ extern "C" {
145145
typedef off_t loff_t;
146146
#endif
147147

148-
/*
149-
* Random stuff
150-
*/
151-
#define max_ncpus 64
152-
#define boot_ncpus (sysconf(_SC_NPROCESSORS_ONLN))
153-
154-
/*
155-
* Process priorities as defined by setpriority(2) and getpriority(2).
156-
*/
157-
#define minclsyspri 19
158-
#define defclsyspri 0
159-
/* Write issue taskq priority. */
160-
#define wtqclsyspri -19
161-
#define maxclsyspri -20
162-
163-
#define CPU_SEQID ((uintptr_t)pthread_self() & (max_ncpus - 1))
164-
#define CPU_SEQID_UNSTABLE CPU_SEQID
165-
166148
#define NN_NUMBUF_SZ (6)
167149

168-
extern int highbit64(uint64_t i);
169-
extern int lowbit64(uint64_t i);
170-
171150
/*
172151
* Kernel modules
173152
*/

lib/libspl/include/Makefile.am

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ libspl_sys_HEADERS = \
6161
%D%/sys/stdtypes.h \
6262
%D%/sys/string.h \
6363
%D%/sys/sunddi.h \
64+
%D%/sys/sysmacros.h \
6465
%D%/sys/systeminfo.h \
6566
%D%/sys/systm.h \
6667
%D%/sys/thread.h \
@@ -88,8 +89,7 @@ libspl_sys_HEADERS += \
8889
%D%/os/linux/sys/mount.h \
8990
%D%/os/linux/sys/param.h \
9091
%D%/os/linux/sys/stat.h \
91-
%D%/os/linux/sys/sysmacros.h \
92-
%D%/os/linux/sys/vfs.h \
92+
%D%/os/linux/sys/vfs.h
9393

9494
libspl_ia32_HEADERS = \
9595
%D%/os/linux/sys/ia32/asm_linkage.h
@@ -104,7 +104,6 @@ libspl_sys_HEADERS += \
104104
%D%/os/freebsd/sys/mount.h \
105105
%D%/os/freebsd/sys/param.h \
106106
%D%/os/freebsd/sys/stat.h \
107-
%D%/os/freebsd/sys/sysmacros.h \
108107
%D%/os/freebsd/sys/vfs.h
109108

110109
libspl_ia32_HEADERS = \

lib/libspl/include/os/freebsd/sys/sysmacros.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/libspl/include/os/linux/sys/sysmacros.h renamed to lib/libspl/include/sys/sysmacros.h

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
* CDDL HEADER START
44
*
55
* The contents of this file are subject to the terms of the
6-
* Common Development and Distribution License, Version 1.0 only
7-
* (the "License"). You may not use this file except in compliance
8-
* with the License.
6+
* Common Development and Distribution License (the "License").
7+
* You may not use this file except in compliance with the License.
98
*
109
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1110
* or https://opensource.org/licenses/CDDL-1.0.
@@ -21,14 +20,26 @@
2120
* CDDL HEADER END
2221
*/
2322
/*
24-
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25-
* Use is subject to license terms.
23+
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24+
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25+
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
26+
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
2627
*/
2728

2829
#ifndef _LIBSPL_SYS_SYSMACROS_H
2930
#define _LIBSPL_SYS_SYSMACROS_H
3031

32+
#include <stdint.h>
33+
34+
#ifdef __linux__
35+
/*
36+
* On Linux, we need the system-provided sysmacros.h to get the makedev(),
37+
* major() and minor() definitions for makedevice() below. FreeBSD does not
38+
* have this header, so include_next won't find it and will abort. So, we
39+
* protect it with a platform check.
40+
*/
3141
#include_next <sys/sysmacros.h>
42+
#endif
3243

3344
/* common macros */
3445
#ifndef MIN
@@ -94,10 +105,22 @@
94105
#define P2SAMEHIGHBIT_TYPED(x, y, type) \
95106
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
96107

108+
#define max_ncpus 64
109+
#define boot_ncpus (sysconf(_SC_NPROCESSORS_ONLN))
97110

98-
/* avoid any possibility of clashing with <stddef.h> version */
99-
#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof)
100-
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
101-
#endif
111+
/*
112+
* Process priorities as defined by setpriority(2) and getpriority(2).
113+
*/
114+
#define minclsyspri 19
115+
#define defclsyspri 0
116+
/* Write issue taskq priority. */
117+
#define wtqclsyspri -19
118+
#define maxclsyspri -20
119+
120+
#define CPU_SEQID ((uintptr_t)pthread_self() & (max_ncpus - 1))
121+
#define CPU_SEQID_UNSTABLE CPU_SEQID
122+
123+
extern int lowbit64(uint64_t i);
124+
extern int highbit64(uint64_t i);
102125

103-
#endif /* _LIBSPL_SYS_SYSMACROS_H */
126+
#endif /* _SYS_SYSMACROS_H */

scripts/spdxcheck.pl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
include/os/freebsd/spl/sys/trace_zfs.h
128128
include/os/freebsd/zfs/sys/zpl.h
129129
include/os/linux/kernel/linux/page_compat.h
130-
lib/libspl/include/os/freebsd/sys/sysmacros.h
131130
lib/libspl/include/sys/string.h
132131
lib/libspl/include/sys/trace_spl.h
133132
lib/libzdb/libzdb.c

0 commit comments

Comments
 (0)