diff options
author | AndreaCorallo <andrea.corallo@arm.com> | 2020-03-08 13:46:33 +0000 |
---|---|---|
committer | Andrea Corallo <andrea.corallo@arm.com> | 2020-03-31 20:57:15 +0200 |
commit | 63b2923dc6f57e74d964a9cf14f4ba595ab14ed9 (patch) | |
tree | 03f4850f666021f4378a87062e2900281dd852ef /gcc/jit/libgccjit.c | |
parent | 689418b97e5eb6a221871a2439bca3e6283ac579 (diff) | |
download | gcc-63b2923dc6f57e74d964a9cf14f4ba595ab14ed9.zip gcc-63b2923dc6f57e74d964a9cf14f4ba595ab14ed9.tar.gz gcc-63b2923dc6f57e74d964a9cf14f4ba595ab14ed9.tar.bz2 |
libgccjit: add new version entry point
gcc/jit/ChangeLog
2020-03-31 Andrea Corallo <andrea.corallo@arm.com>
David Malcolm <dmalcolm@redhat.com>
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_13): New ABI tag
plus add version paragraph.
* libgccjit++.h (namespace gccjit::version): Add new namespace.
* libgccjit.c (gcc_jit_version_major, gcc_jit_version_minor)
(gcc_jit_version_patchlevel): New functions.
* libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_version): New macro.
(gcc_jit_version_major, gcc_jit_version_minor)
(gcc_jit_version_patchlevel): New functions.
* libgccjit.map (LIBGCCJIT_ABI_13) New ABI tag.
gcc/testsuite/ChangeLog
2020-03-31 Andrea Corallo <andrea.corallo@arm.com>
* jit.dg/test-version.c: New testcase.
* jit.dg/all-non-failing-tests.h: Add test-version.c.
Diffstat (limited to 'gcc/jit/libgccjit.c')
-rw-r--r-- | gcc/jit/libgccjit.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 83055fc..a29e988 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -23,6 +23,8 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "timevar.h" #include "typed-splay-tree.h" +#include "cppbuiltin.h" +#include <pthread.h> #include "libgccjit.h" #include "jit-recording.h" @@ -3175,3 +3177,47 @@ gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt, as_vec_type, (gcc::jit::recording::rvalue **)elements); } + +/* A mutex around the cached state in parse_basever. + Ideally this would be within parse_basever, but the mutex is only needed + by libgccjit. */ + +static pthread_mutex_t version_mutex = PTHREAD_MUTEX_INITIALIZER; + +struct version_info +{ + /* Default constructor. Populate via parse_basever, + guarded by version_mutex. */ + version_info () + { + pthread_mutex_lock (&version_mutex); + parse_basever (&major, &minor, &patchlevel); + pthread_mutex_unlock (&version_mutex); + } + + int major; + int minor; + int patchlevel; +}; + + +extern int +gcc_jit_version_major (void) +{ + version_info vi; + return vi.major; +} + +extern int +gcc_jit_version_minor (void) +{ + version_info vi; + return vi.minor; +} + +extern int +gcc_jit_version_patchlevel (void) +{ + version_info vi; + return vi.patchlevel; +} |