Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / offloading / dynamic_module_load.c
blob5393f33e84f85d787baf6c898c6146cb1798264c
1 // RUN: %libomptarget-compile-generic -DSHARED -fPIC -shared -o %t.so && %clang %flags %s -o %t -ldl && %libomptarget-run-generic %t.so 2>&1 | %fcheck-generic
3 #ifdef SHARED
4 #include <stdio.h>
5 int foo() {
6 #pragma omp target
8 printf("%s\n", "DONE.");
9 return 0;
11 #else
12 #include <dlfcn.h>
13 #include <stdio.h>
14 int main(int argc, char **argv) {
15 #pragma omp target
18 void *Handle = dlopen(argv[1], RTLD_NOW);
19 int (*Foo)(void);
21 if (Handle == NULL) {
22 printf("dlopen() failed: %s\n", dlerror());
23 return 1;
25 Foo = (int (*)(void))dlsym(Handle, "foo");
26 if (Handle == NULL) {
27 printf("dlsym() failed: %s\n", dlerror());
28 return 1;
30 // CHECK: DONE.
31 // CHECK-NOT: {{abort|fault}}
32 return Foo();
34 #endif