OSDN Git Service

test/nptl: rework tst-tls3 to link with -z,now
authorAustin Foxley <austinf@cetoncorp.com>
Mon, 30 Nov 2009 04:18:05 +0000 (20:18 -0800)
committerAustin Foxley <austinf@cetoncorp.com>
Mon, 30 Nov 2009 04:18:05 +0000 (20:18 -0800)
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
test/nptl/Makefile.in
test/nptl/tst-tls3.c
test/nptl/tst-tls3mod.c

index 6cde3d9..c6d832b 100644 (file)
@@ -95,7 +95,7 @@ LDFLAGS_tst-clock2 := -lrt
 LDFLAGS_tst-cond11 := -lrt
 LDFLAGS_tst-cond19 := -lrt
 LDFLAGS_tst-rwlock14 := -lrt
-LDFLAGS_tst-tls3 := -ldl -rdynamic
+LDFLAGS_tst-tls3 := -ldl -rdynamic tst-tls3mod.so
 LDFLAGS_tst-tls4 := -ldl
 LDFLAGS_tst-tls5 :=  tst-tls5mod.so
 LDFLAGS_tst-clock := -lrt
@@ -118,7 +118,7 @@ LDFLAGS_tst-timer2 := -lrt
 LDFLAGS_tst-timer3 := -lrt
 LDFLAGS_tst-timer4 := -lrt
 LDFLAGS_tst-timer5 := -lrt
-LDFLAGS_tst-tls3mod.so := -shared -static-libgcc
+LDFLAGS_tst-tls3mod.so := -shared -static-libgcc -lpthread
 LDFLAGS_tst-tls4moda.so := -shared -static-libgcc
 LDFLAGS_tst-tls4modb.so := -shared -static-libgcc
 LDFLAGS_tst-tls5mod.so := -shared -static-libgcc -Wl,-soname,tst-tls5mod.so
index 411acbd..abc5f4c 100644 (file)
@@ -113,6 +113,15 @@ do_test (void)
       exit (1);
     }
 
+  void (*setup_tf) (pthread_barrier_t*, int*, sem_t*) = dlsym(h, "setup_tf");
+  if (setup_tf == NULL)
+    {
+      puts ("dlsym for setup_tf failed");
+      exit(1);
+    }
+
+  setup_tf (&b, &nsigs, &s);
+
   struct sigaction sa;
   sa.sa_handler = dlsym (h, "handler");
   if (sa.sa_handler == NULL)
index 25f8924..53206d3 100644 (file)
 
 #if HAVE___THREAD
 
-extern pthread_barrier_t b;
+static pthread_barrier_t* b = NULL;
 
 #define TOTAL_SIGS 1000
-extern int nsigs;
-
-extern sem_t s;
+static int* nsigs = NULL;
 
+static sem_t* s = NULL;
 
 static __thread void (*fp) (void);
 
@@ -52,17 +51,30 @@ handler (int sig)
 
   fp ();
 
-  if (sem_post (&s) != 0)
+  if (sem_post (s) != 0)
     {
       write (STDOUT_FILENO, "sem_post failed\n", 16);
       _exit (1);
     }
 }
 
+void
+setup_tf (pthread_barrier_t* t_b, int* t_nsigs, sem_t* t_s)
+{
+  b = t_b;
+  nsigs = t_nsigs;
+  s = t_s;
+}
 
 void *
 tf (void *arg)
 {
+  if (!b || !s || !nsigs)
+    {
+      puts ("need to call setup_tf first");
+      exit (1);
+    }
+
   if ((uintptr_t) pthread_self () & (TCB_ALIGNMENT - 1))
     {
       puts ("thread's struct pthread not aligned enough");
@@ -71,18 +83,18 @@ tf (void *arg)
 
   if (fp != NULL)
     {
-printf("fp=%p\n", (void *)&fp);
+      printf("fp=%p\n", (void *)&fp);
       puts ("fp not initially NULL");
       exit (1);
     }
 
   fp = arg;
 
-  pthread_barrier_wait (&b);
+  pthread_barrier_wait (b);
 
-  pthread_barrier_wait (&b);
+  pthread_barrier_wait (b);
 
-  if (nsigs != TOTAL_SIGS)
+  if (*nsigs != TOTAL_SIGS)
     {
       puts ("barrier_wait prematurely returns");
       exit (1);