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