]>
Commit | Line | Data |
---|---|---|
bf5438fc JB |
1 | #ifndef _LINUX_JUMP_LABEL_H |
2 | #define _LINUX_JUMP_LABEL_H | |
3 | ||
4 | #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_HAVE_ARCH_JUMP_LABEL) | |
5 | # include <asm/jump_label.h> | |
6 | # define HAVE_JUMP_LABEL | |
7 | #endif | |
8 | ||
9 | enum jump_label_type { | |
10 | JUMP_LABEL_ENABLE, | |
11 | JUMP_LABEL_DISABLE | |
12 | }; | |
13 | ||
14 | struct module; | |
15 | ||
16 | #ifdef HAVE_JUMP_LABEL | |
17 | ||
18 | extern struct jump_entry __start___jump_table[]; | |
19 | extern struct jump_entry __stop___jump_table[]; | |
20 | ||
21 | extern void arch_jump_label_transform(struct jump_entry *entry, | |
22 | enum jump_label_type type); | |
4c3ef6d7 | 23 | extern void arch_jump_label_text_poke_early(jump_label_t addr); |
bf5438fc JB |
24 | extern void jump_label_update(unsigned long key, enum jump_label_type type); |
25 | extern void jump_label_apply_nops(struct module *mod); | |
4c3ef6d7 | 26 | extern int jump_label_text_reserved(void *start, void *end); |
bf5438fc | 27 | |
3b6e901f | 28 | #define jump_label_enable(key) \ |
bf5438fc JB |
29 | jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE); |
30 | ||
3b6e901f | 31 | #define jump_label_disable(key) \ |
bf5438fc JB |
32 | jump_label_update((unsigned long)key, JUMP_LABEL_DISABLE); |
33 | ||
34 | #else | |
35 | ||
36 | #define JUMP_LABEL(key, label) \ | |
37 | do { \ | |
38 | if (unlikely(*key)) \ | |
39 | goto label; \ | |
40 | } while (0) | |
41 | ||
3b6e901f | 42 | #define jump_label_enable(cond_var) \ |
bf5438fc JB |
43 | do { \ |
44 | *(cond_var) = 1; \ | |
45 | } while (0) | |
46 | ||
3b6e901f | 47 | #define jump_label_disable(cond_var) \ |
bf5438fc JB |
48 | do { \ |
49 | *(cond_var) = 0; \ | |
50 | } while (0) | |
51 | ||
52 | static inline int jump_label_apply_nops(struct module *mod) | |
53 | { | |
54 | return 0; | |
55 | } | |
56 | ||
4c3ef6d7 JB |
57 | static inline int jump_label_text_reserved(void *start, void *end) |
58 | { | |
59 | return 0; | |
60 | } | |
61 | ||
bf5438fc JB |
62 | #endif |
63 | ||
ebf31f50 PZ |
64 | #define COND_STMT(key, stmt) \ |
65 | do { \ | |
66 | __label__ jl_enabled; \ | |
67 | JUMP_LABEL(key, jl_enabled); \ | |
68 | if (0) { \ | |
69 | jl_enabled: \ | |
70 | stmt; \ | |
71 | } \ | |
72 | } while (0) | |
73 | ||
bf5438fc | 74 | #endif |