byteorder.h 860 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _I386_BYTEORDER_H
  2. #define _I386_BYTEORDER_H
  3. #include <asm/types.h>
  4. #ifdef __GNUC__
  5. static __inline__ __u32 ___arch__swab32(__u32 x)
  6. {
  7. __asm__("bswap %0" : "=r" (x) : "0" (x));
  8. return x;
  9. }
  10. #define _constant_swab16(x) ((__u16)( \
  11. (((__u16)(x) & (__u16)0x00ffU) << 8) | \
  12. (((__u16)(x) & (__u16)0xff00U) >> 8)))
  13. static __inline__ __u16 ___arch__swab16(__u16 x)
  14. {
  15. #if CONFIG_IS_ENABLED(X86_64)
  16. return _constant_swab16(x);
  17. #else
  18. __asm__("xchgb %b0,%h0" /* swap bytes */ \
  19. : "=q" (x) \
  20. : "0" (x)); \
  21. return x;
  22. #endif
  23. }
  24. #define __arch__swab32(x) ___arch__swab32(x)
  25. #define __arch__swab16(x) ___arch__swab16(x)
  26. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  27. # define __BYTEORDER_HAS_U64__
  28. # define __SWAB_64_THRU_32__
  29. #endif
  30. #endif /* __GNUC__ */
  31. #include <linux/byteorder/little_endian.h>
  32. #endif /* _I386_BYTEORDER_H */