ams: support building unit test programs on windows/linux/macos
This commit is contained in:
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
extern "C" {
|
||||
|
||||
extern TimeServiceType __nx_time_service_type;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace ams::time {
|
||||
|
||||
@@ -48,6 +50,7 @@ namespace ams::time {
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
switch (mode) {
|
||||
case InitializeMode_Normal: __nx_time_service_type = ::TimeServiceType_User; break;
|
||||
case InitializeMode_Menu: __nx_time_service_type = ::TimeServiceType_Menu; break;
|
||||
@@ -58,6 +61,9 @@ namespace ams::time {
|
||||
}
|
||||
|
||||
R_TRY(::timeInitialize());
|
||||
#else
|
||||
AMS_ABORT("TODO");
|
||||
#endif
|
||||
|
||||
g_initialize_count++;
|
||||
g_initialize_mode = mode;
|
||||
@@ -87,7 +93,11 @@ namespace ams::time {
|
||||
|
||||
if (g_initialize_count > 0) {
|
||||
if ((--g_initialize_count) == 0) {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
::timeExit();
|
||||
#else
|
||||
AMS_ABORT("TODO");
|
||||
#endif
|
||||
g_initialize_mode = InitializeMode_None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,13 @@
|
||||
namespace ams::time {
|
||||
|
||||
Result StandardNetworkSystemClock::GetCurrentTime(PosixTime *out) {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
static_assert(sizeof(*out) == sizeof(u64));
|
||||
return ::timeGetCurrentTime(::TimeType_NetworkSystemClock, reinterpret_cast<u64 *>(out));
|
||||
#else
|
||||
AMS_UNUSED(out);
|
||||
AMS_ABORT("TODO");
|
||||
#endif
|
||||
}
|
||||
|
||||
StandardNetworkSystemClock::time_point StandardNetworkSystemClock::now() {
|
||||
|
||||
@@ -18,14 +18,26 @@
|
||||
namespace ams::time {
|
||||
|
||||
Result GetStandardSteadyClockCurrentTimePoint(SteadyClockTimePoint *out) {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
static_assert(sizeof(*out) == sizeof(::TimeSteadyClockTimePoint));
|
||||
return ::timeGetStandardSteadyClockTimePoint(reinterpret_cast<::TimeSteadyClockTimePoint *>(out));
|
||||
#else
|
||||
AMS_UNUSED(out);
|
||||
AMS_ABORT("TODO");
|
||||
#endif
|
||||
}
|
||||
|
||||
TimeSpan GetStandardSteadyClockInternalOffset() {
|
||||
static_assert(sizeof(TimeSpanType) == sizeof(s64));
|
||||
TimeSpanType offset;
|
||||
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
static_assert(sizeof(TimeSpanType) == sizeof(s64));
|
||||
R_ABORT_UNLESS(::timeGetStandardSteadyClockInternalOffset(reinterpret_cast<s64 *>(std::addressof(offset))));
|
||||
#else
|
||||
AMS_UNUSED(offset);
|
||||
AMS_ABORT("TODO");
|
||||
#endif
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,13 @@
|
||||
namespace ams::time {
|
||||
|
||||
Result StandardUserSystemClock::GetCurrentTime(PosixTime *out) {
|
||||
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||
static_assert(sizeof(*out) == sizeof(u64));
|
||||
return ::timeGetCurrentTime(::TimeType_UserSystemClock, reinterpret_cast<u64 *>(out));
|
||||
#else
|
||||
AMS_UNUSED(out);
|
||||
AMS_ABORT("TODO");
|
||||
#endif
|
||||
}
|
||||
|
||||
StandardUserSystemClock::time_point StandardUserSystemClock::now() {
|
||||
|
||||
Reference in New Issue
Block a user