From b619339b7a6c7952508bff72f07fc98c04e85f2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicol=C3=A1s=20B=C3=A9rtolo?= Date: Mon, 1 Jun 2020 19:53:00 -0300 Subject: [PATCH] Fix DLL imports of gccjit version functions. * 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 | 18 ++++++++++++------ src/w32common.h | 8 ++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/comp.c b/src/comp.c index d0574ac5ef3..8e7582b3e65 100644 --- a/src/comp.c +++ b/src/comp.c @@ -98,6 +98,9 @@ along with GNU Emacs. If not, see . */ #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 diff --git a/src/w32common.h b/src/w32common.h index eb7faa1939a..bd01fd40401 100644 --- a/src/w32common.h +++ b/src/w32common.h @@ -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 -- 2.39.5