Jason Baron | bf5438fc | 2010-09-17 11:09:00 -0400 | [diff] [blame] | 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); |
Jason Baron | 4c3ef6d | 2010-09-17 11:09:08 -0400 | [diff] [blame^] | 23 | extern void arch_jump_label_text_poke_early(jump_label_t addr); |
Jason Baron | bf5438fc | 2010-09-17 11:09:00 -0400 | [diff] [blame] | 24 | extern void jump_label_update(unsigned long key, enum jump_label_type type); |
| 25 | extern void jump_label_apply_nops(struct module *mod); |
Jason Baron | 4c3ef6d | 2010-09-17 11:09:08 -0400 | [diff] [blame^] | 26 | extern int jump_label_text_reserved(void *start, void *end); |
Jason Baron | bf5438fc | 2010-09-17 11:09:00 -0400 | [diff] [blame] | 27 | |
| 28 | #define enable_jump_label(key) \ |
| 29 | jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE); |
| 30 | |
| 31 | #define disable_jump_label(key) \ |
| 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 | |
| 42 | #define enable_jump_label(cond_var) \ |
| 43 | do { \ |
| 44 | *(cond_var) = 1; \ |
| 45 | } while (0) |
| 46 | |
| 47 | #define disable_jump_label(cond_var) \ |
| 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 | |
Jason Baron | 4c3ef6d | 2010-09-17 11:09:08 -0400 | [diff] [blame^] | 57 | static inline int jump_label_text_reserved(void *start, void *end) |
| 58 | { |
| 59 | return 0; |
| 60 | } |
| 61 | |
Jason Baron | bf5438fc | 2010-09-17 11:09:00 -0400 | [diff] [blame] | 62 | #endif |
| 63 | |
| 64 | #endif |