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