From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C72CE8032 for ; Thu, 4 Dec 2014 11:28:40 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 04 Dec 2014 02:28:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,514,1413270000"; d="scan'208";a="642270244" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by fmsmga002.fm.intel.com with ESMTP; 04 Dec 2014 02:28:38 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 4 Dec 2014 18:28:37 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by shsmsx102.ccr.corp.intel.com ([169.254.2.216]) with mapi id 14.03.0195.001; Thu, 4 Dec 2014 18:28:36 +0800 From: "Qiu, Michael" To: Thomas Monjalon Thread-Topic: [PATCH 1/2] eal: detect endianness Thread-Index: AQHQDz/AjmPcs+k3nUirJ6Voc/wGwA== Date: Thu, 4 Dec 2014 10:28:35 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9CB38@SHSMSX101.ccr.corp.intel.com> References: <283531301.lWbIahXLyM@xps13> <1417639668-23500-2-git-send-email-thomas.monjalon@6wind.com> <533710CFB86FA344BFBF2D6802E60286C9C86D@SHSMSX101.ccr.corp.intel.com> <3580620.HEA1jLh5UM@xps13> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" , Chao Zhu Subject: Re: [dpdk-dev] [PATCH 1/2] eal: detect endianness 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: , X-List-Received-Date: Thu, 04 Dec 2014 10:28:41 -0000 On 12/4/2014 5:01 PM, Thomas Monjalon wrote:=0A= > 2014-12-04 02:28, Qiu, Michael:=0A= >> On 12/4/2014 5:26 AM, Thomas Monjalon wrote:=0A= >>> There is no standard to check endianness.=0A= >>> So we need to try different checks.=0A= >>> Previous trials were done in testpmd (see commits=0A= >>> 51f694dd40f56 and 64741f237cf29) without full success.=0A= >>> This one is not guaranteed to work everywhere so it could=0A= >>> evolve when exceptions are found.=0A= > [...]=0A= >>> #include =0A= >>> +#ifdef RTE_EXEC_ENV_BSDAPP=0A= >>> +#include =0A= >>> +#else=0A= >>> +#include =0A= >>> +#endif=0A= >>> +=0A= >>> +/*=0A= >>> + * Compile-time endianness detection=0A= >>> + */=0A= >>> +#define RTE_BIG_ENDIAN 1=0A= >>> +#define RTE_LITTLE_ENDIAN 2=0A= >>> +#if defined __BYTE_ORDER=0A= >>> +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN=0A= >>> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN=0A= >>> +#elif __BYTE_ORDER =3D=3D __LITTLE_ENDIAN=0A= >>> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN=0A= >>> +#endif /* __BYTE_ORDER */=0A= >>> +#elif defined __BYTE_ORDER__=0A= >>> +#if __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__=0A= >>> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN=0A= >>> +#elif __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__=0A= >>> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN=0A= >>> +#endif /* __BYTE_ORDER__ */=0A= >>> +#elif defined __BIG_ENDIAN__=0A= >>> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN=0A= >>> +#elif defined __LITTLE_ENDIAN__=0A= >>> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN=0A= >>> +#endif=0A= >> What do you think about :=0A= >>=0A= >> +/*=0A= >> + * Compile-time endianness detection=0A= >> + */=0A= >> +#define RTE_BIG_ENDIAN 1=0A= >> +#define RTE_LITTLE_ENDIAN 2=0A= >> +if defined __BYTE_ORDER__ /* Prefer gcc build-in macros */=0A= >> +#if __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__=0A= >> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN=0A= >> +#elif __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__=0A= >> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN=0A= >> +#endif /* __BYTE_ORDER__ */=0A= >> +#else=0A= >> +#if defined RTE_EXEC_ENV_BSDAPP=0A= >> +#include =0A= >> +#else=0A= >> +#include =0A= >> +#endif=0A= >> +#if defined __BYTE_ORDER=0A= >> +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN=0A= >> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN=0A= >> +#elif __BYTE_ORDER =3D=3D __LITTLE_ENDIAN=0A= >> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN=0A= >> +#endif /* __BYTE_ORDER */=0A= >> +#elif defined __BIG_ENDIAN__=0A= >> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN=0A= >> +#elif defined __LITTLE_ENDIAN__=0A= >> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN=0A= >> +#endif=0A= >> +#endif=0A= > Please, could you give more explanations about your proposal?=0A= > Why not always try to include endian.h?=0A= =0A= I assume that if gcc can handler why we need include that file?=0A= =0A= Also it seems that only old version could have this issue, newer=0A= versions has build in this marcos.=0A= =0A= So that's why I prefer "__BYTE_ORDER__" for high priority.=0A= =0A= Thanks,=0A= Michael=0A= > Why giving high priority to __BYTE_ORDER__?=0A= >=0A= =0A=