10 #define _VSB_CONFIG_FILE <../lib/h/config/vsbConfig.h> 19 #define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE 26 #define NTP_REQUEST_TIMEOUT 4 32 static char sntp_sync_task[] =
"ipsntps";
33 static char ntp_daemon[] =
"ipntpd";
35 static const char *pserverAddr =
NULL;
36 static CLOCKTIME_SYNCHOOK prevHook;
40 static void timeSync(
int synchronized) {
42 ClockTime_syncHook = prevHook;
45 static int timeRegister(
void)
48 if (getenv(
"TZ") ==
NULL) {
55 prevHook = ClockTime_syncHook;
56 ClockTime_syncHook = timeSync;
58 else if (getenv(
"TIMEZONE") ==
NULL)
59 printf(
"timeRegister: No Time Zone Information available\n");
63 bool useNTP = getenv(
"EPICS_TS_FORCE_NTPTIME") !=
NULL;
66 (taskNameToId(sntp_sync_task) != ERROR ||
67 taskNameToId(ntp_daemon) != ERROR)) {
71 useNTP = clock_gettime(CLOCK_REALTIME, &clockNow) != OK ||
72 clockNow.
tv_sec < BUILD_TIME;
86 static int done = timeRegister();
93 return sntpcTimeGet(const_cast<char *>(pserverAddr),
101 BOOT_PARAMS bootParms;
102 static char host_addr[BOOT_ADDR_LEN];
106 strncpy(host_addr, bootParms.had, BOOT_ADDR_LEN);
107 pserverAddr = host_addr;
114 printf(
"NTP Server = %s\n", pserverAddr);
124 localtime_r(clock, result);
132 gmtime_r(pAnsiTime, pTM);
LIBCOM_API const ENV_PARAM EPICS_TZ
int osdNTPGet(struct timespec *ts)
void ClockTime_Init(int synchronize)
LIBCOM_API const char *epicsStdCall envGetConfigParamPtr(const ENV_PARAM *pParam)
Get a configuration parameter's value or default string.
Routines to get and set EPICS environment parameters.
void osdMonotonicInit(void)
#define epicsTimeOK
Success.
void NTPTime_Init(int priority)
LIBCOM_API void epicsStdCall epicsEnvSet(const char *name, const char *value)
Set an environment variable's value.
LIBCOM_API const ENV_PARAM EPICS_TS_NTP_INET
Defined by POSIX Real Time.
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...
#define NTP_REQUEST_TIMEOUT
int epicsTime_gmtime(const time_t *pAnsiTime, struct tm *pTM)
Break down a time_t into a struct tm in the UTC timezone.
int epicsTime_localtime(const time_t *clock, struct tm *result)
Break down a time_t into a struct tm in the local timezone.