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
+11 -11
View File
@@ -94,27 +94,27 @@ 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) if (!(name)) { \
#define LOAD_FUNCTION(name) \ log_failing_dlsym(yabridge_clap_plugin_name, #name); \
do { \ return false; \
MAYBE_LOAD_FUNCTION(name); \ } \
if (!(name)) { \
log_failing_dlsym(yabridge_clap_plugin_name, #name); \
return false; \
} \
} while (false) } while (false)
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;
} }
+11 -11
View File
@@ -77,25 +77,25 @@ 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) if (!(name)) { \
#define LOAD_FUNCTION(name) \ log_failing_dlsym(yabridge_vst2_plugin_name, #name); \
do { \ return false; \
MAYBE_LOAD_FUNCTION(name); \ } \
if (!(name)) { \
log_failing_dlsym(yabridge_vst2_plugin_name, #name); \
return false; \
} \
} 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;
} }
+11 -11
View File
@@ -94,27 +94,27 @@ 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) if (!(name)) { \
#define LOAD_FUNCTION(name) \ log_failing_dlsym(yabridge_vst3_plugin_name, #name); \
do { \ return false; \
MAYBE_LOAD_FUNCTION(name); \ } \
if (!(name)) { \
log_failing_dlsym(yabridge_vst3_plugin_name, #name); \
return false; \
} \
} while (false) } while (false)
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;
} }