diff mbox

[01/03] Move gcc_jit_result implementation to a new files jit-result.{h|c}

Message ID 1416966320-15713-2-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Nov. 26, 2014, 1:45 a.m. UTC
Whilst investigating another issue I found I had trouble locating
the gcc::jit::result class.  It turned out to be declared in
jit-recording.h, but implemented in jit-playback.c.

Move it to new files: jit-result.{h|c}

gcc/jit/ChangeLog:
	* Make-lang.in (jit_OBJS): Add jit/jit-result.o.
	* jit-playback.c: Include new header jit-result.h.
	(gcc::jit::result::result): Move to new file jit-result.c.
	(gcc::jit::result::~result): Likewise.
	(gcc::jit::playback::result): Likewise.
	* jit-recording.h (class gcc::jit::result): Move to new
	header jit-result.h.
	* jit-result.c: New file, to contain...
	(gcc::jit::result::result): Move here from jit-playback.c,
	removing erroneous "playback" namespace from comment.
	(gcc::jit::result::~result): Likewise.
	(gcc::jit::playback::result): Likewise.
	* jit-result.h: New file, to contain...
	(class gcc::jit::result): Move from jit-recording.h.
	* libgccjit.c: Include jit-result.h.
	(gcc_jit_result_get_code): Update comment to reflect move
	of implementation.
	(gcc_jit_result_release): Likewise.
---
 gcc/jit/Make-lang.in    |  1 +
 gcc/jit/jit-playback.c  | 43 +----------------------------
 gcc/jit/jit-recording.h | 15 ----------
 gcc/jit/jit-result.c    | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/jit/jit-result.h    | 47 +++++++++++++++++++++++++++++++
 gcc/jit/libgccjit.c     |  6 ++--
 6 files changed, 125 insertions(+), 60 deletions(-)
 create mode 100644 gcc/jit/jit-result.c
 create mode 100644 gcc/jit/jit-result.h
diff mbox

Patch

diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index 167fcad..e88fd00 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -64,6 +64,7 @@  jit_OBJS = attribs.o \
 	jit/libgccjit.o \
 	jit/jit-recording.o \
 	jit/jit-playback.o \
+	jit/jit-result.o \
 	jit/jit-builtins.o
 
 # Use strict warnings for this front end.
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index 584a8e6..cd124eb 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -49,6 +49,7 @@  along with GCC; see the file COPYING3.  If not see
 
 #include "jit-common.h"
 #include "jit-playback.h"
+#include "jit-result.h"
 
 
 /* gcc::jit::playback::context::build_cast uses the convert.h API,
@@ -1951,48 +1952,6 @@  add_error_va (location *loc, const char *fmt, va_list ap)
 				  fmt, ap);
 }
 
-/* Constructor for gcc::jit::playback::result.  */
-
-result::
-result(void *dso_handle)
-  : m_dso_handle(dso_handle)
-{
-}
-
-/* gcc::jit::playback::result's destructor.
-
-   Called implicitly by gcc_jit_result_release.  */
-
-result::~result()
-{
-  dlclose (m_dso_handle);
-}
-
-/* Attempt to locate the given function by name within the
-   playback::result, using dlsym.
-
-   Implements the post-error-checking part of
-   gcc_jit_result_get_code.  */
-
-void *
-result::
-get_code (const char *funcname)
-{
-  void *code;
-  const char *error;
-
-  /* Clear any existing error.  */
-  dlerror ();
-
-  code = dlsym (m_dso_handle, funcname);
-
-  if ((error = dlerror()) != NULL)  {
-    fprintf(stderr, "%s\n", error);
-  }
-
-  return code;
-}
-
 /* Dealing with the linemap API.  */
 
 /* Construct a playback::location for a recording::location, if it
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 9b2cfc6..1b0ef91 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -1576,21 +1576,6 @@  private:
 
 } // namespace gcc::jit::recording
 
-/* The result of JIT-compilation.  */
-class result
-{
-public:
-  result(void *dso_handle);
-
-  virtual ~result();
-
-  void *
-  get_code (const char *funcname);
-
-private:
-  void *m_dso_handle;
-};
-
 } // namespace gcc::jit
 
 } // namespace gcc
diff --git a/gcc/jit/jit-result.c b/gcc/jit/jit-result.c
new file mode 100644
index 0000000..9e1e6d8
--- /dev/null
+++ b/gcc/jit/jit-result.c
@@ -0,0 +1,73 @@ 
+/* Internals of libgccjit: implementation of gcc_jit_result
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
+   Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "jit-result.h"
+
+namespace gcc {
+namespace jit {
+
+/* Constructor for gcc::jit::result.  */
+
+result::
+result(void *dso_handle)
+  : m_dso_handle(dso_handle)
+{
+}
+
+/* gcc::jit::result's destructor.
+
+   Called implicitly by gcc_jit_result_release.  */
+
+result::~result()
+{
+  dlclose (m_dso_handle);
+}
+
+/* Attempt to locate the given function by name within the
+   playback::result, using dlsym.
+
+   Implements the post-error-checking part of
+   gcc_jit_result_get_code.  */
+
+void *
+result::
+get_code (const char *funcname)
+{
+  void *code;
+  const char *error;
+
+  /* Clear any existing error.  */
+  dlerror ();
+
+  code = dlsym (m_dso_handle, funcname);
+
+  if ((error = dlerror()) != NULL)  {
+    fprintf(stderr, "%s\n", error);
+  }
+
+  return code;
+}
+
+} // namespace gcc::jit
+
+} // namespace gcc
diff --git a/gcc/jit/jit-result.h b/gcc/jit/jit-result.h
new file mode 100644
index 0000000..60d6930
--- /dev/null
+++ b/gcc/jit/jit-result.h
@@ -0,0 +1,47 @@ 
+/* Internals of libgccjit: implementation of gcc_jit_result
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
+   Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef JIT_RESULT_H
+#define JIT_RESULT_H
+
+namespace gcc {
+
+namespace jit {
+
+/* The result of JIT-compilation.  */
+class result
+{
+public:
+  result(void *dso_handle);
+
+  virtual ~result();
+
+  void *
+  get_code (const char *funcname);
+
+private:
+  void *m_dso_handle;
+};
+
+} // namespace gcc::jit
+
+} // namespace gcc
+
+#endif /* JIT_RESULT_H */
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 7bc9209..42769e8 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -27,6 +27,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "libgccjit.h"
 #include "jit-common.h"
 #include "jit-recording.h"
+#include "jit-result.h"
 
 /* The opaque types used by the public API are actually subclasses
    of the gcc::jit::recording classes.  */
@@ -2047,8 +2048,7 @@  gcc_jit_context_get_first_error (gcc_jit_context *ctxt)
 /* Public entrypoint.  See description in libgccjit.h.
 
    After error-checking, the real work is done by the
-   gcc::jit::playback::result::get_code method in
-   jit-playback.c.  */
+   gcc::jit::result::get_code method in jit-result.c.  */
 
 void *
 gcc_jit_result_get_code (gcc_jit_result *result,
@@ -2063,7 +2063,7 @@  gcc_jit_result_get_code (gcc_jit_result *result,
 /* Public entrypoint.  See description in libgccjit.h.
 
    After error-checking, this is essentially a wrapper around the
-   destructor for gcc::jit::playback::result in jit-playback.c.  */
+   destructor for gcc::jit::result in jit-result.c.  */
 
 void
 gcc_jit_result_release (gcc_jit_result *result)