summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-10-27 20:13:57 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-10-27 20:13:57 (GMT)
commitb156a46b26d9f231d7b36d303055af4d2b3b7c17 (patch)
treef6a6b88da22674f0464f346b7f2cd548d905656a
parent71f8cc9b4a1b7c6e97cbeeae7df0c8600b885492 (diff)
downloadcpython-b156a46b26d9f231d7b36d303055af4d2b3b7c17.zip
cpython-b156a46b26d9f231d7b36d303055af4d2b3b7c17.tar.gz
cpython-b156a46b26d9f231d7b36d303055af4d2b3b7c17.tar.bz2
Issue #8852: Allow the socket module to build on OpenSolaris.
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/socketmodule.c40
2 files changed, 30 insertions, 12 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 3f8d115..5b622ac 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -184,6 +184,8 @@ Tests
Build
-----
+- Issue #8852: Allow the socket module to build on OpenSolaris.
+
- Drop -OPT:Olimit compiler option.
- Issue #10094: Use versioned .so files on GNU/kfreeBSD and the GNU Hurd.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index d340f94..eeb9304 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1139,7 +1139,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
}
#endif
-#ifdef HAVE_NETPACKET_PACKET_H
+#if defined(HAVE_NETPACKET_PACKET_H) && defined(SIOCGIFNAME)
case AF_PACKET:
{
struct sockaddr_ll *a = (struct sockaddr_ll *)addr;
@@ -1455,7 +1455,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
}
#endif
-#ifdef HAVE_NETPACKET_PACKET_H
+#if defined(HAVE_NETPACKET_PACKET_H) && defined(SIOCGIFINDEX)
case AF_PACKET:
{
struct sockaddr_ll* addr;
@@ -4569,16 +4569,32 @@ PyInit__socket(void)
PyModule_AddStringConstant(m, "BDADDR_LOCAL", "00:00:00:FF:FF:FF");
#endif
-#ifdef HAVE_NETPACKET_PACKET_H
- PyModule_AddIntConstant(m, "AF_PACKET", AF_PACKET);
- PyModule_AddIntConstant(m, "PF_PACKET", PF_PACKET);
- PyModule_AddIntConstant(m, "PACKET_HOST", PACKET_HOST);
- PyModule_AddIntConstant(m, "PACKET_BROADCAST", PACKET_BROADCAST);
- PyModule_AddIntConstant(m, "PACKET_MULTICAST", PACKET_MULTICAST);
- PyModule_AddIntConstant(m, "PACKET_OTHERHOST", PACKET_OTHERHOST);
- PyModule_AddIntConstant(m, "PACKET_OUTGOING", PACKET_OUTGOING);
- PyModule_AddIntConstant(m, "PACKET_LOOPBACK", PACKET_LOOPBACK);
- PyModule_AddIntConstant(m, "PACKET_FASTROUTE", PACKET_FASTROUTE);
+#ifdef AF_PACKET
+ PyModule_AddIntMacro(m, AF_PACKET);
+#endif
+#ifdef PF_PACKET
+ PyModule_AddIntMacro(m, PF_PACKET);
+#endif
+#ifdef PACKET_HOST
+ PyModule_AddIntMacro(m, PACKET_HOST);
+#endif
+#ifdef PACKET_BROADCAST
+ PyModule_AddIntMacro(m, PACKET_BROADCAST);
+#endif
+#ifdef PACKET_MULTICAST
+ PyModule_AddIntMacro(m, PACKET_MULTICAST);
+#endif
+#ifdef PACKET_OTHERHOST
+ PyModule_AddIntMacro(m, PACKET_OTHERHOST);
+#endif
+#ifdef PACKET_OUTGOING
+ PyModule_AddIntMacro(m, PACKET_OUTGOING);
+#endif
+#ifdef PACKET_LOOPBACK
+ PyModule_AddIntMacro(m, PACKET_LOOPBACK);
+#endif
+#ifdef PACKET_FASTROUTE
+ PyModule_AddIntMacro(m, PACKET_FASTROUTE);
#endif
#ifdef HAVE_LINUX_TIPC_H