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); |
| 23 | extern void jump_label_update(unsigned long key, enum jump_label_type type); |
| 24 | extern void jump_label_apply_nops(struct module *mod); |
| 25 | extern void arch_jump_label_text_poke_early(jump_label_t addr); |
| 26 | |
| 27 | #define enable_jump_label(key) \ |
| 28 | jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE); |
| 29 | |
| 30 | #define disable_jump_label(key) \ |
| 31 | jump_label_update((unsigned long)key, JUMP_LABEL_DISABLE); |
| 32 | |
| 33 | #else |
| 34 | |
| 35 | #define JUMP_LABEL(key, label) \ |
| 36 | do { \ |
| 37 | if (unlikely(*key)) \ |
| 38 | goto label; \ |
| 39 | } while (0) |
| 40 | |
| 41 | #define enable_jump_label(cond_var) \ |
| 42 | do { \ |
| 43 | *(cond_var) = 1; \ |
| 44 | } while (0) |
| 45 | |
| 46 | #define disable_jump_label(cond_var) \ |
| 47 | do { \ |
| 48 | *(cond_var) = 0; \ |
| 49 | } while (0) |
| 50 | |
| 51 | static inline int jump_label_apply_nops(struct module *mod) |
| 52 | { |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | #endif |
| 57 | |
| 58 | #endif |