 Chromium Code Reviews
 Chromium Code Reviews| Index: src/ots.cc | 
| =================================================================== | 
| --- src/ots.cc (revision 88) | 
| +++ src/ots.cc (working copy) | 
| @@ -83,10 +83,36 @@ | 
| // Use a macro instead of a function because gcc 4.4.3 creates static | 
| // initializers in that case. | 
| -#if defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) | 
| -#define TAG(d, c, b, a) (a | (b << 8) | (c << 16) | (d << 24)) | 
| -#else | 
| -#define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) | 
| +// Try endianness checks with zero, one and two leading underscores, | 
| 
Yusuke Sato
2012/05/01 02:23:31
The #ifdefs look too complex to me. What about rev
 
bashi
2012/05/01 04:05:49
Done. Thank you for suggestion!
 | 
| +// as the symbols actually defined seem to vary between systems. (Sigh.) | 
| +#if defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) && defined(BYTE_ORDER) | 
| +# if BYTE_ORDER == BIG_ENDIAN | 
| +# define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d) | 
| +# elif BYTE_ORDER == LITTLE_ENDIAN | 
| +# define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) | 
| +# else | 
| +# error "unsupported byte order!" | 
| +# endif | 
| +#elif defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) && defined(_BYTE_ORDER) | 
| +# if _BYTE_ORDER == _BIG_ENDIAN | 
| +# define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d) | 
| +# elif _BYTE_ORDER == _LITTLE_ENDIAN | 
| +# define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) | 
| +# else | 
| +# error "unsupported byte order!" | 
| +# endif | 
| +#elif defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) && defined(__BYTE_ORDER) | 
| +# if __BYTE_ORDER == __BIG_ENDIAN | 
| +# define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d) | 
| +# elif __BYTE_ORDER == __LITTLE_ENDIAN | 
| +# define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) | 
| +# else | 
| +# error "unsupported byte order!" | 
| +# endif | 
| +#elif defined(__BIG_ENDIAN__) | 
| +# define TAG(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d) | 
| +#else // fall back to assuming little-endian | 
| +# define TAG(a, b, c, d) (a | (b << 8) | (c << 16) | (d << 24)) | 
| #endif | 
| const struct { |