1*24f836e8SJoachim Protze // RUN: %libomptarget-compilexx-run-and-check-generic
22c7a8eafSMichael Kruse 
32c7a8eafSMichael Kruse #include <cstdio>
42c7a8eafSMichael Kruse #include <cstdlib>
5c10180edSAlexey Bataev #include <vector>
6140ab574SGeorge Rokos #include <cinttypes>
72c7a8eafSMichael Kruse 
82c7a8eafSMichael Kruse // Data structure definitions copied from OpenMP RTL.
92c7a8eafSMichael Kruse struct MapComponentInfoTy {
102c7a8eafSMichael Kruse   void *Base;
112c7a8eafSMichael Kruse   void *Begin;
122c7a8eafSMichael Kruse   int64_t Size;
132c7a8eafSMichael Kruse   int64_t Type;
14e4eaf9d8SJoseph Huber   void *Name;
152c7a8eafSMichael Kruse   MapComponentInfoTy() = default;
MapComponentInfoTyMapComponentInfoTy16e4eaf9d8SJoseph Huber   MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type, void *Name)
17e4eaf9d8SJoseph Huber       : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {}
182c7a8eafSMichael Kruse };
192c7a8eafSMichael Kruse 
202c7a8eafSMichael Kruse struct MapperComponentsTy {
212c7a8eafSMichael Kruse   std::vector<MapComponentInfoTy> Components;
222c7a8eafSMichael Kruse };
232c7a8eafSMichael Kruse 
242c7a8eafSMichael Kruse // OpenMP RTL interfaces
252c7a8eafSMichael Kruse #ifdef __cplusplus
262c7a8eafSMichael Kruse extern "C" {
272c7a8eafSMichael Kruse #endif
282c7a8eafSMichael Kruse int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
292c7a8eafSMichael Kruse void __tgt_push_mapper_component(void *rt_mapper_handle, void *base,
30e4eaf9d8SJoseph Huber                                  void *begin, int64_t size, int64_t type,
31e4eaf9d8SJoseph Huber                                  void *name);
322c7a8eafSMichael Kruse #ifdef __cplusplus
332c7a8eafSMichael Kruse }
342c7a8eafSMichael Kruse #endif
352c7a8eafSMichael Kruse 
main(int argc,char * argv[])362c7a8eafSMichael Kruse int main(int argc, char *argv[]) {
372c7a8eafSMichael Kruse   MapperComponentsTy MC;
382c7a8eafSMichael Kruse   void *base, *begin;
392c7a8eafSMichael Kruse   int64_t size, type;
402c7a8eafSMichael Kruse   // Push 2 elements into MC.
41e4eaf9d8SJoseph Huber   __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
42e4eaf9d8SJoseph Huber   __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
432c7a8eafSMichael Kruse   int64_t num = __tgt_mapper_num_components((void *)&MC);
442c7a8eafSMichael Kruse   // CHECK: num=2
45140ab574SGeorge Rokos   printf("num=%" PRId64 "\n", num);
462c7a8eafSMichael Kruse   return 0;
472c7a8eafSMichael Kruse }
48