]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix DLL imports of gccjit version functions.
authorNicolás Bértolo <nicolasbertolo@gmail.com>
Mon, 1 Jun 2020 22:53:00 +0000 (19:53 -0300)
committerAndrea Corallo <akrl@sdf.org>
Tue, 2 Jun 2020 22:25:24 +0000 (23:25 +0100)
* src/comp.c (init_gccjit_functions): Use LOAD_DLL_FN_OPT macro to
load gcc_jit_version_major, gcc_jit_version_major and
gcc_jit_version_patchlevel.
* src/w32common.h (LOAD_DLL_FN_OPT): Add macro optionally load a
function from a DLL.

src/comp.c
src/w32common.h

index d0574ac5ef31b5beb9140b05365ecfd014ef6042..8e7582b3e65d416bce500b705726429fe200ad75 100644 (file)
@@ -98,6 +98,9 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #undef gcc_jit_struct_as_type
 #undef gcc_jit_struct_set_fields
 #undef gcc_jit_type_get_pointer
+#undef gcc_jit_version_major
+#undef gcc_jit_version_minor
+#undef gcc_jit_version_patchlevel
 
 /* In alphabetical order */
 DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_rvalue_from_int,
@@ -231,9 +234,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);
+DEF_DLL_FN (int, gcc_jit_version_major, (void));
+DEF_DLL_FN (int, gcc_jit_version_minor, (void));
+DEF_DLL_FN (int, gcc_jit_version_patchlevel, (void));
 
 static bool
 init_gccjit_functions (void)
@@ -297,9 +300,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);
+  LOAD_DLL_FN_OPT (library, gcc_jit_version_major);
+  LOAD_DLL_FN_OPT (library, gcc_jit_version_minor);
+  LOAD_DLL_FN_OPT (library, gcc_jit_version_patchlevel);
 
   return true;
 }
@@ -358,6 +361,9 @@ init_gccjit_functions (void)
 #define gcc_jit_struct_as_type fn_gcc_jit_struct_as_type
 #define gcc_jit_struct_set_fields fn_gcc_jit_struct_set_fields
 #define gcc_jit_type_get_pointer fn_gcc_jit_type_get_pointer
+#define gcc_jit_version_major fn_gcc_jit_version_major
+#define gcc_jit_version_minor fn_gcc_jit_version_minor
+#define gcc_jit_version_patchlevel fn_gcc_jit_version_patchlevel
 
 #endif
 
index eb7faa1939a07543145844b1fd3f5970a11081b9..bd01fd404016bc0fd00d307c17c9aba51a0112a1 100644 (file)
@@ -81,6 +81,14 @@ get_proc_addr (HINSTANCE handle, LPCSTR fname)
     }                                                                  \
   while (false)
 
+/* Load a function from the DLL, and don't fail if it does not exist.  */
+#define LOAD_DLL_FN_OPT(lib, func)                                      \
+  do                                                                   \
+    {                                                                  \
+      fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func);         \
+    }                                                                  \
+  while (false)
+
 #ifdef HAVE_HARFBUZZ
 extern bool hbfont_init_w32_funcs (HMODULE);
 #endif