[NTOS:EX] Use InterlockedExchangeAdd64 instead of InterlockedCompareExchange64 loop...
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 12 Jul 2018 13:54:52 +0000 (15:54 +0200)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 15 Aug 2019 16:04:57 +0000 (18:04 +0200)
ntoskrnl/ex/uuid.c

index 4d3c293..8af4776 100644 (file)
@@ -339,27 +339,9 @@ VOID
 NTAPI
 ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
 {
-    LARGE_INTEGER PrevLuid;
-    LONGLONG NewLuid, CompLuid;
-
     /* Atomically increment the luid */
-    PrevLuid.QuadPart = ExpLuid.QuadPart;
-    for (NewLuid = ExpLuid.QuadPart + ExpLuidIncrement; ;
-         NewLuid = PrevLuid.QuadPart + ExpLuidIncrement)
-    {
-        CompLuid = InterlockedCompareExchange64(&ExpLuid.QuadPart,
-                                                NewLuid,
-                                                PrevLuid.QuadPart);
-        if (CompLuid == PrevLuid.QuadPart)
-        {
-            break;
-        }
-
-        PrevLuid.QuadPart = CompLuid;
-    }
-
-    LocallyUniqueId->LowPart = PrevLuid.LowPart;
-    LocallyUniqueId->HighPart = PrevLuid.HighPart;
+    *(LONG64*)LocallyUniqueId = InterlockedExchangeAdd64(&ExpLuid.QuadPart,
+                                                         ExpLuidIncrement);
 }