3 extern void *__user_addr_min, *__user_addr_max;
5 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
7 static inline void __chk_user_ptr(const volatile void *p, size_t size)
9 assert(p >= __user_addr_min && p + size <= __user_addr_max);
12 #define put_user(x, ptr) \
14 typeof(ptr) __pu_ptr = (ptr); \
15 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
16 ACCESS_ONCE(*(__pu_ptr)) = x; \
20 #define get_user(x, ptr) \
22 typeof(ptr) __pu_ptr = (ptr); \
23 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
24 x = ACCESS_ONCE(*(__pu_ptr)); \
28 static void volatile_memcpy(volatile char *to, const volatile char *from,
35 static inline int copy_from_user(void *to, const void __user volatile *from,
38 __chk_user_ptr(from, n);
39 volatile_memcpy(to, from, n);
43 static inline int copy_to_user(void __user volatile *to, const void *from,
46 __chk_user_ptr(to, n);
47 volatile_memcpy(to, from, n);
50 #endif /* UACCESS_H */