[Python-checkins] cpython: replace Py_(u)intptr_t with the c99 standard types

benjamin.peterson python-checkins at python.org
Tue Sep 6 16:48:21 EDT 2016


https://hg.python.org/cpython/rev/02c8db9c255f
changeset:   103142:02c8db9c255f
user:        Benjamin Peterson <benjamin at python.org>
date:        Tue Sep 06 13:47:26 2016 -0700
summary:
  replace Py_(u)intptr_t with the c99 standard types

files:
  Include/pyatomic.h        |   4 +-
  Include/pymacro.h         |   8 +++---
  Include/pymem.h           |   6 ++--
  Modules/_elementtree.c    |   8 +++---
  Modules/_sre.c            |  14 ++++++------
  Modules/_testcapimodule.c |  16 +++++++-------
  Modules/_tracemalloc.c    |  30 +++++++++++++-------------
  Modules/faulthandler.c    |  10 ++++----
  Modules/posixmodule.c     |  26 +++++++++++-----------
  Modules/selectmodule.c    |   4 +-
  Modules/signalmodule.c    |   4 +-
  Modules/sre_lib.h         |   2 +-
  Objects/descrobject.c     |   2 +-
  Objects/longobject.c      |   4 +-
  Objects/obmalloc.c        |   2 +-
  PC/msvcrtmodule.c         |  14 ++++++------
  Parser/grammar.c          |   4 +-
  Parser/parsetok.c         |   2 +-
  Python/ceval_gil.h        |   4 +-
  Python/compile.c          |   6 ++--
  Python/pystate.c          |   2 +-
  21 files changed, 86 insertions(+), 86 deletions(-)


diff --git a/Include/pyatomic.h b/Include/pyatomic.h
--- a/Include/pyatomic.h
+++ b/Include/pyatomic.h
@@ -61,7 +61,7 @@
 } _Py_memory_order;
 
 typedef struct _Py_atomic_address {
-    Py_uintptr_t _value;
+    uintptr_t _value;
 } _Py_atomic_address;
 
 typedef struct _Py_atomic_int {
@@ -98,7 +98,7 @@
 } _Py_memory_order;
 
 typedef struct _Py_atomic_address {
-    Py_uintptr_t _value;
+    uintptr_t _value;
 } _Py_atomic_address;
 
 typedef struct _Py_atomic_int {
diff --git a/Include/pymacro.h b/Include/pymacro.h
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -79,12 +79,12 @@
 #define _Py_SIZE_ROUND_UP(n, a) (((size_t)(n) + \
         (size_t)((a) - 1)) & ~(size_t)((a) - 1))
 /* Round pointer "p" down to the closest "a"-aligned address <= "p". */
-#define _Py_ALIGN_DOWN(p, a) ((void *)((Py_uintptr_t)(p) & ~(Py_uintptr_t)((a) - 1)))
+#define _Py_ALIGN_DOWN(p, a) ((void *)((uintptr_t)(p) & ~(uintptr_t)((a) - 1)))
 /* Round pointer "p" up to the closest "a"-aligned address >= "p". */
-#define _Py_ALIGN_UP(p, a) ((void *)(((Py_uintptr_t)(p) + \
-        (Py_uintptr_t)((a) - 1)) & ~(Py_uintptr_t)((a) - 1)))
+#define _Py_ALIGN_UP(p, a) ((void *)(((uintptr_t)(p) + \
+        (uintptr_t)((a) - 1)) & ~(uintptr_t)((a) - 1)))
 /* Check if pointer "p" is aligned to "a"-bytes boundary. */
-#define _Py_IS_ALIGNED(p, a) (!((Py_uintptr_t)(p) & (Py_uintptr_t)((a) - 1)))
+#define _Py_IS_ALIGNED(p, a) (!((uintptr_t)(p) & (uintptr_t)((a) - 1)))
 
 #ifdef __GNUC__
 #define Py_UNUSED(name) _unused_ ## name __attribute__((unused))
