2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2009, Wind River Systems Inc
7 * Implemented by fredrik.markstrom@gmail.com and ivarholmqvist@gmail.com
10 #include <linux/export.h>
11 #include <linux/uaccess.h>
13 asm(".global __copy_from_user\n"
14 " .type __copy_from_user, @function\n"
61 ".section __ex_table,\"a\"\n"
68 EXPORT_SYMBOL(__copy_from_user
);
71 " .global __copy_to_user\n"
72 " .type __copy_to_user, @function\n"
81 /* Bail if we try to copy zero bytes */
85 /* Copy byte by byte for small copies and if src^dst != 0 */
97 /* If 'to' is an odd address byte copy */
101 /* If 'to' is not divideable by four copy halfwords */
117 /* Copy remaining bytes */
124 ".section __ex_table,\"a\"\n"
130 EXPORT_SYMBOL(__copy_to_user
);
132 long strncpy_from_user(char *__to
, const char __user
*__from
, long __len
)
134 int l
= strnlen_user(__from
, __len
);
142 if (l
== 0 || copy_from_user(__to
, __from
, l
))
150 long strnlen_user(const char __user
*s
, long n
)
154 for (i
= 0; i
< n
; i
++) {
157 if (get_user(c
, s
+ i
) == -EFAULT
)