drm/qxl: make dynamic resizing work properly.
[linux-2.6.git] / tools / virtio / linux / uaccess.h
blob0a578fe18653b8b282af9ee101da0a558da222ba
1 #ifndef UACCESS_H
2 #define UACCESS_H
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) \
13 ({ \
14 typeof(ptr) __pu_ptr = (ptr); \
15 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
16 ACCESS_ONCE(*(__pu_ptr)) = x; \
17 0; \
20 #define get_user(x, ptr) \
21 ({ \
22 typeof(ptr) __pu_ptr = (ptr); \
23 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
24 x = ACCESS_ONCE(*(__pu_ptr)); \
25 0; \
28 static void volatile_memcpy(volatile char *to, const volatile char *from,
29 unsigned long n)
31 while (n--)
32 *(to++) = *(from++);
35 static inline int copy_from_user(void *to, const void __user volatile *from,
36 unsigned long n)
38 __chk_user_ptr(from, n);
39 volatile_memcpy(to, from, n);
40 return 0;
43 static inline int copy_to_user(void __user volatile *to, const void *from,
44 unsigned long n)
46 __chk_user_ptr(to, n);
47 volatile_memcpy(to, from, n);
48 return 0;
50 #endif /* UACCESS_H */