From 69867f861ed13ce7967516e031452608164884e8 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sat, 10 Jul 2004 19:29:02 -0700 Subject: [PATCH] [PATCH] ppc64: uninline some user copy routines gcc 3.5 is complaining about the size of copy_from_user. It turns out it is rather large and putting it out of line saves us about 30kB on a default kernel build. Signed-off-by: Anton Blanchard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc64/lib/Makefile | 2 +- arch/ppc64/lib/usercopy.c | 35 +++++++++++++++++++++++++++++++++++ include/asm-ppc64/uaccess.h | 33 ++++++--------------------------- 3 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 arch/ppc64/lib/usercopy.c diff --git a/arch/ppc64/lib/Makefile b/arch/ppc64/lib/Makefile index 713ae47dab61a..6d0cb66cca133 100644 --- a/arch/ppc64/lib/Makefile +++ b/arch/ppc64/lib/Makefile @@ -3,7 +3,7 @@ # lib-y := checksum.o dec_and_lock.o string.o strcase.o -lib-y += copypage.o memcpy.o copyuser.o +lib-y += copypage.o memcpy.o copyuser.o usercopy.o # Lock primitives are defined as no-ops in include/linux/spinlock.h # for non-SMP configs. Don't build the real versions. diff --git a/arch/ppc64/lib/usercopy.c b/arch/ppc64/lib/usercopy.c new file mode 100644 index 0000000000000..1f487d9e59abf --- /dev/null +++ b/arch/ppc64/lib/usercopy.c @@ -0,0 +1,35 @@ +/* + * Functions which are too large to be inlined. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include + +unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) +{ + if (likely(access_ok(VERIFY_READ, from, n))) + n = __copy_from_user(to, from, n); + else + memset(to, 0, n); + return n; +} + +unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) +{ + if (likely(access_ok(VERIFY_WRITE, to, n))) + n = __copy_to_user(to, from, n); + return n; +} + +unsigned long copy_in_user(void __user *to, const void __user *from, + unsigned long n) +{ + might_sleep(); + if (likely(access_ok(VERIFY_READ, from, n) && + access_ok(VERIFY_WRITE, to, n))) + n =__copy_tofrom_user(to, from, n); + return n; +} diff --git a/include/asm-ppc64/uaccess.h b/include/asm-ppc64/uaccess.h index 9423be5add95e..4d2d6097802b9 100644 --- a/include/asm-ppc64/uaccess.h +++ b/include/asm-ppc64/uaccess.h @@ -272,33 +272,12 @@ __copy_to_user(void __user *to, const void *from, unsigned long n) #define __copy_in_user(to, from, size) \ __copy_tofrom_user((to), (from), (size)) -static inline unsigned long -copy_from_user(void *to, const void __user *from, unsigned long n) -{ - if (likely(access_ok(VERIFY_READ, from, n))) - n = __copy_from_user(to, from, n); - else - memset(to, 0, n); - return n; -} - -static inline unsigned long -copy_to_user(void __user *to, const void *from, unsigned long n) -{ - if (likely(access_ok(VERIFY_WRITE, to, n))) - n = __copy_to_user(to, from, n); - return n; -} - -static inline unsigned long -copy_in_user(void __user *to, const void __user *from, unsigned long n) -{ - might_sleep(); - if (likely(access_ok(VERIFY_READ, from, n) && - access_ok(VERIFY_WRITE, to, n))) - n =__copy_tofrom_user(to, from, n); - return n; -} +extern unsigned long copy_from_user(void *to, const void __user *from, + unsigned long n); +extern unsigned long copy_to_user(void __user *to, const void *from, + unsigned long n); +extern unsigned long copy_in_user(void __user *to, const void __user *from, + unsigned long n); extern unsigned long __clear_user(void __user *addr, unsigned long size); -- 2.53.0