[PATCH] Fix PR target/24071

Eric Botcazou ebotcazou@libertysurf.fr
Tue Oct 31 15:30:00 GMT 2006


> The alternative would be, inside the mutex:
>
>    if (__gthread_active < 0) {
>      __gthread_active = 0;
>      __gthrw_(pthread_once) (...);
>    }
>
> and then, instead of "__gthread_active++":
>
>    else
>      __gthread_active = 0;

On second thoughts, I don't think this is safe.  The first test in my patch

  if (__gthread_active < 0)

is not protected to avoid taking a lock on the main code path so  
__gthread_active must never be 0 when the program is threaded.

However I agree that the increment is potentially confusing so we'd probably 
better eliminate it.  I've also decided to make __gthread_active volatile 
for the sake of extra-safety (I think your modification would also have been 
problematic wrt that aspect).  Revised version attached, same testing.

-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr24071-2.diff
Type: text/x-diff
Size: 4792 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061031/2cedd6c4/attachment.bin>


More information about the Gcc-patches mailing list