Fix TLS access for -static -pthread
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.threads / staticthreads.c
index 87e92d2ea7c5a9fbc388eced409028efb0778551..5c8eabea47ed6f1e40c434f668562e9c1ff273a4 100644 (file)
@@ -1,6 +1,6 @@
 /* This test program is part of GDB, The GNU debugger.
 
-   Copyright 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 2004-2014 Free Software Foundation, Inc.
 
    Originally written by Jeff Johnston <jjohnstn@redhat.com>,
    contributed by Red Hat
 
 sem_t semaphore;
 
+#ifdef HAVE_TLS
+__thread int tlsvar;
+#endif
+
 void *
 thread_function (void *arg)
 {
-  printf ("Thread executing\n");
+#ifdef HAVE_TLS
+  tlsvar = 2;
+#endif
+  printf ("Thread executing\n"); /* tlsvar-is-set */
   while (sem_wait (&semaphore) != 0)
     {
       if (errno != EINTR)
        {
          perror ("thread_function");
-         return;
+         return NULL;
        }
     }
   return NULL;
@@ -57,6 +64,9 @@ main (int argc, char **argv)
       return -1;
     }
 
+#ifdef HAVE_TLS
+  tlsvar = 1;
+#endif
 
   /* Create a thread, wait for it to complete.  */
   {
This page took 0.025612 seconds and 4 git commands to generate.