xref: /llvm-project/offload/test/Inputs/target-use-dev-ptr.c (revision d84d0caf28902843e0aae7ac435daed9aa04e3e2)
1 // Helper function used in Offload Fortran test
2 // target-use-dev-ptr.f90 to allocate data and
3 // check resulting addresses.
4 
5 #include <assert.h>
6 #include <malloc.h>
7 #include <stdio.h>
8 
9 int *get_ptr() {
10   int *ptr = malloc(sizeof(int));
11   assert(ptr && "malloc returned null");
12   return ptr;
13 }
14 
15 int check_result(int *host_ptr, int *dev_ptr) {
16   if (dev_ptr == NULL || dev_ptr == host_ptr) {
17     printf("FAILURE\n");
18     return -1;
19   } else {
20     printf("SUCCESS\n");
21     return 0;
22   }
23 }
24