From 87018882d1e02f609aa7c61f193b02af428adcfc Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 24 May 2023 20:44:30 -0700 Subject: [PATCH 01/10] ARM/Linux can fault on unaligned access Sometimes SIGBUS results from unaligned access. --- src/misc/pv/byteBuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/pv/byteBuffer.h b/src/misc/pv/byteBuffer.h index e507f15..4a71c8a 100644 --- a/src/misc/pv/byteBuffer.h +++ b/src/misc/pv/byteBuffer.h @@ -157,7 +157,7 @@ struct swap<8> { * in execution time and/or object code size of byte-wise copy. */ -#ifdef _ARCH_PPC +#if defined(_ARCH_PPC) || defined(__arm__) || defined(_M_ARM) template union alignu { From c16f19c80e714e37462e4ada9fa6f263d88adcd0 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 24 May 2023 21:31:04 -0700 Subject: [PATCH 02/10] Flip #if logic for unaligned access Assume only x86 can correctly/efficiently handle unaligned access. --- src/misc/pv/byteBuffer.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/misc/pv/byteBuffer.h b/src/misc/pv/byteBuffer.h index 4a71c8a..321f35d 100644 --- a/src/misc/pv/byteBuffer.h +++ b/src/misc/pv/byteBuffer.h @@ -150,14 +150,17 @@ struct swap<8> { #undef _PVA_swap64 /* PVD serialization doesn't pay attention to alignement, - * which some targets really care about and treat unaligned + * which some targets (ARM and powerpc) really care about and treat unaligned * access as a fault, or with a heavy penalty (~= to a syscall). * * For those targets,, we will have to live with the increase * in execution time and/or object code size of byte-wise copy. + * + * Treat x86 32/64 as an outlier, and assume all other targets + * need, or greatly benefit, from aligned access. */ -#if defined(_ARCH_PPC) || defined(__arm__) || defined(_M_ARM) +#if !(defined(__x86_64__) || defined(_M_AMD64) || defined(__i386__) || defined(_M_IX86)) template union alignu { From b7ad4478a4f80d4a51f71d6213568baac81e61c2 Mon Sep 17 00:00:00 2001 From: Simon Rose Date: Wed, 24 May 2023 16:21:47 +0200 Subject: [PATCH 03/10] Update debugPtr to work with EPICS base 7.0.7 There are at least two changes to EPICS base since the addition of debugPtr: * In pvAccess/**/dbdToPv.cpp, a write to an ostream was added (also in pvData/**/testSerialization.cpp) which does not resolve correctly when the operator<< overload is in the global namespace. * In pvAccess/**/caChannel.cpp, weak_ptr->expired() was added The interface to deal with each of these has been added. --- src/misc/debugPtr.cpp | 2 +- src/misc/pv/debugPtr.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/misc/debugPtr.cpp b/src/misc/debugPtr.cpp index 62146e0..3cd3210 100644 --- a/src/misc/debugPtr.cpp +++ b/src/misc/debugPtr.cpp @@ -35,7 +35,7 @@ void shared_ptr_base::track_new() } // create new tracker if ptr!=nullptr, otherwise clear -void shared_ptr_base::track_new(void* ptr) +void shared_ptr_base::track_new(const void* ptr) { track_clear(); if(ptr){ diff --git a/src/misc/pv/debugPtr.h b/src/misc/pv/debugPtr.h index 479eafc..3ce0771 100644 --- a/src/misc/pv/debugPtr.h +++ b/src/misc/pv/debugPtr.h @@ -78,7 +78,7 @@ protected: // add ourselves to tracker void track_new(); // create new tracker if ptr!=nullptr, otherwise clear - void track_new(void* ptr); + void track_new(const void* ptr); // copy tracker and add ourself void track_assign(const shared_ptr_base& o); void track_clear(); @@ -286,6 +286,7 @@ public: long use_count() const noexcept { return real.use_count(); } bool unique() const noexcept { return real.unique(); } + bool expired() const noexcept { return real.expired(); } }; template @@ -316,13 +317,12 @@ do_enable_shared_from_this(const shared_ptr& dest, self->xxInternalSelf = actual; } -}} // namespace epics::debug - template -inline std::ostream& operator<<(std::ostream& strm, const epics::debug::shared_ptr& ptr) +inline std::ostream& operator<<(std::ostream& strm, const shared_ptr& ptr) { strm< Date: Sun, 6 Aug 2023 20:45:08 -0500 Subject: [PATCH 04/10] Generate JSON5 when available Fixes lp: #2029482 / GitHub #92 --- documentation/release_notes.dox | 2 ++ src/factory/printer.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/documentation/release_notes.dox b/documentation/release_notes.dox index 27bc1aa..6e2927f 100644 --- a/documentation/release_notes.dox +++ b/documentation/release_notes.dox @@ -5,6 +5,8 @@ Release 8.0.6 (UNRELEASED) ======================== +- Compatible changes + - Actually enable JSON-5 output in PVStructure::Formatter::JSON when available. Release 8.0.5 (Sep 2022) ======================== diff --git a/src/factory/printer.cpp b/src/factory/printer.cpp index 55fb01c..846f2de 100644 --- a/src/factory/printer.cpp +++ b/src/factory/printer.cpp @@ -404,6 +404,9 @@ std::ostream& operator<<(std::ostream& strm, const PVStructure::Formatter& forma if(format.xfmt==PVStructure::Formatter::JSON) { JSONPrintOptions opts; opts.multiLine = false; +#if EPICS_VERSION_INT>=VERSION_INT(7,0,6,1) + opts.json5 = true; +#endif printJSON(strm, format.xtop, format.xshow ? *format.xshow : BitSet().set(0), opts); strm<<'\n'; return strm; From 04fcb7e38fbf00b97c65c8319648168de15ee92a Mon Sep 17 00:00:00 2001 From: JJL772 Date: Mon, 17 Jul 2023 14:58:39 -0700 Subject: [PATCH 05/10] Don't return local copy of std::string in AnyScalar::bufferUnsafe --- src/misc/anyscalar.cpp | 4 ++-- src/misc/pv/anyscalar.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/misc/anyscalar.cpp b/src/misc/anyscalar.cpp index 7072922..c140a97 100644 --- a/src/misc/anyscalar.cpp +++ b/src/misc/anyscalar.cpp @@ -31,7 +31,7 @@ AnyScalar::AnyScalar(const AnyScalar& o) } #if __cplusplus>=201103L -AnyScalar::AnyScalar(AnyScalar&& o) +AnyScalar::AnyScalar(AnyScalar&& o) noexcept :_stype(o._stype) { typedef std::string string; @@ -136,7 +136,7 @@ void AnyScalar::swap(AnyScalar& o) { } const void* AnyScalar::bufferUnsafe() const { if(_stype==pvString) { - return as().c_str(); + return ref().c_str(); } else { return _wrap.blob; } diff --git a/src/misc/pv/anyscalar.h b/src/misc/pv/anyscalar.h index 2efccae..fdf44b0 100644 --- a/src/misc/pv/anyscalar.h +++ b/src/misc/pv/anyscalar.h @@ -123,7 +123,7 @@ public: AnyScalar(const AnyScalar& o); #if __cplusplus>=201103L - AnyScalar(AnyScalar&& o); + AnyScalar(AnyScalar&& o) noexcept; #endif inline ~AnyScalar() {clear();} @@ -140,7 +140,7 @@ public: } #if __cplusplus>=201103L - inline AnyScalar& operator=(AnyScalar&& o) { + inline AnyScalar& operator=(AnyScalar&& o) noexcept { clear(); swap(o); return *this; From eac2a8e70f567412a4c51276d2a5826382b9b65e Mon Sep 17 00:00:00 2001 From: JJL772 Date: Mon, 17 Jul 2023 15:00:05 -0700 Subject: [PATCH 06/10] Fix use-after-destroy in epicsRefSnapshopCurrent --- src/factory/Convert.cpp | 2 +- src/misc/reftrack.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/factory/Convert.cpp b/src/factory/Convert.cpp index f8ec4a1..af39b21 100644 --- a/src/factory/Convert.cpp +++ b/src/factory/Convert.cpp @@ -27,7 +27,7 @@ using std::string; namespace epics { namespace pvData { -static std::vector split(string commaSeparatedList) { +static std::vector split(const string& commaSeparatedList) { string::size_type numValues = 1; string::size_type index=0; while(true) { diff --git a/src/misc/reftrack.cpp b/src/misc/reftrack.cpp index 18f3307..7c1a88a 100644 --- a/src/misc/reftrack.cpp +++ b/src/misc/reftrack.cpp @@ -271,10 +271,10 @@ char* epicsRefSnapshotCurrent() snap.update(); std::ostringstream strm; strm< Date: Sun, 22 Oct 2023 16:05:43 -0700 Subject: [PATCH 07/10] rename print.cpp -> jprint.cpp In GHA builder somehow print.cpp becomes PRINT.obj instead of print.obj for mkmf.pl, which later fails when print.obj is missing. (apparently windows filesystems are now case sensitive...) --- src/json/Makefile | 2 +- src/json/{print.cpp => jprint.cpp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/json/{print.cpp => jprint.cpp} (100%) diff --git a/src/json/Makefile b/src/json/Makefile index 0baca83..1988c17 100644 --- a/src/json/Makefile +++ b/src/json/Makefile @@ -7,4 +7,4 @@ INC += pv/json.h LIBSRCS += parsehelper.cpp LIBSRCS += parseany.cpp LIBSRCS += parseinto.cpp -LIBSRCS += print.cpp +LIBSRCS += jprint.cpp diff --git a/src/json/print.cpp b/src/json/jprint.cpp similarity index 100% rename from src/json/print.cpp rename to src/json/jprint.cpp From 13e4e577bbc197ee7fe27e858e6ecd88d5265b45 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 22 Oct 2023 15:47:02 -0700 Subject: [PATCH 08/10] gha update --- .ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci b/.ci index 93062ba..899b183 160000 --- a/.ci +++ b/.ci @@ -1 +1 @@ -Subproject commit 93062ba941879f5eeaef40308b406c9d5dbf51c5 +Subproject commit 899b18336b4ce3bd9328fd30c33621224c78a4d7 From 3da69257a0946efa4dc61e6c025e5d2ff463125b Mon Sep 17 00:00:00 2001 From: thomasms Date: Tue, 20 Apr 2021 20:31:07 +0200 Subject: [PATCH 09/10] Remove duplicate doxygen comment - see issue #75 --- src/property/pv/pvAlarm.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/property/pv/pvAlarm.h b/src/property/pv/pvAlarm.h index 5df1faa..3cffae8 100644 --- a/src/property/pv/pvAlarm.h +++ b/src/property/pv/pvAlarm.h @@ -44,11 +44,6 @@ public: //default constructors and destructor are OK //returns (false,true) if pvField(is not, is) a valid alarm structure //An automatic detach is issued if already attached. - /* - * Attach to a field of a PVData object. - * @param pvField The pvField. - * @return (false,true) if the pvField (is not, is) an alarm structure. - */ /* * Attach to a field of a PVData object. * @param pvField The pvField. From dd74289eaf646670d1f62e2c6bbadbd400d1f17a Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 26 May 2023 11:00:37 +0200 Subject: [PATCH 10/10] Silence warning about uninitialized local variable found by static code analysis (cppcheck @ sonarqube) (that doesn't realize ">>=" calls an overloaded operator) --- testApp/pv/testOperators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testApp/pv/testOperators.cpp b/testApp/pv/testOperators.cpp index 4a00d84..38e5416 100644 --- a/testApp/pv/testOperators.cpp +++ b/testApp/pv/testOperators.cpp @@ -33,7 +33,7 @@ MAIN(testOperators) PVDoublePtr pvValue = pvStructure->getSubField("value"); *pvValue <<= testDV; - double dv; + double dv = 0.; *pvValue >>= dv; testOk1(testDV == dv);