consistency in checking for endianness?

Robert P. J. Day rpjday at mindspring.com
Fri Mar 3 20:29:33 UTC 2006


  in dicking around trying to get rid of the #include warning from
hdparm.c, i noticed that there are two approaches in checking for
endianness.

  in include/platform.h, there's a BB-specific approach defined with:

==============================
#ifndef __APPLE__
    #include <byteswap.h>
    #include <endian.h>
#endif

#ifdef __BIG_ENDIAN__
    #define BB_BIG_ENDIAN 1
#elif __BYTE_ORDER == __BIG_ENDIAN
    #define BB_BIG_ENDIAN 1
#else
    #define BB_BIG_ENDIAN 0
#endif
==============================

which i notice is used by libbb/{md5.c,sha1.c}.

  however, all the rest of the code that checks for endianness uses
some variation of either of

  #if __BYTE_ORDER == __BIG_ENDIAN
  #if __BYTE_ORDER == __LITTLE_ENDIAN

any reason for the two different techniques?  wouldn't it be cleaner
to just settle on one or the other?

rday




More information about the busybox mailing list