mirror of https://github.com/ARMmbed/mbed-os.git
Add bool atomics
parent
f8e3f5dc2c
commit
a71984093a
|
@ -100,6 +100,9 @@ void core_util_critical_section_exit(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* Inline bool implementations in the header use uint8_t versions to manipulate the bool */
|
||||
MBED_STATIC_ASSERT(sizeof(bool) == sizeof(uint8_t), "Surely bool is a byte");
|
||||
|
||||
#if MBED_EXCLUSIVE_ACCESS
|
||||
|
||||
/* Supress __ldrex and __strex deprecated warnings - "#3731-D: intrinsic is deprecated" */
|
||||
|
|
|
@ -211,6 +211,12 @@ bool core_util_atomic_cas_u32(volatile uint32_t *ptr, uint32_t *expectedCurrentV
|
|||
/** \copydoc core_util_atomic_cas_u8 */
|
||||
bool core_util_atomic_cas_u64(volatile uint64_t *ptr, uint64_t *expectedCurrentValue, uint64_t desiredValue);
|
||||
|
||||
/** \copydoc core_util_atomic_cas_u8 */
|
||||
MBED_FORCEINLINE bool core_util_atomic_cas_bool(volatile bool *ptr, bool *expectedCurrentValue, bool desiredValue)
|
||||
{
|
||||
return (bool)core_util_atomic_cas_u8((volatile uint8_t *)ptr, (uint8_t *)expectedCurrentValue, desiredValue);
|
||||
}
|
||||
|
||||
/** \copydoc core_util_atomic_cas_u8 */
|
||||
bool core_util_atomic_cas_ptr(void *volatile *ptr, void **expectedCurrentValue, void *desiredValue);
|
||||
|
||||
|
@ -257,6 +263,18 @@ MBED_FORCEINLINE uint32_t core_util_atomic_load_u32(const volatile uint32_t *val
|
|||
*/
|
||||
uint64_t core_util_atomic_load_u64(const volatile uint64_t *valuePtr);
|
||||
|
||||
/**
|
||||
* Atomic load.
|
||||
* @param valuePtr Target memory location.
|
||||
* @return The loaded value.
|
||||
*/
|
||||
MBED_FORCEINLINE bool core_util_atomic_load_bool(const volatile bool *valuePtr)
|
||||
{
|
||||
bool value = *valuePtr;
|
||||
MBED_BARRIER();
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomic load.
|
||||
* @param valuePtr Target memory location.
|
||||
|
@ -312,6 +330,18 @@ MBED_FORCEINLINE void core_util_atomic_store_u32(volatile uint32_t *valuePtr, ui
|
|||
*/
|
||||
void core_util_atomic_store_u64(volatile uint64_t *valuePtr, uint64_t desiredValue);
|
||||
|
||||
/**
|
||||
* Atomic store.
|
||||
* @param valuePtr Target memory location.
|
||||
* @param desiredValue The value to store.
|
||||
*/
|
||||
MBED_FORCEINLINE void core_util_atomic_store_bool(volatile bool *valuePtr, bool desiredValue)
|
||||
{
|
||||
MBED_BARRIER();
|
||||
*valuePtr = desiredValue;
|
||||
MBED_BARRIER();
|
||||
}
|
||||
|
||||
/**
|
||||
* Atomic store.
|
||||
* @param valuePtr Target memory location.
|
||||
|
|
Loading…
Reference in New Issue