Fix copy&paste error.
[glibc/history.git] / elf / tst-tls5.c
bloba571d2cd3fa9685cad18c520e39f010e6914f9ec
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 *foop2;
17 int (*fp) (int, int *);
18 void *h;
20 h = dlopen (modname, RTLD_LAZY);
21 if (h == NULL)
23 printf ("cannot open '%s': %s\n", modname, dlerror ());
24 exit (1);
27 foop = dlsym (h, "foo");
28 if (foop == NULL)
30 printf ("cannot get symbol 'foo': %s\n", dlerror ());
31 exit (1);
34 *foop = 42;
36 fp = dlsym (h, "in_dso");
37 if (fp == NULL)
39 printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
40 exit (1);
43 result |= fp (42, foop);
45 foop2 = dlsym (h, "foo");
46 if (foop2 == NULL)
48 printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
49 exit (1);
52 if (foop != foop2)
54 puts ("address of 'foo' different the second time");
55 result = 1;
57 else if (*foop != 16)
59 puts ("foo != 16");
60 result = 1;
63 dlclose (h);
65 return result;
66 #else
67 return 0;
68 #endif
72 #include "../test-skeleton.c"