/* * User space memory access functions, these should work * on any machine that has kernel and user data in the same * address space, e.g. all NOMMU machines.
*/ #include <linux/string.h> #include <asm-generic/access_ok.h>
switch (size) { case 1:
*(u8 __force *)to = *(u8 *)from; return 0; case 2:
put_unaligned(*(u16 *)from, (u16 __force *)to); return 0; case 4:
put_unaligned(*(u32 *)from, (u32 __force *)to); return 0; case 8:
put_unaligned(*(u64 *)from, (u64 __force *)to); return 0; default:
BUILD_BUG(); return 0;
}
} #define __put_user_fn(sz, u, k) __put_user_fn(sz, u, k)
#define __get_kernel_nofault(dst, src, type, err_label) \ do { \
*((type *)dst) = get_unaligned((type *)(src)); \ if (0) /* make sure the label looks used to the compiler */ \ goto err_label; \
} while (0)
#define __put_kernel_nofault(dst, src, type, err_label) \ do { \
put_unaligned(*((type *)src), (type *)(dst)); \ if (0) /* make sure the label looks used to the compiler */ \ goto err_label; \
} while (0)
/* * These are the main single-value transfer routines. They automatically * use the right size if we just have the right pointer type. * This version just falls back to copy_{from,to}_user, which should * provide a fast-path for small values.
*/ #define __put_user(x, ptr) \
({ \
__typeof__(*(ptr)) __x = (x); \ int __pu_err = -EFAULT; \
__chk_user_ptr(ptr); \ switch (sizeof (*(ptr))) { \ case 1: \ case 2: \ case 4: \ case 8: \
__pu_err = __put_user_fn(sizeof (*(ptr)), \
ptr, &__x); \ break; \ default: \
__put_user_bad(); \ break; \
} \
__pu_err; \
})
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.