pyport.h: typedef a new Py_intptr_t type.
DELICATE ASSUMPTION: That HAVE_UINTPTR_T implies intptr_t is
available as well as uintptr_t. If that turns out not to be
true, things must get uglier (C99 wants both, so I think it's
an assumption we're *likely* to get away with).
thread_nt.h, PyThread_start_new_thread: MS _beginthread is documented
as returning unsigned long; no idea why uintptr_t was being used.
Others: Always use Py_[u]intptr_t, never [u]intptr_t directly.
/* uintptr_t is the C9X name for an unsigned integral type such that a
* legitimate void* can be cast to uintptr_t and then back to void* again
- * without loss of information.
+ * without loss of information. Similarly for intptr_t, wrt a signed
+ * integral type.
*/
#ifdef HAVE_UINTPTR_T
-typedef uintptr_t Py_uintptr_t;
+typedef uintptr_t Py_uintptr_t;
+typedef intptr_t Py_intptr_t;
+
#elif SIZEOF_VOID_P <= SIZEOF_INT
-typedef unsigned int Py_uintptr_t;
+typedef unsigned int Py_uintptr_t;
+typedef int Py_intptr_t;
+
#elif SIZEOF_VOID_P <= SIZEOF_LONG
-typedef unsigned long Py_uintptr_t;
+typedef unsigned long Py_uintptr_t;
+typedef long Py_intptr_t;
+
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
-typedef unsigned LONG_LONG Py_uintptr_t;
+typedef unsigned LONG_LONG Py_uintptr_t;
+typedef LONG_LONG Py_intptr_t;
+
#else
# error "Python needs a typedef for Py_uintptr_t in pyport.h."
#endif /* HAVE_UINTPTR_T */
PyObject *argv;
char **argvlist;
int mode, i, argc;
- intptr_t spawnval;
+ Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, int);
/* spawnv has three arguments: (mode, path, argv), where
char **envlist;
PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL;
int mode, i, pos, argc, envc;
- intptr_t spawnval;
+ Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, int);
/* spawnve has four arguments: (mode, path, argv, env), where
Py_END_ALLOW_THREADS
if (!ok)
return win32_error("CreatePipe", NULL);
- read_fd = _open_osfhandle((intptr_t)read, 0);
- write_fd = _open_osfhandle((intptr_t)write, 1);
+ read_fd = _open_osfhandle((Py_intptr_t)read, 0);
+ write_fd = _open_osfhandle((Py_intptr_t)write, 1);
return Py_BuildValue("(ii)", read_fd, write_fd);
#endif /* MS_WIN32 */
#endif
char *mode = "r";
int bufsize = -1;
#ifdef MS_WIN32
- intptr_t fd;
+ Py_intptr_t fd;
#else
int fd;
#endif
msvcrt_get_osfhandle(PyObject *self, PyObject *args)
{
int fd;
- intptr_t handle;
+ Py_intptr_t handle;
if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd))
return NULL;
#if _MSC_VER >= 1200 /* This file only exists in VC 6.0 or higher */
#include <basetsd.h>
#endif
-#if defined(MS_WINDOWS) && !defined(MS_WIN64)
-typedef long intptr_t;
-typedef unsigned long uintptr_t;
-#endif
#if defined(MS_WIN64)
/* maintain "win32" sys.platform for backward compatibility of Python code,
*/
int PyThread_start_new_thread(void (*func)(void *), void *arg)
{
- uintptr_t rv;
+ unsigned long rv;
int success = 0;
dprintf(("%ld: PyThread_start_new_thread called\n", PyThread_get_thread_ident()));
rv = _beginthread(func, 0, arg); /* use default stack size */
- if (rv != -1) {
+ if (rv != (unsigned long)-1) {
success = 1;
dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n", PyThread_get_thread_ident(), rv));
}