1#ifndef _LINUX_ATOMIC_H 2#define _LINUX_ATOMIC_H 3#include <asm/atomic.h> 4 5/** 6 * atomic_inc_not_zero_hint - increment if not null 7 * @v: pointer of type atomic_t 8 * @hint: probable value of the atomic before the increment 9 * 10 * This version of atomic_inc_not_zero() gives a hint of probable 11 * value of the atomic. This helps processor to not read the memory 12 * before doing the atomic read/modify/write cycle, lowering 13 * number of bus transactions on some arches. 14 * 15 * Returns: 0 if increment was not done, 1 otherwise. 16 */ 17#ifndef atomic_inc_not_zero_hint 18static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint) 19{ 20 int val, c = hint; 21 22 /* sanity test, should be removed by compiler if hint is a constant */ 23 if (!hint) 24 return atomic_inc_not_zero(v); 25 26 do { 27 val = atomic_cmpxchg(v, c, c + 1); 28 if (val == c) 29 return 1; 30 c = val; 31 } while (c); 32 33 return 0; 34} 35#endif 36 37#ifndef CONFIG_ARCH_HAS_ATOMIC_OR 38static inline void atomic_or(int i, atomic_t *v) 39{ 40 int old; 41 int new; 42 43 do { 44 old = atomic_read(v); 45 new = old | i; 46 } while (atomic_cmpxchg(v, old, new) != old); 47} 48#endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR */ 49 50#endif /* _LINUX_ATOMIC_H */ 51