BKL: remove extraneous #include <smp_lock.h>
[linux-3.10.git] / include / linux / jump_label_ref.h
1 #ifndef _LINUX_JUMP_LABEL_REF_H
2 #define _LINUX_JUMP_LABEL_REF_H
3
4 #include <linux/jump_label.h>
5 #include <asm/atomic.h>
6
7 #ifdef HAVE_JUMP_LABEL
8
9 static inline void jump_label_inc(atomic_t *key)
10 {
11         if (atomic_add_return(1, key) == 1)
12                 jump_label_enable(key);
13 }
14
15 static inline void jump_label_dec(atomic_t *key)
16 {
17         if (atomic_dec_and_test(key))
18                 jump_label_disable(key);
19 }
20
21 #else /* !HAVE_JUMP_LABEL */
22
23 static inline void jump_label_inc(atomic_t *key)
24 {
25         atomic_inc(key);
26 }
27
28 static inline void jump_label_dec(atomic_t *key)
29 {
30         atomic_dec(key);
31 }
32
33 #undef JUMP_LABEL
34 #define JUMP_LABEL(key, label)                                          \
35 do {                                                                    \
36         if (unlikely(__builtin_choose_expr(                             \
37               __builtin_types_compatible_p(typeof(key), atomic_t *),    \
38               atomic_read((atomic_t *)(key)), *(key))))                 \
39                 goto label;                                             \
40 } while (0)
41
42 #endif /* HAVE_JUMP_LABEL */
43
44 #endif /* _LINUX_JUMP_LABEL_REF_H */