From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id DFA0E8032 for ; Thu, 4 Dec 2014 13:50:49 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 04 Dec 2014 04:50:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,515,1413270000"; d="scan'208";a="618544356" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga001.jf.intel.com with ESMTP; 04 Dec 2014 04:50:24 -0800 Received: from pgsmsx101.gar.corp.intel.com (10.221.44.78) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 4 Dec 2014 20:50:13 +0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 4 Dec 2014 20:50:12 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0195.001; Thu, 4 Dec 2014 20:50:06 +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 12:50:04 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9CC54@SHSMSX101.ccr.corp.intel.com> References: <283531301.lWbIahXLyM@xps13> <3580620.HEA1jLh5UM@xps13> <533710CFB86FA344BFBF2D6802E60286C9CB38@SHSMSX101.ccr.corp.intel.com> <1538241.xRI4LPKbTP@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 12:50:50 -0000 On 12/4/2014 8:20 PM, Thomas Monjalon wrote:=0A= > 2014-12-04 10:28, Qiu, Michael:=0A= >> 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= >> I assume that if gcc can handler why we need include that file?=0A= > Separating include on top is easier to read, and I'm not sure it won't=0A= > be needed for __BYTE_ORDER__ with some toolchains.=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= > I have no problem with reversing this priority.=0A= >=0A= >>> Why giving high priority to __BYTE_ORDER__?=0A= > Any other comment? May I apply with above change?=0A= =0A= Acked-by: Michael Qiu =0A= =0A= =0A= =0A=