From c76272ad8d140d18e6e5035cfcf2470c72c66e37 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 30 Nov 2015 19:30:05 +0100 Subject: [PATCH] Move more state out of global --- retroarch.c | 34 +++++++++++++++++----------------- runloop.h | 3 --- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/retroarch.c b/retroarch.c index aca08751cf..dd0d1c4ae0 100644 --- a/retroarch.c +++ b/retroarch.c @@ -62,9 +62,6 @@ #include "config.features.h" -static char current_savestate_dir[PATH_MAX_LENGTH]; -static char current_savefile_dir[PATH_MAX_LENGTH]; - /* Descriptive names for options without short variant. Please keep the name in sync with the option name. Order does not matter. */ enum @@ -88,6 +85,13 @@ enum RA_OPT_MAX_FRAMES }; +static char current_savestate_dir[PATH_MAX_LENGTH]; +static char current_savefile_dir[PATH_MAX_LENGTH]; + +static bool error_on_init; +static char error_string[PATH_MAX_LENGTH]; +static jmp_buf error_sjlj_context; + #define _PSUPP(var, name, desc) printf(" %s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no") static void print_features(void) @@ -1138,17 +1142,18 @@ void rarch_init_system_av_info(void) int rarch_main_init(int argc, char *argv[]) { int sjlj_ret; - bool *verbosity = NULL; - global_t *global = global_get_ptr(); + bool *verbosity = NULL; + global_t *global = global_get_ptr(); init_state(); - if ((sjlj_ret = setjmp(global->error_sjlj_context)) > 0) + if ((sjlj_ret = setjmp(error_sjlj_context)) > 0) { - RARCH_ERR("Fatal error received in: \"%s\"\n", global->error_string); + RARCH_ERR("Fatal error received in: \"%s\"\n", error_string); return sjlj_ret; } - global->inited.error = true; + + error_on_init = true; retro_main_log_file_init(NULL); parse_input(argc, argv); @@ -1229,7 +1234,7 @@ int rarch_main_init(int argc, char *argv[]) event_command(EVENT_CMD_SAVEFILES_INIT); event_command(EVENT_CMD_SET_PER_GAME_RESOLUTION); - global->inited.error = false; + error_on_init = false; global->inited.main = true; return 0; @@ -1707,16 +1712,11 @@ int rarch_info_get_capabilities(enum rarch_capabilities type, char *s, size_t le **/ void retro_fail(int error_code, const char *error) { - global_t *global = global_get_ptr(); - - if (!global) - return; - /* We cannot longjmp unless we're in rarch_main_init(). * If not, something went very wrong, and we should * just exit right away. */ - retro_assert(global->inited.error); + retro_assert(error_on_init); - strlcpy(global->error_string, error, sizeof(global->error_string)); - longjmp(global->error_sjlj_context, error_code); + strlcpy(error_string, error, sizeof(error_string)); + longjmp(error_sjlj_context, error_code); } diff --git a/runloop.h b/runloop.h index 8c944507b8..5c44d09104 100644 --- a/runloop.h +++ b/runloop.h @@ -303,7 +303,6 @@ typedef struct global { bool main; bool content; - bool error; struct { bool no_content; @@ -311,8 +310,6 @@ typedef struct global } core; } inited; - jmp_buf error_sjlj_context; - char error_string[PATH_MAX_LENGTH]; retro_keyboard_event_t frontend_key_event; } global_t;