From bad0f062545a39b230f29bb2285fb961e17eca40 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 21 Oct 2020 00:39:16 -0400 Subject: [PATCH] devkitA64 compilation fixes --- include/nod/Util.hpp | 6 +++--- lib/DiscBase.cpp | 2 ++ lib/aes.cpp | 2 +- lib/sha1.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/nod/Util.hpp b/include/nod/Util.hpp index 6bad58a..6cd4fad 100644 --- a/include/nod/Util.hpp +++ b/include/nod/Util.hpp @@ -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); diff --git a/lib/DiscBase.cpp b/lib/DiscBase.cpp index 43044e8..afa4020 100644 --- a/lib/DiscBase.cpp +++ b/lib/DiscBase.cpp @@ -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& buf, size_t sz, bool& patched) { patched = false; +#ifndef __SWITCH__ uint8_t* found = static_cast(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& 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) { diff --git a/lib/aes.cpp b/lib/aes.cpp index 5fea4c9..402cff4 100644 --- a/lib/aes.cpp +++ b/lib/aes.cpp @@ -4,7 +4,7 @@ #if _WIN32 #include -#else +#elif __x86_64__ #include #endif diff --git a/lib/sha1.c b/lib/sha1.c index d98f353..68f5561 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -17,7 +17,7 @@ # endif #else // ! defined __LITTLE_ENDIAN__ #ifndef _WIN32 -# include // machine/endian.h +# include #endif # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define SHA_BIG_ENDIAN