Merge lp:~epics-core/epics-base/epicsTime-status into lp:~epics-core/epics-base/3.16

Proposed by Andrew Johnson
Status: Merged
Merged at revision: 12656
Proposed branch: lp:~epics-core/epics-base/epicsTime-status
Merge into: lp:~epics-core/epics-base/3.16
Diff against target: 550 lines (+85/-48)
12 files modified
documentation/RELEASE_NOTES.html (+22/-0)
src/libCom/error/Makefile (+1/-0)
src/libCom/error/errMdef.h (+1/-0)
src/libCom/osi/epicsGeneralTime.c (+22/-18)
src/libCom/osi/epicsTime.cpp (+11/-11)
src/libCom/osi/epicsTime.h (+9/-2)
src/libCom/osi/os/Darwin/osdTime.cpp (+3/-2)
src/libCom/osi/os/RTEMS/osdTime.cpp (+2/-2)
src/libCom/osi/os/WIN32/osdTime.cpp (+7/-7)
src/libCom/osi/os/posix/osdTime.cpp (+4/-3)
src/libCom/osi/osiNTPTime.c (+2/-2)
src/std/dev/devGeneralTime.c (+1/-1)
To merge this branch: bzr merge lp:~epics-core/epics-base/epicsTime-status
Reviewer Review Type Date Requested Status
mdavidsaver Approve
Review via email: mp+243463@code.launchpad.net

Description of the change

The return value epicsTimeERROR is useless when trying to track down a fault.
This branch replaces it with specific status values for the different kinds of errors.

To post a comment you must log in.
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

I like the idea of more specific errors, but I'd like to keep the definition of epicsTimeERROR to maintain source compatibility with external code (ie. the time provider in mrfioc2). Perhaps epicsTimeERROR can be an alias for an S_ error code (S_time_legacy?).

Otherwise no problem. I can make the change if Andrew approves a name.

review: Needs Fixing
12623. By Andrew Johnson

Show how to make time providers backwards-compatible

Revision history for this message
Andrew Johnson (anj) wrote :

The problem with keeping the epicsTimeERROR definition is that any code that equality compares it with a returned status value will stop working. Several such uses were fixed in this branch, for example this code would still compile with the requested change but needs to be modified to work properly:
  if (epicsTimeFromTimespec(&timeNow, &timespecNow) == epicsTimeERROR) { ... }
since epicsTimeFromTimespec() now returns S_time_conversion on error.

It could be rewritten as either
  if (epicsTimeFromTimespec(&timeNow, &timespecNow) != epicsTimeOK) { ... }
or
  if (epicsTimeFromTimespec(&timeNow, &timespecNow)) { ... }
both of which are backwards compatible.

Time providers that have to return a status and need to be backwards compatible could do this:

#include "epicsTime.h"
#ifndef M_time
/* S_time_... status values were not provided before Base 3.16 */
#define S_time_unsynchronized epicsTimeERROR
#define S_time_...whatever... epicsTimeERROR
#endif

I added the above suggestion for time provider code to the release notes.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

> The problem with keeping the epicsTimeERROR definition is that any code that equality compares it with a returned status value will stop working.

Good point.

FYI the case I have is:

https://github.com/epics-modules/mrfioc2/blob/master/evrApp/src/evrGTIF.cpp

