]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] uninline copy_to_user() and copy_from_user()
authorAndrew Morton <akpm@osdl.org>
Tue, 13 Apr 2004 02:23:29 +0000 (19:23 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 13 Apr 2004 02:23:29 +0000 (19:23 -0700)
40k reduction in my vmlinux.

Thanks to Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua> for performing
the analysis.

arch/i386/lib/usercopy.c
include/asm-i386/uaccess.h

index 3b6e50f89223e017abf18a616aa56fc6d89050af..416a4d10f3bf4467010c054a03273eac05e4263d 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/blkdev.h>
+#include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/mmx.h>
 
@@ -567,7 +568,8 @@ survive:
        return n;
 }
 
-unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned long n)
+unsigned long
+__copy_from_user_ll(void *to, const void __user *from, unsigned long n)
 {
        if (movsl_is_ok(to, from, n))
                __copy_user_zeroing(to, (const void *) from, n);
@@ -575,3 +577,54 @@ unsigned long __copy_from_user_ll(void *to, const void __user *from, unsigned lo
                n = __copy_user_zeroing_intel(to, (const void *) from, n);
        return n;
 }
+
+/**
+ * copy_to_user: - Copy a block of data into user space.
+ * @to:   Destination address, in user space.
+ * @from: Source address, in kernel space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from kernel space to user space.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ */
+unsigned long
+copy_to_user(void __user *to, const void *from, unsigned long n)
+{
+       might_sleep();
+       if (access_ok(VERIFY_WRITE, to, n))
+               n = __copy_to_user(to, from, n);
+       return n;
+}
+EXPORT_SYMBOL(copy_to_user);
+
+/**
+ * copy_from_user: - Copy a block of data from user space.
+ * @to:   Destination address, in kernel space.
+ * @from: Source address, in user space.
+ * @n:    Number of bytes to copy.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * Copy data from user space to kernel space.
+ *
+ * Returns number of bytes that could not be copied.
+ * On success, this will be zero.
+ *
+ * If some data could not be copied, this function will pad the copied
+ * data to the requested size using zero bytes.
+ */
+unsigned long
+copy_from_user(void *to, const void __user *from, unsigned long n)
+{
+       might_sleep();
+       if (access_ok(VERIFY_READ, from, n))
+               n = __copy_from_user(to, from, n);
+       else
+               memset(to, 0, n);
+       return n;
+}
+EXPORT_SYMBOL(copy_from_user);
index 8042de63aa55e15b7aec4a0c4b54c2fe2d53170b..f0216b1e08bb10e045335ca55926cd320f4dae94 100644 (file)
@@ -454,55 +454,9 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
        return __copy_from_user_ll(to, from, n);
 }
 
-/**
- * copy_to_user: - Copy a block of data into user space.
- * @to:   Destination address, in user space.
- * @from: Source address, in kernel space.
- * @n:    Number of bytes to copy.
- *
- * Context: User context only.  This function may sleep.
- *
- * Copy data from kernel space to user space.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- */
-static inline unsigned long
-copy_to_user(void __user *to, const void *from, unsigned long n)
-{
-       might_sleep();
-       if (access_ok(VERIFY_WRITE, to, n))
-               n = __copy_to_user(to, from, n);
-       return n;
-}
-
-/**
- * copy_from_user: - Copy a block of data from user space.
- * @to:   Destination address, in kernel space.
- * @from: Source address, in user space.
- * @n:    Number of bytes to copy.
- *
- * Context: User context only.  This function may sleep.
- *
- * Copy data from user space to kernel space.
- *
- * Returns number of bytes that could not be copied.
- * On success, this will be zero.
- *
- * If some data could not be copied, this function will pad the copied
- * data to the requested size using zero bytes.
- */
-static inline unsigned long
-copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-       might_sleep();
-       if (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);
+unsigned long copy_from_user(void *to,
+                       const void __user *from, unsigned long n);
 long strncpy_from_user(char *dst, const char __user *src, long count);
 long __strncpy_from_user(char *dst, const char __user *src, long count);