EFAULT - update __get_user() __put_user(), by Thayne Harbaugh.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3508 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
ths 2007-11-02 20:24:22 +00:00
parent 80210bcd71
commit 89343ecde5

View File

@ -206,22 +206,22 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
#define access_ok(type,addr,size) \
(page_check_range((target_ulong)addr,size,(type==VERIFY_READ)?PAGE_READ:PAGE_WRITE)==0)
/* NOTE get_user and put_user use host addresses. */
#define __put_user(x,ptr)\
/* NOTE __get_user and __put_user use host pointers and don't check access. */
#define __put_user(x, hptr)\
({\
int size = sizeof(*ptr);\
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
*(uint8_t *)(ptr) = (typeof(*ptr))(x);\
*(uint8_t *)(hptr) = (typeof(*hptr))(x);\
break;\
case 2:\
*(uint16_t *)(ptr) = tswap16((typeof(*ptr))(x));\
*(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
break;\
case 4:\
*(uint32_t *)(ptr) = tswap32((typeof(*ptr))(x));\
*(uint32_t *)(hptr) = tswap32((typeof(*hptr))(x));\
break;\
case 8:\
*(uint64_t *)(ptr) = tswap64((typeof(*ptr))(x));\
*(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
break;\
default:\
abort();\
@ -229,21 +229,21 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
0;\
})
#define __get_user(x, ptr) \
#define __get_user(x, hptr) \
({\
int size = sizeof(*ptr);\
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
x = (typeof(*ptr))*(uint8_t *)(ptr);\
x = (typeof(*hptr))*(uint8_t *)(hptr);\
break;\
case 2:\
x = (typeof(*ptr))tswap16(*(uint16_t *)(ptr));\
x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
break;\
case 4:\
x = (typeof(*ptr))tswap32(*(uint32_t *)(ptr));\
x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
break;\
case 8:\
x = (typeof(*ptr))tswap64(*(uint64_t *)(ptr));\
x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
break;\
default:\
abort();\