]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-100892: consolidate `HEAD_LOCK/HEAD_UNLOCK` macros (#100953)
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Sun, 15 Jan 2023 15:09:26 +0000 (20:39 +0530)
committerGitHub <noreply@github.com>
Sun, 15 Jan 2023 15:09:26 +0000 (20:39 +0530)
Include/internal/pycore_pystate.h
Modules/_threadmodule.c
Python/ceval.c
Python/pystate.c

index 3d6d400f74dd1deb54c97a9a039c7e0057f9aa23..736c2b30d8e097414e9e4a4d4ef960fe2b6129e3 100644 (file)
@@ -162,6 +162,12 @@ PyAPI_FUNC(int) _PyState_AddModule(
 
 PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);
 
+#define HEAD_LOCK(runtime) \
+    PyThread_acquire_lock((runtime)->interpreters.mutex, WAIT_LOCK)
+#define HEAD_UNLOCK(runtime) \
+    PyThread_release_lock((runtime)->interpreters.mutex)
+
+
 #ifdef __cplusplus
 }
 #endif
index 4fbf0e551b078e5d6fa29ae3875ee21eed23cde2..80f467a8e21d66a112bacb81462ad6197793c651 100644 (file)
@@ -839,11 +839,6 @@ local_traverse(localobject *self, visitproc visit, void *arg)
     return 0;
 }
 
-#define HEAD_LOCK(runtime) \
-    PyThread_acquire_lock((runtime)->interpreters.mutex, WAIT_LOCK)
-#define HEAD_UNLOCK(runtime) \
-    PyThread_release_lock((runtime)->interpreters.mutex)
-
 static int
 local_clear(localobject *self)
 {
index 7deee76cc5b89c0ebb01049098648a2968a11040..ecbe2f9d51363fbfc4f59189b751172b0f0ad988 100644 (file)
 #define _Py_atomic_load_relaxed_int32(ATOMIC_VAL) _Py_atomic_load_relaxed(ATOMIC_VAL)
 #endif
 
-#define HEAD_LOCK(runtime) \
-    PyThread_acquire_lock((runtime)->interpreters.mutex, WAIT_LOCK)
-#define HEAD_UNLOCK(runtime) \
-    PyThread_release_lock((runtime)->interpreters.mutex)
-
 /* Forward declarations */
 static PyObject *trace_call_function(
     PyThreadState *tstate, PyObject *callable, PyObject **stack,
index f2f571faf401bf57d321f03a05688ca567422cd5..bf9b8db9a7ed460496e7dff73cac57593037d89a 100644 (file)
@@ -231,10 +231,6 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
 }
 #endif
 
-#define HEAD_LOCK(runtime) \
-    PyThread_acquire_lock((runtime)->interpreters.mutex, WAIT_LOCK)
-#define HEAD_UNLOCK(runtime) \
-    PyThread_release_lock((runtime)->interpreters.mutex)
 
 /* Forward declaration */
 static void _PyGILState_NoteThreadState(