swab.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _BLACKFIN_SWAB_H
  2. #define _BLACKFIN_SWAB_H
  3. #include <asm/types.h>
  4. #include <linux/compiler.h>
  5. #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  6. # define __SWAB_64_THRU_32__
  7. #endif
  8. #ifdef __GNUC__
  9. static __inline__ __attribute_const__ __u32 __arch_swahb32(__u32 xx)
  10. {
  11. __u32 tmp;
  12. __asm__("%1 = %0 >> 8 (V);\n\t"
  13. "%0 = %0 << 8 (V);\n\t"
  14. "%0 = %0 | %1;\n\t"
  15. : "+d"(xx), "=&d"(tmp));
  16. return xx;
  17. }
  18. #define __arch_swahb32 __arch_swahb32
  19. static __inline__ __attribute_const__ __u32 __arch_swahw32(__u32 xx)
  20. {
  21. __u32 rv;
  22. __asm__("%0 = PACK(%1.L, %1.H);\n\t": "=d"(rv): "d"(xx));
  23. return rv;
  24. }
  25. #define __arch_swahw32 __arch_swahw32
  26. static __inline__ __attribute_const__ __u32 __arch_swab32(__u32 xx)
  27. {
  28. return __arch_swahb32(__arch_swahw32(xx));
  29. }
  30. #define __arch_swab32 __arch_swab32
  31. static __inline__ __attribute_const__ __u16 __arch_swab16(__u16 xx)
  32. {
  33. __u32 xw = xx;
  34. __asm__("%0 <<= 8;\n %0.L = %0.L + %0.H (NS);\n": "+d"(xw));
  35. return (__u16)xw;
  36. }
  37. #define __arch_swab16 __arch_swab16
  38. #endif /* __GNUC__ */
  39. #endif /* _BLACKFIN_SWAB_H */