swab.h 995 B

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