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