From ba6a096e866d2c8eda1f6f779d727f2258f0f13e Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 31 Jul 2001 21:35:26 +0000 Subject: [PATCH] a fix for use of posix isnan() function --- src/libCom/Makefile | 2 +- src/libCom/calc/sCalcPerform.c | 5 +++-- src/libCom/osi/os/WIN32/epicsMath.h | 9 +++++++++ src/libCom/osi/os/posix/epicsMath.h | 9 +++++++++ src/libCom/osi/os/vxWorks/epicsMath.h | 9 +++++++++ src/libCom/osi/os/vxWorks/isnan.c | 8 -------- 6 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 src/libCom/osi/os/WIN32/epicsMath.h create mode 100644 src/libCom/osi/os/posix/epicsMath.h create mode 100644 src/libCom/osi/os/vxWorks/epicsMath.h delete mode 100644 src/libCom/osi/os/vxWorks/isnan.c diff --git a/src/libCom/Makefile b/src/libCom/Makefile index 9b4ef882b..1e3edc70c 100644 --- a/src/libCom/Makefile +++ b/src/libCom/Makefile @@ -134,6 +134,7 @@ INC += epicsMutex.h INC += osdMutex.h INC += epicsEvent.h INC += osdEvent.h +INC += epicsMath.h INC += epicsAssert.h INC += epicsFindSymbol.h @@ -205,7 +206,6 @@ SRCS_RTEMS += rtems_util.c # For vxWorks a clock INC_vxWorks += iocClock.h SRCS_vxWorks += iocClock.c -SRCS_vxWorks += isnan.c # Library to build: # lib$(LIBRARY).a or ..dll/..exp/..lib diff --git a/src/libCom/calc/sCalcPerform.c b/src/libCom/calc/sCalcPerform.c index 56c39ae99..b7c53dbf6 100644 --- a/src/libCom/calc/sCalcPerform.c +++ b/src/libCom/calc/sCalcPerform.c @@ -66,6 +66,7 @@ #include "dbDefs.h" #define epicsExportSharedSymbols +#include "epicsMath.h" #include "cvtFast.h" #include "sCalcPostfix.h" #include "sCalcPostfixPvt.h" @@ -141,7 +142,7 @@ static void to_string(struct stackElement *ps) { ps->s = calloc(20, 1); /* any precision greater than 8 results in (slow) sprintf call */ - if (isnan(ps->d)) + if (epicsIsNAN(ps->d)) strcpy(ps->s,"NaN"); else (void)cvtDoubleToString(ps->d, ps->s, 8); @@ -636,7 +637,7 @@ printf(") \n"); #endif *presult = *pd; if (psresult && (lenSresult > 15)) { - if (isnan(*pd)) + if (epicsIsNAN(*pd)) strcpy(psresult,"NaN"); else (void)cvtDoubleToString(*pd, psresult, 8); diff --git a/src/libCom/osi/os/WIN32/epicsMath.h b/src/libCom/osi/os/WIN32/epicsMath.h new file mode 100644 index 000000000..f9c97dd42 --- /dev/null +++ b/src/libCom/osi/os/WIN32/epicsMath.h @@ -0,0 +1,9 @@ + +#ifndef epicsMathh +#define epicsMathh + +#include "float.h" + +#define epicsIsNAN(D) _isnan(D) + +#endif /* epicsMathh */ diff --git a/src/libCom/osi/os/posix/epicsMath.h b/src/libCom/osi/os/posix/epicsMath.h new file mode 100644 index 000000000..d8177e361 --- /dev/null +++ b/src/libCom/osi/os/posix/epicsMath.h @@ -0,0 +1,9 @@ + +#ifndef epicsMathh +#define epicsMathh + +#include "math.h" + +#define epicsIsNAN(D) isnan(D) + +#endif /* epicsMathh diff --git a/src/libCom/osi/os/vxWorks/epicsMath.h b/src/libCom/osi/os/vxWorks/epicsMath.h new file mode 100644 index 000000000..fa84e53de --- /dev/null +++ b/src/libCom/osi/os/vxWorks/epicsMath.h @@ -0,0 +1,9 @@ + +#ifndef epicsMathh +#define epicsMathh + +#include + +#define epicsIsNAN(D) isNan(D) + +#endif /* epicsMathh */ diff --git a/src/libCom/osi/os/vxWorks/isnan.c b/src/libCom/osi/os/vxWorks/isnan.c deleted file mode 100644 index 56f049181..000000000 --- a/src/libCom/osi/os/vxWorks/isnan.c +++ /dev/null @@ -1,8 +0,0 @@ -int isnan(double d) -{ - union { long l[2]; double d; } u; - u.d = d; - if ((u.l[0] & 0x7ff00000) != 0x7ff00000) return(0); - if (u.l[1] || (u.l[0] & 0x000fffff)) return(1); - return(0); -}