mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 21:00:17 +02:00
AOTIR: Review feedback
This commit is contained in:
1 parent
8e06966ddc
commit
075cd423ed
4 files changed
+13
-44
No files matched your search
+3
-1
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <filesystem>
|
||||
|
||||
#include "Interface/Core/GdbServer.h"
|
||||
|
||||
@@ -1239,7 +1240,8 @@ namespace FEXCore::Context {
|
||||
|
||||
void Context::AddNamedRegion(uintptr_t Base, uintptr_t Size, uintptr_t Offset, const std::string &filename) {
|
||||
// TODO: Support overlapping maps and region splitting
|
||||
auto base_filename = filename.substr(filename.find_last_of("/\\") + 1);
|
||||
auto base_filename = std::filesystem::path(filename).filename().string();
|
||||
|
||||
if (base_filename.size()) {
|
||||
auto filename_hash = fasthash64(filename.c_str(), filename.size(), 0xBAADF00D);
|
||||
|
||||
|
||||
@@ -293,14 +293,12 @@ int main(int argc, char **argv, char **const envp) {
|
||||
});
|
||||
}
|
||||
|
||||
std::string base_filename = Program.substr(Program.find_last_of("/\\") + 1) + ".fex-emu.iraot";
|
||||
|
||||
if (AOTIRLoad() || AOTIRCapture()) {
|
||||
LogMan::Msg::I("Warning: AOTIR is experimental, and might lead to crashes. Capture doesn't work with programs that fork.");
|
||||
}
|
||||
|
||||
FEXCore::Context::SetAOTIRLoader(CTX, [](const std::string &fileid) -> std::unique_ptr<std::istream> {
|
||||
auto filepath = std::string(getenv("HOME")) + "/.fex-emu/aotir/" + fileid;
|
||||
auto filepath = std::filesystem::path(getenv("HOME")) / ".fex-emu" / "aotir" / fileid;
|
||||
|
||||
return std::make_unique<std::ifstream>(filepath, std::ios::in | std::ios::binary);
|
||||
});
|
||||
@@ -308,11 +306,10 @@ int main(int argc, char **argv, char **const envp) {
|
||||
FEXCore::Context::RunUntilExit(CTX);
|
||||
|
||||
if (AOTIRCapture()) {
|
||||
mkdir((std::string(getenv("HOME")) + "/.fex-emu/").c_str(), 0700);
|
||||
mkdir((std::string(getenv("HOME")) + "/.fex-emu/aotir").c_str(), 0700);
|
||||
std::filesystem::create_directories(std::filesystem::path(getenv("HOME")) / ".fex-emu" / "aotir");
|
||||
|
||||
auto WroteCache = FEXCore::Context::WriteAOTIR(CTX, [](const std::string& fileid) -> std::unique_ptr<std::ostream> {
|
||||
auto filepath = std::string(getenv("HOME")) + "/.fex-emu/aotir/" + fileid;
|
||||
auto filepath = std::filesystem::path(getenv("HOME")) / ".fex-emu" / "aotir" / fileid;
|
||||
auto AOTWrite = std::make_unique<std::ofstream>(filepath, std::ios::out | std::ios::binary);
|
||||
if (*AOTWrite) {
|
||||
std::filesystem::resize_file(filepath, 0);
|
||||
|
||||
@@ -9,27 +9,12 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <unistd.h>
|
||||
#include <filesystem>
|
||||
|
||||
static std::string get_fdpath(int fd)
|
||||
{
|
||||
std::vector<char> buf(400);
|
||||
ssize_t len;
|
||||
|
||||
std::string fdToName = "/proc/self/fd/" + std::to_string(fd);
|
||||
|
||||
do
|
||||
{
|
||||
buf.resize(buf.size() + 100);
|
||||
len = ::readlink(fdToName.c_str(), &(buf[0]), buf.size());
|
||||
} while (buf.size() == len);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
buf[len] = '\0';
|
||||
return (std::string(&(buf[0])));
|
||||
}
|
||||
/* handle error */
|
||||
return "";
|
||||
std::error_code ec;
|
||||
return std::filesystem::canonical(std::filesystem::path("/proc/self/fd") / std::to_string(fd), ec).string();
|
||||
}
|
||||
|
||||
namespace FEX::HLE::x32 {
|
||||
|
||||
@@ -11,27 +11,12 @@
|
||||
#include <FEXCore/Core/Context.h>
|
||||
#include <FEXCore/Config/Config.h>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
std::string get_fdpath(int fd)
|
||||
static std::string get_fdpath(int fd)
|
||||
{
|
||||
std::vector<char> buf(400);
|
||||
ssize_t len;
|
||||
|
||||
std::string fdToName = "/proc/self/fd/" + std::to_string(fd);
|
||||
|
||||
do
|
||||
{
|
||||
buf.resize(buf.size() + 100);
|
||||
len = ::readlink(fdToName.c_str(), &(buf[0]), buf.size());
|
||||
} while (buf.size() == len);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
buf[len] = '\0';
|
||||
return (std::string(&(buf[0])));
|
||||
}
|
||||
/* handle error */
|
||||
return "";
|
||||
std::error_code ec;
|
||||
return std::filesystem::canonical(std::filesystem::path("/proc/self/fd") / std::to_string(fd), ec).string();
|
||||
}
|
||||
|
||||
namespace FEX::HLE::x64 {
|
||||
|
||||
Reference in new issue
Block a user