Skip to content

Commit 1e6c4e1

Browse files
committed
Move Atomic.h to <mstd_atomic>
`mbed::Atomic<T>` becomes `mstd::atomic<T>`, alongside the other standard C++ library lookalikes.
1 parent 18c4be5 commit 1e6c4e1

File tree

4 files changed

+190
-186
lines changed

4 files changed

+190
-186
lines changed

TESTS/mbed_platform/atomic/main.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
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

2931
namespace {
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)
201205
template<typename T, size_t N>
202206
void 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;

mbed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
#include "drivers/InterruptIn.h"
8989
#include "platform/mbed_wait_api.h"
9090
#include "hal/sleep_api.h"
91-
#include "platform/Atomic.h"
91+
#include "platform/mbed_atomic.h"
9292
#include "platform/mbed_power_mgmt.h"
9393
#include "platform/mbed_rtc_time.h"
9494
#include "platform/mbed_poll.h"

0 commit comments

Comments
 (0)