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 ba42457254. 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>
This commit is contained in:
Bobby R. Bruce
2019-09-23 13:52:58 -07:00
parent 9235ae56c2
commit f97cf54db7
117 changed files with 4325 additions and 1141 deletions

View File

@@ -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);
};