[zeromq-dev] atomic ops

Ivan Pechorin ivan.pechorin at gmail.com
Thu Feb 9 07:14:26 CET 2012


2012/2/8 Steven McCoy <steven.mccoy at miru.hk>:
>
> Compare with my atomics:
>
> http://code.google.com/p/openpgm/source/browse/trunk/openpgm/pgm/include/pgm/atomic.h

Steven, what is the reason to use asm on Solaris/x86 instead of
Solaris intrinsics from <atomic.h> ?

#elif (defined( __SUNPRO_C ) || defined( __SUNPRO_CC )) && (defined(
__i386 ) || defined( __amd64 ))
        uint32_t result = val;
        __asm__ volatile ("lock; xaddl %0, %1"
                       :: "r" (result), "m" (*atomic)  );
        return result;

And (sorry for stupid question), why the asm for x86/x86_64 is
different for SunCC and for GCC/ICC ?

By the way, HP-UX also has the same intrinsics in <atomic.h>.
So, I believe, it's worth changing

#if defined( __sun )
#       include <atomic.h>

to something like this:

#if (defined(sun) || defined(__sun) || defined(hpux) || defined(__hpux))

At least, that's what we use in our proprietary code that runs on all
of these platforms.



More information about the zeromq-dev mailing list