diff --git a/arch/arm/src/armv7-a/arm_gicv2.c b/arch/arm/src/armv7-a/arm_gicv2.c index 03ad226ba94..c6cfccec0b3 100644 --- a/arch/arm/src/armv7-a/arm_gicv2.c +++ b/arch/arm/src/armv7-a/arm_gicv2.c @@ -72,7 +72,7 @@ static atomic_t g_gic_init_done; #if defined(CONFIG_SMP) && CONFIG_SMP_NCPUS > 1 static void arm_gic_init_done(void) { - atomic_fetch_or(&g_gic_init_done, 1 << this_cpu()); + atomic_or(&g_gic_init_done, 1 << this_cpu()); } static void arm_gic_wait_done(cpu_set_t cpuset) diff --git a/arch/arm/src/rtl8720c/amebaz_depend.c b/arch/arm/src/rtl8720c/amebaz_depend.c index ac81473c3dc..674924a5ba2 100644 --- a/arch/arm/src/rtl8720c/amebaz_depend.c +++ b/arch/arm/src/rtl8720c/amebaz_depend.c @@ -876,7 +876,7 @@ static void *device_mutex[5]; static void device_mutex_init(uint32_t device) { irqstate_t status; - if (atomic_fetch_or(&mutex_init, (1 << device)) & (1 << device) == 0) + if (atomic_or(&mutex_init, (1 << device)) & (1 << device) == 0) { rtw_mutex_init(&device_mutex[device]); } diff --git a/arch/arm64/src/imx9/imx9_scmi.c b/arch/arm64/src/imx9/imx9_scmi.c index 9f78831612e..a0da93706f9 100644 --- a/arch/arm64/src/imx9/imx9_scmi.c +++ b/arch/arm64/src/imx9/imx9_scmi.c @@ -476,7 +476,7 @@ static int imx9_scmi_tx(uint32_t channel, uint32_t protocol_id, *header = SCMI_HEADER_MSG(message_id) | SCMI_HEADER_PROTOCOL(protocol_id) | SCMI_HEADER_TYPE(0UL) - | SCMI_HEADER_TOKEN(atomic_fetch_add(&g_token, 1)); + | SCMI_HEADER_TOKEN(atomic_add(&g_token, 1)); msg->header = *header; /* Send message via transport */ diff --git a/arch/sim/src/sim/sim_ummheap.c b/arch/sim/src/sim/sim_ummheap.c index 78626b53843..6edde735e1c 100644 --- a/arch/sim/src/sim/sim_ummheap.c +++ b/arch/sim/src/sim/sim_ummheap.c @@ -174,8 +174,8 @@ static void update_stats(struct mm_heap_s *heap, void *mem, size_t size, list_add_tail(&heap->alloclist, &node->node); spin_unlock_irqrestore(&heap->lock, flags); - atomic_fetch_add(&heap->aordblks, 1); - atomic_fetch_add(&heap->uordblks, size); + atomic_add(&heap->aordblks, 1); + atomic_add(&heap->uordblks, size); usmblks = atomic_read(&heap->usmblks); do { @@ -189,8 +189,8 @@ static void update_stats(struct mm_heap_s *heap, void *mem, size_t size, list_delete(&node->node); spin_unlock_irqrestore(&heap->lock, flags); - atomic_fetch_sub(&heap->aordblks, 1); - atomic_fetch_sub(&heap->uordblks, size); + atomic_sub(&heap->aordblks, 1); + atomic_sub(&heap->uordblks, size); } } diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index dfc73eafd43..f4038cf7481 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1180,7 +1180,7 @@ static void i3c_master_handle_ibi(FAR void *arg) } master->ops->recycle_ibi_slot(dev, slot); - atomic_fetch_sub(&dev->ibi->pending_ibis, 1); + atomic_sub(&dev->ibi->pending_ibis, 1); if (!atomic_read(&dev->ibi->pending_ibis)) { sem_post(&dev->ibi->all_ibis_handled); @@ -1800,7 +1800,7 @@ err_free_dev: void i3c_master_queue_ibi(FAR struct i3c_dev_desc *dev, FAR struct i3c_ibi_slot *slot) { - atomic_fetch_add(&dev->ibi->pending_ibis, 1); + atomic_add(&dev->ibi->pending_ibis, 1); work_queue(HPWORK, &slot->work, i3c_master_handle_ibi, slot, 0); } diff --git a/drivers/net/netdev_upperhalf.c b/drivers/net/netdev_upperhalf.c index 883ce5e7f63..9da33fb8922 100644 --- a/drivers/net/netdev_upperhalf.c +++ b/drivers/net/netdev_upperhalf.c @@ -169,7 +169,7 @@ static FAR netpkt_t *netpkt_get(FAR struct net_driver_s *dev, * cases will be limited by netdev_upper_can_tx and seldom reaches here. */ - if (atomic_fetch_sub(&upper->lower->quota_ptr[type], 1) <= 0) + if (atomic_sub(&upper->lower->quota_ptr[type], 1) <= 0) { nwarn("WARNING: Allowing temporarily exceeding quota of %s.\n", dev->d_ifname); @@ -196,7 +196,7 @@ static void netpkt_put(FAR struct net_driver_s *dev, FAR netpkt_t *pkt, DEBUGASSERT(dev && pkt); - atomic_fetch_add(&upper->lower->quota_ptr[type], 1); + atomic_add(&upper->lower->quota_ptr[type], 1); netdev_iob_replace_l2(dev, pkt); } @@ -1723,9 +1723,9 @@ FAR netpkt_t *netpkt_alloc(FAR struct netdev_lowerhalf_s *dev, { FAR netpkt_t *pkt; - if (atomic_fetch_sub(&dev->quota_ptr[type], 1) <= 0) + if (atomic_sub(&dev->quota_ptr[type], 1) <= 0) { - atomic_fetch_add(&dev->quota_ptr[type], 1); + atomic_add(&dev->quota_ptr[type], 1); return NULL; } @@ -1742,7 +1742,7 @@ FAR netpkt_t *netpkt_alloc(FAR struct netdev_lowerhalf_s *dev, if (pkt == NULL) { - atomic_fetch_add(&dev->quota_ptr[type], 1); + atomic_add(&dev->quota_ptr[type], 1); return NULL; } @@ -1766,7 +1766,7 @@ FAR netpkt_t *netpkt_alloc(FAR struct netdev_lowerhalf_s *dev, void netpkt_free(FAR struct netdev_lowerhalf_s *dev, FAR netpkt_t *pkt, enum netpkt_type_e type) { - atomic_fetch_add(&dev->quota_ptr[type], 1); + atomic_add(&dev->quota_ptr[type], 1); iob_free_chain(pkt); } diff --git a/drivers/note/notesnap_driver.c b/drivers/note/notesnap_driver.c index 47762ef0e45..8b0aa478ad7 100644 --- a/drivers/note/notesnap_driver.c +++ b/drivers/note/notesnap_driver.c @@ -219,7 +219,7 @@ static inline void notesnap_common(FAR struct note_driver_s *drv, /* Atomic operation, equivalent to snap.index++; */ - index = atomic_fetch_add(&snap->index, 1); + index = atomic_add(&snap->index, 1); note = &snap->buffer[index % CONFIG_DRIVERS_NOTESNAP_NBUFFERS]; note->type = type; diff --git a/drivers/reset/core.c b/drivers/reset/core.c index d58ecf9edaf..7ff89ce354a 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -289,7 +289,7 @@ reset_control_get_internal(FAR struct reset_controller_dev *rcdev, return NULL; } - atomic_fetch_add(&rstc->refcnt, 1); + atomic_add(&rstc->refcnt, 1); return rstc; } } @@ -341,7 +341,7 @@ static void reset_control_put_internal(FAR struct reset_control *rstc) { DEBUGASSERT(nxmutex_is_locked(&g_reset_list_mutex)); - if (atomic_fetch_sub(&rstc->refcnt, 1) == 1) + if (atomic_sub(&rstc->refcnt, 1) == 1) { DEBUGASSERT(nxmutex_is_locked(&g_reset_list_mutex)); list_delete(&rstc->list); @@ -864,7 +864,7 @@ int reset_control_reset(FAR struct reset_control *rstc) return -EINVAL; } - if (atomic_fetch_add(&rstc->triggered_count, 1) != 0) + if (atomic_add(&rstc->triggered_count, 1) != 0) { return 0; } @@ -883,7 +883,7 @@ int reset_control_reset(FAR struct reset_control *rstc) if (rstc->shared && ret < 0) { - atomic_fetch_sub(&rstc->triggered_count, 1); + atomic_sub(&rstc->triggered_count, 1); } return ret; @@ -940,7 +940,7 @@ int reset_control_assert(FAR struct reset_control *rstc) return -EINVAL; } - if (atomic_fetch_sub(&rstc->deassert_count, 1) != 1) + if (atomic_sub(&rstc->deassert_count, 1) != 1) { return 0; } @@ -1019,7 +1019,7 @@ int reset_control_deassert(FAR struct reset_control *rstc) return -EINVAL; } - if (atomic_fetch_add(&rstc->deassert_count, 1) != 0) + if (atomic_add(&rstc->deassert_count, 1) != 0) { return 0; } diff --git a/drivers/rpmsg/rpmsg.c b/drivers/rpmsg/rpmsg.c index 217925f6a8a..636c0b0ed50 100644 --- a/drivers/rpmsg/rpmsg.c +++ b/drivers/rpmsg/rpmsg.c @@ -605,8 +605,8 @@ void rpmsg_modify_signals(FAR struct rpmsg_s *rpmsg, FAR struct metal_list *node; bool needlock; - atomic_fetch_and_acquire(&rpmsg->signals, ~clrflags); - atomic_fetch_or_acquire(&rpmsg->signals, setflags); + atomic_and_acquire(&rpmsg->signals, ~clrflags); + atomic_or_acquire(&rpmsg->signals, setflags); /* Send signal to Router Hub */ diff --git a/drivers/rpmsg/rpmsg_port.c b/drivers/rpmsg/rpmsg_port.c index d3e2352f005..c37e3af5205 100644 --- a/drivers/rpmsg/rpmsg_port.c +++ b/drivers/rpmsg/rpmsg_port.c @@ -329,7 +329,7 @@ static void rpmsg_port_hold_rx_buffer(FAR struct rpmsg_device *rdev, { FAR struct rpmsg_hdr *rphdr = RPMSG_LOCATE_HDR(rxbuf); - atomic_fetch_add(&rphdr->reserved, 1 << RPMSG_BUF_HELD_SHIFT); + atomic_add(&rphdr->reserved, 1 << RPMSG_BUF_HELD_SHIFT); } /**************************************************************************** @@ -345,7 +345,7 @@ static void rpmsg_port_release_rx_buffer(FAR struct rpmsg_device *rdev, FAR struct rpmsg_port_header_s *hdr = metal_container_of(rphdr, struct rpmsg_port_header_s, buf); uint32_t reserved = - atomic_fetch_sub(&rphdr->reserved, 1 << RPMSG_BUF_HELD_SHIFT); + atomic_sub(&rphdr->reserved, 1 << RPMSG_BUF_HELD_SHIFT); if ((reserved & RPMSG_BUF_HELD_MASK) == (1 << RPMSG_BUF_HELD_SHIFT)) { diff --git a/drivers/rpmsg/rpmsg_port_spi.c b/drivers/rpmsg/rpmsg_port_spi.c index 8d3eea04959..472b66023b9 100644 --- a/drivers/rpmsg/rpmsg_port_spi.c +++ b/drivers/rpmsg/rpmsg_port_spi.c @@ -268,7 +268,7 @@ static void rpmsg_port_spi_exchange(FAR struct rpmsg_port_spi_s *rpspi) int pending; IOEXP_WRITEPIN(rpspi->ioe, rpspi->mreq, 0); - pending = atomic_fetch_add(&rpspi->transferring, 1); + pending = atomic_add(&rpspi->transferring, 1); if (pending > 0) { if (pending > 1) diff --git a/drivers/rpmsg/rpmsg_port_spi_slave.c b/drivers/rpmsg/rpmsg_port_spi_slave.c index 1a8e0ab63fc..f13bf458f98 100644 --- a/drivers/rpmsg/rpmsg_port_spi_slave.c +++ b/drivers/rpmsg/rpmsg_port_spi_slave.c @@ -243,7 +243,7 @@ static void rpmsg_port_spi_exchange(FAR struct rpmsg_port_spi_s *rpspi) { FAR struct rpmsg_port_header_s *txhdr; - if (atomic_fetch_add(&rpspi->transferring, 1)) + if (atomic_add(&rpspi->transferring, 1)) { return; } diff --git a/drivers/wireless/bluetooth/bt_bridge.c b/drivers/wireless/bluetooth/bt_bridge.c index 42fd3d20381..0cdbc29dd9a 100644 --- a/drivers/wireless/bluetooth/bt_bridge.c +++ b/drivers/wireless/bluetooth/bt_bridge.c @@ -420,12 +420,12 @@ static int bt_bridge_open(FAR struct bt_driver_s *drv) FAR struct bt_bridge_s *bridge = device->bridge; FAR struct bt_driver_s *driver = bridge->driver; - if (atomic_fetch_add(&bridge->refs, 1) == 0) + if (atomic_add(&bridge->refs, 1) == 0) { int ret = driver->open(driver); if (ret < 0) { - atomic_fetch_sub(&bridge->refs, 1); + atomic_sub(&bridge->refs, 1); } return ret; @@ -514,7 +514,7 @@ static void bt_bridge_close(FAR struct bt_driver_s *drv) FAR struct bt_bridge_s *bridge = device->bridge; FAR struct bt_driver_s *driver = bridge->driver; - if (atomic_fetch_sub(&bridge->refs, 1) == 1) + if (atomic_sub(&bridge->refs, 1) == 1) { driver->close(driver); }; diff --git a/fs/event/event_close.c b/fs/event/event_close.c index c2e8cd8a4a7..4a6e61c125c 100644 --- a/fs/event/event_close.c +++ b/fs/event/event_close.c @@ -79,7 +79,7 @@ int nxevent_close(FAR nxevent_t *event) * now. */ - if (atomic_fetch_sub(&inode->i_crefs, 1) <= 1) + if (atomic_sub(&inode->i_crefs, 1) <= 1) { nxevent_destroy(&nevent->ne_event); group_free(NULL, nevent); diff --git a/fs/event/event_open.c b/fs/event/event_open.c index 2f0b45f52b1..6781d055029 100644 --- a/fs/event/event_open.c +++ b/fs/event/event_open.c @@ -186,7 +186,7 @@ int nxevent_open(FAR nxevent_t **event, FAR const char *name, /* Initialize the inode */ INODE_SET_NAMEDEVENT(inode); - atomic_fetch_add(&inode->i_crefs, 1); + atomic_add(&inode->i_crefs, 1); /* Initialize the event groups */ diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index 4319ed502d5..b039051bb73 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -75,7 +75,7 @@ static void fdlist_get_by_index(FAR struct fdlist *list, *filep = fdp1->f_file; if (*filep != NULL) { - atomic_fetch_add(&(*filep)->f_refs, 1); + atomic_add(&(*filep)->f_refs, 1); } spin_unlock_irqrestore_notrace(&list->fl_lock, flags); @@ -605,7 +605,7 @@ int fdlist_dupfile(FAR struct fdlist *list, int oflags, int minfd, fdp = &list->fl_fds[i][j]; if (fdp->f_file == NULL) { - atomic_fetch_add(&filep->f_refs, 1); + atomic_add(&filep->f_refs, 1); fdp->f_file = filep; fdp->f_cloexec = !!(oflags & O_CLOEXEC); #ifdef CONFIG_FDSAN @@ -836,7 +836,7 @@ void file_ref(FAR struct file *filep) /* This interface is used to increase the reference count of filep */ DEBUGASSERT(filep); - atomic_fetch_add(&filep->f_refs, 1); + atomic_add(&filep->f_refs, 1); } /**************************************************************************** @@ -862,7 +862,7 @@ int file_put(FAR struct file *filep) /* If refs is zero, the close() had called, closing it now. */ - if (atomic_fetch_sub(&filep->f_refs, 1) == 1) + if (atomic_sub(&filep->f_refs, 1) == 1) { ret = file_close(filep); if (ret < 0) diff --git a/fs/inode/fs_inodeaddref.c b/fs/inode/fs_inodeaddref.c index 240c0a07b75..2481de918e9 100644 --- a/fs/inode/fs_inodeaddref.c +++ b/fs/inode/fs_inodeaddref.c @@ -47,6 +47,6 @@ void inode_addref(FAR struct inode *inode) { if (inode) { - atomic_fetch_add(&inode->i_crefs, 1); + atomic_add(&inode->i_crefs, 1); } } diff --git a/fs/inode/fs_inodefind.c b/fs/inode/fs_inodefind.c index f53b502b4e2..78cd426cf13 100644 --- a/fs/inode/fs_inodefind.c +++ b/fs/inode/fs_inodefind.c @@ -68,7 +68,7 @@ int inode_find(FAR struct inode_search_s *desc) /* Increment the reference count on the inode */ - atomic_fetch_add(&inode->i_crefs, 1); + atomic_add(&inode->i_crefs, 1); } inode_runlock(); diff --git a/fs/inode/fs_inoderelease.c b/fs/inode/fs_inoderelease.c index 3f9fdf346b3..584f8fd19be 100644 --- a/fs/inode/fs_inoderelease.c +++ b/fs/inode/fs_inoderelease.c @@ -53,7 +53,7 @@ void inode_release(FAR struct inode *inode) { /* Decrement the references of the inode */ - if (atomic_fetch_sub(&inode->i_crefs, 1) <= 1) + if (atomic_sub(&inode->i_crefs, 1) <= 1) { DEBUGASSERT(inode->i_peer == NULL); inode_free(inode); diff --git a/fs/inode/fs_inoderemove.c b/fs/inode/fs_inoderemove.c index 7696bf46184..87c86937479 100644 --- a/fs/inode/fs_inoderemove.c +++ b/fs/inode/fs_inoderemove.c @@ -119,7 +119,7 @@ static FAR struct inode *inode_unlink(FAR const char *path) inode->i_peer = NULL; inode->i_parent = NULL; - atomic_fetch_sub(&inode->i_crefs, 1); + atomic_sub(&inode->i_crefs, 1); } errout: diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index d46d6ee8c20..39c87e95cda 100644 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -436,7 +436,7 @@ int nx_mount(FAR const char *source, FAR const char *target, if (drvr_inode != NULL) #endif { - atomic_fetch_add(&drvr_inode->i_crefs, 1); + atomic_add(&drvr_inode->i_crefs, 1); } #endif @@ -464,7 +464,7 @@ int nx_mount(FAR const char *source, FAR const char *target, if (drvr_inode != NULL) #endif { - atomic_fetch_sub(&drvr_inode->i_crefs, 1); + atomic_sub(&drvr_inode->i_crefs, 1); } #endif diff --git a/fs/mount/fs_umount2.c b/fs/mount/fs_umount2.c index 0de3dfb16d8..a0cced51370 100644 --- a/fs/mount/fs_umount2.c +++ b/fs/mount/fs_umount2.c @@ -151,7 +151,7 @@ int nx_umount2(FAR const char *target, unsigned int flags) { /* Just decrement the reference count (without deleting it) */ - atomic_fetch_sub(&mountpt_inode->i_crefs, 1); + atomic_sub(&mountpt_inode->i_crefs, 1); inode_unlock(); } else diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index feeeea66761..798ece2e264 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -337,7 +337,7 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name, /* Set the initial reference count on this inode to one */ - atomic_fetch_add(&inode->i_crefs, 1); + atomic_add(&inode->i_crefs, 1); if (created) { diff --git a/fs/semaphore/sem_close.c b/fs/semaphore/sem_close.c index da8b1c0a174..00078ed1bc9 100644 --- a/fs/semaphore/sem_close.c +++ b/fs/semaphore/sem_close.c @@ -87,7 +87,7 @@ int nxsem_close(FAR sem_t *sem) * now. */ - if (atomic_fetch_sub(&inode->i_crefs, 1) <= 1) + if (atomic_sub(&inode->i_crefs, 1) <= 1) { nxsem_destroy(&nsem->ns_sem); group_free(NULL, nsem); diff --git a/fs/semaphore/sem_open.c b/fs/semaphore/sem_open.c index e89e0de7461..491e34945d2 100644 --- a/fs/semaphore/sem_open.c +++ b/fs/semaphore/sem_open.c @@ -211,7 +211,7 @@ int nxsem_open(FAR sem_t **sem, FAR const char *name, int oflags, ...) /* Initialize the inode */ INODE_SET_NAMEDSEM(inode); - atomic_fetch_add(&inode->i_crefs, 1); + atomic_add(&inode->i_crefs, 1); /* Initialize the semaphore */ diff --git a/fs/shm/shm_open.c b/fs/shm/shm_open.c index 27279c39867..e7db849cb90 100644 --- a/fs/shm/shm_open.c +++ b/fs/shm/shm_open.c @@ -155,7 +155,7 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name, INODE_SET_SHM(inode); inode->u.i_ops = &g_shmfs_operations; inode->i_private = NULL; - atomic_fetch_add(&inode->i_crefs, 1); + atomic_add(&inode->i_crefs, 1); } /* Associate the inode with a file structure */ diff --git a/fs/vfs/fs_dir.c b/fs/vfs/fs_dir.c index 6b93e90e7a0..40abdc40b14 100644 --- a/fs/vfs/fs_dir.c +++ b/fs/vfs/fs_dir.c @@ -220,7 +220,7 @@ static off_t seek_pseudodir(FAR struct file *filep, off_t offset) { /* Increment the reference count on this next node */ - atomic_fetch_add(&curr->i_crefs, 1); + atomic_add(&curr->i_crefs, 1); } inode_unlock(); @@ -389,7 +389,7 @@ static int read_pseudodir(FAR struct fs_dirent_s *dir, { /* Increment the reference count on this next node */ - atomic_fetch_add(&pdir->next->i_crefs, 1); + atomic_add(&pdir->next->i_crefs, 1); } inode_unlock(); diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index bc2024b8a23..82b13dec554 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -358,7 +358,7 @@ int file_open(FAR struct file *filep, FAR const char *path, int oflags, ...) if (ret >= OK) { - atomic_fetch_add(&filep->f_refs, 1); + atomic_add(&filep->f_refs, 1); } return ret; diff --git a/fs/vfs/fs_profile.c b/fs/vfs/fs_profile.c index 807af6df23a..c6b1a311443 100644 --- a/fs/vfs/fs_profile.c +++ b/fs/vfs/fs_profile.c @@ -50,6 +50,6 @@ void fs_profile_stop(FAR clock_t *start, FAR atomic64_t *total, clock_t stop = perf_gettime(); clock_t delta = stop - *start; - atomic64_fetch_add(total, delta); - atomic_fetch_add(count, 1); + atomic64_add(total, delta); + atomic_add(count, 1); } diff --git a/fs/vfs/fs_pseudofile.c b/fs/vfs/fs_pseudofile.c index c1d8294caa9..db2bba68123 100644 --- a/fs/vfs/fs_pseudofile.c +++ b/fs/vfs/fs_pseudofile.c @@ -551,7 +551,7 @@ int pseudofile_create(FAR struct inode **node, FAR const char *path, (*node)->u.i_ops = &g_pseudofile_ops; (*node)->i_private = pf; - atomic_fetch_add(&(*node)->i_crefs, 1); + atomic_add(&(*node)->i_crefs, 1); inode_unlock(); #ifdef CONFIG_FS_NOTIFY diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index 63884365547..3832bad3960 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -183,7 +183,7 @@ static inline_function void rspin_lock_init(FAR rspinlock_t *lock) static inline_function void spin_lock_notrace(FAR volatile spinlock_t *lock) { #ifdef CONFIG_TICKET_SPINLOCK - int ticket = atomic_fetch_add(&lock->next, 1); + int ticket = atomic_add(&lock->next, 1); while (atomic_read(&lock->owner) != ticket) #else /* CONFIG_TICKET_SPINLOCK */ while (up_testset(lock) == SP_LOCKED) @@ -375,7 +375,7 @@ spin_unlock_notrace(FAR volatile spinlock_t *lock) { UP_DMB(); #ifdef CONFIG_TICKET_SPINLOCK - atomic_fetch_add(&lock->owner, 1); + atomic_add(&lock->owner, 1); #else *lock = SP_UNLOCKED; #endif @@ -1105,7 +1105,7 @@ static inline_function void read_unlock(FAR volatile rwlock_t *lock) DEBUGASSERT(atomic_read(lock) >= RW_SP_READ_LOCKED); UP_DMB(); - atomic_fetch_sub(lock, 1); + atomic_sub(lock, 1); UP_DSB(); UP_SEV(); } diff --git a/libs/libc/misc/lib_tempbuffer.c b/libs/libc/misc/lib_tempbuffer.c index 470342e5211..f642cffa671 100644 --- a/libs/libc/misc/lib_tempbuffer.c +++ b/libs/libc/misc/lib_tempbuffer.c @@ -140,7 +140,7 @@ void lib_put_tempbuffer(FAR char *buffer) { DEBUGASSERT((atomic_read(&g_tempbuffer.free_bitmap) & (1u << index)) == 0); - atomic_fetch_or_acquire(&g_tempbuffer.free_bitmap, 1u << index); + atomic_or_acquire(&g_tempbuffer.free_bitmap, 1u << index); return; } diff --git a/libs/libc/pthread/pthread_condclockwait.c b/libs/libc/pthread/pthread_condclockwait.c index e8e692d50ab..d1b899f0998 100644 --- a/libs/libc/pthread/pthread_condclockwait.c +++ b/libs/libc/pthread/pthread_condclockwait.c @@ -113,7 +113,7 @@ int pthread_cond_clockwait(FAR pthread_cond_t *cond, sinfo("Give up mutex...\n"); - atomic_fetch_add(COND_WAIT_COUNT(cond), 1); + atomic_add(COND_WAIT_COUNT(cond), 1); /* Give up the mutex */ diff --git a/libs/libc/pthread/pthread_condwait.c b/libs/libc/pthread/pthread_condwait.c index 0326e64b4e2..840daa36ff1 100644 --- a/libs/libc/pthread/pthread_condwait.c +++ b/libs/libc/pthread/pthread_condwait.c @@ -90,7 +90,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex) sinfo("Give up mutex / take cond\n"); - atomic_fetch_add(COND_WAIT_COUNT(cond), 1); + atomic_add(COND_WAIT_COUNT(cond), 1); ret = pthread_mutex_breaklock(mutex, &nlocks); status = -nxsem_wait_uninterruptible(&cond->sem); diff --git a/sched/addrenv/addrenv.c b/sched/addrenv/addrenv.c index 32e6cba247c..2d9b59a8a9e 100644 --- a/sched/addrenv/addrenv.c +++ b/sched/addrenv/addrenv.c @@ -469,7 +469,7 @@ void addrenv_take(FAR struct addrenv_s *addrenv) if (addrenv != NULL) { - atomic_fetch_add(&addrenv->refs, 1); + atomic_add(&addrenv->refs, 1); } } @@ -495,7 +495,7 @@ int addrenv_give(FAR struct addrenv_s *addrenv) * address environment has become unreferenced and should be destroyed. */ - return addrenv ? atomic_fetch_sub(&addrenv->refs, 1) - 1 : 1; + return addrenv ? atomic_sub(&addrenv->refs, 1) - 1 : 1; } /**************************************************************************** diff --git a/sched/semaphore/sem_holder.c b/sched/semaphore/sem_holder.c index a124f7c3fa4..1df007a75db 100644 --- a/sched/semaphore/sem_holder.c +++ b/sched/semaphore/sem_holder.c @@ -982,7 +982,7 @@ void nxsem_release_all(FAR struct tcb_s *htcb) * that was taken by sem_wait() or sem_post(). */ - atomic_fetch_add(NXSEM_COUNT(sem), 1); + atomic_add(NXSEM_COUNT(sem), 1); } } } diff --git a/sched/semaphore/sem_post.c b/sched/semaphore/sem_post.c index 8018a1d869a..6f191ed5a08 100644 --- a/sched/semaphore/sem_post.c +++ b/sched/semaphore/sem_post.c @@ -96,7 +96,7 @@ int nxsem_post_slow(FAR sem_t *sem) /* Lock the mutex for us by setting the blocking bit */ - mholder = atomic_fetch_or(NXSEM_MHOLDER(sem), NXSEM_MBLOCKING_BIT); + mholder = atomic_or(NXSEM_MHOLDER(sem), NXSEM_MBLOCKING_BIT); /* Mutex post from another thread is not allowed, unless * called from nxsem_reset. The comparison uses the same encoding diff --git a/sched/semaphore/sem_recover.c b/sched/semaphore/sem_recover.c index c823d6dbca6..59f86446b7b 100644 --- a/sched/semaphore/sem_recover.c +++ b/sched/semaphore/sem_recover.c @@ -112,14 +112,14 @@ void nxsem_recover(FAR struct tcb_s *tcb) if (dq_empty(SEM_WAITLIST(sem))) { uint32_t mholder = - atomic_fetch_and(NXSEM_MHOLDER(sem), ~NXSEM_MBLOCKING_BIT); + atomic_and(NXSEM_MHOLDER(sem), ~NXSEM_MBLOCKING_BIT); DEBUGASSERT(NXSEM_MBLOCKING(mholder)); } } else { DEBUGASSERT(atomic_read(NXSEM_COUNT(sem)) < 0); - atomic_fetch_add(NXSEM_COUNT(sem), 1); + atomic_add(NXSEM_COUNT(sem), 1); } #ifdef CONFIG_MM_KMAP diff --git a/sched/semaphore/sem_trywait.c b/sched/semaphore/sem_trywait.c index 40f2e10275c..710d0a6461e 100644 --- a/sched/semaphore/sem_trywait.c +++ b/sched/semaphore/sem_trywait.c @@ -117,7 +117,7 @@ int nxsem_trywait_slow(FAR sem_t *sem) } else { - atomic_fetch_add(NXSEM_COUNT(sem), 1); + atomic_add(NXSEM_COUNT(sem), 1); } } else diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c index a8391b13b9f..7481b2fa7c9 100644 --- a/sched/semaphore/sem_wait.c +++ b/sched/semaphore/sem_wait.c @@ -117,7 +117,7 @@ int nxsem_wait_slow(FAR sem_t *sem) * this is all that is needed if we block */ - mholder = atomic_fetch_or(NXSEM_MHOLDER(sem), NXSEM_MBLOCKING_BIT); + mholder = atomic_or(NXSEM_MHOLDER(sem), NXSEM_MBLOCKING_BIT); /* Avoid mutex recursion, which is not allowed. The comparison uses * the lock side's encoding so that ids of either sign compare the @@ -143,7 +143,7 @@ int nxsem_wait_slow(FAR sem_t *sem) } else { - unlocked = atomic_fetch_sub(NXSEM_COUNT(sem), 1) > 0; + unlocked = atomic_sub(NXSEM_COUNT(sem), 1) > 0; } if (unlocked) @@ -160,7 +160,7 @@ int nxsem_wait_slow(FAR sem_t *sem) } else { - atomic_fetch_add(NXSEM_COUNT(sem), 1); + atomic_add(NXSEM_COUNT(sem), 1); } leave_critical_section(flags); diff --git a/sched/semaphore/sem_waitirq.c b/sched/semaphore/sem_waitirq.c index e0eec5e42e0..ae86b861e88 100644 --- a/sched/semaphore/sem_waitirq.c +++ b/sched/semaphore/sem_waitirq.c @@ -105,12 +105,12 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) { if (dq_empty(SEM_WAITLIST(sem))) { - atomic_fetch_and(NXSEM_MHOLDER(sem), ~NXSEM_MBLOCKING_BIT); + atomic_and(NXSEM_MHOLDER(sem), ~NXSEM_MBLOCKING_BIT); } } else { - atomic_fetch_add(NXSEM_COUNT(sem), 1); + atomic_add(NXSEM_COUNT(sem), 1); } /* Indicate that the wait is over. */ diff --git a/wireless/bluetooth/bt_atomic.h b/wireless/bluetooth/bt_atomic.h index 6666bab7c7f..9b2db202332 100644 --- a/wireless/bluetooth/bt_atomic.h +++ b/wireless/bluetooth/bt_atomic.h @@ -40,12 +40,12 @@ #define bt_atomic_set(ptr, value) atomic_set(ptr, value); #define bt_atomic_get(ptr) atomic_read(ptr) #define bt_atomic_testbit(ptr, bitno) ((atomic_read(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) +#define bt_atomic_incr(ptr) atomic_add(ptr, 1) +#define bt_atomic_decr(ptr) atomic_sub(ptr, 1) +#define bt_atomic_setbit(ptr, bitno) atomic_or(ptr, (1 << (bitno))) +#define bt_atomic_clrbit(ptr, bitno) atomic_and(ptr, ~(1 << (bitno))) +#define bt_atomic_testsetbit(ptr, bitno) ((atomic_or(ptr, (1 << (bitno))) & (1 << (bitno))) != 0) +#define bt_atomic_testclrbit(ptr, bitno) ((atomic_and(ptr, ~(1 << (bitno))) & (1 << (bitno))) != 0) /**************************************************************************** * Public Types