From: David Malcolm Date: Mon, 1 Dec 2014 17:52:03 +0000 (+0000) Subject: Move gcc_jit_result implementation to a new files jit-result.{h|c} X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56dea35f948f84bff37051141893e1d237c3d0f9;p=gcc.git Move gcc_jit_result implementation to a 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. From-SVN: r218236 --- diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 210dcb0c8ea..455ba59d81c 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,24 @@ +2014-12-01 David Malcolm + + * 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. + 2014-12-01 David Malcolm PR jit/63854 diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index 167fcadfc21..e88fd003865 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 584a8e63759..cd124eb1b84 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 9b2cfc67f3c..1b0ef915522 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 00000000000..9e1e6d85b70 --- /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 . + +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 +. */ + +#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 00000000000..60d6930d058 --- /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 . + +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 +. */ + +#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 7bc9209139b..42769e8c8b6 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)