KEYS: Fix up comments in key management code
[linux-2.6/next.git] / include / linux / jump_label.h
blob7880f18e4b863b7d0ad6a84a0b55a06452ad0990
1 #ifndef _LINUX_JUMP_LABEL_H
2 #define _LINUX_JUMP_LABEL_H
4 #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
5 # include <asm/jump_label.h>
6 # define HAVE_JUMP_LABEL
7 #endif
9 enum jump_label_type {
10 JUMP_LABEL_ENABLE,
11 JUMP_LABEL_DISABLE
14 struct module;
16 #ifdef HAVE_JUMP_LABEL
18 extern struct jump_entry __start___jump_table[];
19 extern struct jump_entry __stop___jump_table[];
21 extern void jump_label_lock(void);
22 extern void jump_label_unlock(void);
23 extern void arch_jump_label_transform(struct jump_entry *entry,
24 enum jump_label_type type);
25 extern void arch_jump_label_text_poke_early(jump_label_t addr);
26 extern void jump_label_update(unsigned long key, enum jump_label_type type);
27 extern void jump_label_apply_nops(struct module *mod);
28 extern int jump_label_text_reserved(void *start, void *end);
30 #define jump_label_enable(key) \
31 jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE);
33 #define jump_label_disable(key) \
34 jump_label_update((unsigned long)key, JUMP_LABEL_DISABLE);
36 #else
38 #define JUMP_LABEL(key, label) \
39 do { \
40 if (unlikely(*key)) \
41 goto label; \
42 } while (0)
44 #define jump_label_enable(cond_var) \
45 do { \
46 *(cond_var) = 1; \
47 } while (0)
49 #define jump_label_disable(cond_var) \
50 do { \
51 *(cond_var) = 0; \
52 } while (0)
54 static inline int jump_label_apply_nops(struct module *mod)
56 return 0;
59 static inline int jump_label_text_reserved(void *start, void *end)
61 return 0;
64 static inline void jump_label_lock(void) {}
65 static inline void jump_label_unlock(void) {}
67 #endif
69 #define COND_STMT(key, stmt) \
70 do { \
71 __label__ jl_enabled; \
72 JUMP_LABEL(key, jl_enabled); \
73 if (0) { \
74 jl_enabled: \
75 stmt; \
76 } \
77 } while (0)
79 #endif