out-of-line x86 "put_user()" implementation
Quoted 5 lines · Linus Torvalds
(quoted diff) +5
-0+/* + * Strange magic calling convention: pointer in %ecx, + * value in %eax(:%edx), return value in %eax, no clobbers. + */ +extern void __put_user_1(void);
Review
Quoted 10 lines
(quoted diff) +10
-0+extern void __put_user_2(void); +extern void __put_user_4(void); +extern void __put_user_8(void); + +#define __put_user_1(x, ptr) __asm__ __volatile__("call __put_user_1":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) +#define __put_user_2(x, ptr) __asm__ __volatile__("call __put_user_2":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) +#define __put_user_4(x, ptr) __asm__ __volatile__("call __put_user_4":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr)) +#define __put_user_8(x, ptr) __asm__ __volatile__("call __put_user_8":"=a" (__ret_pu):"A" ((typeof(*(ptr)))(x)), "c" (ptr)) +#define __put_user_X(x, ptr) __asm__ __volatile__("call __put_user_X":"=a" (__ret_pu):"c" (ptr)) +
Should "cc" be on the clobber list since all the called functions alter EFLAGS?
And in any case is it too much to ask for an 80-column limit? ;)
#define __put_user_1(x, ptr) \
__asm__ __volatile__( \
"call __put_user_1" \
: "=a" (__ret_pu) \
: "0" ((typeof(*(ptr)))(x)), "c" (ptr) \
: "cc")
#define __put_user_2(x, ptr) \
__asm__ __volatile__( \
"call __put_user_2" \
: "=a" (__ret_pu) \
: "0" ((typeof(*(ptr)))(x)), "c" (ptr) \
: "cc")
#define __put_user_4(x, ptr) \
__asm__ __volatile__( \
"call __put_user_4" \
: "=a" (__ret_pu) \
: "0" ((typeof(*(ptr)))(x)), "c" (ptr) \
: "cc")
#define __put_user_8(x, ptr) \
__asm__ __volatile__( \
"call __put_user_8" \
: "=a" (__ret_pu) \
: "A" ((typeof(*(ptr)))(x)), "c" (ptr) \
: "cc")
#define __put_user_X(x, ptr) \
__asm__ __volatile__( \
"call __put_user_X" \
: "=a" (__ret_pu) \
: "c" (ptr) \
: "cc")--
Chuck
Quoted 2 lines · Chuck Ebbert
And in any case is it too much to ask for an 80-column limit? ;)
Yes. Dammit, especially for something like this, the long-line version is just _so_ much more readable. Compare my and your version wrt being able to tell what the differences between the four different cases are.
In the single-long-line version, the differences are trivially visible. In the "prettified" version (aka "I'm still living in the 60's, and proud of it" version), it's impossible to pick out the differences.
If you don't like long lines, use a helper #define for the common part or something.
Linus