From patchwork Fri Nov 18 18:47:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Horman X-Patchwork-Id: 17095 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4F011558A; Fri, 18 Nov 2016 19:48:26 +0100 (CET) Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 3C77B37B3 for ; Fri, 18 Nov 2016 19:48:24 +0100 (CET) Received: from cpe-2606-a000-111b-40ed-7aac-c0ff-fec2-933b.dyn6.twc.com ([2606:a000:111b:40ed:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1c7oCp-0002YV-7Q; Fri, 18 Nov 2016 13:48:16 -0500 From: Neil Horman To: dev@dpdk.org Cc: Neil Horman , Hemant Agrawal , Jerin Jacob , Bruce Richardson , Thomas Monjalon Date: Fri, 18 Nov 2016 13:47:52 -0500 Message-Id: <1479494872-9302-1-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 2.7.4 X-Spam-Score: -2.9 (--) X-Spam-Status: No Subject: [dpdk-dev] [PATCH] pmdinfogen: Fix pmdinfogen to select proper endianess on cross-compile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" pmdinfogen has a bug in which, during build, it pulls in rte_byteorder.h to obtain the rte macros for byteswapping between the cpu byte order and big or little endian. Unfortunately, pmdinfogen is a tool that is only meant to be run during the build of dpdk components, and so, it runs on the host. In cross compile environments however, the rte_byteorder.h is configured using a target cpu, who's endianess may differ from that of the host, leading to improper swapping. The fix is to use host system defined byte swapping routines rather than the dpdk provided routines. Note that we are using non posix compliant routines, as the posix compliant api only addresses 16 and 32 bit swaps, and we also need 64 bit swaps. Those macros exist (via endian.h), but BSD and Linux put that header in different locations so some ifdeffery is required. Tested successfully by myself on Linux and BSD systems. Signed-off-by: Neil Horman CC: Hemant Agrawal CC: Jerin Jacob CC: Bruce Richardson CC: Thomas Monjalon Tested-by: Bruce Richardson --- buildtools/pmdinfogen/pmdinfogen.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/buildtools/pmdinfogen/pmdinfogen.h b/buildtools/pmdinfogen/pmdinfogen.h index 1da2966..7c787c1 100644 --- a/buildtools/pmdinfogen/pmdinfogen.h +++ b/buildtools/pmdinfogen/pmdinfogen.h @@ -16,12 +16,16 @@ #include #include #include +#ifdef __linux__ +#include +#else +#include +#endif #include #include #include #include #include -#include /* On BSD-alike OSes elf.h defines these according to host's word size */ #undef ELF_ST_BIND @@ -75,9 +79,9 @@ #define CONVERT_NATIVE(fend, width, x) ({ \ typeof(x) ___x; \ if ((fend) == ELFDATA2LSB) \ - ___x = rte_le_to_cpu_##width(x); \ + ___x = le##width##toh(x); \ else \ - ___x = rte_be_to_cpu_##width(x); \ + ___x = be##width##toh(x); \ ___x; \ })