.
[glibc.git] / elf / tst-tls4.c
blobf92ee53ce5542c334b173bfaa615d2cccf9df92b
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 #include <tls.h>
8 #define TEST_FUNCTION do_test ()
9 static int
10 do_test (void)
12 #ifdef USE_TLS
13 static const char modname[] = "tst-tlsmod2.so";
14 int result = 0;
15 int *foop;
16 int (*fp) (int, int *);
17 void *h;
19 h = dlopen (modname, RTLD_LAZY);
20 if (h == NULL)
22 printf ("cannot open '%s': %s\n", modname, dlerror ());
23 exit (1);
26 fp = dlsym (h, "in_dso");
27 if (fp == NULL)
29 printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
30 exit (1);
33 result |= fp (0, NULL);
35 foop = dlsym (h, "foo");
36 if (foop == NULL)
38 printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
39 exit (1);
41 if (*foop != 16)
43 puts ("foo != 16");
44 result = 1;
47 dlclose (h);
49 return result;
50 #else
51 return 0;
52 #endif
56 #include "../test-skeleton.c"