in ports/Clock/src/aia_clock_config.c [59:84]
AiaTimepointSeconds_t AiaClock_GetTimeSinceNTPEpoch()
{
while( !Atomic_CompareAndSwap_u32( &g_spinLock, 1, 0 ) )
{
/* spin lock, inefficient */
}
if( !g_serverSynchronized )
{
/* RFC 868 */
static const AiaTimepointSeconds_t UNIX_NTP_EPOCH_DELTA_SECONDS =
2208988800;
/* Initial retrieval of time from system. */
/* Although not defined by the C standard, this is almost always an
* integral value holding the number of seconds (not counting leap
* seconds) since 00:00, Jan 1 1970 UTC, corresponding to POSIX time. */
g_lastRetrievedTimeSinceNTPEpoch =
time( NULL ) + UNIX_NTP_EPOCH_DELTA_SECONDS;
g_lastSynchronization = AiaClock( GetTimeMs )() / AIA_MS_PER_SECOND;
}
AiaTimepointSeconds_t ret =
g_lastRetrievedTimeSinceNTPEpoch +
( ( AiaClock( GetTimeMs )() / AIA_MS_PER_SECOND ) -
g_lastSynchronization );
AiaAtomicBool_Clear( &g_spinLock );
return ret;
}