blob: b72cd9f92c2edc1648848b8c40fe920f281c7663 [file] [log] [blame]
Jason Baronbf5438fc2010-09-17 11:09:00 -04001#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
9enum jump_label_type {
10 JUMP_LABEL_ENABLE,
11 JUMP_LABEL_DISABLE
12};
13
14struct module;
15
16#ifdef HAVE_JUMP_LABEL
17
18extern struct jump_entry __start___jump_table[];
19extern struct jump_entry __stop___jump_table[];
20
21extern void arch_jump_label_transform(struct jump_entry *entry,
22 enum jump_label_type type);
Jason Baron4c3ef6d2010-09-17 11:09:08 -040023extern void arch_jump_label_text_poke_early(jump_label_t addr);
Jason Baronbf5438fc2010-09-17 11:09:00 -040024extern void jump_label_update(unsigned long key, enum jump_label_type type);
25extern void jump_label_apply_nops(struct module *mod);
Jason Baron4c3ef6d2010-09-17 11:09:08 -040026extern int jump_label_text_reserved(void *start, void *end);
Jason Baronbf5438fc2010-09-17 11:09:00 -040027
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) \
37do { \
38 if (unlikely(*key)) \
39 goto label; \
40} while (0)
41
42#define enable_jump_label(cond_var) \
43do { \
44 *(cond_var) = 1; \
45} while (0)
46
47#define disable_jump_label(cond_var) \
48do { \
49 *(cond_var) = 0; \
50} while (0)
51
52static inline int jump_label_apply_nops(struct module *mod)
53{
54 return 0;
55}
56
Jason Baron4c3ef6d2010-09-17 11:09:08 -040057static inline int jump_label_text_reserved(void *start, void *end)
58{
59 return 0;
60}
61
Jason Baronbf5438fc2010-09-17 11:09:00 -040062#endif
63
64#endif