mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
97e1ff1b91
commit
dc9b2a5740
|
@ -56,3 +56,6 @@
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
#include <Library/SafeIntLib.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
|
// 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.
|
// then there must be no overflow of the resulting values summed up.
|
||||||
//
|
//
|
||||||
DwordA = (UINT32)(Multiplicand >> 32);
|
DwordA = (UINT32)RShiftU64 (Multiplicand, 32);
|
||||||
DwordC = (UINT32)(Multiplier >> 32);
|
DwordC = (UINT32)RShiftU64 (Multiplier, 32);
|
||||||
|
|
||||||
//
|
//
|
||||||
// common case -- if high dwords are both zero, no chance for overflow
|
// 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.
|
// now sum them all up checking for overflow.
|
||||||
// shifting is safe because we already checked for overflow above
|
// 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
|
// b * d
|
||||||
//
|
//
|
||||||
|
@ -4075,7 +4076,7 @@ SafeInt32Mult (
|
||||||
OUT INT32 *Result
|
OUT INT32 *Result
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), Result);
|
return SafeInt64ToInt32 (MultS64x64 (Multiplicand, Multiplier), Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <Base.h>
|
#include <Base.h>
|
||||||
#include <Library/SafeIntLib.h>
|
#include <Library/SafeIntLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
INT32 -> UINTN conversion
|
INT32 -> UINTN conversion
|
||||||
|
@ -549,6 +550,6 @@ SafeIntnMult (
|
||||||
OUT INTN *Result
|
OUT INTN *Result
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Result);
|
return SafeInt64ToIntn (MultS64x64 (Multiplicand, Multiplier), Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue