support c++ tools on macos (#2063)

Running reference tests/decompiler should now be possible on macos
(arm). Most of the changes were just cleaning up places where we were
sloppy with ifdefs, but there were two interesting ones:
- `Printer.cpp` was updated to not use a recursive function for printing
lists, to avoid stack overflow
- I replaced xxhash with another version of the same library that
supports arm (the one that comes in zstd). The interface is C instead of
C++ but it's not bad to use. I confirmed that the extractor succeeds on
jak 1 iso so it looks like this gives us the same results as the old
library.
This commit is contained in:
water111 2022-12-22 17:12:05 -05:00 committed by GitHub
parent 98c2291102
commit 73561f10a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 254 additions and 2050 deletions

4
.gitignore vendored
View file

@ -10,6 +10,10 @@ decompiler_out/*
decompiler_out2/*
logs/*
# for vscode/clangd
.cache/*
.DS_Store
# wsl apparently builds to here?
linux-default/

View file

@ -94,6 +94,34 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
set(THIRDPARTY_IGNORED_WARNINGS "-w")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
message(STATUS "AppleClang detected - Setting Defaults")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} \
-Wall \
-Winit-self \
-ggdb \
-Wextra \
-Wno-cast-align \
-Wcast-qual \
-Wdisabled-optimization \
-Wformat \
-Wextra \
-Wmissing-include-dirs \
-Woverloaded-virtual \
-Wredundant-decls \
-Wshadow \
-Wsign-promo \
-O3 \
-fdiagnostics-color=always"
)
# additional c++ flags for release mode for our projects
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
set(THIRDPARTY_IGNORED_WARNINGS "-w")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-stack_size -Wl,0x20000000")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message(STATUS "MSVC detected - Setting Defaults")

View file

@ -57,6 +57,8 @@ target_link_libraries(common fmt lzokay replxx libzstd_static)
if(WIN32)
target_link_libraries(common wsock32 ws2_32 windowsapp)
elseif(APPLE)
# don't need anything special
else()
target_link_libraries(common stdc++fs)
endif()

View file

@ -30,3 +30,7 @@ struct u128 {
};
};
static_assert(sizeof(u128) == 16, "u128");
#if defined __linux || defined __linux__ || defined __APPLE__
#define OS_POSIX
#endif

View file

@ -688,6 +688,54 @@ bool set_regs_now(const ThreadID& tid, const Regs& out) {
// todo, set fprs.
return true;
}
#elif __APPLE__
ThreadID::ThreadID(const std::string& str) {}
std::string ThreadID::to_string() const {
return "invalid";
}
ThreadID get_current_thread_id();
bool attach_and_break(const ThreadID& tid);
void allow_debugging();
bool detach_and_resume(const ThreadID& tid) {
return false;
}
bool get_regs_now(const ThreadID& tid, Regs* out) {
return false;
}
bool set_regs_now(const ThreadID& tid, const Regs& in) {
return false;
}
bool break_now(const ThreadID& tid) {
return false;
}
bool cont_now(const ThreadID& tid) {
return false;
}
bool open_memory(const ThreadID& tid, MemoryHandle* out);
bool close_memory(const ThreadID& tid, MemoryHandle* handle) {
return false;
}
bool read_goal_memory(u8* dest_buffer,
int size,
u32 goal_addr,
const DebugContext& context,
const MemoryHandle& mem) {
return false;
}
bool write_goal_memory(const u8* src_buffer,
int size,
u32 goal_addr,
const DebugContext& context,
const MemoryHandle& mem) {
return false;
}
bool check_stopped(const ThreadID& tid, SignalInfo* out) {
return false;
}
#endif
const char* gpr_names[] = {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",

View file

@ -20,7 +20,7 @@
#endif
namespace xdbg {
#ifdef __linux
#ifdef OS_POSIX
/*!
* Identification for a thread.

View file

@ -4,7 +4,8 @@
*/
// clang-format off
#ifdef __linux
#include "common/common_types.h"
#ifdef OS_POSIX
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <unistd.h>
@ -22,7 +23,7 @@
// clang-format on
int open_socket(int af, int type, int protocol) {
#ifdef __linux
#ifdef OS_POSIX
return socket(af, type, protocol);
#elif _WIN32
WSADATA wsaData = {0};
@ -45,7 +46,7 @@ int connect_socket(int socket, sockaddr* addr, int nameLen) {
return result;
}
#ifdef __linux
#ifdef OS_POSIX
int accept_socket(int socket, sockaddr* addr, socklen_t* addrLen) {
return accept(socket, addr, addrLen);
}
@ -106,7 +107,7 @@ void close_socket(int sock) {
if (sock < 0) {
return;
}
#ifdef __linux
#ifdef OS_POSIX
close(sock);
#elif _WIN32
closesocket(sock);
@ -130,7 +131,7 @@ int set_socket_option(int socket, int level, int optname, const void* optval, in
}
int set_socket_timeout(int socket, long microSeconds) {
#ifdef __linux
#ifdef OS_POSIX
struct timeval timeout = {};
timeout.tv_sec = 0;
timeout.tv_usec = microSeconds;
@ -150,7 +151,7 @@ int set_socket_timeout(int socket, long microSeconds) {
int write_to_socket(int socket, const char* buf, int len) {
int bytes_wrote = 0;
#ifdef __linux
#ifdef OS_POSIX
bytes_wrote = send(socket, buf, len, MSG_NOSIGNAL);
#elif _WIN32
bytes_wrote = send(socket, buf, len, 0);
@ -162,7 +163,7 @@ int write_to_socket(int socket, const char* buf, int len) {
}
int read_from_socket(int socket, char* buf, int len) {
#ifdef __linux
#ifdef OS_POSIX
return read(socket, buf, len);
#elif _WIN32
return recv(socket, buf, len, 0);
@ -170,7 +171,7 @@ int read_from_socket(int socket, char* buf, int len) {
}
bool socket_timed_out() {
#ifdef __linux
#ifdef OS_POSIX
return errno == EAGAIN;
#elif _WIN32
auto err = WSAGetLastError();

View file

@ -6,7 +6,8 @@
*/
// clang-format off
#ifdef __linux
#include "common/common_types.h"
#ifdef OS_POSIX
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@ -24,11 +25,13 @@
const int TCP_SOCKET_LEVEL = SOL_TCP;
#elif _WIN32
const int TCP_SOCKET_LEVEL = IPPROTO_TCP;
#elif __APPLE__
const int TCP_SOCKET_LEVEL = IPPROTO_TCP;
#endif
int open_socket(int af, int type, int protocol);
int connect_socket(int socket, sockaddr* addr, int nameLen);
#ifdef __linux
#ifdef OS_POSIX
int accept_socket(int socket, sockaddr* addr, socklen_t* addrLen);
int select_and_accept_socket(int socket, sockaddr* addr, socklen_t* addrLen, int microSeconds);
#elif _WIN32

View file

@ -2,6 +2,7 @@
#include "XSocketServer.h"
#include "common/cross_sockets/XSocket.h"
#include "common/common_types.h"
#include "third-party/fmt/core.h"
@ -41,7 +42,7 @@ bool XSocketServer::init_server() {
return false;
}
#ifdef __linux
#ifdef OS_POSIX
int server_socket_opt = SO_REUSEADDR | SO_REUSEPORT;
#elif _WIN32
int server_socket_opt = SO_EXCLUSIVEADDRUSE;

View file

@ -3,6 +3,7 @@
#include <functional>
#include <mutex>
#include <thread>
#include <vector>
#include "common/common_types.h"
#include "common/cross_sockets/XSocket.h"

View file

@ -7,21 +7,22 @@
#include "common/util/Assert.h"
#include "common/util/FileUtil.h"
#include "common/common_types.h"
#include "third-party/fmt/core.h"
#include "third-party/json.hpp"
#ifdef __linux__
u32 get_current_tid() {
return (u32)pthread_self();
#ifdef OS_POSIX
u64 get_current_tid() {
return (u64)pthread_self();
}
#else
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "Processthreadsapi.h"
u32 get_current_tid() {
return (u32)GetCurrentThreadId();
u64 get_current_tid() {
return (u64)GetCurrentThreadId();
}
#endif
#include "common/log/log.h"

View file

@ -8,9 +8,9 @@
struct ProfNode {
u64 ts;
u64 tid;
char name[32];
enum Kind : u8 { BEGIN, END, INSTANT, UNUSED } kind = UNUSED;
u32 tid;
};
class GlobalProfiler {

View file

@ -3,6 +3,8 @@
#include <cmath>
#include <mutex>
#include "common/goos/Object.h"
#include "third-party/fmt/core.h"
namespace pretty_print {
@ -74,14 +76,12 @@ goos::Object build_list(const std::vector<goos::Object>& objects) {
// build a list out of an array of forms
goos::Object build_list(const goos::Object* objects, int count) {
ASSERT(count);
auto car = objects[0];
goos::Object cdr;
if (count - 1) {
cdr = build_list(objects + 1, count - 1);
} else {
cdr = goos::Object::make_empty_list();
goos::Object result = goos::Object::make_empty_list();
for (int i = count; i-- > 0;) {
result = goos::PairObject::make_new(objects[i], result);
}
return goos::PairObject::make_new(car, cdr);
return result;
}
// build a list out of a vector of strings that are converted to symbols

View file

@ -2,6 +2,8 @@
#include <thread>
#include "common/common_types.h"
double FrameLimiter::round_to_nearest_60fps(double current) {
double one_frame = 1.f / 60.f;
int frames_missed = (current / one_frame); // rounds down
@ -11,7 +13,7 @@ double FrameLimiter::round_to_nearest_60fps(double current) {
return (frames_missed + 1) * one_frame;
}
#ifdef __linux__
#ifdef OS_POSIX
FrameLimiter::FrameLimiter() {}

View file

@ -1,5 +1,7 @@
#include "Timer.h"
#include "common/common_types.h"
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
@ -37,7 +39,7 @@ int Timer::clock_gettime_monotonic(struct timespec* tv) const {
#endif
void Timer::start() {
#ifdef __linux__
#ifdef OS_POSIX
clock_gettime(CLOCK_MONOTONIC, &_startTime);
#elif _WIN32
clock_gettime_monotonic(&_startTime);
@ -46,7 +48,7 @@ void Timer::start() {
int64_t Timer::getNs() const {
struct timespec now = {};
#ifdef __linux__
#ifdef OS_POSIX
clock_gettime(CLOCK_MONOTONIC, &now);
#elif _WIN32
clock_gettime_monotonic(&now);

View file

@ -1,6 +1,26 @@
#include "crc32.h"
#include <cstring>
#ifdef __APPLE__
#include <arm_acle.h>
u32 crc32(const u8* data, size_t size) {
u32 result = 0xffffffff;
while (size >= 4) {
u32 x;
memcpy(&x, data, 4);
data += 4;
size -= 4;
result = __crc32w(result, x);
}
while (size) {
result = __crc32b(result, *data);
data++;
size--;
}
return ~result;
}
#else
#include <immintrin.h>
u32 crc32(const u8* data, size_t size) {
@ -18,4 +38,5 @@ u32 crc32(const u8* data, size_t size) {
size--;
}
return ~result;
}
}
#endif

View file

@ -21,6 +21,13 @@ size_t get_peak_rss() {
#ifdef _WIN32
// windows has a __cpuid
#include <intrin.h>
#elif __APPLE__
// for now, just return 0's.
void __cpuidex(int result[4], int eax, int ecx) {
for (int i = 0; i < 4; i++) {
result[i] = 0;
}
}
#else
// using int to be compatible with msvc's intrinsic
void __cpuidex(int result[4], int eax, int ecx) {

View file

@ -5,6 +5,8 @@
#include "common/util/Assert.h"
#include "common/util/FileUtil.h"
#include "third-party/zstd/lib/common/xxhash.h"
IsoFile::IsoFile() {
root.is_dir = true;
}
@ -102,7 +104,7 @@ void unpack_entry(FILE* fp,
file_util::write_binary_file(path_to_entry.string(), buffer.data(), buffer.size());
iso.files_extracted++;
if (iso.shouldHash) {
xxh::hash_t<64> hash = xxh::xxhash<64>(buffer);
auto hash = XXH64(buffer.data(), buffer.size(), 0);
iso.hashes.push_back(hash);
}
}

View file

@ -5,8 +5,6 @@
#include "common/util/FileUtil.h"
#include "third-party/xxhash.hpp"
struct IsoFile {
struct Entry {
bool is_dir = false;
@ -29,7 +27,7 @@ struct IsoFile {
bool shouldHash = false;
// There is no reason to map to the files, as we don't retain mappings of each file's expected
// hash
std::vector<xxh::hash64_t> hashes = {};
std::vector<uint64_t> hashes = {};
IsoFile();
};

View file

@ -1108,7 +1108,7 @@ void EmptyElement::get_modified_regs(RegSet&) const {}
/////////////////////////////
bool cmp(Register x, Register y) {
int comparison = x.to_string().compare(y.to_string());
int comparison = x.to_string() > y.to_string();
if (comparison <= 0)
return true;
return false;
@ -1118,7 +1118,7 @@ RLetElement::RLetElement(Form* _body, RegSet _regs) : body(_body) {
for (auto& reg : _regs) {
sorted_regs.push_back(reg);
}
std::sort(sorted_regs.begin(), sorted_regs.end(), cmp);
std::stable_sort(sorted_regs.begin(), sorted_regs.end(), cmp);
}
void RLetElement::apply(const std::function<void(FormElement*)>& f) {

View file

@ -13,7 +13,7 @@
#include "game/kernel/common/kboot.h"
#include "third-party/json.hpp"
#include "third-party/xxhash.hpp"
#include "third-party/zstd/lib/common/xxhash.h"
enum class ExtractorErrorCode {
SUCCESS = 0,
@ -54,7 +54,7 @@ struct ISOMetadata {
std::string canonical_name;
int region; // territory code
int num_files;
xxh::hash64_t contents_hash;
uint64_t contents_hash;
std::string decomp_config;
std::string game_name;
std::vector<std::string> flags;
@ -65,7 +65,7 @@ struct ISOMetadata {
// then the database isn't adequate and everything must change
struct BuildInfo {
std::string serial = "";
xxh::hash64_t elf_hash = 0;
uint64_t elf_hash = 0;
};
void to_json(nlohmann::json& j, const BuildInfo& info) {
@ -101,35 +101,35 @@ static const ISOMetadata jak1_ntsc_black_label_info = {
{"jak1-black-label"}};
// { SERIAL : { ELF_HASH : ISOMetadataDatabase } }
static const std::unordered_map<std::string, std::unordered_map<xxh::hash64_t, ISOMetadata>>
isoDatabase{{"SCUS-97124",
{{7280758013604870207U, jak1_ntsc_black_label_info},
{744661860962747854,
{"Jak & Daxter™: The Precursor Legacy",
GAME_TERRITORY_SCEA,
338,
8538304367812415885U,
"jak1_jp",
"jak1",
{}}}}},
{"SCES-50361",
{{12150718117852276522U,
{"Jak & Daxter™: The Precursor Legacy",
GAME_TERRITORY_SCEE,
338,
16850370297611763875U,
"jak1_pal",
"jak1",
{}}}}},
{"SCPS-15021",
{{16909372048085114219U,
{"ジャックXダクスター ~ 旧世界の遺産",
GAME_TERRITORY_SCEI,
338,
1262350561338887717,
"jak1_jp",
"jak1",
{}}}}}};
static const std::unordered_map<std::string, std::unordered_map<uint64_t, ISOMetadata>> isoDatabase{
{"SCUS-97124",
{{7280758013604870207U, jak1_ntsc_black_label_info},
{744661860962747854,
{"Jak & Daxter™: The Precursor Legacy",
GAME_TERRITORY_SCEA,
338,
8538304367812415885U,
"jak1_jp",
"jak1",
{}}}}},
{"SCES-50361",
{{12150718117852276522U,
{"Jak & Daxter™: The Precursor Legacy",
GAME_TERRITORY_SCEE,
338,
16850370297611763875U,
"jak1_pal",
"jak1",
{}}}}},
{"SCPS-15021",
{{16909372048085114219U,
{"ジャックXダクスター ~ 旧世界の遺産",
GAME_TERRITORY_SCEI,
338,
1262350561338887717,
"jak1_jp",
"jak1",
{}}}}}};
std::optional<ISOMetadata> get_version_info_from_build_info(const BuildInfo& build_info) {
if (build_info.serial.empty() || build_info.elf_hash == 0) {
@ -168,10 +168,10 @@ ISOMetadata get_version_info_or_default(const fs::path& iso_data_path) {
return version_info;
}
std::tuple<std::optional<std::string>, std::optional<xxh::hash64_t>> findElfFile(
std::tuple<std::optional<std::string>, std::optional<uint64_t>> findElfFile(
const fs::path& extracted_iso_path) {
std::optional<std::string> serial = std::nullopt;
std::optional<xxh::hash64_t> elf_hash = std::nullopt;
std::optional<uint64_t> elf_hash = std::nullopt;
for (const auto& entry : fs::directory_iterator(extracted_iso_path)) {
auto as_str = entry.path().filename().string();
if (std::regex_match(as_str, std::regex(".{4}_.{3}\\..{2}"))) {
@ -184,7 +184,7 @@ std::tuple<std::optional<std::string>, std::optional<xxh::hash64_t>> findElfFile
std::vector<u8> buffer(size);
rewind(fp);
fread(&buffer[0], sizeof(std::vector<u8>::value_type), buffer.size(), fp);
elf_hash = std::make_optional(xxh::xxhash<64>(buffer));
elf_hash = std::make_optional(XXH64(buffer.data(), buffer.size(), 0));
fclose(fp);
break;
}
@ -194,9 +194,9 @@ std::tuple<std::optional<std::string>, std::optional<xxh::hash64_t>> findElfFile
void log_potential_new_db_entry(ExtractorErrorCode error_code,
const std::string& serial,
const xxh::hash64_t elf_hash,
const uint64_t elf_hash,
const int files_extracted,
const xxh::hash64_t contents_hash) {
const uint64_t contents_hash) {
// Finally, return the result
// Generate the map entry to make things simple, just convienance
if (error_code == ExtractorErrorCode::VALIDATION_SERIAL_MISSING_FROM_DB) {
@ -237,28 +237,28 @@ std::tuple<bool, ExtractorErrorCode> is_iso_file(fs::path path_to_supposed_iso)
return {true, ExtractorErrorCode::SUCCESS};
}
std::tuple<xxh::hash64_t, int> calculate_extraction_hash(const IsoFile& iso_file) {
std::tuple<uint64_t, int> calculate_extraction_hash(const IsoFile& iso_file) {
// - XOR all hashes together and hash the result. This makes the ordering of the hashes (aka
// files) irrelevant
xxh::hash64_t combined_hash = 0;
uint64_t combined_hash = 0;
for (const auto& hash : iso_file.hashes) {
combined_hash ^= hash;
}
return {xxh::xxhash<64>({combined_hash}), iso_file.hashes.size()};
return {XXH64(&combined_hash, sizeof(uint64_t), 0), iso_file.hashes.size()};
}
std::tuple<xxh::hash64_t, int> calculate_extraction_hash(const fs::path& extracted_iso_path) {
std::tuple<uint64_t, int> calculate_extraction_hash(const fs::path& extracted_iso_path) {
// - XOR all hashes together and hash the result. This makes the ordering of the hashes (aka
// files) irrelevant
xxh::hash64_t combined_hash = 0;
uint64_t combined_hash = 0;
int filec = 0;
for (auto const& dir_entry : fs::recursive_directory_iterator(extracted_iso_path)) {
if (dir_entry.is_regular_file()) {
auto buffer = file_util::read_binary_file(dir_entry.path().string());
auto hash = xxh::xxhash<64>(buffer);
auto hash = XXH64(buffer.data(), buffer.size(), 0);
combined_hash ^= hash;
filec++;
}
}
return {xxh::xxhash<64>({combined_hash}), filec};
return {XXH64(&combined_hash, sizeof(uint64_t), 0), filec};
}

View file

@ -35,7 +35,7 @@ IsoFile extract_files(fs::path input_file_path, fs::path extracted_iso_path) {
std::tuple<std::optional<ISOMetadata>, ExtractorErrorCode> validate(
const fs::path& extracted_iso_path,
const xxh::hash64_t expected_hash,
const uint64_t expected_hash,
const int expected_num_files) {
if (!fs::exists(extracted_iso_path / "DGO")) {
lg::error("input folder doesn't have a DGO folder. Is this the right input?");

View file

@ -1,5 +1,7 @@
#include "fr3_to_gltf.h"
#include <unordered_map>
#include "common/custom_data/Tfrag3Data.h"
#include "common/math/Vector.h"

View file

@ -26,7 +26,7 @@ OverlordDataSource isodrv;
u32 modsrc;
// Reboot IOP with IOP kernel from DVD/CD on boot
u32 reboot;
u32 reboot_iop;
const char* init_types[] = {"fakeiso", "deviso", "iso_cd"};
u8 pad_dma_buf[2 * SCE_PAD_DMA_BUFFER_SIZE];
@ -41,7 +41,7 @@ void kmachine_init_globals_common() {
memset(pad_dma_buf, 0, sizeof(pad_dma_buf));
isodrv = fakeiso; // changed. fakeiso is the only one that works in opengoal.
modsrc = 1;
reboot = 1;
reboot_iop = 1;
vif1_interrupt_handler = 0;
vblank_interrupt_handler = 0;
ee_clock_timer = Timer();

View file

@ -19,7 +19,7 @@ extern OverlordDataSource isodrv;
extern u32 modsrc;
// Reboot IOP on start?
extern u32 reboot;
extern u32 reboot_iop; // renamed to reboot_iop to avoid conflict
extern const char* init_types[];
extern u32 vblank_interrupt_handler;

View file

@ -63,7 +63,7 @@ void output_unload(const char* name);
*/
void output_segment_load(const char* name, Ptr<u8> link_block, u32 flags);
#ifdef __linux__
#ifdef OS_POSIX
/*!
* Print to the GOAL print buffer from C
*/
@ -80,7 +80,7 @@ void cprintf(const char* format, ...);
*/
void reverse(char* s);
#ifdef __linux__
#ifdef OS_POSIX
/*!
* Print directly to the C stdout
* The "k" parameter is ignored, so this is just like printf
@ -94,7 +94,7 @@ void Msg(s32 k, const char* format, ...) __attribute__((format(printf, 2, 3)));
void Msg(s32 k, const char* format, ...);
#endif
#ifdef __linux__
#ifdef OS_POSIX
/*!
* Print directly to the C stdout
* This is identical to Msg.
@ -107,7 +107,7 @@ void MsgWarn(const char* format, ...) __attribute__((format(printf, 1, 2)));
*/
void MsgWarn(const char* format, ...);
#endif
#ifdef __linux__
#ifdef OS_POSIX
/*!
* Print directly to the C stdout
* This is identical to Msg.

View file

@ -60,7 +60,7 @@ void InitParms(int argc, const char* const* argv) {
DiskBoot = 1;
isodrv = fakeiso;
modsrc = 0;
reboot = 0;
reboot_iop = 0;
DebugSegment = 0;
MasterDebug = 0;
}
@ -75,7 +75,7 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: cd mode\n");
isodrv = iso_cd; // use the actual DVD drive for data files
modsrc = 1; // use the DVD drive data for IOP modules
reboot = 1; // Reboot the IOP (load new IOP runtime)
reboot_iop = 1; // Reboot the IOP (load new IOP runtime)
}
// the "cddata" uses the DVD drive for everything but IOP modules.
@ -83,7 +83,7 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: cddata mode\n");
isodrv = iso_cd; // tell IOP to use actual DVD drive for data files
modsrc = 0; // don't use DVD drive for IOP modules
reboot = 0; // no need to reboot the IOP
reboot_iop = 0; // no need to reboot the IOP
}
// the "deviso" mode is one of two modes for testing without the need for DVDs
@ -91,7 +91,7 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: deviso mode\n");
isodrv = deviso; // IOP deviso mode
modsrc = 0; // no IOP module loading (there's no DVD to load from!)
reboot = 0;
reboot_iop = 0;
}
// the "fakeiso" mode is the other of two modes for testing without the need for DVDs
@ -99,7 +99,7 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: fakeiso mode\n");
isodrv = fakeiso; // IOP fakeeiso mode
modsrc = 0; // no IOP module loading (there's no DVD to load from!)
reboot = 0;
reboot_iop = 0;
}
// an added mode to allow booting without a KERNEL.CGO for testing
@ -165,12 +165,12 @@ void InitIOP() {
// before doing anything with the I/O Processor, we need to set up SIF RPC
sceSifInitRpc(0);
if ((isodrv == iso_cd) || modsrc || reboot) {
if ((isodrv == iso_cd) || modsrc || reboot_iop) {
// we will need the DVD drive to bring up the IOP
InitCD();
}
if (!reboot) {
if (!reboot_iop) {
// reboot with development IOP kernel
lg::debug("Rebooting IOP...");
while (!sceSifRebootIop("host0:/usr/local/sce/iop/modules/ioprp221.img")) {

View file

@ -51,7 +51,7 @@ void InitParms(int argc, const char* const* argv) {
DiskBoot = 1;
isodrv = fakeiso;
modsrc = 0;
reboot = 0;
reboot_iop = 0;
DebugSegment = 0;
MasterDebug = 0;
}
@ -66,7 +66,7 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: cd mode\n");
isodrv = iso_cd; // use the actual DVD drive for data files
modsrc = 1; // use the DVD drive data for IOP modules
reboot = 1; // Reboot the IOP (load new IOP runtime)
reboot_iop = 1; // Reboot the IOP (load new IOP runtime)
}
// the "cddata" uses the DVD drive for everything but IOP modules.
@ -74,7 +74,7 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: cddata mode\n");
isodrv = iso_cd; // tell IOP to use actual DVD drive for data files
modsrc = 0; // don't use DVD drive for IOP modules
reboot = 0; // no need to reboot the IOP
reboot_iop = 0; // no need to reboot the IOP
}
if (arg == "-demo") {
@ -99,14 +99,14 @@ void InitParms(int argc, const char* const* argv) {
Msg(6, "dkernel: deviso mode\n");
isodrv = deviso; // IOP deviso mode
modsrc = 2; // now 2 for Jak 2
reboot = 0;
reboot_iop = 0;
}
// the "fakeiso" mode is the other of two modes for testing without the need for DVDs
if (arg == "-fakeiso") {
Msg(6, "dkernel: fakeiso mode\n");
isodrv = fakeiso; // IOP fakeeiso mode
modsrc = 0; // no IOP module loading (there's no DVD to load from!)
reboot = 0;
reboot_iop = 0;
}
// the "boot" mode is used to set GOAL up for running the game in retail mode
@ -185,11 +185,11 @@ void InitIOP() {
sceSifInitRpc(0);
// init cd if we need it
if (((isodrv == iso_cd) || (modsrc == 1)) || (reboot == 1)) {
if (((isodrv == iso_cd) || (modsrc == 1)) || (reboot_iop == 1)) {
InitCD();
}
if (reboot == 0) {
if (reboot_iop == 0) {
// iop with dev kernel
printf("Rebooting IOP...\n");
while (!sceSifRebootIop("host0:/usr/local/sce/iop/modules/ioprp271.img")) {

View file

@ -3,7 +3,8 @@
* Setup and launcher for the runtime.
*/
#ifdef __linux__
#include "common/common_types.h"
#ifdef OS_POSIX
#include <unistd.h>
#include <sys/mman.h>
@ -129,7 +130,12 @@ void ee_runner(SystemThreadInterface& iface) {
if (EE_MEM_LOW_MAP) {
g_ee_main_mem =
(u8*)mmap((void*)0x10000000, EE_MAIN_MEM_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE,
#ifdef __APPLE__
// has no map_populate
MAP_ANONYMOUS | MAP_32BIT | MAP_PRIVATE, 0, 0);
#else
MAP_ANONYMOUS | MAP_32BIT | MAP_PRIVATE | MAP_POPULATE, 0, 0);
#endif
} else {
g_ee_main_mem =
(u8*)mmap((void*)EE_MAIN_MEM_MAP, EE_MAIN_MEM_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE,

View file

@ -1,9 +1,10 @@
#include "SystemThread.h"
#include "common/common_types.h"
#include "common/log/log.h"
#include "common/util/unicode_util.h"
#ifdef __linux
#ifdef OS_POSIX
#include <pthread.h>
#else
// Include order matters...
@ -96,8 +97,10 @@ void* bootstrap_thread_func(void* x) {
SystemThread* thd = (SystemThread*)x;
SystemThreadInterface iface(thd);
#ifdef __linux__
#ifdef __linux
pthread_setname_np(pthread_self(), thd->name.c_str());
#elif __APPLE__
pthread_setname_np(thd->name.c_str());
#else
SetThreadDescription(GetCurrentThread(), (LPCWSTR)utf8_string_to_wide_string(thd->name).c_str());
#endif

View file

@ -1,6 +1,7 @@
#include "collide_pack.h"
#include <functional>
#include <unordered_map>
#include "common/log/log.h"
#include "common/util/Assert.h"

View file

@ -777,6 +777,8 @@ bool Debugger::try_start_watcher() {
stop_watcher();
}
return m_attach_response;
#else
return false;
#endif
}

View file

@ -6,7 +6,8 @@
* The CodeTester can't be used for tests requiring the full GOAL language/linking.
*/
#ifdef __linux__
#include "common/common_types.h"
#ifdef OS_POSIX
#include <sys/mman.h>
#elif _WIN32
#include "third-party/mman/mman.h"

View file

@ -67,7 +67,7 @@ OfflineTestDecompiler setup_decompiler(const OfflineTestWorkGroup& work,
}
if (db_files.size() != object_files.size()) {
lg::error("DB file error: has {} entries, but expected {", db_files.size(),
lg::error("DB file error: has {} entries, but expected {}", db_files.size(),
object_files.size());
for (const auto& coll : work.work_collections) {
for (auto& file : coll.source_files) {

View file

@ -19,7 +19,7 @@ void clear_terminal() {
#elif defined(__LINUX__) || defined(__gnu_linux__) || defined(__linux__)
system("clear");
#elif defined(__APPLE__)
system("clear");
// system("clear");
#endif
}
@ -33,6 +33,7 @@ int main(int argc, char* argv[]) {
int max_files = -1;
std::string single_file = "";
uint32_t num_threads = 1;
std::string project_path;
bool fail_on_cmp = false;
bool pretty_print = false;
@ -54,6 +55,7 @@ int main(int argc, char* argv[]) {
app.add_flag("--fail-on-cmp", fail_on_cmp, "Fail the tests immediately if the comparison fails");
app.add_flag("-p,--pretty-print", pretty_print,
"Use the condensed and progress-indicating printing format");
app.add_option("--proj-path", project_path, "Project path");
app.validate_positionals();
CLI11_PARSE(app, argc, argv);
@ -63,7 +65,11 @@ int main(int argc, char* argv[]) {
}
lg::initialize();
if (!file_util::setup_project_path(std::nullopt)) {
std::optional<fs::path> pp;
if (!project_path.empty()) {
pp = project_path;
}
if (!file_util::setup_project_path(pp)) {
lg::error("Couldn't setup project path, tool is supposed to be ran in the jak-project repo!");
return 1;
}

1942
third-party/xxhash.hpp generated vendored

File diff suppressed because it is too large Load diff