Re: [PATCH] rw-semaphore asm constraints patch fix

Linus Torvalds (torvalds@transmeta.com)
Mon, 8 Apr 2002 08:59:55 -0700 (PDT)


On Mon, 8 Apr 2002, David Howells wrote:
>
> The attached patch should fix the compile error that asm-i386/rwsem.h causes
> with old gcc's whilst maintaining the asm constraints correctly.

Doesn't work.

> + : "=m"(sem->count), "=d"(tmp)
> + : "0"(sem->count), "1"(tmp), "a"(sem)

A "m" constraint cannot be used together with a subsequent number (ie the
"=m" -> "0" thing is illegal - the numbering traditionally only works on
hard registers). It may work with some compilers and with the right
register pressure, but it absolutely _will_ cause problems on other
setups.

I should know, I tried to work around gcc stupidities in this area enough
times, and cursed how various things didn't work with various compilers.

The best thing to do is probably to mark "sem->count" a memory input only,
which together with the memory clobber should be ok.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/