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