mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
feat(ble_mesh): add cas operation for bt_mesh_atomic_val_t
This commit is contained in:
@@ -147,6 +147,33 @@ static inline bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target,
|
||||
extern bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Atomic CAS operation.
|
||||
*
|
||||
* This compares the contents of @a *target
|
||||
* with the contents of @a excepted. If equal,
|
||||
* the operation is a read-modify-write operation
|
||||
* that writes @a new_val into @a *target and return true.
|
||||
* If they are not equal, the operation is a read
|
||||
* and return false.
|
||||
*
|
||||
* @param target Address of atomic variable.
|
||||
* @param excepted Value of excepted.
|
||||
* @param new_val Write value if compare sunncess.
|
||||
*
|
||||
* @return
|
||||
* - true: write operation succeeded.
|
||||
* - false: write operation failed.
|
||||
*/
|
||||
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
|
||||
static inline bool bt_mesh_atomic_campare_and_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t excepted, bt_mesh_atomic_val_t new_val)
|
||||
{
|
||||
return __atomic_compare_exchange_n(target, &excepted, &new_val, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
#else
|
||||
extern bool bt_mesh_atomic_campare_and_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t excepted, bt_mesh_atomic_val_t new_val);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @cond INTERNAL_HIDDEN
|
||||
*/
|
||||
|
Reference in New Issue
Block a user