mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
Build: Improve IA32 compat based on @nms42 patches
closes acidanthera/bugtracker#645 closes acidanthera/bugtracker#646 closes acidanthera/bugtracker#647
This commit is contained in:
parent
e1c7748751
commit
867000cd07
@ -605,7 +605,7 @@ InternalCalculateTargetsIntel64 (
|
||||
|
||||
TargetAddress = ALIGN_VALUE (
|
||||
(Section->Address + LoadAddress),
|
||||
(UINT64)(1U << Section->Alignment)
|
||||
LShiftU64 (1, Section->Alignment)
|
||||
);
|
||||
TargetAddress -= Section->Address;
|
||||
}
|
||||
@ -816,7 +816,7 @@ InternalRelocateRelocationIntel64 (
|
||||
case MachX8664RelocGot:
|
||||
case MachX8664RelocGotLoad:
|
||||
{
|
||||
Adjustment = (1ULL << Length);
|
||||
Adjustment = LShiftU64 (1, Length);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -107,8 +107,7 @@ u_int32_t decompress_lzss(
|
||||
}
|
||||
|
||||
dst = dststart;
|
||||
for (i = 0; i < N - F; i++)
|
||||
text_buf[i] = ' ';
|
||||
memset(text_buf, ' ', N - F);
|
||||
r = N - F;
|
||||
flags = 0;
|
||||
for ( ; ; ) {
|
||||
@ -149,16 +148,10 @@ u_int32_t decompress_lzss(
|
||||
* Note there are 256 trees. */
|
||||
static void init_state(struct encode_state *sp)
|
||||
{
|
||||
int i;
|
||||
|
||||
bzero(sp, sizeof(*sp));
|
||||
|
||||
for (i = 0; i < N - F; i++)
|
||||
sp->text_buf[i] = ' ';
|
||||
for (i = N + 1; i <= N + 256; i++)
|
||||
sp->rchild[i] = NIL;
|
||||
for (i = 0; i < N; i++)
|
||||
sp->parent[i] = NIL;
|
||||
memset(&sp->text_buf[0], ' ', N - F);
|
||||
bzero(&sp->rchild[N + 1], 256 * sizeof(sp->rchild[0]));
|
||||
bzero(&sp->parent[0], N * sizeof(sp->parent[0]));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -30,6 +30,10 @@ typedef INT32 int32_t;
|
||||
#define compress_lzss CompressLZSS
|
||||
#define decompress_lzss DecompressLZSS
|
||||
|
||||
#ifdef memset
|
||||
#undef memset
|
||||
#endif
|
||||
|
||||
#ifdef bzero
|
||||
#undef bzero
|
||||
#endif
|
||||
@ -42,6 +46,7 @@ typedef INT32 int32_t;
|
||||
#undef free
|
||||
#endif
|
||||
|
||||
#define memset(Dst, Val, Size) SetMem ((Dst), (Size), (Val))
|
||||
#define bzero(Dst, Size) ZeroMem ((Dst), (Size))
|
||||
#define malloc(Size) AllocatePool (Size)
|
||||
#define free(Ptr) FreePool (Ptr)
|
||||
|
||||
@ -1411,7 +1411,7 @@ OcCpuScanProcessor (
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "OCCPU: %a %a\n", "Found", Cpu->BrandString));
|
||||
DEBUG ((DEBUG_INFO, "OCCPU: Found %a\n", Cpu->BrandString));
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
|
||||
@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/OcGuardLib.h>
|
||||
|
||||
//
|
||||
@ -122,7 +123,7 @@ BOOLEAN
|
||||
{
|
||||
INT64 Temp;
|
||||
|
||||
Temp = (INT64) A * B;
|
||||
Temp = MultS64x64 (A, B);
|
||||
*Result = (INT32) Temp;
|
||||
if (Temp >= MIN_INT32 && Temp <= MAX_INT32) {
|
||||
return FALSE;
|
||||
@ -186,23 +187,23 @@ BOOLEAN
|
||||
// Implements overflow checking by a series of up to 3 multiplications.
|
||||
//
|
||||
|
||||
AHi = A >> 32ULL;
|
||||
AHi = RShiftU64 (A, 32);
|
||||
ALo = A & MAX_UINT32;
|
||||
BHi = B >> 32ULL;
|
||||
BHi = RShiftU64 (B, 32);
|
||||
BLo = B & MAX_UINT32;
|
||||
|
||||
LoBits = ALo * BLo;
|
||||
LoBits = MultU64x64 (ALo, BLo);
|
||||
if (AHi == 0 && BHi == 0) {
|
||||
*Result = LoBits;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Overflow = AHi > 0 && BHi > 0;
|
||||
HiBits1 = ALo * BHi;
|
||||
HiBits2 = AHi * BLo;
|
||||
HiBits1 = MultU64x64 (ALo, BHi);
|
||||
HiBits2 = MultU64x64 (AHi, BLo);
|
||||
|
||||
*Result = LoBits + ((HiBits1 + HiBits2) << 32ULL);
|
||||
return Overflow || *Result < LoBits || (HiBits1 >> 32ULL) != 0 || (HiBits2 >> 32ULL) != 0;
|
||||
*Result = LoBits + LShiftU64 (HiBits1 + HiBits2, 32);
|
||||
return Overflow || *Result < LoBits || RShiftU64 (HiBits1, 32) != 0 || RShiftU64 (HiBits2, 32) != 0;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user