[zeromq-dev] Pull request on atomic ops

Martin Lucina mato at kotelna.sk
Mon May 10 19:04:54 CEST 2010

Steven, Martin,

steven.mccoy at miru.hk said:
> I saw Mato update the atomic ops for adding NetBSD, here is a further update
> that reads a bit better, maybe.  I tried sending a pull-request on github but
> the interface appears broken and has now disappeared, no idea.
> * Defer NetBSD atomic ops to GCC builtins.
> * Revert Sun atomic ops #define

Unfortunately the GCC builtins are not very useful. After fixing some typos
on Git master I tried to build on NetBSD/hpcarm and as expected got this
error when linking e.g. perf tests:

../src/.libs/libzmq.so: undefined reference to `__sync_val_compare_and_swap_4'
../src/.libs/libzmq.so: undefined reference to `__sync_fetch_and_add_4'
../src/.libs/libzmq.so: undefined reference to `__sync_lock_test_and_set_4'

This is because GCC on ARM does not implement these builtins.  For details
please refer to my detailed write up on this subject here:


Martin, in the light of the above are you OK with reverting this change
which would mean reinstating the BSD atomic_ops and removing the GCC

> Reviewing the code highlights two points,
> * Inconsistent use of asm clobber statements, e.g. add defined CC and memory,
> but sub only defines CC.
> * Bitmaps on SPARCv9 or AMD64 Solaris will be 32-bit.

I'll try and fix these appropriately.

> And damn, those #defines are a mess.

Yeah. We could clean things up by splitting the different implementations
(native, Sun/BSD, Win32, mutex) into different source files and then either
#including those from a "master" file with the #defines or making the
decision at configure time and compiling the corresponding implementation.


More information about the zeromq-dev mailing list