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 <andre...@linux.microsoft.com>
---
 drivers/vdpa/ifc/base/ifcvf.h | 4 ++--
 drivers/vdpa/mlx5/mlx5_vdpa.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/vdpa/ifc/base/ifcvf.h b/drivers/vdpa/ifc/base/ifcvf.h
index 04c81c8196..7be1596556 100644
--- a/drivers/vdpa/ifc/base/ifcvf.h
+++ b/drivers/vdpa/ifc/base/ifcvf.h
@@ -115,11 +115,11 @@ struct ifcvf_pci_common_cfg {
        u32 queue_used_hi;
 };
 
-struct ifcvf_net_config {
+__rte_packed_begin struct ifcvf_net_config {
        u8    mac[6];
        u16   status;
        u16   max_virtqueue_pairs;
-} __rte_packed;
+} __rte_packed_end;
 
 struct ifcvf_pci_mem_resource {
        u64      phys_addr; /**< Physical address, 0 if not resource. */
diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h
index e156520172..6f25eea641 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa.h
+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h
@@ -90,13 +90,13 @@ enum mlx5_vdpa_task_type {
 };
 
 /* Generic task information and size must be multiple of 4B. */
-struct __rte_aligned(4) mlx5_vdpa_task {
+__rte_packed_begin struct __rte_aligned(4) mlx5_vdpa_task {
        struct mlx5_vdpa_priv *priv;
        enum mlx5_vdpa_task_type type;
        RTE_ATOMIC(uint32_t) *remaining_cnt;
        RTE_ATOMIC(uint32_t) *err_cnt;
        uint32_t idx;
-} __rte_packed;
+} __rte_packed_end;
 
 /* Generic mlx5_vdpa_c_thread information. */
 struct mlx5_vdpa_c_thread {
-- 
2.34.1

Reply via email to