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


"DARIN JOHNSON" <darin@usa.net> writes:

> 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.
>
> Am I missing something here?

I'm not sure, but perhaps what you are missing is that if you want to
compile a library with multi-threaded support, you need to provide a
gthreads wrapper.  It doesn't make sense to use atomic operations for
some things but not for, e.g., constructors for static function
variables.

Alternatively, if you just want to write code which uses atomic
operations, but you don't need the library to have multi-threaded
support, then use the builtin __sync_XXX functions, not
__atomic_add_dispatch and friends.

Ian


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