1818#include " unity/unity.h"
1919#include " utest/utest.h"
2020
21+ #include < mstd_atomic>
22+
2123#if !MBED_CONF_RTOS_PRESENT
2224#error [NOT_SUPPORTED] test not supported
2325#endif
@@ -28,6 +30,8 @@ using utest::v1::Case;
2830
2931namespace {
3032
33+ using mstd::atomic;
34+
3135/* Lock-free operations will be much faster - keep runtime down */
3236#define ADD_UNLOCKED_ITERATIONS (SystemCoreClock / 1000 )
3337#define ADD_LOCKED_ITERATIONS (SystemCoreClock / 8000 )
@@ -53,7 +57,7 @@ struct add_release_incrementer {
5357 static void op (A *ptr)
5458 {
5559 for (long i = add_iterations (*ptr); i > 0 ; i--) {
56- ptr->fetch_add (1 , mbed ::memory_order_release);
60+ ptr->fetch_add (1 , mstd ::memory_order_release);
5761 }
5862 }
5963};
@@ -120,8 +124,8 @@ void test_atomic_add()
120124{
121125 struct {
122126 volatile T nonatomic1;
123- Atomic <T> atomic1;
124- volatile Atomic <T> atomic2; // use volatile just to exercise the templates' volatile methods
127+ atomic <T> atomic1;
128+ volatile atomic <T> atomic2; // use volatile just to exercise the templates' volatile methods
125129 volatile T nonatomic2;
126130 } data = { 0 , { 0 }, { 1 }, 0 }; // test initialisation
127131
@@ -201,17 +205,17 @@ void struct_incrementer_b(A *data)
201205template <typename T, size_t N>
202206void test_atomic_struct ()
203207{
204- TEST_ASSERT_EQUAL (N, sizeof (Atomic <T>));
208+ TEST_ASSERT_EQUAL (N, sizeof (atomic <T>));
205209
206210 // Small structures don't have value constructor implemented;
207- Atomic <T> data;
211+ atomic <T> data;
208212 atomic_init (&data, T{0 , 0 , 0 });
209213
210214 Thread t1 (osPriorityNormal, THREAD_STACK);
211215 Thread t2 (osPriorityNormal, THREAD_STACK);
212216
213- TEST_ASSERT_EQUAL (osOK, t1.start (callback (struct_incrementer_a<Atomic <T> >, &data)));
214- TEST_ASSERT_EQUAL (osOK, t2.start (callback (struct_incrementer_b<Atomic <T> >, &data)));
217+ TEST_ASSERT_EQUAL (osOK, t1.start (callback (struct_incrementer_a<atomic <T> >, &data)));
218+ TEST_ASSERT_EQUAL (osOK, t2.start (callback (struct_incrementer_b<atomic <T> >, &data)));
215219
216220 for (long i = add_iterations (data); i > 0 ; i--) {
217221 T curval = data, newval;
0 commit comments