byteorder.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __ASM_SH64_BYTEORDER_H
  2. #define __ASM_SH64_BYTEORDER_H
  3. /*
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * include/asm-sh64/byteorder.h
  9. *
  10. * Copyright (C) 2000, 2001 Paolo Alberelli
  11. *
  12. */
  13. #include <asm/types.h>
  14. static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
  15. {
  16. __asm__("byterev %0, %0\n\t"
  17. "shari %0, 32, %0"
  18. : "=r" (x)
  19. : "0" (x));
  20. return x;
  21. }
  22. static inline __attribute_const__ __u16 ___arch__swab16(__u16 x)
  23. {
  24. __asm__("byterev %0, %0\n\t"
  25. "shari %0, 48, %0"
  26. : "=r" (x)
  27. : "0" (x));
  28. return x;
  29. }
  30. #define __arch__swab32(x) ___arch__swab32(x)
  31. #define __arch__swab16(x) ___arch__swab16(x)
  32. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  33. # define __BYTEORDER_HAS_U64__
  34. # define __SWAB_64_THRU_32__
  35. #endif
  36. #ifdef __LITTLE_ENDIAN__
  37. #include <linux/byteorder/little_endian.h>
  38. #else
  39. #include <linux/byteorder/big_endian.h>
  40. #endif
  41. #endif /* __ASM_SH64_BYTEORDER_H */