summaryrefslogtreecommitdiff
path: root/devel/gettext-tools/files/patch-libgettextpo_glthread_threadlib.c
blob: ac8184e478c340c41fc773b79a4cadf746ba942e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--- libgettextpo/glthread/threadlib.c.orig	2014-07-14 07:29:10 UTC
+++ libgettextpo/glthread/threadlib.c
@@ -29,11 +29,10 @@
 
 # if PTHREAD_IN_USE_DETECTION_HARD
 
-/* The function to be executed by a dummy thread.  */
-static void *
-dummy_thread_func (void *arg)
+static pthread_once_t dummy_once_control = PTHREAD_ONCE_INIT;
+static void
+dummy_once_func (void)
 {
-  return arg;
 }
 
 int
@@ -44,19 +43,10 @@ glthread_in_use (void)
 
   if (!tested)
     {
-      pthread_t thread;
-
-      if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
-        /* Thread creation failed.  */
+      if (pthread_once (&dummy_once_control, dummy_once_func) != 0)
         result = 0;
       else
-        {
-          /* Thread creation works.  */
-          void *retval;
-          if (pthread_join (thread, &retval) != 0)
-            abort ();
-          result = 1;
-        }
+        result = 1;
       tested = 1;
     }
   return result;