swab.h 932 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (C) 2012 Tobias Klauser <tklauser@distanz.ch>
  3. * Copyright (C) 2011 Pyramid Technical Consultants, Inc.
  4. *
  5. * This file is subject to the terms and conditions of the GNU General
  6. * Public License. See the file COPYING in the main directory of this
  7. * archive for more details.
  8. */
  9. #ifndef _ASM_NIOS2_SWAB_H
  10. #define _ASM_NIOS2_SWAB_H
  11. #include <linux/types.h>
  12. #include <asm-generic/swab.h>
  13. #ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT
  14. #ifdef __GNUC__
  15. #define __nios2_swab(x) \
  16. __builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x))
  17. static inline __attribute__((const)) __u16 __arch_swab16(__u16 x)
  18. {
  19. return (__u16) __nios2_swab(((__u32) x) << 16);
  20. }
  21. #define __arch_swab16 __arch_swab16
  22. static inline __attribute__((const)) __u32 __arch_swab32(__u32 x)
  23. {
  24. return (__u32) __nios2_swab(x);
  25. }
  26. #define __arch_swab32 __arch_swab32
  27. #endif /* __GNUC__ */
  28. #endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */
  29. #endif /* _ASM_NIOS2_SWAB_H */