1 #ifndef _LINUX_JUMP_LABEL_H
2 #define _LINUX_JUMP_LABEL_H
4 #include <linux/types.h>
5 #include <linux/compiler.h>
7 #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
9 struct jump_label_key {
11 struct jump_entry *entries;
13 struct jump_label_mod *next;
17 # include <asm/jump_label.h>
18 # define HAVE_JUMP_LABEL
21 enum jump_label_type {
22 JUMP_LABEL_DISABLE = 0,
28 #ifdef HAVE_JUMP_LABEL
31 #define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL, NULL}
33 #define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL}
36 static __always_inline bool static_branch(struct jump_label_key *key)
38 return arch_static_branch(key);
41 extern struct jump_entry __start___jump_table[];
42 extern struct jump_entry __stop___jump_table[];
44 extern void jump_label_lock(void);
45 extern void jump_label_unlock(void);
46 extern void arch_jump_label_transform(struct jump_entry *entry,
47 enum jump_label_type type);
48 extern void arch_jump_label_transform_static(struct jump_entry *entry,
49 enum jump_label_type type);
50 extern int jump_label_text_reserved(void *start, void *end);
51 extern void jump_label_inc(struct jump_label_key *key);
52 extern void jump_label_dec(struct jump_label_key *key);
53 extern bool jump_label_enabled(struct jump_label_key *key);
54 extern void jump_label_apply_nops(struct module *mod);
58 #include <linux/atomic.h>
60 #define JUMP_LABEL_INIT {ATOMIC_INIT(0)}
62 struct jump_label_key {
66 static __always_inline bool static_branch(struct jump_label_key *key)
68 if (unlikely(atomic_read(&key->enabled)))
73 static inline void jump_label_inc(struct jump_label_key *key)
75 atomic_inc(&key->enabled);
78 static inline void jump_label_dec(struct jump_label_key *key)
80 atomic_dec(&key->enabled);
83 static inline int jump_label_text_reserved(void *start, void *end)
88 static inline void jump_label_lock(void) {}
89 static inline void jump_label_unlock(void) {}
91 static inline bool jump_label_enabled(struct jump_label_key *key)
93 return !!atomic_read(&key->enabled);
96 static inline int jump_label_apply_nops(struct module *mod)