swab.h 807 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (C) 2005-2017 Andes Technology Corporation
  3. #ifndef __NDS32_SWAB_H__
  4. #define __NDS32_SWAB_H__
  5. #include <linux/types.h>
  6. #include <linux/compiler.h>
  7. static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
  8. {
  9. __asm__("wsbh %0, %0\n\t" /* word swap byte within halfword */
  10. "rotri %0, %0, #16\n"
  11. :"=r"(x)
  12. :"0"(x));
  13. return x;
  14. }
  15. static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
  16. {
  17. __asm__("wsbh %0, %0\n" /* word swap byte within halfword */
  18. :"=r"(x)
  19. :"0"(x));
  20. return x;
  21. }
  22. #define __arch_swab32(x) ___arch__swab32(x)
  23. #define __arch_swab16(x) ___arch__swab16(x)
  24. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  25. #define __BYTEORDER_HAS_U64__
  26. #define __SWAB_64_THRU_32__
  27. #endif
  28. #endif /* __NDS32_SWAB_H__ */