From ca30a76297419a1e0eac2ee6a709dff70d30e56a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 21 Nov 2008 14:59:56 +0000 Subject: * python/python-internal.h (PyGILState_Ensure): New define. (PyGILState_Release): Likewise. (PyEval_InitThreads): Likewise. (PyThreadState_Swap): Likewise. (PyEval_InitThreads): Likewise. * python/python.c (_initialize_python): Initialize threads. Release GIL. (eval_python_from_control_command): Acquire GIL. (python_command): Likewise. * python/python-internal.h (make_cleanup_py_restore_gil): Declare. * python/python-utils.c (py_gil_restore): New function. (make_cleanup_py_restore_gil): Likewise. --- gdb/python/python-internal.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gdb/python/python-internal.h') diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 72f7a5f..dbc0a53 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -43,6 +43,17 @@ typedef Py_intptr_t Py_ssize_t; #error "Unable to find usable Python.h" #endif +/* If Python.h does not define WITH_THREAD, then the various + GIL-related functions will not be defined. However, + PyGILState_STATE will be. */ +#ifndef WITH_THREAD +#define PyGILState_Ensure() ((PyGILState_STATE) 0) +#define PyGILState_Release(ARG) (ARG) +#define PyEval_InitThreads() 0 +#define PyThreadState_Swap(ARG) (ARG) +#define PyEval_InitThreads() 0 +#endif + struct value; extern PyObject *gdb_module; @@ -57,6 +68,7 @@ struct value *convert_value_from_python (PyObject *obj); void gdbpy_initialize_values (void); struct cleanup *make_cleanup_py_decref (PyObject *py); +struct cleanup *make_cleanup_py_restore_gil (PyGILState_STATE *state); /* Use this after a TRY_EXCEPT to throw the appropriate Python exception. */ -- cgit v1.1