https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fffe4f6385fed59082ea5e1fd3b91b99f848ef3d

commit fffe4f6385fed59082ea5e1fd3b91b99f848ef3d
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Thu Jul 12 15:54:52 2018 +0200
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Thu Aug 15 18:04:57 2019 +0200

    [NTOS:EX] Use InterlockedExchangeAdd64 instead of 
InterlockedCompareExchange64 loop in ExAllocateLocallyUniqueId
---
 ntoskrnl/ex/uuid.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/ntoskrnl/ex/uuid.c b/ntoskrnl/ex/uuid.c
index 4d3c2932bce..8af4776d0b1 100644
--- a/ntoskrnl/ex/uuid.c
+++ b/ntoskrnl/ex/uuid.c
@@ -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);
 }
 
 

Reply via email to