]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseSynchronizationLib/Ebc/Synchronization.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseSynchronizationLib / Ebc / Synchronization.c
CommitLineData
720d3c5f 1/** @file\r
2 Implementation of synchronization functions on EBC.\r
3\r
9095d37b 4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
720d3c5f 6\r
7**/\r
8\r
9b89163e
AB
9/**\r
10 Performs an atomic compare exchange operation on a 16-bit\r
11 unsigned integer.\r
12\r
13 Performs an atomic compare exchange operation on the 16-bit\r
14 unsigned integer specified by Value. If Value is equal to\r
15 CompareValue, then Value is set to ExchangeValue and\r
16 CompareValue is returned. If Value is not equal to\r
17 CompareValue, then Value is returned. The compare exchange\r
18 operation must be performed using MP safe mechanisms.\r
19\r
20 @param Value A pointer to the 16-bit value for the\r
21 compare exchange operation.\r
22 @param CompareValue 16-bit value used in compare operation.\r
23 @param ExchangeValue 16-bit value used in exchange operation.\r
24\r
25 @return The original *Value before exchange.\r
26\r
27**/\r
28UINT16\r
29EFIAPI\r
30InternalSyncCompareExchange16 (\r
2f88bd3a
MK
31 IN volatile UINT16 *Value,\r
32 IN UINT16 CompareValue,\r
33 IN UINT16 ExchangeValue\r
9b89163e
AB
34 )\r
35{\r
36 return *Value != CompareValue ? *Value :\r
2f88bd3a 37 ((*Value = ExchangeValue), CompareValue);\r
9b89163e
AB
38}\r
39\r
720d3c5f 40/**\r
41 Performs an atomic compare exchange operation on a 32-bit\r
42 unsigned integer.\r
43\r
44 Performs an atomic compare exchange operation on the 32-bit\r
45 unsigned integer specified by Value. If Value is equal to\r
46 CompareValue, then Value is set to ExchangeValue and\r
47 CompareValue is returned. If Value is not equal to\r
48 CompareValue, then Value is returned. The compare exchange\r
49 operation must be performed using MP safe mechanisms.\r
50\r
51 @param Value A pointer to the 32-bit value for the\r
52 compare exchange operation.\r
53 @param CompareValue 32-bit value used in compare operation.\r
54 @param ExchangeValue 32-bit value used in exchange operation.\r
55\r
56 @return The original *Value before exchange.\r
57\r
58**/\r
59UINT32\r
60EFIAPI\r
61InternalSyncCompareExchange32 (\r
2f88bd3a
MK
62 IN volatile UINT32 *Value,\r
63 IN UINT32 CompareValue,\r
64 IN UINT32 ExchangeValue\r
720d3c5f 65 )\r
66{\r
67 return *Value != CompareValue ? *Value :\r
2f88bd3a 68 ((*Value = ExchangeValue), CompareValue);\r
720d3c5f 69}\r
70\r
71/**\r
72 Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r
73\r
9095d37b
LG
74 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r
75 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r
76 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r
720d3c5f 77 The compare exchange operation must be performed using MP safe mechanisms.\r
78\r
79 @param Value A pointer to the 64-bit value for the compare exchange\r
80 operation.\r
81 @param CompareValue 64-bit value used in compare operation.\r
82 @param ExchangeValue 64-bit value used in exchange operation.\r
83\r
84 @return The original *Value before exchange.\r
85\r
86**/\r
87UINT64\r
88EFIAPI\r
89InternalSyncCompareExchange64 (\r
2f88bd3a
MK
90 IN volatile UINT64 *Value,\r
91 IN UINT64 CompareValue,\r
92 IN UINT64 ExchangeValue\r
720d3c5f 93 )\r
94{\r
95 return *Value != CompareValue ? *Value :\r
2f88bd3a 96 ((*Value = ExchangeValue), CompareValue);\r
720d3c5f 97}\r
98\r
99/**\r
100 Performs an atomic increment of an 32-bit unsigned integer.\r
101\r
102 Performs an atomic increment of the 32-bit unsigned integer specified by\r
103 Value and returns the incremented value. The increment operation must be\r
104 performed using MP safe mechanisms. The state of the return value is not\r
105 guaranteed to be MP safe.\r
106\r
107 @param Value A pointer to the 32-bit value to increment.\r
108\r
109 @return The incremented value.\r
110\r
111**/\r
112UINT32\r
113EFIAPI\r
114InternalSyncIncrement (\r
2f88bd3a 115 IN volatile UINT32 *Value\r
720d3c5f 116 )\r
117{\r
118 return ++*Value;\r
119}\r
120\r
121/**\r
122 Performs an atomic decrement of an 32-bit unsigned integer.\r
123\r
124 Performs an atomic decrement of the 32-bit unsigned integer specified by\r
125 Value and returns the decrement value. The decrement operation must be\r
126 performed using MP safe mechanisms. The state of the return value is not\r
127 guaranteed to be MP safe.\r
128\r
129 @param Value A pointer to the 32-bit value to decrement.\r
130\r
131 @return The decrement value.\r
132\r
133**/\r
134UINT32\r
135EFIAPI\r
136InternalSyncDecrement (\r
2f88bd3a 137 IN volatile UINT32 *Value\r
720d3c5f 138 )\r
139{\r
140 return --*Value;\r
141}\r