summaryrefslogtreecommitdiff
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-03-24 15:21:57 -0700
committerRaymond Hettinger <python@rcn.com>2013-03-24 15:21:57 -0700
commit579084247b8b12d2d8ec3faa98ae60e7bd5dcfab (patch)
tree30c07db6430d8d82091a73757b4194cd6d6328a7 /Python/pystate.c
parentbbca631b3d681c2c81534d14e9bb746c3bb7c92b (diff)
parent86b17240c2e8176ba8ef55e39bf3b7d10914d8e4 (diff)
downloadcpython-579084247b8b12d2d8ec3faa98ae60e7bd5dcfab.tar.gz
merge
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)
{