jit: handle equality of function pointer types
[official-gcc.git] / gcc / testsuite / jit.dg / verify-dynamic-library.c
blob99f9128bc660218f17dc1eb3fdc2a830f487c2f0
1 /* For use by jit-verify-dynamic-library, used by
2 test-compile-to-dynamic-library.c. */
3 #include <dlfcn.h>
4 #include <stdio.h>
5 #include <stdlib.h>
7 int
8 main (int argc, char **argv)
10 void *handle;
11 void (*hello_world) (const char *name);
12 char *error;
14 handle = dlopen ("./output-of-test-compile-to-dynamic-library.c.so",
15 RTLD_NOW | RTLD_LOCAL);
16 if (!handle)
18 fprintf (stderr, "dlopen failed: %s\n", dlerror());
19 exit (1);
22 /* Clear any existing error */
23 dlerror ();
25 /* This symbol is from the DSO built by
26 test-compile-to-dynamic-library.c. */
27 *(void **) (&hello_world) = dlsym (handle, "hello_world");
29 if ((error = dlerror()) != NULL)
31 fprintf (stderr, "dlsym failed: %s\n", error);
32 exit (2);
35 /* Call the function from the generated DSO. */
36 hello_world (argv[0]);
38 dlclose (handle);
40 return 0;