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