Merge pull request #4276 from unknownbrackets/linux-minor

Improve Linux flash0 path handling, fix __cpuidex() in some gccs
This commit is contained in:
Henrik Rydgård 2013-10-21 01:10:04 -07:00
commit 42464c4d1c
5 changed files with 58 additions and 24 deletions

View file

@ -62,23 +62,18 @@ void __cpuidex(int regs[4], int cpuid_leaf, int ecxval)
#if defined(__i386__) #if defined(__i386__)
"pushl %%ebx;\n\t" "pushl %%ebx;\n\t"
#endif #endif
"movl %4, %%eax;\n\t"
"movl %5, %%ecx;\n\t"
"cpuid;\n\t" "cpuid;\n\t"
"movl %%eax, %0;\n\t"
"movl %%ebx, %1;\n\t" "movl %%ebx, %1;\n\t"
"movl %%ecx, %2;\n\t"
"movl %%edx, %3;\n\t"
#if defined(__i386__) #if defined(__i386__)
"popl %%ebx;\n\t" "popl %%ebx;\n\t"
#endif #endif
:"=m" (regs[0]), "=m" (regs[1]), "=m" (regs[2]), "=m" (regs[3]) :"=a" (regs[0]), "=m" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
:"r" (cpuid_leaf), "r" (ecxval) :"a" (cpuid_leaf), "c" (ecxval)
:"%eax",
#if !defined(__i386__) #if !defined(__i386__)
"%ebx", :"%ebx");
#else
);
#endif #endif
"%ecx", "%edx");
#endif #endif
} }
void __cpuid(int regs[4], int cpuid_leaf) void __cpuid(int regs[4], int cpuid_leaf)

View file

@ -3,6 +3,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QCoreApplication>
#include "QtHost.h" #include "QtHost.h"
#include "LogManager.h" #include "LogManager.h"
@ -313,8 +314,19 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co
g_Config.currentDirectory = QDir::homePath().toStdString(); g_Config.currentDirectory = QDir::homePath().toStdString();
} }
g_Config.memCardDirectory = QDir::homePath().toStdString()+"/.ppsspp/"; g_Config.memCardDirectory = QDir::homePath().toStdString() + "/.ppsspp/";
g_Config.flash0Directory = g_Config.memCardDirectory+"/flash0/";
#if defined(Q_OS_LINUX) && !defined(ARM)
std::string program_path = QCoreApplication::applicationDirPath().toStdString();
if (File::Exists(program_path + "/flash0"))
g_Config.flash0Directory = program_path + "/flash0/";
else if (File::Exists(program_path + "/../flash0"))
g_Config.flash0Directory = program_path + "/../flash0/";
else
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
#else
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
#endif
LogManager::Init(); LogManager::Init();
if (fileToLog != NULL) if (fileToLog != NULL)

View file

@ -26,7 +26,7 @@
class MultiTouchButton : public UI::View { class MultiTouchButton : public UI::View {
public: public:
MultiTouchButton(int bgImg, int img, float scale, UI::LayoutParams *layoutParams) MultiTouchButton(int bgImg, int img, float scale, UI::LayoutParams *layoutParams)
: UI::View(layoutParams), pointerDownMask_(0), bgImg_(bgImg), img_(img), scale_(scale), angle_(0.0f), flipImageH_(false) { : UI::View(layoutParams), pointerDownMask_(0), scale_(scale), bgImg_(bgImg), img_(img), angle_(0.0f), flipImageH_(false) {
} }
virtual void Key(const KeyInput &input) {} virtual void Key(const KeyInput &input) {}

View file

@ -215,6 +215,28 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo
#endif #endif
} }
const std::string NativeProgramPath() {
#if (defined(__APPLE__) && !defined(IOS)) || defined(__linux__)
char program_path[4096];
uint32_t program_path_size = sizeof(program_path) - 1;
#if defined(__linux__)
if (readlink("/proc/self/exe", program_path, 4095) > 0) {
#elif defined(__APPLE__) && !defined(IOS)
if (_NSGetExecutablePath(program_path, &program_path_size) == 0) {
#else
#error Unmatched ifdef.
#endif
program_path[sizeof(program_path) - 1] = '\0';
char *last_slash = strrchr(program_path, '/');
if (last_slash != NULL)
*(last_slash + 1) = '\0';
return program_path;
}
#endif
return "";
}
void NativeInit(int argc, const char *argv[], void NativeInit(int argc, const char *argv[],
const char *savegame_directory, const char *external_directory, const char *installID) { const char *savegame_directory, const char *external_directory, const char *installID) {
bool skipLogo = false; bool skipLogo = false;
@ -226,13 +248,11 @@ void NativeInit(int argc, const char *argv[],
#ifdef IOS #ifdef IOS
user_data_path += "/"; user_data_path += "/";
#elif defined(__APPLE__) #elif defined(__APPLE__)
char program_path[4090]; if (File::Exists(NativeProgramPath() + "assets"))
uint32_t program_path_size = sizeof(program_path); VFSRegister("", new DirectoryAssetReader((NativeProgramPath() + "assets/").c_str()));
_NSGetExecutablePath(program_path,&program_path_size); // It's common to be in a build-xyz/ directory.
*(strrchr(program_path, '/')+1) = '\0'; else
char assets_path[4096]; VFSRegister("", new DirectoryAssetReader((NativeProgramPath() + "../assets/").c_str()));
sprintf(assets_path,"%sassets/",program_path);
VFSRegister("", new DirectoryAssetReader(assets_path));
#endif #endif
// We want this to be FIRST. // We want this to be FIRST.
@ -259,9 +279,15 @@ void NativeInit(int argc, const char *argv[],
g_Config.memCardDirectory = user_data_path; g_Config.memCardDirectory = user_data_path;
g_Config.flash0Directory = std::string(external_directory) + "/flash0/"; g_Config.flash0Directory = std::string(external_directory) + "/flash0/";
#elif !defined(_WIN32) #elif !defined(_WIN32)
// Linux, Mac. Does this path really make sense?
g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/"; g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/"; std::string program_path = NativeProgramPath();
if (program_path.empty())
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
else if (File::Exists(program_path + "flash0"))
g_Config.flash0Directory = program_path + "flash0/";
// It's common to be in a build-xyz/ directory.
else
g_Config.flash0Directory = program_path + "../flash0/";
#endif #endif
#ifndef _WIN32 #ifndef _WIN32

View file

@ -329,8 +329,9 @@ int main(int argc, const char* argv[])
#if defined(ANDROID) #if defined(ANDROID)
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__) #elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
#elif !defined(_WIN32) #elif !defined(_WIN32)
g_Config.memCardDirectory = std::string(getenv("HOME"))+"/.ppsspp/"; g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
g_Config.flash0Directory = g_Config.memCardDirectory+"/flash/"; // TODO: This isn't a great place.
g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";
#endif #endif
if (screenshotFilename != 0) if (screenshotFilename != 0)