From c5012d9f73b80bb55ddba2a8785d5c5841e268ec Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Fri, 17 Dec 2021 09:16:31 +0100 Subject: [PATCH] Make sure epicsInt8 is signed on all architectures --- documentation/RELEASE_NOTES.md | 11 +++++++++++ modules/ca/src/client/comBuf.h | 6 ++++++ modules/ca/src/client/comQueRecv.cpp | 2 +- modules/ca/src/client/comQueRecv.h | 2 +- modules/libcom/src/misc/epicsTypes.h | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index fb925c716..c9f1c69b6 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -16,6 +16,17 @@ should also be read to understand what has changed since earlier releases. +### Make sure epicsInt8 is signed on all architectures + +So far, `epicsInt8` and thus `DBF_CHAR` used to be unsigned on architectures +where `char` is unsigned, for example on many PPC architectures. +This had led to different behavior between architectures when converting +`DBF_CHAR` to signed integer or to floating point types. + +WARNING: This fix may change behavior of existing databases on on architectures +with unsigned `char` (many PPC) when using input links to read from `CHAR` +waveforms. Architectures with signed `char` (usually x86) are unaffected. + ### Fix for `undefined` in configure/RELEASE files Prevents `Use of uninitialized value` warnings from convertRelease.pl. diff --git a/modules/ca/src/client/comBuf.h b/modules/ca/src/client/comBuf.h index 6a4899414..3d5f58c45 100644 --- a/modules/ca/src/client/comBuf.h +++ b/modules/ca/src/client/comBuf.h @@ -88,6 +88,7 @@ public: bool push ( const T & value ); template < class T > unsigned push ( const T * pValue, unsigned nElem ); + unsigned push ( const char * pValue, unsigned nElem ); unsigned push ( const epicsInt8 * pValue, unsigned nElem ); unsigned push ( const epicsUInt8 * pValue, unsigned nElem ); unsigned push ( const epicsOldString * pValue, unsigned nElem ); @@ -208,6 +209,11 @@ inline unsigned comBuf :: push ( const epicsUInt8 *pValue, unsigned nElem ) return copyInBytes ( pValue, nElem ); } +inline unsigned comBuf :: push ( const char *pValue, unsigned nElem ) +{ + return copyInBytes ( pValue, nElem ); +} + inline unsigned comBuf :: push ( const epicsOldString * pValue, unsigned nElem ) { unsigned index = this->nextWriteIndex; diff --git a/modules/ca/src/client/comQueRecv.cpp b/modules/ca/src/client/comQueRecv.cpp index 60e142a35..d7d07361b 100644 --- a/modules/ca/src/client/comQueRecv.cpp +++ b/modules/ca/src/client/comQueRecv.cpp @@ -46,7 +46,7 @@ void comQueRecv::clear () this->nBytesPending = 0u; } -unsigned comQueRecv::copyOutBytes ( epicsInt8 *pBuf, unsigned nBytes ) +unsigned comQueRecv::copyOutBytes ( char *pBuf, unsigned nBytes ) { unsigned totalBytes = 0u; do { diff --git a/modules/ca/src/client/comQueRecv.h b/modules/ca/src/client/comQueRecv.h index ad8bead88..01c961e51 100644 --- a/modules/ca/src/client/comQueRecv.h +++ b/modules/ca/src/client/comQueRecv.h @@ -33,7 +33,7 @@ public: comQueRecv ( comBufMemoryManager & ); ~comQueRecv (); unsigned occupiedBytes () const; - unsigned copyOutBytes ( epicsInt8 *pBuf, unsigned nBytes ); + unsigned copyOutBytes ( char *pBuf, unsigned nBytes ); unsigned removeBytes ( unsigned nBytes ); void pushLastComBufReceived ( comBuf & ); void clear (); diff --git a/modules/libcom/src/misc/epicsTypes.h b/modules/libcom/src/misc/epicsTypes.h index 432c8961c..5efd69464 100644 --- a/modules/libcom/src/misc/epicsTypes.h +++ b/modules/libcom/src/misc/epicsTypes.h @@ -41,7 +41,7 @@ typedef enum { * These are sufficient for all our current archs * @{ */ -typedef char epicsInt8; +typedef signed char epicsInt8; typedef unsigned char epicsUInt8; typedef short epicsInt16; typedef unsigned short epicsUInt16;