mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-111863: Rename Py_NOGIL to Py_GIL_DISABLED (#111864)
Rename Py_NOGIL to Py_GIL_DISABLED
This commit is contained in:
parent
1c8f912ebd
commit
3b3ec0d77f
39 changed files with 82 additions and 81 deletions
|
|
@ -86,7 +86,7 @@ extern "C" {
|
|||
#define _Py_CRITICAL_SECTION_TWO_MUTEXES 0x2
|
||||
#define _Py_CRITICAL_SECTION_MASK 0x3
|
||||
|
||||
#ifdef Py_NOGIL
|
||||
#ifdef Py_GIL_DISABLED
|
||||
# define Py_BEGIN_CRITICAL_SECTION(op) \
|
||||
{ \
|
||||
_PyCriticalSection _cs; \
|
||||
|
|
@ -104,13 +104,13 @@ extern "C" {
|
|||
# define Py_END_CRITICAL_SECTION2() \
|
||||
_PyCriticalSection2_End(&_cs2); \
|
||||
}
|
||||
#else /* !Py_NOGIL */
|
||||
#else /* !Py_GIL_DISABLED */
|
||||
// The critical section APIs are no-ops with the GIL.
|
||||
# define Py_BEGIN_CRITICAL_SECTION(op)
|
||||
# define Py_END_CRITICAL_SECTION()
|
||||
# define Py_BEGIN_CRITICAL_SECTION2(a, b)
|
||||
# define Py_END_CRITICAL_SECTION2()
|
||||
#endif /* !Py_NOGIL */
|
||||
#endif /* !Py_GIL_DISABLED */
|
||||
|
||||
typedef struct {
|
||||
// Tagged pointer to an outer active critical section (or 0).
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ typedef FARPROC dl_funcptr;
|
|||
# define PYD_DEBUG_SUFFIX ""
|
||||
#endif
|
||||
|
||||
#ifdef Py_NOGIL
|
||||
#ifdef Py_GIL_DISABLED
|
||||
# define PYD_THREADING_TAG "t"
|
||||
#else
|
||||
# define PYD_THREADING_TAG ""
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ extern "C" {
|
|||
// ...
|
||||
// PyMutex_Unlock(&m);
|
||||
|
||||
// NOTE: In Py_NOGIL builds, `struct _PyMutex` is defined in Include/object.h.
|
||||
// The Py_NOGIL builds need the definition in Include/object.h for the
|
||||
// NOTE: In Py_GIL_DISABLED builds, `struct _PyMutex` is defined in Include/object.h.
|
||||
// The Py_GIL_DISABLED builds need the definition in Include/object.h for the
|
||||
// `ob_mutex` field in PyObject. For the default (non-free-threaded) build,
|
||||
// we define the struct here to avoid exposing it in the public API.
|
||||
#ifndef Py_NOGIL
|
||||
#ifndef Py_GIL_DISABLED
|
||||
struct _PyMutex { uint8_t v; };
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
|
|||
Furthermore, we can't use designated initializers in Extensions since these
|
||||
are not supported pre-C++20. Thus, keeping an internal copy here is the most
|
||||
backwards compatible solution */
|
||||
#if defined(Py_NOGIL)
|
||||
#if defined(Py_GIL_DISABLED)
|
||||
#define _PyObject_HEAD_INIT(type) \
|
||||
{ \
|
||||
.ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL, \
|
||||
|
|
@ -103,7 +103,7 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
|
|||
#ifdef Py_REF_DEBUG
|
||||
_Py_AddRefTotal(_PyInterpreterState_GET(), n);
|
||||
#endif
|
||||
#if !defined(Py_NOGIL)
|
||||
#if !defined(Py_GIL_DISABLED)
|
||||
op->ob_refcnt += n;
|
||||
#else
|
||||
if (_Py_IsOwnedByCurrentThread(op)) {
|
||||
|
|
@ -128,7 +128,7 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
|
|||
static inline void _Py_SetImmortal(PyObject *op)
|
||||
{
|
||||
if (op) {
|
||||
#ifdef Py_NOGIL
|
||||
#ifdef Py_GIL_DISABLED
|
||||
op->ob_tid = _Py_UNOWNED_TID;
|
||||
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
|
||||
op->ob_ref_shared = 0;
|
||||
|
|
@ -145,7 +145,7 @@ static inline void _Py_SetMortal(PyObject *op, Py_ssize_t refcnt)
|
|||
{
|
||||
if (op) {
|
||||
assert(_Py_IsImmortal(op));
|
||||
#ifdef Py_NOGIL
|
||||
#ifdef Py_GIL_DISABLED
|
||||
op->ob_tid = _Py_UNOWNED_TID;
|
||||
op->ob_ref_local = 0;
|
||||
op->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED);
|
||||
|
|
@ -169,7 +169,7 @@ static inline void _Py_ClearImmortal(PyObject *op)
|
|||
op = NULL; \
|
||||
} while (0)
|
||||
|
||||
#if !defined(Py_NOGIL)
|
||||
#if !defined(Py_GIL_DISABLED)
|
||||
static inline void
|
||||
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
|
||||
{
|
||||
|
|
@ -210,7 +210,7 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
|
|||
}
|
||||
|
||||
#else
|
||||
// TODO: implement Py_DECREF specializations for Py_NOGIL build
|
||||
// TODO: implement Py_DECREF specializations for Py_GIL_DISABLED build
|
||||
static inline void
|
||||
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
|
||||
{
|
||||
|
|
@ -238,7 +238,7 @@ _Py_REF_IS_QUEUED(Py_ssize_t ob_ref_shared)
|
|||
// Merge the local and shared reference count fields and add `extra` to the
|
||||
// refcount when merging.
|
||||
Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra);
|
||||
#endif // !defined(Py_NOGIL)
|
||||
#endif // !defined(Py_GIL_DISABLED)
|
||||
|
||||
#ifdef Py_REF_DEBUG
|
||||
# undef _Py_DEC_REFTOTAL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue