[v6,09/30] drivers/compress: replace packed attributes

Message ID 1732668761-5556-10-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>
---
 drivers/compress/qat/qat_comp.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Tyler Retzlaff Dec. 5, 2024, 12:26 a.m. UTC | #1
On Tue, Nov 26, 2024 at 04:52:20PM -0800, Andre Muezerie wrote:
> 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>
> ---

Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  

Patch

diff --git a/drivers/compress/qat/qat_comp.h b/drivers/compress/qat/qat_comp.h
index 1da4770b1c..90231ad42a 100644
--- a/drivers/compress/qat/qat_comp.h
+++ b/drivers/compress/qat/qat_comp.h
@@ -50,10 +50,10 @@  struct array_of_ptrs {
 	phys_addr_t pointer[0];
 };
 
-struct __rte_cache_aligned qat_inter_sgl {
+__rte_packed_begin struct __rte_cache_aligned qat_inter_sgl {
 	qat_sgl_hdr;
 	struct qat_flat_buf buffers[QAT_NUM_BUFS_IN_IM_SGL];
-} __rte_packed;
+} __rte_packed_end;
 
 
 struct qat_comp_op_cookie {