dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: "Qiu, Michael" <michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org,
	Chao Zhu
	<chaozhu-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Subject: Re: [PATCH 1/2] eal: detect endianness
Date: Thu, 04 Dec 2014 13:19:49 +0100	[thread overview]
Message-ID: <1538241.xRI4LPKbTP@xps13> (raw)
In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9CB38-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

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 <stdint.h>
> >>> +#ifdef RTE_EXEC_ENV_BSDAPP
> >>> +#include <sys/endian.h>
> >>> +#else
> >>> +#include <endian.h>
> >>> +#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 <sys/endian.h>
> >> +#else
> >> +#include <endian.h>
> >> +#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

  parent reply	other threads:[~2014-12-04 12:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1417606044-3432-1-git-send-email-michael.qiu@intel.com>
     [not found] ` <1417606099-3489-1-git-send-email-michael.qiu@intel.com>
     [not found]   ` <1417606099-3489-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-12-03 11:42     ` [PATCH] test-pmd: Fix pointer aliasing error Bruce Richardson
2014-12-03 13:59       ` Qiu, Michael
     [not found]         ` <533710CFB86FA344BFBF2D6802E60286C9C531-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-03 14:51           ` Bruce Richardson
2014-12-03 15:19             ` Qiu, Michael
     [not found]               ` <533710CFB86FA344BFBF2D6802E60286C9C5BA-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-03 15:36                 ` Bruce Richardson
2014-12-04  2:38                   ` Qiu, Michael
     [not found]                     ` <533710CFB86FA344BFBF2D6802E60286C9C893-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-04  3:28                       ` [PATCH v2] " Michael Qiu
     [not found]                         ` <1417663711-19576-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-12-04  4:16                           ` [PATCH v3] " Michael Qiu
2014-12-05  5:34                             ` Qiu, Michael
     [not found]                               ` <533710CFB86FA344BFBF2D6802E60286C9CFE5-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-05  9:24                                 ` Thomas Monjalon
2014-12-08  1:28                                   ` Qiu, Michael
2014-12-08  1:30                             ` Qiu, Michael
2014-12-10  3:44                               ` Qiu, Michael
     [not found]                               ` <533710CFB86FA344BFBF2D6802E60286C9D683-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-11  0:54                                 ` Thomas Monjalon
2014-12-11 17:51                                   ` r k
2014-12-12  6:49                                     ` Qiu, Michael
2014-12-04 12:54                           ` [PATCH v2] " Ananyev, Konstantin
2014-12-03 15:24       ` [PATCH] " Olivier MATZ
     [not found]         ` <547F2B37.5060500-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-03 16:03           ` Dayu Qiu
2014-12-03 15:57       ` Dayu Qiu
2014-12-03 16:26 ` [PATCH] test-pmd: Fix "__BYTE_ORDER__" not defined error Qiu, Michael
     [not found]   ` <533710CFB86FA344BFBF2D6802E60286C9C636-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-03 19:59     ` Thomas Monjalon
2014-12-03 20:47       ` [PATCH 0/2] fix endianness in EAL Thomas Monjalon
     [not found]         ` <1417639668-23500-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-03 20:47           ` [PATCH 1/2] eal: detect endianness Thomas Monjalon
2014-12-04  2:28             ` Qiu, Michael
     [not found]               ` <533710CFB86FA344BFBF2D6802E60286C9C86D-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-04  9:00                 ` Thomas Monjalon
2014-12-04 10:28                   ` Qiu, Michael
     [not found]                     ` <533710CFB86FA344BFBF2D6802E60286C9CB38-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-12-04 12:19                       ` Thomas Monjalon [this message]
2014-12-04 12:50                         ` Qiu, Michael
2014-12-03 20:47           ` [PATCH 2/2] app/testpmd: fix endianness detection Thomas Monjalon
2014-12-04  9:28           ` [PATCH 0/2] fix endianness in EAL Chao Zhu
     [not found]             ` <54802955.2090104-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2014-12-05 16:01               ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1538241.xRI4LPKbTP@xps13 \
    --to=thomas.monjalon-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=chaozhu-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).