This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __sync_bool_compare_and_swap


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]