From: Frederik Deweerdt I felt that the arch_supports_kprobes use was a bit weird. The constant is not capitalized and is used as a variable for a C test. I also added comments (CONFIG_KPROBES) to an #else and an #endif. Signed-off-by: Frederik Deweerdt Signed-off-by: Andrew Morton --- include/asm-i386/kprobes.h | 2 +- include/linux/kprobes.h | 11 +++++------ kernel/kprobes.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff -puN include/asm-i386/kprobes.h~kprobes-arch_supports_kretprobes-cleanup include/asm-i386/kprobes.h --- 25/include/asm-i386/kprobes.h~kprobes-arch_supports_kretprobes-cleanup 2005-05-13 23:32:50.000000000 -0700 +++ 25-akpm/include/asm-i386/kprobes.h 2005-05-13 23:32:50.000000000 -0700 @@ -39,7 +39,7 @@ typedef u8 kprobe_opcode_t; : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry -#define arch_supports_kretprobes 1 +#define ARCH_SUPPORTS_KRETPROBES void kretprobe_trampoline(void); diff -puN include/linux/kprobes.h~kprobes-arch_supports_kretprobes-cleanup include/linux/kprobes.h --- 25/include/linux/kprobes.h~kprobes-arch_supports_kretprobes-cleanup 2005-05-13 23:32:50.000000000 -0700 +++ 25-akpm/include/linux/kprobes.h 2005-05-13 23:32:50.000000000 -0700 @@ -95,15 +95,14 @@ struct jprobe { kprobe_opcode_t *entry; /* probe handling code to jump to */ }; -#ifdef arch_supports_kretprobes +#ifdef ARCH_SUPPORTS_KRETPROBES extern int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs); extern void trampoline_post_handler(struct kprobe *p, struct pt_regs *regs, unsigned long flags); extern struct task_struct *arch_get_kprobe_task(void *ptr); extern void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs); extern void arch_kprobe_flush_task(struct task_struct *tk, spinlock_t *kp_lock); -#else -#define arch_supports_kretprobes 0 +#else /* ARCH_SUPPORTS_KRETPROBES */ static inline void kretprobe_trampoline(void) { } @@ -125,7 +124,7 @@ static inline void arch_kprobe_flush_tas { } #define arch_get_kprobe_task(ptr) ((struct task_struct *)NULL) -#endif +#endif /* ARCH_SUPPORTS_KRETPROBES */ /* * Function-return probe - * Note: @@ -191,7 +190,7 @@ struct kretprobe_instance *get_rp_inst_t void add_rp_inst(struct kretprobe_instance *ri); void kprobe_flush_task(struct task_struct *tk); void recycle_rp_inst(struct kretprobe_instance *ri); -#else +#else /* CONFIG_KPROBES */ static inline int kprobe_running(void) { return 0; @@ -223,5 +222,5 @@ static inline void unregister_kretprobe( static inline void kprobe_flush_task(struct task_struct *tk) { } -#endif +#endif /* CONFIG_KPROBES */ #endif /* _LINUX_KPROBES_H */ diff -puN kernel/kprobes.c~kprobes-arch_supports_kretprobes-cleanup kernel/kprobes.c --- 25/kernel/kprobes.c~kprobes-arch_supports_kretprobes-cleanup 2005-05-13 23:32:50.000000000 -0700 +++ 25-akpm/kernel/kprobes.c 2005-05-13 23:32:50.000000000 -0700 @@ -390,15 +390,14 @@ void unregister_jprobe(struct jprobe *jp unregister_kprobe(&jp->kp); } +#ifdef ARCH_SUPPORTS_KRETPROBES + int register_kretprobe(struct kretprobe *rp) { int ret = 0; struct kretprobe_instance *inst; int i; - if (!arch_supports_kretprobes) - return -ENOSYS; - rp->kp.pre_handler = pre_handler_kretprobe; /* Pre-allocate memory for max kretprobe instances */ @@ -428,6 +427,15 @@ int register_kretprobe(struct kretprobe return ret; } +#else /* ARCH_SUPPORTS_KRETPROBES */ + +int register_kretprobe(struct kretprobe *rp) +{ + return -ENOSYS; +} + +#endif /* ARCH_SUPPORTS_KRETPROBES */ + void unregister_kretprobe(struct kretprobe *rp) { unsigned long flags; _