This patch adds some unit tests for omp-tools.h header. It also adds some simple
functions related to OMPD API versions. It also partially defines the OMPD
initialization function. More OMPD configuration is also added into Makefile.am.

2020-06-24  Tony Sim  <y2s1...@gmail.com>

libgomp/ChangeLog:

        * Makefile.am(toolexeclib_LTLIBRARIES): Add libgompd.la.
        (libgompd_la_LDFLAGS, libgompd_la_DEPENDENCIES, libgompd_la_LINK,
        libgompd_la_SOURCES, libgompd_version_dep, libgompd_version_script,
        libgompd.ver-sun, libgompd.ver, libgompd_version_info): Set.
        * Makefile.in: Regnerate.
        * config/darwin/plugin-suffix.h (SONAME_SUFFIX): Remove ().
        * config/hpux/plugin-suffix.h (SONAME_SUFFIX): Remove ().
        * config/posix/plugin-suffix.h (SONAME_SUFFIX): Remove ().
        * omp-tools.h: Comment out ompd_dll_locations.
        * testsuite/Makefile.in: Regnerate.
        * libgompd.h: New file.
        * libgompd.map: New file.
        * libgompd.s: New file.
        * ompd-lib.c: New file.
        * testsuite/libgomp.ompd/header-1.c: New test.
        * testsuite/libgomp.ompd/header-order-1.c: New test.
        * testsuite/libgomp.ompd/header-order-2.c: New test.
        * testsuite/libgomp.ompd/ompd.exp: New test.

---
 libgomp/Makefile.am                           | 29 +++++++-
 libgomp/Makefile.in                           | 39 ++++++++++-
 libgomp/config/darwin/plugin-suffix.h         |  2 +-
 libgomp/config/hpux/plugin-suffix.h           |  2 +-
 libgomp/config/posix/plugin-suffix.h          |  2 +-
 libgomp/libgompd.h                            | 37 +++++++++++
 libgomp/libgompd.map                          | 49 ++++++++++++++
 libgomp/libgompd.s                            |  1 +
 libgomp/omp-tools.h                           |  2 +-
 libgomp/ompd-lib.c                            | 66 +++++++++++++++++++
 libgomp/testsuite/Makefile.in                 |  1 +
 libgomp/testsuite/libgomp.ompd/header-1.c     | 10 +++
 .../testsuite/libgomp.ompd/header-order-1.c   | 11 ++++
 .../testsuite/libgomp.ompd/header-order-2.c   | 11 ++++
 libgomp/testsuite/libgomp.ompd/ompd.exp       | 38 +++++++++++
 15 files changed, 291 insertions(+), 9 deletions(-)
 create mode 100644 libgomp/libgompd.h
 create mode 100644 libgomp/libgompd.map
 create mode 100644 libgomp/libgompd.s
 create mode 100644 libgomp/ompd-lib.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-1.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-order-1.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-order-2.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/ompd.exp

diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 4d31f4cef46..e15a838e55c 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS = $(addprefix -I, $(search_path))
 AM_CFLAGS = $(XCFLAGS)
 AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
 
-toolexeclib_LTLIBRARIES = libgomp.la
+toolexeclib_LTLIBRARIES = libgomp.la libgompd.la
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB
@@ -31,14 +31,21 @@ PREPROCESS = $(subst -Wc$(comma), , $(COMPILE)) -E
 libgomp.ver: $(top_srcdir)/libgomp.map
        $(EGREP) -v '#(#| |$$)' $< | \
          $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
+libgompd.ver: $(top_srcdir)/libgompd.map
+       $(EGREP) -v '#(#| |$$)' $< | \
+         $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB_GNU
 libgomp_version_script = -Wl,--version-script,libgomp.ver
+libgompd_version_script = -Wl,--version-script,libgompd.ver
 libgomp_version_dep = libgomp.ver
+libgompd_version_dep = libgompd.ver
 endif
 if LIBGOMP_BUILD_VERSIONED_SHLIB_SUN
 libgomp_version_script = -Wl,-M,libgomp.ver-sun
+libgompd_version_script = -Wl,-M,libgompd.ver-sun
 libgomp_version_dep = libgomp.ver-sun
