diff options
-rw-r--r-- | MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf | 3 | ||||
-rw-r--r-- | MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 9 | ||||
-rw-r--r-- | MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c | 3 |
3 files changed, 10 insertions, 5 deletions
diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf index 20a83ed..8fbdafe 100644 --- a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf +++ b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf @@ -56,3 +56,6 @@ [Packages]
MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseLib
diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c index c5f13d7..e96327d 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c @@ -28,6 +28,7 @@ #include <Base.h>
#include <Library/SafeIntLib.h>
+#include <Library/BaseLib.h>
//
@@ -3373,8 +3374,8 @@ SafeUint64Mult ( // b * c must be less than 2^32 or there would be bits in the high 64-bits
// then there must be no overflow of the resulting values summed up.
//
- DwordA = (UINT32)(Multiplicand >> 32);
- DwordC = (UINT32)(Multiplier >> 32);
+ DwordA = (UINT32)RShiftU64 (Multiplicand, 32);
+ DwordC = (UINT32)RShiftU64 (Multiplier, 32);
//
// common case -- if high dwords are both zero, no chance for overflow
@@ -3409,7 +3410,7 @@ SafeUint64Mult ( // now sum them all up checking for overflow.
// shifting is safe because we already checked for overflow above
//
- if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD << 32, &UnsignedResult))) {
+ if (!RETURN_ERROR (SafeUint64Add (LShiftU64 (ProductBC, 32), LShiftU64 (ProductAD, 32), &UnsignedResult))) {
//
// b * d
//
@@ -4075,7 +4076,7 @@ SafeInt32Mult ( OUT INT32 *Result
)
{
- return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), Result);
+ return SafeInt64ToInt32 (MultS64x64 (Multiplicand, Multiplier), Result);
}
/**
diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c index 18bfb9e..ce66a92 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c @@ -28,6 +28,7 @@ #include <Base.h>
#include <Library/SafeIntLib.h>
+#include <Library/BaseLib.h>
/**
INT32 -> UINTN conversion
@@ -549,6 +550,6 @@ SafeIntnMult ( OUT INTN *Result
)
{
- return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Result);
+ return SafeInt64ToIntn (MultS64x64 (Multiplicand, Multiplier), Result);
}
|