14-endianness-detection.patch 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. Author: Guy Martin <gmsoft@gentoo.org>
  2. Description: This patch make the check for endianness actually occur.
  3. Bug-Gentoo: https://bugs.gentoo.org/show_bug.cgi?id=222301
  4. Origin: https://bugs.gentoo.org/attachment.cgi?id=241251
  5. --- a/source/base/all/all.h
  6. +++ b/source/base/all/all.h
  7. @@ -61,7 +61,8 @@ memmove((ptr), &__tmp, sizeof(*(ptr)));
  8. #define put_unaligned(ptr, val) ((void)( *(ptr) = (val) ))
  9. #endif /* __EMULATE_UNALIGNED__ */
  10. -#ifdef __BIG_ENDIAN__
  11. +#include <endian.h>
  12. +#if __BYTE_ORDER == __BIG_ENDIAN
  13. #define ADJUST_ENDIANNESS16(Ptr) {\
  14. USHORT x = get_unaligned((USHORT*) (Ptr));\
  15. put_unaligned((USHORT*) (Ptr), x >> 8 | x << 8);\
  16. @@ -78,10 +79,12 @@ memmove((ptr), &__tmp, sizeof(*(ptr)));
  17. x2 = x2 >> 16 | x2 << 16;\
  18. put_unaligned(((ULONG*) (Ptr)), (x2&0xff00ff00) >> 8 | (x2&0x00ff00ff) << 8);\
  19. }
  20. -#else
  21. +#elif __BYTE_ORDER == __LITTLE_ENDIAN
  22. #define ADJUST_ENDIANNESS16(Ptr)
  23. #define ADJUST_ENDIANNESS32(Ptr)
  24. #define ADJUST_ENDIANNESS64(Ptr)
  25. +#else
  26. +#error Please define system endianness
  27. #endif
  28. #endif