ANDROID is defined by the NDK
__ANDROID__ is defined by the compiler.
When compiling for android without the NDK, such as inside Termux,
ANDROID isn't defined.
POSIX guarantees that off_t is a signed integer type. It was typically
int32_t on historical versions of implementations. Some kind of
migration is necessary for platforms that started with int32_t, and
glibc did it the worst way possible: 32-bit platforms still default to
32-bit off_t, they added a _FILE_OFFSET_BITS macro to request a specific
size, and you can alternatively call nonstandard versions of standard
functions that work with off_t which use a specific size, these are
typically suffixed with "64" (e.g. ftruncate64, stat64) and work with a
nonstandard off64_t type.
Swanstation gets this confusing situation wrong by both defining
_FILE_OFFSET_BITS=64 and using the nonstandard .*64 functions on Linux.
This works on glibc, but breaks other libcs such as musl. By using the
standard names and letting _FILE_OFFSET_BITS handle the rest on glibc,
the code works on all Linux systems.
Ref: https://www.gnu.org/software/libc/manual/html_node/File-Size.html#index-ftruncate64
In file included from /home/jan/Work/swanstation/src/core/bus.cpp:6:
In file included from /home/jan/Work/swanstation/src/core/cpu_code_cache.h:14:
/home/jan/Work/swanstation/src/core/cpu_recompiler_types.h:70:37: error: integer value 16 is outside the valid range of values [0, 15] for the enumeration type 'Code' [-Wenum-constexpr-conver
sion]
70 | constexpr HostReg HostReg_Invalid = static_cast<HostReg>(HostReg_Count);
| ^
2 warnings and 1 error generated.
The code was unspecified behavior in C++ prior to C++17, and was changed
to undefined behavior in C++17. Recent versions of Clang have added a
warning that is treated as an error by default for it, and this commit
fixes compilation on recent Clang.
Ref: https://wiki.sei.cmu.edu/confluence/display/cplusplus/INT50-CPP.+Do+not+cast+to+an+out-of-range+enumeration+value
Ref: https://releases.llvm.org/18.1.4/tools/clang/docs/DiagnosticsReference.html#wenum-constexpr-conversion