The important thing is to have code which works for both <=3.15 and >=3.16, which could be done the in way you mention.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'documentation/RELEASE_NOTES.html'
--- documentation/RELEASE_NOTES.html 2015-04-16 23:12:59 +0000
+++ documentation/RELEASE_NOTES.html 2015-06-03 05:15:51 +0000
@@ -20,6 +20,28 @@
2020
21-->21-->
2222
23<h3>epicsTime API return status</h3>
24
25<p>The epicsTime routines that used to return epicsTimeERROR now return a specific
26S_time_ status value, allowing the caller to discover the reason for any failure.
27The identifier <tt>epicsTimeERROR</tt> is no longer defined, so any references to
28it in source code will no longer compile. The identifier epicsTimeOK still exists
29and has the value 0 as before, so most code that uses these APIs can be changed in
30a way that is backwards-compatible with the previous return status.</p>
31
32<p>Time providers that have to return a status value and still need to be built
33with earlier versions of Base can define the necessary status symbols like this:</p>
34
35<blockquote><pre>
36#include "epicsTime.h"
37
38#ifndef M_time
39/* S_time_... status values were not provided before Base 3.16 */
40#define S_time_unsynchronized epicsTimeERROR
41#define S_time_...whatever... epicsTimeERROR
42#endif
43</pre></blockquote>
44
23<h3>Callback subsystem API</h3>45<h3>Callback subsystem API</h3>
2446
25<p>Added a new macro <tt>callbackGetPriority(prio, callback)</tt> to the47<p>Added a new macro <tt>callbackGetPriority(prio, callback)</tt> to the
2648
=== modified file 'src/libCom/error/Makefile'
--- src/libCom/error/Makefile 2014-08-01 22:55:53 +0000
+++ src/libCom/error/Makefile 2015-06-03 05:15:51 +0000
@@ -22,6 +22,7 @@
22# For bldErrSymTbl22# For bldErrSymTbl
23#23#
24ERR_S_FILES += $(LIBCOM)/osi/devLib.h24ERR_S_FILES += $(LIBCOM)/osi/devLib.h
25ERR_S_FILES += $(LIBCOM)/osi/epicsTime.h
25ERR_S_FILES += $(LIBCOM)/as/asLib.h26ERR_S_FILES += $(LIBCOM)/as/asLib.h
26ERR_S_FILES += $(LIBCOM)/misc/epicsStdlib.h27ERR_S_FILES += $(LIBCOM)/misc/epicsStdlib.h
27ERR_S_FILES += $(LIBCOM)/pool/epicsThreadPool.h28ERR_S_FILES += $(LIBCOM)/pool/epicsThreadPool.h
2829
=== modified file 'src/libCom/error/errMdef.h'
--- src/libCom/error/errMdef.h 2014-08-01 22:55:53 +0000
+++ src/libCom/error/errMdef.h 2015-06-03 05:15:51 +0000
@@ -50,6 +50,7 @@
50#define M_gddFuncTbl (526 <<16) /*gdd jump table*/50#define M_gddFuncTbl (526 <<16) /*gdd jump table*/
51#define M_stdlib (527 <<16) /*EPICS Standard library*/51#define M_stdlib (527 <<16) /*EPICS Standard library*/
52#define M_pool (528 <<16) /*Thread pool*/52#define M_pool (528 <<16) /*Thread pool*/
53#define M_time (529 <<16) /*epicsTime*/
5354
54epicsShareFunc void epicsShareAPI errSymLookup(long status, char *pBuf, unsigned bufLength);55epicsShareFunc void epicsShareAPI errSymLookup(long status, char *pBuf, unsigned bufLength);
55epicsShareFunc void epicsShareAPI errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum);56epicsShareFunc void epicsShareAPI errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum);
5657
=== modified file 'src/libCom/osi/epicsGeneralTime.c'
--- src/libCom/osi/epicsGeneralTime.c 2013-12-11 23:50:29 +0000
+++ src/libCom/osi/epicsGeneralTime.c 2015-06-03 05:15:51 +0000
@@ -86,7 +86,7 @@
86int generalTimeGetExceptPriority(epicsTimeStamp *pDest, int *pPrio, int ignore)86int generalTimeGetExceptPriority(epicsTimeStamp *pDest, int *pPrio, int ignore)
87{87{
88 gtProvider *ptp;88 gtProvider *ptp;
89 int status = epicsTimeERROR;89 int status = S_time_noProvider;
9090
91 generalTime_Init();91 generalTime_Init();
9292
@@ -107,6 +107,7 @@
107 *pPrio = ptp->priority;107 *pPrio = ptp->priority;
108 } else {108 } else {
109 int key;109 int key;
110
110 *pDest = gtPvt.lastProvidedTime;111 *pDest = gtPvt.lastProvidedTime;
111 if (pPrio)112 if (pPrio)
112 *pPrio = gtPvt.lastTimeProvider->priority;113 *pPrio = gtPvt.lastTimeProvider->priority;
@@ -117,8 +118,7 @@
117 break;118 break;
118 }119 }
119 }120 }
120 if (status == epicsTimeERROR &&121 if (status && ignore == 0)
121 ignore == 0)
122 gtPvt.lastTimeProvider = NULL;122 gtPvt.lastTimeProvider = NULL;
123 epicsMutexUnlock(gtPvt.timeListLock);123 epicsMutexUnlock(gtPvt.timeListLock);
124124
@@ -135,7 +135,8 @@
135 gtProvider *ptp = gtPvt.lastTimeProvider;135 gtProvider *ptp = gtPvt.lastTimeProvider;
136136
137 if (ptp == NULL ||137 if (ptp == NULL ||
138 ptp->getInt.Time == NULL) return epicsTimeERROR;138 ptp->getInt.Time == NULL)
139 return S_time_noProvider;
139140
140 return ptp->getInt.Time(pDest);141 return ptp->getInt.Time(pDest);
141}142}
@@ -145,20 +146,20 @@
145 int *pPrio)146 int *pPrio)
146{147{
147 gtProvider *ptp;148 gtProvider *ptp;
148 int status = epicsTimeERROR;149 int status = S_time_noProvider;
149150
150 generalTime_Init();151 generalTime_Init();
151152
152 if ((eventNumber < 0 || eventNumber >= NUM_TIME_EVENTS) &&153 if ((eventNumber < 0 || eventNumber >= NUM_TIME_EVENTS) &&
153 (eventNumber != epicsTimeEventBestTime))154 (eventNumber != epicsTimeEventBestTime))
154 return status;155 return S_time_badEvent;
155156
156 epicsMutexMustLock(gtPvt.eventListLock);157 epicsMutexMustLock(gtPvt.eventListLock);
157 for (ptp = (gtProvider *)ellFirst(&gtPvt.eventProviders);158 for (ptp = (gtProvider *)ellFirst(&gtPvt.eventProviders);
158 ptp; ptp = (gtProvider *)ellNext(&ptp->node)) {159 ptp; ptp = (gtProvider *)ellNext(&ptp->node)) {
159160
160 status = ptp->get.Event(pDest, eventNumber);161 status = ptp->get.Event(pDest, eventNumber);
161 if (status != epicsTimeERROR) {162 if (status == epicsTimeOK) {
162 gtPvt.lastEventProvider = ptp;163 gtPvt.lastEventProvider = ptp;
163 if (pPrio)164 if (pPrio)
164 *pPrio = ptp->priority;165 *pPrio = ptp->priority;
@@ -169,6 +170,7 @@
169 gtPvt.lastProvidedBestTime = *pDest;170 gtPvt.lastProvidedBestTime = *pDest;
170 } else {171 } else {
171 int key;172 int key;
173
172 *pDest = gtPvt.lastProvidedBestTime;174 *pDest = gtPvt.lastProvidedBestTime;
173 key = epicsInterruptLock();175 key = epicsInterruptLock();
174 gtPvt.ErrorCounts++;176 gtPvt.ErrorCounts++;
@@ -180,6 +182,7 @@
180 gtPvt.eventTime[eventNumber] = *pDest;182 gtPvt.eventTime[eventNumber] = *pDest;
181 } else {183 } else {
182 int key;184 int key;
185
183 *pDest = gtPvt.eventTime[eventNumber];186 *pDest = gtPvt.eventTime[eventNumber];
184 key = epicsInterruptLock();187 key = epicsInterruptLock();
185 gtPvt.ErrorCounts++;188 gtPvt.ErrorCounts++;
@@ -189,7 +192,7 @@
189 break;192 break;
190 }193 }
191 }194 }
192 if (status == epicsTimeERROR)195 if (status)
193 gtPvt.lastEventProvider = NULL;196 gtPvt.lastEventProvider = NULL;
194 epicsMutexUnlock(gtPvt.eventListLock);197 epicsMutexUnlock(gtPvt.eventListLock);
195198
@@ -213,7 +216,8 @@
213 gtProvider *ptp = gtPvt.lastEventProvider;216 gtProvider *ptp = gtPvt.lastEventProvider;
214217
215 if (ptp == NULL ||218 if (ptp == NULL ||
216 ptp->getInt.Event == NULL) return epicsTimeERROR;219 ptp->getInt.Event == NULL)
220 return S_time_noProvider;
217221
218 return ptp->getInt.Event(pDest, eventNumber);222 return ptp->getInt.Event(pDest, eventNumber);
219 }223 }
@@ -271,11 +275,11 @@
271 generalTime_Init();275 generalTime_Init();
272276
273 if (name == NULL || getEvent == NULL)277 if (name == NULL || getEvent == NULL)
274 return epicsTimeERROR;278 return S_time_badArgs;
275279
276 ptp = (gtProvider *)malloc(sizeof(gtProvider));280 ptp = (gtProvider *)malloc(sizeof(gtProvider));
277 if (ptp == NULL)281 if (ptp == NULL)
278 return epicsTimeERROR;282 return S_time_noMemory;
279283
280 ptp->name = epicsStrDup(name);284 ptp->name = epicsStrDup(name);
281 ptp->priority = priority;285 ptp->priority = priority;
@@ -293,7 +297,7 @@
293 gtProvider *ptp = findProvider(&gtPvt.eventProviders, gtPvt.eventListLock,297 gtProvider *ptp = findProvider(&gtPvt.eventProviders, gtPvt.eventListLock,
294 name, priority);298 name, priority);
295 if (ptp == NULL)299 if (ptp == NULL)
296 return epicsTimeERROR;300 return S_time_noProvider;
297301
298 ptp->getInt.Event = getEvent;302 ptp->getInt.Event = getEvent;
299303
@@ -308,11 +312,11 @@
308 generalTime_Init();312 generalTime_Init();
309313
310 if (name == NULL || getTime == NULL)314 if (name == NULL || getTime == NULL)
311 return epicsTimeERROR;315 return S_time_badArgs;
312316
313 ptp = (gtProvider *)malloc(sizeof(gtProvider));317 ptp = (gtProvider *)malloc(sizeof(gtProvider));
314 if (ptp == NULL)318 if (ptp == NULL)
315 return epicsTimeERROR;319 return S_time_noMemory;
316320
317 ptp->name = epicsStrDup(name);321 ptp->name = epicsStrDup(name);
318 ptp->priority = priority;322 ptp->priority = priority;
@@ -330,7 +334,7 @@
330 gtProvider *ptp = findProvider(&gtPvt.timeProviders, gtPvt.timeListLock,334 gtProvider *ptp = findProvider(&gtPvt.timeProviders, gtPvt.timeListLock,
331 name, priority);335 name, priority);
332 if (ptp == NULL)336 if (ptp == NULL)
333 return epicsTimeERROR;337 return S_time_noProvider;
334338
335 ptp->getInt.Time = getTime;339 ptp->getInt.Time = getTime;
336340
@@ -388,7 +392,7 @@
388 if (!message) {392 if (!message) {
389 epicsMutexUnlock(gtPvt.timeListLock);393 epicsMutexUnlock(gtPvt.timeListLock);
390 printf("Out of memory\n");394 printf("Out of memory\n");
391 return epicsTimeERROR;395 return S_time_noMemory;
392 }396 }
393397
394 pout = message;398 pout = message;
@@ -399,7 +403,7 @@
399 ptp->name, ptp->priority);403 ptp->name, ptp->priority);
400 if (level) {404 if (level) {
401 epicsTimeStamp tempTS;405 epicsTimeStamp tempTS;
402 if (ptp->get.Time(&tempTS) != epicsTimeERROR) {406 if (ptp->get.Time(&tempTS) == epicsTimeOK) {
403 char tempTSText[40];407 char tempTSText[40];
404 epicsTimeToStrftime(tempTSText, sizeof(tempTSText),408 epicsTimeToStrftime(tempTSText, sizeof(tempTSText),
405 "%Y-%m-%d %H:%M:%S.%06f", &tempTS);409 "%Y-%m-%d %H:%M:%S.%06f", &tempTS);
@@ -430,7 +434,7 @@
430 if (!message) {434 if (!message) {
431 epicsMutexUnlock(gtPvt.eventListLock);435 epicsMutexUnlock(gtPvt.eventListLock);
432 printf("Out of memory\n");436 printf("Out of memory\n");
433 return epicsTimeERROR;437 return S_time_noMemory;
434 }438 }
435439
436 pout = message;440 pout = message;
437441
=== modified file 'src/libCom/osi/epicsTime.cpp'
--- src/libCom/osi/epicsTime.cpp 2014-08-25 21:27:18 +0000
+++ src/libCom/osi/epicsTime.cpp 2015-06-03 05:15:51 +0000
@@ -284,7 +284,7 @@
284 local_tm_nano_sec tm;284 local_tm_nano_sec tm;
285285
286 int status = epicsTime_localtime ( &ansiTimeTicks.ts, &tm.ansi_tm );286 int status = epicsTime_localtime ( &ansiTimeTicks.ts, &tm.ansi_tm );
287 if ( status != epicsTimeOK ) {287 if ( status ) {
288 throw std::logic_error ( "epicsTime_localtime failed" );288 throw std::logic_error ( "epicsTime_localtime failed" );
289 }289 }
290290
@@ -303,7 +303,7 @@
303 gm_tm_nano_sec tm;303 gm_tm_nano_sec tm;
304304
305 int status = epicsTime_gmtime ( &ansiTimeTicks.ts, &tm.ansi_tm );305 int status = epicsTime_gmtime ( &ansiTimeTicks.ts, &tm.ansi_tm );
306 if ( status != epicsTimeOK ) {306 if ( status ) {
307 throw std::logic_error ( "epicsTime_gmtime failed" );307 throw std::logic_error ( "epicsTime_gmtime failed" );
308 }308 }
309309
@@ -891,7 +891,7 @@
891 *pDest = dst.ts;891 *pDest = dst.ts;
892 }892 }
893 catch (...) {893 catch (...) {
894 return epicsTimeERROR;894 return S_time_conversion;
895 }895 }
896 return epicsTimeOK;896 return epicsTimeOK;
897 }897 }
@@ -903,7 +903,7 @@
903 *pDest = epicsTime ( dst );903 *pDest = epicsTime ( dst );
904 }904 }
905 catch (...) {905 catch (...) {
906 return epicsTimeERROR;906 return S_time_conversion;
907 }907 }
908 return epicsTimeOK;908 return epicsTimeOK;
909 }909 }
@@ -915,7 +915,7 @@
915 *pNSecDest = tmns.nSec;915 *pNSecDest = tmns.nSec;
916 }916 }
917 catch (...) {917 catch (...) {
918 return epicsTimeERROR;918 return S_time_conversion;
919 }919 }
920 return epicsTimeOK;920 return epicsTimeOK;
921 }921 }
@@ -927,7 +927,7 @@
927 *pNSecDest = gmtmns.nSec;927 *pNSecDest = gmtmns.nSec;
928 }928 }
929 catch (...) {929 catch (...) {
930 return epicsTimeERROR;930 return S_time_conversion;
931 }931 }
932 return epicsTimeOK;932 return epicsTimeOK;
933 }933 }
@@ -940,7 +940,7 @@
940 *pDest = epicsTime (tmns);940 *pDest = epicsTime (tmns);
941 }941 }
942 catch (...) {942 catch (...) {
943 return epicsTimeERROR;943 return S_time_conversion;
944 }944 }
945 return epicsTimeOK;945 return epicsTimeOK;
946 }946 }
@@ -950,7 +950,7 @@
950 *pDest = epicsTime (*pSrc);950 *pDest = epicsTime (*pSrc);
951 }951 }
952 catch (...) {952 catch (...) {
953 return epicsTimeERROR;953 return S_time_conversion;
954 }954 }
955 return epicsTimeOK;955 return epicsTimeOK;
956 }956 }
@@ -960,7 +960,7 @@
960 *pDest = epicsTime (*pSrc);960 *pDest = epicsTime (*pSrc);
961 }961 }
962 catch (...) {962 catch (...) {
963 return epicsTimeERROR;963 return S_time_conversion;
964 }964 }
965 return epicsTimeOK;965 return epicsTimeOK;
966 }966 }
@@ -970,7 +970,7 @@
970 *pDest = epicsTime (*pSrc);970 *pDest = epicsTime (*pSrc);
971 }971 }
972 catch (...) {972 catch (...) {
973 return epicsTimeERROR;973 return S_time_conversion;
974 }974 }
975 return epicsTimeOK;975 return epicsTimeOK;
976 }976 }
@@ -980,7 +980,7 @@
980 *pDest = epicsTime (*pSrc);980 *pDest = epicsTime (*pSrc);
981 }981 }
982 catch (...) {982 catch (...) {
983 return epicsTimeERROR;983 return S_time_conversion;
984 }984 }
985 return epicsTimeOK;985 return epicsTimeOK;
986 }986 }
987987
=== modified file 'src/libCom/osi/epicsTime.h'
--- src/libCom/osi/epicsTime.h 2014-08-19 03:55:07 +0000
+++ src/libCom/osi/epicsTime.h 2015-06-03 05:15:51 +0000
@@ -17,6 +17,7 @@
17#include "shareLib.h"17#include "shareLib.h"
18#include "epicsTypes.h"18#include "epicsTypes.h"
19#include "osdTime.h"19#include "osdTime.h"
20#include "errMdef.h"
2021
21/* The EPICS Epoch is 00:00:00 Jan 1, 1990 UTC */22/* The EPICS Epoch is 00:00:00 Jan 1, 1990 UTC */
22#define POSIX_TIME_AT_EPICS_EPOCH 631152000u23#define POSIX_TIME_AT_EPICS_EPOCH 631152000u
@@ -170,9 +171,15 @@
170extern "C" {171extern "C" {
171#endif /* __cplusplus */172#endif /* __cplusplus */
172173
173/* All epicsTime routines return (-1,0) for (failure,success) */174/* epicsTime routines return S_time_ error status values */
174#define epicsTimeOK 0175#define epicsTimeOK 0
175#define epicsTimeERROR (-1)176#define S_time_noProvider (M_time| 1) /*No time provider*/
177#define S_time_badEvent (M_time| 2) /*Bad event number*/
178#define S_time_badArgs (M_time| 3) /*Invalid arguments*/
179#define S_time_noMemory (M_time| 4) /*Out of memory*/
180#define S_time_unsynchronized (M_time| 5) /*Provider not synchronized*/
181#define S_time_timezone (M_time| 6) /*Invalid timeone*/
182#define S_time_conversion (M_time| 7) /*Time conversion error*/
176183
177/*Some special values for eventNumber*/184/*Some special values for eventNumber*/
178#define epicsTimeEventCurrentTime 0185#define epicsTimeEventCurrentTime 0
179186
=== modified file 'src/libCom/osi/os/Darwin/osdTime.cpp'
--- src/libCom/osi/os/Darwin/osdTime.cpp 2013-03-13 19:48:34 +0000
+++ src/libCom/osi/os/Darwin/osdTime.cpp 2015-06-03 05:15:51 +0000
@@ -11,6 +11,7 @@
11#include <stdlib.h>11#include <stdlib.h>
12#include <stdio.h>12#include <stdio.h>
13#include <string.h>13#include <string.h>
14#include <errno.h>
14#include <mach/mach.h>15#include <mach/mach.h>
15#include <mach/clock.h>16#include <mach/clock.h>
1617
@@ -52,13 +53,13 @@
52int epicsTime_gmtime(const time_t *pAnsiTime, struct tm *pTM)53int epicsTime_gmtime(const time_t *pAnsiTime, struct tm *pTM)
53{54{
54 return gmtime_r(pAnsiTime, pTM) ?55 return gmtime_r(pAnsiTime, pTM) ?
55 epicsTimeOK : epicsTimeERROR;56 epicsTimeOK : errno;
56}57}
5758
58int epicsTime_localtime(const time_t *clock, struct tm *result)59int epicsTime_localtime(const time_t *clock, struct tm *result)
59{60{
60 return localtime_r(clock, result) ?61 return localtime_r(clock, result) ?
61 epicsTimeOK : epicsTimeERROR;62 epicsTimeOK : errno;
62}63}
6364
64extern "C" epicsShareFunc void65extern "C" epicsShareFunc void
6566
=== modified file 'src/libCom/osi/os/RTEMS/osdTime.cpp'
--- src/libCom/osi/os/RTEMS/osdTime.cpp 2011-08-23 18:20:00 +0000
+++ src/libCom/osi/os/RTEMS/osdTime.cpp 2015-06-03 05:15:51 +0000
@@ -91,7 +91,7 @@
91 return epicsTimeOK;91 return epicsTimeOK;
92 }92 }
93 else {93 else {
94 return epicsTimeERROR;94 return errno;
95 }95 }
96}96}
9797
@@ -102,7 +102,7 @@
102 return epicsTimeOK;102 return epicsTimeOK;
103 }103 }
104 else {104 else {
105 return epicsTimeERROR;105 return errno;
106 }106 }
107}107}
108108
109109
=== modified file 'src/libCom/osi/os/WIN32/osdTime.cpp'
--- src/libCom/osi/os/WIN32/osdTime.cpp 2015-03-13 16:50:26 +0000
+++ src/libCom/osi/os/WIN32/osdTime.cpp 2015-06-03 05:15:51 +0000
@@ -164,7 +164,7 @@
164 SYSTEMTIME st;164 SYSTEMTIME st;
165 BOOL status = FileTimeToSystemTime ( &ft, &st );165 BOOL status = FileTimeToSystemTime ( &ft, &st );
166 if ( ! status ) {166 if ( ! status ) {
167 return epicsTimeERROR;167 return S_time_conversion;
168 }168 }
169169
170 pTM->tm_sec = st.wSecond; // seconds after the minute - [0,59]170 pTM->tm_sec = st.wSecond; // seconds after the minute - [0,59]
@@ -193,7 +193,7 @@
193 TIME_ZONE_INFORMATION tzInfo;193 TIME_ZONE_INFORMATION tzInfo;
194 DWORD tzStatus = GetTimeZoneInformation ( & tzInfo );194 DWORD tzStatus = GetTimeZoneInformation ( & tzInfo );
195 if ( tzStatus == TIME_ZONE_ID_INVALID ) {195 if ( tzStatus == TIME_ZONE_ID_INVALID ) {
196 return epicsTimeERROR;196 return S_time_timezone;
197 }197 }
198198
199 //199 //
@@ -204,13 +204,13 @@
204 SYSTEMTIME st;204 SYSTEMTIME st;
205 BOOL success = FileTimeToSystemTime ( & ft, & st );205 BOOL success = FileTimeToSystemTime ( & ft, & st );
206 if ( ! success ) {206 if ( ! success ) {
207 return epicsTimeERROR;207 return S_time_conversion;
208 }208 }
209 SYSTEMTIME lst;209 SYSTEMTIME lst;
210 success = SystemTimeToTzSpecificLocalTime (210 success = SystemTimeToTzSpecificLocalTime (
211 & tzInfo, & st, & lst );211 & tzInfo, & st, & lst );
212 if ( ! success ) {212 if ( ! success ) {
213 return epicsTimeERROR;213 return S_time_conversion;
214 }214 }
215215
216 //216 //
@@ -220,7 +220,7 @@
220 FILETIME lft;220 FILETIME lft;
221 success = SystemTimeToFileTime ( & lst, & lft );221 success = SystemTimeToFileTime ( & lst, & lft );
222 if ( ! success ) {222 if ( ! success ) {
223 return epicsTimeERROR;223 return S_time_conversion;
224 }224 }
225225
226 int is_dst = -1; // unknown state of dst226 int is_dst = -1; // unknown state of dst
@@ -234,14 +234,14 @@
234 success = SystemTimeToFileTime (234 success = SystemTimeToFileTime (
235 & tzInfo.StandardDate, & StandardDateFT );235 & tzInfo.StandardDate, & StandardDateFT );
236 if ( ! success ) {236 if ( ! success ) {
237 return epicsTimeERROR;237 return S_time_conversion;
238 }238 }
239 tzInfo.DaylightDate.wYear = st.wYear;239 tzInfo.DaylightDate.wYear = st.wYear;
240 FILETIME DaylightDateFT;240 FILETIME DaylightDateFT;
241 success = SystemTimeToFileTime (241 success = SystemTimeToFileTime (
242 & tzInfo.DaylightDate, & DaylightDateFT );242 & tzInfo.DaylightDate, & DaylightDateFT );
243 if ( ! success ) {243 if ( ! success ) {
244 return epicsTimeERROR;244 return S_time_conversion;
245 }245 }
246 if ( CompareFileTime ( & lft, & DaylightDateFT ) >= 0246 if ( CompareFileTime ( & lft, & DaylightDateFT ) >= 0
247 && CompareFileTime ( & lft, & StandardDateFT ) < 0 ) {247 && CompareFileTime ( & lft, & StandardDateFT ) < 0 ) {
248248
=== modified file 'src/libCom/osi/os/posix/osdTime.cpp'
--- src/libCom/osi/os/posix/osdTime.cpp 2013-03-15 20:23:55 +0000
+++ src/libCom/osi/os/posix/osdTime.cpp 2015-06-03 05:15:51 +0000
@@ -11,6 +11,7 @@
11#include <stdlib.h>11#include <stdlib.h>
12#include <stdio.h>12#include <stdio.h>
13#include <string.h>13#include <string.h>
14#include <errno.h>
1415
15#include "osiSock.h"16#include "osiSock.h"
1617
@@ -36,7 +37,7 @@
36 struct timezone tz;37 struct timezone tz;
3738
38 if (gettimeofday (&tv, &tz))39 if (gettimeofday (&tv, &tz))
39 return epicsTimeERROR;40 return errno;
4041
41 *pDest = epicsTime(tv);42 *pDest = epicsTime(tv);
42 return epicsTimeOK;43 return epicsTimeOK;
@@ -68,7 +69,7 @@
68 return epicsTimeOK;69 return epicsTimeOK;
69 }70 }
70 else {71 else {
71 return epicsTimeERROR;72 return errno;
72 }73 }
73}74}
7475
@@ -80,7 +81,7 @@
80 return epicsTimeOK;81 return epicsTimeOK;
81 }82 }
82 else {83 else {
83 return epicsTimeERROR;84 return errno;
84 }85 }
85}86}
8687
8788
=== modified file 'src/libCom/osi/osiNTPTime.c'
--- src/libCom/osi/osiNTPTime.c 2014-08-25 21:27:18 +0000
+++ src/libCom/osi/osiNTPTime.c 2015-06-03 05:15:51 +0000
@@ -164,7 +164,7 @@
164 }164 }
165165
166 if (timespecNow.tv_sec <= POSIX_TIME_AT_EPICS_EPOCH ||166 if (timespecNow.tv_sec <= POSIX_TIME_AT_EPICS_EPOCH ||
167 epicsTimeFromTimespec(&timeNow, &timespecNow) == epicsTimeERROR) {167 epicsTimeFromTimespec(&timeNow, &timespecNow) != epicsTimeOK) {
168 errlogPrintf("NTPTimeSync: Bad time received from NTP server\n");168 errlogPrintf("NTPTimeSync: Bad time received from NTP server\n");
169 NTPTimePvt.synchronized = 0;169 NTPTimePvt.synchronized = 0;
170 continue;170 continue;
@@ -213,7 +213,7 @@
213 epicsUInt32 ticksSince;213 epicsUInt32 ticksSince;
214214
215 if (!NTPTimePvt.synchronized)215 if (!NTPTimePvt.synchronized)
216 return epicsTimeERROR;216 return S_time_unsynchronized;
217217
218 epicsMutexMustLock(NTPTimePvt.lock);218 epicsMutexMustLock(NTPTimePvt.lock);
219219
220220
=== modified file 'src/std/dev/devGeneralTime.c'
--- src/std/dev/devGeneralTime.c 2013-12-17 18:54:04 +0000
+++ src/std/dev/devGeneralTime.c 2015-06-03 05:15:51 +0000
@@ -37,7 +37,7 @@
37{37{
38 epicsTimeStamp ts;38 epicsTimeStamp ts;
3939
40 if (epicsTimeERROR != epicsTimeGetCurrent(&ts)) {40 if (epicsTimeOK == epicsTimeGetCurrent(&ts)) {
41 *pseconds = ts.secPastEpoch + ((double)(ts.nsec)) * 1e-9;41 *pseconds = ts.secPastEpoch + ((double)(ts.nsec)) * 1e-9;
42 return 0;42 return 0;
43 }43 }

Subscribers

People subscribed via source and target branches