007-endianness-check.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. diff -Nur busybox-1.17.2.orig/include/platform.h busybox-1.17.2/include/platform.h
  2. --- busybox-1.17.2.orig/include/platform.h 2010-08-23 02:44:35.000000000 +0200
  3. +++ busybox-1.17.2/include/platform.h 2010-09-28 15:20:33.000000000 +0200
  4. @@ -152,27 +152,37 @@
  5. #if defined(__digital__) && defined(__unix__)
  6. # include <sex.h>
  7. -# define __BIG_ENDIAN__ (BYTE_ORDER == BIG_ENDIAN)
  8. -# define __BYTE_ORDER BYTE_ORDER
  9. -#elif defined __FreeBSD__
  10. +#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
  11. + || defined(__APPLE__)
  12. # include <sys/resource.h> /* rlimit */
  13. # include <machine/endian.h>
  14. # define bswap_64 __bswap64
  15. # define bswap_32 __bswap32
  16. # define bswap_16 __bswap16
  17. -# define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN)
  18. -#elif !defined __APPLE__
  19. +#else
  20. # include <byteswap.h>
  21. # include <endian.h>
  22. #endif
  23. -#if defined(__BIG_ENDIAN__) && __BIG_ENDIAN__
  24. +#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
  25. # define BB_BIG_ENDIAN 1
  26. # define BB_LITTLE_ENDIAN 0
  27. -#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
  28. +#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
  29. +# define BB_BIG_ENDIAN 0
  30. +# define BB_LITTLE_ENDIAN 1
  31. +#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN
  32. # define BB_BIG_ENDIAN 1
  33. # define BB_LITTLE_ENDIAN 0
  34. -#elif (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__386__)
  35. +#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN
  36. +# define BB_BIG_ENDIAN 0
  37. +# define BB_LITTLE_ENDIAN 1
  38. +#elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
  39. +# define BB_BIG_ENDIAN 1
  40. +# define BB_LITTLE_ENDIAN 0
  41. +#elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
  42. +# define BB_BIG_ENDIAN 0
  43. +# define BB_LITTLE_ENDIAN 1
  44. +#elif defined(__386__)
  45. # define BB_BIG_ENDIAN 0
  46. # define BB_LITTLE_ENDIAN 1
  47. #else