开发者

Sun compiler's equivalent of gcc's __sync_fetch_and_add? aka Oracle Studio 12.2

Does the Oracle (Sun) Studio 12.2 C/C++/Fortran c开发者_运维知识库ompiler 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