diff options
author | gatecat <gatecat@ds0.me> | 2022-09-14 09:28:47 +0200 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2022-09-14 09:28:47 +0200 |
commit | a72f898ff4c4237424c468044a6db9d6953b541e (patch) | |
tree | 1c4a543f661dd1b281aecf4660388491702fa8d8 /3rdparty/pybind11/tests/cross_module_gil_utils.cpp | |
parent | f1349e114f3a16ccd002e8513339e18f5be4d31b (diff) | |
download | nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.tar.gz nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.tar.bz2 nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.zip |
3rdparty: Bump vendored pybind11 version for py3.11 support
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to '3rdparty/pybind11/tests/cross_module_gil_utils.cpp')
-rw-r--r-- | 3rdparty/pybind11/tests/cross_module_gil_utils.cpp | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/3rdparty/pybind11/tests/cross_module_gil_utils.cpp b/3rdparty/pybind11/tests/cross_module_gil_utils.cpp index 07db9f6e..1436c35d 100644 --- a/3rdparty/pybind11/tests/cross_module_gil_utils.cpp +++ b/3rdparty/pybind11/tests/cross_module_gil_utils.cpp @@ -7,6 +7,7 @@ BSD-style license that can be found in the LICENSE file. */ #include <pybind11/pybind11.h> + #include <cstdint> // This file mimics a DSO that makes pybind11 calls but does not define a @@ -24,50 +25,21 @@ void gil_acquire() { py::gil_scoped_acquire gil; } constexpr char kModuleName[] = "cross_module_gil_utils"; -#if PY_MAJOR_VERSION >= 3 struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - kModuleName, - NULL, - 0, - NULL, - NULL, - NULL, - NULL, - NULL -}; -#else -PyMethodDef module_methods[] = { - {NULL, NULL, 0, NULL} -}; -#endif + PyModuleDef_HEAD_INIT, kModuleName, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr}; -} // namespace +} // namespace -extern "C" PYBIND11_EXPORT -#if PY_MAJOR_VERSION >= 3 -PyObject* PyInit_cross_module_gil_utils() -#else -void initcross_module_gil_utils() -#endif -{ +extern "C" PYBIND11_EXPORT PyObject *PyInit_cross_module_gil_utils() { - PyObject* m = -#if PY_MAJOR_VERSION >= 3 - PyModule_Create(&moduledef); -#else - Py_InitModule(kModuleName, module_methods); -#endif + PyObject *m = PyModule_Create(&moduledef); - if (m != NULL) { - static_assert( - sizeof(&gil_acquire) == sizeof(void*), - "Function pointer must have the same size as void*"); - PyModule_AddObject(m, "gil_acquire_funcaddr", - PyLong_FromVoidPtr(reinterpret_cast<void*>(&gil_acquire))); + if (m != nullptr) { + static_assert(sizeof(&gil_acquire) == sizeof(void *), + "Function pointer must have the same size as void*"); + PyModule_AddObject( + m, "gil_acquire_funcaddr", PyLong_FromVoidPtr(reinterpret_cast<void *>(&gil_acquire))); } -#if PY_MAJOR_VERSION >= 3 return m; -#endif } |