diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2010-05-03 15:33:05 -0700 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2010-05-03 15:33:05 -0700 |
| commit | f450fa5f991af3c0814f96265cb3b2aafdce2309 (patch) | |
| tree | 1f0e549863606fb8e11215061ad5dde0f37b50cd /libc/kernel/arch-sh/asm/uaccess.h | |
| parent | 5ef5272be985dfdeafa86077c306f6b64d334240 (diff) | |
| parent | 0be7eda75a14815aaa3e5cd5d5d4e5d25dc35d1c (diff) | |
| download | bionic-f450fa5f991af3c0814f96265cb3b2aafdce2309.zip bionic-f450fa5f991af3c0814f96265cb3b2aafdce2309.tar.gz bionic-f450fa5f991af3c0814f96265cb3b2aafdce2309.tar.bz2 | |
merge from open-source master
Change-Id: If02d33af51017dbd85e91c79ac2e848eda6cf253
Diffstat (limited to 'libc/kernel/arch-sh/asm/uaccess.h')
| -rw-r--r-- | libc/kernel/arch-sh/asm/uaccess.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libc/kernel/arch-sh/asm/uaccess.h b/libc/kernel/arch-sh/asm/uaccess.h new file mode 100644 index 0000000..8b27346 --- /dev/null +++ b/libc/kernel/arch-sh/asm/uaccess.h @@ -0,0 +1,55 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __ASM_SH_UACCESS_H +#define __ASM_SH_UACCESS_H + +#include <linux/errno.h> +#include <linux/sched.h> +#include <asm/segment.h> + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +#define __addr_ok(addr) ((unsigned long __force)(addr) < current_thread_info()->addr_limit.seg) + +#define __access_ok(addr, size) (__addr_ok((addr) + (size))) +#define access_ok(type, addr, size) (__chk_user_ptr(addr), __access_ok((unsigned long __force)(addr), (size))) + +#define put_user(x,ptr) __put_user_check((x), (ptr), sizeof(*(ptr))) +#define get_user(x,ptr) __get_user_check((x), (ptr), sizeof(*(ptr))) + +#define __put_user(x,ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr))) +#define __get_user(x,ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr))) + +struct __large_struct { unsigned long buf[100]; }; +#define __m(x) (*(struct __large_struct __user *)(x)) + +#define __get_user_nocheck(x,ptr,size) ({ long __gu_err; unsigned long __gu_val; const __typeof__(*(ptr)) __user *__gu_addr = (ptr); __chk_user_ptr(ptr); __get_user_size(__gu_val, __gu_addr, (size), __gu_err); (x) = (__typeof__(*(ptr)))__gu_val; __gu_err; }) + +#define __get_user_check(x,ptr,size) ({ long __gu_err = -EFAULT; unsigned long __gu_val = 0; const __typeof__(*(ptr)) *__gu_addr = (ptr); if (likely(access_ok(VERIFY_READ, __gu_addr, (size)))) __get_user_size(__gu_val, __gu_addr, (size), __gu_err); (x) = (__typeof__(*(ptr)))__gu_val; __gu_err; }) + +#define __put_user_nocheck(x,ptr,size) ({ long __pu_err; __typeof__(*(ptr)) __user *__pu_addr = (ptr); __typeof__(*(ptr)) __pu_val = x; __chk_user_ptr(ptr); __put_user_size(__pu_val, __pu_addr, (size), __pu_err); __pu_err; }) + +#define __put_user_check(x,ptr,size) ({ long __pu_err = -EFAULT; __typeof__(*(ptr)) __user *__pu_addr = (ptr); __typeof__(*(ptr)) __pu_val = x; if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) __put_user_size(__pu_val, __pu_addr, (size), __pu_err); __pu_err; }) + +#include "uaccess_32.h" + +#define __copy_to_user_inatomic __copy_to_user +#define __copy_from_user_inatomic __copy_from_user + +#define clear_user(addr,n) ({ void __user * __cl_addr = (addr); unsigned long __cl_size = (n); if (__cl_size && access_ok(VERIFY_WRITE, ((unsigned long)(__cl_addr)), __cl_size)) __cl_size = __clear_user(__cl_addr, __cl_size); __cl_size; }) + +#define strncpy_from_user(dest,src,count) ({ unsigned long __sfu_src = (unsigned long)(src); int __sfu_count = (int)(count); long __sfu_res = -EFAULT; if (__access_ok(__sfu_src, __sfu_count)) __sfu_res = __strncpy_from_user((unsigned long)(dest), __sfu_src, __sfu_count); __sfu_res; }) + +#define strlen_user(str) strnlen_user(str, ~0UL >> 1) + +#endif |
