From c6359d6dbc63664246021f51d85108b8b8511523 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 6 Dec 2015 19:31:47 +0100 Subject: [PATCH] Divorce g_system_menu from global state --- camera/camera_driver.c | 1 + command_event.c | 5 +++-- driver.c | 6 +++--- dynamic.c | 1 + gfx/video_driver.c | 1 + input/drivers/linuxraw_input.c | 1 + input/input_keyboard.c | 4 +++- location/location_driver.c | 1 + menu/cbs/menu_cbs_deferred_push.c | 20 ++++++++++---------- menu/cbs/menu_cbs_left.c | 1 + menu/cbs/menu_cbs_right.c | 1 + menu/cbs/menu_cbs_start.c | 1 + menu/menu_displaylist.c | 1 + menu/menu_driver.c | 6 +++--- menu/menu_entries.c | 12 +++--------- menu/menu_setting.c | 1 + runloop.c | 1 + runloop.h | 11 +++-------- system.c | 4 ++++ system.h | 4 ++++ 20 files changed, 47 insertions(+), 36 deletions(-) diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 5a0158fd73..13efd27011 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -19,6 +19,7 @@ #include "camera_driver.h" #include "../general.h" #include "../string_list_special.h" +#include "../system.h" #include "../verbosity.h" static const camera_driver_t *camera_drivers[] = { diff --git a/command_event.c b/command_event.c index ca7eedb16c..392bfc6679 100644 --- a/command_event.c +++ b/command_event.c @@ -33,6 +33,7 @@ #include "msg_hash.h" #include "retroarch.h" #include "rewind.h" +#include "system.h" #include "dir_list_special.h" #ifdef HAVE_CHEEVOS @@ -972,7 +973,7 @@ bool event_command(enum event_command cmd) case EVENT_CMD_LOAD_CORE_DEINIT: #ifdef HAVE_DYNAMIC #ifdef HAVE_MENU - libretro_free_system_info(&global->menu.info); + libretro_free_system_info(&g_system_menu); #endif #endif break; @@ -982,7 +983,7 @@ bool event_command(enum event_command cmd) #ifdef HAVE_MENU menu_handle_t *menu = menu_driver_get_ptr(); if (menu) - event_update_system_info(&global->menu.info, + event_update_system_info(&g_system_menu, &menu->load_no_content); #endif } diff --git a/driver.c b/driver.c index bcb4b5c407..df02c1b146 100644 --- a/driver.c +++ b/driver.c @@ -18,6 +18,7 @@ #include "general.h" #include "msg_hash.h" +#include "system.h" #include "audio/audio_driver.h" #include "audio/audio_resampler_driver.h" @@ -325,10 +326,9 @@ bool driver_update_system_av_info(const void *data) **/ static void menu_update_libretro_info(void) { - global_t *global = global_get_ptr(); - struct retro_system_info *info = global ? &global->menu.info : NULL; + struct retro_system_info *info = &g_system_menu; - if (!global || !info) + if (!info) return; #ifndef HAVE_DYNAMIC diff --git a/dynamic.c b/dynamic.c index 8b9da4a065..a3969c7b00 100644 --- a/dynamic.c +++ b/dynamic.c @@ -33,6 +33,7 @@ #include "location/location_driver.h" #include "record/record_driver.h" #include "performance.h" +#include "system.h" #include "libretro_private.h" #include "cores/internal_cores.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 4fc1087728..f2175a0ca3 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -31,6 +31,7 @@ #include "../performance.h" #include "../string_list_special.h" #include "../libretro_version_1.h" +#include "../system.h" #ifdef HAVE_MENU #include "../menu/menu_hash.h" diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index a3c951e6bd..4beccb6c33 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -23,6 +23,7 @@ #include +#include "../../configuration.h" #include "../../general.h" #include "../../verbosity.h" diff --git a/input/input_keyboard.c b/input/input_keyboard.c index 7165489e0e..0de8397fe0 100644 --- a/input/input_keyboard.c +++ b/input/input_keyboard.c @@ -18,9 +18,11 @@ #include #include -#include "../general.h" #include "input_keyboard.h" +#include "../general.h" +#include "../system.h" + struct input_keyboard_line { char *buffer; diff --git a/location/location_driver.c b/location/location_driver.c index 3906d4bc31..ae6a59cfc5 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -19,6 +19,7 @@ #include "location_driver.h" #include "../general.h" +#include "../system.h" #include "../string_list_special.h" #include "../verbosity.h" diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index f99b61bc44..7401c466f4 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -26,6 +26,7 @@ #include "../../cores/internal_cores.h" #include "../../general.h" +#include "../../system.h" #include "../../verbosity.h" #include "../../tasks/tasks.h" @@ -510,7 +511,6 @@ enum static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned type) { settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); const char *exts = core_info_list_get_all_extensions(); @@ -537,10 +537,10 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ if (exts) strlcpy(info->exts, exts, sizeof(info->exts)); - else if (global->menu.info.valid_extensions) + else if (g_system_menu.valid_extensions) { - if (*global->menu.info.valid_extensions) - strlcpy(info->exts, global->menu.info.valid_extensions, + if (*g_system_menu.valid_extensions) + strlcpy(info->exts, g_system_menu.valid_extensions, sizeof(info->exts)); } else @@ -548,10 +548,10 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ break; case PUSH_ARCHIVE_OPEN: info->setting = menu_setting_find(info->label); - if (global->menu.info.valid_extensions) + if (g_system_menu.valid_extensions) { - if (*global->menu.info.valid_extensions) - strlcpy(info->exts, global->menu.info.valid_extensions, + if (*g_system_menu.valid_extensions) + strlcpy(info->exts, g_system_menu.valid_extensions, sizeof(info->exts)); } else @@ -562,10 +562,10 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ if (menu_setting_get_browser_selection_type(info->setting) == ST_DIR) { } - else if (global->menu.info.valid_extensions) + else if (g_system_menu.valid_extensions) { - if (*global->menu.info.valid_extensions) - strlcpy(info->exts, global->menu.info.valid_extensions, + if (*g_system_menu.valid_extensions) + strlcpy(info->exts, g_system_menu.valid_extensions, sizeof(info->exts)); } else diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 8bcafca0a8..f509e7e3fd 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -26,6 +26,7 @@ #include "../../cheats.h" #include "../../general.h" #include "../../retroarch.h" +#include "../../system.h" #ifndef BIND_ACTION_LEFT #define BIND_ACTION_LEFT(cbs, name) \ diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 84389aea57..402f3009bf 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -26,6 +26,7 @@ #include "../../cheats.h" #include "../../general.h" #include "../../retroarch.h" +#include "../../system.h" #include "../../ui/ui_companion_driver.h" #ifndef BIND_ACTION_RIGHT diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 8c68f5ac3b..221cdd12d6 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -26,6 +26,7 @@ #include "../../cheats.h" #include "../../general.h" #include "../../retroarch.h" +#include "../../system.h" #include "../../performance.h" #include "../../gfx/video_shader_driver.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 322dd3ada0..5f42cdb7d9 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -30,6 +30,7 @@ #include "../cheats.h" #include "../general.h" +#include "../system.h" #include "../frontend/frontend_driver.h" #include "../ui/ui_companion_driver.h" #include "../gfx/video_shader_driver.h" diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 856c892374..e22bda4870 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -25,6 +25,7 @@ #include "menu_shader.h" #include "../general.h" +#include "../system.h" #include "../frontend/frontend.h" #include "../string_list_special.h" #include "../tasks/tasks.h" @@ -392,7 +393,6 @@ static void menu_environment_get(int *argc, char *argv[], static void menu_push_to_history_playlist(void) { settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); char *fullpath = NULL; if (!settings->history_list_enable) @@ -414,7 +414,7 @@ static void menu_push_to_history_playlist(void) fullpath, NULL, settings->libretro, - global->menu.info.library_name, + g_system_menu.library_name, NULL, NULL); } @@ -525,7 +525,7 @@ void menu_free(menu_handle_t *menu) menu_driver_free(menu); #ifdef HAVE_DYNAMIC - libretro_free_system_info(&global->menu.info); + libretro_free_system_info(&g_system_menu); #endif menu_display_free(); diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 8c2e163d7d..dc80564e61 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -22,6 +22,7 @@ #include "menu_hash.h" #include "../general.h" +#include "../system.h" struct menu_list { @@ -463,21 +464,14 @@ bool menu_entries_show_back(void) * (shown at the top of the UI). */ int menu_entries_get_core_title(char *s, size_t len) { - const char *core_name = NULL; - const char *core_version = NULL; - global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); rarch_system_info_t *info = rarch_system_info_get_ptr(); + const char *core_name = g_system_menu.library_name; + const char *core_version = g_system_menu.library_version; if (!settings->menu.core_enable) return -1; - if (global) - { - core_name = global->menu.info.library_name; - core_version = global->menu.info.library_version; - } - if (!core_name || core_name[0] == '\0') core_name = info->info.library_name; if (!core_name || core_name[0] == '\0') diff --git a/menu/menu_setting.c b/menu/menu_setting.c index fbb4d0d490..a336f898bd 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -37,6 +37,7 @@ #include "../driver.h" #include "../general.h" +#include "../system.h" #include "../dynamic.h" #include "../camera/camera_driver.h" #include "../location/location_driver.h" diff --git a/runloop.c b/runloop.c index 4c5ba803d3..898a623686 100644 --- a/runloop.c +++ b/runloop.c @@ -40,6 +40,7 @@ #include "retroarch.h" #include "runloop.h" #include "rewind.h" +#include "system.h" #include "dir_list_special.h" #include "audio/audio_driver.h" #include "camera/camera_driver.h" diff --git a/runloop.h b/runloop.h index 18faa01553..fdabe65f59 100644 --- a/runloop.h +++ b/runloop.h @@ -16,11 +16,13 @@ #ifndef __RETROARCH_RUNLOOP_H #define __RETROARCH_RUNLOOP_H +#include + +#include "configuration.h" #include "libretro.h" #include "core_info.h" #include "core_options.h" #include "dynamic.h" -#include "system.h" #ifdef __cplusplus extern "C" { @@ -194,13 +196,6 @@ typedef struct global bool ips_pref; } patch; -#ifdef HAVE_MENU - struct - { - struct retro_system_info info; - } menu; -#endif - struct { bool load_disable; diff --git a/system.c b/system.c index fc36638fb8..fe732e59c6 100644 --- a/system.c +++ b/system.c @@ -27,6 +27,10 @@ static rarch_system_info_t *g_system; +#ifdef HAVE_MENU +struct retro_system_info g_system_menu; +#endif + static rarch_system_info_t *rarch_system_info_new(void) { return (rarch_system_info_t*)calloc(1, sizeof(rarch_system_info_t)); diff --git a/system.h b/system.h index 987ec07a91..fae44eca4c 100644 --- a/system.h +++ b/system.h @@ -57,6 +57,10 @@ typedef struct rarch_system_info unsigned num_ports; } rarch_system_info_t; +#ifdef HAVE_MENU +extern struct retro_system_info g_system_menu; +#endif + rarch_system_info_t *rarch_system_info_get_ptr(void); void rarch_system_info_free(void);