From cb6a1dd0ffc59310b6ee3320f54c7e3bd03d9f8d Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 10 Dec 2023 22:48:34 +0100 Subject: [PATCH] Fix yabridge_version() in chainloaders The function doesn't (and cannot) have the same name as the function pointer, so `MAYBE_LOAD_FUNCTION()` does the wrong thing here. May as well just do it manually. --- src/chainloader/clap-chainloader.cpp | 22 +++++++++++----------- src/chainloader/vst2-chainloader.cpp | 22 +++++++++++----------- src/chainloader/vst3-chainloader.cpp | 22 +++++++++++----------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/chainloader/clap-chainloader.cpp b/src/chainloader/clap-chainloader.cpp index af6ba880..cded4577 100644 --- a/src/chainloader/clap-chainloader.cpp +++ b/src/chainloader/clap-chainloader.cpp @@ -94,27 +94,27 @@ bool initialize_library() { return false; } -#define MAYBE_LOAD_FUNCTION(name) \ +#define LOAD_FUNCTION(name) \ do { \ (name) = \ reinterpret_cast(dlsym(library_handle, #name)); \ - } while (false) -#define LOAD_FUNCTION(name) \ - do { \ - MAYBE_LOAD_FUNCTION(name); \ - if (!(name)) { \ - log_failing_dlsym(yabridge_clap_plugin_name, #name); \ - return false; \ - } \ + if (!(name)) { \ + log_failing_dlsym(yabridge_clap_plugin_name, #name); \ + return false; \ + } \ } while (false) LOAD_FUNCTION(yabridge_module_init); LOAD_FUNCTION(yabridge_module_free); LOAD_FUNCTION(yabridge_module_get_factory); - MAYBE_LOAD_FUNCTION(remote_yabridge_version); + + // This one can be a null pointer if the function does not yet exist in this + // yabridge version + remote_yabridge_version = + reinterpret_cast( + dlsym(library_handle, "yabridge_version")); #undef LOAD_FUNCTION -#undef MAYBE_LOAD_FUNCTION return true; } diff --git a/src/chainloader/vst2-chainloader.cpp b/src/chainloader/vst2-chainloader.cpp index 8e24367b..7ccb58c3 100644 --- a/src/chainloader/vst2-chainloader.cpp +++ b/src/chainloader/vst2-chainloader.cpp @@ -77,25 +77,25 @@ bool initialize_library() { return false; } -#define MAYBE_LOAD_FUNCTION(name) \ +#define LOAD_FUNCTION(name) \ do { \ (name) = \ reinterpret_cast(dlsym(library_handle, #name)); \ - } while (false) -#define LOAD_FUNCTION(name) \ - do { \ - MAYBE_LOAD_FUNCTION(name); \ - if (!(name)) { \ - log_failing_dlsym(yabridge_vst2_plugin_name, #name); \ - return false; \ - } \ + if (!(name)) { \ + log_failing_dlsym(yabridge_vst2_plugin_name, #name); \ + return false; \ + } \ } while (false) LOAD_FUNCTION(yabridge_plugin_init); - MAYBE_LOAD_FUNCTION(remote_yabridge_version); + + // This one can be a null pointer if the function does not yet exist in this + // yabridge version + remote_yabridge_version = + reinterpret_cast( + dlsym(library_handle, "yabridge_version")); #undef LOAD_FUNCTION -#undef MAYBE_LOAD_FUNCTION return true; } diff --git a/src/chainloader/vst3-chainloader.cpp b/src/chainloader/vst3-chainloader.cpp index 7801ce1a..3e222374 100644 --- a/src/chainloader/vst3-chainloader.cpp +++ b/src/chainloader/vst3-chainloader.cpp @@ -94,27 +94,27 @@ bool initialize_library() { return false; } -#define MAYBE_LOAD_FUNCTION(name) \ +#define LOAD_FUNCTION(name) \ do { \ (name) = \ reinterpret_cast(dlsym(library_handle, #name)); \ - } while (false) -#define LOAD_FUNCTION(name) \ - do { \ - MAYBE_LOAD_FUNCTION(name); \ - if (!(name)) { \ - log_failing_dlsym(yabridge_vst3_plugin_name, #name); \ - return false; \ - } \ + if (!(name)) { \ + log_failing_dlsym(yabridge_vst3_plugin_name, #name); \ + return false; \ + } \ } while (false) LOAD_FUNCTION(yabridge_module_init); LOAD_FUNCTION(yabridge_module_free); LOAD_FUNCTION(yabridge_module_get_plugin_factory); - MAYBE_LOAD_FUNCTION(remote_yabridge_version); + + // This one can be a null pointer if the function does not yet exist in this + // yabridge version + remote_yabridge_version = + reinterpret_cast( + dlsym(library_handle, "yabridge_version")); #undef LOAD_FUNCTION -#undef MAYBE_LOAD_FUNCTION return true; }