]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failure
authorDandan Bi <dandan.bi@intel.com>
Mon, 26 Feb 2018 03:55:15 +0000 (11:55 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 28 Feb 2018 03:44:14 +0000 (11:44 +0800)
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>
MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
MdePkg/Library/BaseSafeIntLib/SafeIntLib.c
MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c

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