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