This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, toplevel/config] fix tls.m4 configure race condition (bootstrap/PR43170)
On Tue, Jun 08, 2010 at 05:24:18PM +0100, IainS wrote:
> >- static int *a_in_other_thread;
> >+ int *a_in_other_thread;
> >+ int *a_in_main_thread;
> >
> >No reason to make this global.
> >
> >Patch okay if you just move the "a_in_main_thread = &a" assignment
> >for all branches. I can take care of syncing to src.
>
> if
> int *a_in_main_thread;
>
> is local to main () is not the compiler at liberty to move the first
> access to it to the first place it's used?
>
> i.e. it could order the call to __emutls_get_address () for
> a_in_main_thread after the call the pthread_create().
>
> the placement of a_in_main_thread as global was to ensure that it
> could not do that (well, that was my understanding).
Yeah. Alternatively both could be made volatile:
static int *volatile a_in_other_thread;
static int *volatile a_in_main_thread;
(well, with volatile a_in_main_thread could perhaps stay even to be just
local variable in main).
Jakub