23 void gil_acquire() { py::gil_scoped_acquire gil; }
25 constexpr
char kModuleName[] =
"cross_module_gil_utils";
27 #if PY_MAJOR_VERSION >= 3 28 struct PyModuleDef moduledef = {
29 PyModuleDef_HEAD_INIT,
40 PyMethodDef module_methods[] = {
48 #if PY_MAJOR_VERSION >= 3 49 PyObject* PyInit_cross_module_gil_utils()
56 #if PY_MAJOR_VERSION >= 3 57 PyModule_Create(&moduledef);
59 Py_InitModule(kModuleName, module_methods);
64 sizeof(&gil_acquire) ==
sizeof(
void*),
65 "Function pointer must have the same size as void*");
66 PyModule_AddObject(m,
"gil_acquire_funcaddr",
67 PyLong_FromVoidPtr(reinterpret_cast<void*>(&gil_acquire)));
70 #if PY_MAJOR_VERSION >= 3
PYBIND11_EXPORT void initcross_module_gil_utils()