swab.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2011 Texas Instruments Incorporated
  3. * Author: Mark Salter <msalter@redhat.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef _ASM_C6X_SWAB_H
  10. #define _ASM_C6X_SWAB_H
  11. static inline __attribute_const__ __u16 __c6x_swab16(__u16 val)
  12. {
  13. asm("swap4 .l1 %0,%0\n" : "+a"(val));
  14. return val;
  15. }
  16. static inline __attribute_const__ __u32 __c6x_swab32(__u32 val)
  17. {
  18. asm("swap4 .l1 %0,%0\n"
  19. "swap2 .l1 %0,%0\n"
  20. : "+a"(val));
  21. return val;
  22. }
  23. static inline __attribute_const__ __u64 __c6x_swab64(__u64 val)
  24. {
  25. asm(" swap2 .s1 %p0,%P0\n"
  26. "|| swap2 .l1 %P0,%p0\n"
  27. " swap4 .l1 %p0,%p0\n"
  28. " swap4 .l1 %P0,%P0\n"
  29. : "+a"(val));
  30. return val;
  31. }
  32. static inline __attribute_const__ __u32 __c6x_swahw32(__u32 val)
  33. {
  34. asm("swap2 .l1 %0,%0\n" : "+a"(val));
  35. return val;
  36. }
  37. static inline __attribute_const__ __u32 __c6x_swahb32(__u32 val)
  38. {
  39. asm("swap4 .l1 %0,%0\n" : "+a"(val));
  40. return val;
  41. }
  42. #define __arch_swab16 __c6x_swab16
  43. #define __arch_swab32 __c6x_swab32
  44. #define __arch_swab64 __c6x_swab64
  45. #define __arch_swahw32 __c6x_swahw32
  46. #define __arch_swahb32 __c6x_swahb32
  47. #endif /* _ASM_C6X_SWAB_H */