summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/psc/time/clocks/tick_based_steady_clock_core.cpp
blob: 22da1fbccc358ff1d70379605ef23f66e085b2a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include <chrono>

#include "core/core.h"
#include "core/core_timing.h"
#include "core/hle/service/psc/time/clocks/tick_based_steady_clock_core.h"

namespace Service::PSC::Time {

Result TickBasedSteadyClockCore::GetCurrentTimePointImpl(SteadyClockTimePoint& out_time_point) {
    auto ticks{m_system.CoreTiming().GetClockTicks()};
    auto current_time_s =
        std::chrono::duration_cast<std::chrono::seconds>(ConvertToTimeSpan(ticks)).count();
    out_time_point.time_point = current_time_s;
    out_time_point.clock_source_id = m_clock_source_id;
    R_SUCCEED();
}

s64 TickBasedSteadyClockCore::GetCurrentRawTimePointImpl() {
    SteadyClockTimePoint time_point{};
    if (GetCurrentTimePointImpl(time_point) != ResultSuccess) {
        LOG_ERROR(Service_Time, "Failed to GetCurrentTimePoint!");
    }
    return std::chrono::duration_cast<std::chrono::nanoseconds>(
               std::chrono::seconds(time_point.time_point))
        .count();
}

s64 TickBasedSteadyClockCore::GetTestOffsetImpl() const {
    return 0;
}

void TickBasedSteadyClockCore::SetTestOffsetImpl(s64 offset) {}

s64 TickBasedSteadyClockCore::GetInternalOffsetImpl() const {
    return 0;
}

void TickBasedSteadyClockCore::SetInternalOffsetImpl(s64 offset) {}

} // namespace Service::PSC::Time