diff --git a/src/libCom/osi/os/posix/osdTime.cpp b/src/libCom/osi/os/posix/osdTime.cpp index 0f91ee427..0ea1b96ff 100644 --- a/src/libCom/osi/os/posix/osdTime.cpp +++ b/src/libCom/osi/os/posix/osdTime.cpp @@ -24,6 +24,11 @@ #define TIME_INIT ClockTime_Init(CLOCKTIME_NOSYNC) #else + /* Some posix systems like Darwin don't have CLOCK_REALTIME */ + + #define TIME_INIT generalTimeCurrentTpRegister("GetTimeOfDay", \ + LAST_RESORT_PRIORITY, osdTimeGetCurrent) + extern "C" { static int osdTimeGetCurrent (epicsTimeStamp *pDest) { @@ -37,9 +42,6 @@ return epicsTimeOK; } } // extern "C" - - #define TIME_INIT generalTimeCurrentTpRegister("GetTimeOfDay", \ - LAST_RESORT_PRIORITY, osdTimeGetCurrent) #endif static int timeRegister(void) diff --git a/src/libCom/osi/osiClockTime.c b/src/libCom/osi/osiClockTime.c index 3ba74e5ae..ea3e0c3eb 100644 --- a/src/libCom/osi/osiClockTime.c +++ b/src/libCom/osi/osiClockTime.c @@ -37,6 +37,12 @@ static struct { static epicsThreadOnceId onceId = EPICS_THREAD_ONCE_INIT; +#ifdef CLOCK_REALTIME +/* This code is not used on systems without Posix CLOCK_REALTIME such + * as Darwin, but the only way to detect that is from the OS headers, + * so the Makefile can't exclude building this file on those systems. + */ + /* Forward references */ static int ClockTimeGetCurrent(epicsTimeStamp *pDest); @@ -147,7 +153,7 @@ static int ClockTimeGetCurrent(epicsTimeStamp *pDest) /* If a Hi-Res clock is available and works, use it */ #ifdef CLOCK_REALTIME_HR - clock_gettime(CLOCK_REALTIME_HD, &clockNow) && + clock_gettime(CLOCK_REALTIME_HR, &clockNow) && #endif clock_gettime(CLOCK_REALTIME, &clockNow); @@ -165,6 +171,11 @@ static int ClockTimeGetCurrent(epicsTimeStamp *pDest) } +#endif /* CLOCK_REALTIME */ +/* Allow the following report routine to be compiled anyway + * to avoid getting a build warning from ranlib. + */ + /* Status Report */ int ClockTime_Report(int level)