summary refs log tree commit diff
path: root/socket
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-12-26 10:00:22 +0000
committerRoland McGrath <roland@gnu.org>1995-12-26 10:00:22 +0000
commitbe7e3b7e7ef0fb3d632002bda04d0ad0537ced8b (patch)
treeed3701064cddf156aed81b7799617ecc031f6e1c /socket
parente0f09b6b2a5a06ee90f962d79aad21274152d052 (diff)
downloadglibc-be7e3b7e7ef0fb3d632002bda04d0ad0537ced8b.tar.gz
glibc-be7e3b7e7ef0fb3d632002bda04d0ad0537ced8b.tar.xz
glibc-be7e3b7e7ef0fb3d632002bda04d0ad0537ced8b.zip
Mon Dec 25 20:56:39 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> cvs/libc-951228 cvs/libc-951227 cvs/libc-951226
	* sysdeps/mach/hurd/bind.c: Translate EEXIST from dir_link into
	EADDRINUSE.  If translated node doesn't grok ifsock protocol,
	return EADDRINUSE.

	* sysdeps/mach/hurd/connect.c: Make address arg
	`const struct sockaddr_un *'.
	The redecl is kosher and avoids another variable for AF_LOCAL case.
	* sysdeps/mach/hurd/sendto.c: Likewise.
	* sysdeps/mach/hurd/bind.c: Likewise.

	* socket/sys/socket.h (__SOCKADDR_ARG): Enable transparent_union
 	code for GCC >= 2.7; use __transparent_union__ for name safety;
 	add several sockaddr flavors.
	(__SOCKADDR_ALLTYPES, __SOCKADDR_ONETYPE): New macros used in
	constructing the transparent union declarations.
	(__CONST_SOCKADDR_ARG): New type (or macro if not GCC 2.7).
	(bind, connect, sendto): Make the sockaddr argument use that.
Diffstat (limited to 'socket')
-rw-r--r--socket/sys/socket.h52
1 files changed, 33 insertions, 19 deletions
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 65217216a0..9b88e642f7 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -115,25 +115,38 @@ struct sockaddr
 
 /* This is the type we use for generic socket address arguments.
 
-   NOTE: Since this functionality is volatile, I'm disabling the use of it for
-   now.
-
-   With GCC 2.6 and later, the funky union causes redeclarations or uses with
+   With GCC 2.7 and later, the funky union causes redeclarations or uses with
    any of the listed types to be allowed without complaint.  */
 #if	(!defined (__GNUC__) || __GNUC__ < 2 || \
-	 /*(__GNUC__ == 2 && __GNUC_MINOR__ < 6)*/ 1)
-#define	__SOCKADDR_ARG	struct sockaddr *
+	 (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
+#define	__SOCKADDR_ARG		struct sockaddr *
+#define	__CONST_SOCKADDR_ARG	__const struct sockaddr *
 #else
-/* Bring these names into being at top-level scope, in case they have not been
-   defined yet.  Add more `struct sockaddr_AF' types here as necessary.  */
-struct sockaddr_in;
-struct sockaddr_un;
-struct sockaddr_ns;
-typedef union { struct sockaddr *__sa;
-		struct sockaddr_in *__sa_in;
-		struct sockaddr_un *__sa_un;
-		struct sockaddr_ns *__sa_ns;
-	      } __SOCKADDR_ARG __attribute__ ((transparent_union));
+/* Add more `struct sockaddr_AF' types here as necessary.
+   These are all the ones I found on NetBSD and Linux.  */
+#define __SOCKADDR_ALLTYPES \
+  __SOCKADDR_ONETYPE (sockaddr) \
+  __SOCKADDR_ONETYPE (sockaddr_at) \
+  __SOCKADDR_ONETYPE (sockaddr_ax25) \
+  __SOCKADDR_ONETYPE (sockaddr_dl) \
+  __SOCKADDR_ONETYPE (sockaddr_eon) \
+  __SOCKADDR_ONETYPE (sockaddr_in) \
+  __SOCKADDR_ONETYPE (sockaddr_in6) \
+  __SOCKADDR_ONETYPE (sockaddr_inarp) \
+  __SOCKADDR_ONETYPE (sockaddr_ipx) \
+  __SOCKADDR_ONETYPE (sockaddr_iso) \
+  __SOCKADDR_ONETYPE (sockaddr_ns) \
+  __SOCKADDR_ONETYPE (sockaddr_un) \
+  __SOCKADDR_ONETYPE (sockaddr_x25)
+
+#define __SOCKADDR_ONETYPE(type) struct type *__##type##__;
+typedef union { __SOCKADDR_ALLTYPES
+	      } __SOCKADDR_ARG __attribute__ ((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+#define __SOCKADDR_ONETYPE(type) __const struct type *__##type##__;
+typedef union { __SOCKADDR_ALLTYPES
+	      } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
 #endif
 
 
@@ -151,7 +164,7 @@ extern int socketpair __P ((int __domain, enum __socket_type __type,
 			    int __protocol, int __fds[2]));
 
 /* Give the socket FD the local address ADDR (which is LEN bytes long).  */
-extern int bind __P ((int __fd, __SOCKADDR_ARG __addr, size_t __len));
+extern int bind __P ((int __fd, __CONST_SOCKADDR_ARG __addr, size_t __len));
 
 /* Put the local address of FD into *ADDR and its length in *LEN.  */
 extern int getsockname __P ((int __fd, __SOCKADDR_ARG __addr,
@@ -161,7 +174,8 @@ extern int getsockname __P ((int __fd, __SOCKADDR_ARG __addr,
    For connectionless socket types, just set the default address to send to
    and the only address from which to accept transmissions.
    Return 0 on success, -1 for errors.  */
-extern int connect __P ((int __fd, __SOCKADDR_ARG __addr, size_t __len));
+extern int connect __P ((int __fd,
+			 __CONST_SOCKADDR_ARG __addr, size_t __len));
 
 /* Put the address of the peer connected to socket FD into *ADDR
    (which is *LEN bytes long), and its actual length into *LEN.  */
@@ -192,7 +206,7 @@ extern int recv __P ((int __fd, __ptr_t __buf, size_t __n, int __flags));
 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
    ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.  */
 extern int sendto __P ((int __fd, __ptr_t __buf, size_t __n, int __flags,
-			__SOCKADDR_ARG __addr, size_t __addr_len));
+			__CONST_SOCKADDR_ARG __addr, size_t __addr_len));
 
 /* Read N bytes into BUF through socket FD.
    If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of