elf/dl-lookup.c: Use __glibc_likely and __glibc_unlikely
[glibc.git] / elf / tst-tls5.c
blob76905c56db0422a456f5bb6910a793579a273d12
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
6 #define TEST_FUNCTION do_test ()
7 static int
8 do_test (void)
10 static const char modname[] = "tst-tlsmod2.so";
11 int result = 0;
12 int *foop;
13 int *foop2;
14 int (*fp) (int, int *);
15 void *h;
17 h = dlopen (modname, RTLD_LAZY);
18 if (h == NULL)
20 printf ("cannot open '%s': %s\n", modname, dlerror ());
21 exit (1);
24 foop = dlsym (h, "foo");
25 if (foop == NULL)
27 printf ("cannot get symbol 'foo': %s\n", dlerror ());
28 exit (1);
31 *foop = 42;
33 fp = dlsym (h, "in_dso");
34 if (fp == NULL)
36 printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
37 exit (1);
40 result |= fp (42, foop);
42 foop2 = dlsym (h, "foo");
43 if (foop2 == NULL)
45 printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
46 exit (1);
49 if (foop != foop2)
51 puts ("address of 'foo' different the second time");
52 result = 1;
54 else if (*foop != 16)
56 puts ("foo != 16");
57 result = 1;
60 dlclose (h);
62 return result;
66 #include "../test-skeleton.c"