This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: __atomic_add support without gthreads
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: "DARIN JOHNSON" <darin at usa dot net>
- Cc: <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 23 Feb 2009 12:26:13 -0800
- Subject: Re: __atomic_add support without gthreads
- References: <264NBuahG2592S28.1235176472@cmsweb28.cms.usa.net>
> 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