byteorder.h 855 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifdef CONFIG_X86_BSWAP
  8. __asm__("bswap %0" : "=r" (x) : "0" (x));
  9. #else
  10. __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
  11. "rorl $16,%0\n\t" /* swap words */
  12. "xchgb %b0,%h0" /* swap higher bytes */
  13. :"=q" (x)
  14. : "0" (x));
  15. #endif
  16. return x;
  17. }
  18. static __inline__ __u16 ___arch__swab16(__u16 x)
  19. {
  20. __asm__("xchgb %b0,%h0" /* swap bytes */ \
  21. : "=q" (x) \
  22. : "0" (x)); \
  23. return x;
  24. }
  25. #define __arch__swab32(x) ___arch__swab32(x)
  26. #define __arch__swab16(x) ___arch__swab16(x)
  27. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  28. # define __BYTEORDER_HAS_U64__
  29. # define __SWAB_64_THRU_32__
  30. #endif
  31. #endif /* __GNUC__ */
  32. #include <linux/byteorder/little_endian.h>
  33. #endif /* _I386_BYTEORDER_H */