From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by dpdk.org (Postfix) with ESMTP id 5AA497E75 for ; Thu, 4 Dec 2014 13:20:14 +0100 (CET) Received: by mail-wi0-f177.google.com with SMTP id l15so27674636wiw.16 for ; Thu, 04 Dec 2014 04:20:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=GN4qOPLSnC2Gr1gBtUFElUi3KIIjnGGi5LkOgOeyBsI=; b=QZlkPWSRNAmcmYIYXhAvOZjmHfSYTG7E2HIiZ536T9Jrovn+POfKwWKAXR7BdVdSQS iqLN1nkcmkhDK42dEHrJiB5xd4P5NODO4XFWU6wjKxPTekSEDdMz9TQnxcKDj350eSoJ h9eOZbsdnhs20rKj+7x7YXn7BjagdLS8oawTmtvp1GK5cBtSx69ebDs125ZVlIuNVerj wOLGsc9jnDV+glLAwp3zX0DjU9569FMAqPzlHHBLSI1xmzUFltkdpXJK8wD6JUvfiP5l 9VEgEV3hKpiitZORXpV0tN/rpJ4+bfHk8YNewfzSLKnQD/olOJOg7Fsue0pkUwQVOLDh yp1A== X-Gm-Message-State: ALoCoQmCcwOHc4W1b8QAzgU/VOl39/8sRFQY7TajBPWM/03d5RRqKKIyZC38iU1TxBaY6/L1gn4G X-Received: by 10.180.80.194 with SMTP id t2mr110728467wix.6.1417695613755; Thu, 04 Dec 2014 04:20:13 -0800 (PST) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id ly9sm4732377wjb.24.2014.12.04.04.20.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Dec 2014 04:20:13 -0800 (PST) From: Thomas Monjalon To: "Qiu, Michael" Date: Thu, 04 Dec 2014 13:19:49 +0100 Message-ID: <1538241.xRI4LPKbTP@xps13> Organization: 6WIND User-Agent: KMail/4.14.3 (Linux/3.17.4-1-ARCH; KDE/4.14.3; x86_64; ; ) In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9CB38@SHSMSX101.ccr.corp.intel.com> References: <283531301.lWbIahXLyM@xps13> <3580620.HEA1jLh5UM@xps13> <533710CFB86FA344BFBF2D6802E60286C9CB38@SHSMSX101.ccr.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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:20:14 -0000 2014-12-04 10:28, Qiu, Michael: > On 12/4/2014 5:01 PM, Thomas Monjalon wrote: > > 2014-12-04 02:28, Qiu, Michael: > >> On 12/4/2014 5:26 AM, Thomas Monjalon wrote: > >>> There is no standard to check endianness. > >>> So we need to try different checks. > >>> Previous trials were done in testpmd (see commits > >>> 51f694dd40f56 and 64741f237cf29) without full success. > >>> This one is not guaranteed to work everywhere so it could > >>> evolve when exceptions are found. > > [...] > >>> #include > >>> +#ifdef RTE_EXEC_ENV_BSDAPP > >>> +#include > >>> +#else > >>> +#include > >>> +#endif > >>> + > >>> +/* > >>> + * Compile-time endianness detection > >>> + */ > >>> +#define RTE_BIG_ENDIAN 1 > >>> +#define RTE_LITTLE_ENDIAN 2 > >>> +#if defined __BYTE_ORDER > >>> +#if __BYTE_ORDER == __BIG_ENDIAN > >>> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN > >>> +#elif __BYTE_ORDER == __LITTLE_ENDIAN > >>> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN > >>> +#endif /* __BYTE_ORDER */ > >>> +#elif defined __BYTE_ORDER__ > >>> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ > >>> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN > >>> +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > >>> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN > >>> +#endif /* __BYTE_ORDER__ */ > >>> +#elif defined __BIG_ENDIAN__ > >>> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN > >>> +#elif defined __LITTLE_ENDIAN__ > >>> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN > >>> +#endif > >> What do you think about : > >> > >> +/* > >> + * Compile-time endianness detection > >> + */ > >> +#define RTE_BIG_ENDIAN 1 > >> +#define RTE_LITTLE_ENDIAN 2 > >> +if defined __BYTE_ORDER__ /* Prefer gcc build-in macros */ > >> +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ > >> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN > >> +#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > >> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN > >> +#endif /* __BYTE_ORDER__ */ > >> +#else > >> +#if defined RTE_EXEC_ENV_BSDAPP > >> +#include > >> +#else > >> +#include > >> +#endif > >> +#if defined __BYTE_ORDER > >> +#if __BYTE_ORDER == __BIG_ENDIAN > >> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN > >> +#elif __BYTE_ORDER == __LITTLE_ENDIAN > >> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN > >> +#endif /* __BYTE_ORDER */ > >> +#elif defined __BIG_ENDIAN__ > >> +#define RTE_BYTE_ORDER RTE_BIG_ENDIAN > >> +#elif defined __LITTLE_ENDIAN__ > >> +#define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN > >> +#endif > >> +#endif > > > > Please, could you give more explanations about your proposal? > > Why not always try to include endian.h? > > I assume that if gcc can handler why we need include that file? Separating include on top is easier to read, and I'm not sure it won't be needed for __BYTE_ORDER__ with some toolchains. > Also it seems that only old version could have this issue, newer > versions has build in this marcos. > > So that's why I prefer "__BYTE_ORDER__" for high priority. I have no problem with reversing this priority. > > Why giving high priority to __BYTE_ORDER__? Any other comment? May I apply with above change? -- Thomas