tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

-D_NETBSD_SOURCE makes headers uncompilable



Hello,

A few of the traditional BSD origin headers, use u_{char,int,long} which
are not defined in <sys/types.h> if _NETBSD_SOURCE is defined. There are
four choices:

1. Leave things alone; it's been broken forever and seems harmless. Autoconf
   bitches.
2. Fix all the headers to use the full types; intrusive will introduce diffs
   with other Unixes and upstreams.
3. Provide local definitions of the needed types on each header. Messy, error
   prone.
4. Put the definition of those types in a separate header (<sys/utypes.h>)
   and include this header from other headers that require it. This is what
   I've chosen to implement in this patch and I'd like to commit.
5. ???

Comments?

christos

Index: include/bm.h
===================================================================
RCS file: /cvsroot/src/include/bm.h,v
retrieving revision 1.5
diff -u -u -r1.5 bm.h
--- include/bm.h	3 Feb 2005 04:39:32 -0000	1.5
+++ include/bm.h	22 Jan 2016 18:53:53 -0000
@@ -37,6 +37,8 @@
 #ifndef _BM_H_
 #define	_BM_H_
 
+#include <sys/utypes.h>
+
 typedef struct {
 	u_char	*pat;			/* pattern */
 	size_t	 patlen;		/* pattern length */
Index: include/ifaddrs.h
===================================================================
RCS file: /cvsroot/src/include/ifaddrs.h,v
retrieving revision 1.5
diff -u -u -r1.5 ifaddrs.h
--- include/ifaddrs.h	3 Feb 2005 04:39:32 -0000	1.5
+++ include/ifaddrs.h	22 Jan 2016 18:53:54 -0000
@@ -28,6 +28,8 @@
 #ifndef	_IFADDRS_H_
 #define	_IFADDRS_H_
 
+#include <sys/utypes.h>
+
 struct ifaddrs {
 	struct ifaddrs  *ifa_next;
 	char		*ifa_name;
Index: include/kvm.h
===================================================================
RCS file: /cvsroot/src/include/kvm.h,v
retrieving revision 1.16
diff -u -u -r1.16 kvm.h
--- include/kvm.h	12 Sep 2011 21:14:29 -0000	1.16
+++ include/kvm.h	22 Jan 2016 18:53:54 -0000
@@ -48,6 +48,7 @@
 #include <nlist.h>
 #include <sys/cdefs.h>
 #include <sys/types.h>
+#include <sys/utypes.h>
 #include <stdbool.h>
 #include <stdio.h>
 
Index: include/link_aout.h
===================================================================
RCS file: /cvsroot/src/include/link_aout.h,v
retrieving revision 1.21
diff -u -u -r1.21 link_aout.h
--- include/link_aout.h	28 Apr 2008 20:22:54 -0000	1.21
+++ include/link_aout.h	22 Jan 2016 18:53:54 -0000
@@ -42,6 +42,7 @@
 
 #include <dlfcn.h>			/* for Dl_info */
 #include <a.out.h>			/* for struct nlist */
+#include <sys/utypes.h>			/* for u_{int,long} */
 
 /*
  * A `Shared Object Descriptor' describes a shared object that is needed
Index: include/login_cap.h
===================================================================
RCS file: /cvsroot/src/include/login_cap.h,v
retrieving revision 1.11
diff -u -u -r1.11 login_cap.h
--- include/login_cap.h	11 Jan 2009 03:04:12 -0000	1.11
+++ include/login_cap.h	22 Jan 2016 18:53:54 -0000
@@ -64,6 +64,7 @@
 typedef int (*envfunc_t)(void *, const char *, const char *, int);
 
 #include <sys/cdefs.h>
+#include <sys/utypes.h>
 __BEGIN_DECLS
 struct passwd;
 
Index: include/nsswitch.h
===================================================================
RCS file: /cvsroot/src/include/nsswitch.h,v
retrieving revision 1.21
diff -u -u -r1.21 nsswitch.h
--- include/nsswitch.h	17 Jul 2011 20:54:34 -0000	1.21
+++ include/nsswitch.h	22 Jan 2016 18:53:54 -0000
@@ -33,6 +33,7 @@
 #define _NSSWITCH_H	1
 
 #include <sys/types.h>
+#include <sys/utypes.h>
 #include <stdarg.h>
 
 #define	NSS_MODULE_INTERFACE_VERSION	0
Index: include/res_update.h
===================================================================
RCS file: /cvsroot/src/include/res_update.h,v
retrieving revision 1.8
diff -u -u -r1.8 res_update.h
--- include/res_update.h	15 Nov 2012 18:49:37 -0000	1.8
+++ include/res_update.h	22 Jan 2016 18:53:54 -0000
@@ -25,6 +25,7 @@
 #define __RES_UPDATE_H
 
 #include <sys/types.h>
+#include <sys/utypes.h>
 #include <arpa/nameser.h>
 #include <sys/queue.h>
 #include <resolv.h>
Index: include/resolv.h
===================================================================
RCS file: /cvsroot/src/include/resolv.h,v
retrieving revision 1.40
diff -u -u -r1.40 resolv.h
--- include/resolv.h	7 Nov 2012 15:45:24 -0000	1.40
+++ include/resolv.h	22 Jan 2016 18:53:54 -0000
@@ -59,6 +59,7 @@
 # include <sys/bitypes.h>
 #else
 #include <sys/types.h>
+#include <sys/utypes.h>
 #endif
 #include <sys/cdefs.h>
 #include <sys/socket.h>
Index: include/arpa/inet.h
===================================================================
RCS file: /cvsroot/src/include/arpa/inet.h,v
retrieving revision 1.24
diff -u -u -r1.24 inet.h
--- include/arpa/inet.h	21 Jun 2008 20:12:49 -0000	1.24
+++ include/arpa/inet.h	22 Jan 2016 18:53:54 -0000
@@ -65,6 +65,7 @@
 #include <sys/cdefs.h>
 #include <sys/featuretest.h>
 #include <sys/types.h>
+#include <sys/utypes.h>
 
 #include <netinet/in.h>
 
Index: include/arpa/nameser.h
===================================================================
RCS file: /cvsroot/src/include/arpa/nameser.h,v
retrieving revision 1.25
diff -u -u -r1.25 nameser.h
--- include/arpa/nameser.h	12 Apr 2009 17:07:34 -0000	1.25
+++ include/arpa/nameser.h	22 Jan 2016 18:53:54 -0000
@@ -60,6 +60,7 @@
 # include <sys/bitypes.h>
 #else
 # include <sys/types.h>
+# include <sys/utypes.h>
 #endif
 #include <sys/cdefs.h>
 
Index: sys/sys/Makefile
===================================================================
RCS file: /cvsroot/src/sys/sys/Makefile,v
retrieving revision 1.157
diff -u -u -r1.157 Makefile
--- sys/sys/Makefile	17 Aug 2015 06:16:03 -0000	1.157
+++ sys/sys/Makefile	22 Jan 2016 18:53:54 -0000
@@ -42,7 +42,8 @@
 	tape.h termios.h time.h timeb.h timepps.h times.h timespec.h \
 	timex.h tls.h trace.h tree.h tty.h ttychars.h ttycom.h \
 	ttydefaults.h ttydev.h types.h \
-	ucontext.h ucred.h uio.h un.h unistd.h unpcb.h user.h utsname.h uuid.h \
+	ucontext.h ucred.h uio.h un.h unistd.h unpcb.h user.h utsname.h \
+	utypes.h uuid.h \
 	vadvise.h verified_exec.h videoio.h vmmeter.h vnode.h vnode_if.h \
 	wait.h wapbl.h wapbl_replay.h wdog.h xattr.h
 
Index: sys/sys/types.h
===================================================================
RCS file: /cvsroot/src/sys/sys/types.h,v
retrieving revision 1.95
diff -u -u -r1.95 types.h
--- sys/sys/types.h	27 Aug 2015 12:30:51 -0000	1.95
+++ sys/sys/types.h	22 Jan 2016 18:53:54 -0000
@@ -98,15 +98,7 @@
 #include <machine/endian.h>
 
 #if defined(_NETBSD_SOURCE)
-typedef	unsigned char	u_char;
-typedef	unsigned short	u_short;
-typedef	unsigned int	u_int;
-typedef	unsigned long	u_long;
-
-typedef unsigned char	unchar;		/* Sys V compatibility */
-typedef	unsigned short	ushort;		/* Sys V compatibility */
-typedef	unsigned int	uint;		/* Sys V compatibility */
-typedef unsigned long	ulong;		/* Sys V compatibility */
+#include <sys/utypes.h>
 #endif
 
 typedef	uint64_t	u_quad_t;	/* quads */

--- /dev/null	2016-01-22 13:51:21.000000000 -0500
+++ sys/sys/utypes.h	2016-01-22 13:47:05.000000000 -0500
@@ -0,0 +1,41 @@
+/*	$NetBSD$	*/
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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_UTYPES_H_
+#define _SYS_UTYPES_H_
+
+typedef	unsigned char	u_char;		/* BSD compatibility */
+typedef	unsigned short	u_short;	/* BSD compatibility */
+typedef	unsigned int	u_int;		/* BSD compatibility */
+typedef	unsigned long	u_long;		/* BSD compatibility */
+
+typedef	unsigned char	unchar;		/* Sys V compatibility */
+typedef	unsigned short	ushort;		/* Sys V compatibility */
+typedef	unsigned int	uint;		/* Sys V compatibility */
+typedef 	unsigned long	ulong;		/* Sys V compatibility */
+
+#endif /* _SYS_UTYPES_H_ */


Home | Main Index | Thread Index | Old Index