le.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _ASM_GENERIC_BITOPS_LE_H_
  2. #define _ASM_GENERIC_BITOPS_LE_H_
  3. #include <asm/types.h>
  4. #include <asm/byteorder.h>
  5. #if defined(__LITTLE_ENDIAN)
  6. #define BITOP_LE_SWIZZLE 0
  7. static inline unsigned long find_next_zero_bit_le(const void *addr,
  8. unsigned long size, unsigned long offset)
  9. {
  10. return find_next_zero_bit(addr, size, offset);
  11. }
  12. static inline unsigned long find_next_bit_le(const void *addr,
  13. unsigned long size, unsigned long offset)
  14. {
  15. return find_next_bit(addr, size, offset);
  16. }
  17. static inline unsigned long find_first_zero_bit_le(const void *addr,
  18. unsigned long size)
  19. {
  20. return find_first_zero_bit(addr, size);
  21. }
  22. #elif defined(__BIG_ENDIAN)
  23. #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
  24. #ifndef find_next_zero_bit_le
  25. extern unsigned long find_next_zero_bit_le(const void *addr,
  26. unsigned long size, unsigned long offset);
  27. #endif
  28. #ifndef find_next_bit_le
  29. extern unsigned long find_next_bit_le(const void *addr,
  30. unsigned long size, unsigned long offset);
  31. #endif
  32. #ifndef find_first_zero_bit_le
  33. #define find_first_zero_bit_le(addr, size) \
  34. find_next_zero_bit_le((addr), (size), 0)
  35. #endif
  36. #else
  37. #error "Please fix <asm/byteorder.h>"
  38. #endif
  39. static inline int test_bit_le(int nr, const void *addr)
  40. {
  41. return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  42. }
  43. static inline void __set_bit_le(int nr, void *addr)
  44. {
  45. __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  46. }
  47. static inline void __clear_bit_le(int nr, void *addr)
  48. {
  49. __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  50. }
  51. static inline int test_and_set_bit_le(int nr, void *addr)
  52. {
  53. return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  54. }
  55. static inline int test_and_clear_bit_le(int nr, void *addr)
  56. {
  57. return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  58. }
  59. static inline int __test_and_set_bit_le(int nr, void *addr)
  60. {
  61. return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  62. }
  63. static inline int __test_and_clear_bit_le(int nr, void *addr)
  64. {
  65. return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
  66. }
  67. #endif /* _ASM_GENERIC_BITOPS_LE_H_ */