[PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines

Sascha Hauer s.hauer at pengutronix.de
Fri Jun 29 05:13:49 EDT 2012


On Fri, Jun 29, 2012 at 12:48:23PM +0400, Antony Pavlov wrote:
> On 29 June 2012 11:25, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> >
> > In file included from common/environment.c:37:
> > include/envfs.h:41:21: warning: "__LITTLE_ENDIAN" is not defined
> 
> You are right.
> 
> >> +
> >> +#ifdef __LITTLE_ENDIAN
> >
> > As said, this file is included from scripts/bareboxenv.c which is
> > compiled for userspace. __LITTLE_ENDIAN will always be defined in
> > userspace.
> 
> But it included from common/environment.c too!

That's why I have the following:

#ifdef __BAREBOX__
#  ifdef __LITTLE_ENDIAN
#    define ENVFS_ORDER_LITTLE
#  elif defined __BIG_ENDIAN
#    define ENVFS_ORDER_BIG
#  else
#    error "could not determine byte order"
#  endif
#else
#  if __BYTE_ORDER == __LITTLE_ENDIAN
#    define ENVFS_ORDER_LITTLE
#  elif __BYTE_ORDER == __BIG_ENDIAN
#    define ENVFS_ORDER_BIG
#  else
#    error "could not determine byte order"
#  endif
#endif

This should work as expected. Maybe the name ENVFS_ORDER_LITTLE and
ENVFS_ORDER_BIG are a bit confusing, should probably better ENVFS_ORDER_NATIVE
and ENVFS_ORDER_SWAP.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list