Make mutex test variables volatile to prevent potential errors cused by optimizer 35/41535/1
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Tue, 16 Jun 2015 10:36:08 +0000 (11:36 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Tue, 16 Jun 2015 10:36:08 +0000 (11:36 +0100)
Change-Id: I94a455df9ef4fcca817b606220b4de2419649cd3

automated-tests/src/dali-devel/utc-Dali-Mutex.cpp

index 2911d6c..60fdaaf 100644 (file)
@@ -50,10 +50,11 @@ int UtcDaliMutexSingleThread(void)
 
 namespace // for local variables to avoid name clashes
 {
-int gGlobalValue = 0;
-Mutex* gGlobalValueMutex;
-bool gWorkerThreadWait = true;
-enum ThreadState { INIT, RUN, LOCKING, TERMINATE } gWorkerThreadState = INIT;
+// make all these volatile to pre-empt any optimization screwing up the logic
+volatile int gGlobalValue = 0;
+volatile bool gWorkerThreadWait = true;
+volatile enum ThreadState { INIT, RUN, LOCKING, TERMINATE } gWorkerThreadState = INIT;
+Mutex* volatile gGlobalValueMutex; // volatile pointer to a mutex object
 }
 void* WorkerThread1( void* ptr )
 {