Created
January 19, 2012 19:57
-
-
Save goodell/1642199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 403606a78accd2d0db07fac09b73e454e1cba96d | |
Author: Dave Goodell <[email protected]> | |
Date: Wed Jan 18 17:44:07 2012 -0600 | |
stop cheating with _POSIX_C_SOURCE and friends in tcp_getip.c | |
This was always a questionable hack, but it finally bit us on | |
OS X 10.7 (Lion). | |
No reviewer. | |
--- | |
.../nemesis/nemesis/netmod/tcp/tcp_getip.c | 33 ++------ | |
src/mpid/ch3/channels/nemesis/subconfigure.m4 | 49 ++++-------- | |
src/mpid/ch3/subconfigure.m4 | 83 -------------------- | |
3 files changed, 23 insertions(+), 142 deletions(-) | |
diff --git a/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_getip.c b/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_getip.c | |
index baec5f7..7ae09bf 100644 | |
--- a/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_getip.c | |
+++ b/src/mpid/ch3/channels/nemesis/nemesis/netmod/tcp/tcp_getip.c | |
@@ -13,29 +13,14 @@ | |
/* FIXME: This should use the standard debug/logging routines and macros */ | |
static int dbg_ifname = 0; | |
-/* FIXME: This more-or-less duplicates the code in | |
- ch3/util/sock/ch3u_getintefaces.c , which is already more thoroughly | |
- tested and more portable than the code here. | |
- */ | |
-#ifdef USE_NOPOSIX_FOR_IFCONF | |
-/* This is a very special case. Allow the use of some extensions for | |
- just the rest of this file so that we can get the ifconf structure */ | |
-#undef _POSIX_C_SOURCE | |
-#endif | |
- | |
-#ifdef USE_SVIDSOURCE_FOR_IFCONF | |
-/* This is a very special case. Allow the use of some extensions for just | |
- the rest of this file so that we can get the ifconf structure */ | |
-#define _SVID_SOURCE | |
-#endif | |
- | |
-#ifdef USE_ALL_SOURCE_FOR_IFCONF | |
-/* This is a very special case. Allow the use of some extensions for just | |
- the rest of this file so that we can get the ifconf structure | |
- This is needed for AIX. | |
- */ | |
-#define _ALL_SOURCE | |
-#endif | |
+/* NOTE: We previously used configure tests to decide if defining/undefining | |
+ * macros like _POSIX_C_SOURCE, _SVID_SOURCE, and _ALL_SOURCE would give us | |
+ * access to the ifconf structure. If so, we would define them here. However | |
+ * this was a problem because all of the other tests done by configure were | |
+ * effectively invalidated once we made those definitions. This manifested | |
+ * itself as problems on Mac OS X 10.7 (Lion) related to | |
+ * "__builtin___snprintf_chk", and probably can cause various other bugs on | |
+ * other platforms. Related to ticket #1568. */ | |
#include "tcp_impl.h" | |
#include <sys/types.h> | |
@@ -248,7 +233,7 @@ int MPIDI_GetIPInterface( MPIDU_Sock_ifaddr_t *ifaddr, int *found ) | |
#endif | |
-#if defined(SIOCGIFADDR) | |
+#if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ) | |
/* 'ifname' is a string that might be the name of an interface (e.g., "eth0", | |
* "en1", "ib0", etc), not an "interface hostname" ("node1", "192.168.1.38", | |
diff --git a/src/mpid/ch3/channels/nemesis/subconfigure.m4 b/src/mpid/ch3/channels/nemesis/subconfigure.m4 | |
index 609cd14..d100723 100644 | |
--- a/src/mpid/ch3/channels/nemesis/subconfigure.m4 | |
+++ b/src/mpid/ch3/channels/nemesis/subconfigure.m4 | |
@@ -325,52 +325,31 @@ AC_TRY_COMPILE([ | |
#include <sys/socket.h> | |
#endif | |
#include <net/if.h> | |
-],[struct ifconf conftest;], | |
+],[struct ifconf conftest; int s; s = sizeof(conftest);], | |
pac_cv_have_struct_ifconf=yes,pac_cv_have_struct_ifconf=no)]) | |
-if test "$pac_cv_have_struct_ifconf" = "no" ; then | |
- # Try again with _SVID_SOURCE | |
- AC_CACHE_CHECK([whether we can use struct ifconf with _SVID_SOURCE], | |
-pac_cv_have_struct_ifconf_with_svid,[ | |
-AC_TRY_COMPILE([ | |
-#define _SVID_SOURCE | |
-#include <sys/types.h> | |
-#ifdef HAVE_SYS_SOCKET_H | |
-#include <sys/socket.h> | |
-#endif | |
-#include <net/if.h> | |
-],[struct ifconf conftest;], | |
-pac_cv_have_struct_ifconf_with_svid=yes, | |
-pac_cv_have_struct_ifconf_with_svid=no)]) | |
- if test "$pac_cv_have_struct_ifconf_with_svid" = yes ; then | |
- AC_DEFINE(USE_SVIDSOURCE_FOR_IFCONF,1,[Define if _SVID_SOURCE needs to be defined for struct ifconf]) | |
- fi | |
+# Intentionally not testing whether _SVID_SOURCE or _POSIX_C_SOURCE affects | |
+# ifconf availability. Making those sort of modifications at this stage | |
+# invalidates nearly all of our previous tests, since those macros fundamentally | |
+# change many features of the compiler on most platforms. See ticket #1568. | |
+ | |
+if test "$pac_cv_have_struct_ifconf" = "yes" ; then | |
+ AC_DEFINE(HAVE_STRUCT_IFCONF,1,[Define if struct ifconf can be used]) | |
fi | |
-if test "$pac_cv_have_struct_ifconf" = "no" -a \ | |
- "$pac_cv_have_struct_ifconf_with_svid" = "no" ; then | |
- # Try again with undef _POSIX_C_SOURCE | |
- AC_CACHE_CHECK([whether we can use struct ifconf without _POSIX_C_SOURCE], | |
-pac_cv_have_struct_ifconf_without_posix,[ | |
+AC_CACHE_CHECK([whether we can use struct ifreq], | |
+pac_cv_have_struct_ifreq,[ | |
AC_TRY_COMPILE([ | |
-#undef _POSIX_C_SOURCE | |
#include <sys/types.h> | |
#ifdef HAVE_SYS_SOCKET_H | |
#include <sys/socket.h> | |
#endif | |
#include <net/if.h> | |
-],[struct ifconf conftest;], | |
-pac_cv_have_struct_ifconf_without_posix=yes, | |
-pac_cv_have_struct_ifconf_without_posix=no)]) | |
- if test "$pac_cv_have_struct_ifconf_without_posix" = yes ; then | |
- AC_DEFINE(USE_NOPOSIX_FOR_IFCONF,1,[Define if _POSIX_C_SOURCE needs to be undefined for struct ifconf]) | |
- fi | |
-fi | |
+],[struct ifreq conftest; int s; s = sizeof(conftest);], | |
+pac_cv_have_struct_ifreq=yes,pac_cv_have_struct_ifreq=no)]) | |
-if test "$pac_cv_have_struct_ifconf" = "yes" -o \ | |
- "$pac_cv_have_struct_ifconf_with_svid" = "yes" -o \ | |
- "$pac_cv_have_struct_ifconf_without_posix" = "yes" ; then | |
- AC_DEFINE(HAVE_STRUCT_IFCONF,1,[Define if struct ifconf can be used]) | |
+if test "$pac_cv_have_struct_ifreq" = "yes" ; then | |
+ AC_DEFINE(HAVE_STRUCT_IFREQ,1,[Define if struct ifreq can be used]) | |
fi | |
# Check for knem options | |
diff --git a/src/mpid/ch3/subconfigure.m4 b/src/mpid/ch3/subconfigure.m4 | |
index aa2975a..6250608 100644 | |
--- a/src/mpid/ch3/subconfigure.m4 | |
+++ b/src/mpid/ch3/subconfigure.m4 | |
@@ -137,89 +137,6 @@ fi | |
AC_C_BIGENDIAN | |
-# If we need the socket code, see if we can use struct ifconf | |
-# Some systems require special compile options or definitions, or | |
-# special header files. | |
-# | |
-# To simplify this sequence of tests, we set | |
-# pac_found_struct_ifconf | |
-# to yes when we figure out how to get struct ifconf | |
-pac_found_struct_ifconf=no | |
-# | |
-# sys/socket.h is needed on Solaris | |
-AC_CACHE_CHECK([whether we can use struct ifconf], | |
-pac_cv_have_struct_ifconf,[ | |
-AC_TRY_COMPILE([ | |
-#include <sys/types.h> | |
-#ifdef HAVE_SYS_SOCKET_H | |
-#include <sys/socket.h> | |
-#endif | |
-#include <net/if.h> | |
-],[struct ifconf conftest;], | |
-[pac_cv_have_struct_ifconf=yes;pac_found_struct_ifconf=yes], | |
- pac_cv_have_struct_ifconf=no)]) | |
- | |
-if test "$pac_found_struct_ifconf" = "no" ; then | |
- # Try again with _SVID_SOURCE | |
- AC_CACHE_CHECK([whether we can use struct ifconf with _SVID_SOURCE], | |
-pac_cv_have_struct_ifconf_with_svid,[ | |
-AC_TRY_COMPILE([ | |
-#define _SVID_SOURCE | |
-#include <sys/types.h> | |
-#ifdef HAVE_SYS_SOCKET_H | |
-#include <sys/socket.h> | |
-#endif | |
-#include <net/if.h> | |
-],[struct ifconf conftest;], | |
-pac_cv_have_struct_ifconf_with_svid=yes;pac_found_struct_ifconf=yes, | |
-pac_cv_have_struct_ifconf_with_svid=no)]) | |
- if test "$pac_cv_have_struct_ifconf_with_svid" = yes ; then | |
- AC_DEFINE(USE_SVIDSOURCE_FOR_IFCONF,1,[Define if _SVID_SOURCE needs to be defined for struct ifconf]) | |
- fi | |
-fi | |
- | |
-if test "$pac_found_struct_ifconf" = "no" ; then | |
- # Try again with undef _POSIX_C_SOURCE | |
- AC_CACHE_CHECK([whether we can use struct ifconf without _POSIX_C_SOURCE], | |
-pac_cv_have_struct_ifconf_without_posix,[ | |
-AC_TRY_COMPILE([ | |
-#undef _POSIX_C_SOURCE | |
-#include <sys/types.h> | |
-#ifdef HAVE_SYS_SOCKET_H | |
-#include <sys/socket.h> | |
-#endif | |
-#include <net/if.h> | |
-],[struct ifconf conftest;], | |
-pac_cv_have_struct_ifconf_without_posix=yes;pac_found_struct_ifconf=yes, | |
-pac_cv_have_struct_ifconf_without_posix=no)]) | |
- if test "$pac_cv_have_struct_ifconf_without_posix" = yes ; then | |
- AC_DEFINE(USE_NOPOSIX_FOR_IFCONF,1,[Define if _POSIX_C_SOURCE needs to be undefined for struct ifconf]) | |
- fi | |
-fi | |
- | |
-if test "$pac_found_struct_ifconf" = "no" ; then | |
- # Try again with _ALL_SOURCE | |
- AC_CACHE_CHECK([whether we can use struct ifconf with _ALL_SOURCE], | |
-pac_cv_have_struct_ifconf_with_svid,[ | |
-AC_TRY_COMPILE([ | |
-#define _ALL_SOURCE | |
-#include <sys/types.h> | |
-#ifdef HAVE_SYS_SOCKET_H | |
-#include <sys/socket.h> | |
-#endif | |
-#include <net/if.h> | |
-],[struct ifconf conftest;], | |
-pac_cv_have_struct_ifconf_with_all_source=yes;pac_found_struct_ifconf=yes, | |
-pac_cv_have_struct_ifconf_with_all_source=no)]) | |
- if test "$pac_cv_have_struct_ifconf_with_all_source" = yes ; then | |
- AC_DEFINE(USE_ALL_SOURCE_FOR_IFCONF,1,[Define if _ALL_SOURCE needs to be defined for struct ifconf]) | |
- fi | |
-fi | |
- | |
-if test "$pac_found_struct_ifconf" = "yes" ; then | |
- AC_DEFINE(HAVE_STRUCT_IFCONF,1,[Define if struct ifconf can be used]) | |
-fi | |
- | |
])dnl end AM_COND_IF(BUILD_CH3,...) | |
])dnl end _BODY | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment