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