brintos

brintos / llvm-project-archived public Read only

0
0
Text · 735 B · 5393f33 Raw
35 lines · c
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-generic2 3#ifdef SHARED4#include <stdio.h>5int foo() {6#pragma omp target7  ;8  printf("%s\n", "DONE.");9  return 0;10}11#else12#include <dlfcn.h>13#include <stdio.h>14int main(int argc, char **argv) {15#pragma omp target16  ;17 18  void *Handle = dlopen(argv[1], RTLD_NOW);19  int (*Foo)(void);20 21  if (Handle == NULL) {22    printf("dlopen() failed: %s\n", dlerror());23    return 1;24  }25  Foo = (int (*)(void))dlsym(Handle, "foo");26  if (Handle == NULL) {27    printf("dlsym() failed: %s\n", dlerror());28    return 1;29  }30  // CHECK: DONE.31  // CHECK-NOT: {{abort|fault}}32  return Foo();33}34#endif35