]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedCompareExchange32.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseSynchronizationLib / Ia32 / 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 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
11
12 Performs an atomic compare exchange operation on the 32-bit unsigned integer
13 specified by Value. If Value is equal to CompareValue, then Value is set to
14 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
15 then Value is returned. The compare exchange operation must be performed using
16 MP safe mechanisms.
17
18 @param Value A pointer to the 32-bit value for the compare exchange
19 operation.
20 @param CompareValue 32-bit value used in compare operation.
21 @param ExchangeValue 32-bit value used in exchange operation.
22
23 @return The original *Value before exchange.
24
25 **/
26 UINT32
27 EFIAPI
28 InternalSyncCompareExchange32 (
29 IN volatile UINT32 *Value,
30 IN UINT32 CompareValue,
31 IN UINT32 ExchangeValue
32 )
33 {
34 _asm {
35 mov ecx, Value
36 mov eax, CompareValue
37 mov edx, ExchangeValue
38 lock cmpxchg [ecx], edx
39 }
40 }