buserror on osx.4

Igor Sysoev is at rambler-co.ru
Thu Dec 21 11:59:15 MSK 2006

On Thu, 21 Dec 2006, Igor Sysoev wrote:

>> (gdb) disassemble ___compare_and_swap32
>> Dump of assembler code for function ___compare_and_swap32:
>> 0xffff8080 <___compare_and_swap32+0>:   lwarx   r7,0,r5
>> 0xffff8084 <___compare_and_swap32+4>:   cmplw   r7,r3
>> 0xffff8088 <___compare_and_swap32+8>:   bne-    0xffff809c 
>> <___compare_and_swap32+28>
>> 0xffff808c <___compare_and_swap32+12>:  stwcx.  r4,0,r5
>> 0xffff8090 <___compare_and_swap32+16>:  bne-    0xffff8080 
>> <___compare_and_swap32>
>> 0xffff8094 <___compare_and_swap32+20>:  li      r3,1
>> 0xffff8098 <___compare_and_swap32+24>:  blr
>> 0xffff809c <___compare_and_swap32+28>:  li      r3,0
>> 0xffff80a0 <___compare_and_swap32+32>:  blr
>> 0xffff80a4 <___compare_and_swap32+36>:  .long 0x0
>> 0xffff80a8 <___compare_and_swap32+40>:  .long 0x0
>> 0xffff80ac <___compare_and_swap32+44>:  .long 0x0
>> 0xffff80b0 <___compare_and_swap32+48>:  .long 0x0
>> 0xffff80b4 <___compare_and_swap32+52>:  .long 0x0
>> 0xffff80b8 <___compare_and_swap32+56>:  .long 0x0
>> 0xffff80bc <___compare_and_swap32+60>:  .long 0x0
>> End of assembler dump.
> OK, then I will do atomic operation using MacOSX builtin
> OSAtomicCompareAndSwap32Barrier()

Just to be sure that OSAtomicCompareAndSwap32() does not cycle forever
(as it may if lwarx/stwcx pair does not work) on your Mac compile
this program:

#include <libkern/OSAtomic.h>

static  int32_t  test;

int main()
     int  rc;

     rc = OSAtomicCompareAndSwap32(0, 1, &test);

     printf("rc: %d, test: %d\n", rc, test);


cc -o q q.c

and run, it should show:

rc: 1, test: 1

Igor Sysoev

More information about the nginx mailing list