]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/ofed/include/linux/atomic.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / ofed / include / linux / atomic.h
1 #ifndef _COMPAT_LINUX_ATOMIC_H
2 #define _COMPAT_LINUX_ATOMIC_H 1
3
4 /*
5 #include <linux/version.h>
6
7 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36))
8 #include_next <linux/atomic.h>
9 #else
10 */
11
12 #include <asm/atomic.h>
13
14 /* Shahar Klein: atomic_inc_not_zero_hint do we need it? */
15 #if 0
16
17 /**
18  * atomic_inc_not_zero_hint - increment if not null
19  * @v: pointer of type atomic_t
20  * @hint: probable value of the atomic before the increment
21  *
22  * This version of atomic_inc_not_zero() gives a hint of probable
23  * value of the atomic. This helps processor to not read the memory
24  * before doing the atomic read/modify/write cycle, lowering
25  * number of bus transactions on some arches.
26  *
27  * Returns: 0 if increment was not done, 1 otherwise.
28  */
29
30 #ifndef atomic_inc_not_zero_hint
31 static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
32 {
33         int val, c = hint;
34
35         /* sanity test, should be removed by compiler if hint is a constant */
36         if (!hint)
37                 return atomic_inc_not_zero(v);
38
39         do {
40                 val = atomic_cmpxchg(v, c, c + 1);
41                 if (val == c)
42                         return 1;
43                 c = val;
44         } while (c);
45
46         return 0;
47 }
48 #endif
49 #endif
50
51 //#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) */
52
53 #endif  /* _COMPAT_LINUX_ATOMIC_H */