[v2,02/14] stack: use C11 alignas

Message ID 1707884270-27189-3-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Series use C11 alignas and normalize type alignment |


Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Feb. 14, 2024, 4:17 a.m. UTC
  * Move __rte_aligned from the end of {struct,union} definitions to
  be between {struct,union} and tag.

  The placement between {struct,union} and the tag allows the desired
  alignment to be imparted on the type regardless of the toolchain being
  used for all of GCC, LLVM, MSVC compilers building both C and C++.

* Replace use of __rte_aligned(a) on variables/fields with alignas(a).

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
 lib/stack/rte_stack.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h
index a379300..573e15c 100644
--- a/lib/stack/rte_stack.h
+++ b/lib/stack/rte_stack.h
@@ -15,6 +15,8 @@ 
 #ifndef _RTE_STACK_H_
 #define _RTE_STACK_H_
+#include <stdalign.h>
 #ifdef __cplusplus
 extern "C" {
@@ -42,7 +44,7 @@  struct rte_stack_lf_head {
 struct rte_stack_lf_list {
 	/** List head */
-	struct rte_stack_lf_head head __rte_aligned(16);
+	alignas(16) struct rte_stack_lf_head head;
 	/** List len */
 	RTE_ATOMIC(uint64_t) len;