summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-28 20:42:55 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-28 20:42:55 (GMT)
commit67c7ce4bef3223af744d2b510d294000ce00388d (patch)
treed94599db1db51bb5aa9f1daaaa338ef7199a4715 /Modules
parent1a9a9d543327397396827642895410183f8902d5 (diff)
downloadcpython-67c7ce4bef3223af744d2b510d294000ce00388d.zip
cpython-67c7ce4bef3223af744d2b510d294000ce00388d.tar.gz
cpython-67c7ce4bef3223af744d2b510d294000ce00388d.tar.bz2
Issue #4835: make PyLong_FromSocket_t() and PyLong_AsSocket_t() private
to the socket module, and fix the width of socket descriptors to be correctly detected under 64-bit Windows.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
index 49ac9d0..4f426f5 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -93,6 +93,14 @@ typedef int SOCKET_T;
# define SIZEOF_SOCKET_T SIZEOF_INT
#endif
+#if SIZEOF_SOCKET_T <= SIZEOF_LONG
+#define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd))
+#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLong(fd)
+#else
+#define PyLong_FromSocket_t(fd) PyLong_FromLongLong((SOCKET_T)(fd))
+#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd)
+#endif
+
/* Socket address */
typedef union sock_addr {
struct sockaddr_in in;