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