diff --git a/Include/internal/pycore_object_deferred.h b/Include/internal/pycore_object_deferred.h index c070d768b7d771..4156b6594974fa 100644 --- a/Include/internal/pycore_object_deferred.h +++ b/Include/internal/pycore_object_deferred.h @@ -16,15 +16,20 @@ extern "C" { // counting should be tracked by the GC so that they are eventually collected. extern void _PyObject_SetDeferredRefcount(PyObject *op); +#ifdef Py_GIL_DISABLED static inline int _PyObject_HasDeferredRefcount(PyObject *op) { -#ifdef Py_GIL_DISABLED return _PyObject_HAS_GC_BITS(op, _PyGC_BITS_DEFERRED); +} #else +static inline int +_PyObject_HasDeferredRefcount(PyObject *Py_UNUSED(op)) +{ return 0; -#endif } +#endif + #ifdef __cplusplus } diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 9495ccc8ac3889..abaa81f8678c2a 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -782,16 +782,22 @@ PyStackRef_LongCheck(_PyStackRef stackref) return PyLong_Check(PyStackRef_AsPyObjectBorrow(stackref)); } +#ifdef Py_GIL_DISABLED static inline void _PyThreadState_PushCStackRef(PyThreadState *tstate, _PyCStackRef *ref) { -#ifdef Py_GIL_DISABLED _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; ref->next = tstate_impl->c_stack_refs; tstate_impl->c_stack_refs = ref; -#endif ref->ref = PyStackRef_NULL; } +#else +static inline void +_PyThreadState_PushCStackRef(PyThreadState *Py_UNUSED(tstate), _PyCStackRef *ref) +{ + ref->ref = PyStackRef_NULL; +} +#endif static inline void _PyThreadState_PushCStackRefNew(PyThreadState *tstate, _PyCStackRef *ref, PyObject *obj) @@ -800,27 +806,39 @@ _PyThreadState_PushCStackRefNew(PyThreadState *tstate, _PyCStackRef *ref, PyObje ref->ref = PyStackRef_FromPyObjectNew(obj); } + +#ifdef Py_GIL_DISABLED static inline void _PyThreadState_PopCStackRef(PyThreadState *tstate, _PyCStackRef *ref) { -#ifdef Py_GIL_DISABLED _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; assert(tstate_impl->c_stack_refs == ref); tstate_impl->c_stack_refs = ref->next; -#endif PyStackRef_XCLOSE(ref->ref); } static inline _PyStackRef _PyThreadState_PopCStackRefSteal(PyThreadState *tstate, _PyCStackRef *ref) { -#ifdef Py_GIL_DISABLED _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate; assert(tstate_impl->c_stack_refs == ref); tstate_impl->c_stack_refs = ref->next; -#endif return ref->ref; } +#else +static inline void +_PyThreadState_PopCStackRef(PyThreadState *Py_UNUSED(tstate), _PyCStackRef *ref) +{ + PyStackRef_XCLOSE(ref->ref); +} + +static inline _PyStackRef +_PyThreadState_PopCStackRefSteal(PyThreadState *Py_UNUSED(tstate), _PyCStackRef *ref) +{ + return ref->ref; +} +#endif + #ifdef Py_GIL_DISABLED diff --git a/Include/slots.h b/Include/slots.h index 4bf7bda0208a8d..3ef8768bbd26c3 100644 --- a/Include/slots.h +++ b/Include/slots.h @@ -42,7 +42,7 @@ struct PySlot { #define PySlot_STATIC_DATA(NAME, VALUE) \ {.sl_id=(NAME), .sl_flags=PySlot_STATIC, .sl_ptr=(VALUE)} -#define PySlot_END {0} +#define PySlot_END {0, 0, {0}, {0}} // Macros without designated initializers (for C++11 and below): diff --git a/Lib/test/test_cext/setup.py b/Lib/test/test_cext/setup.py index 58bee3e255a4b3..52b63773c98cc0 100644 --- a/Lib/test/test_cext/setup.py +++ b/Lib/test/test_cext/setup.py @@ -21,6 +21,8 @@ if not MSVC: # C compiler flags for GCC and clang BASE_CFLAGS = [ + '-Wall', + '-Wextra', # The purpose of test_cext extension is to check that building a C # extension using the Python C API does not emit C compiler warnings. '-Werror', @@ -71,6 +73,8 @@ if not MSVC: # C++ compiler flags for GCC and clang CPPFLAGS = [ + '-Wall', + '-Wextra', # gh-91321: The purpose of _testcppext extension is to check that building # a C++ extension using the Python C API does not emit C++ compiler # warnings