From 863e8fdd3bc199e81512c8113a50848ee01418c5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 7 Jun 2013 14:35:45 -0500 Subject: [PATCH] libCom: Fix VxWorks localtime_r() and gmtime_r() wrappers Wind River changed the return value between VxWorks 6.8 and 6.9. --- src/libCom/osi/os/vxWorks/osdTime.cpp | 12 ++++++++---- src/libCom/test/epicsTimeTest.cpp | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/libCom/osi/os/vxWorks/osdTime.cpp b/src/libCom/osi/os/vxWorks/osdTime.cpp index a0e2422e9..eed1ad078 100644 --- a/src/libCom/osi/os/vxWorks/osdTime.cpp +++ b/src/libCom/osi/os/vxWorks/osdTime.cpp @@ -67,14 +67,18 @@ void osdNTPReport(void) } -// vxWorks localtime_r interface does not match POSIX standards +// vxWorks localtime_r returns different things in different versions. +// It can't fail though, so we just ignore the return value. int epicsTime_localtime(const time_t *clock, struct tm *result) { - return localtime_r(clock, result) == OK ? epicsTimeOK : epicsTimeERROR; + localtime_r(clock, result); + return epicsTimeOK; } -// vxWorks gmtime_r interface does not match POSIX standards +// vxWorks gmtime_r returns different things in different versions. +// It can't fail though, so we just ignore the return value. int epicsTime_gmtime ( const time_t *pAnsiTime, struct tm *pTM ) { - return gmtime_r(pAnsiTime, pTM) == OK ? epicsTimeOK : epicsTimeERROR; + gmtime_r(pAnsiTime, pTM); + return epicsTimeOK; } diff --git a/src/libCom/test/epicsTimeTest.cpp b/src/libCom/test/epicsTimeTest.cpp index c89d13a5c..c108eca7f 100644 --- a/src/libCom/test/epicsTimeTest.cpp +++ b/src/libCom/test/epicsTimeTest.cpp @@ -48,17 +48,23 @@ MAIN(epicsTimeTest) const int wasteTime = 100000; const int nTimes = 10; - testPlan(16 + nTimes * 18); + testPlan(12 + nTimes * 18); - { + try { const epicsTimeStamp epochTS = {0, 0}; epicsTime epochET = epochTS; struct gm_tm_nano_sec epicsEpoch = epochET; - testOk1(epicsEpoch.ansi_tm.tm_sec == 0); - testOk1(epicsEpoch.ansi_tm.tm_min == 0); - testOk1(epicsEpoch.ansi_tm.tm_hour == 0); - testOk1(epicsEpoch.ansi_tm.tm_yday == 0); - testOk1(epicsEpoch.ansi_tm.tm_year == 90); + + testOk(epicsEpoch.ansi_tm.tm_sec == 0 && + epicsEpoch.ansi_tm.tm_min == 0 && + epicsEpoch.ansi_tm.tm_hour == 0 && + epicsEpoch.ansi_tm.tm_yday == 0 && + epicsEpoch.ansi_tm.tm_year == 90, + "epicsTime_gmtime() for EPICS epoch"); + } + catch ( ... ) { + testFail("epicsTime_gmtime() failed"); + testAbort("Can't continue, check your OS!"); } { // badNanosecTest