From d93c196c38ad376938df9c5cca9c3b827291a0c2 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sun, 11 Aug 2019 11:06:42 +0200
Subject: [PATCH] <machine/stdint.h>: Remove __boolean_t.

It is not machine dependent so no __type is required.

However, some code was abusing __boolean_t kind of, and I had to change
that to using bool.

It would be better if we had a <sys/stdbool.h> at this point.
---
 sys/cpu/x86_64/include/stdint.h |  5 -----
 sys/net/netmsg.h                | 10 +++++++---
 sys/net/radix.h                 |  9 +++++----
 sys/net/route.h                 |  2 +-
 sys/sys/objcache.h              | 15 +++++++++------
 sys/sys/systimer.h              | 21 ++++++++-------------
 sys/sys/types.h                 |  9 +++++----
 usr.bin/netstat/mbuf.c          |  2 --
 8 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/sys/cpu/x86_64/include/stdint.h b/sys/cpu/x86_64/include/stdint.h
index d22509e26e..60be7fe741 100644
--- a/sys/cpu/x86_64/include/stdint.h
+++ b/sys/cpu/x86_64/include/stdint.h
@@ -52,11 +52,6 @@ typedef	short		__int16_t;
 typedef	unsigned short	__uint16_t;
 typedef	int		__int32_t;
 typedef	unsigned int	__uint32_t;
-#if defined(__cplusplus) || __STDC_VERSION__ < 199901L && !__GNUC_PREREQ__(3, 0)
-typedef	int		__boolean_t;
-#else
-typedef	_Bool		__boolean_t;
-#endif
 
 #ifdef __LP64__
 typedef	long		__int64_t;
diff --git a/sys/net/netmsg.h b/sys/net/netmsg.h
index b3f1787427..498650716f 100644
--- a/sys/net/netmsg.h
+++ b/sys/net/netmsg.h
@@ -26,13 +26,17 @@
  * 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.
- *
- * $DragonFly: src/sys/net/netmsg.h,v 1.10 2008/10/27 02:56:30 sephe Exp $
  */
 
 #ifndef _NET_NETMSG_H_
 #define _NET_NETMSG_H_
 
+#ifdef _KERNEL
+#include <sys/types.h>
+#else
+#include <stdbool.h>
+#endif
+
 #ifndef _SYS_THREAD_H_
 #include <sys/thread.h>
 #endif
@@ -110,7 +114,7 @@ struct netmsg_pr_timeout {
 };
 
 struct netmsg_so_notify;
-typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg_so_notify *);
+typedef bool (*msg_predicate_fn_t)(struct netmsg_so_notify *);
 
 struct netmsg_so_notify {
 	struct netmsg_base	base;
diff --git a/sys/net/radix.h b/sys/net/radix.h
index bd2e134b56..034a22facb 100644
--- a/sys/net/radix.h
+++ b/sys/net/radix.h
@@ -28,14 +28,15 @@
  *
  *	@(#)radix.h	8.2 (Berkeley) 10/31/94
  * $FreeBSD: src/sys/net/radix.h,v 1.16.2.1 2000/05/03 19:17:11 wollman Exp $
- * $DragonFly: src/sys/net/radix.h,v 1.12 2006/09/05 03:48:12 dillon Exp $
  */
 
 #ifndef _NET_RADIX_H_
 #define	_NET_RADIX_H_
 
-#ifndef _SYS_TYPES_H_
+#ifdef _KERNEL
 #include <sys/types.h>
+#else
+#include <stdbool.h>
 #endif
 
 #ifdef MALLOC_DECLARE
@@ -184,8 +185,8 @@ struct radix_node_head {
 void			 rn_init (void);
 int			 rn_inithead (void **, struct radix_node_head *, int);
 struct radix_node_head	*rn_cpumaskhead(int cpu);
-__boolean_t		 rn_refines (char *, char *);
-struct radix_node	*rn_addmask (char *, __boolean_t, int,
+bool			 rn_refines (char *, char *);
+struct radix_node	*rn_addmask (char *, bool, int,
 				     struct radix_node_head *),
 			*rn_addroute (char *, char *, struct radix_node_head *,
 				      struct radix_node [2]),
diff --git a/sys/net/route.h b/sys/net/route.h
index ade7258ee9..a16cd74263 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -354,7 +354,7 @@ void	 rtalloc (struct route *);
 void	 rtalloc_ign (struct route *, u_long);
 
 struct rtentry *
-	 _rtlookup (struct sockaddr *, __boolean_t, u_long);
+	 _rtlookup (struct sockaddr *, boolean_t, u_long);
 #define		RTL_REPORTMSG	TRUE
 #define		RTL_DONTREPORT	FALSE
 
diff --git a/sys/sys/objcache.h b/sys/sys/objcache.h
index 8f334ba3f0..46014db157 100644
--- a/sys/sys/objcache.h
+++ b/sys/sys/objcache.h
@@ -33,18 +33,21 @@
 #ifndef _SYS_OBJCACHE_H_
 #define _SYS_OBJCACHE_H_
 
-#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
-
-#ifndef _SYS_TYPES_H_
+#ifdef _KERNEL
 #include <sys/types.h>
+#else
+#include <stdbool.h>
 #endif
+
+#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
+
 #ifndef _SYS_MALLOC_H_
 #include <sys/malloc.h>
 #endif
 
 #define OC_MFLAGS	0x0000ffff	/* same as malloc flags */
 
-typedef __boolean_t (objcache_ctor_fn)(void *obj, void *privdata, int ocflags);
+typedef bool (objcache_ctor_fn)(void *obj, void *privdata, int ocflags);
 typedef void (objcache_dtor_fn)(void *obj, void *privdata);
 
 /*
@@ -70,13 +73,13 @@ struct objcache
 			  int cluster_limit, int nom_cache,
 			  objcache_ctor_fn *ctor, objcache_dtor_fn *dtor,
 			  void *privdata);
-void	objcache_set_cluster_limit(struct objcache *oc, int cluster_limit);
+void	 objcache_set_cluster_limit(struct objcache *oc, int cluster_limit);
 void	*objcache_get(struct objcache *oc, int ocflags);
 void	 objcache_put(struct objcache *oc, void *obj);
 void	 objcache_dtor(struct objcache *oc, void *obj);
 void	 objcache_populate_linear(struct objcache *oc, void *elts, int nelts,
 				  int size);
-__boolean_t objcache_reclaimlist(struct objcache *oc[], int nlist, int ocflags);
+bool	 objcache_reclaimlist(struct objcache *oc[], int nlist, int ocflags);
 void	 objcache_destroy(struct objcache *oc);
 
 #endif	/* !_KERNEL */
diff --git a/sys/sys/systimer.h b/sys/sys/systimer.h
index a8d830120e..e8e1f85224 100644
--- a/sys/sys/systimer.h
+++ b/sys/sys/systimer.h
@@ -32,28 +32,23 @@
  * 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.
- * 
- * $DragonFly: src/sys/sys/systimer.h,v 1.13 2007/04/30 06:57:36 dillon Exp $
  */
 
 #ifndef _SYS_SYSTIMER_H_
 #define _SYS_SYSTIMER_H_
 
-#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
-
-#ifndef _SYS_TYPES_H_
+#ifdef _KERNEL
 #include <sys/types.h>
+#else
+#include <stdbool.h>
 #endif
+
+#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
+
 #ifndef _SYS_QUEUE_H_
 #include <sys/queue.h>
 #endif
 
-/* XXX fix sys/kinfo.h */
-#ifndef __BOOLEAN_T_DEFINED__
-#define __BOOLEAN_T_DEFINED__
-typedef	__boolean_t	boolean_t;
-#endif
-
 struct intrframe;
 
 typedef __uint32_t	sysclock_t;
@@ -213,7 +208,7 @@ struct cputimer_intr {
 	void		(*pmfixup)
 			(struct cputimer_intr *);
 	void		(*initclock)
-			(struct cputimer_intr *, boolean_t);
+			(struct cputimer_intr *, bool);
 	void		(*pcpuhand)
 			(struct cputimer_intr *);
 	SLIST_ENTRY(cputimer_intr) next;
@@ -264,7 +259,7 @@ void cputimer_intr_default_restart(struct cputimer_intr *);
 void cputimer_intr_default_config(struct cputimer_intr *,
 				  const struct cputimer *);
 void cputimer_intr_default_pmfixup(struct cputimer_intr *);
-void cputimer_intr_default_initclock(struct cputimer_intr *, boolean_t);
+void cputimer_intr_default_initclock(struct cputimer_intr *, bool);
 
 /*
  * Interrupt cputimer external interfaces
diff --git a/sys/sys/types.h b/sys/sys/types.h
index 54495f7d9f..7b3d4d5eae 100644
--- a/sys/sys/types.h
+++ b/sys/sys/types.h
@@ -140,9 +140,10 @@ typedef	int		mqd_t;		/* message queue descriptor */
 
 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
 
-#ifndef __BOOLEAN_T_DEFINED__
-#define	__BOOLEAN_T_DEFINED__
-typedef	__boolean_t	boolean_t;
+#if defined(__cplusplus) || __STDC_VERSION__ < 199901L && !__GNUC_PREREQ__(3, 0)
+typedef	int		boolean_t;
+#else
+typedef	_Bool		boolean_t;
 #endif
 
 typedef	u_int64_t	uoff_t;
@@ -152,7 +153,7 @@ typedef	u_int64_t	uoff_t;
 #define	__bool_true_false_are_defined	1
 #define	false	0
 #define	true	1
-#if __STDC_VERSION__ < 199901L && __GNUC__ < 3
+#if __STDC_VERSION__ < 199901L && !__GNUC_PREREQ__(3, 0)
 typedef	int	_Bool;
 #endif
 typedef	_Bool	bool;
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 10c39c741a..38b8fc0df4 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -28,7 +28,6 @@
  *
  * @(#)mbuf.c	8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.bin/netstat/mbuf.c,v 1.17.2.3 2001/08/10 09:07:09 ru Exp $
- * $DragonFly: src/usr.bin/netstat/mbuf.c,v 1.7 2006/10/09 22:30:48 hsu Exp $
  */
 
 #define _KERNEL_STRUCTURES
@@ -44,7 +43,6 @@
 #include "netstat.h"
 
 #define	YES	1
-typedef int bool;
 
 static struct mbtypenames {
 	int	mt_type;
-- 
2.22.0

