Skip to content

Commit

Permalink
bt_atomic: use atomic macro to replace wireless/bluetooth/bt_atomic.c
Browse files Browse the repository at this point in the history
Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Dec 2, 2024
1 parent 30940d9 commit e337295
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 130 deletions.
1 change: 0 additions & 1 deletion wireless/bluetooth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ if(CONFIG_WIRELESS_BLUETOOTH)
list(
APPEND
SRCS
bt_atomic.c
bt_att.c
bt_conn.c
bt_gatt.c
Expand Down
2 changes: 1 addition & 1 deletion wireless/bluetooth/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ifeq ($(CONFIG_WIRELESS_BLUETOOTH_HOST),y)

# Host-layer

CSRCS += bt_atomic.c bt_att.c bt_conn.c bt_gatt.c
CSRCS += bt_att.c bt_conn.c bt_gatt.c
CSRCS += bt_ioctl.c bt_keys.c bt_l2cap.c bt_smp.c
CSRCS += bt_uuid.c bt_services.c

Expand Down
112 changes: 0 additions & 112 deletions wireless/bluetooth/bt_atomic.c

This file was deleted.

26 changes: 10 additions & 16 deletions wireless/bluetooth/bt_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,20 @@
* Pre-processor Definitions
****************************************************************************/

#define bt_atomic_set(ptr, value) (*(ptr) = (value))
#define bt_atomic_get(ptr) (*(ptr))
#define bt_atomic_testbit(ptr, bitno) ((*(ptr) & (1 << (bitno))) != 0)
#define bt_atomic_set(ptr, value) atomic_store((ptr), (value));
#define bt_atomic_get(ptr) atomic_load(ptr)
#define bt_atomic_testbit(ptr, bitno) ((atomic_load(ptr) & (1 << (bitno))) != 0)
#define bt_atomic_incr(ptr) atomic_fetch_add((ptr), 1)
#define bt_atomic_decr(ptr) atomic_fetch_sub((ptr), 1)
#define bt_atomic_setbit(ptr, bitno) atomic_fetch_or((ptr), ((1 << (bitno))))
#define bt_atomic_clrbit(ptr, bitno) atomic_fetch_and((ptr), (~(1 << (bitno))))
#define bt_atomic_testsetbit(ptr, bitno) ((atomic_fetch_or((ptr), (1 << (bitno))) & (1 << (bitno))) != 0)
#define bt_atomic_testclrbit(ptr, bitno) ((atomic_fetch_and((ptr), ~(1 << (bitno))) & (1 << (bitno))) != 0)

/****************************************************************************
* Public Types
****************************************************************************/

typedef uint8_t bt_atomic_t;

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

bt_atomic_t bt_atomic_incr(FAR bt_atomic_t *ptr);
bt_atomic_t bt_atomic_decr(FAR bt_atomic_t *ptr);
bt_atomic_t bt_atomic_setbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
bt_atomic_t bt_atomic_clrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);

bool bt_atomic_testsetbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
bool bt_atomic_testclrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
typedef atomic_char bt_atomic_t;

#endif /* __WIRELESS_BLUETOOTH_BT_ATOMIC_H */

0 comments on commit e337295

Please sign in to comment.