From 8bc374af012c703cbd62ad0aa5820c8889d0bcbf Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 16 May 2019 17:45:04 +0200
Subject: [PATCH] Don't include the full <sys/signal.h> in includes that just
 need sigset_t.

Split it out into a separate header, <sys/_sigset_t.h> and include that
in <spawn.h> and <sys/select.h>.

This cleans up these two headers' name space considerably.
---
 include/spawn.h   |  7 ++++++-
 sys/sys/_sigset.h | 41 +++++++++++++++++++++++++++++++++++++++++
 sys/sys/select.h  | 22 ++++++++++------------
 sys/sys/signal.h  | 11 +++++------
 4 files changed, 62 insertions(+), 19 deletions(-)
 create mode 100644 sys/sys/_sigset.h

diff --git a/include/spawn.h b/include/spawn.h
index 38c785d430..149d18738b 100644
--- a/include/spawn.h
+++ b/include/spawn.h
@@ -30,8 +30,8 @@
 #define _SPAWN_H_
 
 #include <sys/cdefs.h>
-#include <sys/signal.h>
 #include <sys/stdint.h>
+#include <sys/_sigset.h>
 
 #ifndef _MODE_T_DECLARED
 typedef	__uint16_t	mode_t;
@@ -43,6 +43,11 @@ typedef	__pid_t		pid_t;
 #define	_PID_T_DECLARED
 #endif
 
+#ifndef _SIGSET_T_DECLARED
+typedef	struct __sigset	sigset_t;
+#define	_SIGSET_T_DECLARED
+#endif
+
 struct sched_param;
 
 typedef struct __posix_spawnattr		*posix_spawnattr_t;
diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h
new file mode 100644
index 0000000000..5b0ea95c7e
--- /dev/null
+++ b/sys/sys/_sigset.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019 The DragonFly Project.  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.
+ * 3. Neither the name of The DragonFly Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific, prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDERS 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.
+ */
+
+#ifndef	_SYS__SIGSET_H_
+#define	_SYS__SIGSET_H_
+
+#define	_SIG_WORDS	4
+
+struct __sigset {
+	unsigned int	__bits[_SIG_WORDS];
+};
+
+#endif /* _SYS__SIGSET_H_ */
diff --git a/sys/sys/select.h b/sys/sys/select.h
index 3d7d552db6..41b34321ff 100644
--- a/sys/sys/select.h
+++ b/sys/sys/select.h
@@ -34,24 +34,22 @@
 #define	_SYS_SELECT_H_
 
 #include <sys/cdefs.h>
-
-#ifndef _SYS_SIGNAL_H_
-#include <sys/signal.h>
-#endif
-#ifndef _SYS_TIME_H_
-#include <sys/time.h>
-#endif
-
 #include <sys/fd_set.h>
+#include <sys/_sigset.h>
 #include <sys/_timespec.h>
 #include <sys/_timeval.h>
 
+#ifndef _SIGSET_T_DECLARED
+typedef	struct __sigset	sigset_t;
+#define	_SIGSET_T_DECLARED
+#endif
+
 __BEGIN_DECLS
 int	select(int, fd_set * __restrict, fd_set * __restrict,
-	       fd_set * __restrict, struct timeval * __restrict);
-int	 pselect(int, fd_set * __restrict, fd_set * __restrict,
-		fd_set * __restrict, const struct timespec * __restrict,
-		const sigset_t * __restrict);
+	    fd_set * __restrict, struct timeval * __restrict);
+int	pselect(int, fd_set * __restrict, fd_set * __restrict,
+	    fd_set * __restrict, const struct timespec * __restrict,
+	    const sigset_t * __restrict);
 __END_DECLS
 
 #endif	/* !_SYS_SELECT_H_ */
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index 04d8badb4a..6bcc7d1312 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -40,12 +40,12 @@
 
 #include <sys/cdefs.h>
 #include <sys/_pthreadtypes.h>
+#include <sys/_sigset.h>
 #include <machine/stdint.h>	/* for __ types */
 
 /*
  * sigset_t macros.
  */
-#define	_SIG_WORDS	4
 #define	_SIG_MAXSIG	128
 #define	_SIG_IDX(sig)	((sig) - 1)
 #define	_SIG_WORD(sig)	(_SIG_IDX(sig) >> 5)
@@ -268,11 +268,10 @@ typedef struct __siginfo {
 } siginfo_t;
 #endif /* __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE */
 
-/* #if __POSIX_VISIBLE */
-typedef struct __sigset {
-	unsigned int	__bits[_SIG_WORDS];
-} sigset_t;
-/* #endif */
+#ifndef _SIGSET_T_DECLARED
+typedef	struct __sigset	sigset_t;
+#define	_SIGSET_T_DECLARED
+#endif
 
 /*
  * XXX - there are some nasty dependencies on include file order. Now that
-- 
2.21.0

