libgomp: defined OMPD library-wide functions.

Message ID 20200701152801.1994985-1-y2s1982@gmail.com
State New
Headers show
Series
  • libgomp: defined OMPD library-wide functions.
Related show

Commit Message

Jakub Jelinek via Gcc-patches July 1, 2020, 3:28 p.m.
This patch provides an initial set of definition for the rest of library-wide OMPD functions.

It addresses all feedbacks.

2020-07-01  Tony Sim  <y2s1982@gmail.com>

libgomp/ChangeLog:

	* libgompd.h: Include omp-tools.h.
	(gompd_callbacks): New extern declaration.
	* ompd-lib.c (gompd_callbacks): New declaration.
	(ompd_initialized): New declaration.
	(ompd_initialize): Checks callbacks and assigns it to gompd_callbacks.
	(ompd_finalize): Add new function.

---
 libgomp/libgompd.h |  4 ++++
 libgomp/ompd-lib.c | 16 ++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

-- 
2.27.0

Patch

diff --git a/libgomp/libgompd.h b/libgomp/libgompd.h
index 9782828bff5..3a428e1c1e4 100644
--- a/libgomp/libgompd.h
+++ b/libgomp/libgompd.h
@@ -29,9 +29,13 @@ 
 #ifndef LIBGOMPD_H
 #define LIBGOMPD_H 1
 
+#include "omp-tools.h"
+
 #define ompd_stringify(x) ompd_str2(x)
 #define ompd_str2(x) #x
 
 #define OMPD_VERSION 201811
 
+extern ompd_callbacks_t gompd_callbacks;
+
 #endif /* LIBGOMPD_H */
diff --git a/libgomp/ompd-lib.c b/libgomp/ompd-lib.c
index f0ae9e85a7e..d5350e1045c 100644
--- a/libgomp/ompd-lib.c
+++ b/libgomp/ompd-lib.c
@@ -29,6 +29,9 @@ 
 #include "omp-tools.h"
 #include "libgompd.h"
 
+ompd_callbacks_t gompd_callbacks;
+static int ompd_initialized = 0;
+
 ompd_rc_t
 ompd_get_api_version (ompd_word_t *version)
 {
@@ -47,15 +50,24 @@  ompd_get_version_string (const char **string)
 ompd_rc_t
 ompd_initialize (ompd_word_t api_version, const ompd_callbacks_t *callbacks)
 {
-  static int ompd_initialized = 0;
+  if (!callbacks)
+    return ompd_rc_bad_input;
 
   if (ompd_initialized)
     return ompd_rc_error;
 
+  gompd_callbacks = *callbacks;
+
   (void) api_version;
-  (void) callbacks;
 
   ompd_initialized = 1;
 
   return ompd_rc_ok;
 }
+
+ompd_rc_t
+ompd_finalize (void)
+{
+  ompd_initialized = 0;
+  return ompd_rc_ok;
+}