]>
Commit | Line | Data |
---|---|---|
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 | |
9 | \r | |
10 | \r | |
11 | \r | |
12 | /**\r | |
13 | Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r | |
14 | \r | |
15 | Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r | |
16 | by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r | |
17 | CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r | |
18 | The compare exchange operation must be performed using MP safe mechanisms.\r | |
19 | \r | |
20 | @param Value A pointer to the 64-bit value for the compare exchange\r | |
21 | operation.\r | |
2fc59a00 | 22 | @param CompareValue A 64-bit value used in a compare operation.\r |
23 | @param ExchangeValue A 64-bit value used in an exchange operation.\r | |
720d3c5f | 24 | \r |
25 | @return The original *Value before exchange.\r | |
26 | \r | |
27 | **/\r | |
28 | UINT64\r | |
29 | EFIAPI\r | |
30 | InternalSyncCompareExchange64 (\r | |
4cee954e | 31 | IN volatile UINT64 *Value,\r |
720d3c5f | 32 | IN UINT64 CompareValue,\r |
33 | IN UINT64 ExchangeValue\r | |
34 | )\r | |
35 | {\r | |
36 | _asm {\r | |
37 | mov esi, Value\r | |
38 | mov eax, dword ptr [CompareValue + 0]\r | |
39 | mov edx, dword ptr [CompareValue + 4]\r | |
40 | mov ebx, dword ptr [ExchangeValue + 0]\r | |
41 | mov ecx, dword ptr [ExchangeValue + 4]\r | |
42 | lock cmpxchg8b qword ptr [esi]\r | |
43 | }\r | |
44 | }\r |