Subject: Re: [boost] [thread] thread-safe static local
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-03-03 19:02:20


----- Original Message -----
From: "Phil Endecott" <spam_from_boost_dev_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, March 04, 2009 12:11 AM
Subject: Re: [boost] [thread] thread-safe static local

>
> Othman, Ossama wrote:
>>> As you may know, gcc creates local statics that are thread safe by
>>> default.
>
>> Is there a way to reliably determine if the gcc's thread-safe local
>> statics are enabled?
>
> No, last time I looked there didn't seem to be anything.
> IIRC there's also no way to enable/disable it for individual variables
> using attributes.
>
>> If not, multithreaded library code that relies on that feature, for example,
>> should hide static locals inside an out-of-line function/method in the odd
>> event users of the library disable gcc's thread safe local statics for their
>> own code through the '-fno-threadsafe-statics' command line option.
>
> Yes, you need to do something like this if you can't require users to
> use the default setting.

Hi,
the boost build chain can take care of both adding a feature no-threadsafe-statics, that will do the setting of the compiler flag -fno-threadsafe-statics and an additional define, e.g. BOOST_NO_THREADSAFE_STATICS.

With other build chains, it will be enough to signal on the documentation that both must be correlated.

Vicente