]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseSynchronizationLib / X64 / InterlockedCompareExchange16.c
CommitLineData
9b89163e
AB
1/** @file\r
2 InterlockedCompareExchange16 function\r
3\r
4cee954e 4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
9b89163e
AB
5 Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16/**\r
17 Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.\r
18**/\r
19\r
20__int16 _InterlockedCompareExchange16(\r
21 __int16 volatile * Destination,\r
22 __int16 Exchange,\r
23 __int16 Comperand\r
24);\r
25\r
26#pragma intrinsic(_InterlockedCompareExchange16)\r
27\r
28/**\r
29 Performs an atomic compare exchange operation on a 16-bit unsigned integer.\r
30\r
31 Performs an atomic compare exchange operation on the 16-bit unsigned integer specified\r
32 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
33 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
34 The compare exchange operation must be performed using MP safe mechanisms.\r
35\r
36 @param Value A pointer to the 16-bit value for the compare exchange\r
37 operation.\r
38 @param CompareValue 16-bit value used in compare operation.\r
39 @param ExchangeValue 16-bit value used in exchange operation.\r
40\r
41 @return The original *Value before exchange.\r
42\r
43**/\r
44UINT16\r
45EFIAPI\r
46InternalSyncCompareExchange16 (\r
4cee954e 47 IN volatile UINT16 *Value,\r
9b89163e
AB
48 IN UINT16 CompareValue,\r
49 IN UINT16 ExchangeValue\r
50 )\r
51{\r
52 return _InterlockedCompareExchange16 (Value, ExchangeValue, CompareValue);\r
53}\r
54\r