Skip to content

Commit 7713093

Browse files
committed
Rename Py_NOGIL to Py_DISABLE_GIL
1 parent 804575b commit 7713093

35 files changed

+76
-75
lines changed

Include/internal/pycore_importdl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typedef FARPROC dl_funcptr;
3131
# define PYD_DEBUG_SUFFIX ""
3232
#endif
3333

34-
#ifdef Py_NOGIL
34+
#ifdef Py_DISABLE_GIL
3535
# define PYD_THREADING_TAG "t"
3636
#else
3737
# define PYD_THREADING_TAG ""

Include/internal/pycore_object.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
5454
Furthermore, we can't use designated initializers in Extensions since these
5555
are not supported pre-C++20. Thus, keeping an internal copy here is the most
5656
backwards compatible solution */
57-
#if defined(Py_NOGIL)
57+
#if defined(Py_DISABLE_GIL)
5858
#define _PyObject_HEAD_INIT(type) \
5959
{ \
6060
.ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL, \
@@ -103,7 +103,7 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
103103
#ifdef Py_REF_DEBUG
104104
_Py_AddRefTotal(_PyInterpreterState_GET(), n);
105105
#endif
106-
#if !defined(Py_NOGIL)
106+
#if !defined(Py_DISABLE_GIL)
107107
op->ob_refcnt += n;
108108
#else
109109
if (_Py_IsOwnedByCurrentThread(op)) {
@@ -128,7 +128,7 @@ static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)
128128
static inline void _Py_SetImmortal(PyObject *op)
129129
{
130130
if (op) {
131-
#ifdef Py_NOGIL
131+
#ifdef Py_DISABLE_GIL
132132
op->ob_tid = _Py_UNOWNED_TID;
133133
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
134134
op->ob_ref_shared = 0;
@@ -145,7 +145,7 @@ static inline void _Py_SetMortal(PyObject *op, Py_ssize_t refcnt)
145145
{
146146
if (op) {
147147
assert(_Py_IsImmortal(op));
148-
#ifdef Py_NOGIL
148+
#ifdef Py_DISABLE_GIL
149149
op->ob_tid = _Py_UNOWNED_TID;
150150
op->ob_ref_local = 0;
151151
op->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED);
@@ -169,7 +169,7 @@ static inline void _Py_ClearImmortal(PyObject *op)
169169
op = NULL; \
170170
} while (0)
171171

172-
#if !defined(Py_NOGIL)
172+
#if !defined(Py_DISABLE_GIL)
173173
static inline void
174174
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
175175
{
@@ -210,7 +210,7 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
210210
}
211211

212212
#else
213-
// TODO: implement Py_DECREF specializations for Py_NOGIL build
213+
// TODO: implement Py_DECREF specializations for Py_DISABLE_GIL build
214214
static inline void
215215
_Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
216216
{
@@ -238,7 +238,7 @@ _Py_REF_IS_QUEUED(Py_ssize_t ob_ref_shared)
238238
// Merge the local and shared reference count fields and add `extra` to the
239239
// refcount when merging.
240240
Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra);
241-
#endif // !defined(Py_NOGIL)
241+
#endif // !defined(Py_DISABLE_GIL)
242242

243243
#ifdef Py_REF_DEBUG
244244
# undef _Py_DEC_REFTOTAL

Include/object.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ check by comparing the reference count field to the immortality reference count.
106106
#define _Py_IMMORTAL_REFCNT (UINT_MAX >> 2)
107107
#endif
108108

109-
// Py_NOGIL builds indicate immortal objects using `ob_ref_local`, which is
109+
// Py_DISABLE_GIL builds indicate immortal objects using `ob_ref_local`, which is
110110
// always 32-bits.
111-
#ifdef Py_NOGIL
111+
#ifdef Py_DISABLE_GIL
112112
#define _Py_IMMORTAL_REFCNT_LOCAL UINT32_MAX
113113
#endif
114114

115115
// Make all internal uses of PyObject_HEAD_INIT immortal while preserving the
116116
// C-API expectation that the refcnt will be set to 1.
117-
#if defined(Py_NOGIL)
117+
#if defined(Py_DISABLE_GIL)
118118
#define PyObject_HEAD_INIT(type) \
119119
{ \
120120
0, \
@@ -159,7 +159,7 @@ check by comparing the reference count field to the immortality reference count.
159159
* by hand. Similarly every pointer to a variable-size Python object can,
160160
* in addition, be cast to PyVarObject*.
161161
*/
162-
#ifndef Py_NOGIL
162+
#ifndef Py_DISABLE_GIL
163163
struct _object {
164164
#if (defined(__GNUC__) || defined(__clang__)) \
165165
&& !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)
@@ -231,7 +231,7 @@ typedef struct {
231231
PyAPI_FUNC(int) Py_Is(PyObject *x, PyObject *y);
232232
#define Py_Is(x, y) ((x) == (y))
233233

234-
#if defined(Py_NOGIL) && !defined(Py_LIMITED_API)
234+
#if defined(Py_DISABLE_GIL) && !defined(Py_LIMITED_API)
235235
static inline uintptr_t
236236
_Py_ThreadId(void)
237237
{
@@ -268,7 +268,7 @@ _Py_IsOwnedByCurrentThread(PyObject *ob)
268268
#endif
269269

270270
static inline Py_ssize_t Py_REFCNT(PyObject *ob) {
271-
#if !defined(Py_NOGIL)
271+
#if !defined(Py_DISABLE_GIL)
272272
return ob->ob_refcnt;
273273
#else
274274
uint32_t local = _Py_atomic_load_uint32_relaxed(&ob->ob_ref_local);
@@ -309,7 +309,7 @@ static inline Py_ssize_t Py_SIZE(PyObject *ob) {
309309

310310
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
311311
{
312-
#if defined(Py_NOGIL)
312+
#if defined(Py_DISABLE_GIL)
313313
return op->ob_ref_local == _Py_IMMORTAL_REFCNT_LOCAL;
314314
#elif SIZEOF_VOID_P > 4
315315
return _Py_CAST(PY_INT32_T, op->ob_refcnt) < 0;
@@ -343,7 +343,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
343343
if (_Py_IsImmortal(ob)) {
344344
return;
345345
}
346-
#ifndef Py_NOGIL
346+
#ifndef Py_DISABLE_GIL
347347
ob->ob_refcnt = refcnt;
348348
#else
349349
if (_Py_IsOwnedByCurrentThread(ob)) {
@@ -360,7 +360,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
360360
ob->ob_ref_local = 0;
361361
ob->ob_ref_shared = _Py_REF_SHARED(refcnt, _Py_REF_MERGED);
362362
}
363-
#endif // Py_NOGIL
363+
#endif // Py_DISABLE_GIL
364364
#endif // Py_LIMITED_API+0 < 0x030d0000
365365
}
366366
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
@@ -739,7 +739,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
739739
#else
740740
// Non-limited C API and limited C API for Python 3.9 and older access
741741
// directly PyObject.ob_refcnt.
742-
#if defined(Py_NOGIL)
742+
#if defined(Py_DISABLE_GIL)
743743
uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local);
744744
uint32_t new_local = local + 1;
745745
if (new_local == 0) {
@@ -777,7 +777,7 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
777777
#endif
778778

779779

780-
#if !defined(Py_LIMITED_API) && defined(Py_NOGIL)
780+
#if !defined(Py_LIMITED_API) && defined(Py_DISABLE_GIL)
781781
// Implements Py_DECREF on objects not owned by the current thread.
782782
PyAPI_FUNC(void) _Py_DecRefShared(PyObject *);
783783
PyAPI_FUNC(void) _Py_DecRefSharedDebug(PyObject *, const char *, int);
@@ -803,7 +803,7 @@ static inline void Py_DECREF(PyObject *op) {
803803
}
804804
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op))
805805

806-
#elif defined(Py_NOGIL) && defined(Py_REF_DEBUG)
806+
#elif defined(Py_DISABLE_GIL) && defined(Py_REF_DEBUG)
807807
static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
808808
{
809809
uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local);
@@ -828,7 +828,7 @@ static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
828828
}
829829
#define Py_DECREF(op) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
830830

831-
#elif defined(Py_NOGIL)
831+
#elif defined(Py_DISABLE_GIL)
832832
static inline void Py_DECREF(PyObject *op)
833833
{
834834
uint32_t local = _Py_atomic_load_uint32_relaxed(&op->ob_ref_local);

Lib/sysconfig/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _init_non_posix(vars):
348348
vars['BINLIBDEST'] = get_path('platstdlib')
349349
vars['INCLUDEPY'] = get_path('include')
350350

351-
# Add EXT_SUFFIX, SOABI, and Py_NOGIL
351+
# Add EXT_SUFFIX, SOABI, and Py_DISABLE_GIL
352352
vars.update(_sysconfig.config_vars())
353353

354354
vars['LIBDIR'] = _safe_realpath(os.path.join(get_config_var('installed_base'), 'libs'))

Lib/test/libregrtest/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def get_build_info():
290290
build = []
291291

292292
# --disable-gil
293-
if sysconfig.get_config_var('Py_NOGIL'):
293+
if sysconfig.get_config_var('Py_DISABLE_GIL'):
294294
build.append("nogil")
295295

296296
if hasattr(sys, 'gettotalrefcount'):

Lib/test/pythoninfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ def collect_sysconfig(info_add):
516516
'PY_LDFLAGS_NODIST',
517517
'PY_STDMODULE_CFLAGS',
518518
'Py_DEBUG',
519+
'Py_DISABLE_GIL',
519520
'Py_ENABLE_SHARED',
520-
'Py_NOGIL',
521521
'SHELL',
522522
'SOABI',
523523
'abs_builddir',

Lib/test/support/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def check_cflags_pgo():
796796
return any(option in cflags_nodist for option in pgo_options)
797797

798798

799-
if sysconfig.get_config_var('Py_NOGIL'):
799+
if sysconfig.get_config_var('Py_DISABLE_GIL'):
800800
_header = 'PHBBInP'
801801
else:
802802
_header = 'nP'

Lib/test/test_cppext/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# gh-110119: pip does not currently support 't' in the ABI flag use by
1717
# --disable-gil builds. Once it does, we can remove this skip.
18-
@unittest.skipIf(sysconfig.get_config_var('Py_NOGIL') == 1,
18+
@unittest.skipIf(sysconfig.get_config_var('Py_DISABLE_GIL') == 1,
1919
'test does not work with --disable-gil')
2020
@support.requires_subprocess()
2121
class TestCPPExt(unittest.TestCase):

Lib/test/test_importlib/test_windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_module_not_found(self):
112112
class WindowsExtensionSuffixTests:
113113
def test_tagged_suffix(self):
114114
suffixes = self.machinery.EXTENSION_SUFFIXES
115-
abi_flags = "t" if sysconfig.get_config_var("Py_NOGIL") else ""
115+
abi_flags = "t" if sysconfig.get_config_var("Py_DISABLE_GIL") else ""
116116
ver = sys.version_info
117117
platform = re.sub('[^a-zA-Z0-9]', '_', get_platform())
118118
expected_tag = f".cp{ver.major}{ver.minor}{abi_flags}-{platform}.pyd"

Lib/test/test_sys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,8 @@ def test_pystats(self):
12091209
@unittest.skipUnless(hasattr(sys, 'abiflags'), 'need sys.abiflags')
12101210
def test_disable_gil_abi(self):
12111211
abi_threaded = 't' in sys.abiflags
1212-
py_nogil = (sysconfig.get_config_var('Py_NOGIL') == 1)
1213-
self.assertEqual(py_nogil, abi_threaded)
1212+
py_disable_gil = (sysconfig.get_config_var('Py_DISABLE_GIL') == 1)
1213+
self.assertEqual(py_disable_gil, abi_threaded)
12141214

12151215

12161216
@test.support.cpython_only
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rename ``Py_NOGIL`` to ``Py_DISABLE_GIL``. Patch by Hugo van Kemenade.

Modules/_ctypes/_ctypes_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef _MSC_VER
2-
#include "pyconfig.h" // Py_NOGIL
2+
#include "pyconfig.h" // Py_DISABLE_GIL
33
#endif
44

5-
#ifndef Py_NOGIL
5+
#ifndef Py_DISABLE_GIL
66
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
77
#define Py_LIMITED_API 0x030c0000
88
#endif

Modules/_multiprocessing/posixshmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
posixshmem - A Python extension that provides shm_open() and shm_unlink()
33
*/
44

5-
#include "pyconfig.h" // Py_NOGIL
5+
#include "pyconfig.h" // Py_DISABLE_GIL
66

7-
#ifndef Py_NOGIL
7+
#ifndef Py_DISABLE_GIL
88
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
99
#define Py_LIMITED_API 0x030c0000
1010
#endif

Modules/_scproxy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55

66
#ifndef _MSC_VER
7-
#include "pyconfig.h" // Py_NOGIL
7+
#include "pyconfig.h" // Py_DISABLE_GIL
88
#endif
99

10-
#ifndef Py_NOGIL
10+
#ifndef Py_DISABLE_GIL
1111
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
1212
#define Py_LIMITED_API 0x030c0000
1313
#endif

Modules/_stat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
*/
1313

1414
#ifndef _MSC_VER
15-
#include "pyconfig.h" // Py_NOGIL
15+
#include "pyconfig.h" // Py_DISABLE_GIL
1616
#endif
1717

18-
#ifndef Py_NOGIL
18+
#ifndef Py_DISABLE_GIL
1919
// Need limited C API version 3.13 for PyModule_Add() on Windows
2020
#define Py_LIMITED_API 0x030d0000
2121
#endif

Modules/_sysconfig.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ _sysconfig_config_vars_impl(PyObject *module)
5757
}
5858
#endif
5959

60-
#ifdef Py_NOGIL
61-
PyObject *py_nogil = _PyLong_GetOne();
60+
#ifdef Py_DISABLE_GIL
61+
PyObject *py_disable_gil = _PyLong_GetOne();
6262
#else
63-
PyObject *py_nogil = _PyLong_GetZero();
63+
PyObject *py_disable_gil = _PyLong_GetZero();
6464
#endif
65-
if (PyDict_SetItemString(config, "Py_NOGIL", py_nogil) < 0) {
65+
if (PyDict_SetItemString(config, "Py_DISABLE_GIL", py_disable_gil) < 0) {
6666
Py_DECREF(config);
6767
return NULL;
6868
}

Modules/_testcapi/heaptype_relative.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef _MSC_VER
2-
#include "pyconfig.h" // Py_NOGIL
2+
#include "pyconfig.h" // Py_DISABLE_GIL
33
#endif
44

5-
#ifndef Py_NOGIL
5+
#ifndef Py_DISABLE_GIL
66
#define Py_LIMITED_API 0x030c0000 // 3.12
77
#endif
88

Modules/_testcapi/vectorcall_limited.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Test Vectorcall in the limited API */
22

33
#ifndef _MSC_VER
4-
#include "pyconfig.h" // Py_NOGIL
4+
#include "pyconfig.h" // Py_DISABLE_GIL
55
#endif
66

7-
#ifndef Py_NOGIL
7+
#ifndef Py_DISABLE_GIL
88
#define Py_LIMITED_API 0x030c0000 // 3.12
99
#endif
1010

Modules/_testclinic_limited.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#undef Py_BUILD_CORE_BUILTIN
66

77
#ifndef _MSC_VER
8-
#include "pyconfig.h" // Py_NOGIL
8+
#include "pyconfig.h" // Py_DISABLE_GIL
99
#endif
1010

11-
#ifndef Py_NOGIL
11+
#ifndef Py_DISABLE_GIL
1212
// For now, only limited C API 3.13 is supported
1313
#define Py_LIMITED_API 0x030d0000
1414
#endif

Modules/_testimportmultiple.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66

77
#ifndef _MSC_VER
8-
#include "pyconfig.h" // Py_NOGIL
8+
#include "pyconfig.h" // Py_DISABLE_GIL
99
#endif
1010

11-
#ifndef Py_NOGIL
11+
#ifndef Py_DISABLE_GIL
1212
#define Py_LIMITED_API 0x03020000
1313
#endif
1414

Modules/_uuidmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55

66
#ifndef _MSC_VER
7-
#include "pyconfig.h" // Py_NOGIL
7+
#include "pyconfig.h" // Py_DISABLE_GIL
88
#endif
99

10-
#ifndef Py_NOGIL
10+
#ifndef Py_DISABLE_GIL
1111
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
1212
#define Py_LIMITED_API 0x030c0000
1313
#endif

Modules/errnomodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Errno module */
22

33
#ifndef _MSC_VER
4-
#include "pyconfig.h" // Py_NOGIL
4+
#include "pyconfig.h" // Py_DISABLE_GIL
55
#endif
66

7-
#ifndef Py_NOGIL
7+
#ifndef Py_DISABLE_GIL
88
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
99
#define Py_LIMITED_API 0x030c0000
1010
#endif

0 commit comments

Comments
 (0)