2010-09-17 23:09:00 +08:00
|
|
|
#ifndef _LINUX_JUMP_LABEL_H
|
|
|
|
#define _LINUX_JUMP_LABEL_H
|
|
|
|
|
2010-10-30 00:33:43 +08:00
|
|
|
#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
|
2010-09-17 23:09:00 +08:00
|
|
|
# include <asm/jump_label.h>
|
|
|
|
# define HAVE_JUMP_LABEL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum jump_label_type {
|
|
|
|
JUMP_LABEL_ENABLE,
|
|
|
|
JUMP_LABEL_DISABLE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct module;
|
|
|
|
|
|
|
|
#ifdef HAVE_JUMP_LABEL
|
|
|
|
|
|
|
|
extern struct jump_entry __start___jump_table[];
|
|
|
|
extern struct jump_entry __stop___jump_table[];
|
|
|
|
|
2010-10-02 05:23:48 +08:00
|
|
|
extern void jump_label_lock(void);
|
|
|
|
extern void jump_label_unlock(void);
|
2010-09-17 23:09:00 +08:00
|
|
|
extern void arch_jump_label_transform(struct jump_entry *entry,
|
|
|
|
enum jump_label_type type);
|
2010-09-17 23:09:08 +08:00
|
|
|
extern void arch_jump_label_text_poke_early(jump_label_t addr);
|
2010-09-17 23:09:00 +08:00
|
|
|
extern void jump_label_update(unsigned long key, enum jump_label_type type);
|
|
|
|
extern void jump_label_apply_nops(struct module *mod);
|
2010-09-17 23:09:08 +08:00
|
|
|
extern int jump_label_text_reserved(void *start, void *end);
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2010-10-15 03:10:38 +08:00
|
|
|
#define jump_label_enable(key) \
|
2010-09-17 23:09:00 +08:00
|
|
|
jump_label_update((unsigned long)key, JUMP_LABEL_ENABLE);
|
|
|
|
|
2010-10-15 03:10:38 +08:00
|
|
|
#define jump_label_disable(key) \
|
2010-09-17 23:09:00 +08:00
|
|
|
jump_label_update((unsigned long)key, JUMP_LABEL_DISABLE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define JUMP_LABEL(key, label) \
|
|
|
|
do { \
|
|
|
|
if (unlikely(*key)) \
|
|
|
|
goto label; \
|
|
|
|
} while (0)
|
|
|
|
|
2010-10-15 03:10:38 +08:00
|
|
|
#define jump_label_enable(cond_var) \
|
2010-09-17 23:09:00 +08:00
|
|
|
do { \
|
|
|
|
*(cond_var) = 1; \
|
|
|
|
} while (0)
|
|
|
|
|
2010-10-15 03:10:38 +08:00
|
|
|
#define jump_label_disable(cond_var) \
|
2010-09-17 23:09:00 +08:00
|
|
|
do { \
|
|
|
|
*(cond_var) = 0; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static inline int jump_label_apply_nops(struct module *mod)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-17 23:09:08 +08:00
|
|
|
static inline int jump_label_text_reserved(void *start, void *end)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-02 05:23:48 +08:00
|
|
|
static inline void jump_label_lock(void) {}
|
|
|
|
static inline void jump_label_unlock(void) {}
|
|
|
|
|
2010-09-17 23:09:00 +08:00
|
|
|
#endif
|
|
|
|
|
2010-10-17 18:15:00 +08:00
|
|
|
#define COND_STMT(key, stmt) \
|
|
|
|
do { \
|
|
|
|
__label__ jl_enabled; \
|
|
|
|
JUMP_LABEL(key, jl_enabled); \
|
|
|
|
if (0) { \
|
|
|
|
jl_enabled: \
|
|
|
|
stmt; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2010-09-17 23:09:00 +08:00
|
|
|
#endif
|