--- nono/vm/rtc.cpp 2026/04/29 17:05:11 1.1.1.8 +++ nono/vm/rtc.cpp 2026/04/29 17:05:18 1.1.1.9 @@ -11,14 +11,11 @@ #include "rtc.h" #include "config.h" #include "scheduler.h" -#include "sync.h" - -// グローバル参照用 -RTCDevice *gRTC; +#include "syncer.h" // コンストラクタ -RTCDevice::RTCDevice(const std::string& objname_) - : inherited(objname_) +RTCDevice::RTCDevice() + : inherited(OBJ_RTC) { event.Regist("RTC ClockIn"); event.time = period; @@ -28,12 +25,18 @@ RTCDevice::RTCDevice(const std::string& // デストラクタ RTCDevice::~RTCDevice() { - gRTC = NULL; } +// 初期化 bool RTCDevice::Init() { + if (inherited::Init() == false) { + return false; + } + + syncer = GetSyncer(); + // TODO: use_localtime を設定可能にするべきかどうか // 時刻固定オプション (パフォーマンス測定用)。 @@ -155,9 +158,9 @@ RTCDevice::StartTime() SetYear(tm.tm_year + 1900); SetLeap(tm.tm_year & 3); - stime = gSync->GetRealTime(); + stime = syncer->GetRealTime(); - gScheduler->StartEvent(event); + scheduler->StartEvent(event); } // デバッグオプションの日付文字列を解析する。 @@ -244,9 +247,9 @@ RTCDevice::Callback(Event& ev) stime += period; ClockIn(); if (sync_rt) { - gScheduler->StartRealtimeEvent(ev, stime, period); + scheduler->StartRealtimeEvent(ev, stime, period); } else { - gScheduler->StartEvent(ev); + scheduler->StartEvent(ev); } } @@ -258,7 +261,7 @@ RTCDevice::ClockIn_PowerOff() ClockIn(); // XXX RealTime ではなく HostTime? - uint64 rt = gSync->GetRealTime(); + uint64 rt = syncer->GetRealTime(); if (rt > stime) { // RTC が現実より遅れているので早回し return 0;