+libgompd_version_dep = libgompd.ver-sun
 libgomp.ver-sun : libgomp.ver \
                $(top_srcdir)/../contrib/make_sunver.pl \
                $(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
@@ -48,16 +55,32 @@ libgomp.ver-sun : libgomp.ver \
         `echo $(libgomp_la_LIBADD) | \
            sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
         > $@ || (rm -f $@ ; exit 1)
+libgompd.ver-sun : libgompd.ver \
+               $(top_srcdir)/../contrib/make_sunver.pl \
+               $(libgompd_la_OBJECTS) $(libgompd_la_LIBADD)
+       perl $(top_srcdir)/../contrib/make_sunver.pl \
+         libgompd.ver \
+         $(libgompd_la_OBJECTS:%.lo=.libs/%.o) \
+        `echo $(libgompd_la_LIBADD) | \
+           sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+        > $@ || (rm -f $@ ; exit 1)
 endif
 else
 libgomp_version_script =
+libgompd_version_script =
 libgomp_version_dep =
+libgompd_version_dep =
 endif
 libgomp_version_info = -version-info $(libtool_VERSION)
+libgompd_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
-        $(lt_host_flags)
+       $(lt_host_flags)
+libgompd_la_LDFLAGS = $(libgompd_version_info) $(libgompd_version_script) \
+       $(lt_host_flags)
 libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
+libgompd_la_DEPENDENCIES = $(libgompd_version_dep)
 libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
+libgompd_la_LINK = $(LINK) $(libgompd_la_LDFLAGS)
 
 libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.c error.c \
        icv.c icv-device.c iter.c iter_ull.c loop.c loop_ull.c ordered.c \
@@ -67,6 +90,8 @@ libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c 
env.c error.c \
        oacc-mem.c oacc-async.c oacc-plugin.c oacc-cuda.c priority_queue.c \
        affinity-fmt.c teams.c allocator.c oacc-profiling.c oacc-target.c
 
+libgompd_la_SOURCES = ompd-lib.c
+
 include $(top_srcdir)/plugin/Makefrag.am
 
 if USE_FORTRAN
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 3ca1be0d73e..af897d6c6ba 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -234,6 +234,9 @@ am_libgomp_la_OBJECTS = alloc.lo atomic.lo barrier.lo 
critical.lo \
        teams.lo allocator.lo oacc-profiling.lo oacc-target.lo \
        $(am__objects_1)
 libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS)
+libgompd_la_LIBADD =
+am_libgompd_la_OBJECTS = ompd-lib.lo
+libgompd_la_OBJECTS = $(am_libgompd_la_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -282,7 +285,8 @@ am__v_FCLD_0 = @echo "  FCLD    " $@;
 am__v_FCLD_1 = 
 SOURCES = $(libgomp_plugin_gcn_la_SOURCES) \
        $(libgomp_plugin_hsa_la_SOURCES) \
-       $(libgomp_plugin_nvptx_la_SOURCES) $(libgomp_la_SOURCES)
+       $(libgomp_plugin_nvptx_la_SOURCES) $(libgomp_la_SOURCES) \
+       $(libgompd_la_SOURCES)
 AM_V_DVIPS = $(am__v_DVIPS_@AM_V@)
 am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@)
 am__v_DVIPS_0 = @echo "  DVIPS   " $@;
@@ -548,8 +552,8 @@ libsubincludedir = 
$(libdir)/gcc/$(target_alias)/$(gcc_version)/include
 AM_CPPFLAGS = $(addprefix -I, $(search_path))
 AM_CFLAGS = $(XCFLAGS)
 AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
-toolexeclib_LTLIBRARIES = libgomp.la $(am__append_1) $(am__append_2) \
-       $(am__append_3)
+toolexeclib_LTLIBRARIES = libgomp.la libgompd.la $(am__append_1) \
+       $(am__append_2) $(am__append_3)
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 # -Wc is only a libtool option.
@@ -558,15 +562,27 @@ nodist_toolexeclib_HEADERS = libgomp.spec
 @LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgomp_version_script = 
 
@LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_script
 = -Wl,--version-script,libgomp.ver
 
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_script
 = -Wl,-M,libgomp.ver-sun
+@LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgompd_version_script = 
+@LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_script
 = -Wl,--version-script,libgompd.ver
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_script
 = -Wl,-M,libgompd.ver-sun
 @LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgomp_version_dep = 
 
@LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep
 = libgomp.ver
 
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep
 = libgomp.ver-sun
