mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Make compile with msvc, clang and gcc on Windows
This commit is contained in:
parent
ed75bab7b2
commit
0c94606fcf
60 changed files with 519 additions and 4584 deletions
|
|
@ -725,7 +725,7 @@ namespace CRCPP
|
|||
{
|
||||
while (size--)
|
||||
{
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
|
||||
#ifdef _MSC_VER
|
||||
// Disable warning about data loss when doing (remainder >> CHAR_BIT) when
|
||||
// remainder is one byte long. The algorithm is still correct in this case,
|
||||
// though it's possible that one additional machine instruction will be executed.
|
||||
|
|
@ -733,7 +733,7 @@ namespace CRCPP
|
|||
# pragma warning (disable : 4333)
|
||||
#endif
|
||||
remainder = (remainder >> CHAR_BIT) ^ lookupTable[static_cast<unsigned char>(remainder ^ *current++)];
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (pop)
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,9 +225,9 @@ namespace fs
|
|||
{
|
||||
}
|
||||
|
||||
[[noreturn]] stat_t file_base::stat()
|
||||
[[noreturn]] stat_t file_base::get_stat()
|
||||
{
|
||||
fmt::throw_exception("fs::file::stat() not supported.");
|
||||
fmt::throw_exception("fs::file::get_stat() not supported.");
|
||||
}
|
||||
|
||||
void file_base::sync()
|
||||
|
|
@ -1131,7 +1131,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
|||
CloseHandle(m_handle);
|
||||
}
|
||||
|
||||
stat_t stat() override
|
||||
stat_t get_stat() override
|
||||
{
|
||||
FILE_BASIC_INFO basic_info;
|
||||
ensure(GetFileInformationByHandleEx(m_handle, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO))); // "file::stat"
|
||||
|
|
@ -1356,7 +1356,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
|||
::close(m_fd);
|
||||
}
|
||||
|
||||
stat_t stat() override
|
||||
stat_t get_stat() override
|
||||
{
|
||||
struct ::stat file_info;
|
||||
ensure(::fstat(m_fd, &file_info) == 0); // "file::stat"
|
||||
|
|
@ -1506,7 +1506,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
|||
|
||||
m_file = std::make_unique<unix_file>(fd);
|
||||
|
||||
if (mode & fs::isfile && !(mode & fs::write) && stat().is_directory)
|
||||
if (mode & fs::isfile && !(mode & fs::write) && get_stat().is_directory)
|
||||
{
|
||||
m_file.reset();
|
||||
g_tls_error = error::isdir;
|
||||
|
|
@ -1657,7 +1657,7 @@ bool fs::dir::open(const std::string& path)
|
|||
to_utf8(info.name, found.cFileName);
|
||||
info.is_directory = (found.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
info.is_writable = (found.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
info.size = ((u64)found.nFileSizeHigh << 32) | (u64)found.nFileSizeLow;
|
||||
info.size = (static_cast<u64>(found.nFileSizeHigh) << 32) | static_cast<u64>(found.nFileSizeLow);
|
||||
info.atime = to_time(found.ftLastAccessTime);
|
||||
info.mtime = to_time(found.ftLastWriteTime);
|
||||
info.ctime = info.mtime;
|
||||
|
|
@ -2002,13 +2002,13 @@ fs::file fs::make_gather(std::vector<fs::file> files)
|
|||
{
|
||||
}
|
||||
|
||||
fs::stat_t stat() override
|
||||
fs::stat_t get_stat() override
|
||||
{
|
||||
fs::stat_t result{};
|
||||
|
||||
if (!files.empty())
|
||||
{
|
||||
result = files[0].stat();
|
||||
result = files[0].get_stat();
|
||||
}
|
||||
|
||||
result.is_directory = false;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace fs
|
|||
{
|
||||
virtual ~file_base();
|
||||
|
||||
[[noreturn]] virtual stat_t stat();
|
||||
[[noreturn]] virtual stat_t get_stat();
|
||||
virtual void sync();
|
||||
virtual bool trunc(u64 length) = 0;
|
||||
virtual u64 read(void* buffer, u64 size) = 0;
|
||||
|
|
@ -273,14 +273,14 @@ namespace fs
|
|||
}
|
||||
|
||||
// Get file information
|
||||
stat_t stat(
|
||||
stat_t get_stat(
|
||||
u32 line = __builtin_LINE(),
|
||||
u32 col = __builtin_COLUMN(),
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION()) const
|
||||
{
|
||||
if (!m_file) xnull({line, col, file, func});
|
||||
return m_file->stat();
|
||||
return m_file->get_stat();
|
||||
}
|
||||
|
||||
// Sync file buffers
|
||||
|
|
@ -814,7 +814,7 @@ namespace fs
|
|||
return obj.size();
|
||||
}
|
||||
|
||||
stat_t stat() override
|
||||
stat_t get_stat() override
|
||||
{
|
||||
return m_stat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ std::string fmt::win_error_to_string(unsigned long error, void* module_handle)
|
|||
std::string message;
|
||||
LPWSTR message_buffer = nullptr;
|
||||
if (FormatMessageW((module_handle ? FORMAT_MESSAGE_FROM_HMODULE : FORMAT_MESSAGE_FROM_SYSTEM) | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
module_handle, error, 0, (LPWSTR)&message_buffer, 0, nullptr))
|
||||
module_handle, error, 0, reinterpret_cast<LPWSTR>(&message_buffer), 0, nullptr))
|
||||
{
|
||||
message = fmt::format("%s (0x%x)", fmt::trim(wchar_to_utf8(message_buffer), " \t\n\r\f\v"), error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1828,15 +1828,15 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept
|
|||
const bool s_exception_handler_set = []() -> bool
|
||||
{
|
||||
#ifdef USE_ASAN
|
||||
if (!AddVectoredExceptionHandler(FALSE, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
|
||||
if (!AddVectoredExceptionHandler(FALSE, static_cast<PVECTORED_EXCEPTION_HANDLER>(exception_handler)))
|
||||
#else
|
||||
if (!AddVectoredExceptionHandler(1, (PVECTORED_EXCEPTION_HANDLER)exception_handler))
|
||||
if (!AddVectoredExceptionHandler(1, static_cast<PVECTORED_EXCEPTION_HANDLER>(exception_handler)))
|
||||
#endif
|
||||
{
|
||||
report_fatal_error("AddVectoredExceptionHandler() failed.");
|
||||
}
|
||||
|
||||
if (!SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)exception_filter))
|
||||
if (!SetUnhandledExceptionFilter(static_cast<LPTOP_LEVEL_EXCEPTION_FILTER>(exception_filter)))
|
||||
{
|
||||
report_fatal_error("SetUnhandledExceptionFilter() failed.");
|
||||
}
|
||||
|
|
@ -2042,7 +2042,7 @@ void thread_base::start()
|
|||
#ifdef _WIN32
|
||||
m_thread = ::_beginthreadex(nullptr, 0, entry_point, this, CREATE_SUSPENDED, nullptr);
|
||||
ensure(m_thread);
|
||||
ensure(::ResumeThread(reinterpret_cast<HANDLE>(+m_thread)) != -1);
|
||||
ensure(::ResumeThread(reinterpret_cast<HANDLE>(+m_thread)) != static_cast<DWORD>(-1));
|
||||
#elif defined(__APPLE__)
|
||||
pthread_attr_t stack_size_attr;
|
||||
pthread_attr_init(&stack_size_attr);
|
||||
|
|
@ -2150,7 +2150,7 @@ u64 thread_base::finalize(thread_state result_state) noexcept
|
|||
tls_cycles += cycles;
|
||||
FILETIME ctime, etime, ktime, utime;
|
||||
GetThreadTimes(GetCurrentThread(), &ctime, &etime, &ktime, &utime);
|
||||
const u64 time = ((ktime.dwLowDateTime | (u64)ktime.dwHighDateTime << 32) + (utime.dwLowDateTime | (u64)utime.dwHighDateTime << 32)) * 100ull - tls_time;
|
||||
const u64 time = ((ktime.dwLowDateTime | static_cast<u64>(ktime.dwHighDateTime) << 32) + (utime.dwLowDateTime | static_cast<u64>(utime.dwHighDateTime) << 32)) * 100ull - tls_time;
|
||||
tls_time += time;
|
||||
const u64 fsoft = 0;
|
||||
const u64 fhard = 0;
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ namespace utils
|
|||
std::vector<std::string> get_backtrace_symbols(const std::vector<void*>& stack)
|
||||
{
|
||||
std::vector<std::string> result = {};
|
||||
std::vector<u8> symbol_buf(sizeof(SYMBOL_INFO) + sizeof(TCHAR) * 256);
|
||||
std::vector<u8> symbol_buf(sizeof(SYMBOL_INFOW) + sizeof(TCHAR) * 256);
|
||||
|
||||
const auto hProcess = ::GetCurrentProcess();
|
||||
|
||||
auto sym = reinterpret_cast<SYMBOL_INFO*>(symbol_buf.data());
|
||||
sym->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
auto sym = reinterpret_cast<SYMBOL_INFOW*>(symbol_buf.data());
|
||||
sym->SizeOfStruct = sizeof(SYMBOL_INFOW);
|
||||
sym->MaxNameLen = 256;
|
||||
|
||||
IMAGEHLP_LINEW64 line_info{};
|
||||
|
|
@ -90,7 +90,7 @@ namespace utils
|
|||
for (const auto& pointer : stack)
|
||||
{
|
||||
DWORD64 unused;
|
||||
SymFromAddr(hProcess, reinterpret_cast<DWORD64>(pointer), &unused, sym);
|
||||
SymFromAddrW(hProcess, reinterpret_cast<DWORD64>(pointer), &unused, sym);
|
||||
|
||||
if (sym->NameLen)
|
||||
{
|
||||
|
|
@ -98,7 +98,7 @@ namespace utils
|
|||
|
||||
// Attempt to get file and line information if available
|
||||
DWORD unused2;
|
||||
if (SymGetLineFromAddrW(hProcess, reinterpret_cast<DWORD64>(pointer), &unused2, &line_info))
|
||||
if (SymGetLineFromAddrW64(hProcess, reinterpret_cast<DWORD64>(pointer), &unused2, &line_info))
|
||||
{
|
||||
const auto full_path = fmt::format("%s:%u %s", wstr_to_utf8(line_info.FileName, -1), line_info.LineNumber, function_name);
|
||||
result.push_back(full_path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue