]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseSynchronizationLib / X64 / InterlockedCompareExchange16.c
1 /** @file
2 InterlockedCompareExchange16 function
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 /**
11 Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
12 **/
13
14 __int16 _InterlockedCompareExchange16(
15 __int16 volatile * Destination,
16 __int16 Exchange,
17 __int16 Comperand
18 );
19
20 #pragma intrinsic(_InterlockedCompareExchange16)
21
22 /**
23 Performs an atomic compare exchange operation on a 16-bit unsigned integer.
24
25 Performs an atomic compare exchange operation on the 16-bit unsigned integer specified
26 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
27 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
28 The compare exchange operation must be performed using MP safe mechanisms.
29
30 @param Value A pointer to the 16-bit value for the compare exchange
31 operation.
32 @param CompareValue 16-bit value used in compare operation.
33 @param ExchangeValue 16-bit value used in exchange operation.
34
35 @return The original *Value before exchange.
36
37 **/
38 UINT16
39 EFIAPI
40 InternalSyncCompareExchange16 (
41 IN volatile UINT16 *Value,
42 IN UINT16 CompareValue,
43 IN UINT16 ExchangeValue
44 )
45 {
46 return _InterlockedCompareExchange16 (Value, ExchangeValue, CompareValue);
47 }
48