summaryrefslogtreecommitdiff
path: root/opencl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-09-18 19:13:34 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-09-18 20:28:29 +0200
commit33d922ea07b6b20276471b19fd9c148ed90d7442 (patch)
tree84a4ea43f15af47852308d31c8b32d1b75fdcc2f /opencl
parentc3940a9fb2de7ba09f7d82497491918fd9bb3d0e (diff)
-Werror=volatile in OpenCLZone
Recent GCC 10 trunk in C++20 mode reports issues like > include/opencl/OpenCLZone.hxx:27:9: error: ‘++’ expression of ‘volatile’-qualified type is deprecated [-Werror=volatile] > 27 | gnEnterCount++; > | ^~~~~~~~~~~~ But unlike in the case of ec17c8ec5256386b0197a8ffe5d7cad3e7d70f8f "-Werror=volatile in OpenGLZone", * it looks like there are no multi-threading issues here, and the counters are just accessed (via OpenCLZone::isInZone) from the VCLExceptionSignal_impl signal handler in addition to being modified (via OpenCLZone RAII objects) from mainline code; and * from the usage pattern of gnEnterCount and gnLeaveCount it appears that they can be combined into a single counter. (f41eb66302208f384a475fb20c98b6d1b0676cb6 "opencl: OpenCLZone, detect CL device change and disable CL on crash" presumably modelled OpenCLZone naively after OpenGLZone, without simplifying it where possible.) One minor advantage of having two monotonically increasing counters is that when they overflow, the implementation of isInZone (comparing them for equality) still gives ~useful results (assuming that a false "match" of non-overflown gnEnterCount against overflown gnLeaveCount is highly unlikely). But instances of OpenCLZone RAII objects are presumably never nested very deeply (if at all), so that the newly added "TODO: overflow" comment (which would even cause UB if std::sig_atomic_t is signed) is probably of no practical concern. Change-Id: I92e1f2c46ca996a0a86bacabcda2accba5eb6298 Reviewed-on: https://gerrit.libreoffice.org/79106 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'opencl')
-rw-r--r--opencl/source/OpenCLZone.cxx3
1 files changed, 1 insertions, 2 deletions
diff --git a/opencl/source/OpenCLZone.cxx b/opencl/source/OpenCLZone.cxx
index e4e3ff08fff4..f7c8e961364d 100644
--- a/opencl/source/OpenCLZone.cxx
+++ b/opencl/source/OpenCLZone.cxx
@@ -19,8 +19,7 @@
// FIXME: templatize me vs. OpenGLZone.
-sal_uInt64 volatile OpenCLZone::gnEnterCount = 0;
-sal_uInt64 volatile OpenCLZone::gnLeaveCount = 0;
+std::sig_atomic_t volatile OpenCLZone::gnEnterCount = 0;
bool volatile OpenCLZone::gbInInitialTest = false;
/**