]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.c
MdePkg: Apply uncrustify changes
[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
14 _InterlockedCompareExchange (
15 long volatile *Destination,
16 long Exchange,
17 long Comperand
18 );
19
20 #pragma intrinsic(_InterlockedCompareExchange)
21
22 /**
23 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
24
25 Performs an atomic compare exchange operation on the 32-bit unsigned integer
26 specified by Value. If Value is equal to CompareValue, then Value is set to
27 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
28 then Value is returned. The compare exchange operation must be performed using
29 MP safe mechanisms.
30
31 @param Value A pointer to the 32-bit value for the compare exchange
32 operation.
33 @param CompareValue 32-bit value used in compare operation.
34 @param ExchangeValue 32-bit value used in exchange operation.
35
36 @return The original *Value before exchange.
37
38 **/
39 UINT32
40 EFIAPI
41 InternalSyncCompareExchange32 (
42 IN volatile UINT32 *Value,
43 IN UINT32 CompareValue,
44 IN UINT32 ExchangeValue
45 )
46 {
47 return _InterlockedCompareExchange (Value, ExchangeValue, CompareValue);
48 }