SF bug [#456252] Python should never stomp on [u]intptr_t.
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.
This commit is contained in:
parent
1936745668
commit
79248aa1e4
|
@ -63,16 +63,25 @@ Used in: LONG_LONG
|
|||
|
||||
/* 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 intptr_t Py_intptr_t;
|
||||
|
||||
#elif SIZEOF_VOID_P <= SIZEOF_INT
|
||||
typedef unsigned int Py_uintptr_t;
|
||||
typedef int Py_intptr_t;
|
||||
|
||||
#elif SIZEOF_VOID_P <= SIZEOF_LONG
|
||||
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 LONG_LONG Py_intptr_t;
|
||||
|
||||
#else
|
||||
# error "Python needs a typedef for Py_uintptr_t in pyport.h."
|
||||
#endif /* HAVE_UINTPTR_T */
|
||||
|
|
|
@ -1551,7 +1551,7 @@ posix_spawnv(PyObject *self, PyObject *args)
|
|||
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
|
||||
|
@ -1620,7 +1620,7 @@ posix_spawnve(PyObject *self, PyObject *args)
|
|||
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
|
||||
|
@ -3689,8 +3689,8 @@ posix_pipe(PyObject *self, PyObject *args)
|
|||
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
|
||||
|
|
|
@ -1423,7 +1423,7 @@ PySocketSock_makefile(PySocketSockObject *s, PyObject *args)
|
|||
char *mode = "r";
|
||||
int bufsize = -1;
|
||||
#ifdef MS_WIN32
|
||||
intptr_t fd;
|
||||
Py_intptr_t fd;
|
||||
#else
|
||||
int fd;
|
||||
#endif
|
||||
|
|
|
@ -98,7 +98,7 @@ static PyObject *
|
|||
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;
|
||||
|
|
|
@ -294,10 +294,6 @@ typedef int pid_t;
|
|||
#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,
|
||||
|
|
|
@ -152,7 +152,7 @@ static void PyThread__init_thread(void)
|
|||
*/
|
||||
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()));
|
||||
|
@ -161,7 +161,7 @@ int PyThread_start_new_thread(void (*func)(void *), void *arg)
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue