diff options
author | Bobby R. Bruce <bbruce@ucdavis.edu> | 2019-09-23 13:52:58 -0700 |
---|---|---|
committer | Bobby R. Bruce <bbruce@ucdavis.edu> | 2019-09-24 21:40:15 +0000 |
commit | f97cf54db7a6f7642cc9fd122f23c4396c39bcf0 (patch) | |
tree | 17d2ed22a1114cb138500d46afddb3bafcc2b418 /ext/pybind11/tests/test_virtual_functions.cpp | |
parent | 9235ae56c282d5a02ada3ed9b4e0fe2ee5738bde (diff) | |
download | gem5-f97cf54db7a6f7642cc9fd122f23c4396c39bcf0.tar.xz |
ext: Updated Pybind11 to version 2.4.1.
This updates Pybind11 from version 2.2.1 to version 2.4.1. This fixes
warning/error received when "<experiment/optional>" is used when
compiling using c++14 with clang. It should be noted that
"ext/pybind11/include/pybind11/std.h" has been changed to include a fix
added by commit ba42457254cc362eddc099f22b60d469cc6369e0. This is
necessary to avoid build errors.
Built: Linux (gcc, c++11) and MacOS (clang, c++14).
Tested: Ran quick tests for X86, ARM, and RISC-V.
Deprecates: https://gem5-review.googlesource.com/c/public/gem5/+/21019
Change-Id: Ie9783511cb6be50136076a55330e645f4f36d075
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21119
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'ext/pybind11/tests/test_virtual_functions.cpp')
-rw-r--r-- | ext/pybind11/tests/test_virtual_functions.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/ext/pybind11/tests/test_virtual_functions.cpp b/ext/pybind11/tests/test_virtual_functions.cpp index 953b390b8..ccf018d99 100644 --- a/ext/pybind11/tests/test_virtual_functions.cpp +++ b/ext/pybind11/tests/test_virtual_functions.cpp @@ -10,6 +10,7 @@ #include "pybind11_tests.h" #include "constructor_stats.h" #include <pybind11/functional.h> +#include <thread> /* This is an example class that we'll want to be able to extend from Python */ class ExampleVirt { @@ -17,7 +18,7 @@ public: ExampleVirt(int state) : state(state) { print_created(this, state); } ExampleVirt(const ExampleVirt &e) : state(e.state) { print_copy_created(this); } ExampleVirt(ExampleVirt &&e) : state(e.state) { print_move_created(this); e.state = 0; } - ~ExampleVirt() { print_destroyed(this); } + virtual ~ExampleVirt() { print_destroyed(this); } virtual int run(int value) { py::print("Original implementation of " @@ -128,6 +129,7 @@ private: class NCVirt { public: + virtual ~NCVirt() { } virtual NonCopyable get_noncopyable(int a, int b) { return NonCopyable(a, b); } virtual Movable get_movable(int a, int b) = 0; @@ -157,6 +159,28 @@ struct DispatchIssue : Base { } }; +static void test_gil() { + { + py::gil_scoped_acquire lock; + py::print("1st lock acquired"); + + } + + { + py::gil_scoped_acquire lock; + py::print("2nd lock acquired"); + } + +} + +static void test_gil_from_thread() { + py::gil_scoped_release release; + + std::thread t(test_gil); + t.join(); +} + + // Forward declaration (so that we can put the main tests here; the inherited virtual approaches are // rather long). void initialize_inherited_virtuals(py::module &m); @@ -207,7 +231,9 @@ TEST_SUBMODULE(virtual_functions, m) { void f() override { py::print("PyA.f()"); - PYBIND11_OVERLOAD(void, A, f); + // This convolution just gives a `void`, but tests that PYBIND11_TYPE() works to protect + // a type containing a , + PYBIND11_OVERLOAD(PYBIND11_TYPE(typename std::enable_if<true, void>::type), A, f); } }; @@ -249,7 +275,7 @@ TEST_SUBMODULE(virtual_functions, m) { m.def("dispatch_issue_go", [](const Base * b) { return b->dispatch(); }); // test_override_ref - // #392/397: overridding reference-returning functions + // #392/397: overriding reference-returning functions class OverrideTest { public: struct A { std::string value = "hi"; }; @@ -414,7 +440,6 @@ public: }; */ - void initialize_inherited_virtuals(py::module &m) { // test_inherited_virtuals @@ -447,4 +472,8 @@ void initialize_inherited_virtuals(py::module &m) { py::class_<D_Tpl, C_Tpl, PyB_Tpl<D_Tpl>>(m, "D_Tpl") .def(py::init<>()); + + // Fix issue #1454 (crash when acquiring/releasing GIL on another thread in Python 2.7) + m.def("test_gil", &test_gil); + m.def("test_gil_from_thread", &test_gil_from_thread); }; |