3 # User Victor Stinner <victor.stinner@gmail.com>
4 # Date 1442581594 -7200
5 # Node ID d4fcb362f7c66b25b22ddc0d27db0cc96acc727b
6 # Parent d04a0954e142f873adee88ec5bc1c1d81cd46bc4
7 Issue #25150: Hide the private _Py_atomic_xxx symbols from the public
8 Python.h header to fix a compilation error with OpenMP. PyThreadState_GET()
9 becomes an alias to PyThreadState_Get() to avoid ABI incompatibilies.
11 It is important that the _PyThreadState_Current variable is always accessed
12 with the same implementation of pyatomic.h. Use the PyThreadState_Get()
13 function so extension modules will all reuse the same implementation.
15 diff --git a/Include/pyatomic.h b/Include/pyatomic.h
16 --- a/Include/pyatomic.h
17 +++ b/Include/pyatomic.h
19 -/* Issue #23644: <stdatomic.h> is incompatible with C++, see:
20 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 */
21 -#if !defined(Py_LIMITED_API) && !defined(__cplusplus)
26 #include "dynamic_annotations.h"
28 @@ -248,5 +246,5 @@ static __inline__ void
29 #define _Py_atomic_load_relaxed(ATOMIC_VAL) \
30 _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
32 +#endif /* Py_BUILD_CORE */
33 #endif /* Py_ATOMIC_H */
34 -#endif /* Py_LIMITED_API */
35 diff --git a/Include/pystate.h b/Include/pystate.h
36 --- a/Include/pystate.h
37 +++ b/Include/pystate.h
38 @@ -177,20 +177,13 @@ PyAPI_FUNC(int) PyThreadState_SetAsyncEx
39 /* Variable and macro for in-line access to current thread state */
41 /* Assuming the current thread holds the GIL, this is the
42 - PyThreadState for the current thread.
44 - Issue #23644: pyatomic.h is incompatible with C++ (yet). Disable
45 - PyThreadState_GET() optimization: declare it as an alias to
46 - PyThreadState_Get(), as done for limited API. */
47 -#if !defined(Py_LIMITED_API) && !defined(__cplusplus)
48 + PyThreadState for the current thread. */
50 PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
53 -#if defined(Py_DEBUG) || defined(Py_LIMITED_API) || defined(__cplusplus)
54 -#define PyThreadState_GET() PyThreadState_Get()
55 +# define PyThreadState_GET() \
56 + ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
58 -#define PyThreadState_GET() \
59 - ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
60 +# define PyThreadState_GET() PyThreadState_Get()
64 diff --git a/Misc/NEWS b/Misc/NEWS
67 @@ -11,6 +11,10 @@ Release date: TBA
71 +- Issue #25150: Hide the private _Py_atomic_xxx symbols from the public
72 + Python.h header to fix a compilation error with OpenMP. PyThreadState_GET()
73 + becomes an alias to PyThreadState_Get() to avoid ABI incompatibilies.