Skip to content

Commit 9d3dd89

Browse files
committed
bt_atomic: use atomic macro to replace wireless/bluetooth/bt_atomic.c
Signed-off-by: hujun5 <[email protected]>
1 parent 6135892 commit 9d3dd89

File tree

4 files changed

+11
-130
lines changed

4 files changed

+11
-130
lines changed

wireless/bluetooth/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ if(CONFIG_WIRELESS_BLUETOOTH)
2929
list(
3030
APPEND
3131
SRCS
32-
bt_atomic.c
3332
bt_att.c
3433
bt_conn.c
3534
bt_gatt.c

wireless/bluetooth/Make.defs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ifeq ($(CONFIG_WIRELESS_BLUETOOTH_HOST),y)
3030

3131
# Host-layer
3232

33-
CSRCS += bt_atomic.c bt_att.c bt_conn.c bt_gatt.c
33+
CSRCS += bt_att.c bt_conn.c bt_gatt.c
3434
CSRCS += bt_ioctl.c bt_keys.c bt_l2cap.c bt_smp.c
3535
CSRCS += bt_uuid.c bt_services.c
3636

wireless/bluetooth/bt_atomic.c

-112
This file was deleted.

wireless/bluetooth/bt_atomic.h

+10-16
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,20 @@
3737
* Pre-processor Definitions
3838
****************************************************************************/
3939

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)
4349

4450
/****************************************************************************
4551
* Public Types
4652
****************************************************************************/
4753

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;
6155

6256
#endif /* __WIRELESS_BLUETOOTH_BT_ATOMIC_H */

0 commit comments

Comments
 (0)