summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/BitField.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseLib/BitField.c')
-rw-r--r--MdePkg/Library/BaseLib/BitField.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/MdePkg/Library/BaseLib/BitField.c b/MdePkg/Library/BaseLib/BitField.c
index 0b517aa974..3db8a23c95 100644
--- a/MdePkg/Library/BaseLib/BitField.c
+++ b/MdePkg/Library/BaseLib/BitField.c
@@ -14,6 +14,8 @@
**/
+#include "BaseLibInternals.h"
+
/**
Worker function that returns a bit field from Operand
@@ -763,10 +765,16 @@ BitFieldOr64 (
IN UINT64 OrData
)
{
+ UINT64 Value1;
+ UINT64 Value2;
+
ASSERT (EndBit < sizeof (Operand) * 8);
ASSERT (StartBit <= EndBit);
- return Operand |
- (LShiftU64 (OrData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
+
+ Value1 = LShiftU64 (OrData, StartBit);
+ Value2 = LShiftU64 ((UINT64) - 2, EndBit);
+
+ return Operand | (Value1 & ~Value2);
}
/**
@@ -801,10 +809,16 @@ BitFieldAnd64 (
IN UINT64 AndData
)
{
+ UINT64 Value1;
+ UINT64 Value2;
+
ASSERT (EndBit < sizeof (Operand) * 8);
ASSERT (StartBit <= EndBit);
- return Operand &
- ~(LShiftU64 (~AndData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
+
+ Value1 = LShiftU64 (~AndData, StartBit);
+ Value2 = LShiftU64 ((UINT64)-2, EndBit);
+
+ return Operand & ~(Value1 & ~Value2);
}
/**