Go to main content
Oracle® Developer Studio 12.6: C User's Guide

Exit Print View

Updated: July 2017
 
 

3.2.3 Implementation Notes

When multiple components such as executables or shared libraries require an atomic runtime, you should dynamically link each component with the appropriate –xatomic option to create a correct dynamic dependency. You should not produce a shared library that requires an atomic option to be supplied when the library is linked.

It is not recommend to use both runtime libraries in the same process, for the following reasons:

  • Some atomic types require calls to the runtime support library to perform synchronization. The two runtime systems have different internal data structures, so the two libraries cannot synchronize the same object.

  • The Oracle Developer Studio library libstatomic uses the same global symbol names for functions as libatomic. If both libraries are used in the same process, an executable or library could call functions in an unexpected library.

Programs that attempt to use both runtime libraries might seem to work at first, but are likely to fail and cannot be supported.


Note -  Using –latomic to link will not result in linking with /usr/lib/libatomic.so.1. That library is the GCC implementation and primarily intended to be used with GCC until a compatible library is released in Oracle Solaris and Linux.

Because many of the atomic operations are inlined, your application might be able to use the atomics feature without depending on the atomics runtime library. The behavior is implementation specific, so the results might change if you upgrade compilers. If your application uses only scalar atomic types (flags, char, int, long, or pointers) and builds on an x86 platform, then your resulting binary might not need libstatomic. You can try compiling such an application or library with the –xatomic=none option and check if it links and runs correctly.