Of course, it helps if you actually use GCC 4.6 and not 4.5.3 when trying to compile. D'oh! My bad. Please ignore. Everything works as expected/documented: ~/t $ cat test.c #include <stdio.h> void main() { __int128 a = 1, b; b = __sync_val_compare_and_swap(&a, 1, 2); printf("Returned value = %d, New value = %d\n", (int)b, (int)a); } ~/t $ gcc-4.6.3-pre9999 -mcx16 test.c -o test ~/t $ ./test Returned value = 1, New value = 2 ~/t $ objdump -d test | grep cmpxchg16b 40059e: f0 48 0f c7 0e lock cmpxchg16b (%rsi) ~/t $ On 7 January 2012 17:25, Borg Onion <borg.onion@xxxxxxxxx> wrote: > Hello, > > I'm trying to figure out how to make use of CMPXCHG16B. The GCC > manual looks to point towards __sync_val_compare_and_swap() with > __int128 data types and the -mcx16 compile flag. But this data type > is not present when I try to compile with it, nor do I think my 4th > generation Opteron is capable of holding __int128 values in its > registers. So what's the equivalent of .Net's > _InterlockedCompareExchange128() > [http://msdn.microsoft.com/en-us/library/bb514094.aspx] in GCC-land? > I'm trying to avoid having to (re?)implement it myself as these folks > did: > > http://stackoverflow.com/questions/4825400/cmpxchg16b-correct > > Thanks for any guidance, > > --Borg Onion -- --Borg Onion