summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2018-02-26 11:55:15 +0800
committerLiming Gao <liming.gao@intel.com>2018-02-28 11:44:14 +0800
commitdc9b2a57403262cf6df9d150ea3a118a7d765ad8 (patch)
tree4a191454ab1b8d5e5afc448e305e829a2a9ed408 /MdePkg
parent97e1ff1b913bdedcf08c0d1917d488e0097759b7 (diff)
downloadedk2-dc9b2a57403262cf6df9d150ea3a118a7d765ad8.tar.gz
edk2-dc9b2a57403262cf6df9d150ea3a118a7d765ad8.tar.bz2
edk2-dc9b2a57403262cf6df9d150ea3a118a7d765ad8.zip
MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failure
v2: Add [LibraryClasses] section in INF file and refine coding style. There are VS2015 NOOPT IA32 build failure like below in BaseSafeIntLib. XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allmul XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allshl XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __aullshr This patch replaces direct shift/multiplication of 64-bit integer with related function call to fix these failure. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf3
-rw-r--r--MdePkg/Library/BaseSafeIntLib/SafeIntLib.c9
-rw-r--r--MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c3
3 files changed, 10 insertions, 5 deletions
diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
index 20a83ed97b..8fbdafe748 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 c5f13d7e08..e96327d134 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 18bfb9e413..ce66a92293 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);
}