Messages in this thread Patch in this message | | | Date | Thu, 16 Feb 2006 21:52:42 -0500 | From | Kyle McMartin <> | Subject | [PATCH] Generic is_compat_task helper |
| |
Implement a generic is_compat_task function. It should only be used when absolutely necessary. For example, to clean up the per-architecture tests in drivers/input/evdev.c.
Prototype is such that the existing asm-x86_64 helper needs no change.
Architecture maintainers must add an appropriate implementation to asm/compat.h, if needed.
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
---
Yeah, this can be abused... but, blocks like:
#ifdef CONFIG_X86_64 # define COMPAT_TEST is_compat_task() #elif defined(CONFIG_IA64) # define COMPAT_TEST IS_IA32_PROCESS(task_pt_regs(current)) #elif defined(CONFIG_S390) # define COMPAT_TEST test_thread_flag(TIF_31BIT) #elif defined(CONFIG_MIPS) # define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR) #else # define COMPAT_TEST test_thread_flag(TIF_32BIT) #endif
from drivers/input/evdev.c are worse. This style of block also appeared in a patch on netdev recently...
I think everyone can agree centralizing this is probably better than the current state of affairs.
diff --git a/include/asm-parisc/compat.h b/include/asm-parisc/compat.h index 38b918f..a5eb7cd 100644 --- a/include/asm-parisc/compat.h +++ b/include/asm-parisc/compat.h @@ -5,6 +5,7 @@ */ #include <linux/types.h> #include <linux/sched.h> +#include <linux/personality.h> #define COMPAT_USER_HZ 100 @@ -144,4 +145,14 @@ static __inline__ void __user *compat_al return (void __user *)regs->gr[30]; } +static inline int __is_compat_task(struct task_struct *t) +{ + return (personality(t->personality) == PER_LINUX32); +} + +static inline int is_compat_task(void) +{ + return __is_compat_task(current); +} + #endif /* _ASM_PARISC_COMPAT_H */ diff --git a/include/linux/compat.h b/include/linux/compat.h index c9ab2a2..d2e0ea9 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -181,5 +181,12 @@ static inline int compat_timespec_compar return lhs->tv_nsec - rhs->tv_nsec; } +#else /* !CONFIG_COMPAT */ + +static inline int is_compat_task(void) +{ + return 0; +} + #endif /* CONFIG_COMPAT */ #endif /* _LINUX_COMPAT_H */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |