patch-2.4.22 linux-2.4.22/include/asm-sh/uaccess.h
Next file: linux-2.4.22/include/asm-sh/ubc.h
Previous file: linux-2.4.22/include/asm-sh/types.h
Back to the patch index
Back to the overall index
- Lines: 154
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/include/asm-sh/uaccess.h
- Orig date:
2002-02-25 11:38:13.000000000 -0800
diff -urN linux-2.4.21/include/asm-sh/uaccess.h linux-2.4.22/include/asm-sh/uaccess.h
@@ -1,4 +1,4 @@
-/* $Id: uaccess.h,v 1.13 2001/10/01 02:22:01 gniibe Exp $
+/* $Id: uaccess.h,v 1.1.1.1.2.4 2002/08/28 16:52:43 gniibe Exp $
*
* User space memory access functions
*
@@ -102,12 +102,11 @@
} x = (__typeof__(*(ptr))) __gu_val; __gu_err; })
#define __get_user_check(x,ptr,size) ({ \
-long __gu_err; \
+long __gu_err = -EFAULT; \
__typeof__(*(ptr)) __gu_val; \
long __gu_addr; \
__asm__("":"=r" (__gu_val)); \
__gu_addr = (long) (ptr); \
-__asm__("":"=r" (__gu_err)); \
if (__access_ok(__gu_addr,size)) { \
switch (size) { \
case 1: __get_user_asm("b"); break; \
@@ -155,12 +154,11 @@
} __pu_err; })
#define __put_user_check(x,ptr,size) ({ \
-long __pu_err; \
+long __pu_err = -EFAULT; \
__typeof__(*(ptr)) __pu_val; \
long __pu_addr; \
__pu_val = (x); \
__pu_addr = (long) (ptr); \
-__asm__("":"=r" (__pu_err)); \
if (__access_ok(__pu_addr,size)) { \
switch (size) { \
case 1: __put_user_asm("b"); break; \
@@ -244,42 +242,7 @@
/* Generic arbitrary sized copy. */
/* Return the number of bytes NOT copied */
-/* XXX: should be such that: 4byte and the rest. */
-static __inline__ __kernel_size_t
-__copy_user(void *__to, const void *__from, __kernel_size_t __n)
-{
- unsigned long __dummy, _f, _t;
- __kernel_size_t res;
-
- if ((res = __n))
- __asm__ __volatile__(
- "9:\n\t"
- "mov.b @%2+, %1\n\t"
- "dt %0\n"
- "1:\n\t"
- "mov.b %1, @%3\n\t"
- "bf/s 9b\n\t"
- " add #1, %3\n"
- "2:\n"
- ".section .fixup,\"ax\"\n"
- "3:\n\t"
- "mov.l 5f, %1\n\t"
- "jmp @%1\n\t"
- " add #1, %0\n\t"
- ".balign 4\n"
- "5: .long 2b\n"
- ".previous\n"
- ".section __ex_table,\"a\"\n"
- " .balign 4\n"
- " .long 9b,2b\n"
- " .long 1b,3b\n"
- ".previous"
- : "=r" (res), "=&z" (__dummy), "=r" (_f), "=r" (_t)
- : "2" (__from), "3" (__to), "0" (res)
- : "memory", "t");
-
- return res;
-}
+extern __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
#define copy_to_user(to,from,n) ({ \
void *__copy_to = (void *) (to); \
@@ -308,39 +271,11 @@
__copy_user((void *)(to), \
(void *)(from), n)
-/* XXX: Not sure it works well..
- should be such that: 4byte clear and the rest. */
-static __inline__ __kernel_size_t
-__clear_user(void *addr, __kernel_size_t size)
-{
- unsigned long __a;
-
- __asm__ __volatile__(
- "9:\n\t"
- "dt %0\n"
- "1:\n\t"
- "mov.b %4, @%1\n\t"
- "bf/s 9b\n\t"
- " add #1, %1\n"
- "2:\n"
- ".section .fixup,\"ax\"\n"
- "3:\n\t"
- "mov.l 4f, %1\n\t"
- "jmp @%1\n\t"
- " nop\n"
- ".balign 4\n"
- "4: .long 2b\n"
- ".previous\n"
- ".section __ex_table,\"a\"\n"
- " .balign 4\n"
- " .long 1b,3b\n"
- ".previous"
- : "=r" (size), "=r" (__a)
- : "0" (size), "1" (addr), "r" (0)
- : "memory", "t");
-
- return size;
-}
+/*
+ * Clear the area and return remaining number of bytes
+ * (on failure. Usually it's 0.)
+ */
+extern __kernel_size_t __clear_user(void *addr, __kernel_size_t size);
#define clear_user(addr,n) ({ \
void * __cl_addr = (addr); \
@@ -396,8 +331,6 @@
__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
} __sfu_res; })
-#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
-
/*
* Return the size of a string (including the ending 0!)
*/
@@ -436,12 +369,20 @@
static __inline__ long strnlen_user(const char *s, long n)
{
- if (!__addr_ok(s))
+ if (!access_ok(VERIFY_READ, s, n))
return 0;
else
return __strnlen_user(s, n);
}
+static __inline__ long strlen_user(const char *s)
+{
+ if (!access_ok(VERIFY_READ, s, 0))
+ return 0;
+ else
+ return __strnlen_user(s, ~0UL >> 1);
+}
+
struct exception_table_entry
{
unsigned long insn, fixup;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)