[ros-diffs] [tkreuzer] 52246: [RTL] Fix useage of volatile in casts.

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Wed Jun 15 13:33:49 UTC 2011


Author: tkreuzer
Date: Wed Jun 15 13:33:48 2011
New Revision: 52246

URL: http://svn.reactos.org/svn/reactos?rev=52246&view=rev
Log:
[RTL]
Fix useage of volatile in casts.

Modified:
    trunk/reactos/lib/rtl/workitem.c

Modified: trunk/reactos/lib/rtl/workitem.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/workitem.c?rev=52246&r1=52245&r2=52246&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/workitem.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/workitem.c [iso-8859-1] Wed Jun 15 13:33:48 2011
@@ -45,7 +45,7 @@
 static LONG ThreadPoolIOWorkerThreadsRequests;
 static LONG ThreadPoolIOWorkerThreadsLongRequests;
 
-#define IsThreadPoolInitialized() ((volatile LONG)ThreadPoolInitialized == 1)
+#define IsThreadPoolInitialized() (*((volatile LONG*)&ThreadPoolInitialized) == 1)
 
 static NTSTATUS
 RtlpInitializeThreadPool(VOID)
@@ -614,8 +614,8 @@
             /* FIXME - figure out an effective method to determine if it's appropriate to
                        lower the number of threads. For now let's always terminate if there's
                        at least one thread and no queued items. */
-            Terminate = ((volatile LONG)ThreadPoolIOWorkerThreads - (volatile LONG)ThreadPoolIOWorkerThreadsLongRequests >= WORKERTHREAD_CREATION_THRESHOLD) &&
-                        ((volatile LONG)ThreadPoolIOWorkerThreadsRequests == 0);
+            Terminate = (*((volatile LONG*)&ThreadPoolIOWorkerThreads) - *((volatile LONG*)&ThreadPoolIOWorkerThreadsLongRequests) >= WORKERTHREAD_CREATION_THRESHOLD) &&
+                        (*((volatile LONG*)&ThreadPoolIOWorkerThreadsRequests) == 0);
 
             if (Terminate)
             {
@@ -718,7 +718,7 @@
             {
                 /* FIXME - we might want to optimize this */
                 if (TimeoutCount++ > 2 &&
-                    (volatile LONG)ThreadPoolWorkerThreads - (volatile LONG)ThreadPoolWorkerThreadsLongRequests >= WORKERTHREAD_CREATION_THRESHOLD)
+                    *((volatile LONG*)&ThreadPoolWorkerThreads) - *((volatile LONG*)&ThreadPoolWorkerThreadsLongRequests) >= WORKERTHREAD_CREATION_THRESHOLD)
                 {
                     Terminate = TRUE;
                 }
@@ -819,7 +819,7 @@
                 /* Grow the thread pool */
                 Status = RtlpStartWorkerThread(RtlpIoWorkerThreadProc);
 
-                if (!NT_SUCCESS(Status) && (volatile LONG)ThreadPoolIOWorkerThreads != 0)
+                if (!NT_SUCCESS(Status) && *((volatile LONG*)&ThreadPoolIOWorkerThreads) != 0)
                 {
                     /* We failed to create the thread, but there's at least one there so
                        we can at least queue the request */
@@ -846,7 +846,7 @@
                 /* Grow the thread pool */
                 Status = RtlpStartWorkerThread(RtlpWorkerThreadProc);
 
-                if (!NT_SUCCESS(Status) && (volatile LONG)ThreadPoolWorkerThreads != 0)
+                if (!NT_SUCCESS(Status) && *((volatile LONG*)&ThreadPoolWorkerThreads) != 0)
                 {
                     /* We failed to create the thread, but there's at least one there so
                        we can at least queue the request */




More information about the Ros-diffs mailing list