diff --git a/Include/pymem.h b/Include/pymem.h
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -37,7 +37,7 @@
    If memory block is already tracked, update the existing trace. */
 PyAPI_FUNC(int) _PyTraceMalloc_Track(
     _PyTraceMalloc_domain_t domain,
-    Py_uintptr_t ptr,
+    uintptr_t ptr,
     size_t size);
 
 /* Untrack an allocated memory block in the tracemalloc module.
@@ -46,7 +46,7 @@
    Return -2 if tracemalloc is disabled, otherwise return 0. */
 PyAPI_FUNC(int) _PyTraceMalloc_Untrack(
     _PyTraceMalloc_domain_t domain,
-    Py_uintptr_t ptr);
+    uintptr_t ptr);
 
 /* Get the traceback where a memory block was allocated.
 
@@ -58,7 +58,7 @@
    Raise an exception and return NULL on error. */
 PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
     _PyTraceMalloc_domain_t domain,
-    Py_uintptr_t ptr);
+    uintptr_t ptr);
 #endif   /* !Py_LIMITED_API */
 
 
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -57,9 +57,9 @@
    that all use of text and tail as object pointers must be wrapped in
    JOIN_OBJ.  see comments in the ElementObject definition for more
    info. */
-#define JOIN_GET(p) ((Py_uintptr_t) (p) & 1)
-#define JOIN_SET(p, flag) ((void*) ((Py_uintptr_t) (JOIN_OBJ(p)) | (flag)))
-#define JOIN_OBJ(p) ((PyObject*) ((Py_uintptr_t) (p) & ~(Py_uintptr_t)1))
+#define JOIN_GET(p) ((uintptr_t) (p) & 1)
+#define JOIN_SET(p, flag) ((void*) ((uintptr_t) (JOIN_OBJ(p)) | (flag)))
+#define JOIN_OBJ(p) ((PyObject*) ((uintptr_t) (p) & ~(uintptr_t)1))
 
 /* Py_CLEAR for a PyObject* that uses a join flag. Pass the pointer by
  * reference since this function sets it to NULL.
@@ -797,7 +797,7 @@
     }
 
     /* add object to memo dictionary (so deepcopy won't visit it again) */
-    id = PyLong_FromSsize_t((Py_uintptr_t) self);
+    id = PyLong_FromSsize_t((uintptr_t) self);
     if (!id)
         goto error;
 
diff --git a/Modules/_sre.c b/Modules/_sre.c
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1582,7 +1582,7 @@
         skip = *code;                                   \
         VTRACE(("%lu (skip to %p)\n",                   \
                (unsigned long)skip, code+skip));        \
-        if (skip-adj > (Py_uintptr_t)(end - code))      \
+        if (skip-adj > (uintptr_t)(end - code))      \
             FAIL;                                       \
         code++;                                         \
     } while (0)
@@ -1616,7 +1616,7 @@
 
         case SRE_OP_CHARSET:
             offset = 256/SRE_CODE_BITS; /* 256-bit bitmap */
-            if (offset > (Py_uintptr_t)(end - code))
+            if (offset > (uintptr_t)(end - code))
                 FAIL;
             code += offset;
             break;
@@ -1624,7 +1624,7 @@
         case SRE_OP_BIGCHARSET:
             GET_ARG; /* Number of blocks */
             offset = 256/sizeof(SRE_CODE); /* 256-byte table */
-            if (offset > (Py_uintptr_t)(end - code))
+            if (offset > (uintptr_t)(end - code))
                 FAIL;
             /* Make sure that each byte points to a valid block */
             for (i = 0; i < 256; i++) {
@@ -1633,7 +1633,7 @@
             }
             code += offset;
             offset = arg * (256/SRE_CODE_BITS); /* 256-bit bitmap times arg */
-            if (offset > (Py_uintptr_t)(end - code))
+            if (offset > (uintptr_t)(end - code))
                 FAIL;
             code += offset;
             break;
@@ -1784,11 +1784,11 @@
                     GET_ARG; prefix_len = arg;
                     GET_ARG;
                     /* Here comes the prefix string */
-                    if (prefix_len > (Py_uintptr_t)(newcode - code))
+                    if (prefix_len > (uintptr_t)(newcode - code))
                         FAIL;
                     code += prefix_len;
                     /* And here comes the overlap table */
