|
37 | 37 | * Pre-processor Definitions
|
38 | 38 | ****************************************************************************/
|
39 | 39 |
|
40 |
| -#define bt_atomic_set(ptr, value) (*(ptr) = (value)) |
41 |
| -#define bt_atomic_get(ptr) (*(ptr)) |
42 |
| -#define bt_atomic_testbit(ptr, bitno) ((*(ptr) & (1 << (bitno))) != 0) |
| 40 | +#define bt_atomic_set(ptr, value) atomic_store((ptr), (value)); |
| 41 | +#define bt_atomic_get(ptr) atomic_load(ptr) |
| 42 | +#define bt_atomic_testbit(ptr, bitno) ((atomic_load(ptr) & (1 << (bitno))) != 0) |
| 43 | +#define bt_atomic_incr(ptr) atomic_fetch_add((ptr), 1) |
| 44 | +#define bt_atomic_decr(ptr) atomic_fetch_sub((ptr), 1) |
| 45 | +#define bt_atomic_setbit(ptr, bitno) atomic_fetch_or((ptr), ((1 << (bitno)))) |
| 46 | +#define bt_atomic_clrbit(ptr, bitno) atomic_fetch_and((ptr), (~(1 << (bitno)))) |
| 47 | +#define bt_atomic_testsetbit(ptr, bitno) ((atomic_fetch_or((ptr), (1 << (bitno))) & (1 << (bitno))) != 0) |
| 48 | +#define bt_atomic_testclrbit(ptr, bitno) ((atomic_fetch_and((ptr), ~(1 << (bitno))) & (1 << (bitno))) != 0) |
43 | 49 |
|
44 | 50 | /****************************************************************************
|
45 | 51 | * Public Types
|
46 | 52 | ****************************************************************************/
|
47 | 53 |
|
48 |
| -typedef uint8_t bt_atomic_t; |
49 |
| - |
50 |
| -/**************************************************************************** |
51 |
| - * Public Function Prototypes |
52 |
| - ****************************************************************************/ |
53 |
| - |
54 |
| -bt_atomic_t bt_atomic_incr(FAR bt_atomic_t *ptr); |
55 |
| -bt_atomic_t bt_atomic_decr(FAR bt_atomic_t *ptr); |
56 |
| -bt_atomic_t bt_atomic_setbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno); |
57 |
| -bt_atomic_t bt_atomic_clrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno); |
58 |
| - |
59 |
| -bool bt_atomic_testsetbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno); |
60 |
| -bool bt_atomic_testclrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno); |
| 54 | +typedef atomic_char bt_atomic_t; |
61 | 55 |
|
62 | 56 | #endif /* __WIRELESS_BLUETOOTH_BT_ATOMIC_H */
|
0 commit comments