bug-gnulib
[Top][All Lists]
Advanced

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

sys_socket: ensure ss_family


From: Bruno Haible
Subject: sys_socket: ensure ss_family
Date: Sun, 28 Nov 2010 17:06:46 +0100
User-agent: KMail/1.9.9

Hi Simon,

On AIX 5.1, I'm seeing this compilation failure:

gcc -D_ALL_SOURCE -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1  -I. -I.  
-I.. -I./..  -I../gllib -I./../gllib    -g -O2 -MT test-sys_socket.o -MD -MP 
-MF .deps/test-sys_socket.Tpo -c -o test-sys_socket.o test-sys_socket.c
test-sys_socket.c: In function 'main':
test-sys_socket.c:52: error: 'struct sockaddr_storage' has no member named 
'ss_family'
make: 1254-004 The error code from the last command is 1.

The 'struct sockaddr_storage' on AIX has a field '__ss_family', not 'ss_family'.

This fixes it. OK to push?


2010-11-28  Bruno Haible  <address@hidden>

        sys_socket: Ensure ss_family field on AIX.
        * lib/sys_socket.in.h (ss_family): New macro definition.
        * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Set
        HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY.
        (gl_SYS_SOCKET_H_DEFAULTS): Initialize
        HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY.
        * modules/sys_socket (Makefile.am): Substitute
        HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY.
        * doc/posix-headers/sys_socket.texi: Mention the AIX bug.

--- doc/posix-headers/sys_socket.texi.orig      Sun Nov 28 17:00:58 2010
+++ doc/posix-headers/sys_socket.texi   Sun Nov 28 16:50:48 2010
@@ -18,6 +18,10 @@
 @code{SHUT_RDWR} macros on some platforms, despite having the @code{shutdown}
 functions:
 emx+gcc.
address@hidden
+The @code{struct sockaddr_storage} type does not have a member @code{ss_family}
+on some platforms:
+AIX 7.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- lib/sys_socket.in.h.orig    Sun Nov 28 17:00:58 2010
+++ lib/sys_socket.in.h Sun Nov 28 16:57:38 2010
@@ -70,7 +70,14 @@
 typedef unsigned short  sa_family_t;
 #endif
 
-#if address@hidden@
+#if @HAVE_STRUCT_SOCKADDR_STORAGE@
+/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1.  */
+# if address@hidden@
+#  ifndef ss_family
+#   define ss_family __ss_family
+#  endif
+# endif
+#else
 # include <alignof.h>
 /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
    2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
--- m4/sys_socket_h.m4.orig     Sun Nov 28 17:00:58 2010
+++ m4/sys_socket_h.m4  Sun Nov 28 16:56:30 2010
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 19
+# sys_socket_h.m4 serial 20
 dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -57,6 +57,19 @@
   if test $ac_cv_type_sa_family_t = no; then
     HAVE_SA_FAMILY_T=0
   fi
+  if test $ac_cv_type_struct_sockaddr_storage != no; then
+    AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],
+      [],
+      [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0],
+      [#include <sys/types.h>
+       #ifdef HAVE_SYS_SOCKET_H
+       #include <sys/socket.h>
+       #endif
+       #ifdef HAVE_WS2TCPIP_H
+       #include <ws2tcpip.h>
+       #endif
+      ])
+  fi
   gl_PREREQ_SYS_H_WINSOCK2
 
   dnl Check for declarations of anything we want to poison if the
@@ -145,6 +158,8 @@
   GNULIB_SHUTDOWN=0;    AC_SUBST([GNULIB_SHUTDOWN])
   GNULIB_ACCEPT4=0;     AC_SUBST([GNULIB_ACCEPT4])
   HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
+  HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
+                        AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
   HAVE_SA_FAMILY_T=1;   AC_SUBST([HAVE_SA_FAMILY_T])
   HAVE_ACCEPT4=1;       AC_SUBST([HAVE_ACCEPT4])
 ])
--- modules/sys_socket.orig     Sun Nov 28 17:00:58 2010
+++ modules/sys_socket  Sun Nov 28 16:56:55 2010
@@ -52,6 +52,7 @@
              -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
              -e 
's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
+             -e 
's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g'
 \
              -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
              -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]