-                    if (prefix_len > (Py_uintptr_t)(newcode - code))
+                    if (prefix_len > (uintptr_t)(newcode - code))
                         FAIL;
                     /* Each overlap value should be < prefix_len */
                     for (i = 0; i < prefix_len; i++) {
@@ -1917,7 +1917,7 @@
                to allow arbitrary jumps anywhere in the code; so we just look
                for a JUMP opcode preceding our skip target.
             */
-            if (skip >= 3 && skip-3 < (Py_uintptr_t)(end - code) &&
+            if (skip >= 3 && skip-3 < (uintptr_t)(end - code) &&
                 code[skip-3] == SRE_OP_JUMP)
             {
                 VTRACE(("both then and else parts present\n"));
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -113,10 +113,10 @@
     CHECK_SIZEOF(Py_ssize_t, sizeof(void *));
     CHECK_SIGNNESS(Py_ssize_t, 1);
 
-    CHECK_SIZEOF(Py_uintptr_t, sizeof(void *));
-    CHECK_SIGNNESS(Py_uintptr_t, 0);
-    CHECK_SIZEOF(Py_intptr_t, sizeof(void *));
-    CHECK_SIGNNESS(Py_intptr_t, 1);
+    CHECK_SIZEOF(uintptr_t, sizeof(void *));
+    CHECK_SIGNNESS(uintptr_t, 0);
+    CHECK_SIZEOF(intptr_t, sizeof(void *));
+    CHECK_SIGNNESS(intptr_t, 1);
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -3861,11 +3861,11 @@
 
     if (release_gil) {
         Py_BEGIN_ALLOW_THREADS
-        res = _PyTraceMalloc_Track(domain, (Py_uintptr_t)ptr, size);
+        res = _PyTraceMalloc_Track(domain, (uintptr_t)ptr, size);
         Py_END_ALLOW_THREADS
     }
     else {
-        res = _PyTraceMalloc_Track(domain, (Py_uintptr_t)ptr, size);
+        res = _PyTraceMalloc_Track(domain, (uintptr_t)ptr, size);
     }
 
     if (res < 0) {
@@ -3890,7 +3890,7 @@
     if (PyErr_Occurred())
         return NULL;
 
-    res = _PyTraceMalloc_Untrack(domain, (Py_uintptr_t)ptr);
+    res = _PyTraceMalloc_Untrack(domain, (uintptr_t)ptr);
     if (res < 0) {
         PyErr_SetString(PyExc_RuntimeError, "_PyTraceMalloc_Track error");
         return NULL;
@@ -3912,7 +3912,7 @@
     if (PyErr_Occurred())
         return NULL;
 
-    return _PyTraceMalloc_GetTraceback(domain, (Py_uintptr_t)ptr);
+    return _PyTraceMalloc_GetTraceback(domain, (uintptr_t)ptr);
 }
 
 
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -67,7 +67,7 @@
 __attribute__((packed))
 #endif
 {
-    Py_uintptr_t ptr;
+    uintptr_t ptr;
     _PyTraceMalloc_domain_t domain;
 } pointer_t;
 
@@ -523,7 +523,7 @@
 tracemalloc_use_domain_cb(_Py_hashtable_t *old_traces,
                            _Py_hashtable_entry_t *entry, void *user_data)
 {
-    Py_uintptr_t ptr;
+    uintptr_t ptr;
     pointer_t key;
     _Py_hashtable_t *new_traces = (_Py_hashtable_t *)user_data;
     const void *pdata = _Py_HASHTABLE_ENTRY_PDATA(old_traces, entry);
@@ -538,7 +538,7 @@
 }
 
 
-/* Convert tracemalloc_traces from compact key (Py_uintptr_t) to pointer_t key.
+/* Convert tracemalloc_traces from compact key (uintptr_t) to pointer_t key.
  * Return 0 on success, -1 on error. */
 static int
 tracemalloc_use_domain(void)
@@ -572,7 +572,7 @@
 
 
 static void
-tracemalloc_remove_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+tracemalloc_remove_trace(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
 {
     trace_t trace;
     int removed;
@@ -595,11 +595,11 @@
 }
 
 #define REMOVE_TRACE(ptr) \
-            tracemalloc_remove_trace(DEFAULT_DOMAIN, (Py_uintptr_t)(ptr))
+            tracemalloc_remove_trace(DEFAULT_DOMAIN, (uintptr_t)(ptr))
 
 
 static int
-tracemalloc_add_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
+tracemalloc_add_trace(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
                       size_t size)
 {
     pointer_t key = {ptr, domain};
@@ -617,7 +617,7 @@
 
     if (!tracemalloc_config.use_domain && domain != DEFAULT_DOMAIN) {
         /* first trace using a non-zero domain whereas traces use compact
-           (Py_uintptr_t) keys: switch to pointer_t keys. */
+           (uintptr_t) keys: switch to pointer_t keys. */
         if (tracemalloc_use_domain() < 0) {
             return -1;
         }
@@ -663,7 +663,7 @@
 }
 
 #define ADD_TRACE(ptr, size) \
-            tracemalloc_add_trace(DEFAULT_DOMAIN, (Py_uintptr_t)(ptr), size)
+            tracemalloc_add_trace(DEFAULT_DOMAIN, (uintptr_t)(ptr), size)
 
 
 static void*
@@ -1023,7 +1023,7 @@
                                            hashtable_compare_pointer_t);
     }
     else {
-        tracemalloc_traces = hashtable_new(sizeof(Py_uintptr_t),
+        tracemalloc_traces = hashtable_new(sizeof(uintptr_t),
                                            sizeof(trace_t),
                                            _Py_hashtable_hash_ptr,
                                            _Py_hashtable_compare_direct);
@@ -1414,7 +1414,7 @@
 
 
 static traceback_t*
-tracemalloc_get_traceback(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+tracemalloc_get_traceback(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
 {
     trace_t trace;
     int found;
@@ -1461,7 +1461,7 @@
     else
         ptr = (void *)obj;
 
-    traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (Py_uintptr_t)ptr);
+    traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (uintptr_t)ptr);
     if (traceback == NULL)
         Py_RETURN_NONE;
 
@@ -1489,7 +1489,7 @@
     traceback_t *traceback;
     int i;
 
-    traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (Py_uintptr_t)ptr);
+    traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (uintptr_t)ptr);
     if (traceback == NULL)
         return;
 
@@ -1762,7 +1762,7 @@
 }
 
 int
-_PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
+_PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, uintptr_t ptr,
                      size_t size)
 {
     int res;
@@ -1791,7 +1791,7 @@
 
 
 int
-_PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+_PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
 {
     if (!tracemalloc_config.tracing) {
         /* tracemalloc is not tracing: do nothing */
@@ -1807,7 +1807,7 @@
 
 
 PyObject*
-_PyTraceMalloc_GetTraceback(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
+_PyTraceMalloc_GetTraceback(_PyTraceMalloc_domain_t domain, uintptr_t ptr)
 {
     traceback_t *traceback;
 
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -1072,12 +1072,12 @@
 #  pragma intel optimization_level 0
 #endif
 static
-Py_uintptr_t
-stack_overflow(Py_uintptr_t min_sp, Py_uintptr_t max_sp, size_t *depth)
+uintptr_t
+stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
 {
     /* allocate 4096 bytes on the stack at each call */
     unsigned char buffer[4096];
-    Py_uintptr_t sp = (Py_uintptr_t)&buffer;
+    uintptr_t sp = (uintptr_t)&buffer;
     *depth += 1;
     if (sp < min_sp || max_sp < sp)
         return sp;
@@ -1090,8 +1090,8 @@
 faulthandler_stack_overflow(PyObject *self)
 {
     size_t depth, size;
-    Py_uintptr_t sp = (Py_uintptr_t)&depth;
-    Py_uintptr_t stop;
+    uintptr_t sp = (uintptr_t)&depth;
+    uintptr_t stop;
 
     faulthandler_suppress_crash_report();
     depth = 0;
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2492,8 +2492,8 @@
     type = 'id_t'
     format_unit = '" _Py_PARSE_PID "'
 
-class Py_intptr_t_converter(CConverter):
-    type = 'Py_intptr_t'
+class intptr_t_converter(CConverter):
+    type = 'intptr_t'
     format_unit = '" _Py_PARSE_INTPTR "'
 
 class Py_off_t_converter(CConverter):
@@ -5244,7 +5244,7 @@
     char **argvlist;
     int i;
     Py_ssize_t argc;
-    Py_intptr_t spawnval;
+    intptr_t spawnval;
     PyObject *(*getitem)(PyObject *, Py_ssize_t);
 
     /* spawnv has three arguments: (mode, path, argv), where
@@ -5323,7 +5323,7 @@
     char **envlist;
     PyObject *res = NULL;
     Py_ssize_t argc, i, envc;
-    Py_intptr_t spawnval;
+    intptr_t spawnval;
     PyObject *(*getitem)(PyObject *, Py_ssize_t);
     Py_ssize_t lastarg = 0;
 
@@ -7078,7 +7078,7 @@
 /* MS C has a variant of waitpid() that's usable for most purposes. */
 /*[clinic input]
 os.waitpid
-    pid: Py_intptr_t
+    pid: intptr_t
     options: int
     /
 
@@ -7091,11 +7091,11 @@
 [clinic start generated code]*/
 
 static PyObject *
-os_waitpid_impl(PyObject *module, Py_intptr_t pid, int options)
+os_waitpid_impl(PyObject *module, intptr_t pid, int options)
 /*[clinic end generated code: output=15f1ce005a346b09 input=444c8f51cca5b862]*/
 {
     int status;
-    Py_intptr_t res;
+    intptr_t res;
     int async_err = 0;
 
     do {
@@ -8559,8 +8559,8 @@
     Py_BEGIN_ALLOW_THREADS
     ok = CreatePipe(&read, &write, &attr, 0);
     if (ok) {
-        fds[0] = _open_osfhandle((Py_intptr_t)read, _O_RDONLY);
-        fds[1] = _open_osfhandle((Py_intptr_t)write, _O_WRONLY);
+        fds[0] = _open_osfhandle((intptr_t)read, _O_RDONLY);
+        fds[1] = _open_osfhandle((intptr_t)write, _O_WRONLY);
         if (fds[0] == -1 || fds[1] == -1) {
             CloseHandle(read);
             CloseHandle(write);
@@ -11375,14 +11375,14 @@
 #ifdef MS_WINDOWS
 /*[clinic input]
 os.get_handle_inheritable -> bool
-    handle: Py_intptr_t
+    handle: intptr_t
     /
 
 Get the close-on-exe flag of the specified file descriptor.
 [clinic start generated code]*/
 
 static int
-os_get_handle_inheritable_impl(PyObject *module, Py_intptr_t handle)
+os_get_handle_inheritable_impl(PyObject *module, intptr_t handle)
 /*[clinic end generated code: output=9e5389b0aa0916ce input=5f7759443aae3dc5]*/
 {
     DWORD flags;
@@ -11398,7 +11398,7 @@
 
 /*[clinic input]
 os.set_handle_inheritable
-    handle: Py_intptr_t
+    handle: intptr_t
     inheritable: bool
     /
 
@@ -11406,7 +11406,7 @@
 [clinic start generated code]*/
 
 static PyObject *
-os_set_handle_inheritable_impl(PyObject *module, Py_intptr_t handle,
+os_set_handle_inheritable_impl(PyObject *module, intptr_t handle,
                                int inheritable)
 /*[clinic end generated code: output=b1e67bfa3213d745 input=e64b2b2730469def]*/
 {
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -1797,7 +1797,7 @@
  */
 #if !defined(__OpenBSD__)
 #   define IDENT_TYPE  T_UINTPTRT
-#   define IDENT_CAST  Py_intptr_t
+#   define IDENT_CAST  intptr_t
 #   define DATA_TYPE   T_INTPTRT
 #   define DATA_FMT_UNIT INTPTRT_FMT_UNIT
 #   define IDENT_AsType PyLong_AsUintptr_t
@@ -1876,7 +1876,7 @@
 kqueue_event_richcompare(kqueue_event_Object *s, kqueue_event_Object *o,
                          int op)
 {
-    Py_intptr_t result = 0;
+    intptr_t result = 0;
 
     if (!kqueue_event_Check(o)) {
         if (op == Py_EQ || op == Py_NE) {
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -198,7 +198,7 @@
 report_wakeup_write_error(void *data)
 {
     int save_errno = errno;
-    errno = (int) (Py_intptr_t) data;
+    errno = (int) (intptr_t) data;
     PyErr_SetFromErrno(PyExc_OSError);
     PySys_WriteStderr("Exception ignored when trying to write to the "
                       "signal wakeup fd:\n");
@@ -277,7 +277,7 @@
 
             if (rc < 0) {
                 Py_AddPendingCall(report_wakeup_write_error,
-                                  (void *)(Py_intptr_t)errno);
+                                  (void *)(intptr_t)errno);
             }
         }
     }
diff --git a/Modules/sre_lib.h b/Modules/sre_lib.h
--- a/Modules/sre_lib.h
+++ b/Modules/sre_lib.h
@@ -529,7 +529,7 @@
     if (ctx->pattern[0] == SRE_OP_INFO) {
         /* optimization info block */
         /* <INFO> <1=skip> <2=flags> <3=min> ... */
-        if (ctx->pattern[3] && (Py_uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) {
+        if (ctx->pattern[3] && (uintptr_t)(end - ctx->ptr) < ctx->pattern[3]) {
             TRACE(("reject (got %" PY_FORMAT_SIZE_T "d chars, "
                    "need %" PY_FORMAT_SIZE_T "d)\n",
                    end - ctx->ptr, (Py_ssize_t) ctx->pattern[3]));
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1019,7 +1019,7 @@
 static PyObject *
 wrapper_richcompare(PyObject *a, PyObject *b, int op)
 {
-    Py_intptr_t result;
+    intptr_t result;
     PyObject *v;
     PyWrapperDescrObject *a_descr, *b_descr;
 
diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -989,13 +989,13 @@
 PyLong_FromVoidPtr(void *p)
 {
 #if SIZEOF_VOID_P <= SIZEOF_LONG
-    return PyLong_FromUnsignedLong((unsigned long)(Py_uintptr_t)p);
+    return PyLong_FromUnsignedLong((unsigned long)(uintptr_t)p);
 #else
 
 #if SIZEOF_LONG_LONG < SIZEOF_VOID_P
 #   error "PyLong_FromVoidPtr: sizeof(long long) < sizeof(void*)"
 #endif
-    return PyLong_FromUnsignedLongLong((unsigned long long)(Py_uintptr_t)p);
+    return PyLong_FromUnsignedLongLong((unsigned long long)(uintptr_t)p);
 #endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
 
 }
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -18,7 +18,7 @@
 #define uint    unsigned int    /* assuming >= 16 bits */
 
 #undef uptr
-#define uptr    Py_uintptr_t
+#define uptr    uintptr_t
 
 /* Forward declaration */
 static void* _PyMem_DebugRawMalloc(void *ctx, size_t size);
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -33,12 +33,12 @@
 #endif
 
 /*[python input]
-class Py_intptr_t_converter(CConverter):
-    type = 'Py_intptr_t'
+class intptr_t_converter(CConverter):
+    type = 'intptr_t'
     format_unit = '"_Py_PARSE_INTPTR"'
 
 class handle_return_converter(long_return_converter):
-    type = 'Py_intptr_t'
+    type = 'intptr_t'
     cast = '(void *)'
     conversion_fn = 'PyLong_FromVoidPtr'
 
@@ -148,7 +148,7 @@
 /*[clinic input]
 msvcrt.open_osfhandle -> long
 
-    handle: Py_intptr_t
+    handle: intptr_t
     flags: int
     /
 
@@ -160,7 +160,7 @@
 [clinic start generated code]*/
 
 static long
-msvcrt_open_osfhandle_impl(PyObject *module, Py_intptr_t handle, int flags)
+msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags)
 /*[clinic end generated code: output=bf65e422243a39f9 input=4d8516ed32db8f65]*/
 {
     int fd;
@@ -183,11 +183,11 @@
 Raises IOError if fd is not recognized.
 [clinic start generated code]*/
 
-static Py_intptr_t
+static intptr_t
 msvcrt_get_osfhandle_impl(PyObject *module, int fd)
 /*[clinic end generated code: output=eac47643338c0baa input=c7d18d02c8017ec1]*/
 {
-    Py_intptr_t handle = -1;
+    intptr_t handle = -1;
 
     if (!_PyVerify_fd(fd)) {
         PyErr_SetFromErrno(PyExc_IOError);
diff --git a/Parser/grammar.c b/Parser/grammar.c
--- a/Parser/grammar.c
+++ b/Parser/grammar.c
@@ -63,7 +63,7 @@
     s->s_upper = 0;
     s->s_accel = NULL;
     s->s_accept = 0;
-    return Py_SAFE_DOWNCAST(s - d->d_state, Py_intptr_t, int);
+    return Py_SAFE_DOWNCAST(s - d->d_state, intptr_t, int);
 }
 
 void
@@ -105,7 +105,7 @@
     if (Py_DebugFlag)
         printf("Label @ %8p, %d: %s\n", ll, ll->ll_nlabels,
                PyGrammar_LabelRepr(lb));
-    return Py_SAFE_DOWNCAST(lb - ll->ll_label, Py_intptr_t, int);
+    return Py_SAFE_DOWNCAST(lb - ll->ll_label, intptr_t, int);
 }
 
 /* Same, but rather dies than adds */
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -255,7 +255,7 @@
 #endif
         if (a >= tok->line_start)
             col_offset = Py_SAFE_DOWNCAST(a - tok->line_start,
-                                          Py_intptr_t, int);
+                                          intptr_t, int);
         else
             col_offset = -1;
 
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -178,7 +178,7 @@
         /* Sub-interpreter support: threads might have been switched
            under our feet using PyThreadState_Swap(). Fix the GIL last
            holder variable so that our heuristics work. */
-        _Py_atomic_store_relaxed(&gil_last_holder, (Py_uintptr_t)tstate);
+        _Py_atomic_store_relaxed(&gil_last_holder, (uintptr_t)tstate);
     }
 
     MUTEX_LOCK(gil_mutex);
@@ -240,7 +240,7 @@
     _Py_ANNOTATE_RWLOCK_ACQUIRED(&gil_locked, /*is_write=*/1);
 
     if (tstate != (PyThreadState*)_Py_atomic_load_relaxed(&gil_last_holder)) {
-        _Py_atomic_store_relaxed(&gil_last_holder, (Py_uintptr_t)tstate);
+        _Py_atomic_store_relaxed(&gil_last_holder, (uintptr_t)tstate);
         ++gil_switch_number;
     }
 
diff --git a/Python/compile.c b/Python/compile.c
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -476,9 +476,9 @@
 {
     basicblock *block;
     for (block = u->u_blocks; block != NULL; block = block->b_list) {
-        assert((Py_uintptr_t)block != 0xcbcbcbcbU);
-        assert((Py_uintptr_t)block != 0xfbfbfbfbU);
-        assert((Py_uintptr_t)block != 0xdbdbdbdbU);
+        assert((uintptr_t)block != 0xcbcbcbcbU);
+        assert((uintptr_t)block != 0xfbfbfbfbU);
+        assert((uintptr_t)block != 0xdbdbdbdbU);
         if (block->b_instr != NULL) {
             assert(block->b_ialloc > 0);
             assert(block->b_iused > 0);
diff --git a/Python/pystate.c b/Python/pystate.c
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -6,7 +6,7 @@
 #define GET_TSTATE() \
     ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
 #define SET_TSTATE(value) \
-    _Py_atomic_store_relaxed(&_PyThreadState_Current, (Py_uintptr_t)(value))
+    _Py_atomic_store_relaxed(&_PyThreadState_Current, (uintptr_t)(value))
 #define GET_INTERP_STATE() \
     (GET_TSTATE()->interp)
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list