Re: [PATCH] Add 64-bit get_user and __get_user for i386

From: Jim Wilson
Date: Tue Apr 20 2004 - 18:28:30 EST


Jamie Lokier wrote:
However that doesn't seem to be a problem. Experiments show that an
__asm__ which outputs to a char or short type is _always_
sign-extended or zero-extended if needed by the compiler, on various
i386 subtargets. The compiler doesn't assume anything about the
output higher bits from an __asm__.
--> GCC experts, can you confirm the above property please?

expand_asm_operands in stmt.c checks for promoted variables, and if it sees one, it will generate a temporary with the unpromoted size to replace it in the asm, and then copy the temporary to the promoted variable after the asm, ensuring that the extension happens after the asm.

(Function calls are similar: GCC won't assume anything about the
higher bits of the result received from a function, although it always
promotes the result before returning a value. Odd combination).

I think this is a minor gcc bug. We have been promoting char/short return values since the gcc-1.x days. This promotion occurs regardless of whether the target asks for return values to be promoted. This promotion happens in start_function in c-decl.c. Perhaps this is a left over from the K&R C days, as I don't see anything in the C89 standard that requires this. Changing this now might break ports that require the promotion, but were not explicitly asking for it, so changing this might be tricky. I'd suggest opening a gcc bugzilla bug report if we really care about this.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

-
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/