[PATCH v2 05/21] stack: use C11 alignof

Tyler Retzlaff roretzla at linux.microsoft.com
Tue Feb 13 19:34:36 CET 2024


Replace use of __alignof__(e) with C11 alignof(typeof(e)) to improve
portability between toolchains.

Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
Acked-by: Chengwen Feng <fengchengwen at huawei.com>
---
 lib/stack/rte_stack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/stack/rte_stack.c b/lib/stack/rte_stack.c
index 1dab6d6..7261281 100644
--- a/lib/stack/rte_stack.c
+++ b/lib/stack/rte_stack.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <string.h>
 #include <sys/queue.h>
 
@@ -90,7 +91,7 @@ struct rte_stack *
 	rte_mcfg_tailq_write_lock();
 
 	mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
-					 0, __alignof__(*s));
+					 0, alignof(typeof(*s)));
 	if (mz == NULL) {
 		STACK_LOG_ERR("Cannot reserve stack memzone!");
 		rte_mcfg_tailq_write_unlock();
-- 
1.8.3.1



More information about the dev mailing list