MCPcopy Create free account
hub / github.com/pybind/pybind11 / PyInit_cross_module_gil_utils

Function PyInit_cross_module_gil_utils

tests/cross_module_gil_utils.cpp:88–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 PyModule_AddObject(m, Name, PyLong_FromVoidPtr(reinterpret_cast<void *>(&__VA_ARGS__)));
87
88extern "C" PYBIND11_EXPORT PyObject *PyInit_cross_module_gil_utils() {
89
90 PyObject *m = PyModule_Create(&moduledef);
91
92 if (m != nullptr) {
93 static_assert(sizeof(&gil_acquire) == sizeof(void *),
94 "Function pointer must have the same size as void*");
95#ifdef Py_GIL_DISABLED
96 PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
97#endif
98 ADD_FUNCTION("gil_acquire_funcaddr", gil_acquire)
99 ADD_FUNCTION("gil_multi_acquire_release_funcaddr", gil_multi_acquire_release)
100 ADD_FUNCTION("gil_acquire_inner_custom_funcaddr",
101 gil_acquire_inner<CustomAutoGIL, CustomAutoNoGIL>)
102 ADD_FUNCTION("gil_acquire_nested_custom_funcaddr",
103 gil_acquire_nested<CustomAutoGIL, CustomAutoNoGIL>)
104 ADD_FUNCTION("gil_acquire_inner_pybind11_funcaddr",
105 gil_acquire_inner<py::gil_scoped_acquire, py::gil_scoped_release>)
106 ADD_FUNCTION("gil_acquire_nested_pybind11_funcaddr",
107 gil_acquire_nested<py::gil_scoped_acquire, py::gil_scoped_release>)
108 }
109
110 return m;
111}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected