diff options
-rw-r--r-- | include/opencl/OpenCLZone.hxx | 18 | ||||
-rw-r--r-- | opencl/source/OpenCLZone.cxx | 3 |
2 files changed, 12 insertions, 9 deletions
diff --git a/include/opencl/OpenCLZone.hxx b/include/opencl/OpenCLZone.hxx index 0d2059dddc87..d1c59dcd25d4 100644 --- a/include/opencl/OpenCLZone.hxx +++ b/include/opencl/OpenCLZone.hxx @@ -10,33 +10,37 @@ #ifndef INCLUDED_OPENCL_INC_OPENCL_ZONE_HXX #define INCLUDED_OPENCL_INC_OPENCL_ZONE_HXX +#include <sal/config.h> + +#include <cassert> +#include <csignal> + #include <opencl/opencldllapi.h> // FIXME: post back-port, templatize me and share with OpenGLZone. class OPENCL_DLLPUBLIC OpenCLZone { - /// how many times have we entered a CL zone - static volatile sal_uInt64 gnEnterCount; - /// how many times have we left a new CL zone - static volatile sal_uInt64 gnLeaveCount; + /// how many times have we entered a CL zone and not yet left it + static volatile std::sig_atomic_t gnEnterCount; static volatile bool gbInInitialTest; public: OpenCLZone() { - gnEnterCount++; + gnEnterCount = gnEnterCount + 1; //TODO: overflow } ~OpenCLZone() { - gnLeaveCount++; + assert(gnEnterCount > 0); + gnEnterCount = gnEnterCount - 1; if (!isInZone()) gbInInitialTest = false; } static bool isInZone() { - return gnEnterCount != gnLeaveCount; + return gnEnterCount > 0; } static bool isInInitialTest() 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; /** |