mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: platform/mbed_critical.h
- Revision:
- 184:08ed48f1de7f
- Parent:
- 180:96ed750bd169
--- a/platform/mbed_critical.h Tue Mar 20 17:01:51 2018 +0000 +++ b/platform/mbed_critical.h Thu Apr 19 17:12:19 2018 +0100 @@ -83,6 +83,13 @@ void core_util_critical_section_exit(void); /** + * Determine if we are currently in a critical section + * + * @return true if in a critical section, false otherwise. + */ +bool core_util_in_critical_section(void); + +/** * Atomic compare and set. It compares the contents of a memory location to a * given value and, only if they are the same, modifies the contents of that * memory location to a given new value. This is done as a single atomic @@ -137,7 +144,7 @@ * always succeeds if the current value is expected, as per the pseudocode * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. */ -bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue); +bool core_util_atomic_cas_u8(volatile uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue); /** * Atomic compare and set. It compares the contents of a memory location to a @@ -194,7 +201,7 @@ * always succeeds if the current value is expected, as per the pseudocode * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. */ -bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue); +bool core_util_atomic_cas_u16(volatile uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue); /** * Atomic compare and set. It compares the contents of a memory location to a @@ -251,7 +258,7 @@ * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. * } */ -bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue); +bool core_util_atomic_cas_u32(volatile uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue); /** * Atomic compare and set. It compares the contents of a memory location to a @@ -308,7 +315,7 @@ * always succeeds if the current value is expected, as per the pseudocode * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. */ -bool core_util_atomic_cas_ptr(void **ptr, void **expectedCurrentValue, void *desiredValue); +bool core_util_atomic_cas_ptr(void * volatile *ptr, void **expectedCurrentValue, void *desiredValue); /** * Atomic increment. @@ -316,7 +323,7 @@ * @param delta The amount being incremented. * @return The new incremented value. */ -uint8_t core_util_atomic_incr_u8(uint8_t *valuePtr, uint8_t delta); +uint8_t core_util_atomic_incr_u8(volatile uint8_t *valuePtr, uint8_t delta); /** * Atomic increment. @@ -324,7 +331,7 @@ * @param delta The amount being incremented. * @return The new incremented value. */ -uint16_t core_util_atomic_incr_u16(uint16_t *valuePtr, uint16_t delta); +uint16_t core_util_atomic_incr_u16(volatile uint16_t *valuePtr, uint16_t delta); /** * Atomic increment. @@ -332,7 +339,7 @@ * @param delta The amount being incremented. * @return The new incremented value. */ -uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta); +uint32_t core_util_atomic_incr_u32(volatile uint32_t *valuePtr, uint32_t delta); /** * Atomic increment. @@ -343,7 +350,7 @@ * @note The type of the pointer argument is not taken into account * and the pointer is incremented by bytes. */ -void *core_util_atomic_incr_ptr(void **valuePtr, ptrdiff_t delta); +void *core_util_atomic_incr_ptr(void * volatile *valuePtr, ptrdiff_t delta); /** * Atomic decrement. @@ -351,7 +358,7 @@ * @param delta The amount being decremented. * @return The new decremented value. */ -uint8_t core_util_atomic_decr_u8(uint8_t *valuePtr, uint8_t delta); +uint8_t core_util_atomic_decr_u8(volatile uint8_t *valuePtr, uint8_t delta); /** * Atomic decrement. @@ -359,7 +366,7 @@ * @param delta The amount being decremented. * @return The new decremented value. */ -uint16_t core_util_atomic_decr_u16(uint16_t *valuePtr, uint16_t delta); +uint16_t core_util_atomic_decr_u16(volatile uint16_t *valuePtr, uint16_t delta); /** * Atomic decrement. @@ -367,7 +374,7 @@ * @param delta The amount being decremented. * @return The new decremented value. */ -uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta); +uint32_t core_util_atomic_decr_u32(volatile uint32_t *valuePtr, uint32_t delta); /** * Atomic decrement. @@ -378,7 +385,7 @@ * @note The type of the pointer argument is not taken into account * and the pointer is decremented by bytes */ -void *core_util_atomic_decr_ptr(void **valuePtr, ptrdiff_t delta); +void *core_util_atomic_decr_ptr(void * volatile *valuePtr, ptrdiff_t delta); #ifdef __cplusplus } // extern "C"