Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 40053:693ff5d73412 2.4
Port of universal binary support for Mac OSX from python 2.5. This takes away
the need for the out-of-tree universal binary support that was used to build
the 2.4.3 installer.
Missing here relative to that tree are some changes to IDLE, IMHO those patches
aren't appropriate for the 2.4 branch and users are better of using 2.5's IDLE.
| author | Ronald Oussoren <ronaldoussoren@mac.com> |
|---|---|
| date | Sun, 08 Oct 2006 17:41:25 +0000 |
| parents | 6fb46e87d5f9 |
| children | f7fbdc562d7a |
line wrap: on
line diff
--- a/Modules/socketmodule.c Sun Oct 08 14:24:26 2006 +0000 +++ b/Modules/socketmodule.c Sun Oct 08 17:41:25 2006 +0000 @@ -61,6 +61,15 @@ */ +#ifdef __APPLE__ + /* + * inet_aton is not available on OSX 10.3, yet we want to use a binary + * that was build on 10.4 or later to work on that release, weak linking + * comes to the rescue. + */ +# pragma weak inet_aton +#endif + #include "Python.h" #undef MAX @@ -300,6 +309,11 @@ older releases don't have */ #undef HAVE_GETADDRINFO #endif + +#ifdef HAVE_INET_ATON +#define USE_INET_ATON_WEAKLINK +#endif + #endif /* I know this is a bad practice, but it is the easiest... */ @@ -3261,7 +3275,9 @@ #endif #ifdef HAVE_INET_ATON struct in_addr buf; -#else +#endif + +#if !defined(HAVE_INET_ATON) || defined(USE_INET_ATON_WEAKLINK) /* Have to use inet_addr() instead */ unsigned long packed_addr; #endif @@ -3272,6 +3288,10 @@ #ifdef HAVE_INET_ATON + +#ifdef USE_INET_ATON_WEAKLINK + if (inet_aton != NULL) { +#endif if (inet_aton(ip_addr, &buf)) return PyString_FromStringAndSize((char *)(&buf), sizeof(buf)); @@ -3280,7 +3300,14 @@ "illegal IP address string passed to inet_aton"); return NULL; -#else /* ! HAVE_INET_ATON */ +#ifdef USE_INET_ATON_WEAKLINK + } else { +#endif + +#endif + +#if !defined(HAVE_INET_ATON) || defined(USE_INET_ATON_WEAKLINK) + /* special-case this address as inet_addr might return INADDR_NONE * for this */ if (strcmp(ip_addr, "255.255.255.255") == 0) { @@ -3297,6 +3324,11 @@ } return PyString_FromStringAndSize((char *) &packed_addr, sizeof(packed_addr)); + +#ifdef USE_INET_ATON_WEAKLINK + } +#endif + #endif }
