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