1 // RUN: %libomptarget-compilexx-run-and-check-generic 2 3 #include <cstdio> 4 #include <cstdlib> 5 #include <vector> 6 #include <cinttypes> 7 8 // Data structure definitions copied from OpenMP RTL. 9 struct MapComponentInfoTy { 10 void *Base; 11 void *Begin; 12 int64_t Size; 13 int64_t Type; 14 void *Name; 15 MapComponentInfoTy() = default; 16 MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type, void *Name) 17 : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {} 18 }; 19 20 struct MapperComponentsTy { 21 std::vector<MapComponentInfoTy> Components; 22 }; 23 24 // OpenMP RTL interfaces 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 int64_t __tgt_mapper_num_components(void *rt_mapper_handle); 29 void __tgt_push_mapper_component(void *rt_mapper_handle, void *base, 30 void *begin, int64_t size, int64_t type, 31 void *name); 32 #ifdef __cplusplus 33 } 34 #endif 35 36 int main(int argc, char *argv[]) { 37 MapperComponentsTy MC; 38 void *base, *begin; 39 int64_t size, type; 40 // Push 2 elements into MC. 41 __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr); 42 __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr); 43 int64_t num = __tgt_mapper_num_components((void *)&MC); 44 // CHECK: num=2 45 printf("num=%" PRId64 "\n", num); 46 return 0; 47 } 48