mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 07:20:34 +00:00
(3DS) better handling of argc/argv, fixes crash in CIA builds.
This commit is contained in:
parent
c85e44d597
commit
8bd789389f
@ -34,6 +34,7 @@ OBJS += ctr/ctr_svchax.o
|
||||
ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJS += griffin/griffin.o
|
||||
else
|
||||
CFLAGS += -DHAVE_COMPRESSION
|
||||
OBJS += libretro-common/file/archive_file.o
|
||||
OBJS += libretro-common/file/archive_file_zlib.o
|
||||
OBJS += libretro-common/encodings/encoding_utf.o
|
||||
@ -132,7 +133,6 @@ else
|
||||
OBJS += list_special.o
|
||||
OBJS += libretro-common/lists/string_list.o
|
||||
OBJS += libretro-common/string/stdstring.o
|
||||
# OBJS += file_ops.o
|
||||
OBJS += libretro-common/file/nbio/nbio_stdio.o
|
||||
OBJS += libretro-common/lists/file_list.o
|
||||
OBJS += libretro-common/queues/message_queue.o
|
||||
@ -225,8 +225,6 @@ else
|
||||
OBJS += deps/zlib/trees.o
|
||||
OBJS += deps/zlib/uncompr.o
|
||||
OBJS += deps/zlib/zutil.o
|
||||
# OBJS += deps/zlib/ioapi.o
|
||||
# OBJS += deps/zlib/unzip.o
|
||||
OBJS += audio/audio_utils.o
|
||||
endif
|
||||
|
||||
@ -286,7 +284,6 @@ CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include
|
||||
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
|
||||
CFLAGS += -DHAVE_GRIFFIN=1 -DHAVE_FILTERS_BUILTIN -DHAVE_MENU -DHAVE_RGUI
|
||||
CFLAGS += -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG
|
||||
CFLAGS += -DHAVE_COMPRESSION
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "ctr_debug.h"
|
||||
|
||||
#define CTR_APPMEMALLOC_PTR ((u32*)0x1FF80040)
|
||||
@ -60,7 +61,8 @@ void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
|
||||
__system_initArgv();
|
||||
|
||||
}
|
||||
void __system_allocateHeaps() {
|
||||
void __system_allocateHeaps()
|
||||
{
|
||||
u32 tmp = 0;
|
||||
|
||||
MemInfo stack_memInfo;
|
||||
@ -135,48 +137,46 @@ int __system_argc;
|
||||
char** __system_argv;
|
||||
extern const char* __system_arglist;
|
||||
|
||||
//extern char* fake_heap_start;
|
||||
extern char* fake_heap_end;
|
||||
|
||||
void __system_initArgv()
|
||||
{
|
||||
int i;
|
||||
const char* temp = __system_arglist;
|
||||
|
||||
// Check if the argument list is present
|
||||
if (!temp)
|
||||
return;
|
||||
|
||||
// Retrieve argc
|
||||
__system_argc = *(u32*)temp;
|
||||
temp += sizeof(u32);
|
||||
|
||||
// Find the end of the argument data
|
||||
for (i = 0; i < __system_argc; i ++)
|
||||
struct
|
||||
{
|
||||
for (; *temp; temp ++);
|
||||
temp ++;
|
||||
u32 argc;
|
||||
char args[];
|
||||
}*arg_struct = (void*)__system_arglist;
|
||||
|
||||
__system_argc = 0;
|
||||
|
||||
if (arg_struct)
|
||||
__system_argc = arg_struct->argc;
|
||||
|
||||
if (__system_argc)
|
||||
{
|
||||
__system_argv = (char**) malloc((__system_argc + 1) * sizeof(char**));
|
||||
__system_argv[0] = arg_struct->args;
|
||||
for (i = 1; i < __system_argc; i++)
|
||||
__system_argv[i] = __system_argv[i - 1] + strlen(__system_argv[i - 1]) + 1;
|
||||
|
||||
i = __system_argc - 1;
|
||||
__system_argc = 1;
|
||||
while (i)
|
||||
{
|
||||
if(__system_argv[i] && isalnum(__system_argv[i][0])
|
||||
&& strncmp(__system_argv[i], "3dslink:/", 9))
|
||||
{
|
||||
__system_argv[1] = __system_argv[i];
|
||||
__system_argc = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Reserve heap memory for argv data
|
||||
u32 argSize = temp - __system_arglist - sizeof(u32);
|
||||
// __system_argv = (char**)fake_heap_start;
|
||||
// fake_heap_start += sizeof(char**)*(__system_argc + 1);
|
||||
// char* argCopy = fake_heap_start;
|
||||
// fake_heap_start += argSize;
|
||||
|
||||
__system_argv = malloc(sizeof(char**)*(__system_argc + 1) + argSize);
|
||||
char* argCopy = (char*)__system_argv + sizeof(char**)*(__system_argc + 1);
|
||||
|
||||
|
||||
// Fill argv array
|
||||
memcpy(argCopy, &__system_arglist[4], argSize);
|
||||
temp = argCopy;
|
||||
for (i = 0; i < __system_argc; i ++)
|
||||
i--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__system_argv[i] = (char*)temp;
|
||||
for (; *temp; temp ++);
|
||||
temp ++;
|
||||
__system_argc = 1;
|
||||
__system_argv = (char**) malloc(sizeof(char**) * 2);
|
||||
__system_argv[0] = "sdmc:/retroarch/retroarch";
|
||||
}
|
||||
__system_argv[__system_argc] = NULL;
|
||||
}
|
||||
@ -195,7 +195,8 @@ void __attribute__((noreturn)) __ctru_exit(int rc)
|
||||
__libctru_exit(rc);
|
||||
}
|
||||
|
||||
typedef union{
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned description : 10;
|
||||
@ -238,6 +239,7 @@ void wait_for_input(void)
|
||||
|
||||
if (kDown & KEY_SELECT)
|
||||
exit(0);
|
||||
|
||||
#if 0
|
||||
select_pressed = true;
|
||||
#endif
|
||||
|
@ -80,27 +80,6 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
|
||||
"filters", sizeof(g_defaults.dir.remap));
|
||||
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
|
||||
"retroarch.cfg", sizeof(g_defaults.path.config));
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
/* clean-up argc/argv */
|
||||
if(*argc)
|
||||
{
|
||||
int i = *argc - 1;
|
||||
*argc = 0;
|
||||
while (i)
|
||||
{
|
||||
if(argv[i] && isalnum(argv[i][0])
|
||||
&& strncmp(argv[i], "3dslink:/", 9))
|
||||
{
|
||||
argv[1] = argv[i];
|
||||
argv[2] = NULL;
|
||||
*argc = 2;
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void frontend_ctr_deinit(void *data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user