devkitA64 compilation fixes

This commit is contained in:
Luke Street 2020-10-21 00:39:16 -04:00
parent 9a10e58f8d
commit bad0f06254
4 changed files with 7 additions and 5 deletions

View File

@ -265,7 +265,7 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
OVERLAPPED ov = {};
LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1,
&ov);
#else
#elif !defined(__SWITCH__)
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
LogModule.report(logvisor::Error, FMT_STRING("flock {}: {}"), path, strerror(errno));
#endif
@ -277,7 +277,7 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
static inline int FSeek(FILE* fp, int64_t offset, int whence) {
#if _WIN32
return _fseeki64(fp, offset, whence);
#elif __APPLE__ || __FreeBSD__
#elif __APPLE__ || __FreeBSD__ || __SWITCH__
return fseeko(fp, offset, whence);
#else
return fseeko64(fp, offset, whence);
@ -287,7 +287,7 @@ static inline int FSeek(FILE* fp, int64_t offset, int whence) {
static inline int64_t FTell(FILE* fp) {
#if _WIN32
return _ftelli64(fp);
#elif __APPLE__ || __FreeBSD__
#elif __APPLE__ || __FreeBSD__ || __SWITCH__
return ftello(fp);
#else
return ftello64(fp);

View File

@ -284,6 +284,7 @@ static bool IsSystemFile(SystemStringView name, bool& isDol) {
* This is required for multi-DOL games, but doesn't harm functionality otherwise */
static void PatchDOL(std::unique_ptr<uint8_t[]>& buf, size_t sz, bool& patched) {
patched = false;
#ifndef __SWITCH__
uint8_t* found = static_cast<uint8_t*>(memmem(buf.get(), sz,
"\x3C\x03\xF8\x00\x28\x00\x00\x00\x40\x82\x00\x0C"
"\x38\x60\x00\x01\x48\x00\x02\x44\x38\x61\x00\x18\x48",
@ -292,6 +293,7 @@ static void PatchDOL(std::unique_ptr<uint8_t[]>& buf, size_t sz, bool& patched)
found[11] = '\x04';
patched = true;
}
#endif
}
static size_t PatchDOL(IFileIO::IReadStream& in, IPartWriteStream& out, size_t sz, bool& patched) {

View File

@ -4,7 +4,7 @@
#if _WIN32
#include <intrin.h>
#else
#elif __x86_64__
#include <cpuid.h>
#endif

View File

@ -17,7 +17,7 @@
# endif
#else // ! defined __LITTLE_ENDIAN__
#ifndef _WIN32
# include <endian.h> // machine/endian.h
# include <machine/endian.h>
#endif
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define SHA_BIG_ENDIAN