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