This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __sync_bool_compare_and_swap
- From: Andrew Haley <aph at redhat dot com>
- To: Magnus Fromreide <magfr at lysator dot liu dot se>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 5 Jan 2007 17:05:41 +0000
- Subject: Re: __sync_bool_compare_and_swap
- References: <1168016239.15226.8.camel@localhost>
Magnus Fromreide writes:
> I got so happy when __sync_bool_compare_and_swap showed up in 4.1 but
> now HEAD have changed the behaviour for me.
>
> Earlier I got (gcc version 4.1.2 20061028 (prerelease) (Debian
> 4.1.1-19)) (Yes, vendor version, but gcc.gnu.org versions did the same)
>
> lock
> cmpxchgl %edx, (%ecx)
>
> but now I get (gcc version 4.3.0 20070105 (experimental)) (rev 120486
> (this would be interesting in the output of gcc -v, is there a way to
> put the revision there?))
>
> call __sync_bool_compare_and_swap_4
>
> Now, reading the manual suggests that if I use the wrong architecture I
> should get a call of this form but since the code I used was
>
> int main()
> {
> int a;
> return __sync_bool_compare_and_swap(&a, 0, 1);
> }
>
> I think it should generate the cmpxchgl.
But it can't unless you use an architecture that has cmpxchgl.
cmpxchgl is a 486 instruction; if you compile for 386, we have to
generate the call because there is no such instruction.
Andrew.