diff Modules/socketmodule.h @ 64302:5c89f9571ba5 3.1

Merged revisions 84347 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84347 | antoine.pitrou | 2010-08-28 22:42:55 +0200 (sam., 28 août 2010) | 5 lines 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. ........
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 28 Aug 2010 20:53:24 +0000
parents f197407bdba2
children 3d9a86b8cc98
line wrap: on
line diff
--- a/Modules/socketmodule.h	Sat Aug 28 18:27:09 2010 +0000
+++ b/Modules/socketmodule.h	Sat Aug 28 20:53:24 2010 +0000
@@ -93,6 +93,14 @@
 #       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;