xref: /llvm-project/offload/test/offloading/shared_lib_fp_mapping.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // clang-format off
2 // RUN: %clang-generic -fPIC -shared %S/../Inputs/declare_indirect_func.c -o %T/libslfm.so  -fopenmp-version=51
3 // RUN: %libomptarget-compile-generic -rpath %T -L %T -l slfm -o %t  -fopenmp-version=51
4 // RUN: env LIBOMPTARGET_INFO=32 %t 2>&1 | %fcheck-generic
5 // clang-format on
6 
7 #include <stdio.h>
8 
9 extern int func(); // Provided in liba.so, returns 42
10 typedef int (*fp_t)();
11 
main()12 int main() {
13   int x = 0;
14   fp_t fp = &func;
15   printf("TARGET\n");
16 #pragma omp target map(from : x)
17   x = fp();
18   // CHECK: Copying data from device to host, {{.*}} Size=8
19   // CHECK: Copying data from device to host, {{.*}} Size=4
20   // CHECK: 42
21   printf("%i\n", x);
22 }
23