[pygobject] Disable calls to PyGILState_* when threads are disabled
- From: Simon van der Linden <svdlinden src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Disable calls to PyGILState_* when threads are disabled
- Date: Tue, 18 Jan 2011 18:12:07 +0000 (UTC)
commit a4b210d69c832629894090b7154ae194209b0c60
Author: Arnaud Charlet <charlet adacore com>
Date: Tue Jan 18 18:31:29 2011 +0100
Disable calls to PyGILState_* when threads are disabled
Since threads may also be disabled in Python too, those symbols may not
be resolved.
https://bugzilla.gnome.org/show_bug.cgi?id=374603
glib/pyglib.c | 12 ++++++++++++
gobject/pygobject-private.h | 6 ++++++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/glib/pyglib.c b/glib/pyglib.c
index 8163e88..1e024c2 100644
--- a/glib/pyglib.c
+++ b/glib/pyglib.c
@@ -94,7 +94,11 @@ pyglib_gil_state_ensure(void)
if (!_PyGLib_API->threads_enabled)
return PyGILState_LOCKED;
+#ifdef DISABLE_THREADING
+ return PyGILState_LOCKED;
+#else
return PyGILState_Ensure();
+#endif
}
void
@@ -105,7 +109,9 @@ pyglib_gil_state_release(PyGILState_STATE state)
if (!_PyGLib_API->threads_enabled)
return;
+#ifndef DISABLE_THREADING
PyGILState_Release(state);
+#endif
}
/**
@@ -171,13 +177,19 @@ _pyglib_notify_on_enabling_threads(PyGLibThreadsEnabledFunc callback)
int
pyglib_gil_state_ensure_py23 (void)
{
+#ifdef DISABLE_THREADING
+ return 0;
+#else
return PyGILState_Ensure();
+#endif
}
void
pyglib_gil_state_release_py23 (int flag)
{
+#ifndef DISABLE_THREADING
PyGILState_Release(flag);
+#endif
}
/**
diff --git a/gobject/pygobject-private.h b/gobject/pygobject-private.h
index ae4cfe1..a928cb1 100644
--- a/gobject/pygobject-private.h
+++ b/gobject/pygobject-private.h
@@ -32,12 +32,18 @@ extern struct _PyGObject_Functions pygobject_api_functions;
#define pyg_threads_enabled (pygobject_api_functions.threads_enabled)
+#ifdef DISABLE_THREADING
+#define pyg_gil_state_ensure() 0
+#define pyg_gil_state_release(state) G_STMT_START { \
+ } G_STMT_END
+#else
#define pyg_gil_state_ensure() (pygobject_api_functions.threads_enabled? (PyGILState_Ensure()) : 0)
#define pyg_gil_state_release(state) G_STMT_START { \
if (pygobject_api_functions.threads_enabled) \
PyGILState_Release(state); \
} G_STMT_END
+#endif
#define pyg_begin_allow_threads \
G_STMT_START { \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]