aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/uaccess.h
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-06-25 10:05:11 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-09 03:14:18 -0400
commit865e5b76505cdade261773bde32f785b3ce579f1 (patch)
tree3ac122f2b95162b286b1a136ec4460f422b0d8b9 /include/asm-x86/uaccess.h
parentca23386216b9d4fc3bb211101205077d2b2916ae (diff)
x86: merge getuser.
Merge versions of getuser from uaccess_32.h and uaccess_64.h into uaccess.h. There is a part which is 64-bit only (for now), and for that, we use a __get_user_8 macro. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/uaccess.h')
-rw-r--r--include/asm-x86/uaccess.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/include/asm-x86/uaccess.h b/include/asm-x86/uaccess.h
index 2fc30c2a8a98..8cb580c0b411 100644
--- a/include/asm-x86/uaccess.h
+++ b/include/asm-x86/uaccess.h
@@ -120,6 +120,61 @@ extern int __get_user_bad(void);
120 : "=a" (ret),"=d" (x) \ 120 : "=a" (ret),"=d" (x) \
121 : "0" (ptr)) \ 121 : "0" (ptr)) \
122 122
123/* Careful: we have to cast the result to the type of the pointer
124 * for sign reasons */
125
126/**
127 * get_user: - Get a simple variable from user space.
128 * @x: Variable to store result.
129 * @ptr: Source address, in user space.
130 *
131 * Context: User context only. This function may sleep.
132 *
133 * This macro copies a single simple variable from user space to kernel
134 * space. It supports simple types like char and int, but not larger
135 * data types like structures or arrays.
136 *
137 * @ptr must have pointer-to-simple-variable type, and the result of
138 * dereferencing @ptr must be assignable to @x without a cast.
139 *
140 * Returns zero on success, or -EFAULT on error.
141 * On error, the variable @x is set to zero.
142 */
143#ifdef CONFIG_X86_32
144#define __get_user_8(__ret_gu, __val_gu, ptr) \
145 __get_user_x(X, __ret_gu, __val_gu, ptr)
146#else
147#define __get_user_8(__ret_gu, __val_gu, ptr) \
148 __get_user_x(8, __ret_gu, __val_gu, ptr)
149#endif
150
151#define get_user(x, ptr) \
152({ \
153 int __ret_gu; \
154 unsigned long __val_gu; \
155 __chk_user_ptr(ptr); \
156 switch (sizeof(*(ptr))) { \
157 case 1: \
158 __get_user_x(1, __ret_gu, __val_gu, ptr); \
159 break; \
160 case 2: \
161 __get_user_x(2, __ret_gu, __val_gu, ptr); \
162 break; \
163 case 4: \
164 __get_user_x(4, __ret_gu, __val_gu, ptr); \
165 break; \
166 case 8: \
167 __get_user_8(__ret_gu, __val_gu, ptr); \
168 break; \
169 default: \
170 __get_user_x(X, __ret_gu, __val_gu, ptr); \
171 break; \
172 } \
173 (x) = (__typeof__(*(ptr)))__val_gu; \
174 __ret_gu; \
175})
176
177
123#ifdef CONFIG_X86_32 178#ifdef CONFIG_X86_32
124# include "uaccess_32.h" 179# include "uaccess_32.h"
125#else 180#else