Skip to contentSkip to conversation

use C11 alignof

PATCH Superseded Tyler Retzlaff 8 participants 40 messages Jan 24, 2024 – Feb 14, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover use C11 alignof

Replace use of __alignof__(T) and __alignof__(e) with C11 alignof(T) and alignof(typeof(e)) respectively to improve portability of the code between toolchains.

Tyler Retzlaff (9):
ring: use C11 alignof
mbuf: use C11 alignof
ethdev: use C11 alignof
eventdev: use C11 alignof
stack: use C11 alignof
node: use C11 alignof
pdcp: use C11 alignof
reorder: use C11 alignof
security: use C11 alignof

 lib/ethdev/ethdev_driver.c  | 3 ++-
 lib/ethdev/rte_flow.c       | 3 ++-
 lib/eventdev/rte_eventdev.c | 3 ++-
 lib/mbuf/rte_mbuf_dyn.c     | 3 ++-
 lib/node/node_private.h     | 4 +++-
 lib/pdcp/rte_pdcp.c         | 4 +++-
 lib/reorder/rte_reorder.c   | 3 ++-
 lib/ring/rte_ring.c         | 3 ++-
 lib/security/rte_security.c | 5 +++--
 lib/stack/rte_stack.c       | 3 ++-
 10 files changed, 23 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/9 ring: use C11 alignof

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

---
 lib/ring/rte_ring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/ring/rte_ring.c +2 -1
index c59f626..a783299 100644
@@ -7,6 +7,7 @@
  * Used as BSD-3 Licensed with permission from Kip Macy.
  */
 
