2
1

uClibc-0.9.31.1-add-bsd-endian-conversions.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From c6d6237819037168a6923ac080e348e54615422c Mon Sep 17 00:00:00 2001
  2. From: Vladimir Zapolskiy <vzapolskiy@gmail.com>
  3. Date: Tue, 1 Jun 2010 23:22:57 +0400
  4. Subject: [PATCH] endian.h: add BSD convertions between big/little-endian byte order
  5. This patch adds support for convertion of values between host and
  6. big-/little-endian byte order.
  7. Signed-off-by: Vladimir Zapolskiy <vzapolskiy@gmail.com>
  8. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
  9. ---
  10. include/endian.h | 38 ++++++++++++++++++++++++++++++++++++++
  11. 1 files changed, 38 insertions(+), 0 deletions(-)
  12. diff --git a/include/endian.h b/include/endian.h
  13. index 2f7bce1..0ba7384 100644
  14. --- a/include/endian.h
  15. +++ b/include/endian.h
  16. @@ -55,4 +55,42 @@
  17. # define __LONG_LONG_PAIR(HI, LO) HI, LO
  18. #endif
  19. +
  20. +#ifdef __USE_BSD
  21. +/* Conversion interfaces. */
  22. +# include <byteswap.h>
  23. +
  24. +# if __BYTE_ORDER == __LITTLE_ENDIAN
  25. +# define htobe16(x) __bswap_16 (x)
  26. +# define htole16(x) (x)
  27. +# define be16toh(x) __bswap_16 (x)
  28. +# define le16toh(x) (x)
  29. +
  30. +# define htobe32(x) __bswap_32 (x)
  31. +# define htole32(x) (x)
  32. +# define be32toh(x) __bswap_32 (x)
  33. +# define le32toh(x) (x)
  34. +
  35. +# define htobe64(x) __bswap_64 (x)
  36. +# define htole64(x) (x)
  37. +# define be64toh(x) __bswap_64 (x)
  38. +# define le64toh(x) (x)
  39. +# else
  40. +# define htobe16(x) (x)
  41. +# define htole16(x) __bswap_16 (x)
  42. +# define be16toh(x) (x)
  43. +# define le16toh(x) __bswap_16 (x)
  44. +
  45. +# define htobe32(x) (x)
  46. +# define htole32(x) __bswap_32 (x)
  47. +# define be32toh(x) (x)
  48. +# define le32toh(x) __bswap_32 (x)
  49. +
  50. +# define htobe64(x) (x)
  51. +# define htole64(x) __bswap_64 (x)
  52. +# define be64toh(x) (x)
  53. +# define le64toh(x) __bswap_64 (x)
  54. +# endif
  55. +#endif
  56. +
  57. #endif /* endian.h */
  58. --
  59. 1.7.3.4