diff --git a/src/factory/printer.cpp b/src/factory/printer.cpp index c68c860..70e81c7 100644 --- a/src/factory/printer.cpp +++ b/src/factory/printer.cpp @@ -19,9 +19,7 @@ #define epicsExportSharedSymbols #include #include -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) -# include -#endif +#include namespace epics { namespace pvData { @@ -404,15 +402,11 @@ void printRaw(std::ostream& strm, const PVStructure::Formatter& format, const PV std::ostream& operator<<(std::ostream& strm, const PVStructure::Formatter& format) { if(format.xfmt==PVStructure::Formatter::JSON) { -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) JSONPrintOptions opts; opts.multiLine = false; printJSON(strm, format.xtop, format.xshow ? *format.xshow : BitSet().set(0), opts); strm<<'\n'; return strm; -#else - // fall through to Raw -#endif } else if(format.xfmt==PVStructure::Formatter::NT) { std::string id(format.xtop.getStructure()->getID()), diff --git a/src/json/parseany.cpp b/src/json/parseany.cpp index 7d1a2f6..e860da3 100644 --- a/src/json/parseany.cpp +++ b/src/json/parseany.cpp @@ -10,8 +10,6 @@ #include #include -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) - #include "pv/json.h" namespace pvd = epics::pvData; @@ -280,5 +278,3 @@ parseJSON(std::istream& strm) } }} // namespace epics::pvData - -#endif // EPICS_VERSION_INT diff --git a/src/json/parsehelper.cpp b/src/json/parsehelper.cpp index bd53db0..9cc44c3 100644 --- a/src/json/parsehelper.cpp +++ b/src/json/parsehelper.cpp @@ -9,8 +9,6 @@ #define epicsExportSharedSymbols #include -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) - #include "pv/json.h" namespace { @@ -118,5 +116,3 @@ bool yajl_parse_helper(std::istream& src, } }} // namespace epics::pvData - -#endif // EPICS_VERSION_INT diff --git a/src/json/parseinto.cpp b/src/json/parseinto.cpp index 587f095..601fa4c 100644 --- a/src/json/parseinto.cpp +++ b/src/json/parseinto.cpp @@ -11,9 +11,6 @@ #include #include #include - -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) - #include "pv/json.h" namespace pvd = epics::pvData; @@ -347,6 +344,3 @@ void parseJSON(std::istream& strm, } }} // namespace epics::pvData - -#endif // EPICS_VERSION_INT - diff --git a/src/json/print.cpp b/src/json/print.cpp index 60707d2..f747cdf 100644 --- a/src/json/print.cpp +++ b/src/json/print.cpp @@ -11,9 +11,6 @@ #include #include #include - -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) - #include "pv/json.h" namespace pvd = epics::pvData; @@ -232,5 +229,3 @@ void printJSON(std::ostream& strm, } }} // namespace epics::pvData - -#endif // EPICS_VERSION_INT diff --git a/src/json/pv/json.h b/src/json/pv/json.h index 66d09c5..63fbdf5 100644 --- a/src/json/pv/json.h +++ b/src/json/pv/json.h @@ -13,8 +13,6 @@ #include #include -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) - #ifdef epicsExportSharedSymbols # define pvjson_epicsExportSharedSymbols # undef epicsExportSharedSymbols @@ -147,8 +145,4 @@ typedef size_t size_arg; }} // namespace epics::pvData -#else -# error JSON parser requires EPICS Base >= 3.15.0.1 -#endif // EPICS_VERSION_INT - #endif // PV_JSON_H diff --git a/src/misc/parseToPOD.cpp b/src/misc/parseToPOD.cpp index 2691d48..ea4716e 100644 --- a/src/misc/parseToPOD.cpp +++ b/src/misc/parseToPOD.cpp @@ -25,406 +25,6 @@ using std::string; #define NEED_LONGLONG #endif -#ifndef EPICS_VERSION_INT -#define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#define EPICS_VERSION_INT VERSION_INT(EPICS_VERSION, EPICS_REVISION, EPICS_MODIFICATION, EPICS_PATCH_LEVEL) -#endif - -#if EPICS_VERSION_INT < VERSION_INT(3,15,0,1) -/* These integer conversion primitives added to epicsStdlib.c in 3.15.0.1 */ - -#define S_stdlib_noConversion 1 /* No digits to convert */ -#define S_stdlib_extraneous 2 /* Extraneous characters */ -#define S_stdlib_underflow 3 /* Too small to represent */ -#define S_stdlib_overflow 4 /* Too large to represent */ -#define S_stdlib_badBase 5 /* Number base not supported */ - -static int -epicsParseLong(const char *str, long *to, int base, char **units) -{ - int c; - char *endp; - long value; - - while ((c = *str) && isspace(c)) - ++str; - - errno = 0; - value = strtol(str, &endp, base); - - if (endp == str) - return S_stdlib_noConversion; - if (errno == EINVAL) /* Not universally supported */ - return S_stdlib_badBase; - if (errno == ERANGE) - return S_stdlib_overflow; - - while ((c = *endp) && isspace(c)) - ++endp; - if (c && !units) - return S_stdlib_extraneous; - - *to = value; - if (units) - *units = endp; - return 0; -} - -static int -epicsParseULong(const char *str, unsigned long *to, int base, char **units) -{ - int c; - char *endp; - unsigned long value; - - while ((c = *str) && isspace(c)) - ++str; - - errno = 0; - value = strtoul(str, &endp, base); - - if (endp == str) - return S_stdlib_noConversion; - if (errno == EINVAL) /* Not universally supported */ - return S_stdlib_badBase; - if (errno == ERANGE) - return S_stdlib_overflow; - - while ((c = *endp) && isspace(c)) - ++endp; - if (c && !units) - return S_stdlib_extraneous; - - *to = value; - if (units) - *units = endp; - return 0; -} - -static int -epicsParseDouble(const char *str, double *to, char **units) -{ - int c; - char *endp; - double value; - - while ((c = *str) && isspace(c)) - ++str; - - errno = 0; - value = epicsStrtod(str, &endp); - - if (endp == str) - return S_stdlib_noConversion; - if (errno == ERANGE) - return (value == 0) ? S_stdlib_underflow : S_stdlib_overflow; - - while ((c = *endp) && isspace(c)) - ++endp; - if (c && !units) - return S_stdlib_extraneous; - - *to = value; - if (units) - *units = endp; - return 0; -} - - -/* These call the primitives */ - -static int -epicsParseInt8(const char *str, epicsInt8 *to, int base, char **units) -{ - long value; - int status = epicsParseLong(str, &value, base, units); - - if (status) - return status; - - if (value < -0x80 || value > 0x7f) - return S_stdlib_overflow; - - *to = (epicsInt8)value; - return 0; -} - -static int -epicsParseUInt8(const char *str, epicsUInt8 *to, int base, char **units) -{ - unsigned long value; - int status = epicsParseULong(str, &value, base, units); - - if (status) - return status; - - if (value > 0xff && value <= ~0xffUL) - return S_stdlib_overflow; - - *to = (epicsUInt8)value; - return 0; -} - -static int -epicsParseInt16(const char *str, epicsInt16 *to, int base, char **units) -{ - long value; - int status = epicsParseLong(str, &value, base, units); - - if (status) - return status; - - if (value < -0x8000 || value > 0x7fff) - return S_stdlib_overflow; - - *to = (epicsInt16)value; - return 0; -} - -static int -epicsParseUInt16(const char *str, epicsUInt16 *to, int base, char **units) -{ - unsigned long value; - int status = epicsParseULong(str, &value, base, units); - - if (status) - return status; - - if (value > 0xffff && value <= ~0xffffUL) - return S_stdlib_overflow; - - *to = (epicsUInt16)value; - return 0; -} - -static int -epicsParseInt32(const char *str, epicsInt32 *to, int base, char **units) -{ - long value; - int status = epicsParseLong(str, &value, base, units); - - if (status) - return status; - -#if (LONG_MAX > 0x7fffffff) - if (value < -0x80000000L || value > 0x7fffffffL) - return S_stdlib_overflow; -#endif - - *to = (epicsInt32)value; - return 0; -} - -static int -epicsParseUInt32(const char *str, epicsUInt32 *to, int base, char **units) -{ - unsigned long value; - int status = epicsParseULong(str, &value, base, units); - - if (status) - return status; - -#if (ULONG_MAX > 0xffffffff) - if (value > 0xffffffffUL && value <= ~0xffffffffUL) - return S_stdlib_overflow; -#endif - - *to = (epicsUInt32)value; - return 0; -} - -static int -epicsParseFloat(const char *str, float *to, char **units) -{ - double value, abs; - int status = epicsParseDouble(str, &value, units); - - if (status) - return status; - - abs = fabs(value); - if (value > 0 && abs <= FLT_MIN) - return S_stdlib_underflow; - if (finite(value) && abs >= FLT_MAX) - return S_stdlib_overflow; - - *to = (float)value; - return 0; -} -#endif - -// Sometimes we have to provide our own copy of strtoll() -#if defined(_MSC_VER) && _MSC_VER < 1800 -// On Windows with MSVC, Base-3.15 provides strtoll() -# define NEED_OLL_FUNCS (EPICS_VERSION_INT < VERSION_INT(3,15,0,1)) -#elif defined(vxWorks) -// On VxWorks, Base-3.15 provides strtoll() -# define NEED_OLL_FUNCS (EPICS_VERSION_INT < VERSION_INT(3,15,0,1)) -#else -// Other architectures all provide strtoll() -# define NEED_OLL_FUNCS 0 -#endif - -#if defined(NEED_LONGLONG) && NEED_OLL_FUNCS -static -long long strtoll(const char *ptr, char ** endp, int base) -{ - size_t inlen = strlen(ptr); - long long result; - unsigned char offset=0; - - assert(base==0); - - if(ptr[0]=='-') - offset=1; - - try { - std::istringstream strm(ptr); - - assert(strm.rdbuf()->in_avail()>=0 - && inlen==(size_t)strm.rdbuf()->in_avail()); - - if(ptr[offset]=='0') { - if(ptr[offset+1]=='x') - strm >> std::hex; - else - strm >> std::oct; - } - - strm >> result; - if(strm.fail()) - goto noconvert; - - assert(strm.rdbuf()->in_avail()>=0 - && inlen>=(size_t)strm.rdbuf()->in_avail()); - - size_t consumed = inlen - strm.rdbuf()->in_avail(); - *endp = (char*)ptr + consumed; - - return result; - - } catch(...) { - goto noconvert; - } - - return result; -noconvert: - *endp = (char*)ptr; - return 0; -} - -#if defined(vxWorks) -/* The VxWorks version of std::istringstream >> uint64_t is buggy, - * provide our own implementation - */ -static -unsigned long long strtoull(const char *nptr, char **endptr, int base) -{ - const char *s = nptr; - unsigned long long acc; - int c; - unsigned long long cutoff; - int neg = 0, any, cutlim; - - do - c = *s++; - while (isspace(c)); - if (c == '-') - { - neg = 1; - c = *s++; - } - else if (c == '+') - c = *s++; - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) - { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - cutoff = (unsigned long long) UINT64_MAX / (unsigned long long) base; - cutlim = (unsigned long long) UINT64_MAX % (unsigned long long) base; - - for (acc = 0, any = 0;; c = *s++) - { - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else - { - any = 1; - acc *= base; - acc += c; - } - } - if (any < 0) - { - acc = UINT64_MAX; - errno = ERANGE; - } - else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = any ? (char *) s - 1 : (char *) nptr; - return (acc); -} -#else -static -unsigned long long strtoull(const char *ptr, char ** endp, int base) -{ - size_t inlen = strlen(ptr); - unsigned long long result; - - assert(base==0); - - try { - std::istringstream strm(ptr); - - assert(strm.rdbuf()->in_avail()>=0 - && inlen==(size_t)strm.rdbuf()->in_avail()); - - if(ptr[0]=='0') { - if(ptr[1]=='x') - strm >> std::hex; - else - strm >> std::oct; - } - - strm >> result; - if(strm.fail()) - goto noconvert; - - assert(strm.rdbuf()->in_avail()>=0 - && inlen>=(size_t)strm.rdbuf()->in_avail()); - - size_t consumed = inlen - strm.rdbuf()->in_avail(); - *endp = (char*)ptr + consumed; - - return result; - - } catch(...) { - goto noconvert; - } - - return result; -noconvert: - *endp = (char*)ptr; - return 0; -} -#endif -#endif - /* do we need long long? */ #ifdef NEED_LONGLONG static int diff --git a/src/misc/pv/reftrack.h b/src/misc/pv/reftrack.h index f5dc558..3c7cb59 100644 --- a/src/misc/pv/reftrack.h +++ b/src/misc/pv/reftrack.h @@ -46,27 +46,10 @@ #include #include +#include -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif - -#ifndef EPICS_VERSION_INT -# define EPICS_VERSION_INT VERSION_INT(EPICS_VERSION, EPICS_REVISION, EPICS_MODIFICATION, EPICS_PATCH_LEVEL) -#endif - -#if EPICS_VERSION_INT>=VERSION_INT(3,15,1,0) -# include -# define REFTRACK_USE_ATOMIC -#endif - -#ifdef REFTRACK_USE_ATOMIC -# define REFTRACE_INCREMENT(counter) ::epics::atomic::increment(counter) -# define REFTRACE_DECREMENT(counter) ::epics::atomic::decrement(counter) -#else -# define REFTRACE_INCREMENT(counter) do{}while(0) -# define REFTRACE_DECREMENT(counter) do{}while(0) -#endif +#define REFTRACE_INCREMENT(counter) ::epics::atomic::increment(counter) +#define REFTRACE_DECREMENT(counter) ::epics::atomic::decrement(counter) #include diff --git a/src/misc/reftrack.cpp b/src/misc/reftrack.cpp index d13b386..18f3307 100644 --- a/src/misc/reftrack.cpp +++ b/src/misc/reftrack.cpp @@ -25,15 +25,6 @@ namespace { -#ifndef REFTRACK_USE_ATOMIC -static inline -size_t readref(const size_t *ref) -{ - volatile const size_t *vref = ref; - return *vref; -} -#endif - typedef epicsGuard Guard; typedef epicsGuardRelease UnGuard; @@ -88,11 +79,7 @@ size_t readRefCounter(const char *name) refgbl_t::counters_t::iterator it(refgbl->counters.find(name)); if(it==refgbl->counters.end()) return 0; -#ifdef REFTRACK_USE_ATOMIC return atomic::get(*it->second); -#else - return readref(it->second); -#endif } const RefSnapshot::Count& @@ -119,11 +106,7 @@ void RefSnapshot::update() end=counters.end(); it!=end; ++it) { -#ifdef REFTRACK_USE_ATOMIC size_t cnt = atomic::get(*it->second); -#else - size_t cnt = readref(it->second); -#endif counts[it->first] = Count(cnt, 0); } diff --git a/testApp/misc/testjson.cpp b/testApp/misc/testjson.cpp index f156a25..2928aa5 100644 --- a/testApp/misc/testjson.cpp +++ b/testApp/misc/testjson.cpp @@ -7,8 +7,6 @@ #include -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) - #include #include #include @@ -290,15 +288,3 @@ MAIN(testjson) } return testDone(); } - -#else // EPICS_VERSION_INT - -#include - -MAIN(testjson) -{ - testPlan(1); - testSkip(1, "JSON parser requires Base >=3.15.0.1"); - return testDone(); -} -#endif //EPICS_VERSION_INT diff --git a/testApp/misc/testprinter.cpp b/testApp/misc/testprinter.cpp index 095b4d6..c4c0c22 100644 --- a/testApp/misc/testprinter.cpp +++ b/testApp/misc/testprinter.cpp @@ -16,10 +16,6 @@ #include #include -#if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) -# define USE_JSON -#endif - namespace pvd = epics::pvData; typedef std::vector lines_t;