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
This commit is contained in:
parent
52b9468f15
commit
56dea35f94
@ -1,3 +1,24 @@
|
||||
2014-12-01 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* 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 <dmalcolm@redhat.com>
|
||||
|
||||
PR jit/63854
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
73
gcc/jit/jit-result.c
Normal file
73
gcc/jit/jit-result.c
Normal file
@ -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
|
47
gcc/jit/jit-result.h
Normal file
47
gcc/jit/jit-result.h
Normal file
@ -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 */
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user