Question

Does the Oracle (Sun) Studio 12.2 C/C++/Fortran compiler for Linux 64-bit have an equivalent to the __sync_fetch_and_add function that is provided in gcc? I can't seem to find the wrapper code for the intel atomics in the Sun documentation nor the .h files in my Sun Studio installation. That means either I'm just bad at searching, or it could be it does not exist, not sure which.

I happen to need access to whatever atomic hardware functions are available on the intel i7 using the Sun C/C++ compilers, such as Test-and-set, Compare-and-swap, Fetch-and-foo.

This is complicated by the fact that I'm not an assembly programmer, and that this is a Sun compiler not a GCC compiler so copying the asm code from gcc's open source implementation is not necessarily going to work, and finally it's 64 bit compiler and hardware, so the 32 bit examples that are easily found are not necessarily going to work right on the 64 bit system.

Background: The purpose is for implementing some concurrent programs for multicore which require these particular hardware atomics.

Thanks for reading.

No correct solution

OTHER TIPS

From the Oracle documentation, you'll need to include atomic.h and use one of the following:

uint_t atomic_add_int_nv(volatile uint_t *target, int delta);
uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval);
void atomic_or_32(volatile uint32_t *target, uint32_t bits);

... etc.

http://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hr06/index.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top