Skip to content

Commit

Permalink
Rename Py_NOGIL to Py_DISABLE_GIL
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Nov 9, 2023
1 parent 52ff880 commit af090d9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_DISABLE_GIL is defined to 1). In the
* default build, this field is always zero.
*/
uintptr_t critical_section;
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_critical_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern "C" {
#define _Py_CRITICAL_SECTION_TWO_MUTEXES 0x2
#define _Py_CRITICAL_SECTION_MASK 0x3

#ifdef Py_NOGIL
#ifdef Py_DISABLE_GIL
# define Py_BEGIN_CRITICAL_SECTION(op) \
{ \
_PyCriticalSection _cs; \
Expand All @@ -104,13 +104,13 @@ extern "C" {
# define Py_END_CRITICAL_SECTION2() \
_PyCriticalSection2_End(&_cs2); \
}
#else /* !Py_NOGIL */
#else /* !Py_DISABLE_GIL */
// 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_DISABLE_GIL */

typedef struct {
// Tagged pointer to an outer active critical section (or 0).
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_DISABLE_GIL builds, `struct _PyMutex` is defined in Include/object.h.
// The Py_DISABLE_GIL 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_DISABLE_GIL
struct _PyMutex { uint8_t v; };
#endif

Expand Down
4 changes: 2 additions & 2 deletions Modules/_testinternalcapi/test_critical_sections.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "pycore_critical_section.h"

#ifdef Py_NOGIL
#ifdef Py_DISABLE_GIL
#define assert_nogil assert
#define assert_gil(x)
#else
Expand All @@ -25,7 +25,7 @@ test_critical_sections(PyObject *self, PyObject *Py_UNUSED(args))
assert(d2 != NULL);

// Beginning a critical section should lock the associated object and
// push the critical section onto the thread's stack (in Py_NOGIL builds).
// push the critical section onto the thread's stack (in Py_DISABLE_GIL builds).
Py_BEGIN_CRITICAL_SECTION(d1);
assert_nogil(PyMutex_IsLocked(&d1->ob_mutex));
assert_nogil(_PyCriticalSection_IsActive(PyThreadState_GET()->critical_section));
Expand Down

0 comments on commit af090d9

Please sign in to comment.