This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Re: [Patch, toplevel/config] fix tls.m4 configure race condition (bootstrap/PR43170)
- From: dominiq at lps dot ens dot fr (Dominique Dhumieres)
- To: gcc-patches at gcc dot gnu dot org
- Cc: bonzini at gcc dot gnu dot org, developer at sandoe-acoustics dot co dot uk
- Date: Tue, 08 Jun 2010 18:55:51 +0200
- Subject: Re: Re: [Patch, toplevel/config] fix tls.m4 configure race condition (bootstrap/PR43170)
I have tested the following for 10000 runs without failure the following
variants:
[macbook] f90/bug% cat pthread_create_2.c
#include <pthread.h>
__thread int a;
static void *
thread_func (void *arg)
{
int *a_in_other_thread;
a_in_other_thread = &a;
return (void *)0;
}
int
main ()
{
pthread_t thread;
void *thread_retval;
int *a_in_main_thread;
int *a_in_other_thread;
a_in_main_thread = &a;
if (pthread_create (&thread, (pthread_attr_t *)0,
thread_func, (void *)0))
return 0;
if (pthread_join (thread, &thread_retval))
return 0;
return (a_in_other_thread == a_in_main_thread);
;
return 0;
}
[macbook] f90/bug% cat pthread_create_3.c
#include <pthread.h>
__thread volatile int a;
static void *
thread_func (void *arg)
{
static int volatile *volatile a_in_other_thread;
a_in_other_thread = &a;
return (void *)0;
}
int
main ()
{
pthread_t thread;
void *thread_retval;
int volatile *volatile a_in_main_thread;
static int volatile *volatile a_in_other_thread;
a_in_main_thread = &a;
if (pthread_create (&thread, (pthread_attr_t *)0,
thread_func, (void *)0))
return 0;
if (pthread_join (thread, &thread_retval))
return 0;
return (a_in_other_thread == a_in_main_thread);
;
return 0;
}
compiled with -g -O2 -pthread.
Dominique