summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-09-06 20:47:26 (GMT)
committerBenjamin Peterson <benjamin@python.org>2016-09-06 20:47:26 (GMT)
commitca4706399879b30e952c402637b4fc0d4d2e661c (patch)
tree72f97b545d4d31afd06a8874fcbb578cb178aa0d /Modules
parent3c397e4c39430000348f2f64d9e394bf1b61c509 (diff)
downloadcpython-ca4706399879b30e952c402637b4fc0d4d2e661c.zip
cpython-ca4706399879b30e952c402637b4fc0d4d2e661c.tar.gz
cpython-ca4706399879b30e952c402637b4fc0d4d2e661c.tar.bz2
replace Py_(u)intptr_t with the c99 standard types
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_elementtree.c8
-rw-r--r--Modules/_sre.c14
-rw-r--r--Modules/_testcapimodule.c16
-rw-r--r--Modules/_tracemalloc.c30
-rw-r--r--Modules/faulthandler.c10
-rw-r--r--Modules/posixmodule.c26
-rw-r--r--Modules/selectmodule.c4
-rw-r--r--Modules/signalmodule.c4
-rw-r--r--Modules/sre_lib.h2
9 files changed, 57 insertions, 57 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 39eba7c..ca5ab2c 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -57,9 +57,9 @@ do { memory -= size; printf("%8d - %s\n", memory, comment); } while (0)
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 @@ _elementtree_Element___deepcopy__(ElementObject *self, PyObject *memo)
}
/* 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
index 0a62f62..afa9099 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -1582,7 +1582,7 @@ _sre_compile_impl(PyObject *module, PyObject *pattern, int flags,
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 @@ _validate_charset(SRE_CODE *code, SRE_CODE *end)
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 @@ _validate_charset(SRE_CODE *code, SRE_CODE *end)
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 @@ _validate_charset(SRE_CODE *code, SRE_CODE *end)
}
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 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
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 @@ _validate_inner(SRE_CODE *code, SRE_CODE *end, Py_ssize_t groups)
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
index 8d2cf31..87cf4b2 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -113,10 +113,10 @@ test_sizeof_c_types(PyObject *self)
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 @@ tracemalloc_track(PyObject *self, PyObject *args)
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 @@ tracemalloc_untrack(PyObject *self, PyObject *args)
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 @@ tracemalloc_get_traceback(PyObject *self, PyObject *args)
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
index 48f5b47..1a53cfe 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -67,7 +67,7 @@ typedef struct
__attribute__((packed))
#endif
{
- Py_uintptr_t ptr;
+ uintptr_t ptr;
_PyTraceMalloc_domain_t domain;
} pointer_t;
@@ -523,7 +523,7 @@ static int
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 @@ tracemalloc_use_domain_cb(_Py_hashtable_t *old_traces,
}
-/* 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 @@ tracemalloc_use_domain(void)
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 @@ tracemalloc_remove_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
}
#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 @@ tracemalloc_add_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
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 @@ tracemalloc_add_trace(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
}
#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 @@ tracemalloc_init(void)
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 @@ finally:
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 @@ py_tracemalloc_get_object_traceback(PyObject *self, PyObject *obj)
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 @@ _PyMem_DumpTraceback(int fd, const void *ptr)
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 @@ _PyTraceMalloc_Fini(void)
}
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 @@ _PyTraceMalloc_Track(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr,
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 @@ _PyTraceMalloc_Untrack(_PyTraceMalloc_domain_t domain, Py_uintptr_t ptr)
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
index 8969b4c..c2d3000 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -1072,12 +1072,12 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
# 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 @@ static PyObject *
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
index df295c2..e88ee56 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2492,8 +2492,8 @@ class id_t_converter(CConverter):
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 @@ os_spawnv_impl(PyObject *module, int mode, PyObject *path, PyObject *argv)
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 @@ os_spawnve_impl(PyObject *module, int mode, PyObject *path, PyObject *argv,
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 @@ os_waitpid_impl(PyObject *module, pid_t pid, int options)
/* 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 @@ The options argument is ignored on Windows.
[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 @@ os_pipe_impl(PyObject *module)
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 @@ os_set_inheritable_impl(PyObject *module, int fd, int inheritable)
#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 @@ os_get_handle_inheritable_impl(PyObject *module, Py_intptr_t handle)
/*[clinic input]
os.set_handle_inheritable
- handle: Py_intptr_t
+ handle: intptr_t
inheritable: bool
/
@@ -11406,7 +11406,7 @@ Set the inheritable flag of the specified handle.
[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
index 80e7873..49fa1f5 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -1797,7 +1797,7 @@ static PyTypeObject kqueue_queue_Type;
*/
#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 @@ static PyObject *
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
index a1a18b0..e078091 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -198,7 +198,7 @@ static int
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 @@ trip_signal(int sig_num)
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
index 78f7ac7..0865fc6 100644
--- a/Modules/sre_lib.h
+++ b/Modules/sre_lib.h
@@ -529,7 +529,7 @@ entrance:
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]));