History

compat: provide compat_ptr() on all architectures

In order to avoid needless #ifdef CONFIG_COMPAT checks, move the compat_ptr() definition to linux/compat.h where it can be seen by any file regardless of the architecture. Only s390 needs a special definition, this can use the self-#define trick we have elsewhere.

Arnd Bergmann committed 6 years ago

Commit 202bf8d1 parent 556d6879 files · +20 −109Browse files

Showing the changes to include/linux (1 of 9 files). Show all

Unified · Split

include/linux/compat.h+18−0
@@ -958,4 +958,22 @@ static inline bool in_compat_syscall(void) { return false; } · 957 unmodified lines
958 958
959#endif /* CONFIG_COMPAT */959#endif /* CONFIG_COMPAT */
960 960
961/*
962 * A pointer passed in from user mode. This should not
963 * be used for syscall parameters, just declare them
964 * as pointers because the syscall entry code will have
965 * appropriately converted them already.
966 */
967#ifndef compat_ptr
968static inline void __user *compat_ptr(compat_uptr_t uptr)
969{
970 return (void __user *)(unsigned long)uptr;
971}
972#endif
973
974static inline compat_uptr_t ptr_to_compat(void __user *uptr)
975{
976 return (u32)(unsigned long)uptr;
977}
978
961#endif /* _LINUX_COMPAT_H */979#endif /* _LINUX_COMPAT_H */