[PATCH] ppc64: fix semtimedop compat syscall

Arnd Bergmann arnd at arndb.de
Wed Mar 23 10:44:30 EST 2005

On Dinsdag 22 März 2005 23:58, Stephen Rothwell wrote:
> I was just being pedantic as this is the case we care about.  It is quite
> possible that the compiler upon seeing "int x" as an function argument
> will assume that any value passed to the argument has been sign extended
> to the equivalent of long by any caller of the function (since ints as
> function arguments may actually be 64 bit registers).  So the (long)(int)
> cast may be a noop for this particular complier and if we have zero
> extended the value in assembler instead, the result will be incorrect.
> I am not saying that any compiler does do this, but it would still be
> internally consistent, no?

I think that some versions of gcc on s390 do exactly this, although
I can't reproduce it right now (I only have gcc-2.95 at hand here).
When you do a cast from unsigned to int, the compiler always has
to do the sign-extend anyway.

IIRC, the three architectures that I have looked at so far all behave
slightly differently:

- on s390x, a register containing an int uses the whole 64 bits,
  like a long int. When calling a function with int parameters,
  the _caller_ needs to do a sign-extend from the lower 32 bits of
  its local variable.

- On x86_64, any 32 bit operation, even something trivial like mov eax,ebx
  clears the high 32 bits of the 64 bit register.

- On ppc64, the high order bits are ignored

 Arnd <><

More information about the Linuxppc64-dev mailing list