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