summaryrefslogtreecommitdiff
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-04-30 16:34:30 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2013-04-30 16:34:30 +0300
commitc6666f2ecc6dfd60aa6fe88950c5dfb2eb8d6687 (patch)
treed32b1b16efb870f6f89d2b7cced40620296efa00 /Python/pystate.c
parent14a057272cda4f9703954afaa0156517bb0b321f (diff)
parent2ee4b800e8fc729e008e576bd7e12aa1c0935098 (diff)
downloadcpython-c6666f2ecc6dfd60aa6fe88950c5dfb2eb8d6687.tar.gz
#17881: merge with 3.3.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index cfd61d0098..70038936d6 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -697,6 +697,15 @@ PyGILState_GetThisThreadState(void)
return (PyThreadState *)PyThread_get_key_value(autoTLSkey);
}
+int
+PyGILState_Check(void)
+{
+ /* can't use PyThreadState_Get() since it will assert that it has the GIL */
+ PyThreadState *tstate = (PyThreadState*)_Py_atomic_load_relaxed(
+ &_PyThreadState_Current);
+ return tstate && (tstate == PyGILState_GetThisThreadState());
+}
+
PyGILState_STATE
PyGILState_Ensure(void)
{