I'm trying to use __atomic_load_n
from the gcc
atomic builtins page, compiling with
gcc -Wall -march=i686 -std=gnu99 ll.c -o ll
but it tells me it can't
warning: implicit declaration of function ‘__atomic_load_n’
I thought it would be enough to provide gcc
with the arch
and the march
flags (and made sure by setting the std=gnu99
flag), but to no avail. In fact, even if I test for the common __GCC_VERSION__
or __GNUC__
macros don't seem to have values... but I have a pretty vanilla gcc
installation, the one that comes in Ubuntu.
I know I'm doing something silly, but I can't figure out what. I have gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Code looks like this: it's a function that never gets called (yet), so the problem is at compile time.
type* func(type* p) {
type* q = __atomic_load_n (p, __ATOMIC_SEQ_CST);
}
GCC provides built-in versions of the ISO C99 floating-point comparison macros that avoid raising exceptions for unordered operands. They have the same names as the standard macros ( isgreater , isgreaterequal , isless , islessequal , islessgreater , and isunordered ) , with __builtin_ prefixed.
Atomic operations are intended to allow access to shared data without extra protection (mutex, rwlock, …). This may improve: ● single thread performance ● scalability ● overall system performance.
Up until GCC 4.6.3, compiler built-ins for atomic operations were a pure compiler extension, and in GCC they were grouped into the __sync_*
family of functions.
As of version 4.7.0, both the new C++11 and the C11 standards had been finalized, and GCC updated their atomic built-ins to better reflect the new memory model of those two new language revisions. The new functions are grouped into the __atomic_*
family.
However, the older built-ins are still available, and the documentation says this:
It is always safe to replace a
__sync
call with an__atomic
call using the__ATOMIC_SEQ_CST
memory model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With