Using gcc atomic inline?

I am trying to use __atomic_load_n on a gcc atomic builtins page, compiling with

 gcc -Wall -march=i686 -std=gnu99 ll.c -o ll 

but he tells me that he cannot

  warning: implicit declaration of function '__atomic_load_n' 

I thought that it would be enough to provide gcc arch and march flags (and make sure by setting the flag std=gnu99 ), but to no avail. In fact, even if I test the common __GCC_VERSION__ or __GNUC__ , it does not seem to __GNUC__ ... but I have a pretty vanilla gcc installation that comes with Unbuntu.

I know that I am doing something stupid, but I cannot understand that. I have gcc (Ubuntu / Linaro 4.6.3-1ubuntu5) 4.6.3

The code looks like this: it is a function that is never called (yet), so the problem is at compile time.

 type* func(type* p) { type* q = __atomic_load_n (p, __ATOMIC_SEQ_CST); } 
+6
source share
1 answer

Prior to GCC 4.6.3, the built-in compilers for atomic operations were a pure compiler extension, and in GCC they were grouped into an __sync_* family of functions.

Starting with version 4.7.0, the new C ++ 11 and C11 standards were completed, and GCC updated its atomic built-in modules to better reflect the new memory model of these two new language versions. New functions are grouped in the __atomic_* family.

However, older plugins are still available , and the documentation says the following:

it is safe to replace the __sync call with the __sync call using the __ATOMIC_SEQ_CST memory __ATOMIC_SEQ_CST .

+13
source

All Articles