summaryrefslogtreecommitdiff
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2013-04-30 01:03:46 -0700
committerGregory P. Smith <greg@krypto.org>2013-04-30 01:03:46 -0700
commitf4a81018278410a686c152f5d77704b66a44e858 (patch)
tree1c9cc0c9c8c73f59ccc0483a86d571ce8722f318 /Python/pystate.c
parentf6eb3e9ba97d7489f84b9bc202c64c6b5022857f (diff)
parent1a46c427590ebe60b8c1befc08576558bcf23dae (diff)
downloadcpython-f4a81018278410a686c152f5d77704b66a44e858.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)
{