Create new rarch_main signature

This commit is contained in:
twinaphex 2015-04-20 21:31:25 +02:00
parent 4e187ad642
commit 14505cc222
10 changed files with 29 additions and 63 deletions

View File

@ -29,9 +29,6 @@
struct android_app *g_android;
static pthread_key_t thread_key;
/* Forward declaration. */
extern void android_app_entry(void *args);
void engine_handle_cmd(void *data)
{
int8_t cmd;
@ -350,6 +347,23 @@ static void jni_thread_destruct(void *value)
pthread_setspecific(thread_key, NULL);
}
static void android_app_entry(void *data)
{
char *argv[1];
int argc = 0;
if (rarch_main(argc, argv, data) != 0)
goto end;
#ifndef HAVE_MAIN
while (rarch_main_iterate() != -1);
main_exit(args);
#endif
end:
exit(0);
}
/*
* Native activity interaction (called from main thread)
**/

View File

@ -529,10 +529,3 @@ const frontend_ctx_driver_t frontend_ctx_darwin = {
frontend_darwin_get_powerstate,
"darwin",
};
#if !defined(HAVE_COCOA) && !defined(HAVE_COCOATOUCH)
int main(int argc, char *argv[])
{
return rarch_main(argc, argv);
}
#endif

View File

@ -36,7 +36,7 @@ int main(int argc, char *argv[])
settings_t *settings = config_get_ptr();
emscripten_set_canvas_size(800, 600);
rarch_main(argc, argv);
rarch_main(argc, argv, NULL);
emscripten_set_main_loop(emscripten_mainloop,
settings->video.vsync ? 0 : INT_MAX, 1);

View File

@ -22,16 +22,6 @@
#include "../runloop.h"
#include <file/file_path.h>
#if defined(ANDROID)
#define returnfunc() exit(0)
#define return_var(var) return
#define args_initial_ptr() data
#else
#define returnfunc() return 0
#define return_var(var) return var
#define args_initial_ptr() NULL
#endif
#define MAX_ARGS 32
/**
@ -276,17 +266,9 @@ error:
*
* Returns: varies per platform.
**/
#if defined(ANDROID)
void android_app_entry(void *data)
#else
int rarch_main(int argc, char *argv[])
#endif
int rarch_main(int argc, char *argv[], void *data)
{
#ifdef ANDROID
char *argv[1];
int argc = 0;
#endif
void *args = (void *)args_initial_ptr();
void *args = (void*)data;
int ret = 0;
settings_t *settings = NULL;
driver_t *driver = NULL;
@ -311,9 +293,7 @@ int rarch_main(int argc, char *argv[])
if (!(ret = (main_load_content(argc, argv, args,
driver->frontend_ctx->environment_get,
driver->frontend_ctx->process_args))))
{
return_var(ret);
}
return ret;
}
event_command(EVENT_CMD_HISTORY_INIT);
@ -346,12 +326,12 @@ int rarch_main(int argc, char *argv[])
main_exit(args);
#endif
returnfunc();
return 0;
}
#ifndef HAVE_MAIN
int main(int argc, char *argv[])
{
return rarch_main(argc, argv);
return rarch_main(argc, argv, NULL);
}
#endif

View File

@ -59,11 +59,7 @@ void main_exit_save_config(void);
*
* Returns: varies per platform.
**/
#if defined(ANDROID)
void android_app_entry(void *data);
#else
int rarch_main(int argc, char *argv[]);
#endif
int rarch_main(int argc, char *argv[], void *data);
/**
* main_load_content:

View File

@ -33,18 +33,6 @@
#include <dirent.h>
#include "../compat/strl.h"
#undef main
int rarch_main(int argc, char **argv);
static void start_rarch(const char *path)
{
char arg0[] = "retroarch";
char arg1[256];
strlcpy(arg1, path, sizeof(arg1));
char *argv[3] = { arg0, arg1, NULL };
rarch_main(sizeof(argv) / sizeof(argv[0]) - 1, argv);
}
#define FG_COL -1
#define BG_COL 0
@ -168,8 +156,6 @@ int main(void)
strlcat(fn, entries[pos].d_name, sizeof(fn));
printf("%s\n", fn);
start_rarch(fn);
}
}

View File

@ -108,9 +108,6 @@ struct defaults
/* Public data structures. */
extern struct defaults g_defaults;
/* Public functions. */
int rarch_main(int argc, char *argv[]);
#ifdef __cplusplus
}
#endif

View File

@ -22,12 +22,12 @@
#include "../general.h"
#include <string.h>
int rarch_main(int argc, char *argv[]);
int rarch_main(int argc, char *argv[], void *data);
#undef main
int main(int argc, char *argv[])
{
while (rarch_main(argc, argv) == 0)
while (rarch_main(argc, argv, NULL) == 0)
{
if (optind + 1 >= argc)
return 0;

View File

@ -175,7 +175,7 @@ static char** waiting_argv;
[apple_platform loadingCore:nil withFile:nil];
if (rarch_main(waiting_argc, waiting_argv))
if (rarch_main(waiting_argc, waiting_argv, NULL))
apple_rarch_exited();
waiting_argc = 0;

View File

@ -279,7 +279,7 @@ enum
[self setDelegate:self];
if (rarch_main(0, NULL))
if (rarch_main(0, NULL, NULL))
apple_rarch_exited();
/* Setup window */
@ -290,7 +290,7 @@ enum
[apple_platform loadingCore:nil withFile:nil];
if (rarch_main(0, NULL))
if (rarch_main(0, NULL, NULL))
apple_rarch_exited();
#ifdef HAVE_MFI