+#include <stdalign.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -288,7 +289,7 @@ struct rte_ring *
 	 * rte_errno for us appropriately - hence no check in this function
 	 */
 	mz = rte_memzone_reserve_aligned(mz_name, ring_size, socket_id,
-					 mz_flags, __alignof__(*r));
+					 mz_flags, alignof(typeof(*r)));
 	if (mz != NULL) {
 		r = mz->addr;
 		/* no need to check return value here, we already checked the
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/9 mbuf: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/mbuf/rte_mbuf_dyn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf_dyn.c +2 -1
index 446018f..1cfb329 100644
@@ -2,6 +2,7 @@
  * Copyright 2019 6WIND S.A.
  */
 
+#include <stdalign.h>
 #include <sys/queue.h>
 #include <stdint.h>
 #include <limits.h>
@@ -585,7 +586,7 @@ void rte_mbuf_dyn_dump(FILE *out)
 	static const struct rte_mbuf_dynfield field_desc = {
 		.name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME,
 		.size = sizeof(rte_mbuf_timestamp_t),
-		.align = __alignof__(rte_mbuf_timestamp_t),
+		.align = alignof(rte_mbuf_timestamp_t),
 	};
 	struct rte_mbuf_dynflag flag_desc = {};
 	int offset;
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/9 ethdev: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/ethdev/ethdev_driver.c | 3 ++-
 lib/ethdev/rte_flow.c      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
lib/ethdev/ethdev_driver.c +2 -1
index bd917a1..4d45fbd 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <stdlib.h>
 #include <pthread.h>
 
@@ -633,7 +634,7 @@ struct rte_eth_dev *
 	static const struct rte_mbuf_dynfield field_desc = {
 		.name = RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME,
 		.size = sizeof(rte_eth_ip_reassembly_dynfield_t),
-		.align = __alignof__(rte_eth_ip_reassembly_dynfield_t),
+		.align = alignof(rte_eth_ip_reassembly_dynfield_t),
 	};
 	static const struct rte_mbuf_dynflag ip_reassembly_dynflag = {
 		.name = RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME,
lib/ethdev/rte_flow.c +2 -1
index f49d1d3..2cd30d6 100644
@@ -3,6 +3,7 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
+#include <stdalign.h>
 #include <errno.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -281,7 +282,7 @@ struct rte_flow_desc_data {
 	static const struct rte_mbuf_dynfield desc_offs = {
 		.name = RTE_MBUF_DYNFIELD_METADATA_NAME,
 		.size = sizeof(uint32_t),
-		.align = __alignof__(uint32_t),
+		.align = alignof(uint32_t),
 	};
 	static const struct rte_mbuf_dynflag desc_flag = {
 		.name = RTE_MBUF_DYNFLAG_METADATA_NAME,
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/9 eventdev: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/eventdev/rte_eventdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/eventdev/rte_eventdev.c +2 -1
index 94628a6..d494f8f 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2016 Cavium, Inc
  */
 
+#include <stdalign.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1405,7 +1406,7 @@ int rte_event_dev_selftest(uint8_t dev_id)
 	static const struct rte_mbuf_dynfield test_seqn_dynfield_desc = {
 		.name = "rte_event_pmd_selftest_seqn_dynfield",
 		.size = sizeof(rte_event_pmd_selftest_seqn_t),
-		.align = __alignof__(rte_event_pmd_selftest_seqn_t),
+		.align = alignof(rte_event_pmd_selftest_seqn_t),
 	};
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/9 stack: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/stack/rte_stack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/stack/rte_stack.c +2 -1
index 1dab6d6..7261281 100644
@@ -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();
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/9 node: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/node/node_private.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/node/node_private.h +3 -1
index 845fdaa..92acb9b 100644
@@ -5,6 +5,8 @@
 #ifndef __NODE_PRIVATE_H__
 #define __NODE_PRIVATE_H__
 
+#include <stdalign.h>
+
 #include <rte_common.h>
 #include <rte_log.h>
 #include <rte_mbuf.h>
@@ -42,7 +44,7 @@ struct node_mbuf_priv1 {
 static const struct rte_mbuf_dynfield node_mbuf_priv1_dynfield_desc = {
 	.name = "rte_node_dynfield_priv1",
 	.size = sizeof(struct node_mbuf_priv1),
-	.align = __alignof__(struct node_mbuf_priv1),
+	.align = alignof(struct node_mbuf_priv1),
 };
 extern int node_mbuf_priv1_dynfield_offset;
 
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/9 pdcp: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/pdcp/rte_pdcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/pdcp/rte_pdcp.c +3 -1
index 1c6d246..1c076fb 100644
@@ -2,6 +2,8 @@
  * Copyright(C) 2023 Marvell.
  */
 
+#include <stdalign.h>
+
 #include <rte_errno.h>
 #include <rte_pdcp.h>
 #include <rte_malloc.h>
@@ -32,7 +34,7 @@ struct entity_layout {
 	const struct rte_mbuf_dynfield dynfield_desc = {
 		.name = RTE_PDCP_DYNFIELD_NAME,
 		.size = sizeof(rte_pdcp_dynfield_t),
-		.align = __alignof__(rte_pdcp_dynfield_t),
+		.align = alignof(rte_pdcp_dynfield_t),
 	};
 
 	if (rte_pdcp_dynfield_offset != -1)
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH 8/9 reorder: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/reorder/rte_reorder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/reorder/rte_reorder.c +2 -1
index ff81544..c080b2c 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <string.h>
 #include <sys/queue.h>
 
@@ -72,7 +73,7 @@ struct rte_reorder_buffer *
 	static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = {
 		.name = RTE_REORDER_SEQN_DYNFIELD_NAME,
 		.size = sizeof(rte_reorder_seqn_t),
-		.align = __alignof__(rte_reorder_seqn_t),
+		.align = alignof(rte_reorder_seqn_t),
 	};
 
 	if (b == NULL) {
Signature · 1 line
1.8.3.1
Acked-by on v1 8/9
#10 lore raw

RE: [EXT] [PATCH 8/9] reorder: use C11 alignof

Quoted 15 lines

-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Thursday, January 25, 2024 12:18 AM
To: [email protected]
Cc: Akhil Goyal <[email protected]>; Andrew Rybchenko <[email protected]>; Anoob Joseph <[email protected]>; Ferruh Yigit <[email protected]>; Honnappa Nagarahalli <[email protected]>; Jerin Jacob <[email protected]>; Konstantin Ananyev <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Ori Kam <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Thomas Monjalon <[email protected]>; Volodymyr Fialko <[email protected]>; Tyler Retzlaff <[email protected]>
Subject: [EXT] [PATCH 8/9] reorder: use C11 alignof

External Email

Quoted 8 lines

----------------------------------------------------------------------
Replace use of __alignof__(T) with C11 alignof(T) to improve portability between toolchains.

---
 lib/reorder/rte_reorder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

__alignof__ is supported by GCC from C99, but since DPDK 23.11 C11 compiler is required anyway, It should be fine to switch.

/Volodymyr

#11 lore raw

PATCH 9/9 security: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/security/rte_security.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/security/rte_security.c +3 -2
index b082a29..e5c862f 100644
@@ -4,6 +4,7 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <stdalign.h>
 #include <ctype.h>
 #include <stdlib.h>
 
@@ -38,7 +39,7 @@
 	static const struct rte_mbuf_dynfield dynfield_desc = {
 		.name = RTE_SECURITY_DYNFIELD_NAME,
 		.size = sizeof(rte_security_dynfield_t),
-		.align = __alignof__(rte_security_dynfield_t),
+		.align = alignof(rte_security_dynfield_t),
 	};
 	rte_security_dynfield_offset =
 		rte_mbuf_dynfield_register(&dynfield_desc);
@@ -51,7 +52,7 @@
 	static const struct rte_mbuf_dynfield dynfield_desc = {
 		.name = RTE_SECURITY_OOP_DYNFIELD_NAME,
 		.size = sizeof(rte_security_oop_dynfield_t),
-		.align = __alignof__(rte_security_oop_dynfield_t),
+		.align = alignof(rte_security_oop_dynfield_t),
 	};
 
 	rte_security_oop_dynfield_offset =
Signature · 1 line
1.8.3.1
#13 lore raw
In reply to Tyler Retzlaff
Quoted 30 lines

From: Tyler Retzlaff [mailto:[email protected]]
Sent: Thursday, 25 January 2024 00.18

Replace use of __alignof__(T) and __alignof__(e) with C11 alignof(T) and alignof(typeof(e)) respectively to improve portability of the code between toolchains.

Tyler Retzlaff (9):
ring: use C11 alignof
mbuf: use C11 alignof
ethdev: use C11 alignof
eventdev: use C11 alignof
stack: use C11 alignof
node: use C11 alignof
pdcp: use C11 alignof
reorder: use C11 alignof
security: use C11 alignof

 lib/ethdev/ethdev_driver.c  | 3 ++-
 lib/ethdev/rte_flow.c       | 3 ++-
 lib/eventdev/rte_eventdev.c | 3 ++-
 lib/mbuf/rte_mbuf_dyn.c     | 3 ++-
 lib/node/node_private.h     | 4 +++-
 lib/pdcp/rte_pdcp.c         | 4 +++-
 lib/reorder/rte_reorder.c   | 3 ++-
 lib/ring/rte_ring.c         | 3 ++-
 lib/security/rte_security.c | 5 +++--
 lib/stack/rte_stack.c       | 3 ++-
 10 files changed, 23 insertions(+), 11 deletions(-)
Quoted 1 line

--

#14 lore raw
In reply to Tyler Retzlaff
Quoted 27 lines · Tyler Retzlaff

Replace use of __alignof__(T) and __alignof__(e) with C11 alignof(T) and alignof(typeof(e)) respectively to improve portability of the code between toolchains.

Tyler Retzlaff (9):
ring: use C11 alignof
mbuf: use C11 alignof
ethdev: use C11 alignof
eventdev: use C11 alignof
stack: use C11 alignof
node: use C11 alignof
pdcp: use C11 alignof
reorder: use C11 alignof
security: use C11 alignof

 lib/ethdev/ethdev_driver.c  | 3 ++-
 lib/ethdev/rte_flow.c       | 3 ++-
 lib/eventdev/rte_eventdev.c | 3 ++-
 lib/mbuf/rte_mbuf_dyn.c     | 3 ++-
 lib/node/node_private.h     | 4 +++-
 lib/pdcp/rte_pdcp.c         | 4 +++-
 lib/reorder/rte_reorder.c   | 3 ++-
 lib/ring/rte_ring.c         | 3 ++-
 lib/security/rte_security.c | 5 +++--
 lib/stack/rte_stack.c       | 3 ++-
 10 files changed, 23 insertions(+), 11 deletions(-)
#15 lore raw
In reply to Tyler Retzlaff
Quoted 16 lines · Tyler Retzlaff

Replace use of __alignof__(T) and __alignof__(e) with C11 alignof(T) and alignof(typeof(e)) respectively to improve portability of the code between toolchains.

Tyler Retzlaff (9):
ring: use C11 alignof
mbuf: use C11 alignof
ethdev: use C11 alignof
eventdev: use C11 alignof
stack: use C11 alignof
node: use C11 alignof
pdcp: use C11 alignof
reorder: use C11 alignof
security: use C11 alignof

Quoted 11 lines
 lib/ethdev/ethdev_driver.c  | 3 ++-
 lib/ethdev/rte_flow.c       | 3 ++-
 lib/eventdev/rte_eventdev.c | 3 ++-
 lib/mbuf/rte_mbuf_dyn.c     | 3 ++-
 lib/node/node_private.h     | 4 +++-
 lib/pdcp/rte_pdcp.c         | 4 +++-
 lib/reorder/rte_reorder.c   | 3 ++-
 lib/ring/rte_ring.c         | 3 ++-
 lib/security/rte_security.c | 5 +++--
 lib/stack/rte_stack.c       | 3 ++-
 10 files changed, 23 insertions(+), 11 deletions(-)

The change is trivial, but without a check in checkpatches.sh, I imagine new occurence to be introduced in the future. Btw, as it is trivial, please apply this change to the whole tree.

Signature · 1 line
David Marchand
#16 lore raw

v2 cover use C11 alignof

In reply to Tyler Retzlaff

Replace use of __alignof__(T) and __alignof__(e) with C11 alignof(T) and alignof(typeof(e)) respectively to improve portability of the code between toolchains.

v2:
* expand series to replace use in entire source tree, now includes app, drivers, examples in addition to lib.

Tyler Retzlaff (21):
ring: use C11 alignof
mbuf: use C11 alignof
ethdev: use C11 alignof
eventdev: use C11 alignof
stack: use C11 alignof
node: use C11 alignof
pdcp: use C11 alignof
reorder: use C11 alignof
security: use C11 alignof
test: use C11 alignof
examples: use C11 alignof
app/eventdev: use C11 alignof
drivers/bus: use C11 alignof
event/sw: use C11 alignof
net/bnxt: use C11 alignof
net/iavf: use C11 alignof
net/nfp: use C11 alignof
net/sfc: use C11 alignof
net/virtio: use C11 alignof
net/vmxnet3: use C11 alignof
devtools: forbid direct use of compiler alignof and typeof

 app/test-eventdev/test_order_common.c |  6 ++++--
 app/test/test_distributor.c           |  3 ++-
 app/test/test_graph.c                 |  3 ++-
 app/test/test_mbuf.c                  |  9 +++++----
 app/test/test_ring_stress_impl.h      |  6 ++++--
 devtools/checkpatches.sh              | 16 ++++++++++++++++
 drivers/bus/dpaa/dpaa_bus.c           |  3 ++-
 drivers/bus/fslmc/fslmc_bus.c         |  3 ++-
 drivers/event/sw/sw_evdev_selftest.c  |  3 ++-
 drivers/net/bnxt/bnxt_ethdev.c        |  3 ++-
 drivers/net/iavf/iavf_ethdev.c        |  3 ++-
 drivers/net/iavf/iavf_ipsec_crypto.c  |  4 +++-
 drivers/net/iavf/iavf_testpmd.c       |  3 ++-
 drivers/net/nfp/nfp_ipsec.c           |  4 +++-
 drivers/net/sfc/sfc_dp.c              |  5 +++--
 drivers/net/virtio/virtio_rxtx.c      |  7 ++++---
 drivers/net/vmxnet3/vmxnet3_ethdev.c  |  3 ++-
 examples/bbdev_app/main.c             |  3 ++-
 examples/rxtx_callbacks/main.c        |  3 ++-
 lib/ethdev/ethdev_driver.c            |  3 ++-
 lib/ethdev/rte_flow.c                 |  3 ++-
 lib/eventdev/rte_eventdev.c           |  3 ++-
 lib/mbuf/rte_mbuf_dyn.c               |  3 ++-
 lib/node/node_private.h               |  4 +++-
 lib/pdcp/rte_pdcp.c                   |  4 +++-
 lib/reorder/rte_reorder.c             |  3 ++-
 lib/ring/rte_ring.c                   |  3 ++-
 lib/security/rte_security.c           |  5 +++--
 lib/stack/rte_stack.c                 |  3 ++-
 29 files changed, 87 insertions(+), 37 deletions(-)
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH v2 1/21 ring: use C11 alignof

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

---
 lib/ring/rte_ring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/ring/rte_ring.c +2 -1
index c59f626..a783299 100644
@@ -7,6 +7,7 @@
  * Used as BSD-3 Licensed with permission from Kip Macy.
  */
 
+#include <stdalign.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -288,7 +289,7 @@ struct rte_ring *
 	 * rte_errno for us appropriately - hence no check in this function
 	 */
 	mz = rte_memzone_reserve_aligned(mz_name, ring_size, socket_id,
-					 mz_flags, __alignof__(*r));
+					 mz_flags, alignof(typeof(*r)));
 	if (mz != NULL) {
 		r = mz->addr;
 		/* no need to check return value here, we already checked the
Signature · 1 line
1.8.3.1
#18 lore raw

PATCH v2 2/21 mbuf: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/mbuf/rte_mbuf_dyn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/mbuf/rte_mbuf_dyn.c +2 -1
index 446018f..1cfb329 100644
@@ -2,6 +2,7 @@
  * Copyright 2019 6WIND S.A.
  */
 
+#include <stdalign.h>
 #include <sys/queue.h>
 #include <stdint.h>
 #include <limits.h>
@@ -585,7 +586,7 @@ void rte_mbuf_dyn_dump(FILE *out)
 	static const struct rte_mbuf_dynfield field_desc = {
 		.name = RTE_MBUF_DYNFIELD_TIMESTAMP_NAME,
 		.size = sizeof(rte_mbuf_timestamp_t),
-		.align = __alignof__(rte_mbuf_timestamp_t),
+		.align = alignof(rte_mbuf_timestamp_t),
 	};
 	struct rte_mbuf_dynflag flag_desc = {};
 	int offset;
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH v2 3/21 ethdev: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/ethdev/ethdev_driver.c | 3 ++-
 lib/ethdev/rte_flow.c      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
lib/ethdev/ethdev_driver.c +2 -1
index bd917a1..4d45fbd 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2022 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <stdlib.h>
 #include <pthread.h>
 
@@ -633,7 +634,7 @@ struct rte_eth_dev *
 	static const struct rte_mbuf_dynfield field_desc = {
 		.name = RTE_MBUF_DYNFIELD_IP_REASSEMBLY_NAME,
 		.size = sizeof(rte_eth_ip_reassembly_dynfield_t),
-		.align = __alignof__(rte_eth_ip_reassembly_dynfield_t),
+		.align = alignof(rte_eth_ip_reassembly_dynfield_t),
 	};
 	static const struct rte_mbuf_dynflag ip_reassembly_dynflag = {
 		.name = RTE_MBUF_DYNFLAG_IP_REASSEMBLY_INCOMPLETE_NAME,
lib/ethdev/rte_flow.c +2 -1
index f49d1d3..2cd30d6 100644
@@ -3,6 +3,7 @@
  * Copyright 2016 Mellanox Technologies, Ltd
  */
 
+#include <stdalign.h>
 #include <errno.h>
 #include <stddef.h>
 #include <stdint.h>
@@ -281,7 +282,7 @@ struct rte_flow_desc_data {
 	static const struct rte_mbuf_dynfield desc_offs = {
 		.name = RTE_MBUF_DYNFIELD_METADATA_NAME,
 		.size = sizeof(uint32_t),
-		.align = __alignof__(uint32_t),
+		.align = alignof(uint32_t),
 	};
 	static const struct rte_mbuf_dynflag desc_flag = {
 		.name = RTE_MBUF_DYNFLAG_METADATA_NAME,
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH v2 4/21 eventdev: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/eventdev/rte_eventdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/eventdev/rte_eventdev.c +2 -1
index 94628a6..d494f8f 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2016 Cavium, Inc
  */
 
+#include <stdalign.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1405,7 +1406,7 @@ int rte_event_dev_selftest(uint8_t dev_id)
 	static const struct rte_mbuf_dynfield test_seqn_dynfield_desc = {
 		.name = "rte_event_pmd_selftest_seqn_dynfield",
 		.size = sizeof(rte_event_pmd_selftest_seqn_t),
-		.align = __alignof__(rte_event_pmd_selftest_seqn_t),
+		.align = alignof(rte_event_pmd_selftest_seqn_t),
 	};
 	struct rte_eventdev *dev = &rte_eventdevs[dev_id];
 
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH v2 5/21 stack: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/stack/rte_stack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/stack/rte_stack.c +2 -1
index 1dab6d6..7261281 100644
@@ -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();
Signature · 1 line
1.8.3.1
#22 lore raw

PATCH v2 6/21 node: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/node/node_private.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/node/node_private.h +3 -1
index 73563e4..2b9bad1 100644
@@ -5,6 +5,8 @@
 #ifndef __NODE_PRIVATE_H__
 #define __NODE_PRIVATE_H__
 
+#include <stdalign.h>
+
 #include <rte_common.h>
 #include <rte_log.h>
 #include <rte_mbuf.h>
@@ -42,7 +44,7 @@ struct node_mbuf_priv1 {
 static const struct rte_mbuf_dynfield node_mbuf_priv1_dynfield_desc = {
 	.name = "rte_node_dynfield_priv1",
 	.size = sizeof(struct node_mbuf_priv1),
-	.align = __alignof__(struct node_mbuf_priv1),
+	.align = alignof(struct node_mbuf_priv1),
 };
 extern int node_mbuf_priv1_dynfield_offset;
 
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH v2 7/21 pdcp: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/pdcp/rte_pdcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/pdcp/rte_pdcp.c +3 -1
index 1c6d246..1c076fb 100644
@@ -2,6 +2,8 @@
  * Copyright(C) 2023 Marvell.
  */
 
+#include <stdalign.h>
+
 #include <rte_errno.h>
 #include <rte_pdcp.h>
 #include <rte_malloc.h>
@@ -32,7 +34,7 @@ struct entity_layout {
 	const struct rte_mbuf_dynfield dynfield_desc = {
 		.name = RTE_PDCP_DYNFIELD_NAME,
 		.size = sizeof(rte_pdcp_dynfield_t),
-		.align = __alignof__(rte_pdcp_dynfield_t),
+		.align = alignof(rte_pdcp_dynfield_t),
 	};
 
 	if (rte_pdcp_dynfield_offset != -1)
Signature · 1 line
1.8.3.1
#24 lore raw

PATCH v2 8/21 reorder: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/reorder/rte_reorder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/reorder/rte_reorder.c +2 -1
index ff81544..c080b2c 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <string.h>
 #include <sys/queue.h>
 
@@ -72,7 +73,7 @@ struct rte_reorder_buffer *
 	static const struct rte_mbuf_dynfield reorder_seqn_dynfield_desc = {
 		.name = RTE_REORDER_SEQN_DYNFIELD_NAME,
 		.size = sizeof(rte_reorder_seqn_t),
-		.align = __alignof__(rte_reorder_seqn_t),
+		.align = alignof(rte_reorder_seqn_t),
 	};
 
 	if (b == NULL) {
Signature · 1 line
1.8.3.1
#25 lore raw

PATCH v2 9/21 security: use C11 alignof

In reply to Tyler Retzlaff

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

---
 lib/security/rte_security.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
lib/security/rte_security.c +3 -2
index b082a29..e5c862f 100644
@@ -4,6 +4,7 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <stdalign.h>
 #include <ctype.h>
 #include <stdlib.h>
 
@@ -38,7 +39,7 @@
 	static const struct rte_mbuf_dynfield dynfield_desc = {
 		.name = RTE_SECURITY_DYNFIELD_NAME,
 		.size = sizeof(rte_security_dynfield_t),
-		.align = __alignof__(rte_security_dynfield_t),
+		.align = alignof(rte_security_dynfield_t),
 	};
 	rte_security_dynfield_offset =
 		rte_mbuf_dynfield_register(&dynfield_desc);
@@ -51,7 +52,7 @@
 	static const struct rte_mbuf_dynfield dynfield_desc = {
 		.name = RTE_SECURITY_OOP_DYNFIELD_NAME,
 		.size = sizeof(rte_security_oop_dynfield_t),
-		.align = __alignof__(rte_security_oop_dynfield_t),
+		.align = alignof(rte_security_oop_dynfield_t),
 	};
 
 	rte_security_oop_dynfield_offset =
Signature · 1 line
1.8.3.1
#26 lore raw

PATCH v2 10/21 test: use C11 alignof

In reply to Tyler Retzlaff

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

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

---
 app/test/test_distributor.c      | 3 ++-
 app/test/test_graph.c            | 3 ++-
 app/test/test_mbuf.c             | 9 +++++----
 app/test/test_ring_stress_impl.h | 6 ++++--
 4 files changed, 13 insertions(+), 8 deletions(-)
app/test/test_distributor.c +2 -1
index 6cb27f4..d2037b7 100644
@@ -5,6 +5,7 @@
 #include "test.h"
 
 #include <unistd.h>
+#include <stdalign.h>
 #include <string.h>
 #include <rte_cycles.h>
 #include <rte_errno.h>
@@ -831,7 +832,7 @@ int test_error_distributor_create_numworkers(void)
 	static const struct rte_mbuf_dynfield seq_dynfield_desc = {
 		.name = "test_distributor_dynfield_seq",
 		.size = sizeof(seq_dynfield_t),
-		.align = __alignof__(seq_dynfield_t),
+		.align = alignof(seq_dynfield_t),
 	};
 	seq_dynfield_offset =
 		rte_mbuf_dynfield_register(&seq_dynfield_desc);
app/test/test_graph.c +2 -1
index 3dd017e..b8409bc 100644
@@ -7,6 +7,7 @@
 #include <assert.h>
 #include <inttypes.h>
 #include <signal.h>
+#include <stdalign.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -935,7 +936,7 @@ struct test_node_register {
 	static const struct rte_mbuf_dynfield graph_dynfield_desc = {
 		.name = "test_graph_dynfield",
 		.size = sizeof(graph_dynfield_t),
-		.align = __alignof__(graph_dynfield_t),
+		.align = alignof(graph_dynfield_t),
 	};
 	graph_dynfield_offset =
 		rte_mbuf_dynfield_register(&graph_dynfield_desc);
app/test/test_mbuf.c +5 -4
index d7393df..51ea6ef 100644
@@ -5,6 +5,7 @@
 #include "test.h"
 
 #include <string.h>
+#include <stdalign.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -2534,19 +2535,19 @@ struct test_case {
 	const struct rte_mbuf_dynfield dynfield = {
 		.name = "test-dynfield",
 		.size = sizeof(uint8_t),
-		.align = __alignof__(uint8_t),
+		.align = alignof(uint8_t),
 		.flags = 0,
 	};
 	const struct rte_mbuf_dynfield dynfield2 = {
 		.name = "test-dynfield2",
 		.size = sizeof(uint16_t),
-		.align = __alignof__(uint16_t),
+		.align = alignof(uint16_t),
 		.flags = 0,
 	};
 	const struct rte_mbuf_dynfield dynfield3 = {
 		.name = "test-dynfield3",
 		.size = sizeof(uint8_t),
-		.align = __alignof__(uint8_t),
+		.align = alignof(uint8_t),
 		.flags = 0,
 	};
 	const struct rte_mbuf_dynfield dynfield_fail_big = {
@@ -2564,7 +2565,7 @@ struct test_case {
 	const struct rte_mbuf_dynfield dynfield_fail_flag = {
 		.name = "test-dynfield",
 		.size = sizeof(uint8_t),
-		.align = __alignof__(uint8_t),
+		.align = alignof(uint8_t),
 		.flags = 1,
 	};
 	const struct rte_mbuf_dynflag dynflag_fail_flag = {
app/test/test_ring_stress_impl.h +4 -2
index 62f046a..2dec897 100644
@@ -2,6 +2,8 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <stdalign.h>
+
 #include "test_ring_stress.h"
 
 /**
@@ -285,7 +287,7 @@ struct ring_elem {
 	*data = NULL;
 
 	sz = num * sizeof(*elm);
-	elm = rte_zmalloc(NULL, sz, __alignof__(*elm));
+	elm = rte_zmalloc(NULL, sz, alignof(typeof(*elm)));
 	if (elm == NULL) {
 		printf("%s: alloc(%zu) for %u elems data failed",
 			__func__, sz, num);
@@ -297,7 +299,7 @@ struct ring_elem {
 	/* alloc ring */
 	nr = 2 * num;
 	sz = rte_ring_get_memsize(nr);
-	r = rte_zmalloc(NULL, sz, __alignof__(*r));
+	r = rte_zmalloc(NULL, sz, alignof(typeof(*r)));
 	if (r == NULL) {
 		printf("%s: alloc(%zu) for FIFO with %u elems failed",
 			__func__, sz, nr);
Signature · 1 line
1.8.3.1
#27 lore raw

PATCH v2 11/21 examples: use C11 alignof

In reply to Tyler Retzlaff

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

---
 examples/bbdev_app/main.c      | 3 ++-
 examples/rxtx_callbacks/main.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
examples/bbdev_app/main.c +2 -1
index ef9cd29..16599ae 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1051,7 +1052,7 @@ uint16_t bbdev_parse_number(const char *mask)
 	static const struct rte_mbuf_dynfield input_dynfield_desc = {
 		.name = "example_bbdev_dynfield_input",
 		.size = sizeof(struct rte_mbuf *),
-		.align = __alignof__(struct rte_mbuf *),
+		.align = alignof(struct rte_mbuf *),
 	};
 
 	__atomic_store_n(&global_exit_flag, 0, __ATOMIC_RELAXED);
examples/rxtx_callbacks/main.c +2 -1
index 59eee49..4682921 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2015 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <inttypes.h>
@@ -292,7 +293,7 @@
 	static const struct rte_mbuf_dynfield tsc_dynfield_desc = {
 		.name = "example_bbdev_dynfield_tsc",
 		.size = sizeof(tsc_t),
-		.align = __alignof__(tsc_t),
+		.align = alignof(tsc_t),
 	};
 
 	/* init EAL */
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH v2 12/21 app/eventdev: use C11 alignof

In reply to Tyler Retzlaff

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

---
 app/test-eventdev/test_order_common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
app/test-eventdev/test_order_common.c +4 -2
index 6f00f24..a9894c6 100644
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Cavium, Inc
  */
 
+#include <stdalign.h>
+
 #include "test_order_common.h"
 
 int
@@ -139,12 +141,12 @@
 	static const struct rte_mbuf_dynfield flow_id_dynfield_desc = {
 		.name = "test_event_dynfield_flow_id",
 		.size = sizeof(flow_id_t),
-		.align = __alignof__(flow_id_t),
+		.align = alignof(flow_id_t),
 	};
 	static const struct rte_mbuf_dynfield seqn_dynfield_desc = {
 		.name = "test_event_dynfield_seqn",
 		.size = sizeof(seqn_t),
-		.align = __alignof__(seqn_t),
+		.align = alignof(seqn_t),
 	};
 
 	test_order = rte_zmalloc_socket(test->name, sizeof(struct test_order),
Signature · 1 line
1.8.3.1
#29 lore raw

PATCH v2 13/21 drivers/bus: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/bus/dpaa/dpaa_bus.c   | 3 ++-
 drivers/bus/fslmc/fslmc_bus.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/bus/dpaa/dpaa_bus.c +2 -1
index e57159f..4647360 100644
@@ -4,6 +4,7 @@
  *
  */
 /* System headers */
+#include <stdalign.h>
 #include <stdio.h>
 #include <inttypes.h>
 #include <unistd.h>
@@ -307,7 +308,7 @@ int rte_dpaa_portal_init(void *arg)
 	static const struct rte_mbuf_dynfield dpaa_seqn_dynfield_desc = {
 		.name = DPAA_SEQN_DYNFIELD_NAME,
 		.size = sizeof(dpaa_seqn_t),
-		.align = __alignof__(dpaa_seqn_t),
+		.align = alignof(dpaa_seqn_t),
 	};
 	unsigned int cpu, lcore = rte_lcore_id();
 	int ret;
drivers/bus/fslmc/fslmc_bus.c +2 -1
index 57bfb51..b1af47c 100644
@@ -6,6 +6,7 @@
 
 #include <string.h>
 #include <dirent.h>
+#include <stdalign.h>
 #include <stdbool.h>
 
 #include <rte_log.h>
@@ -395,7 +396,7 @@
 	static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc = {
 		.name = DPAA2_SEQN_DYNFIELD_NAME,
 		.size = sizeof(dpaa2_seqn_t),
-		.align = __alignof__(dpaa2_seqn_t),
+		.align = alignof(dpaa2_seqn_t),
 	};
 
 	if (TAILQ_EMPTY(&rte_fslmc_bus.device_list))
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH v2 14/21 event/sw: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/event/sw/sw_evdev_selftest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/event/sw/sw_evdev_selftest.c +2 -1
index e6646e5..a2ce140 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2016-2017 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -3201,7 +3202,7 @@ struct test_event_dev_stats {
 	static const struct rte_mbuf_dynfield counter_dynfield_desc = {
 		.name = "rte_event_sw_dynfield_selftest_counter",
 		.size = sizeof(counter_dynfield_t),
-		.align = __alignof__(counter_dynfield_t),
+		.align = alignof(counter_dynfield_t),
 	};
 	counter_dynfield_offset =
 		rte_mbuf_dynfield_register(&counter_dynfield_desc);
Signature · 1 line
1.8.3.1
#31 lore raw

PATCH v2 15/21 net/bnxt: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/net/bnxt/bnxt_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +2 -1
index acf7e6e..45d840d 100644
@@ -4,6 +4,7 @@
  */
 
 #include <inttypes.h>
+#include <stdalign.h>
 #include <stdbool.h>
 
 #include <dev_driver.h>
@@ -5920,7 +5921,7 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
 		static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = {
 			.name = RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME,
 			.size = sizeof(bnxt_cfa_code_dynfield_t),
-			.align = __alignof__(bnxt_cfa_code_dynfield_t),
+			.align = alignof(bnxt_cfa_code_dynfield_t),
 		};
 		bnxt_cfa_code_dynfield_offset =
 			rte_mbuf_dynfield_register(&bnxt_cfa_code_dynfield_desc);
Signature · 1 line
1.8.3.1
Acked-by on v2 15/21
#32 lore raw

Re: [PATCH v2 15/21] net/bnxt: use C11 alignof

Quoted 5 lines · Tyler Retzlaff

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

Quoted 28 lines
---
 drivers/net/bnxt/bnxt_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt_ethdev.c +2 -2
index acf7e6e..45d840d 100644
@@ -4,6 +4,7 @@
  */
 
 #include <inttypes.h>
+#include <stdalign.h>
 #include <stdbool.h>
 
 #include <dev_driver.h>
@@ -5920,7 +5921,7 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
                static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = {
                        .name = RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME,
                        .size = sizeof(bnxt_cfa_code_dynfield_t),
-                       .align = __alignof__(bnxt_cfa_code_dynfield_t),
+                       .align = alignof(bnxt_cfa_code_dynfield_t),
                };
                bnxt_cfa_code_dynfield_offset =
                        rte_mbuf_dynfield_register(&bnxt_cfa_code_dynfield_desc);
--

1.8.3.1

#33 lore raw

PATCH v2 16/21 net/iavf: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/net/iavf/iavf_ethdev.c       | 3 ++-
 drivers/net/iavf/iavf_ipsec_crypto.c | 4 +++-
 drivers/net/iavf/iavf_testpmd.c      | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/iavf/iavf_ethdev.c +2 -1
index 1fb876e..0b350e9 100644
@@ -4,6 +4,7 @@
 
 #include <ctype.h>
 #include <sys/queue.h>
+#include <stdalign.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
@@ -55,7 +56,7 @@
 static const struct rte_mbuf_dynfield iavf_proto_xtr_metadata_param = {
 	.name = "intel_pmd_dynfield_proto_xtr_metadata",
 	.size = sizeof(uint32_t),
-	.align = __alignof__(uint32_t),
+	.align = alignof(uint32_t),
 	.flags = 0,
 };
 
drivers/net/iavf/iavf_ipsec_crypto.c +3 -1
index d6c0180..6fd45ff 100644
@@ -2,6 +2,8 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#include <stdalign.h>
+
 #include <rte_cryptodev.h>
 #include <rte_ethdev.h>
 #include <rte_security_driver.h>
@@ -1535,7 +1537,7 @@ enum rte_crypto_aead_algorithm aead_maptbl[] = {
 	struct rte_mbuf_dynfield pkt_md_dynfield = {
 		.name = "iavf_ipsec_crypto_pkt_metadata",
 		.size = sizeof(struct iavf_ipsec_crypto_pkt_metadata),
-		.align = __alignof__(struct iavf_ipsec_crypto_pkt_metadata)
+		.align = alignof(struct iavf_ipsec_crypto_pkt_metadata)
 	};
 	struct virtchnl_ipsec_cap capabilities;
 	int rc;
drivers/net/iavf/iavf_testpmd.c +2 -1
index 07aac07..775179f 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2016 Intel Corporation.
  */
 
+#include <stdalign.h>
 #include <stdlib.h>
 
 #include <rte_pmd_iavf.h>
@@ -41,7 +42,7 @@ struct cmd_enable_tx_lldp_result {
 	const struct rte_mbuf_dynfield iavf_tx_lldp_dynfield = {
 		.name = IAVF_TX_LLDP_DYNFIELD,
 		.size = sizeof(uint8_t),
-		.align = __alignof__(uint8_t),
+		.align = alignof(uint8_t),
 		.flags = 0
 	};
 	int offset;
Signature · 1 line
1.8.3.1
#34 lore raw

PATCH v2 17/21 net/nfp: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/net/nfp/nfp_ipsec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/nfp/nfp_ipsec.c +3 -1
index 4529473..6e9bb06 100644
@@ -3,6 +3,8 @@
  * All rights reserved.
  */
 
+#include <stdalign.h>
+
 #include "nfp_ipsec.h"
 
 #include <rte_cryptodev.h>
@@ -1348,7 +1350,7 @@ enum nfp_ipsec_df_type {
 	static const struct rte_mbuf_dynfield pkt_md_dynfield = {
 		.name = "nfp_ipsec_crypto_pkt_metadata",
 		.size = sizeof(struct nfp_tx_ipsec_desc_msg),
-		.align = __alignof__(struct nfp_tx_ipsec_desc_msg),
+		.align = alignof(struct nfp_tx_ipsec_desc_msg),
 	};
 
 	ctx = rte_zmalloc("security_ctx",
Signature · 1 line
1.8.3.1
#35 lore raw

PATCH v2 18/21 net/sfc: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/net/sfc/sfc_dp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/sfc/sfc_dp.c +3 -2
index 2b0a1d7..7e2a20e 100644
@@ -8,6 +8,7 @@
  */
 
 #include <sys/queue.h>
+#include <stdalign.h>
 #include <string.h>
 #include <errno.h>
 
@@ -91,7 +92,7 @@ struct sfc_dp *
 	static const struct rte_mbuf_dynfield mport = {
 		.name = "rte_net_sfc_dynfield_mport",
 		.size = sizeof(efx_mport_id_t),
-		.align = __alignof__(efx_mport_id_t),
+		.align = alignof(efx_mport_id_t),
 	};
 	static const struct rte_mbuf_dynflag mport_override = {
 		.name = "rte_net_sfc_dynflag_mport_override",
@@ -134,7 +135,7 @@ struct sfc_dp *
 	static const struct rte_mbuf_dynfield ft_ctx_id = {
 		.name = "rte_net_sfc_dynfield_ft_ctx_id",
 		.size = sizeof(uint8_t),
-		.align = __alignof__(uint8_t),
+		.align = alignof(uint8_t),
 	};
 
 	int field_offset;
Signature · 1 line
1.8.3.1
#36 lore raw

PATCH v2 19/21 net/virtio: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/net/virtio/virtio_rxtx.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/virtio/virtio_rxtx.c +4 -3
index 99b9519..f69b945 100644
@@ -2,6 +2,7 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
+#include <stdalign.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -1797,7 +1798,7 @@
 		    txm->nb_segs == 1 &&
 		    rte_pktmbuf_headroom(txm) >= hdr_size &&
 		    rte_is_aligned(rte_pktmbuf_mtod(txm, char *),
-			   __alignof__(struct virtio_net_hdr_mrg_rxbuf)))
+			   alignof(struct virtio_net_hdr_mrg_rxbuf)))
 			can_push = 1;
 		else if (virtio_with_feature(hw, VIRTIO_RING_F_INDIRECT_DESC) &&
 			 txm->nb_segs < VIRTIO_MAX_TX_INDIRECT)
@@ -1878,7 +1879,7 @@
 		    txm->nb_segs == 1 &&
 		    rte_pktmbuf_headroom(txm) >= hdr_size &&
 		    rte_is_aligned(rte_pktmbuf_mtod(txm, char *),
-				   __alignof__(struct virtio_net_hdr_mrg_rxbuf)))
+				   alignof(struct virtio_net_hdr_mrg_rxbuf)))
 			can_push = 1;
 		else if (virtio_with_feature(hw, VIRTIO_RING_F_INDIRECT_DESC) &&
 			 txm->nb_segs < VIRTIO_MAX_TX_INDIRECT)
@@ -1980,7 +1981,7 @@
 		     txm->nb_segs == 1 &&
 		     rte_pktmbuf_headroom(txm) >= hdr_size &&
 		     rte_is_aligned(rte_pktmbuf_mtod(txm, char *),
-				__alignof__(struct virtio_net_hdr_mrg_rxbuf))) {
+				alignof(struct virtio_net_hdr_mrg_rxbuf))) {
 			inorder_pkts[nb_inorder_pkts] = txm;
 			nb_inorder_pkts++;
 
Signature · 1 line
1.8.3.1
#37 lore raw

PATCH v2 20/21 net/vmxnet3: use C11 alignof

In reply to Tyler Retzlaff

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

---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/vmxnet3/vmxnet3_ethdev.c +2 -1
index 4fd7040..b239ea3 100644
@@ -3,6 +3,7 @@
  */
 
 #include <sys/queue.h>
+#include <stdalign.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
@@ -367,7 +368,7 @@ struct vmxnet3_xstats_name_off {
 	static const struct rte_mbuf_dynfield vmxnet3_segs_dynfield_desc = {
 		.name = VMXNET3_SEGS_DYNFIELD_NAME,
 		.size = sizeof(vmxnet3_segs_dynfield_t),
-		.align = __alignof__(vmxnet3_segs_dynfield_t),
+		.align = alignof(vmxnet3_segs_dynfield_t),
 	};
 
 	PMD_INIT_FUNC_TRACE();
Signature · 1 line
1.8.3.1
#38 lore raw

PATCH v2 21/21 devtools: forbid direct use of compiler alignof and typeof

In reply to Tyler Retzlaff

Add 2 checks forbidding direct use of __alignof__ and __typeof__ instead C11 alignof and rte_common.h typeof macros should be used.

---
 devtools/checkpatches.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
devtools/checkpatches.sh +16 -0
index c9e466f..e379700 100755
@@ -151,6 +151,22 @@ check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# forbid use of __alignof__
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS='\\<__alignof__\\>' \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using __alignof__, prefer C11 alignof' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
+	# forbid use of __typeof__
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS='\\<__typeof__\\>' \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using __typeof__, prefer typeof' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# forbid use of non abstracted bit count operations
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__builtin_(clz|clzll|ctz|ctzll|popcount|popcountll)\\>' \
Signature · 1 line
1.8.3.1
#39 lore raw
In reply to Tyler Retzlaff
Quoted 54 lines · Tyler Retzlaff

Replace use of __alignof__(T) and __alignof__(e) with C11 alignof(T) and alignof(typeof(e)) respectively to improve portability of the code between toolchains.

v2:
* expand series to replace use in entire source tree, now includes app, drivers, examples in addition to lib.

Tyler Retzlaff (21):
ring: use C11 alignof
mbuf: use C11 alignof
ethdev: use C11 alignof
eventdev: use C11 alignof
stack: use C11 alignof
node: use C11 alignof
pdcp: use C11 alignof
reorder: use C11 alignof
security: use C11 alignof
test: use C11 alignof
examples: use C11 alignof
app/eventdev: use C11 alignof
drivers/bus: use C11 alignof
event/sw: use C11 alignof
net/bnxt: use C11 alignof
net/iavf: use C11 alignof
net/nfp: use C11 alignof
net/sfc: use C11 alignof
net/virtio: use C11 alignof
net/vmxnet3: use C11 alignof
devtools: forbid direct use of compiler alignof and typeof

 app/test-eventdev/test_order_common.c |  6 ++++--
 app/test/test_distributor.c           |  3 ++-
 app/test/test_graph.c                 |  3 ++-
 app/test/test_mbuf.c                  |  9 +++++----
 app/test/test_ring_stress_impl.h      |  6 ++++--
 devtools/checkpatches.sh              | 16 ++++++++++++++++
 drivers/bus/dpaa/dpaa_bus.c           |  3 ++-
 drivers/bus/fslmc/fslmc_bus.c         |  3 ++-
 drivers/event/sw/sw_evdev_selftest.c  |  3 ++-
 drivers/net/bnxt/bnxt_ethdev.c        |  3 ++-
 drivers/net/iavf/iavf_ethdev.c        |  3 ++-
 drivers/net/iavf/iavf_ipsec_crypto.c  |  4 +++-
 drivers/net/iavf/iavf_testpmd.c       |  3 ++-
 drivers/net/nfp/nfp_ipsec.c           |  4 +++-
 drivers/net/sfc/sfc_dp.c              |  5 +++--
 drivers/net/virtio/virtio_rxtx.c      |  7 ++++---
 drivers/net/vmxnet3/vmxnet3_ethdev.c  |  3 ++-
 examples/bbdev_app/main.c             |  3 ++-
 examples/rxtx_callbacks/main.c        |  3 ++-
 lib/ethdev/ethdev_driver.c            |  3 ++-
 lib/ethdev/rte_flow.c                 |  3 ++-
 lib/eventdev/rte_eventdev.c           |  3 ++-
Quoted 8 lines
 lib/mbuf/rte_mbuf_dyn.c               |  3 ++-
 lib/node/node_private.h               |  4 +++-
 lib/pdcp/rte_pdcp.c                   |  4 +++-
 lib/reorder/rte_reorder.c             |  3 ++-
 lib/ring/rte_ring.c                   |  3 ++-
 lib/security/rte_security.c           |  5 +++--
 lib/stack/rte_stack.c                 |  3 ++-
 29 files changed, 87 insertions(+), 37 deletions(-)

Thanks Tyler.
Series applied.

Signature · 1 line
David Marchand