Skip to content

Commit 1a1bd2e

Browse files
authored
bpo-40302: Replace PY_INT64_T with int64_t (GH-19573)
* Replace PY_INT64_T with int64_t * Replace PY_UINT32_T with uint32_t * Replace PY_UINT64_T with uint64_t sha3module.c no longer checks if PY_UINT64_T is defined since it's always defined and uint64_t is always available on platforms supported by Python.
1 parent 9f5fe79 commit 1a1bd2e

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

Doc/c-api/init.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
11141114
.. versionadded:: 3.9
11151115
11161116
1117-
.. c:function:: PY_INT64_T PyInterpreterState_GetID(PyInterpreterState *interp)
1117+
.. c:function:: int64_t PyInterpreterState_GetID(PyInterpreterState *interp)
11181118
11191119
Return the interpreter's unique ID. If there was any error in doing
11201120
so then ``-1`` is returned and an error is set.

Include/internal/pycore_interp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct _xidregitem {
170170
struct _xidregitem *next;
171171
};
172172

173-
PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(PY_INT64_T);
173+
PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(int64_t);
174174

175175
PyAPI_FUNC(int) _PyInterpreterState_IDInitref(struct _is *);
176176
PyAPI_FUNC(void) _PyInterpreterState_IDIncref(struct _is *);

Modules/_randommodule.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ init_by_array(RandomObject *self, uint32_t init_key[], size_t key_length)
234234
static int
235235
random_seed_urandom(RandomObject *self)
236236
{
237-
PY_UINT32_T key[N];
237+
uint32_t key[N];
238238

239239
if (_PyOS_URandomNonblock(key, sizeof(key)) < 0) {
240240
return -1;
@@ -250,14 +250,14 @@ random_seed_time_pid(RandomObject *self)
250250
uint32_t key[5];
251251

252252
now = _PyTime_GetSystemClock();
253-
key[0] = (PY_UINT32_T)(now & 0xffffffffU);
254-
key[1] = (PY_UINT32_T)(now >> 32);
253+
key[0] = (uint32_t)(now & 0xffffffffU);
254+
key[1] = (uint32_t)(now >> 32);
255255

256-
key[2] = (PY_UINT32_T)getpid();
256+
key[2] = (uint32_t)getpid();
257257

258258
now = _PyTime_GetMonotonicClock();
259-
key[3] = (PY_UINT32_T)(now & 0xffffffffU);
260-
key[4] = (PY_UINT32_T)(now >> 32);
259+
key[3] = (uint32_t)(now & 0xffffffffU);
260+
key[4] = (uint32_t)(now >> 32);
261261

262262
init_by_array(self, key, Py_ARRAY_LENGTH(key));
263263
}

Modules/_sha3/sha3module.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
#elif PY_BIG_ENDIAN
4141
/* opt64 is not yet supported on big endian platforms */
4242
#define KeccakOpt 32
43-
#elif SIZEOF_VOID_P == 8 && defined(PY_UINT64_T)
43+
#elif SIZEOF_VOID_P == 8
4444
/* opt64 works only on little-endian 64bit platforms with unsigned int64 */
4545
#define KeccakOpt 64
4646
#else
4747
/* opt32 is used for the remaining 32 and 64bit platforms */
4848
#define KeccakOpt 32
4949
#endif
5050

51-
#if KeccakOpt == 64 && defined(PY_UINT64_T)
51+
#if KeccakOpt == 64
5252
/* 64bit platforms with unsigned int64 */
53-
typedef PY_UINT64_T UINT64;
53+
typedef uint64_t UINT64;
5454
typedef unsigned char UINT8;
5555
#endif
5656

Modules/_xxsubinterpretersmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ static PyObject *
21352135
interp_get_main(PyObject *self, PyObject *Py_UNUSED(ignored))
21362136
{
21372137
// Currently, 0 is always the main interpreter.
2138-
PY_INT64_T id = 0;
2138+
int64_t id = 0;
21392139
return _PyInterpreterID_New(id);
21402140
}
21412141

Objects/interpreteridobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ _PyInterpreterState_GetIDObject(PyInterpreterState *interp)
270270
if (_PyInterpreterState_IDInitref(interp) != 0) {
271271
return NULL;
272272
};
273-
PY_INT64_T id = PyInterpreterState_GetID(interp);
273+
int64_t id = PyInterpreterState_GetID(interp);
274274
if (id < 0) {
275275
return NULL;
276276
}

Python/pystate.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,11 @@ PyInterpreterState_GetID(PyInterpreterState *interp)
452452

453453

454454
static PyInterpreterState *
455-
interp_look_up_id(_PyRuntimeState *runtime, PY_INT64_T requested_id)
455+
interp_look_up_id(_PyRuntimeState *runtime, int64_t requested_id)
456456
{
457457
PyInterpreterState *interp = runtime->interpreters.head;
458458
while (interp != NULL) {
459-
PY_INT64_T id = PyInterpreterState_GetID(interp);
459+
int64_t id = PyInterpreterState_GetID(interp);
460460
if (id < 0) {
461461
return NULL;
462462
}
@@ -469,7 +469,7 @@ interp_look_up_id(_PyRuntimeState *runtime, PY_INT64_T requested_id)
469469
}
470470

471471
PyInterpreterState *
472-
_PyInterpreterState_LookUpID(PY_INT64_T requested_id)
472+
_PyInterpreterState_LookUpID(int64_t requested_id)
473473
{
474474
PyInterpreterState *interp = NULL;
475475
if (requested_id >= 0) {

0 commit comments

Comments
 (0)