28 lines · c
1// Helper function used in Offload Fortran test2// target-use-dev-ptr.f90 to allocate data and3// check resulting addresses.4 5#include <assert.h>6#include <malloc.h>7#include <stdio.h>8 9int *get_ptr() {10 int *ptr = malloc(sizeof(int));11 assert(ptr && "malloc returned null");12 return ptr;13}14 15int 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 25int check_equality(void *host_ptr, void *dev_ptr) {26 return dev_ptr == host_ptr;27}28