mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #23644: Fix issues with C++ when compiling Python extensions
Disable completly pyatomic.h on C++, because <stdatomic.h> is not compatible with C++. <pyatomic.h> is only needed by the optimized PyThreadState_GET() macro in pystate.h. Instead, declare PyThreadState_GET() as an alias to PyThreadState_Get(), as done for limited API.
This commit is contained in:
parent
b28de01992
commit
6562b29e13
2 changed files with 10 additions and 12 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
#ifndef Py_LIMITED_API
|
/* Issue #23644: <stdatomic.h> is incompatible with C++, see:
|
||||||
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 */
|
||||||
|
#if !defined(Py_LIMITED_API) && !defined(__cplusplus)
|
||||||
#ifndef Py_ATOMIC_H
|
#ifndef Py_ATOMIC_H
|
||||||
#define Py_ATOMIC_H
|
#define Py_ATOMIC_H
|
||||||
|
|
||||||
|
|
@ -6,10 +8,6 @@
|
||||||
|
|
||||||
#include "pyconfig.h"
|
#include "pyconfig.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_STD_ATOMIC)
|
#if defined(HAVE_STD_ATOMIC)
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -250,9 +248,5 @@ _Py_ANNOTATE_MEMORY_ORDER(const volatile void *address, _Py_memory_order order)
|
||||||
#define _Py_atomic_load_relaxed(ATOMIC_VAL) \
|
#define _Py_atomic_load_relaxed(ATOMIC_VAL) \
|
||||||
_Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
|
_Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* Py_ATOMIC_H */
|
#endif /* Py_ATOMIC_H */
|
||||||
#endif /* Py_LIMITED_API */
|
#endif /* Py_LIMITED_API */
|
||||||
|
|
|
||||||
|
|
@ -174,12 +174,16 @@ PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
||||||
/* Variable and macro for in-line access to current thread state */
|
/* Variable and macro for in-line access to current thread state */
|
||||||
|
|
||||||
/* Assuming the current thread holds the GIL, this is the
|
/* Assuming the current thread holds the GIL, this is the
|
||||||
PyThreadState for the current thread. */
|
PyThreadState for the current thread.
|
||||||
#ifndef Py_LIMITED_API
|
|
||||||
|
Issue #23644: pyatomic.h is incompatible with C++ (yet). Disable
|
||||||
|
PyThreadState_GET() optimization: declare it as an alias to
|
||||||
|
PyThreadState_Get(), as done for limited API. */
|
||||||
|
#if !defined(Py_LIMITED_API) && !defined(__cplusplus)
|
||||||
PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
|
PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
|
#if defined(Py_DEBUG) || defined(Py_LIMITED_API) || defined(__cplusplus)
|
||||||
#define PyThreadState_GET() PyThreadState_Get()
|
#define PyThreadState_GET() PyThreadState_Get()
|
||||||
#else
|
#else
|
||||||
#define PyThreadState_GET() \
|
#define PyThreadState_GET() \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue