uaccess-unaligned.h 733 B

123456789101112131415161718192021222324252627
  1. #ifndef __ASM_GENERIC_UACCESS_UNALIGNED_H
  2. #define __ASM_GENERIC_UACCESS_UNALIGNED_H
  3. /*
  4. * This macro should be used instead of __get_user() when accessing
  5. * values at locations that are not known to be aligned.
  6. */
  7. #define __get_user_unaligned(x, ptr) \
  8. ({ \
  9. __typeof__ (*(ptr)) __x; \
  10. __copy_from_user(&__x, (ptr), sizeof(*(ptr))) ? -EFAULT : 0; \
  11. (x) = __x; \
  12. })
  13. /*
  14. * This macro should be used instead of __put_user() when accessing
  15. * values at locations that are not known to be aligned.
  16. */
  17. #define __put_user_unaligned(x, ptr) \
  18. ({ \
  19. __typeof__ (*(ptr)) __x = (x); \
  20. __copy_to_user((ptr), &__x, sizeof(*(ptr))) ? -EFAULT : 0; \
  21. })
  22. #endif /* __ASM_GENERIC_UACCESS_UNALIGNED_H */