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(size: 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(format: "FAILURE\n"); |
18 | return -1; |
19 | } else { |
20 | printf(format: "SUCCESS\n"); |
21 | return 0; |
22 | } |
23 | } |
24 | |
25 | int check_equality(void *host_ptr, void *dev_ptr) { |
26 | return dev_ptr == host_ptr; |
27 | } |
28 |