]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gthr-posix.h (__gthread_active_init): Create detached instead of joinable thread...
authorJohn David Anglin <dave.anglin@nrc-cnrc.gc.ca>
Fri, 12 Oct 2007 00:09:10 +0000 (00:09 +0000)
committerJohn David Anglin <danglin@gcc.gnu.org>
Fri, 12 Oct 2007 00:09:10 +0000 (00:09 +0000)
* gthr-posix.h (__gthread_active_init): Create detached instead of
joinable thread when testing whether threads are active on hppa-hpux.
* gthr-posix95.h (__gthread_active_init): Likewise.

From-SVN: r129246

gcc/ChangeLog
gcc/gthr-posix.h
gcc/gthr-posix95.h

index dac597f2b6212bf631d26ed2eaf97398053c613d..a5272799e0dd575a05e88299bc92894cc751f1bd 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-11  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+
+       * gthr-posix.h (__gthread_active_init): Create detached instead of
+       joinable thread when testing whether threads are active on hppa-hpux.
+       * gthr-posix95.h (__gthread_active_init): Likewise.
+
 2007-10-11  Kenneth Zadeck <zadeck@naturalbridge.com>
 
        PR middle-end/33676
index 5c00cd308623620048c1b37357559aaa2456de2f..ad6822e26ade652f0ce2620f9d2406a9a181e6d8 100644 (file)
@@ -246,20 +246,20 @@ __gthread_active_init (void)
 {
   static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
   pthread_t t;
+  pthread_attr_t a;
   int result;
 
   __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
   if (__gthread_active < 0)
     {
-      result = __gthrw_(pthread_create) (&t, NULL, __gthread_start, NULL);
+      __gthrw_(pthread_attr_init) (&a);
+      __gthrw_(pthread_attr_setdetachstate) (&a, PTHREAD_CREATE_DETACHED);
+      result = __gthrw_(pthread_create) (&t, &a, __gthread_start, NULL);
       if (result != ENOSYS)
-       {
-         __gthread_active = 1;
-         if (!result)
-           __gthrw_(pthread_join) (t, NULL);
-       }
+       __gthread_active = 1;
       else
        __gthread_active = 0;
+      __gthrw_(pthread_attr_destroy) (&a);
     }
   __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
 }
index df250d2bf4106a3e2aba7949677a0d2abdb392de..eb54c925f6f8d6c29599b53f4f676e67a07c74f8 100644 (file)
@@ -209,20 +209,20 @@ __gthread_active_init (void)
 {
   static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
   pthread_t t;
+  pthread_attr_t a;
   int result;
 
   __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
   if (__gthread_active < 0)
     {
-      result = __gthrw_(pthread_create) (&t, NULL, __gthread_start, NULL);
+      __gthrw_(pthread_attr_init) (&a);
+      __gthrw_(pthread_attr_setdetachstate) (&a, PTHREAD_CREATE_DETACHED);
+      result = __gthrw_(pthread_create) (&t, &a, __gthread_start, NULL);
       if (result != ENOSYS)
-       {
-         __gthread_active = 1;
-         if (!result)
-           __gthrw_(pthread_join) (t, NULL);
-       }
+       __gthread_active = 1;
       else
        __gthread_active = 0;
+      __gthrw_(pthread_attr_destroy) (&a);
     }
   __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
 }