]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ebc/Synchronization.c
1. added functions header for BaseUefiDecompressLi
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ebc / Synchronization.c
1 /** @file
2 Implementation of synchronization functions on EBC.
3
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
9
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.
12
13 Module Name: Synchronization.c
14
15 **/
16
17 UINT32
18 EFIAPI
19 InternalSyncCompareExchange32 (
20 IN volatile UINT32 *Value,
21 IN UINT32 CompareValue,
22 IN UINT32 ExchangeValue
23 )
24 {
25 return *Value != CompareValue ? *Value :
26 ((*Value = ExchangeValue), CompareValue);
27 }
28
29 /**
30 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
31
32 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
33 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
34 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
35 The compare exchange operation must be performed using MP safe mechanisms.
36
37 @param Value A pointer to the 64-bit value for the compare exchange
38 operation.
39 @param CompareValue 64-bit value used in compare operation.
40 @param ExchangeValue 64-bit value used in exchange operation.
41
42 @return The original *Value before exchange.
43
44 **/
45 UINT64
46 EFIAPI
47 InternalSyncCompareExchange64 (
48 IN volatile UINT64 *Value,
49 IN UINT64 CompareValue,
50 IN UINT64 ExchangeValue
51 )
52 {
53 return *Value != CompareValue ? *Value :
54 ((*Value = ExchangeValue), CompareValue);
55 }
56
57 /**
58 Performs an atomic increment of an 32-bit unsigned integer.
59
60 Performs an atomic increment of the 32-bit unsigned integer specified by
61 Value and returns the incremented value. The increment operation must be
62 performed using MP safe mechanisms. The state of the return value is not
63 guaranteed to be MP safe.
64
65 @param Value A pointer to the 32-bit value to increment.
66
67 @return The incremented value.
68
69 **/
70 UINT32
71 EFIAPI
72 InternalSyncIncrement (
73 IN volatile UINT32 *Value
74 )
75 {
76 return ++*Value;
77 }
78
79 /**
80 Performs an atomic decrement of an 32-bit unsigned integer.
81
82 Performs an atomic decrement of the 32-bit unsigned integer specified by
83 Value and returns the decrement value. The decrement operation must be
84 performed using MP safe mechanisms. The state of the return value is not
85 guaranteed to be MP safe.
86
87 @param Value A pointer to the 32-bit value to decrement.
88
89 @return The decrement value.
90
91 **/
92 UINT32
93 EFIAPI
94 InternalSyncDecrement (
95 IN volatile UINT32 *Value
96 )
97 {
98 return --*Value;
99 }