]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ebc/Synchronization.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / Ebc / Synchronization.c
1 /*++
2
3 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12
13 Module Name:
14
15 Synchronization.c
16
17 Abstract:
18
19
20 --*/
21
22 #include "BaseLibInternals.h"
23
24 UINT32
25 EFIAPI
26 InternalSyncCompareExchange32 (
27 IN volatile UINT32 *Value,
28 IN UINT32 CompareValue,
29 IN UINT32 ExchangeValue
30 )
31 {
32 return *Value != CompareValue ? *Value :
33 ((*Value = ExchangeValue), CompareValue);
34 }
35
36 /**
37 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
38
39 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
40 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
41 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
42 The compare exchange operation must be performed using MP safe mechanisms.
43
44 @param Value A pointer to the 64-bit value for the compare exchange
45 operation.
46 @param CompareValue 64-bit value used in compare operation.
47 @param ExchangeValue 64-bit value used in exchange operation.
48
49 @return The original *Value before exchange.
50
51 **/
52 UINT64
53 EFIAPI
54 InternalSyncCompareExchange64 (
55 IN volatile UINT64 *Value,
56 IN UINT64 CompareValue,
57 IN UINT64 ExchangeValue
58 )
59 {
60 return *Value != CompareValue ? *Value :
61 ((*Value = ExchangeValue), CompareValue);
62 }
63
64 /**
65 Performs an atomic increment of an 32-bit unsigned integer.
66
67 Performs an atomic increment of the 32-bit unsigned integer specified by
68 Value and returns the incremented value. The increment operation must be
69 performed using MP safe mechanisms. The state of the return value is not
70 guaranteed to be MP safe.
71
72 @param Value A pointer to the 32-bit value to increment.
73
74 @return The incremented value.
75
76 **/
77 UINT32
78 EFIAPI
79 InternalSyncIncrement (
80 IN volatile UINT32 *Value
81 )
82 {
83 return ++*Value;
84 }
85
86 /**
87 Performs an atomic decrement of an 32-bit unsigned integer.
88
89 Performs an atomic decrement of the 32-bit unsigned integer specified by
90 Value and returns the decrement value. The decrement operation must be
91 performed using MP safe mechanisms. The state of the return value is not
92 guaranteed to be MP safe.
93
94 @param Value A pointer to the 32-bit value to decrement.
95
96 @return The decrement value.
97
98 **/
99 UINT32
100 EFIAPI
101 InternalSyncDecrement (
102 IN volatile UINT32 *Value
103 )
104 {
105 return --*Value;
106 }