From f3cd25ebb7137e6e75d93d728b606ddb8f51e4ad Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 2 May 2013 15:17:31 +0200 Subject: [PATCH] Clean up load_no_rom grabbing interface. --- dynamic.c | 13 +++++++++---- dynamic.h | 9 +++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dynamic.c b/dynamic.c index 1180c878a2b..f0e660ab382 100644 --- a/dynamic.c +++ b/dynamic.c @@ -119,6 +119,14 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data) return true; } +void libretro_get_environment_info(void (*func)(retro_environment_t), bool *load_no_rom) +{ + load_no_rom_hook = load_no_rom; + + // load_no_rom gets set in this callback. + func(environ_cb_get_system_info); +} + static dylib_t libretro_get_system_info_lib(const char *path, struct retro_system_info *info, bool *load_no_rom) { dylib_t lib = dylib_load(path); @@ -145,10 +153,7 @@ static dylib_t libretro_get_system_info_lib(const char *path, struct retro_syste if (!set_environ) return lib; - load_no_rom_hook = load_no_rom; - - // load_no_rom gets set in this callback. - set_environ(environ_cb_get_system_info); + libretro_get_environment_info(set_environ, load_no_rom); } return lib; diff --git a/dynamic.h b/dynamic.h index c1c3f413cff..6efa2722fb7 100644 --- a/dynamic.h +++ b/dynamic.h @@ -45,6 +45,15 @@ void dylib_close(dylib_t lib); function_t dylib_proc(dylib_t lib, const char *proc); #endif +// Sets environment callback in order to get statically known information from it. +// Fetched via environment callbacks instead of retro_get_system_info(), as this info +// is part of extensions. +// Should only be called once right after core load to avoid overwriting +// the "real" environ callback. +// +// For statically linked cores, pass retro_set_environment as argument. +void libretro_get_environment_info(void (*)(retro_environment_t), bool *load_no_rom); + #ifdef HAVE_DYNAMIC // Gets system info from an arbitrary lib. // The struct returned must be freed as strings are allocated dynamically.