(Linux) Restarting of core in non-HAVE_DYNAMIC mode now properly

implemented
This commit is contained in:
twinaphex 2016-02-05 19:16:35 +01:00
parent c67771fab6
commit f29c61bacc
2 changed files with 21 additions and 12 deletions

View File

@ -138,7 +138,7 @@ void fill_pathname_abbreviate_special(char *out_path,
} }
#if !defined(RARCH_CONSOLE) #if !defined(RARCH_CONSOLE)
void fill_pathname_application_path(char *buf, size_t size) void fill_pathname_application_path(char *s, size_t len)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
CFBundleRef bundle = CFBundleGetMainBundle(); CFBundleRef bundle = CFBundleGetMainBundle();
@ -146,22 +146,22 @@ void fill_pathname_application_path(char *buf, size_t size)
size_t i; size_t i;
(void)i; (void)i;
if (!size) if (!len)
return; return;
#ifdef _WIN32 #ifdef _WIN32
DWORD ret = GetModuleFileName(GetModuleHandle(NULL), buf, size - 1); DWORD ret = GetModuleFileName(GetModuleHandle(NULL), s, len - 1);
buf[ret] = '\0'; s[ret] = '\0';
#elif defined(__APPLE__) #elif defined(__APPLE__)
if (bundle) if (bundle)
{ {
CFURLRef bundle_url = CFBundleCopyBundleURL(bundle); CFURLRef bundle_url = CFBundleCopyBundleURL(bundle);
CFStringRef bundle_path = CFURLCopyPath(bundle_url); CFStringRef bundle_path = CFURLCopyPath(bundle_url);
CFStringGetCString(bundle_path, buf, size, kCFStringEncodingUTF8); CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8);
CFRelease(bundle_path); CFRelease(bundle_path);
CFRelease(bundle_url); CFRelease(bundle_url);
retro_assert(strlcat(buf, "nobin", size) < size); retro_assert(strlcat(s, "nobin", len) < len);
return; return;
} }
#elif defined(__HAIKU__) #elif defined(__HAIKU__)
@ -172,7 +172,7 @@ void fill_pathname_application_path(char *buf, size_t size)
{ {
if (info.type == B_APP_IMAGE) if (info.type == B_APP_IMAGE)
{ {
strlcpy(buf, info.name, size); strlcpy(s, info.name, len);
return; return;
} }
} }
@ -182,7 +182,7 @@ void fill_pathname_application_path(char *buf, size_t size)
static const char *exts[] = { "exe", "file", "path/a.out" }; static const char *exts[] = { "exe", "file", "path/a.out" };
char link_path[PATH_MAX_LENGTH] = {0}; char link_path[PATH_MAX_LENGTH] = {0};
*buf = '\0'; *s = '\0';
pid = getpid(); pid = getpid();
/* Linux, BSD and Solaris paths. Not standardized. */ /* Linux, BSD and Solaris paths. Not standardized. */
@ -192,11 +192,11 @@ void fill_pathname_application_path(char *buf, size_t size)
snprintf(link_path, sizeof(link_path), "/proc/%u/%s", snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
(unsigned)pid, exts[i]); (unsigned)pid, exts[i]);
ret = readlink(link_path, buf, size - 1); ret = readlink(link_path, s, len - 1);
if (ret >= 0) if (ret >= 0)
{ {
buf[ret] = '\0'; s[ret] = '\0';
return; return;
} }
} }

View File

@ -2145,6 +2145,8 @@ static int frontend_android_parse_drive_list(void *data)
#endif #endif
#ifndef HAVE_DYNAMIC #ifndef HAVE_DYNAMIC
#include "../../retroarch.h"
static bool frontend_linux_set_fork(enum frontend_fork fork_mode) static bool frontend_linux_set_fork(enum frontend_fork fork_mode)
{ {
switch (fork_mode) switch (fork_mode)
@ -2159,9 +2161,16 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode)
break; break;
case FRONTEND_FORK_RESTART: case FRONTEND_FORK_RESTART:
RARCH_LOG("FRONTEND_FORK_RESTART\n"); RARCH_LOG("FRONTEND_FORK_RESTART\n");
/* NOTE: We don't implement Salamander, so just turn
* this into FRONTEND_FORK_CORE. */
linux_fork_mode = FRONTEND_FORK_CORE; linux_fork_mode = FRONTEND_FORK_CORE;
{
char executable_path[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
fill_pathname_application_path(executable_path, sizeof(executable_path));
strlcpy(settings->libretro, executable_path, sizeof(settings->libretro));
}
rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL);
break; break;
case FRONTEND_FORK_NONE: case FRONTEND_FORK_NONE:
default: default: