Replace long int with __syscall_slong_t in sys/msg.h
[glibc.git] / elf / tst-dlmopen1.c
blob9839267d8f1d231c36a63ec501e77739b4ad0896
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <gnu/lib-names.h>
6 static int
7 do_test (void)
9 void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
10 if (h == NULL)
12 printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
13 return 1;
16 Lmid_t ns = -10;
17 if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
19 printf ("dlinfo for %s in %s failed: %s\n",
20 LIBC_SO, __func__, dlerror ());
21 return 1;
24 if (ns != LM_ID_BASE)
26 printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
27 return 1;
30 if (dlclose (h) != 0)
32 printf ("dlclose for %s in %s failed: %s\n",
33 LIBC_SO, __func__, dlerror ());
34 return 1;
37 h = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", RTLD_LAZY);
38 if (h == NULL)
40 printf ("cannot get handle for %s: %s\n",
41 "tst-dlmopen1mod.so", dlerror ());
42 return 1;
45 ns = -10;
46 if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
48 printf ("dlinfo for %s in %s failed: %s\n",
49 "tst-dlmopen1mod.so", __func__, dlerror ());
50 return 1;
53 if (ns == LM_ID_BASE)
55 printf ("namespace for %s is LM_ID_BASE\n", LIBC_SO);
56 return 1;
59 int (*fct) (Lmid_t) = dlsym (h, "foo");
60 if (fct == NULL)
62 printf ("could not find %s: %s\n", "foo", dlerror ());
63 return 1;
66 if (fct (ns) != 0)
67 return 1;
69 if (dlclose (h) != 0)
71 printf ("dlclose for %s in %s failed: %s\n",
72 LIBC_SO, __func__, dlerror ());
73 return 1;
76 return 0;
79 #define TEST_FUNCTION do_test ()
80 #include "../test-skeleton.c"