From 2b65025d93bde3a5b61eb0cc66a61ab4440cd977 Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Tue, 23 Aug 2011 13:20:00 -0500 Subject: [PATCH] RTEMS: Time registration when dynamically loading The old test for discriminating between statically and dynamically linked applications (os/RTEMS/osdTime.cpp:staticTimeRegister()) is wrong, it never detects a dynamically loaded app. fixes lp:831648 -------------- This line and the following will be ignored -------------- modified: src/libCom/osi/os/RTEMS/osdTime.cpp --- src/libCom/osi/os/RTEMS/osdTime.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libCom/osi/os/RTEMS/osdTime.cpp b/src/libCom/osi/os/RTEMS/osdTime.cpp index b7ff6ee08..acefa1b09 100644 --- a/src/libCom/osi/os/RTEMS/osdTime.cpp +++ b/src/libCom/osi/os/RTEMS/osdTime.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "epicsTime.h" #include "osdTime.h" #include "osiNTPTime.h" @@ -117,17 +118,21 @@ double rtemsTicksPerSecond_double, rtemsTicksPerTwoSeconds_double; * explicitly calls osdTimeRegister() at the appropriate time. * However if we are loaded dynamically we *do* register our * standard time providers at static constructor time; in this - * case the tick rate will have been set already. + * case the network is available already. */ static int staticTimeRegister(void) { - if (rtemsTicksPerSecond != 0) - osdTimeRegister(); - rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &rtemsTicksPerSecond); rtemsTicksPerSecond_double = rtemsTicksPerSecond; rtemsTicksPerTwoSeconds_double = rtemsTicksPerSecond_double * 2.0; + /* If networking is already up at the time static constructors + * are executed then we are probably run-time loaded and it's + * OK to osdTimeRegister() at this point. + */ + if (rtems_bsdnet_ticks_per_second != 0) + osdTimeRegister(); + return 1; } static int done = staticTimeRegister();