mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 00:53:34 +08:00
STM32 driver: Space optimized SystemClock constructor
This commit is contained in:
@@ -217,16 +217,24 @@ uavcan::uint32_t getUtcAjdustmentJumpCount()
|
||||
|
||||
} // namespace clock
|
||||
|
||||
SystemClock SystemClock::self;
|
||||
|
||||
SystemClock& SystemClock::instance()
|
||||
{
|
||||
MutexLocker mlocker(clock::mutex);
|
||||
|
||||
static union SystemClockStorage
|
||||
{
|
||||
uavcan::uint8_t buffer[sizeof(SystemClock)];
|
||||
long long _aligner_1;
|
||||
long double _aligner_2;
|
||||
} storage;
|
||||
SystemClock* const ptr = reinterpret_cast<SystemClock*>(storage.buffer);
|
||||
|
||||
if (!clock::initialized)
|
||||
{
|
||||
clock::init();
|
||||
new (ptr) SystemClock();
|
||||
}
|
||||
return self;
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
} // namespace uavcan_stm32
|
||||
|
||||
Reference in New Issue
Block a user