aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-um/uaccess.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-um/uaccess.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-um/uaccess.h')
-rw-r--r--include/asm-um/uaccess.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/asm-um/uaccess.h b/include/asm-um/uaccess.h
new file mode 100644
index 000000000000..801710d00a40
--- /dev/null
+++ b/include/asm-um/uaccess.h
@@ -0,0 +1,102 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __UM_UACCESS_H
7#define __UM_UACCESS_H
8
9#include "linux/sched.h"
10
11#define VERIFY_READ 0
12#define VERIFY_WRITE 1
13
14/*
15 * The fs value determines whether argument validity checking should be
16 * performed or not. If get_fs() == USER_DS, checking is performed, with
17 * get_fs() == KERNEL_DS, checking is bypassed.
18 *
19 * For historical reasons, these macros are grossly misnamed.
20 */
21
22#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
23
24#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
25#define USER_DS MAKE_MM_SEG(TASK_SIZE)
26
27#define get_ds() (KERNEL_DS)
28#define get_fs() (current_thread_info()->addr_limit)
29#define set_fs(x) (current_thread_info()->addr_limit = (x))
30
31#define segment_eq(a, b) ((a).seg == (b).seg)
32
33#include "um_uaccess.h"
34
35#define __copy_from_user(to, from, n) copy_from_user(to, from, n)
36
37#define __copy_to_user(to, from, n) copy_to_user(to, from, n)
38
39#define __copy_to_user_inatomic __copy_to_user
40#define __copy_from_user_inatomic __copy_from_user
41
42#define __get_user(x, ptr) \
43({ \
44 const __typeof__(ptr) __private_ptr = ptr; \
45 __typeof__(*(__private_ptr)) __private_val; \
46 int __private_ret = -EFAULT; \
47 (x) = 0; \
48 if (__copy_from_user(&__private_val, (__private_ptr), \
49 sizeof(*(__private_ptr))) == 0) {\
50 (x) = (__typeof__(*(__private_ptr))) __private_val; \
51 __private_ret = 0; \
52 } \
53 __private_ret; \
54})
55
56#define get_user(x, ptr) \
57({ \
58 const __typeof__((*(ptr))) __user *private_ptr = (ptr); \
59 (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
60 __get_user(x, private_ptr) : ((x) = 0, -EFAULT)); \
61})
62
63#define __put_user(x, ptr) \
64({ \
65 __typeof__(ptr) __private_ptr = ptr; \
66 __typeof__(*(__private_ptr)) __private_val; \
67 int __private_ret = -EFAULT; \
68 __private_val = (__typeof__(*(__private_ptr))) (x); \
69 if (__copy_to_user((__private_ptr), &__private_val, \
70 sizeof(*(__private_ptr))) == 0) { \
71 __private_ret = 0; \
72 } \
73 __private_ret; \
74})
75
76#define put_user(x, ptr) \
77({ \
78 __typeof__(*(ptr)) __user *private_ptr = (ptr); \
79 (access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \
80 __put_user(x, private_ptr) : -EFAULT); \
81})
82
83#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
84
85struct exception_table_entry
86{
87 unsigned long insn;
88 unsigned long fixup;
89};
90
91#endif
92
93/*
94 * Overrides for Emacs so that we follow Linus's tabbing style.
95 * Emacs will notice this stuff at the end of the file and automatically
96 * adjust the settings for this buffer only. This must remain at the end
97 * of the file.
98 * ---------------------------------------------------------------------------
99 * Local variables:
100 * c-file-style: "linux"
101 * End:
102 */