[v6,18/30] examples/common: replace packed attributes

Message ID 1732668761-5556-19-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers
Series fix packing of structs when building with MSVC |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Andre Muezerie Nov. 27, 2024, 12:52 a.m. UTC
MSVC struct packing is not compatible with GCC. Replace macro
__rte_packed with __rte_packed_begin to push existing pack value
and set packing to 1-byte and macro __rte_packed_end to restore
the pack value prior to the push.

Macro __rte_packed_end is deliberately utilized to trigger a
MSVC compiler warning if no existing packing has been pushed allowing
easy identification of locations where the __rte_packed_begin is
missing.

Added parenthesis around *pnum in line
__ rte_packed_end (*pnum) = (void *)pn;
to avoid patch check error below:

ERROR:SPACING: need consistent spacing around '*' (ctx:WxV)
34: FILE: examples/common/neon/port_group.h:27:
+	} __ rte_packed_end *pnum = (void *)pn;

With the parenthesis it becomes a warning, still not ideal, but better
Running checkpatch.pl:
WARNING:SPACING: space prohibited between function name and open
parenthesis '('
34: FILE: examples/common/neon/port_group.h:27:
+	} __ rte_packed_end (*pnum) = (void *)pn;

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 examples/common/neon/port_group.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/examples/common/neon/port_group.h b/examples/common/neon/port_group.h
index 421e2e8613..0c8ea4c085 100644
--- a/examples/common/neon/port_group.h
+++ b/examples/common/neon/port_group.h
@@ -21,10 +21,10 @@  static inline uint16_t *
 port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1,
 		  uint16x8_t dp2)
 {
-	union {
+	__rte_packed_begin union {
 		uint16_t u16[FWDSTEP + 1];
 		uint64_t u64;
-	} __rte_packed *pnum = (void *)pn;
+	} __rte_packed_end (*pnum) = (void *)pn;
 
 	uint16x8_t mask = {1, 2, 4, 8, 0, 0, 0, 0};
 	int32_t v;