Commit Graph

9 Commits (4b3cddff2a66d5b13ad861e8782d1d630c2479c1)

Author SHA1 Message Date
Rajkumar Kanagaraj eb40dbcc20 Remove ARMC5 reference from Mbed OS platform 2020-03-19 10:48:14 -07:00
Kevin Bracey d31879a1d4 Atomics: GCC fix for M23 (again)
Add another missing unified syntax directive. Was previously fixed in
03f1ac3ffd, but the same problem was not addressed in the pending PR that
added the `NEWVAL_2OP` assembler.
2019-08-13 10:46:48 +03:00
Kevin Bracey b1c35b7a86 Move Atomic.h to <mstd_atomic>
`mbed::Atomic<T>` becomes `mstd::atomic<T>`, alongside the other
standard C++ library lookalikes.
2019-07-18 20:02:07 +03:00
Kevin Bracey 3fd7e11595 mbed_atomic templates: add noexcept
Add noexcept for consistency with upcoming Atomic.h
2019-07-09 19:09:02 +03:00
Kevin Bracey f9f887d88e mbed_atomic_impl.h: Add pre-op (xxx_fetch) forms
Even though C/C++11 don't offer pre-op forms (that do the operation then
return the new value) of their freestanding functions, we will be making
them visible via pre-op operators on `Atomic<T>` (++, --, +=, -=, &=,
|=, ^=).

It is easier to do a pre-op than a post-op, as we can use one
fewer register in the assembler, so it's worth optimising for what will
be quite common cases. Make these forms accessible for `Atomic<T>`, but
don't document them for standalone use at this stage.
2019-07-09 19:09:02 +03:00
Kevin Bracey 03f1ac3ffd Atomics: GCC fix for M23 (ARMv8-M baseline)
Add unified syntax directives to make the atomic assembler work when GCC
is building for M23.

GCC actually uses unified syntax when compiling C code, but puts
`.syntax divided` before each piece of inline assembly when targetting
Thumb-1 type devices like M0 and M23 for backwards compatibility. We can
overcome this with our own `.syntax unified`.  The command-line option
`-masm-syntax-unified` intended to override this globally has been
broken from GCC 6 to 8.0.
2019-05-29 16:48:41 +03:00
Kevin Bracey c799dc3332 ARMC5: fix mbed_atomic_impl.h assembly 2019-05-16 13:06:16 +03:00
Kevin Bracey 2bb40450ec Add non-volatile atomic loads and stores
Volatile makes no real difference when we're using assembler, or locked
functions, but leaving it off could be more efficient for the basic
loads and stores. So add non-volatile overloads in C++ for them.
2019-04-26 13:12:35 +03:00
Kevin Bracey 87396e0bf6 Assembler atomics
Reimplement atomic code in inline assembly. This can improve
optimisation, and avoids potential architectural problems with using
LDREX/STREX intrinsics.

API further extended:
* Bitwise operations (fetch_and/fetch_or/fetch_xor)
* fetch_add and fetch_sub (like incr/decr, but returning old value -
  aligning with C++11)
* compare_exchange_weak
* Explicit memory order specification
* Basic freestanding template overloads for C++

This gives our existing C implementation essentially all the functionality
needed by C++11.

An actual Atomic<T> template based upon these C functions could follow.
2019-04-26 13:12:35 +03:00