]>
Commit | Line | Data |
---|---|---|
f1baef62 | 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 | |
f1baef62 | 13 | **/\r |
14 | \r | |
15 | #include "BaseLibInternals.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
19 | \r | |
20 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
21 | Value and returns the incremented value. The increment operation must be\r | |
22 | performed using MP safe mechanisms. The state of the return value is not\r | |
23 | guaranteed to be MP safe.\r | |
24 | \r | |
25 | @param Value A pointer to the 32-bit value to increment.\r | |
26 | \r | |
27 | @return The incremented value.\r | |
28 | \r | |
29 | **/\r | |
30 | UINT32\r | |
31 | EFIAPI\r | |
32 | InternalSyncIncrement (\r | |
33 | IN volatile UINT32 *Value\r | |
34 | )\r | |
35 | {\r | |
36 | UINT32 OriginalValue;\r | |
37 | \r | |
38 | do {\r | |
39 | OriginalValue = *Value;\r | |
40 | } while (OriginalValue != InternalSyncCompareExchange32 (\r | |
41 | Value,\r | |
42 | OriginalValue,\r | |
43 | OriginalValue + 1\r | |
44 | ));\r | |
45 | return OriginalValue + 1;\r | |
46 | }\r | |
47 | \r | |
48 | /**\r | |
49 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
50 | \r | |
51 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
52 | Value and returns the decrement value. The decrement operation must be\r | |
53 | performed using MP safe mechanisms. The state of the return value is not\r | |
54 | guaranteed to be MP safe.\r | |
55 | \r | |
56 | @param Value A pointer to the 32-bit value to decrement.\r | |
57 | \r | |
58 | @return The decrement value.\r | |
59 | \r | |
60 | **/\r | |
61 | UINT32\r | |
62 | EFIAPI\r | |
63 | InternalSyncDecrement (\r | |
64 | IN volatile UINT32 *Value\r | |
65 | )\r | |
66 | {\r | |
67 | UINT32 OriginalValue;\r | |
68 | \r | |
69 | do {\r | |
70 | OriginalValue = *Value;\r | |
71 | } while (OriginalValue != InternalSyncCompareExchange32 (\r | |
72 | Value,\r | |
73 | OriginalValue,\r | |
74 | OriginalValue - 1\r | |
75 | ));\r | |
76 | return OriginalValue - 1;\r | |
77 | }\r |