atomic.h 645 B

1234567891011121314151617181920212223
  1. #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
  2. #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
  3. #include <asm/types.h>
  4. #include <asm/bitsperlong.h>
  5. static inline void set_bit(int nr, unsigned long *addr)
  6. {
  7. addr[nr / __BITS_PER_LONG] |= 1UL << (nr % __BITS_PER_LONG);
  8. }
  9. static inline void clear_bit(int nr, unsigned long *addr)
  10. {
  11. addr[nr / __BITS_PER_LONG] &= ~(1UL << (nr % __BITS_PER_LONG));
  12. }
  13. static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
  14. {
  15. return ((1UL << (nr % __BITS_PER_LONG)) &
  16. (((unsigned long *)addr)[nr / __BITS_PER_LONG])) != 0;
  17. }
  18. #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ */