Replace the use of gcc builtin __atomic_xxx intrinsics with
corresponding rte_atomic_xxx optional stdatomic API

Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com>
---
 lib/telemetry/telemetry.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index aeb078c..9298284 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -45,7 +45,7 @@ struct socket {
        int sock;
        char path[sizeof(((struct sockaddr_un *)0)->sun_path)];
        handler fn;
-       uint16_t *num_clients;
+       RTE_ATOMIC(uint16_t) *num_clients;
 };
 static struct socket v2_socket; /* socket for v2 telemetry */
 static struct socket v1_socket; /* socket for v1 telemetry */
@@ -64,7 +64,7 @@ struct socket {
 /* Used when accessing or modifying list of command callbacks */
 static rte_spinlock_t callback_sl = RTE_SPINLOCK_INITIALIZER;
 #ifndef RTE_EXEC_ENV_WINDOWS
-static uint16_t v2_clients;
+static RTE_ATOMIC(uint16_t) v2_clients;
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 
 int
@@ -404,7 +404,7 @@ struct socket {
                bytes = read(s, buffer, sizeof(buffer) - 1);
        }
        close(s);
-       __atomic_fetch_sub(&v2_clients, 1, __ATOMIC_RELAXED);
+       rte_atomic_fetch_sub_explicit(&v2_clients, 1, rte_memory_order_relaxed);
        return NULL;
 }
 
@@ -421,14 +421,14 @@ struct socket {
                        return NULL;
                }
                if (s->num_clients != NULL) {
-                       uint16_t conns = __atomic_load_n(s->num_clients,
-                                       __ATOMIC_RELAXED);
+                       uint16_t conns = 
rte_atomic_load_explicit(s->num_clients,
+                                       rte_memory_order_relaxed);
                        if (conns >= MAX_CONNECTIONS) {
                                close(s_accepted);
                                continue;
                        }
-                       __atomic_fetch_add(s->num_clients, 1,
-                                       __ATOMIC_RELAXED);
+                       rte_atomic_fetch_add_explicit(s->num_clients, 1,
+                                       rte_memory_order_relaxed);
                }
                rc = pthread_create(&th, NULL, s->fn,
                                    (void *)(uintptr_t)s_accepted);
@@ -437,8 +437,8 @@ struct socket {
                                 strerror(rc));
                        close(s_accepted);
                        if (s->num_clients != NULL)
-                               __atomic_fetch_sub(s->num_clients, 1,
-                                                  __ATOMIC_RELAXED);
+                               rte_atomic_fetch_sub_explicit(s->num_clients, 1,
+                                                  rte_memory_order_relaxed);
                        continue;
                }
                pthread_detach(th);
-- 
1.8.3.1

Reply via email to