Message ID | 1732668761-5556-3-git-send-email-andremue@linux.microsoft.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | David Marchand |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F8D745D31; Wed, 27 Nov 2024 01:53:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0003A427C3; Wed, 27 Nov 2024 01:53:06 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id ECE82402E0 for <dev@dpdk.org>; Wed, 27 Nov 2024 01:53:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 22DA820545B7; Tue, 26 Nov 2024 16:53:02 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 22DA820545B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1732668782; bh=ZCU1KydXC22LyTJuY6NcSUFqZsZaY8RbOp6LEyJoulY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YDD7uZs9rd5xfeMhUmmSqB+ayEUbE38H8P2Ep53OCJfRH9aj5FCkfmzGAmVkwVgFD /UO6JsrDzGdoYuAMygG02dBWdWOPWIdtnGclAevXnQwKyNWO4vMEOB8vmh7m6+UjoU lbDuZ66RU9s1H3wqU9dyyzzzel7jI6I9XEntS3MQ= From: Andre Muezerie <andremue@linux.microsoft.com> To: roretzla@linux.microsoft.com Cc: aman.deep.singh@intel.com, anatoly.burakov@intel.com, bruce.richardson@intel.com, byron.marohn@intel.com, conor.walsh@intel.com, cristian.dumitrescu@intel.com, david.hunt@intel.com, dev@dpdk.org, dsosnowski@nvidia.com, gakhil@marvell.com, jerinj@marvell.com, jingjing.wu@intel.com, kirill.rybalchenko@intel.com, konstantin.v.ananyev@yandex.ru, matan@nvidia.com, orika@nvidia.com, radu.nicolau@intel.com, ruifeng.wang@arm.com, sameh.gobriel@intel.com, sivaprasad.tummala@amd.com, skori@marvell.com, stephen@networkplumber.org, suanmingm@nvidia.com, vattunuru@marvell.com, viacheslavo@nvidia.com, vladimir.medvedkin@intel.com, yipeng1.wang@intel.com, Andre Muezerie <andremue@linux.microsoft.com> Subject: [PATCH v6 02/30] eal/include: add new packing macros Date: Tue, 26 Nov 2024 16:52:13 -0800 Message-Id: <1732668761-5556-3-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1732668761-5556-1-git-send-email-andremue@linux.microsoft.com> References: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> <1732668761-5556-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
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. Add macro
__rte_packed_begin which can be used to push existing pack value
and set packing to 1-byte. Add 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.
Macro __rte_packed will be removed in a subsequent patch.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/eal/include/rte_common.h | 11 +++++++++++
1 file changed, 11 insertions(+)
Comments
On Tue, Nov 26, 2024 at 04:52:13PM -0800, Andre Muezerie wrote: > MSVC struct packing is not compatible with GCC. Add macro > __rte_packed_begin which can be used to push existing pack value > and set packing to 1-byte. Add 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. > > Macro __rte_packed will be removed in a subsequent patch. > > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com> > --- Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 4d299f2b36..affdcaf3c1 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -108,6 +108,17 @@ typedef uint16_t unaligned_uint16_t; #define __rte_packed __attribute__((__packed__)) #endif +/** + * Force a structure to be packed + */ +#ifdef RTE_TOOLCHAIN_MSVC +#define __rte_packed_begin __pragma(pack(push, 1)) +#define __rte_packed_end __pragma(pack(pop)) +#else +#define __rte_packed_begin +#define __rte_packed_end __attribute__((__packed__)) +#endif + /** * Macro to mark a type that is not subject to type-based aliasing rules */