Author: Armin Rigo <[email protected]>
Branch: release-1.11
Changeset: r3030:aadf924dcf23
Date: 2017-09-27 13:12 +0200
http://bitbucket.org/cffi/cffi/changeset/aadf924dcf23/
Log: hg merge default
diff --git a/c/misc_thread_common.h b/c/misc_thread_common.h
--- a/c/misc_thread_common.h
+++ b/c/misc_thread_common.h
@@ -65,22 +65,30 @@
/* Seems that CPython 3.5.1 made our job harder. Did not find out how
to do that without these hacks. We can't use PyThreadState_GET(),
because that calls PyThreadState_Get() which fails an assert if the
- result is NULL. */
-#if PY_MAJOR_VERSION >= 3 && !defined(_Py_atomic_load_relaxed)
- /* this was abruptly un-defined in 3.5.1 */
-void *volatile _PyThreadState_Current;
- /* XXX simple volatile access is assumed atomic */
-# define _Py_atomic_load_relaxed(pp) (*(pp))
-#endif
-
+ result is NULL. We can use _PyThreadState_UncheckedGet() from 3.6,
+ though. It was added in 3.5.2 but should never be used in 3.5.x
+ because it is not available in 3.5.0 or 3.5.1. */
+#if PY_VERSION_HEX >= 0x03060000
static PyThreadState *get_current_ts(void)
{
-#if defined(_Py_atomic_load_relaxed)
+ return _PyThreadState_UncheckedGet();
+}
+#else
+# if PY_MAJOR_VERSION >= 3 && !defined(_Py_atomic_load_relaxed)
+ /* this was abruptly un-defined in 3.5.1 */
+extern void *volatile _PyThreadState_Current;
+ /* XXX simple volatile access is assumed atomic */
+# define _Py_atomic_load_relaxed(pp) (*(pp))
+# endif
+static PyThreadState *get_current_ts(void)
+{
+# if defined(_Py_atomic_load_relaxed)
return (PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current);
-#else
+# else
return _PyThreadState_Current;
+# endif
+}
#endif
-}
static PyGILState_STATE gil_ensure(void)
{
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit