Documentation of __sync builtins unclear on external function callback behavior

Johan Tibell johan.tibell@gmail.com
Wed Jul 16 22:01:00 GMT 2014


The documentation of the __sync atomic builtins [1] state that

> Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning is generated and a call an external function is generated. The external function carries the same name as the built-in version, with an additional suffix ‘_n’ where n is the size of the data type.

I initial read this as a call to some function *defined by GCC* is
being emitted, but I now realize that this can be read as "the caller
is supposed to have defined such a fallback function". Which reading
is correct?

I have some code that fails to compile on i386 with the error

    /usr/home/ghc-builder/work/builder/tempbuild/build/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.3.1.0-ghc7.9.20140716.so:
undefined reference to `__sync_fetch_and_add_8'

so I guess that means that GCC is not defining these external fallback
functions?

1. https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fsync-Builtins.html#_005f_005fsync-Builtins

-- Johan



More information about the Gcc-help mailing list