15b17e1cd8928ae65932758ce6478ac6d3e9a86b2Arnd Bergmann#ifndef __ASM_GENERIC_UACCESS_UNALIGNED_H 25b17e1cd8928ae65932758ce6478ac6d3e9a86b2Arnd Bergmann#define __ASM_GENERIC_UACCESS_UNALIGNED_H 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This macro should be used instead of __get_user() when accessing 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * values at locations that are not known to be aligned. 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define __get_user_unaligned(x, ptr) \ 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds({ \ 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __typeof__ (*(ptr)) __x; \ 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __copy_from_user(&__x, (ptr), sizeof(*(ptr))) ? -EFAULT : 0; \ 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (x) = __x; \ 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}) 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This macro should be used instead of __put_user() when accessing 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * values at locations that are not known to be aligned. 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define __put_user_unaligned(x, ptr) \ 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds({ \ 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __typeof__ (*(ptr)) __x = (x); \ 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds __copy_to_user((ptr), &__x, sizeof(*(ptr))) ? -EFAULT : 0; \ 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}) 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 265b17e1cd8928ae65932758ce6478ac6d3e9a86b2Arnd Bergmann#endif /* __ASM_GENERIC_UACCESS_UNALIGNED_H */ 27