mirror of
https://github.com/libretro/RetroArch
synced 2025-02-15 09:40:11 +00:00
Move global error_on_init/error_string/sjlj jump to global
state - move g_extern out of p_rarch
This commit is contained in:
parent
113e9340c1
commit
d3d7748f92
46
retroarch.c
46
retroarch.c
@ -58,7 +58,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <setjmp.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
@ -401,19 +400,15 @@ extern const bluetooth_driver_t *bluetooth_drivers[];
|
|||||||
/* MAIN GLOBAL VARIABLES */
|
/* MAIN GLOBAL VARIABLES */
|
||||||
struct rarch_state
|
struct rarch_state
|
||||||
{
|
{
|
||||||
struct global g_extern; /* retro_time_t alignment */
|
|
||||||
char *connect_host; /* Netplay hostname passed from CLI */
|
char *connect_host; /* Netplay hostname passed from CLI */
|
||||||
|
|
||||||
struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS];
|
struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS];
|
||||||
|
|
||||||
jmp_buf error_sjlj_context; /* 4-byte alignment,
|
|
||||||
put it right before long */
|
|
||||||
#ifdef HAVE_THREAD_STORAGE
|
#ifdef HAVE_THREAD_STORAGE
|
||||||
sthread_tls_t rarch_tls; /* unsigned alignment */
|
sthread_tls_t rarch_tls; /* unsigned alignment */
|
||||||
#endif
|
#endif
|
||||||
unsigned perf_ptr_rarch;
|
unsigned perf_ptr_rarch;
|
||||||
|
|
||||||
char error_string[255];
|
|
||||||
char launch_arguments[4096];
|
char launch_arguments[4096];
|
||||||
char path_default_shader_preset[PATH_MAX_LENGTH];
|
char path_default_shader_preset[PATH_MAX_LENGTH];
|
||||||
char path_content[PATH_MAX_LENGTH];
|
char path_content[PATH_MAX_LENGTH];
|
||||||
@ -425,7 +420,6 @@ struct rarch_state
|
|||||||
char dir_savefile[PATH_MAX_LENGTH];
|
char dir_savefile[PATH_MAX_LENGTH];
|
||||||
char dir_savestate[PATH_MAX_LENGTH];
|
char dir_savestate[PATH_MAX_LENGTH];
|
||||||
bool has_set_username;
|
bool has_set_username;
|
||||||
bool rarch_error_on_init;
|
|
||||||
bool has_set_verbosity;
|
bool has_set_verbosity;
|
||||||
bool has_set_libretro;
|
bool has_set_libretro;
|
||||||
bool has_set_libretro_directory;
|
bool has_set_libretro_directory;
|
||||||
@ -486,6 +480,7 @@ retro_keybind_set input_autoconf_binds[MAX_USERS];
|
|||||||
|
|
||||||
static runloop_state_t runloop_state = {0};
|
static runloop_state_t runloop_state = {0};
|
||||||
static access_state_t access_state_st = {0};
|
static access_state_t access_state_st = {0};
|
||||||
|
static struct global global_driver_st = {0}; /* retro_time_t alignment */
|
||||||
|
|
||||||
access_state_t *access_state_get_ptr(void)
|
access_state_t *access_state_get_ptr(void)
|
||||||
{
|
{
|
||||||
@ -519,8 +514,7 @@ int content_get_subsystem(void)
|
|||||||
|
|
||||||
global_t *global_get_ptr(void)
|
global_t *global_get_ptr(void)
|
||||||
{
|
{
|
||||||
struct rarch_state *p_rarch = &rarch_st;
|
return &global_driver_st;
|
||||||
return &p_rarch->g_extern;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -4793,7 +4787,7 @@ bool command_event(enum event_command cmd, void *data)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_MENU_RESET_TO_DEFAULT_CONFIG:
|
case CMD_EVENT_MENU_RESET_TO_DEFAULT_CONFIG:
|
||||||
config_set_defaults(&p_rarch->g_extern);
|
config_set_defaults(global_get_ptr());
|
||||||
break;
|
break;
|
||||||
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG:
|
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG:
|
||||||
#if !defined(HAVE_DYNAMIC)
|
#if !defined(HAVE_DYNAMIC)
|
||||||
@ -5832,7 +5826,7 @@ static void global_free(struct rarch_state *p_rarch)
|
|||||||
runloop_st->current_core.has_set_input_descriptors = false;
|
runloop_st->current_core.has_set_input_descriptors = false;
|
||||||
runloop_st->current_core.has_set_subsystems = false;
|
runloop_st->current_core.has_set_subsystems = false;
|
||||||
|
|
||||||
global = &p_rarch->g_extern;
|
global = global_get_ptr();
|
||||||
path_clear_all();
|
path_clear_all();
|
||||||
dir_clear_all();
|
dir_clear_all();
|
||||||
|
|
||||||
@ -5919,7 +5913,7 @@ void main_exit(void *args)
|
|||||||
|
|
||||||
p_rarch->has_set_username = false;
|
p_rarch->has_set_username = false;
|
||||||
runloop_st->is_inited = false;
|
runloop_st->is_inited = false;
|
||||||
p_rarch->rarch_error_on_init = false;
|
global_get_ptr()->error_on_init = false;
|
||||||
#ifdef HAVE_CONFIGFILE
|
#ifdef HAVE_CONFIGFILE
|
||||||
p_rarch->rarch_block_config_read = false;
|
p_rarch->rarch_block_config_read = false;
|
||||||
#endif
|
#endif
|
||||||
@ -11227,7 +11221,7 @@ static bool retroarch_parse_input_and_config(
|
|||||||
#if !defined(HAVE_DYNAMIC)
|
#if !defined(HAVE_DYNAMIC)
|
||||||
config_load_file_salamander();
|
config_load_file_salamander();
|
||||||
#endif
|
#endif
|
||||||
config_load(&p_rarch->g_extern);
|
config_load(global_get_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosity_enabled = verbosity_is_enabled();
|
verbosity_enabled = verbosity_is_enabled();
|
||||||
@ -11735,7 +11729,7 @@ bool retroarch_main_init(int argc, char *argv[])
|
|||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
recording_state_t
|
recording_state_t
|
||||||
*recording_st = recording_state_get_ptr();
|
*recording_st = recording_state_get_ptr();
|
||||||
global_t *global = &p_rarch->g_extern;
|
global_t *global = global_get_ptr();
|
||||||
access_state_t *access_st = access_state_get_ptr();
|
access_state_t *access_st = access_state_get_ptr();
|
||||||
#ifdef HAVE_ACCESSIBILITY
|
#ifdef HAVE_ACCESSIBILITY
|
||||||
bool accessibility_enable = false;
|
bool accessibility_enable = false;
|
||||||
@ -11749,19 +11743,21 @@ bool retroarch_main_init(int argc, char *argv[])
|
|||||||
video_st->active = true;
|
video_st->active = true;
|
||||||
audio_state_get_ptr()->active= true;
|
audio_state_get_ptr()->active= true;
|
||||||
|
|
||||||
if (setjmp(p_rarch->error_sjlj_context) > 0)
|
if (setjmp(global->error_sjlj_context) > 0)
|
||||||
{
|
{
|
||||||
RARCH_ERR("%s: \"%s\"\n",
|
RARCH_ERR("%s: \"%s\"\n",
|
||||||
msg_hash_to_str(MSG_FATAL_ERROR_RECEIVED_IN), p_rarch->error_string);
|
msg_hash_to_str(MSG_FATAL_ERROR_RECEIVED_IN),
|
||||||
|
global->error_string);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
p_rarch->rarch_error_on_init = true;
|
global->error_on_init = true;
|
||||||
|
|
||||||
/* Have to initialise non-file logging once at the start... */
|
/* Have to initialise non-file logging once at the start... */
|
||||||
retro_main_log_file_init(NULL, false);
|
retro_main_log_file_init(NULL, false);
|
||||||
|
|
||||||
verbosity_enabled = retroarch_parse_input_and_config(p_rarch, &p_rarch->g_extern, argc, argv);
|
verbosity_enabled = retroarch_parse_input_and_config(p_rarch,
|
||||||
|
global_get_ptr(), argc, argv);
|
||||||
|
|
||||||
#ifdef HAVE_ACCESSIBILITY
|
#ifdef HAVE_ACCESSIBILITY
|
||||||
accessibility_enable = settings->bools.accessibility_enable;
|
accessibility_enable = settings->bools.accessibility_enable;
|
||||||
@ -12019,7 +12015,7 @@ bool retroarch_main_init(int argc, char *argv[])
|
|||||||
|
|
||||||
command_event(CMD_EVENT_SET_PER_GAME_RESOLUTION, NULL);
|
command_event(CMD_EVENT_SET_PER_GAME_RESOLUTION, NULL);
|
||||||
|
|
||||||
p_rarch->rarch_error_on_init = false;
|
global->error_on_init = false;
|
||||||
runloop_st->is_inited = true;
|
runloop_st->is_inited = true;
|
||||||
|
|
||||||
#ifdef HAVE_DISCORD
|
#ifdef HAVE_DISCORD
|
||||||
@ -12591,15 +12587,14 @@ void runloop_set_current_core_type(
|
|||||||
|
|
||||||
void retroarch_fail(int error_code, const char *error)
|
void retroarch_fail(int error_code, const char *error)
|
||||||
{
|
{
|
||||||
struct rarch_state *p_rarch = &rarch_st;
|
global_t *global = global_get_ptr();
|
||||||
/* We cannot longjmp unless we're in retroarch_main_init().
|
/* We cannot longjmp unless we're in retroarch_main_init().
|
||||||
* If not, something went very wrong, and we should
|
* If not, something went very wrong, and we should
|
||||||
* just exit right away. */
|
* just exit right away. */
|
||||||
retro_assert(p_rarch->rarch_error_on_init);
|
retro_assert(global->error_on_init);
|
||||||
|
strlcpy(global->error_string,
|
||||||
strlcpy(p_rarch->error_string,
|
error, sizeof(global->error_string));
|
||||||
error, sizeof(p_rarch->error_string));
|
longjmp(global->error_sjlj_context, error_code);
|
||||||
longjmp(p_rarch->error_sjlj_context, error_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retroarch_main_quit(void)
|
bool retroarch_main_quit(void)
|
||||||
@ -13975,7 +13970,6 @@ int runloop_iterate(void)
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
enum analog_dpad_mode dpad_mode[MAX_USERS];
|
enum analog_dpad_mode dpad_mode[MAX_USERS];
|
||||||
struct rarch_state *p_rarch = &rarch_st;
|
|
||||||
input_driver_state_t *input_st = input_state_get_ptr();
|
input_driver_state_t *input_st = input_state_get_ptr();
|
||||||
audio_driver_state_t *audio_st = audio_state_get_ptr();
|
audio_driver_state_t *audio_st = audio_state_get_ptr();
|
||||||
video_driver_state_t *video_st = video_state_get_ptr();
|
video_driver_state_t *video_st = video_state_get_ptr();
|
||||||
@ -14079,7 +14073,7 @@ int runloop_iterate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ((enum runloop_state_enum)runloop_check_state(
|
switch ((enum runloop_state_enum)runloop_check_state(
|
||||||
p_rarch->rarch_error_on_init,
|
global_get_ptr()->error_on_init,
|
||||||
settings, current_time))
|
settings, current_time))
|
||||||
{
|
{
|
||||||
case RUNLOOP_STATE_QUIT:
|
case RUNLOOP_STATE_QUIT:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef _RETROARCH_TYPES_H
|
#ifndef _RETROARCH_TYPES_H
|
||||||
#define _RETROARCH_TYPES_H
|
#define _RETROARCH_TYPES_H
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
@ -297,6 +298,9 @@ typedef struct rarch_resolution
|
|||||||
|
|
||||||
typedef struct global
|
typedef struct global
|
||||||
{
|
{
|
||||||
|
jmp_buf error_sjlj_context; /* 4-byte alignment,
|
||||||
|
put it right before long */
|
||||||
|
|
||||||
/* Settings and/or global state that is specific to
|
/* Settings and/or global state that is specific to
|
||||||
* a console-style implementation. */
|
* a console-style implementation. */
|
||||||
struct
|
struct
|
||||||
@ -322,9 +326,11 @@ typedef struct global
|
|||||||
bool softfilter_enable;
|
bool softfilter_enable;
|
||||||
|
|
||||||
} console;
|
} console;
|
||||||
/* Settings and/or global states specific to menus */
|
|
||||||
|
char error_string[255];
|
||||||
bool launched_from_cli;
|
bool launched_from_cli;
|
||||||
bool cli_load_menu_on_error;
|
bool cli_load_menu_on_error;
|
||||||
|
bool error_on_init;
|
||||||
} global_t;
|
} global_t;
|
||||||
|
|
||||||
typedef struct content_file_override
|
typedef struct content_file_override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user