2 * User address space access functions.
3 * The non inlined parts of asm-i386/uaccess.h are here.
5 * Copyright 1997 Andi Kleen <ak@muc.de>
6 * Copyright 1997 Linus Torvalds
8 #include <asm/uaccess.h>
11 __generic_copy_to_user(void *to
, const void *from
, unsigned long n
)
13 if (access_ok(VERIFY_WRITE
, to
, n
))
14 __copy_user(to
,from
,n
);
19 __generic_copy_from_user(void *to
, const void *from
, unsigned long n
)
21 if (access_ok(VERIFY_READ
, from
, n
))
22 __copy_user_zeroing(to
,from
,n
);
28 * Copy a null terminated string from userspace.
31 #define __do_strncpy_from_user(dst,src,count,res) \
32 __asm__ __volatile__( \
37 " testb %%al,%%al\n" \
43 ".section .fixup,\"ax\"\n" \
47 ".section __ex_table,\"a\"\n" \
51 : "=d"(res), "=c"(count) \
52 : "i"(-EFAULT), "0"(count), "1"(count), "S"(src), "D"(dst) \
53 : "si", "di", "ax", "memory")
56 __strncpy_from_user(char *dst
, const char *src
, long count
)
59 __do_strncpy_from_user(dst
, src
, count
, res
);
64 strncpy_from_user(char *dst
, const char *src
, long count
)
67 if (access_ok(VERIFY_READ
, src
, 1))
68 __do_strncpy_from_user(dst
, src
, count
, res
);
77 #define __do_clear_user(addr,size) \
78 __asm__ __volatile__( \
83 ".section .fixup,\"ax\"\n" \
84 "3: lea 0(%1,%0,4),%0\n" \
87 ".section __ex_table,\"a\"\n" \
93 : "r"(size & 3), "0"(size / 4), "D"(addr), "a"(0) \
97 clear_user(void *to
, unsigned long n
)
99 if (access_ok(VERIFY_WRITE
, to
, n
))
100 __do_clear_user(to
, n
);
105 __clear_user(void *to
, unsigned long n
)
107 __do_clear_user(to
, n
);
112 * Return the size of a string (including the ending 0)
117 long strlen_user(const char *s
)
121 __asm__
__volatile__(
125 ".section .fixup,\"ax\"\n"
129 ".section __ex_table,\"a\"\n"
133 :"=c" (res
), "=D" (s
)
134 :"1" (s
), "a" (0), "0" (-__addr_ok(s
)));
135 return res
& -__addr_ok(s
);