From patchwork Wed Mar 20 21:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 138626 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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 D996543D0A; Wed, 20 Mar 2024 22:06:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89A6540A6F; Wed, 20 Mar 2024 22:06:14 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A9C8C40A6F for ; Wed, 20 Mar 2024 22:06:13 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id E9E9E20B74C1; Wed, 20 Mar 2024 14:06:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E9E9E20B74C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1710968772; bh=Voq+F+SyxuZBC+ZYqhgF2Bm6b+40Msje8TCyGJ0TmoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LOj25S8Wgdx7xA3pI3/hEdO0qGkrZARu7nq276f4U7ElbToxForSsKCXIbAoS0kR/ vktifxvuJlC43TRdK4cirjQJ3sFlrPMQVVZX46PK89IhSzDbHOz9wmIG9ydt9KLZwC gzuZexmY0vFeErkEV7B+jjWuntPlodODxvcq5iwA= From: Tyler Retzlaff To: dev@dpdk.org Cc: Akhil Goyal , Aman Singh , Anatoly Burakov , Bruce Richardson , Byron Marohn , Conor Walsh , Cristian Dumitrescu , Dariusz Sosnowski , David Hunt , Jerin Jacob , Jingjing Wu , Kirill Rybalchenko , Konstantin Ananyev , Matan Azrad , Ori Kam , Radu Nicolau , Ruifeng Wang , Sameh Gobriel , Sivaprasad Tummala , Suanming Mou , Sunil Kumar Kori , Vamsi Attunuru , Viacheslav Ovsiienko , Vladimir Medvedkin , Yipeng Wang , Yuying Zhang , Tyler Retzlaff Subject: [PATCH 01/15] eal: provide pack start macro for MSVC Date: Wed, 20 Mar 2024 14:05:57 -0700 Message-Id: <1710968771-16435-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> References: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org MSVC struct packing is not compatible with GCC provide a macro that can be used to push existing pack value and sets packing to 1-byte. The existing __rte_packed macro is then used to restore the pack value prior to the push. Instead of providing macros exclusively for MSVC and for GCC the existing macro is deliberately utilized to trigger a warning if no existing packing has been pushed allowing easy identification of locations where the __rte_msvc_pack is missing. Signed-off-by: Tyler Retzlaff --- lib/eal/include/rte_common.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 298a5c6..44825ed 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -97,8 +97,10 @@ * Force a structure to be packed */ #ifdef RTE_TOOLCHAIN_MSVC -#define __rte_packed +#define __rte_msvc_pack __pragma(pack(push, 1)) +#define __rte_packed __pragma(pack(pop)) #else +#define __rte_msvc_pack #define __rte_packed __attribute__((__packed__)) #endif