Subject: Re: getnameinfo type incompatibility
To: Christos Zoulas <christos@zoulas.com>
From: None <itojun@iijlab.net>
List: tech-net
Date: 05/23/2000 22:07:16
>| 	if sys/ansi.h a too much change before 1.5 (or many feels it needs 
>| 	more time to be baked), I'd propose the following:
>| 	- before 1.5, add socklen_t decl into machine/ansi.h
>| 	- after 1.5 branch, change #ifdef'ing model if necessary, move MI items
>| 	  from machine/ansi.h to sys/ansi.h, whatever.
>| 	I really need socklen_t in netdb.h quick.
>I'd like to talk a bit more with klaus and others before we commit the
>change and I'd like to reach a consensus... I think the best thing is
>to follow existing practice (<machine/ansi.h>) and fix it properly
>later.

	did you have chance to talk with klaus?

	just for comparison, this is a variant which has _BSD_SOCKLEN_T_
	in machine/ansi.h (the comment in sys/arch/*/include/ansi.h may be
	unnecessary).

	we have couple of proposals, and the attached diff does the first one.
	- add _BSD_SOCKLEN_T_ into machine/ansi.h
		/* in machine/ansi.h */
		#define _BSD_SOCKLEN_T_	unsigned int

		/* in other headers */
		#ifdef _BSD_SOCKLEN_T_
		typedef _BSD_SOCKLEN_T	socklen_t;
		#undef _BSD_SOCKLEN_T
		#endif

		pros: uniform way of declaring commonly used types
		cons: multiple declaration, in sys/arch/*/include/ansi.h
	- add _BSD_SOCKLEN_T_ into sys/ansi.h (thorpej)
		(same as above)

		pros: uniform way of declaring commonly used types
		pros: single declaration
	- use new into sys/ansi.h (klaus)
		/* in sys/ansi.h */
		typedef unsigned int __socklen_t;

		/* in other headers */
		#ifndef socklen_t
		typedef __socklent_t socklen_t;
		#define socklent_t socklen_t
		#endif

		pros: less reserved #define symbols
		pros: single declaration
		cons: why re-invent?

itojun


Index: include/netdb.h
===================================================================
RCS file: /cvsroot/basesrc/include/netdb.h,v
retrieving revision 1.17
diff -u -r1.17 netdb.h
--- netdb.h	2000/02/09 12:25:07	1.17
+++ netdb.h	2000/05/23 12:57:50
@@ -242,6 +242,15 @@
 #define SCOPE_DELIMITER '%'		/*KAME extension*/
 #endif /* !_XOPEN_SOURCE */
 
+/*
+ * Data types
+ */
+#if !defined(_XOPEN_SOURCE)
+#ifdef	_BSD_SOCKLEN_T_
+typedef	_BSD_SOCKLEN_T_ socklen_t;
+#undef	_BSD_SOCKLEN_T_
+#endif
+
 __BEGIN_DECLS
 void		endhostent __P((void));
 void		endnetent __P((void));
@@ -284,7 +293,7 @@
 #if !defined(_XOPEN_SOURCE)
 int		getaddrinfo __P((const char *, const char *,
 				 const struct addrinfo *, struct addrinfo **));
-int		getnameinfo __P((const struct sockaddr *, size_t, char *,
+int		getnameinfo __P((const struct sockaddr *, socklen_t, char *,
 				 size_t, char *, size_t, int));
 void		freeaddrinfo __P((struct addrinfo *));
 char		*gai_strerror __P((int));
Index: sys/sys/socket.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/socket.h,v
retrieving revision 1.54
diff -u -r1.54 socket.h
--- socket.h	2000/04/03 11:49:25	1.54
+++ socket.h	2000/05/23 12:57:53
@@ -74,7 +74,11 @@
 /*
  * Data types.
  */
-typedef	unsigned int	socklen_t;
+#include <machine/ansi.h>
+#ifdef	_BSD_SOCKLEN_T_
+typedef	_BSD_SOCKLEN_T_ socklen_t;
+#undef	_BSD_SOCKLEN_T_
+#endif
 
 /*
  * Socket types.
Index: sys/arch/alpha/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/include/ansi.h,v
retrieving revision 1.11
diff -u -r1.11 ansi.h
--- ansi.h	2000/05/10 17:53:45	1.11
+++ ansi.h	2000/05/23 12:57:53
@@ -70,6 +70,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		long		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned long	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/arm26/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/arm26/include/ansi.h,v
retrieving revision 1.1
diff -u -r1.1 ansi.h
--- ansi.h	2000/05/09 21:55:58	1.1
+++ ansi.h	2000/05/23 12:57:54
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/arm32/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/arm32/include/ansi.h,v
retrieving revision 1.7
diff -u -r1.7 ansi.h
--- ansi.h	1998/04/27 17:39:10	1.7
+++ ansi.h	2000/05/23 12:57:54
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/i386/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/include/ansi.h,v
retrieving revision 1.11
diff -u -r1.11 ansi.h
--- ansi.h	2000/05/05 00:21:48	1.11
+++ ansi.h	2000/05/23 12:58:03
@@ -65,6 +65,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/m68k/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/m68k/include/ansi.h,v
retrieving revision 1.9
diff -u -r1.9 ansi.h
--- ansi.h	1998/04/27 17:39:11	1.9
+++ ansi.h	2000/05/23 12:58:05
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/mips/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/ansi.h,v
retrieving revision 1.10
diff -u -r1.10 ansi.h
--- ansi.h	1999/04/24 08:10:33	1.10
+++ ansi.h	2000/05/23 12:58:08
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/pc532/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/pc532/include/ansi.h,v
retrieving revision 1.10
diff -u -r1.10 ansi.h
--- ansi.h	1998/04/27 17:39:11	1.10
+++ ansi.h	2000/05/23 12:58:11
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/powerpc/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/powerpc/include/ansi.h,v
retrieving revision 1.7
diff -u -r1.7 ansi.h
--- ansi.h	2000/02/27 17:50:21	1.7
+++ ansi.h	2000/05/23 12:58:15
@@ -58,6 +58,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 typedef struct {
 	char __gpr, __fpr, __pad[2];
Index: sys/arch/sh3/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sh3/include/ansi.h,v
retrieving revision 1.1
diff -u -r1.1 ansi.h
--- ansi.h	1999/09/13 10:31:14	1.1
+++ ansi.h	2000/05/23 12:58:16
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/sparc/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc/include/ansi.h,v
retrieving revision 1.9
diff -u -r1.9 ansi.h
--- ansi.h	1999/06/05 12:54:23	1.9
+++ ansi.h	2000/05/23 12:58:16
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		long		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned long	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/sparc64/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc64/include/ansi.h,v
retrieving revision 1.3
diff -u -r1.3 ansi.h
--- ansi.h	1998/07/31 15:30:40	1.3
+++ ansi.h	2000/05/23 12:58:17
@@ -59,6 +59,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		long		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned long	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 /*
  * Runes (wchar_t) is declared to be an ``int'' instead of the more natural
Index: sys/arch/vax/include/ansi.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/vax/include/ansi.h,v
retrieving revision 1.7
diff -u -r1.7 ansi.h
--- ansi.h	1998/04/27 17:39:11	1.7
+++ ansi.h	2000/05/23 12:58:19
@@ -63,6 +63,8 @@
 #define	_BSD_USECONDS_T_	unsigned int	/* useconds_t */
 #define	_BSD_INTPTR_T_		int		/* intptr_t */
 #define	_BSD_UINTPTR_T_		unsigned int	/* uintptr_t */
+/* NOTE: socklen_t is not part of ANSI standard, it is in XSH5 */
+#define	_BSD_SOCKLEN_T_		unsigned int	/* socklen_t */
 
 
 #endif  /* _ANSI_H_ */