From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by dpdk.org (Postfix) with ESMTP id 1D1B77E75 for ; Thu, 4 Dec 2014 10:00:34 +0100 (CET) Received: by mail-wi0-f171.google.com with SMTP id bs8so33952846wib.10 for ; Thu, 04 Dec 2014 01:00:33 -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=RlcJz3y6bxxfRvzUajvvp+TntI0wq2okoy0uYWcEqKs=; b=gdVathoTfe6zLwNRbrHt7mw3T3amaIx3NfbogutJS/qJNaZz4E/2Avb91j7WBBUPZp 9cMTjn+w5Z29Dc2RES03Bp0Ky9k8wa/4LYMLFiyKVE4i1tff7thsPYfaDS6GWJpc5+ne UESdS2gr+Hw+9xq9tPnuzRpuLgx13FHzJWeCxDWBvHl52ezwtufRQBmSBKUM364JLFhR 2Pr7YgXYmNYSwg4EUDiCaXr4kcBtMUuXpVV2SuBmq21ywQI/I8JG07zPZAADEbfk1Pe6 B2KdfYqW33udRODo95ggU9PIEgkdki/4YYs0AYPAsykcP2nTQM+qTE1dJAcpFpJTr8l/ lBHA== X-Gm-Message-State: ALoCoQnzJILqcKralGUEn5SUwqgGZtB9FmqGiluZfsxAe8HjeEKsYjHr/0ibNWzUOBs0D9xc5w5t X-Received: by 10.180.99.1 with SMTP id em1mr19889316wib.29.1417683633700; Thu, 04 Dec 2014 01:00:33 -0800 (PST) Received: from xps13.localnet (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id h8sm40422719wiy.17.2014.12.04.01.00.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Dec 2014 01:00:33 -0800 (PST) From: Thomas Monjalon To: "Qiu, Michael" Date: Thu, 04 Dec 2014 10:00:09 +0100 Message-ID: <3580620.HEA1jLh5UM@xps13> Organization: 6WIND User-Agent: KMail/4.14.3 (Linux/3.17.4-1-ARCH; KDE/4.14.3; x86_64; ; ) In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9C86D@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> 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 09:00:34 -0000 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? Why giving high priority to __BYTE_ORDER__? -- Thomas