aboutsummaryrefslogtreecommitdiffstats
path: root/python/gevent/libev/libev_vfd.h
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-09-14 19:32:27 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-09-14 19:32:27 -0700
commit4212164e91ba2f49583cf44ad623a29b36db8f77 (patch)
tree47aefe3c0162f03e0c823b43873356f69c1cd636 /python/gevent/libev/libev_vfd.h
parent6ca20ff7010f2bafc7fefcb8cad982be27a8aeae (diff)
downloadyt-local-4212164e91ba2f49583cf44ad623a29b36db8f77.tar.lz
yt-local-4212164e91ba2f49583cf44ad623a29b36db8f77.tar.xz
yt-local-4212164e91ba2f49583cf44ad623a29b36db8f77.zip
Windows: Use 32-bit distribution of python
Diffstat (limited to 'python/gevent/libev/libev_vfd.h')
-rw-r--r--python/gevent/libev/libev_vfd.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/python/gevent/libev/libev_vfd.h b/python/gevent/libev/libev_vfd.h
index ec16a28..ff30fd8 100644
--- a/python/gevent/libev/libev_vfd.h
+++ b/python/gevent/libev/libev_vfd.h
@@ -1,11 +1,12 @@
#ifdef _WIN32
-#ifdef _WIN64
-typedef PY_LONG_LONG vfd_socket_t;
+/* see discussion in the libuv directory: this is a SOCKET which is a
+ HANDLE which is a PVOID (even though they're really small ints),
+ and CPython and PyPy return that SOCKET cast to an int from
+ fileno()
+*/
+typedef intptr_t vfd_socket_t;
#define vfd_socket_object PyLong_FromLongLong
-#else
-typedef long vfd_socket_t;
-#define vfd_socket_object PyInt_FromLong
-#endif
+
#ifdef LIBEV_EMBED
/*
* If libev on win32 is embedded, then we can use an
@@ -53,13 +54,13 @@ static CRITICAL_SECTION* vfd_make_lock()
#define VFD_GIL_DECLARE PyGILState_STATE ___save
#define VFD_GIL_ENSURE ___save = PyGILState_Ensure()
#define VFD_GIL_RELEASE PyGILState_Release(___save)
-#else
+#else /* ! WITH_THREAD */
#define VFD_LOCK_ENTER
#define VFD_LOCK_LEAVE
#define VFD_GIL_DECLARE
#define VFD_GIL_ENSURE
#define VFD_GIL_RELEASE
-#endif
+#endif /*_WITH_THREAD */
/*
* Given a virtual fd returns an OS handle or -1
@@ -67,7 +68,7 @@ static CRITICAL_SECTION* vfd_make_lock()
*/
static vfd_socket_t vfd_get(int fd)
{
- int handle = -1;
+ vfd_socket_t handle = -1;
VFD_LOCK_ENTER;
if (vfd_entries != NULL && fd >= 0 && fd < vfd_num)
handle = vfd_entries[fd].handle;
@@ -201,7 +202,7 @@ done:
#define vfd_free(fd) vfd_free_((fd), 0)
#define EV_WIN32_CLOSE_FD(fd) vfd_free_((fd), 1)
-#else
+#else /* !LIBEV_EMBED */
/*
* If libev on win32 is not embedded in gevent, then
* the only way to map vfds is to use the default of
@@ -211,13 +212,14 @@ done:
#define vfd_get(fd) _get_osfhandle((fd))
#define vfd_open(fd) _open_osfhandle((fd), 0)
#define vfd_free(fd)
-#endif
-#else
+#endif /* LIBEV_EMBED */
+
+#else /* !_WIN32 */
/*
* On non-win32 platforms vfd_* are noop macros
*/
typedef int vfd_socket_t;
#define vfd_get(fd) (fd)
-#define vfd_open(fd) ((int)(fd))
+#define vfd_open(fd) (fd)
#define vfd_free(fd)
-#endif
+#endif /* _WIN32 */