[v3,02/16] eal: pack structures when building with MSVC

Message ID 1713225079-17938-3-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix packing of structs when building with MSVC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff April 15, 2024, 11:51 p.m. UTC
Add __rte_msvc_pack to all __rte_packed structs to cause packing
when building with MSVC.

Remove __rte_packed where it appears natural alignment without
packing would produce the same layout or the struct is internal.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/common/eal_private.h      | 2 +-
 lib/eal/include/rte_memory.h      | 1 +
 lib/eal/include/rte_memzone.h     | 1 +
 lib/eal/include/rte_trace_point.h | 2 +-
 lib/eal/x86/include/rte_memcpy.h  | 3 +++
 5 files changed, 7 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index 71523cf..4c929fb 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -62,7 +62,7 @@  struct rte_config {
 	 * DPDK instances
 	 */
 	struct rte_mem_config *mem_config;
-} __rte_packed;
+};
 
 /**
  * Get the global configuration structure.
diff --git a/lib/eal/include/rte_memory.h b/lib/eal/include/rte_memory.h
index 842362d..73bb00d 100644
--- a/lib/eal/include/rte_memory.h
+++ b/lib/eal/include/rte_memory.h
@@ -46,6 +46,7 @@ 
 /**
  * Physical memory segment descriptor.
  */
+__rte_msvc_pack
 struct rte_memseg {
 	rte_iova_t iova;            /**< Start IO address. */
 	union {
diff --git a/lib/eal/include/rte_memzone.h b/lib/eal/include/rte_memzone.h
index 931497f..ca312c0 100644
--- a/lib/eal/include/rte_memzone.h
+++ b/lib/eal/include/rte_memzone.h
@@ -45,6 +45,7 @@ 
  * A structure describing a memzone, which is a contiguous portion of
  * physical memory identified by a name.
  */
+__rte_msvc_pack
 struct rte_memzone {
 
 #define RTE_MEMZONE_NAMESIZE 32       /**< Maximum length of memory zone name.*/
diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h
index 41e2a7f..e786ee3 100644
--- a/lib/eal/include/rte_trace_point.h
+++ b/lib/eal/include/rte_trace_point.h
@@ -297,7 +297,7 @@  struct __rte_trace_stream_header {
 	rte_uuid_t uuid;
 	uint32_t lcore_id;
 	char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
-} __rte_packed;
+};
 
 struct __rte_trace_header {
 	uint32_t offset;
diff --git a/lib/eal/x86/include/rte_memcpy.h b/lib/eal/x86/include/rte_memcpy.h
index 72a9229..fdc5df0 100644
--- a/lib/eal/x86/include/rte_memcpy.h
+++ b/lib/eal/x86/include/rte_memcpy.h
@@ -57,12 +57,15 @@ 
 	 * Use the following structs to avoid violating C standard
 	 * alignment requirements and to avoid strict aliasing bugs
 	 */
+	__rte_msvc_pack
 	struct rte_uint64_alias {
 		uint64_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint32_alias {
 		uint32_t val;
 	} __rte_packed __rte_may_alias;
+	__rte_msvc_pack
 	struct rte_uint16_alias {
 		uint16_t val;
 	} __rte_packed __rte_may_alias;