diff --git a/build_tools b/build_tools index c004e383e..7c9845040 160000 --- a/build_tools +++ b/build_tools @@ -1 +1 @@ -Subproject commit c004e383e1621d6bbdbdb9b2cb1d8eb9369aed6e +Subproject commit 7c9845040311ae8a1964f6d4f6a4eef3530bb3d7 diff --git a/docs/building.md b/docs/building.md index 8742377ea..487f5d35d 100644 --- a/docs/building.md +++ b/docs/building.md @@ -28,6 +28,17 @@ the file to run in the 'Command Arguments' field (or use `--flagfile=flags.txt`) To redirect output, use the following command flags: `--flagfile=$(SolutionDir)scratch\flags.txt 2>&1 1>$(SolutionDir)scratch\stdout.txt` +### Linux + +Linux support is extremely experimental and incomplete. + +Only tested with GCC 4.9 on Ubuntu 14. [CodeLite](http://codelite.org) is the +IDE of choice and `xb premake` will spit out files for that. Make also works via +`xb build`. + +Currently building requires that CC == CXX == g++. If you know a way around this +(to force .c files to be built with g++) let me know. + ## Running To make life easier you can use `--flagfile=myflags.txt` to specify all diff --git a/premake5.lua b/premake5.lua index 404f0f494..cf2cd1849 100644 --- a/premake5.lua +++ b/premake5.lua @@ -36,7 +36,7 @@ filter("configurations:Checked") }) flags({"Symbols"}) runtime("Debug") -filter("configurations:Checked", "platforms:Windows") +filter({"configurations:Checked", "platforms:Windows"}) buildoptions({ "/RTCsu", -- Full Run-Time Checks. }) @@ -69,6 +69,7 @@ filter("platforms:Linux") toolset("clang") buildoptions({ "-std=c++14", + "-mlzcnt", -- Assume lzcnt supported. }) filter("platforms:Windows") @@ -151,7 +152,6 @@ solution("xenia") include("src/xenia/app") include("src/xenia/apu") include("src/xenia/apu/nop") - include("src/xenia/apu/xaudio2") include("src/xenia/base") include("src/xenia/cpu") include("src/xenia/cpu/backend/x64") @@ -161,13 +161,17 @@ solution("xenia") include("src/xenia/gpu/gl4") include("src/xenia/hid") include("src/xenia/hid/nop") - include("src/xenia/hid/winkey") - include("src/xenia/hid/xinput") include("src/xenia/kernel") include("src/xenia/ui") include("src/xenia/ui/gl") include("src/xenia/vfs") + if os.is("windows") then + include("src/xenia/apu/xaudio2") + include("src/xenia/hid/winkey") + include("src/xenia/hid/xinput") + end + include("third_party/capstone.lua") include("third_party/elemental-forms") include("third_party/glew.lua") diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua index 464b414b4..1de6feb17 100644 --- a/src/xenia/app/premake5.lua +++ b/src/xenia/app/premake5.lua @@ -12,7 +12,6 @@ project("xenia-app") "gflags", "xenia-apu", "xenia-apu-nop", - "xenia-apu-xaudio2", "xenia-base", "xenia-core", "xenia-cpu", @@ -21,8 +20,6 @@ project("xenia-app") "xenia-gpu", "xenia-gpu-gl4", "xenia-hid-nop", - "xenia-hid-winkey", - "xenia-hid-xinput", "xenia-kernel", "xenia-ui", "xenia-ui-gl", @@ -49,6 +46,12 @@ project("xenia-app") project_root.."/third_party/elemental-forms", }) + filter("platforms:Windows") + links({ + "xenia-apu-xaudio2", + "xenia-hid-winkey", + "xenia-hid-xinput", + }) filter("configurations:Checked") local libav_root = "../third_party/libav-xma-bin/lib/Debug" linkoptions({ diff --git a/src/xenia/base/atomic.h b/src/xenia/base/atomic.h index 2601532d6..8cbd1b789 100644 --- a/src/xenia/base/atomic.h +++ b/src/xenia/base/atomic.h @@ -102,17 +102,17 @@ inline int32_t atomic_dec(volatile int32_t* value) { } inline int32_t atomic_exchange(int32_t new_value, volatile int32_t* value) { - return __sync_val_compare_and_swap(*value, value, new_value); + return __sync_val_compare_and_swap(value, *value, new_value); } inline int64_t atomic_exchange(int64_t new_value, volatile int64_t* value) { - return __sync_val_compare_and_swap(*value, value, new_value); + return __sync_val_compare_and_swap(value, *value, new_value); } inline int32_t atomic_exchange_add(int32_t amount, volatile int32_t* value) { - return __sync_fetch_and_add(amount, value); + return __sync_fetch_and_add(value, amount); } inline int64_t atomic_exchange_add(int64_t amount, volatile int64_t* value) { - return __sync_fetch_and_add(amount, value); + return __sync_fetch_and_add(value, amount); } inline bool atomic_cas(int32_t old_value, int32_t new_value, diff --git a/src/xenia/base/logging.h b/src/xenia/base/logging.h index 150655760..42613a499 100644 --- a/src/xenia/base/logging.h +++ b/src/xenia/base/logging.h @@ -31,15 +31,7 @@ namespace xe { do { \ } while (false) -#if XE_COMPILER_GNUC -#define XE_LOG_LINE_ATTRIBUTE __attribute__((format(printf, 5, 6))) -#else -#define XE_LOG_LINE_ATTRIBUTE -#endif // XE_COMPILER_GNUC -void log_line(const char level_char, const char* fmt, - ...) XE_LOG_LINE_ATTRIBUTE; -#undef XE_LOG_LINE_ATTRIBUTE - +void log_line(const char level_char, const char* fmt, ...); void handle_fatal(const char* fmt, ...); #if XE_OPTION_ENABLE_LOGGING diff --git a/src/xenia/base/mapped_memory_posix.cc b/src/xenia/base/mapped_memory_posix.cc index 40ee08eab..07c80f4d6 100644 --- a/src/xenia/base/mapped_memory_posix.cc +++ b/src/xenia/base/mapped_memory_posix.cc @@ -39,11 +39,11 @@ std::unique_ptr MappedMemory::Open(const std::wstring& path, const char* mode_str; int prot; switch (mode) { - case Mode::READ: + case Mode::kRead: mode_str = "rb"; prot = PROT_READ; break; - case Mode::READ_WRITE: + case Mode::kReadWrite: mode_str = "r+b"; prot = PROT_READ | PROT_WRITE; break; diff --git a/src/xenia/base/string.cc b/src/xenia/base/string.cc index 2590b19ac..2dcc93d49 100644 --- a/src/xenia/base/string.cc +++ b/src/xenia/base/string.cc @@ -9,20 +9,34 @@ #include "xenia/base/string.h" +// TODO(benvanik): when GCC finally gets codecvt, use that. +#if XE_PLATFORM_LINUX +#define NO_CODECVT 1 +#else #include +#endif // XE_PLATFORM_LINUX + #include #include namespace xe { std::string to_string(const std::wstring& source) { - static std::wstring_convert> converter; +#if NO_CODECVT + return std::string(source.begin(), source.end()); +#else + static std::wstring_convert > converter; return converter.to_bytes(source); +#endif // XE_PLATFORM_LINUX } std::wstring to_wstring(const std::string& source) { - static std::wstring_convert> converter; +#if NO_CODECVT + return std::wstring(source.begin(), source.end()); +#else + static std::wstring_convert > converter; return converter.from_bytes(source); +#endif // XE_PLATFORM_LINUX } std::string::size_type find_first_of_case(const std::string& target, diff --git a/src/xenia/base/threading_linux.cc b/src/xenia/base/threading_linux.cc new file mode 100644 index 000000000..6f4a97584 --- /dev/null +++ b/src/xenia/base/threading_linux.cc @@ -0,0 +1,21 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2015 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/base/threading.h" + +#include +#include + +namespace xe { +namespace threading { + +void MaybeYield() { pthread_yield(); } + +} // namespace threading +} // namespace xe diff --git a/src/xenia/base/threading_posix.cc b/src/xenia/base/threading_posix.cc index 21cb3f252..4b60baaf7 100644 --- a/src/xenia/base/threading_posix.cc +++ b/src/xenia/base/threading_posix.cc @@ -30,8 +30,6 @@ void set_name(std::thread::native_handle_type handle, const std::string& name) { pthread_setname_np(pthread_self(), name.c_str()); } -void MaybeYield() { pthread_yield_np(); } - void Sleep(std::chrono::microseconds duration) { timespec rqtp = {duration.count() / 1000000, duration.count() % 1000}; nanosleep(&rqtp, nullptr); diff --git a/src/xenia/cpu/backend/x64/x64_assembler.cc b/src/xenia/cpu/backend/x64/x64_assembler.cc index 51e14dd9e..ab6d121e3 100644 --- a/src/xenia/cpu/backend/x64/x64_assembler.cc +++ b/src/xenia/cpu/backend/x64/x64_assembler.cc @@ -9,6 +9,8 @@ #include "xenia/cpu/backend/x64/x64_assembler.h" +#include + #include "third_party/capstone/include/capstone.h" #include "third_party/capstone/include/x86.h" #include "xenia/base/reset_scope.h" diff --git a/src/xenia/cpu/backend/x64/x64_backend.cc b/src/xenia/cpu/backend/x64/x64_backend.cc index 7e20233e3..21e992ba1 100644 --- a/src/xenia/cpu/backend/x64/x64_backend.cc +++ b/src/xenia/cpu/backend/x64/x64_backend.cc @@ -61,10 +61,10 @@ bool X64Backend::Initialize() { machine_info_.supports_extended_load_store = false; } - machine_info_.register_sets[0] = { + machine_info_.register_sets[0] = (MachineInfo::RegisterSet){ 0, "gpr", MachineInfo::RegisterSet::INT_TYPES, X64Emitter::GPR_COUNT, }; - machine_info_.register_sets[1] = { + machine_info_.register_sets[1] = (MachineInfo::RegisterSet){ 1, "xmm", MachineInfo::RegisterSet::FLOAT_TYPES | MachineInfo::RegisterSet::VEC_TYPES, X64Emitter::XMM_COUNT, diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index c3a492e36..bf04b47dd 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -2019,7 +2019,7 @@ struct LOAD_MMIO_I32 auto read_address = uint32_t(i.src2.value); e.mov(e.r8, uint64_t(mmio_range->callback_context)); e.mov(e.r9d, read_address); - e.CallNativeSafe(mmio_range->read); + e.CallNativeSafe(reinterpret_cast(mmio_range->read)); e.bswap(e.eax); e.mov(i.dest, e.eax); if (IsTracingData()) { @@ -2050,7 +2050,7 @@ struct STORE_MMIO_I32 e.mov(e.r10d, i.src3); e.bswap(e.r10d); } - e.CallNativeSafe(mmio_range->write); + e.CallNativeSafe(reinterpret_cast(mmio_range->write)); if (IsTracingData()) { if (i.src3.is_constant) { e.mov(e.r8d, i.src3.constant()); @@ -6461,7 +6461,7 @@ struct PACK : Sequence> { e.vpshufb(i.dest, i.dest, e.GetXmmConstPtr(XMMPackFLOAT16_2)); } else { e.lea(e.r8, e.StashXmm(0, i.src1)); - e.CallNativeSafe(EmulateFLOAT16_2); + e.CallNativeSafe(reinterpret_cast(EmulateFLOAT16_2)); e.vmovaps(i.dest, e.xmm0); } } @@ -6488,7 +6488,7 @@ struct PACK : Sequence> { e.vpshufb(i.dest, i.dest, e.GetXmmConstPtr(XMMPackFLOAT16_4)); } else { e.lea(e.r8, e.StashXmm(0, i.src1)); - e.CallNativeSafe(EmulateFLOAT16_4); + e.CallNativeSafe(reinterpret_cast(EmulateFLOAT16_4)); e.vmovaps(i.dest, e.xmm0); } } @@ -6787,7 +6787,7 @@ struct UNPACK : Sequence> { e.vpor(i.dest, e.GetXmmConstPtr(XMM0001)); } else { e.lea(e.r8, e.StashXmm(0, i.src1)); - e.CallNativeSafe(EmulateFLOAT16_2); + e.CallNativeSafe(reinterpret_cast(EmulateFLOAT16_2)); e.vmovaps(i.dest, e.xmm0); } } @@ -6821,7 +6821,7 @@ struct UNPACK : Sequence> { e.vcvtph2ps(i.dest, i.dest); } else { e.lea(e.r8, e.StashXmm(0, i.src1)); - e.CallNativeSafe(EmulateFLOAT16_4); + e.CallNativeSafe(reinterpret_cast(EmulateFLOAT16_4)); e.vmovaps(i.dest, e.xmm0); } } diff --git a/src/xenia/cpu/backend/x64/x64_tracers.cc b/src/xenia/cpu/backend/x64/x64_tracers.cc index 916372376..67cb1490e 100644 --- a/src/xenia/cpu/backend/x64/x64_tracers.cc +++ b/src/xenia/cpu/backend/x64/x64_tracers.cc @@ -9,6 +9,8 @@ #include "xenia/cpu/backend/x64/x64_tracers.h" +#include + #include "xenia/base/vec128.h" #include "xenia/cpu/backend/x64/x64_emitter.h" #include "xenia/cpu/processor.h" @@ -61,35 +63,36 @@ void TraceString(void* raw_context, const char* str) { void TraceContextLoadI8(void* raw_context, uint64_t offset, uint8_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%d (%X) = ctx i8 +%llu\n", (int8_t)value, value, offset); + DPRINT("%d (%X) = ctx i8 +%" PRIu64 "\n", (int8_t)value, value, offset); } void TraceContextLoadI16(void* raw_context, uint64_t offset, uint16_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%d (%X) = ctx i16 +%llu\n", (int16_t)value, value, offset); + DPRINT("%d (%X) = ctx i16 +%" PRIu64 "\n", (int16_t)value, value, offset); } void TraceContextLoadI32(void* raw_context, uint64_t offset, uint32_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%d (%X) = ctx i32 +%llu\n", (int32_t)value, value, offset); + DPRINT("%d (%X) = ctx i32 +%" PRIu64 "\n", (int32_t)value, value, offset); } void TraceContextLoadI64(void* raw_context, uint64_t offset, uint64_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%lld (%llX) = ctx i64 +%llu\n", (int64_t)value, value, offset); + DPRINT("%" PRId64 " (%" PRIX64 ") = ctx i64 +%" PRIu64 "\n", (int64_t)value, + value, offset); } void TraceContextLoadF32(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%e (%X) = ctx f32 +%llu\n", xe::m128_f32<0>(value), + DPRINT("%e (%X) = ctx f32 +%" PRIu64 "\n", xe::m128_f32<0>(value), xe::m128_i32<0>(value), offset); } void TraceContextLoadF64(void* raw_context, uint64_t offset, const double* value) { auto thread_state = *reinterpret_cast(raw_context); auto v = _mm_loadu_pd(value); - DPRINT("%le (%llX) = ctx f64 +%llu\n", xe::m128_f64<0>(v), xe::m128_i64<0>(v), - offset); + DPRINT("%le (%" PRIX64 ") = ctx f64 +%" PRIu64 "\n", xe::m128_f64<0>(v), + xe::m128_i64<0>(v), offset); } void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%llu\n", + DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%" PRIu64 "\n", xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value), xe::m128_i32<2>(value), xe::m128_i32<3>(value), offset); @@ -97,38 +100,40 @@ void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) { void TraceContextStoreI8(void* raw_context, uint64_t offset, uint8_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("ctx i8 +%llu = %d (%X)\n", offset, (int8_t)value, value); + DPRINT("ctx i8 +%" PRIu64 " = %d (%X)\n", offset, (int8_t)value, value); } void TraceContextStoreI16(void* raw_context, uint64_t offset, uint16_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("ctx i16 +%llu = %d (%X)\n", offset, (int16_t)value, value); + DPRINT("ctx i16 +%" PRIu64 " = %d (%X)\n", offset, (int16_t)value, value); } void TraceContextStoreI32(void* raw_context, uint64_t offset, uint32_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("ctx i32 +%llu = %d (%X)\n", offset, (int32_t)value, value); + DPRINT("ctx i32 +%" PRIu64 " = %d (%X)\n", offset, (int32_t)value, value); } void TraceContextStoreI64(void* raw_context, uint64_t offset, uint64_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("ctx i64 +%llu = %lld (%llX)\n", offset, (int64_t)value, value); + DPRINT("ctx i64 +%" PRIu64 " = %" PRId64 " (%" PRIX64 ")\n", offset, + (int64_t)value, value); } void TraceContextStoreF32(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("ctx f32 +%llu = %e (%X)\n", offset, xe::m128_f32<0>(value), + DPRINT("ctx f32 +%" PRIu64 " = %e (%X)\n", offset, xe::m128_f32<0>(value), xe::m128_i32<0>(value)); } void TraceContextStoreF64(void* raw_context, uint64_t offset, const double* value) { auto thread_state = *reinterpret_cast(raw_context); auto v = _mm_loadu_pd(value); - DPRINT("ctx f64 +%llu = %le (%llX)\n", offset, xe::m128_f64<0>(v), - xe::m128_i64<0>(v)); + DPRINT("ctx f64 +%" PRIu64 " = %le (%" PRIX64 ")\n", offset, + xe::m128_f64<0>(v), xe::m128_i64<0>(v)); } void TraceContextStoreV128(void* raw_context, uint64_t offset, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("ctx v128 +%llu = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n", offset, - xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value), - xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value), - xe::m128_i32<2>(value), xe::m128_i32<3>(value)); + DPRINT("ctx v128 +%" PRIu64 " = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n", + offset, xe::m128_f32<0>(value), xe::m128_f32<1>(value), + xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value), + xe::m128_i32<1>(value), xe::m128_i32<2>(value), + xe::m128_i32<3>(value)); } void TraceMemoryLoadI8(void* raw_context, uint32_t address, uint8_t value) { @@ -145,7 +150,8 @@ void TraceMemoryLoadI32(void* raw_context, uint32_t address, uint32_t value) { } void TraceMemoryLoadI64(void* raw_context, uint32_t address, uint64_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%lld (%llX) = load.i64 %.8X\n", (int64_t)value, value, address); + DPRINT("%" PRId64 " (%" PRIX64 ") = load.i64 %.8X\n", (int64_t)value, value, + address); } void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); @@ -154,7 +160,7 @@ void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) { } void TraceMemoryLoadF64(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("%le (%llX) = load.f64 %.8X\n", xe::m128_f64<0>(value), + DPRINT("%le (%" PRIX64 ") = load.f64 %.8X\n", xe::m128_f64<0>(value), xe::m128_i64<0>(value), address); } void TraceMemoryLoadV128(void* raw_context, uint32_t address, __m128 value) { @@ -179,7 +185,8 @@ void TraceMemoryStoreI32(void* raw_context, uint32_t address, uint32_t value) { } void TraceMemoryStoreI64(void* raw_context, uint32_t address, uint64_t value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("store.i64 %.8X = %lld (%llX)\n", address, (int64_t)value, value); + DPRINT("store.i64 %.8X = %" PRId64 " (%" PRIX64 ")\n", address, + (int64_t)value, value); } void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); @@ -188,8 +195,8 @@ void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) { } void TraceMemoryStoreF64(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); - DPRINT("store.f64 %.8X = %le (%llX)\n", address, xe::m128_f64<0>(value), - xe::m128_i64<0>(value)); + DPRINT("store.f64 %.8X = %le (%" PRIX64 ")\n", address, + xe::m128_f64<0>(value), xe::m128_i64<0>(value)); } void TraceMemoryStoreV128(void* raw_context, uint32_t address, __m128 value) { auto thread_state = *reinterpret_cast(raw_context); diff --git a/src/xenia/cpu/elf_module.cc b/src/xenia/cpu/elf_module.cc index 7de8fa281..314b15d45 100644 --- a/src/xenia/cpu/elf_module.cc +++ b/src/xenia/cpu/elf_module.cc @@ -79,7 +79,7 @@ bool ElfModule::Load(const std::string& name, const std::string& path, XELOGE( "ELF: Could not load ELF because target machine is not PPC! (target: " "%d)", - hdr->e_machine); + uint32_t(hdr->e_machine)); return false; } @@ -108,8 +108,8 @@ bool ElfModule::Load(const std::string& name, const std::string& path, // Allocate and copy into memory. // Base address @ 0x80000000 uint32_t virtual_addr = phdr[i].p_vaddr < 0x80000000 - ? phdr[i].p_vaddr + 0x80000000 - : phdr[i].p_vaddr; + ? uint32_t(phdr[i].p_vaddr) + 0x80000000 + : uint32_t(phdr[i].p_vaddr); if (!memory() ->LookupHeap(virtual_addr) ->AllocFixed( diff --git a/src/xenia/cpu/frontend/ppc_context.cc b/src/xenia/cpu/frontend/ppc_context.cc index 473ae589b..c5912d141 100644 --- a/src/xenia/cpu/frontend/ppc_context.cc +++ b/src/xenia/cpu/frontend/ppc_context.cc @@ -9,6 +9,7 @@ #include "xenia/cpu/frontend/ppc_context.h" +#include #include namespace xe { @@ -64,7 +65,7 @@ bool PPCContext::CompareRegWithString(const char* name, const char* value, if (sscanf(name, "r%d", &n) == 1) { uint64_t expected = ParseInt64(value); if (this->r[n] != expected) { - snprintf(out_value, out_value_size, "%016llX", this->r[n]); + snprintf(out_value, out_value_size, "%016" PRIX64, this->r[n]); return false; } return true; diff --git a/src/xenia/cpu/frontend/ppc_instr.cc b/src/xenia/cpu/frontend/ppc_instr.cc index 7681e48f6..5eb6b40c7 100644 --- a/src/xenia/cpu/frontend/ppc_instr.cc +++ b/src/xenia/cpu/frontend/ppc_instr.cc @@ -9,6 +9,7 @@ #include "xenia/cpu/frontend/ppc_instr.h" +#include #include #include @@ -98,9 +99,9 @@ void InstrOperand::Dump(std::string& out_str) { break; case 8: if (imm.is_signed) { - snprintf(buffer, max_count, "%lld", (int64_t)imm.value); + snprintf(buffer, max_count, "%" PRId64, (int64_t)imm.value); } else { - snprintf(buffer, max_count, "0x%.16llX", imm.value); + snprintf(buffer, max_count, "0x%.16" PRIX64, imm.value); } break; } diff --git a/src/xenia/cpu/hir/hir_builder.cc b/src/xenia/cpu/hir/hir_builder.cc index 6b409c8ff..9a27c3aaf 100644 --- a/src/xenia/cpu/hir/hir_builder.cc +++ b/src/xenia/cpu/hir/hir_builder.cc @@ -9,6 +9,7 @@ #include "xenia/cpu/hir/hir_builder.h" +#include #include #include @@ -118,7 +119,7 @@ void HIRBuilder::DumpValue(StringBuffer* str, Value* value) { str->AppendFormat("%X", value->constant.i32); break; case INT64_TYPE: - str->AppendFormat("%llX", value->constant.i64); + str->AppendFormat("%" PRIX64, value->constant.i64); break; case FLOAT32_TYPE: str->AppendFormat("%F", value->constant.f32); diff --git a/src/xenia/cpu/hir/value.cc b/src/xenia/cpu/hir/value.cc index 75ac758ca..ea395e0ec 100644 --- a/src/xenia/cpu/hir/value.cc +++ b/src/xenia/cpu/hir/value.cc @@ -322,11 +322,23 @@ void Value::MulHi(Value* other, bool is_unsigned) { } break; case INT64_TYPE: +#if XE_COMPILER_MSVC if (is_unsigned) { constant.i64 = __umulh(constant.i64, other->constant.i64); } else { constant.i64 = __mulh(constant.i64, other->constant.i64); } +#else + if (is_unsigned) { + constant.i64 = static_cast( + static_cast(constant.i64) * + static_cast(other->constant.i64)); + } else { + constant.i64 = + static_cast(static_cast<__int128>(constant.i64) * + static_cast<__int128>(other->constant.i64)); + } +#endif // XE_COMPILER_MSVC break; default: assert_unhandled_case(type); @@ -440,7 +452,7 @@ void Value::Abs() { break; case VEC128_TYPE: for (int i = 0; i < 4; ++i) { - constant.v128.f32[i] = std::fabsf(constant.v128.f32[i]); + constant.v128.f32[i] = std::abs(constant.v128.f32[i]); } break; default: @@ -452,7 +464,7 @@ void Value::Abs() { void Value::Sqrt() { switch (type) { case FLOAT32_TYPE: - constant.f32 = 1.0f / std::sqrtf(constant.f32); + constant.f32 = 1.0f / std::sqrt(constant.f32); break; case FLOAT64_TYPE: constant.f64 = 1.0 / std::sqrt(constant.f64); diff --git a/src/xenia/cpu/thread_state.cc b/src/xenia/cpu/thread_state.cc index 3465149ff..92260de07 100644 --- a/src/xenia/cpu/thread_state.cc +++ b/src/xenia/cpu/thread_state.cc @@ -9,6 +9,7 @@ #include "xenia/cpu/thread_state.h" +#include #include #include "xenia/base/assert.h" @@ -85,7 +86,7 @@ ThreadState::ThreadState(Processor* processor, uint32_t thread_id, // Allocate with 64b alignment. context_ = - reinterpret_cast(_aligned_malloc(sizeof(PPCContext), 64)); + reinterpret_cast(aligned_alloc(64, sizeof(PPCContext))); assert_true(((uint64_t)context_ & 0x3F) == 0); std::memset(context_, 0, sizeof(PPCContext)); @@ -110,7 +111,7 @@ ThreadState::~ThreadState() { thread_state_ = nullptr; } - _aligned_free(context_); + free(context_); if (stack_allocated_) { memory()->LookupHeap(stack_address_)->Decommit(stack_address_, stack_size_); } diff --git a/src/xenia/gpu/register_file.h b/src/xenia/gpu/register_file.h index f6d28d13f..524cea772 100644 --- a/src/xenia/gpu/register_file.h +++ b/src/xenia/gpu/register_file.h @@ -11,6 +11,7 @@ #define XENIA_GPU_REGISTER_FILE_H_ #include +#include namespace xe { namespace gpu { diff --git a/src/xenia/gpu/sampler_info.cc b/src/xenia/gpu/sampler_info.cc index 6bef01ae0..16b790d50 100644 --- a/src/xenia/gpu/sampler_info.cc +++ b/src/xenia/gpu/sampler_info.cc @@ -9,6 +9,7 @@ #include "xenia/gpu/sampler_info.h" +#include #include #include "third_party/xxhash/xxhash.h" diff --git a/src/xenia/gpu/texture_info.cc b/src/xenia/gpu/texture_info.cc index f5d427a98..2a1fa40f3 100644 --- a/src/xenia/gpu/texture_info.cc +++ b/src/xenia/gpu/texture_info.cc @@ -187,8 +187,8 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) { format_info->block_height; // Tiles are 32x32 blocks. All textures must be multiples of tile dimensions. - uint32_t tile_width = uint32_t(std::ceilf(block_width / 32.0f)); - uint32_t tile_height = uint32_t(std::ceilf(block_height / 32.0f)); + uint32_t tile_width = uint32_t(std::ceil(block_width / 32.0f)); + uint32_t tile_height = uint32_t(std::ceil(block_height / 32.0f)); size_2d.block_width = tile_width * 32; size_2d.block_height = tile_height * 32; @@ -229,8 +229,8 @@ void TextureInfo::CalculateTextureSizesCube( format_info->block_height; // Tiles are 32x32 blocks. All textures must be multiples of tile dimensions. - uint32_t tile_width = uint32_t(std::ceilf(block_width / 32.0f)); - uint32_t tile_height = uint32_t(std::ceilf(block_height / 32.0f)); + uint32_t tile_width = uint32_t(std::ceil(block_width / 32.0f)); + uint32_t tile_height = uint32_t(std::ceil(block_height / 32.0f)); size_cube.block_width = tile_width * 32; size_cube.block_height = tile_height * 32; diff --git a/src/xenia/gpu/texture_info.h b/src/xenia/gpu/texture_info.h index 3dc5467bf..d417e026a 100644 --- a/src/xenia/gpu/texture_info.h +++ b/src/xenia/gpu/texture_info.h @@ -10,6 +10,7 @@ #ifndef XENIA_GPU_TEXTURE_INFO_H_ #define XENIA_GPU_TEXTURE_INFO_H_ +#include #include #include "xenia/base/assert.h" diff --git a/src/xenia/kernel/objects/xmodule.h b/src/xenia/kernel/objects/xmodule.h index 029e0faec..55d6e676f 100644 --- a/src/xenia/kernel/objects/xmodule.h +++ b/src/xenia/kernel/objects/xmodule.h @@ -44,15 +44,9 @@ struct X_LDR_DATA_TABLE_ENTRY { xe::be time_date_stamp; // 0x50 xe::be loaded_imports; // 0x54 xe::be xex_header_base; // 0x58 - - union { - X_ANSI_STRING load_file_name; // 0x5C - - struct { - xe::be closure_root; // 0x5C - xe::be traversal_parent; // 0x60 - }; - }; + // X_ANSI_STRING load_file_name; // 0x5C + xe::be closure_root; // 0x5C + xe::be traversal_parent; // 0x60 }; class XModule : public XObject { diff --git a/src/xenia/kernel/objects/xthread.h b/src/xenia/kernel/objects/xthread.h index d9ae6d56b..290a503b1 100644 --- a/src/xenia/kernel/objects/xthread.h +++ b/src/xenia/kernel/objects/xthread.h @@ -189,7 +189,7 @@ class XThread : public XObject { int32_t priority_ = 0; uint32_t affinity_ = 0; - std::atomic irql_ = 0; + std::atomic irql_ = {0}; xe::mutex apc_lock_; NativeList* apc_list_ = nullptr; }; diff --git a/src/xenia/kernel/util/xex2_info.h b/src/xenia/kernel/util/xex2_info.h index b56b669c2..d05f964ee 100644 --- a/src/xenia/kernel/util/xex2_info.h +++ b/src/xenia/kernel/util/xex2_info.h @@ -405,7 +405,7 @@ struct xe_xex2_loader_info_t { xe_xex2_media_flags media_flags; }; -enum xe_xex2_section_type : uint32_t { +enum xe_xex2_section_type { XEX_SECTION_CODE = 1, XEX_SECTION_DATA = 2, XEX_SECTION_READONLY_DATA = 3, diff --git a/src/xenia/kernel/xobject.h b/src/xenia/kernel/xobject.h index 8ecec925e..cfde59b8f 100644 --- a/src/xenia/kernel/xobject.h +++ b/src/xenia/kernel/xobject.h @@ -12,6 +12,7 @@ #include #include +#include #include #include "xenia/base/threading.h" @@ -162,10 +163,7 @@ class XObject { int32_t as_type = -1); template static object_ref GetNativeObject(KernelState* kernel_state, - void* native_ptr, int32_t as_type = -1) { - return object_ref(reinterpret_cast( - GetNativeObject(kernel_state, native_ptr, as_type).release())); - } + void* native_ptr, int32_t as_type = -1); virtual xe::threading::WaitHandle* GetWaitHandle() { return nullptr; } @@ -208,9 +206,9 @@ template class object_ref { public: object_ref() noexcept : value_(nullptr) {} - object_ref(nullptr_t) noexcept // NOLINT(runtime/explicit) + object_ref(std::nullptr_t) noexcept // NOLINT(runtime/explicit) : value_(nullptr) {} - object_ref& operator=(nullptr_t) noexcept { + object_ref& operator=(std::nullptr_t) noexcept { reset(); return (*this); } @@ -250,9 +248,7 @@ class object_ref { return (*this); } - void swap(object_ref& right) noexcept { - std::_Swap_adl(value_, right.value_); - } + void swap(object_ref& right) noexcept { std::swap(value_, right.value_); } ~object_ref() noexcept { if (value_) { @@ -298,22 +294,22 @@ class object_ref { }; template -bool operator==(const object_ref<_Ty>& _Left, nullptr_t) noexcept { +bool operator==(const object_ref<_Ty>& _Left, std::nullptr_t) noexcept { return (_Left.get() == reinterpret_cast<_Ty*>(0)); } template -bool operator==(nullptr_t, const object_ref<_Ty>& _Right) noexcept { +bool operator==(std::nullptr_t, const object_ref<_Ty>& _Right) noexcept { return (reinterpret_cast<_Ty*>(0) == _Right.get()); } template -bool operator!=(const object_ref<_Ty>& _Left, nullptr_t _Right) noexcept { +bool operator!=(const object_ref<_Ty>& _Left, std::nullptr_t _Right) noexcept { return (!(_Left == _Right)); } template -bool operator!=(nullptr_t _Left, const object_ref<_Ty>& _Right) noexcept { +bool operator!=(std::nullptr_t _Left, const object_ref<_Ty>& _Right) noexcept { return (!(_Left == _Right)); } @@ -323,6 +319,13 @@ object_ref retain_object(T* ptr) { return object_ref(ptr); } +template +object_ref XObject::GetNativeObject(KernelState* kernel_state, + void* native_ptr, int32_t as_type) { + return object_ref(reinterpret_cast( + GetNativeObject(kernel_state, native_ptr, as_type).release())); +} + } // namespace kernel } // namespace xe diff --git a/src/xenia/profiling.cc b/src/xenia/profiling.cc index 9e2bd26d0..b0c99ddd4 100644 --- a/src/xenia/profiling.cc +++ b/src/xenia/profiling.cc @@ -24,16 +24,16 @@ #define MICROPROFILE_USE_THREAD_NAME_CALLBACK 1 #define MICROPROFILE_WEBSERVER_MAXFRAMES 3 #define MICROPROFILE_PRINTF XELOGI -#define MICROPROFILE_WEBSERVER 1 +#define MICROPROFILE_WEBSERVER 0 #define MICROPROFILE_DEBUG 0 -#if MICROPROFILE_WEBSERVER -#include // NOLINT(build/include_order) -#endif // MICROPROFILE_WEBSERVER #include "third_party/microprofile/microprofile.h" -#include "third_party/microprofile/microprofileui.h" #include "xenia/profiling.h" +#if XE_OPTION_PROFILING +#include "third_party/microprofile/microprofileui.h" +#endif // XE_OPTION_PROFILING + DEFINE_bool(show_profiler, false, "Show profiling UI by default."); namespace xe { diff --git a/src/xenia/profiling.h b/src/xenia/profiling.h index 6d8da30f3..a655af154 100644 --- a/src/xenia/profiling.h +++ b/src/xenia/profiling.h @@ -14,9 +14,11 @@ #include "xenia/base/string.h" -#define XE_OPTION_PROFILING 1 #if XE_PLATFORM_WIN32 +#define XE_OPTION_PROFILING 1 #define XE_OPTION_PROFILING_UI 1 +#else +#define XE_OPTION_PROFILING 0 #endif // XE_PLATFORM_WIN32 #if XE_OPTION_PROFILING @@ -115,8 +117,10 @@ namespace xe { do { \ } while (false) +#ifndef MICROPROFILE_TEXT_WIDTH #define MICROPROFILE_TEXT_WIDTH 1 #define MICROPROFILE_TEXT_HEIGHT 1 +#endif // !MICROPROFILE_TEXT_WIDTH #endif // XE_OPTION_PROFILING diff --git a/src/xenia/ui/gl/gl4_elemental_renderer.cc b/src/xenia/ui/gl/gl4_elemental_renderer.cc index 0baddc98a..d42f09df1 100644 --- a/src/xenia/ui/gl/gl4_elemental_renderer.cc +++ b/src/xenia/ui/gl/gl4_elemental_renderer.cc @@ -9,6 +9,7 @@ #include "xenia/ui/gl/gl4_elemental_renderer.h" +#include #include #include diff --git a/src/xenia/ui/gl/gl_profiler_display.cc b/src/xenia/ui/gl/gl_profiler_display.cc index 0912a4aad..870172300 100644 --- a/src/xenia/ui/gl/gl_profiler_display.cc +++ b/src/xenia/ui/gl/gl_profiler_display.cc @@ -12,6 +12,7 @@ #include #include +#include "third_party/microprofile/microprofile.h" #include "third_party/microprofile/microprofileui.h" #include "xenia/base/assert.h" diff --git a/src/xenia/vfs/devices/stfs_container_device.cc b/src/xenia/vfs/devices/stfs_container_device.cc index 6242264e0..c0cf1943c 100644 --- a/src/xenia/vfs/devices/stfs_container_device.cc +++ b/src/xenia/vfs/devices/stfs_container_device.cc @@ -198,7 +198,8 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries( size_t remaining_size = file_size; uint32_t info = 0x80; while (remaining_size && block_index && info >= 0x80) { - size_t block_size = std::min(0x1000ull, remaining_size); + size_t block_size = + std::min(static_cast(0x1000), remaining_size); size_t offset = BlockToOffset(ComputeBlockNumber(block_index)); entry->block_list_.push_back({offset, block_size}); remaining_size -= block_size; diff --git a/third_party/GL/glew.c b/third_party/GL/glew.c index d1415dfd1..e0ba9c12c 100644 --- a/third_party/GL/glew.c +++ b/third_party/GL/glew.c @@ -10116,7 +10116,8 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) } /* query opengl extensions string */ - extStart = glewExperimental ? "" : glGetString(GL_EXTENSIONS); + extStart = glewExperimental ? (const GLubyte*)"" + : (const GLubyte*)glGetString(GL_EXTENSIONS); if (extStart == 0) extStart = (const GLubyte*)""; extEnd = extStart + _glewStrLen(extStart); diff --git a/third_party/capstone.lua b/third_party/capstone.lua index f18d2fba9..c8378e3a5 100644 --- a/third_party/capstone.lua +++ b/third_party/capstone.lua @@ -41,3 +41,12 @@ project("capstone") "capstone/arch/X86/*.inc", }) force_compile_as_cc({"capstone/**.c"}) + + filter("platforms:Linux") + -- Capstone code is... not fantastic. + buildoptions({ + "-Wno-error=write-strings", + "-Wno-write-string", + "-Wno-deprecated", + "-w", + }) diff --git a/third_party/elemental-forms b/third_party/elemental-forms index 4fdbd5fe7..0b0d51fa4 160000 --- a/third_party/elemental-forms +++ b/third_party/elemental-forms @@ -1 +1 @@ -Subproject commit 4fdbd5fe789da92fd5e23240c63ed5aa2cba5ed2 +Subproject commit 0b0d51fa4afcf00f67770cf52fc4db7abb6a8cbb diff --git a/xenia-build b/xenia-build index c28e5088f..b6bb48451 100755 --- a/xenia-build +++ b/xenia-build @@ -476,11 +476,15 @@ class BaseBuildCommand(Command): self.parser.add_argument( '--force', action='store_true', help='Forces a full rebuild.') + self.parser.add_argument( + '--no-premake', action='store_true', + help='Skips running premake before building.') def execute(self, args, pass_args, cwd): - print('- running premake...') - run_platform_premake() - print('') + if not args['no_premake']: + print('- running premake...') + run_platform_premake() + print('') print('- building (%s):%s...' % ( 'all' if not len(args['target']) else ' '.join(args['target']), @@ -500,7 +504,7 @@ class BaseBuildCommand(Command): else: # TODO(benvanik): allow gcc? os.environ['CXX'] = 'clang++-3.8' - os.environ['CC'] = 'clang-3.8' + os.environ['CC'] = 'clang++-3.8' result = shell_call([ 'make', '-Cbuild/',