[v6,24/30] examples/vhost_blk: replace packed attributes

Message ID 1732668761-5556-25-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 success coding style OK

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.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 examples/vhost_blk/blk_spec.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/examples/vhost_blk/blk_spec.h b/examples/vhost_blk/blk_spec.h
index 3c54f70eaf..6c6a36d471 100644
--- a/examples/vhost_blk/blk_spec.h
+++ b/examples/vhost_blk/blk_spec.h
@@ -73,6 +73,7 @@  struct vhost_memory_padded {
 	struct vhost_memory_region regions[VHOST_USER_MEMORY_MAX_NREGIONS];
 };
 
+__rte_packed_begin
 struct vhost_user_msg {
 	enum vhost_user_request request;
 
@@ -89,6 +90,6 @@  struct vhost_user_msg {
 		struct vhost_memory_padded memory;
 		struct vhost_user_config cfg;
 	} payload;
-} __rte_packed;
+} __rte_packed_end;
 
 #endif