Re: out-of-line x86 "put_user()" implementation

From: Chuck Ebbert
Date: Fri Feb 11 2005 - 21:02:20 EST


On Tue, 8 Feb 2005 at 18:27:08 -0800, Linus Torvalds wrote:

> +/*
> + * Strange magic calling convention: pointer in %ecx,
> + * value in %eax(:%edx), return value in %eax, no clobbers.
> + */
> +extern void __put_user_1(void);
> +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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/