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