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.
This commit is contained in:
Robbert van der Helm
2023-12-10 22:48:34 +01:00
parent f1a7ad4dcb
commit cb6a1dd0ff
3 changed files with 33 additions and 33 deletions
+7 -7
View File
@@ -94,14 +94,10 @@ bool initialize_library() {
return false; return false;
} }
#define MAYBE_LOAD_FUNCTION(name) \ #define LOAD_FUNCTION(name) \
do { \ do { \
(name) = \ (name) = \
reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \ reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \
} while (false)
#define LOAD_FUNCTION(name) \
do { \
MAYBE_LOAD_FUNCTION(name); \
if (!(name)) { \ if (!(name)) { \
log_failing_dlsym(yabridge_clap_plugin_name, #name); \ log_failing_dlsym(yabridge_clap_plugin_name, #name); \
return false; \ return false; \
@@ -111,10 +107,14 @@ bool initialize_library() {
LOAD_FUNCTION(yabridge_module_init); LOAD_FUNCTION(yabridge_module_init);
LOAD_FUNCTION(yabridge_module_free); LOAD_FUNCTION(yabridge_module_free);
LOAD_FUNCTION(yabridge_module_get_factory); 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<decltype(remote_yabridge_version)>(
dlsym(library_handle, "yabridge_version"));
#undef LOAD_FUNCTION #undef LOAD_FUNCTION
#undef MAYBE_LOAD_FUNCTION
return true; return true;
} }
+7 -7
View File
@@ -77,14 +77,10 @@ bool initialize_library() {
return false; return false;
} }
#define MAYBE_LOAD_FUNCTION(name) \ #define LOAD_FUNCTION(name) \
do { \ do { \
(name) = \ (name) = \
reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \ reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \
} while (false)
#define LOAD_FUNCTION(name) \
do { \
MAYBE_LOAD_FUNCTION(name); \
if (!(name)) { \ if (!(name)) { \
log_failing_dlsym(yabridge_vst2_plugin_name, #name); \ log_failing_dlsym(yabridge_vst2_plugin_name, #name); \
return false; \ return false; \
@@ -92,10 +88,14 @@ bool initialize_library() {
} while (false) } while (false)
LOAD_FUNCTION(yabridge_plugin_init); 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<decltype(remote_yabridge_version)>(
dlsym(library_handle, "yabridge_version"));
#undef LOAD_FUNCTION #undef LOAD_FUNCTION
#undef MAYBE_LOAD_FUNCTION
return true; return true;
} }
+7 -7
View File
@@ -94,14 +94,10 @@ bool initialize_library() {
return false; return false;
} }
#define MAYBE_LOAD_FUNCTION(name) \ #define LOAD_FUNCTION(name) \
do { \ do { \
(name) = \ (name) = \
reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \ reinterpret_cast<decltype(name)>(dlsym(library_handle, #name)); \
} while (false)
#define LOAD_FUNCTION(name) \
do { \
MAYBE_LOAD_FUNCTION(name); \
if (!(name)) { \ if (!(name)) { \
log_failing_dlsym(yabridge_vst3_plugin_name, #name); \ log_failing_dlsym(yabridge_vst3_plugin_name, #name); \
return false; \ return false; \
@@ -111,10 +107,14 @@ bool initialize_library() {
LOAD_FUNCTION(yabridge_module_init); LOAD_FUNCTION(yabridge_module_init);
LOAD_FUNCTION(yabridge_module_free); LOAD_FUNCTION(yabridge_module_free);
LOAD_FUNCTION(yabridge_module_get_plugin_factory); 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<decltype(remote_yabridge_version)>(
dlsym(library_handle, "yabridge_version"));
#undef LOAD_FUNCTION #undef LOAD_FUNCTION
#undef MAYBE_LOAD_FUNCTION
return true; return true;
} }