+@LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgompd_version_dep = 
+@LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_dep
 = libgompd.ver
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_dep
 = libgompd.ver-sun
 libgomp_version_info = -version-info $(libtool_VERSION)
+libgompd_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
         $(lt_host_flags)
 
+libgompd_la_LDFLAGS = $(libgompd_version_info) $(libgompd_version_script) \
+        $(lt_host_flags)
+
 libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
+libgompd_la_DEPENDENCIES = $(libgompd_version_dep)
 libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
+libgompd_la_LINK = $(LINK) $(libgompd_la_LDFLAGS)
 libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.c \
        error.c icv.c icv-device.c iter.c iter_ull.c loop.c loop_ull.c \
        ordered.c parallel.c sections.c single.c task.c team.c work.c \
@@ -576,6 +592,7 @@ libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c 
env.c \
        oacc-async.c oacc-plugin.c oacc-cuda.c priority_queue.c \
        affinity-fmt.c teams.c allocator.c oacc-profiling.c \
        oacc-target.c $(am__append_4)
+libgompd_la_SOURCES = ompd-lib.c
 
 # Nvidia PTX OpenACC plugin.
 @PLUGIN_NVPTX_TRUE@libgomp_plugin_nvptx_version_info = -version-info 
$(libtool_VERSION)
@@ -758,6 +775,9 @@ libgomp-plugin-nvptx.la: $(libgomp_plugin_nvptx_la_OBJECTS) 
$(libgomp_plugin_nvp
 libgomp.la: $(libgomp_la_OBJECTS) $(libgomp_la_DEPENDENCIES) 
$(EXTRA_libgomp_la_DEPENDENCIES) 
        $(AM_V_GEN)$(libgomp_la_LINK) -rpath $(toolexeclibdir) 
$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD) $(LIBS)
 
+libgompd.la: $(libgompd_la_OBJECTS) $(libgompd_la_DEPENDENCIES) 
$(EXTRA_libgompd_la_DEPENDENCIES) 
+       $(AM_V_GEN)$(libgompd_la_LINK) -rpath $(toolexeclibdir) 
$(libgompd_la_OBJECTS) $(libgompd_la_LIBADD) $(LIBS)
+
 mostlyclean-compile:
        -rm -f *.$(OBJEXT)
 
@@ -796,6 +816,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oacc-plugin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oacc-profiling.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oacc-target.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-lib.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordered.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/priority_queue.Plo@am__quote@
@@ -1404,6 +1425,9 @@ vpath % $(strip $(search_path))
 @libgomp_build_versioned_shlib_t...@libgomp.ver: $(top_srcdir)/libgomp.map
 @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   $(EGREP) -v '#(#| |$$)' $< | \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@     $(PREPROCESS) -P -include config.h - 
> $@ || (rm -f $@ ; exit 1)
+@libgomp_build_versioned_shlib_t...@libgompd.ver: $(top_srcdir)/libgompd.map
+@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   $(EGREP) -v '#(#| |$$)' $< | \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@     $(PREPROCESS) -P -include config.h - 
> $@ || (rm -f $@ ; exit 1)
 
@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@libgomp_build_versioned_shlib_t...@libgomp.ver-sun
 : libgomp.ver \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
        $(top_srcdir)/../contrib/make_sunver.pl \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
        $(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
@@ -1413,6 +1437,15 @@ vpath % $(strip $(search_path))
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
 `echo $(libgomp_la_LIBADD) | \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
 > $@ || (rm -f $@ ; exit 1)
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@libgomp_build_versioned_shlib_t...@libgompd.ver-sun
 : libgompd.ver \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
        $(top_srcdir)/../contrib/make_sunver.pl \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
        $(libgompd_la_OBJECTS) $(libgompd_la_LIBADD)
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
perl $(top_srcdir)/../contrib/make_sunver.pl \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
  libgompd.ver \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
  $(libgompd_la_OBJECTS:%.lo=.libs/%.o) \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
 `echo $(libgompd_la_LIBADD) | \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@   
 > $@ || (rm -f $@ ; exit 1)
 
 omp_lib_kinds.mod: omp_lib.mod
        :
diff --git a/libgomp/config/darwin/plugin-suffix.h 
b/libgomp/config/darwin/plugin-suffix.h
index 171a7a8113e..19e6ebeb04a 100644
--- a/libgomp/config/darwin/plugin-suffix.h
+++ b/libgomp/config/darwin/plugin-suffix.h
@@ -23,4 +23,4 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define SONAME_SUFFIX(n) ("." #n ".dylib")
+#define SONAME_SUFFIX(n) "." #n ".dylib"
diff --git a/libgomp/config/hpux/plugin-suffix.h 
b/libgomp/config/hpux/plugin-suffix.h
index 29e1f12726c..71c062ec696 100644
--- a/libgomp/config/hpux/plugin-suffix.h
+++ b/libgomp/config/hpux/plugin-suffix.h
@@ -23,4 +23,4 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define SONAME_SUFFIX(n) (".sl." #n)
+#define SONAME_SUFFIX(n) ".sl." #n
diff --git a/libgomp/config/posix/plugin-suffix.h 
b/libgomp/config/posix/plugin-suffix.h
index d111e529b84..20c4ab8f988 100644
--- a/libgomp/config/posix/plugin-suffix.h
+++ b/libgomp/config/posix/plugin-suffix.h
@@ -23,4 +23,4 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define SONAME_SUFFIX(n) (".so." #n)
+#define SONAME_SUFFIX(n) ".so." #n
diff --git a/libgomp/libgompd.h b/libgomp/libgompd.h
new file mode 100644
index 00000000000..138a8f600b9
--- /dev/null
+++ b/libgomp/libgompd.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Yoosuk Sim <y2s1...@gmail.com>.
+
+   This file is part of the GNU Offloading and Multi Processing Library
+   (libgomp).
+
+   Libgomp is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This file contains various macros and auxiliary function declarations
+   for OMPD library.  */
+
+#ifndef LIBGOMPD_H
+#define LIBGOMPD_H 1
+
+#define ompd_str1(x) ompd_str2(x)
+#define ompd_str2(x) #x
+
+#define OMPD_VERSION 201811
+
+#endif /* LIBGOMPD_H */
diff --git a/libgomp/libgompd.map b/libgomp/libgompd.map
new file mode 100644
index 00000000000..b70c3ca43e5
--- /dev/null
+++ b/libgomp/libgompd.map
@@ -0,0 +1,49 @@
+OMPD_5.0 {
+  global:
+       ompd_dll_locations_valid;
+       ompd_bp_parallel_begin;
+       ompd_bp_parallel_end;
+       ompd_bp_task_begin;
+       ompd_bp_task_end;
+       ompd_bp_thread_begin;
+       ompd_bp_thread_end;
+       ompd_bp_device_begin;
+       ompd_bp_device_end;
+       ompd_initialize;
+       ompd_get_api_version;
+       ompd_get_version_string;
+       ompd_get_finalize;
+       ompd_process_initialize;
+       ompd_device_initialize;
+       ompd_rel_address_space_handle;
+       ompd_get_omp_version;
+       ompd_get_omp_version_string;
+       ompd_get_thread_in_parallel;
+       ompd_get_thread_handle;
+       ompd_rel_thread_handle;
+       ompd_thread_handle_compare;
+       ompd_get_thread_id;
+       ompd_get_curr_parallel_handle;
+       ompd_get_enclosing_parallel_handle;
+       ompd_get_task_parallel_handle;
+       ompd_rel_parallel_handle;
+       ompd_parallel_handle_compare;
+       ompd_get_curr_task_handle;
+       ompd_get_generating_task_handle;
+       ompd_get_scheduling_task_handle;
+       ompd_get_task_in_parallel;
+       ompd_rel_task_handle;
+       ompd_task_handle_compare;
+       ompd_get_task_function;
+       ompd_get_task_frame;
+       ompd_enumerate_states;
+       ompd_get_state;
+       ompd_get_display_control_vars;
+       ompd_rel_display_control_vars;
+       ompd_enumerate_icvs;
+       ompd_get_icv_from_scope;
+       ompd_get_icv_string_from_scope;
+       ompd_get_tool_data;
+  local:
+       *;
+};
diff --git a/libgomp/libgompd.s b/libgomp/libgompd.s
new file mode 100644
index 00000000000..a648bedf3c7
--- /dev/null
+++ b/libgomp/libgompd.s
@@ -0,0 +1 @@
+       .file   "libgompd.c"
diff --git a/libgomp/omp-tools.h b/libgomp/omp-tools.h
index 394c33e40dd..b6b8c5295a5 100644
--- a/libgomp/omp-tools.h
+++ b/libgomp/omp-tools.h
@@ -101,7 +101,7 @@ typedef struct ompd_device_type_sizes_t {
 } ompd_device_type_sizes_t;
 
 
-const char **ompd_dll_locations;
+//const char **ompd_dll_locations;
 
 void ompd_dll_locations_valid (void) __GOMPD_NOTHROW;
 
diff --git a/libgomp/ompd-lib.c b/libgomp/ompd-lib.c
new file mode 100644
index 00000000000..d653add9ade
--- /dev/null
+++ b/libgomp/ompd-lib.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Yoosuk Sim <y2s1...@gmail.com>.
+
+   This file is part of the GNU Offloading and Multi Processing Library
+   (libgomp).
+
+   Libgomp is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This file contains function definitions for OMPD's per-library functions
+   defined in the OpenMP 5.0 API Documentation, 5.5.1.  */
+
+#include <stddef.h>
+#include "omp-tools.h"
+#include "libgompd.h"
+#include "plugin-suffix.h"
+
+
+const char *ompd_dll_locations[2] = { "libgompd" SONAME_SUFFIX (1), NULL };
+
+ompd_rc_t
+ompd_get_api_version (ompd_word_t *version)
+{
+  *version = OMPD_VERSION;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+ompd_get_version_string (const char **string)
+{
+  *string = "GNU OpenMP Runtime implementing OpenMP 5.0" 
ompd_str2(OMPD_VERSION);
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+ompd_initialize (ompd_word_t api_version, const ompd_callbacks_t *callbacks)
+{
+  /* initialized flag */
+  static int ompd_initialized = 0;
+
+  if (ompd_initialized)
+    return ompd_rc_error;
+
+  /* initialize here */
+
+  /* set initialized flag */
+  ompd_initialized = 1;
+
+  return ompd_rc_ok;
+}
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 52aa6c5fbc9..845dedc80b6 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -295,6 +295,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
+tmake_file = @tmake_file@
 toolexecdir = @toolexecdir@
 toolexeclibdir = @toolexeclibdir@
 top_build_prefix = @top_build_prefix@
diff --git a/libgomp/testsuite/libgomp.ompd/header-1.c 
b/libgomp/testsuite/libgomp.ompd/header-1.c
new file mode 100644
index 00000000000..5fb20d40402
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/header-1.c
@@ -0,0 +1,10 @@
+/*  Test that the omp-tools.h will compile successfully.  */
+
+/* { dg-do compile } */
+#include "omp-tools.h"
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.ompd/header-order-1.c 
b/libgomp/testsuite/libgomp.ompd/header-order-1.c
new file mode 100644
index 00000000000..a3aa60166ec
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/header-order-1.c
@@ -0,0 +1,11 @@
+/*  Test that the omp-tools.h will compile successfully with omp.h .  */
+
+/* { dg-do compile } */
+#include "omp-tools.h"
+#include "omp.h"
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.ompd/header-order-2.c 
b/libgomp/testsuite/libgomp.ompd/header-order-2.c
new file mode 100644
index 00000000000..12a5da3dfc6
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/header-order-2.c
@@ -0,0 +1,11 @@
+/*  Test that the omp-tools.h will compile successfully with omp.h .  */
+
+/* { dg-do compile } */
+#include "omp.h"
+#include "omp-tools.h"
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.ompd/ompd.exp 
b/libgomp/testsuite/libgomp.ompd/ompd.exp
new file mode 100644
index 00000000000..1df981c186e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/ompd.exp
@@ -0,0 +1,38 @@
+if [info exists lang_library_path] then {
+    unset lang_library_path
+    unset lang_link_flags
+}
+if [info exists lang_test_file] then {
+    unset lang_test_file
+}
+if [info exists lang_include_flags] then {
+    unset lang_include_flags
+}
+
+load_lib libgomp-dg.exp
+load_gcc_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS "-O2"
+}
+
+# Initialize dg.
+dg-init
+
+# Turn on OpenMP.
+lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+
+# Gather a list of all tests.
+set tests [lsort [concat \
+                     [find $srcdir/$subdir *.c]]]
+
+set ld_library_path $always_ld_library_path
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+# Main loop.
+dg-runtest $tests "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
-- 
2.26.2

Reply via email to