swab.h 977 B

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