Initialized merge tracking via "svnmerge" with revisions "1-209303" from
[official-gcc.git] / gcc-4_9 / gcc / testsuite / g++.dg / dso / dlclose1.C
blob80f270c20596fd511de6a3bccb2a8fb76ee88b62
1 // PR c++/60731
2 // { dg-do run { target { dlopen && disable-for-4.9 } } }
3 // { dg-add-options dlopen }
4 // { dg-build-dso "dlclose1-dso.cc" }
6 #include <dlfcn.h>
7 extern "C" void abort();
8 extern "C" int printf (const char *, ...);
10 // Open and close the DSO for each call so that statics are reinitialized.
11 int call()
13   void *h = dlopen ("./dlclose1-dso.so", RTLD_NOW);
14   if (!h) { printf ("dlopen failed: %s\n", dlerror()); abort(); }
15   int (*fn)() = (int(*)())dlsym (h, "fn");
16   if (!fn) { printf ("dlsym failed: %s\n", dlerror()); abort(); }
17   int r = fn();
18   dlclose (h);
19   return r;
22 int main() {
23   int i = call();
24   int j = call();
25   if (i != j)
26     {
27       printf ("mismatch: %d != %d\n", i, j);
28       abort();
29     }