diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2023-11-20 13:52:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-20 13:52:00 (GMT) |
commit | 3b3ec0d77f0f836cbe5ff1ab97efcc8b7ed5d787 (patch) | |
tree | f79786b7e97064b1a71840ac9c1421e87d6adc15 /Include | |
parent | 1c8f912ebdfdb146cd7dd2d7a3a67d2c5045ddb0 (diff) | |
download | cpython-3b3ec0d77f0f836cbe5ff1ab97efcc8b7ed5d787.zip cpython-3b3ec0d77f0f836cbe5ff1ab97efcc8b7ed5d787.tar.gz cpython-3b3ec0d77f0f836cbe5ff1ab97efcc8b7ed5d787.tar.bz2 |
gh-111863: Rename `Py_NOGIL` to `Py_GIL_DISABLED` (#111864)
Rename Py_NOGIL to Py_GIL_DISABLED
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/pystate.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_critical_section.h | 6 | ||||
-rw-r--r-- | Include/internal/pycore_importdl.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_lock.h | 6 | ||||
-rw-r--r-- | Include/internal/pycore_object.h | 14 | ||||
-rw-r--r-- | Include/object.h | 26 |
6 files changed, 28 insertions, 28 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h index 34e2383..56172d2 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/pystate.h @@ -151,7 +151,7 @@ struct _ts { /* Tagged pointer to top-most critical section, or zero if there is no * active critical section. Critical sections are only used in - * `--disable-gil` builds (i.e., when Py_NOGIL is defined to 1). In the + * `--disable-gil` builds (i.e., when Py_GIL_DISABLED is defined to 1). In the * default build, this field is always zero. */ uintptr_t critical_section; diff --git a/Include/internal/pycore_critical_section.h b/Include/internal/pycore_critical_section.h index 73c2e24..bf2bbff 100644 --- a/Include/internal/pycore_critical_section.h +++ b/Include/internal/pycore_critical_section.h @@ -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). diff --git a/Include/internal/pycore_importdl.h b/Include/internal/pycore_importdl.h index dee6424..c858358 100644 --- a/Include/internal/pycore_importdl.h +++ b/Include/internal/pycore_importdl.h @@ -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 "" diff --git a/Include/internal/pycore_lock.h b/Include/internal/pycore_lock.h index 25c3cf5..f135cbb 100644 --- a/Include/internal/pycore_lock.h +++ b/Include/internal/pycore_lock.h @@ -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 diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 206d8a5..f413b84 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -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 diff --git a/Include/object.h b/Include/object.h index 061b509..6b70a49 100644 --- a/Include/object.h +++ b/Include/object.h @@ -106,9 +106,9 @@ check by comparing the reference count field to the immortality reference count. #define _Py_IMMORTAL_REFCNT (UINT_MAX >> 2) #endif -// Py_NOGIL builds indicate immortal objects using `ob_ref_local`, which is +// Py_GIL_DISABLED builds indicate immortal objects using `ob_ref_local`, which is // always 32-bits. -#ifdef Py_NOGIL +#ifdef Py_GIL_DISABLED #define _Py_IMMORTAL_REFCNT_LOCAL UINT32_MAX #endif @@ -117,7 +117,7 @@ check by comparing the reference count field to the immortality reference count. // Make all internal uses of PyObject_HEAD_INIT immortal while preserving the // C-API expectation that the refcnt will be set to 1. -#if defined(Py_NOGIL) +#if defined(Py_GIL_DISABLED) #define PyObject_HEAD_INIT(type) \ { \ 0, \ @@ -162,7 +162,7 @@ check by comparing the reference count field to the immortality reference count. * by hand. Similarly every pointer to a variable-size Python object can, * in addition, be cast to PyVarObject*. */ -#ifndef Py_NOGIL +#ifndef Py_GIL_DISABLED struct _object { #if (defined(__GNUC__) || defined(__clang__)) \ && !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) @@ -238,7 +238,7 @@ typedef struct { PyAPI_FUNC(int) Py_Is(PyObject *x, PyObject *y); #define Py_Is(x, y) ((x) == (y)) -#if defined(Py_NOGIL) && !defined(Py_LIMITED_API) +#if defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API) static inline uintptr_t _Py_ThreadId(void) { @@ -275,7 +275,7 @@ _Py_IsOwnedByCurrentThread(PyObject *ob) #endif static inline Py_ssize_t Py_REFCNT(PyObject *ob) { -#if !defined(Py_NOGIL) +#if !defined(Py_GIL_DISABLED) return ob->ob_refcnt; #else uint32_t local = _Py_atomic_load_uint32_relaxed(&ob->ob_ref_local); @@ -316,7 +316,7 @@ static inline Py_ssize_t Py_SIZE(PyObject *ob) { static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op) { -#if defined(Py_NOGIL) +#if defined(Py_GIL_DISABLED) return op->ob_ref_local == _Py_IMMORTAL_REFCNT_LOCAL; #elif SIZEOF_VOID_P > 4 return _Py_CAST(PY_INT32_T, op->ob_refcnt) < 0; @@ -350,7 +350,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) { if (_Py_IsImmortal(ob)) { return; } -#ifndef Py_NOGIL +#ifndef Py_GIL_DISABLED ob->ob_refcnt = refcnt; #else if (_Py_IsOwnedByCurrentThread(ob)) { @@ -367,7 +367,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) { ob->ob_ref_local = 0; ob->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED); } -#endif // Py_NOGIL +#endif // Py_GIL_DISABLED #endif // Py_LIMITED_API+0 < 0x030d0000 } #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 @@ -746,7 +746,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) #else // Non-limited C API and limited C API for Python 3.9 and older access // directly PyObject.ob_refcnt. -#if defined(Py_NOGIL) +#if defined(Py_GIL_DISABLED) uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); uint32_t new_local = local + 1; if (new_local == 0) { @@ -784,7 +784,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) #endif -#if !defined(Py_LIMITED_API) && defined(Py_NOGIL) +#if !defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) // Implements Py_DECREF on objects not owned by the current thread. PyAPI_FUNC(void) _Py_DecRefShared(PyObject *); PyAPI_FUNC(void) _Py_DecRefSharedDebug(PyObject *, const char *, int); @@ -810,7 +810,7 @@ static inline void Py_DECREF(PyObject *op) { } #define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op)) -#elif defined(Py_NOGIL) && defined(Py_REF_DEBUG) +#elif defined(Py_GIL_DISABLED) && defined(Py_REF_DEBUG) static inline void Py_DECREF(const char *filename, int lineno, PyObject *op) { uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); @@ -835,7 +835,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op) } #define Py_DECREF(op) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op)) -#elif defined(Py_NOGIL) +#elif defined(Py_GIL_DISABLED) static inline void Py_DECREF(PyObject *op) { uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local); |