[v4,22/45] raw/ifpga: use rte stdatomic API

Message ID 1713568003-30453-23-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series use stdatomic API |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff April 19, 2024, 11:06 p.m. UTC
  Replace the use of gcc builtin __atomic_xxx intrinsics with
corresponding rte_atomic_xxx optional rte stdatomic API.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index f89bd3f..78d3c88 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -73,7 +73,7 @@ 
 
 static struct ifpga_rawdev ifpga_rawdevices[IFPGA_RAWDEV_NUM];
 
-static int ifpga_monitor_refcnt;
+static RTE_ATOMIC(int) ifpga_monitor_refcnt;
 static rte_thread_t ifpga_monitor_start_thread;
 
 static struct ifpga_rawdev *
@@ -512,7 +512,7 @@  static int set_surprise_link_check_aer(
 	int gsd_enable, ret;
 #define MS 1000
 
-	while (__atomic_load_n(&ifpga_monitor_refcnt, __ATOMIC_RELAXED)) {
+	while (rte_atomic_load_explicit(&ifpga_monitor_refcnt, rte_memory_order_relaxed)) {
 		gsd_enable = 0;
 		for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
 			ifpga_rdev = &ifpga_rawdevices[i];
@@ -549,7 +549,7 @@  static int set_surprise_link_check_aer(
 
 	dev->poll_enabled = 1;
 
-	if (!__atomic_fetch_add(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED)) {
+	if (!rte_atomic_fetch_add_explicit(&ifpga_monitor_refcnt, 1, rte_memory_order_relaxed)) {
 		ret = rte_thread_create_internal_control(&ifpga_monitor_start_thread,
 				"ifpga-mon", ifpga_rawdev_gsd_handle, NULL);
 		if (ret != 0) {
@@ -573,7 +573,8 @@  static int set_surprise_link_check_aer(
 
 	dev->poll_enabled = 0;
 
-	if (!(__atomic_fetch_sub(&ifpga_monitor_refcnt, 1, __ATOMIC_RELAXED) - 1) &&
+	if (!(rte_atomic_fetch_sub_explicit(&ifpga_monitor_refcnt, 1,
+	    rte_memory_order_relaxed) - 1) &&
 		ifpga_monitor_start_thread.opaque_id != 0) {
 		ret = pthread_cancel((pthread_t)ifpga_monitor_start_thread.opaque_id);
 		if (ret)