This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]