From 146eb58120d75743f912d0f8d7472e0087613cc5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 17 Nov 2004 19:58:09 +0000 Subject: [PATCH] Revive the canary, and add a test routine that checks whether the optimizer bug is still present. Tornado 2.x compilers for 68K need -O0 to work. --- src/libCom/osi/os/vxWorks/osdThread.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libCom/osi/os/vxWorks/osdThread.c b/src/libCom/osi/os/vxWorks/osdThread.c index 92ff88c2f..1b2984a59 100644 --- a/src/libCom/osi/os/vxWorks/osdThread.c +++ b/src/libCom/osi/os/vxWorks/osdThread.c @@ -358,10 +358,21 @@ void *epicsThreadPrivateGet(epicsThreadPrivateId id) return(data); } +/* Tornado compilers for 68k have an optimizer bug at -O1 and above; the + * code generated for epicsThreadSleepQuantum() is incorrect. This routine + * tests for that bug. This routine must appear above the code it calls or + * or the optimizer may inline epicsThreadSleepQuantum() */ +int vxWorksBrokenCompilerTest() +{ + double q = epicsThreadSleepQuantum(); + double one = q * sysClkRateGet(); + int ok = (one > 0.999) && (one < 1.001); + printf("%s: epicsThreadSleepQuantum() = %f\n", ok ? "Ok" : "BROKEN", q); + return ok; +} + double epicsThreadSleepQuantum () { - /* If HZ is a double, under -O3 optimization the Tornado 2.x - * compilers generate bad code. Using a float works. */ - float HZ = sysClkRateGet(); + double HZ = sysClkRateGet (); return 1.0 / HZ; }