This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Make generic atomicity.h use gthr.h mutexes
- From: Phil Edwards <phil at jaj dot com>
- To: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Cc: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Sun, 10 Nov 2002 18:11:24 -0500
- Subject: Re: Make generic atomicity.h use gthr.h mutexes
- References: <200211102017.gAAKHsUT004444@hiauly1.hia.nrc.ca>
On Sun, Nov 10, 2002 at 03:17:54PM -0500, John David Anglin wrote:
> __initialized is local to the each inline copy of __exchange_and_add,
> so each copy will attempt to initialize _Atomic_add_mutex. Even if
> __initialized was global, there could be race conditions in initializing
> _Atomic_add_mutex.
Yargh, of course. Okay, if __initialized is moved to something like
namespace __gnu_cxx
{
__gthread_mutex_t _Atomic_add_mutex __attribute__ ((__weak__))
#ifdef __GTHREAD_MUTEX_INIT
= __GTHREAD_MUTEX_INIT
#else
;
bool _Atomic_add_mutex_initialized __attribute__ ((__weak__)) = false
#endif
;
}
and the if branch remains, that should do it.
I'm not fond of the semicolon games played above, and will cheerfully be more
verbose if people prefer.
Phil
--
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
- Edsger Dijkstra, 1930-2002