byteorder.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * include/asm-v850/byteorder.h -- Endian id and conversion ops
  3. *
  4. * Copyright (C) 2001 NEC Corporation
  5. * Copyright (C) 2001 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #ifndef __V850_BYTEORDER_H__
  14. #define __V850_BYTEORDER_H__
  15. #include <asm/types.h>
  16. #include <linux/compiler.h>
  17. #ifdef __GNUC__
  18. static __inline__ __attribute_const__ __u32 ___arch__swab32 (__u32 word)
  19. {
  20. __u32 res;
  21. __asm__ ("bsw %1, %0" : "=r" (res) : "r" (word));
  22. return res;
  23. }
  24. static __inline__ __attribute_const__ __u16 ___arch__swab16 (__u16 half_word)
  25. {
  26. __u16 res;
  27. __asm__ ("bsh %1, %0" : "=r" (res) : "r" (half_word));
  28. return res;
  29. }
  30. #define __arch__swab32(x) ___arch__swab32(x)
  31. #define __arch__swab16(x) ___arch__swab16(x)
  32. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  33. # define __BYTEORDER_HAS_U64__
  34. # define __SWAB_64_THRU_32__
  35. #endif
  36. #endif /* __GNUC__ */
  37. #include <linux/byteorder/little_endian.h>
  38. #endif /* __V850_BYTEORDER_H__ */