Fixes issue where fopen("test.txt","r") opens 3dstest.txt instead of test.txt.
Also correct misuse of strncat() as count applies to src not dest.
See:
8136d94657806a4d34c5
Since kernel doesn't directly access the LMA, but just does memory
management on them instead, they should be passed as u32 (uptr) instead
of void *.
Also change CodeSetInfo to CodeSetHeader to avoid confusion with
ExHeader types.
Fix chainload method used when HM is not launched.
We now wait for custom PM to change our launch flag and ask us to
terminate. We previously had a few issues:
- a potential race condition where we exit before PM changes our
runflags (not observed)
- a kernel deadlock between ExitProcess and TerminateProcess (observed,
this is due to Nintendo's lack of barrier in many of their atomics
code)
- debuggers reporting that we were terminated, instead of exiting
gracefully (not desirable)
This implements the syscalls for `clock_gettime` and `clock_getres`. We
support two clocks: CLOCK_REALTIME and CLOCK_MONOTONIC. I've opted to
use the existing `osGetTime()` code for the realtime clock, because it's
known to work.
For CLOCK_MONOTONIC I've used `svcGetSystemTick()` directly, as it has a
higher resolution. We can ignore the drift and so on, because it's
supposed to be just the number of ticks since last boot.
This is a potentially breaking change as the register was left with an unpredictable/unspecified value.
Config: default NaN mode enabled, flush-to-zero enabled, and round to nearest.
Prior to system version 11.0, the kernel filled the resulting handle with junk in case of failure, when calling svcConnectToPort, etc.
In some situations libctru could accidentally close valid handles.