# HG changeset patch
# User Kyle Moffett <mrmacman_g4@mac.com>
# Node ID 373f5d6a5416e6f6dd7cd5085edf9b232f361a55
# Parent  43cd2abd0f4c5d2e8ee4666d6bf1f0b96e252e54
Fix up struct sockaddr_in definition

The struct sockaddr_in padding calculation is unnecessarily complex and could be simplified by letting GCC do the padding calculation with unnamed struct and union fields.  A namespace pollution issue in the definition of sin_zero is fixed by changing from a macro define to an extra unnamed struct within the new unnamed union.

Signed-off-by: Kyle Moffett <mrmacman_g4@mac.com>

diff -r 43cd2abd0f4c -r 373f5d6a5416 include/linux/in.h
--- a/include/linux/in.h	Wed Jul 27 04:02:15 2005
+++ b/include/linux/in.h	Thu Jul 28 02:29:11 2005
@@ -172,17 +172,27 @@
 };
 
 /* Structure describing an Internet (IP) socket address. */
-#define __SOCK_SIZE__	16		/* sizeof(struct sockaddr)	*/
+#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
 struct sockaddr_in {
-  sa_family_t		sin_family;	/* Address family		*/
-  unsigned short int	sin_port;	/* Port number			*/
-  struct in_addr	sin_addr;	/* Internet address		*/
-
-  /* Pad to size of `struct sockaddr'. */
-  unsigned char		__pad[__SOCK_SIZE__ - sizeof(short int) -
-			sizeof(unsigned short int) - sizeof(struct in_addr)];
-};
-#define sin_zero	__pad		/* for BSD UNIX comp. -FvK	*/
+  union {
+    struct { /* Linux-style */
+	sa_family_t	sin_family;	/* Address family	*/
+	unsigned short	sin_port;	/* Port number		*/
+	struct in_addr	sin_addr;	/* Internet address	*/
+	unsigned char	__pad[];	/* Access to pad data	*/
+    };
+    struct { /* BSD-compatibility (Allow the sin_zero name) */
+	sa_family_t	__bsd_sin_family;
+	unsigned short	__bsd_sin_port;
+	struct in_addr	__bsd_sin_addr;
+	unsigned char	sin_zero[];
+    };
+    /* Pad to size of `struct sockaddr'. */
+    unsigned char __sockaddr_data[__SOCK_SIZE__];
+  };
+};
+#define __SOCKADDR_IN_PADDING__ ( sizeof(struct sockaddr_in) - \
+		offsetof(struct sockaddr_in, __pad) )
 
 
 /*
