summaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-05-31 20:47:50 +0100
committerAndrea Corallo <akrl@sdf.org>2020-05-31 22:22:23 +0100
commitc936e028c643dc2629e6d2041f2069d89d8c5877 (patch)
tree9d47843f1a8977620490e5d15a4149bd74f1ca19 /src/comp.c
parent15d4fee69fa637191ed985af2397e732001dab6f (diff)
downloademacs-c936e028c643dc2629e6d2041f2069d89d8c5877.tar.gz
emacs-c936e028c643dc2629e6d2041f2069d89d8c5877.tar.bz2
emacs-c936e028c643dc2629e6d2041f2069d89d8c5877.zip
* Add `comp-libgccjit-version' subr
* src/comp.c (gcc_jit_version_major, gcc_jit_version_minor) (gcc_jit_version_patchlevel): Import. (Fcomp_libgccjit_version): New Lisp function. (syms_of_comp): Update for 'comp-libgccjit-version'.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/comp.c b/src/comp.c
index 81c4d2fe32a..c9d3fd04070 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -236,6 +236,9 @@ DEF_DLL_FN (void, gcc_jit_context_set_logfile,
DEF_DLL_FN (void, gcc_jit_struct_set_fields,
(gcc_jit_struct *struct_type, gcc_jit_location *loc, int num_fields,
gcc_jit_field **fields));
+DEF_DLL_FN (int, gcc_jit_version_major);
+DEF_DLL_FN (int, gcc_jit_version_minor);
+DEF_DLL_FN (int, gcc_jit_version_patchlevel);
static bool
init_gccjit_functions (void)
@@ -300,6 +303,9 @@ init_gccjit_functions (void)
LOAD_DLL_FN (library, gcc_jit_struct_as_type);
LOAD_DLL_FN (library, gcc_jit_struct_set_fields);
LOAD_DLL_FN (library, gcc_jit_type_get_pointer);
+ LOAD_DLL_FN (library, gcc_jit_version_major);
+ LOAD_DLL_FN (library, gcc_jit_version_minor);
+ LOAD_DLL_FN (library, gcc_jit_version_patchlevel);
return true;
}
@@ -3988,6 +3994,29 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
return out_file;
}
+DEFUN ("comp-libgccjit-version", Fcomp_libgccjit_version,
+ Scomp_libgccjit_version, 0, 0, 0,
+ doc: /* Return the libgccjit version in use in the form
+(MAJOR MINOR PATCHLEVEL) or nil if unknown (pre GCC10). */)
+ (void)
+{
+#if defined (LIBGCCJIT_HAVE_gcc_jit_version) || defined (WINDOWSNT)
+ load_gccjit_if_necessary (true);
+
+ /* FIXME this kludge is quite bad. Can we dynamically load on all
+ operating systems? */
+#pragma GCC diagnostic ignored "-Waddress"
+ return gcc_jit_version_major
+ ? list3 (make_fixnum (gcc_jit_version_major ()),
+ make_fixnum (gcc_jit_version_minor ()),
+ make_fixnum (gcc_jit_version_patchlevel ()))
+ : Qnil;
+#pragma GCC diagnostic pop
+#else
+ return Qnil;
+#endif
+}
+
/******************************************************************************/
/* Helper functions called from the run-time. */
@@ -4781,6 +4810,7 @@ syms_of_comp (void)
defsubr (&Scomp__init_ctxt);
defsubr (&Scomp__release_ctxt);
defsubr (&Scomp__compile_ctxt_to_file);
+ defsubr (&Scomp_libgccjit_version);
defsubr (&Scomp__register_lambda);
defsubr (&Scomp__register_subr);
defsubr (&Scomp__late_register_subr);