]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ipf/Synchronization.c
44593e177879209a8c7cceec19d6b1cfd81079ab
2 Implementation of synchronization functions on Itanium.
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. 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.
13 Module Name: Synchronization.c
18 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
20 Performs an atomic compare exchange operation on the 32-bit unsigned integer
21 specified by Value. If Value is equal to CompareValue, then Value is set to
22 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
23 then Value is returned. The compare exchange operation must be performed using
26 @param Value A pointer to the 32-bit value for the compare exchange
28 @param CompareValue 32-bit value used in compare operation.
29 @param ExchangeValue 32-bit value used in exchange operation.
31 @return The original *Value before exchange.
36 InternalSyncCompareExchange32 (
37 IN
volatile UINT32
*Value
,
38 IN UINT32 CompareValue
,
39 IN UINT32 ExchangeValue
43 Performs an atomic increment of an 32-bit unsigned integer.
45 Performs an atomic increment of the 32-bit unsigned integer specified by
46 Value and returns the incremented value. The increment operation must be
47 performed using MP safe mechanisms. The state of the return value is not
48 guaranteed to be MP safe.
50 @param Value A pointer to the 32-bit value to increment.
52 @return The incremented value.
57 InternalSyncIncrement (
58 IN
volatile UINT32
*Value
64 OriginalValue
= *Value
;
65 } while (OriginalValue
!= InternalSyncCompareExchange32 (
70 return OriginalValue
+ 1;
74 Performs an atomic decrement of an 32-bit unsigned integer.
76 Performs an atomic decrement of the 32-bit unsigned integer specified by
77 Value and returns the decrement value. The decrement operation must be
78 performed using MP safe mechanisms. The state of the return value is not
79 guaranteed to be MP safe.
81 @param Value A pointer to the 32-bit value to decrement.
83 @return The decrement value.
88 InternalSyncDecrement (
89 IN
volatile UINT32
*Value
95 OriginalValue
= *Value
;
96 } while (OriginalValue
!= InternalSyncCompareExchange32 (
101 return OriginalValue
- 1;