lbalhar / rpms / python3

Forked from rpms/python3 4 years ago
Clone
Robert Kuska 0837458
Robert Kuska 0837458
# HG changeset patch
Robert Kuska 0837458
# User Victor Stinner <victor.stinner@gmail.com>
Robert Kuska 0837458
# Date 1442581594 -7200
Robert Kuska 0837458
# Node ID d4fcb362f7c66b25b22ddc0d27db0cc96acc727b
Robert Kuska 0837458
# Parent  d04a0954e142f873adee88ec5bc1c1d81cd46bc4
Robert Kuska 0837458
Issue #25150: Hide the private _Py_atomic_xxx symbols from the public
Robert Kuska 0837458
Python.h header to fix a compilation error with OpenMP. PyThreadState_GET()
Robert Kuska 0837458
becomes an alias to PyThreadState_Get() to avoid ABI incompatibilies.
Robert Kuska 0837458
Robert Kuska 0837458
It is important that the _PyThreadState_Current variable is always accessed
Robert Kuska 0837458
with the same implementation of pyatomic.h. Use the PyThreadState_Get()
Robert Kuska 0837458
function so extension modules will all reuse the same implementation.
Robert Kuska 0837458
Robert Kuska 0837458
diff --git a/Include/pyatomic.h b/Include/pyatomic.h
Robert Kuska 0837458
--- a/Include/pyatomic.h
Robert Kuska 0837458
+++ b/Include/pyatomic.h
Robert Kuska 0837458
@@ -1,8 +1,6 @@
Robert Kuska 0837458
-/* Issue #23644: <stdatomic.h> is incompatible with C++, see:
Robert Kuska 0837458
-   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 */
Robert Kuska 0837458
-#if !defined(Py_LIMITED_API) && !defined(__cplusplus)
Robert Kuska 0837458
 #ifndef Py_ATOMIC_H
Robert Kuska 0837458
 #define Py_ATOMIC_H
Robert Kuska 0837458
+#ifdef Py_BUILD_CORE
Robert Kuska 0837458
 
Robert Kuska 0837458
 #include "dynamic_annotations.h"
Robert Kuska 0837458
 
Robert Kuska 0837458
@@ -248,5 +246,5 @@ static __inline__ void
Robert Kuska 0837458
 #define _Py_atomic_load_relaxed(ATOMIC_VAL) \
Robert Kuska 0837458
     _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed)
Robert Kuska 0837458
 
Robert Kuska 0837458
+#endif  /* Py_BUILD_CORE */
Robert Kuska 0837458
 #endif  /* Py_ATOMIC_H */
Robert Kuska 0837458
-#endif  /* Py_LIMITED_API */
Robert Kuska 0837458
diff --git a/Include/pystate.h b/Include/pystate.h
Robert Kuska 0837458
--- a/Include/pystate.h
Robert Kuska 0837458
+++ b/Include/pystate.h
Robert Kuska 0837458
@@ -177,20 +177,13 @@ PyAPI_FUNC(int) PyThreadState_SetAsyncEx
Robert Kuska 0837458
 /* Variable and macro for in-line access to current thread state */
Robert Kuska 0837458
 
Robert Kuska 0837458
 /* Assuming the current thread holds the GIL, this is the
Robert Kuska 0837458
-   PyThreadState for the current thread.
Robert Kuska 0837458
-
Robert Kuska 0837458
-   Issue #23644: pyatomic.h is incompatible with C++ (yet). Disable
Robert Kuska 0837458
-   PyThreadState_GET() optimization: declare it as an alias to
Robert Kuska 0837458
-   PyThreadState_Get(), as done for limited API. */
Robert Kuska 0837458
-#if !defined(Py_LIMITED_API) && !defined(__cplusplus)
Robert Kuska 0837458
+   PyThreadState for the current thread. */
Robert Kuska 0837458
+#ifdef Py_BUILD_CORE
Robert Kuska 0837458
 PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
Robert Kuska 0837458
-#endif
Robert Kuska 0837458
-
Robert Kuska 0837458
-#if defined(Py_DEBUG) || defined(Py_LIMITED_API) || defined(__cplusplus)
Robert Kuska 0837458
-#define PyThreadState_GET() PyThreadState_Get()
Robert Kuska 0837458
+#  define PyThreadState_GET() \
Robert Kuska 0837458
+             ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
Robert Kuska 0837458
 #else
Robert Kuska 0837458
-#define PyThreadState_GET() \
Robert Kuska 0837458
-    ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
Robert Kuska 0837458
+#  define PyThreadState_GET() PyThreadState_Get()
Robert Kuska 0837458
 #endif
Robert Kuska 0837458
 
Robert Kuska 0837458
 typedef