]> granicus.if.org Git - python/commitdiff
issue #1746656: Fix for OS X. configure and #include changes so that the socket
authorGregory P. Smith <greg@krypto.org>
Sun, 15 May 2011 19:18:23 +0000 (12:18 -0700)
committerGregory P. Smith <greg@krypto.org>
Sun, 15 May 2011 19:18:23 +0000 (12:18 -0700)
module compiles again on OS X with its more annoying #include requirements.

Modules/socketmodule.c
configure
configure.in

index 701af2f0bf0b70e00e5fa6ac8ccb17e169c3ae92..d3f65aa18c6bd8c4cd1f32aa02f70d32b299a76e 100644 (file)
@@ -256,6 +256,14 @@ if_indextoname(index) -- returns the corresponding interface name\n\
 #include <sys/types.h>
 #endif
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+
 /* Generic socket object definitions and includes */
 #define PySocket_BUILDING_SOCKET
 #include "socketmodule.h"
index d5506efd942469fc6982613605dbbae39e19a64a..e1ab99b81e9f59edde00e881b8f32aa28bdb5c84 100755 (executable)
--- a/configure
+++ b/configure
@@ -6037,7 +6037,7 @@ sys/lock.h sys/mkdev.h sys/modem.h \
 sys/param.h sys/poll.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
 sys/stat.h sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
-libutil.h sys/resource.h net/if.h netpacket/packet.h sysexits.h bluetooth.h \
+libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
 bluetooth/bluetooth.h linux/tipc.h spawn.h util.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -6260,6 +6260,34 @@ fi
 fi
 
 
+# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
+for ac_header in net/if.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+"
+if test "x$ac_cv_header_net_if_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_IF_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
 # On Solaris, term.h requires curses.h
 for ac_header in term.h
 do :
index 3ae9a34ffe176999b52fcec2af516e2d22206492..3bf46b0ed8d1346e32c599f43fcb1585d69dbe92 100644 (file)
@@ -1293,11 +1293,28 @@ sys/lock.h sys/mkdev.h sys/modem.h \
 sys/param.h sys/poll.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
 sys/stat.h sys/termio.h sys/time.h \
 sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
-libutil.h sys/resource.h net/if.h netpacket/packet.h sysexits.h bluetooth.h \
+libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
 bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
 AC_HEADER_DIRENT
 AC_HEADER_MAJOR
 
+# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
+AC_CHECK_HEADERS([net/if.h], [], [],
+[#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+])
+
+
 # On Solaris, term.h requires curses.h
 AC_CHECK_HEADERS(term.h,,,[
 #ifdef HAVE_CURSES_H