]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange64.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseSynchronizationLib / Ia32 / InterlockedCompareExchange64.c
CommitLineData
720d3c5f 1/** @file\r
2 InterlockedCompareExchange64 function\r
3\r
4cee954e 4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
720d3c5f 6\r
7**/\r
8\r
720d3c5f 9/**\r
10 Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
11\r
12 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
13 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
14 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
15 The compare exchange operation must be performed using MP safe mechanisms.\r
16\r
17 @param Value A pointer to the 64-bit value for the compare exchange\r
18 operation.\r
2fc59a00 19 @param CompareValue A 64-bit value used in a compare operation.\r
20 @param ExchangeValue A 64-bit value used in an exchange operation.\r
720d3c5f 21\r
22 @return The original *Value before exchange.\r
23\r
24**/\r
25UINT64\r
26EFIAPI\r
27InternalSyncCompareExchange64 (\r
2f88bd3a
MK
28 IN volatile UINT64 *Value,\r
29 IN UINT64 CompareValue,\r
30 IN UINT64 ExchangeValue\r
720d3c5f 31 )\r
32{\r
33 _asm {\r
34 mov esi, Value\r
35 mov eax, dword ptr [CompareValue + 0]\r
36 mov edx, dword ptr [CompareValue + 4]\r
37 mov ebx, dword ptr [ExchangeValue + 0]\r
38 mov ecx, dword ptr [ExchangeValue + 4]\r
39 lock cmpxchg8b qword ptr [esi]\r
40 }\r
41}\r