diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-02-12 12:19:38 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-02-18 07:25:58 +0100 |
commit | e4ad14cc789090290550e3aa9640e4969037e8b7 (patch) | |
tree | 94d366cf331ee1f5dc10fc4e4298a41ed878acfd /testsuites/sptests | |
parent | libdl/rap: Add the section alloc call after section load was split (diff) | |
download | rtems-e4ad14cc789090290550e3aa9640e4969037e8b7.tar.bz2 |
score: Avoid some deadlocks in _Once()
Recursive usage of the same pthread_once_t results now in a deadlock.
Previously, an error of EINVAL was returned. This usage scenario is
invalid according to the POSIX pthread_once() specification.
Close #3334.
Diffstat (limited to 'testsuites/sptests')
-rw-r--r-- | testsuites/sptests/spcxx01/init.cc | 21 | ||||
-rw-r--r-- | testsuites/sptests/spcxx01/spcxx01.doc | 2 |
2 files changed, 20 insertions, 3 deletions
diff --git a/testsuites/sptests/spcxx01/init.cc b/testsuites/sptests/spcxx01/init.cc index 7962810da0..b7be220092 100644 --- a/testsuites/sptests/spcxx01/init.cc +++ b/testsuites/sptests/spcxx01/init.cc @@ -29,6 +29,7 @@ #include "config.h" #endif +#include <future> #include <new> #include <rtems.h> @@ -41,10 +42,8 @@ struct alignas(256) S { int i; }; -extern "C" void Init(rtems_task_argument arg) +static void test_aligned_new(void) { - TEST_BEGIN(); - int *i = static_cast<decltype(i)>( ::operator new(sizeof(*i), std::align_val_t(256)) ); @@ -58,6 +57,20 @@ extern "C" void Init(rtems_task_argument arg) rtems_test_assert(s != nullptr); rtems_test_assert(reinterpret_cast<uintptr_t>(s) % 256 == 0); delete s; +} + +static void test_future(void) +{ + std::future<int> f = std::async(std::launch::async, []{ return 12358; }); + rtems_test_assert(f.get() == 12358); +} + +extern "C" void Init(rtems_task_argument arg) +{ + TEST_BEGIN(); + + test_aligned_new(); + test_future(); TEST_END(); exit(0); @@ -69,6 +82,8 @@ extern "C" void Init(rtems_task_argument arg) #define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/testsuites/sptests/spcxx01/spcxx01.doc b/testsuites/sptests/spcxx01/spcxx01.doc index 669e6820ab..73e6a3f83a 100644 --- a/testsuites/sptests/spcxx01/spcxx01.doc +++ b/testsuites/sptests/spcxx01/spcxx01.doc @@ -5,7 +5,9 @@ test set name: spcxx01 directives: - ::operator new() + - std::async() concepts: - Ensure that the aligned new operator works. + - Ensure that std::async() works. |