]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSynchronizationLib/Ebc/Synchronization.c
c13f4e06bcdbbd307b7eb40aed2ffac6a5164c34
2 Implementation of synchronization functions on EBC.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Performs an atomic compare exchange operation on a 16-bit
19 Performs an atomic compare exchange operation on the 16-bit
20 unsigned integer specified by Value. If Value is equal to
21 CompareValue, then Value is set to ExchangeValue and
22 CompareValue is returned. If Value is not equal to
23 CompareValue, then Value is returned. The compare exchange
24 operation must be performed using MP safe mechanisms.
26 @param Value A pointer to the 16-bit value for the
27 compare exchange operation.
28 @param CompareValue 16-bit value used in compare operation.
29 @param ExchangeValue 16-bit value used in exchange operation.
31 @return The original *Value before exchange.
36 InternalSyncCompareExchange16 (
37 IN
volatile UINT16
*Value
,
38 IN UINT16 CompareValue
,
39 IN UINT16 ExchangeValue
42 return *Value
!= CompareValue
? *Value
:
43 ((*Value
= ExchangeValue
), CompareValue
);
47 Performs an atomic compare exchange operation on a 32-bit
50 Performs an atomic compare exchange operation on the 32-bit
51 unsigned integer specified by Value. If Value is equal to
52 CompareValue, then Value is set to ExchangeValue and
53 CompareValue is returned. If Value is not equal to
54 CompareValue, then Value is returned. The compare exchange
55 operation must be performed using MP safe mechanisms.
57 @param Value A pointer to the 32-bit value for the
58 compare exchange operation.
59 @param CompareValue 32-bit value used in compare operation.
60 @param ExchangeValue 32-bit value used in exchange operation.
62 @return The original *Value before exchange.
67 InternalSyncCompareExchange32 (
68 IN
volatile UINT32
*Value
,
69 IN UINT32 CompareValue
,
70 IN UINT32 ExchangeValue
73 return *Value
!= CompareValue
? *Value
:
74 ((*Value
= ExchangeValue
), CompareValue
);
78 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
80 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
81 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
82 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
83 The compare exchange operation must be performed using MP safe mechanisms.
85 @param Value A pointer to the 64-bit value for the compare exchange
87 @param CompareValue 64-bit value used in compare operation.
88 @param ExchangeValue 64-bit value used in exchange operation.
90 @return The original *Value before exchange.
95 InternalSyncCompareExchange64 (
96 IN
volatile UINT64
*Value
,
97 IN UINT64 CompareValue
,
98 IN UINT64 ExchangeValue
101 return *Value
!= CompareValue
? *Value
:
102 ((*Value
= ExchangeValue
), CompareValue
);
106 Performs an atomic increment of an 32-bit unsigned integer.
108 Performs an atomic increment of the 32-bit unsigned integer specified by
109 Value and returns the incremented value. The increment operation must be
110 performed using MP safe mechanisms. The state of the return value is not
111 guaranteed to be MP safe.
113 @param Value A pointer to the 32-bit value to increment.
115 @return The incremented value.
120 InternalSyncIncrement (
121 IN
volatile UINT32
*Value
128 Performs an atomic decrement of an 32-bit unsigned integer.
130 Performs an atomic decrement of the 32-bit unsigned integer specified by
131 Value and returns the decrement value. The decrement operation must be
132 performed using MP safe mechanisms. The state of the return value is not
133 guaranteed to be MP safe.
135 @param Value A pointer to the 32-bit value to decrement.
137 @return The decrement value.
142 InternalSyncDecrement (
143 IN
volatile UINT32
*Value