This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __atomic_add support without gthreads


> I noticed some support was in for using atomic operations in
> some C++ library functions in GCC 4.2.  However when looking
> through the code it seems as if some case is being left out.
> The code seems to assume either __GTHREADS is being used, or
> the application is purely single-threaded.  There's no third
> choice where __atomic_add_dispatch() does an atomic add even
> if GTHREADS is not used.  I want to avoid creating a gthreads
> wrapper for our OS.

If your target cpu/os supports __sync_fetch_and_add it should be used. 

The choices are either builtin support, support for some kind of
machine specific asm, or pthread simulation. See
GLIBCXX_ENABLE_ATOMIC_BUILTINS and the define _GLIBCXX_ATOMIC_BUILTINS.

Please note that configuration in this area has changed for this in 4.3
and some more in 4.4. I would encourage you to do new ports against gcc
trunk.

-benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]