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


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

Re: threadsafeness at egcs1.0.3 and 1.1


> This is a case for calling pthread_once which is associated with a
> quite high cost (the pthread_once_t is normally at least two words
> long).

Interesting. There is an additional problem in local static
initializers for C++: If initialization throws an exception,
initialization is considered incomplete, and should be re-tried on the
next call (of course, after destructors of subobjects have been
called). 

So pthread_once doesn't really work here: We can't have once routines
that fail. Instead, we would need to duplicate glibc pthread_once with
a mutex and a condition, except that it restores the once_t to NEVER
instead of DONE in case of an exception.

This would also simplify linking to non-threaded code: the libgcc2
__cpp_once function would just call the initializer in the
non-threaded case.

Regards,
Martin


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