Skip to content

Commit b2ab210

Browse files
authored
gh-109693: Update pyruntimestate._finalizing to use pyatomic.h (gh-110837)
1 parent 8f07b6e commit b2ab210

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Include/internal/pycore_runtime.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern "C" {
99
#endif
1010

1111
#include "pycore_atexit.h" // struct _atexit_runtime_state
12-
#include "pycore_atomic.h" // _Py_atomic_address
1312
#include "pycore_ceval_state.h" // struct _ceval_runtime_state
1413
#include "pycore_faulthandler.h" // struct _faulthandler_runtime_state
1514
#include "pycore_floatobject.h" // struct _Py_float_runtime_state
@@ -170,7 +169,7 @@ typedef struct pyruntimestate {
170169
171170
Use _PyRuntimeState_GetFinalizing() and _PyRuntimeState_SetFinalizing()
172171
to access it, don't access it directly. */
173-
_Py_atomic_address _finalizing;
172+
PyThreadState *_finalizing;
174173
/* The ID of the OS thread in which we are finalizing. */
175174
unsigned long _finalizing_id;
176175

@@ -299,7 +298,7 @@ extern void _PyRuntime_Finalize(void);
299298

300299
static inline PyThreadState*
301300
_PyRuntimeState_GetFinalizing(_PyRuntimeState *runtime) {
302-
return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->_finalizing);
301+
return (PyThreadState*)_Py_atomic_load_ptr_relaxed(&runtime->_finalizing);
303302
}
304303

305304
static inline unsigned long
@@ -309,7 +308,7 @@ _PyRuntimeState_GetFinalizingID(_PyRuntimeState *runtime) {
309308

310309
static inline void
311310
_PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) {
312-
_Py_atomic_store_relaxed(&runtime->_finalizing, (uintptr_t)tstate);
311+
_Py_atomic_store_ptr_relaxed(&runtime->_finalizing, tstate);
313312
if (tstate == NULL) {
314313
_Py_atomic_store_ulong_relaxed(&runtime->_finalizing_id, 0);
315314
}

0 commit comments

Comments
 (0)