]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c
2 GCC inline implementation of BaseSynchronizationLib processor specific functions.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 Performs an atomic increment of an 32-bit unsigned integer.
22 Performs an atomic increment of the 32-bit unsigned integer specified by
23 Value and returns the incremented value. The increment operation must be
24 performed using MP safe mechanisms. The state of the return value is not
25 guaranteed to be MP safe.
27 @param Value A pointer to the 32-bit value to increment.
29 @return The incremented value.
34 InternalSyncIncrement (
35 IN
volatile UINT32
*Value
40 __asm__
__volatile__ (
44 : "=a" (Result
), // %0
56 Performs an atomic decrement of an 32-bit unsigned integer.
58 Performs an atomic decrement of the 32-bit unsigned integer specified by
59 Value and returns the decremented value. The decrement operation must be
60 performed using MP safe mechanisms. The state of the return value is not
61 guaranteed to be MP safe.
63 @param Value A pointer to the 32-bit value to decrement.
65 @return The decremented value.
70 InternalSyncDecrement (
71 IN
volatile UINT32
*Value
76 __asm__
__volatile__ (
80 : "=a" (Result
), // %0
92 Performs an atomic compare exchange operation on a 16-bit unsigned integer.
94 Performs an atomic compare exchange operation on the 16-bit unsigned integer
95 specified by Value. If Value is equal to CompareValue, then Value is set to
96 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
97 then Value is returned. The compare exchange operation must be performed using
101 @param Value A pointer to the 16-bit value for the compare exchange
103 @param CompareValue 16-bit value used in compare operation.
104 @param ExchangeValue 16-bit value used in exchange operation.
106 @return The original *Value before exchange.
111 InternalSyncCompareExchange16 (
112 IN OUT
volatile UINT16
*Value
,
113 IN UINT16 CompareValue
,
114 IN UINT16 ExchangeValue
119 __asm__
__volatile__ (
122 : "=a" (CompareValue
),
124 : "a" (CompareValue
),
136 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
138 Performs an atomic compare exchange operation on the 32-bit unsigned integer
139 specified by Value. If Value is equal to CompareValue, then Value is set to
140 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
141 then Value is returned. The compare exchange operation must be performed using
145 @param Value A pointer to the 32-bit value for the compare exchange
147 @param CompareValue 32-bit value used in compare operation.
148 @param ExchangeValue 32-bit value used in exchange operation.
150 @return The original *Value before exchange.
155 InternalSyncCompareExchange32 (
156 IN OUT
volatile UINT32
*Value
,
157 IN UINT32 CompareValue
,
158 IN UINT32 ExchangeValue
163 __asm__
__volatile__ (
166 : "=a" (CompareValue
), // %0
168 : "a" (CompareValue
), // %2
169 "r" (ExchangeValue
), // %3
180 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
182 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
183 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
184 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
185 The compare exchange operation must be performed using MP safe mechanisms.
188 @param Value A pointer to the 64-bit value for the compare exchange
190 @param CompareValue 64-bit value used in compare operation.
191 @param ExchangeValue 64-bit value used in exchange operation.
193 @return The original *Value before exchange.
198 InternalSyncCompareExchange64 (
199 IN OUT
volatile UINT64
*Value
,
200 IN UINT64 CompareValue
,
201 IN UINT64 ExchangeValue
205 __asm__
__volatile__ (
208 : "=a" (CompareValue
), // %0
210 : "a" (CompareValue
), // %2
211 "r" (ExchangeValue
), // %3