1
0

byteswap.h 584 B

123456789101112131415161718
  1. #if defined(__linux__) || defined(__CYGWIN__)
  2. #include_next <byteswap.h>
  3. #else
  4. static inline unsigned short bswap_16(unsigned short val)
  5. {
  6. return ((val & 0xff) << 8) | ((val >> 8) & 0xff);
  7. }
  8. static inline unsigned long bswap_32(unsigned long val)
  9. {
  10. return bswap_16((unsigned short)val) << 16 |
  11. bswap_16((unsigned short)(val >> 16));
  12. }
  13. static inline unsigned long long bswap_64(unsigned long long val)
  14. {
  15. return ((((unsigned long long)bswap_32(val)) << 32) |
  16. (((unsigned long long)bswap_32(val >> 32)) & 0xffffffffULL));
  17. }
  18. #endif