diff options
Diffstat (limited to 'gnu-efi/gnu-efi-3.0/lib/ia64/math.c')
-rw-r--r-- | gnu-efi/gnu-efi-3.0/lib/ia64/math.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/gnu-efi/gnu-efi-3.0/lib/ia64/math.c b/gnu-efi/gnu-efi-3.0/lib/ia64/math.c new file mode 100644 index 0000000..a8c4e12 --- /dev/null +++ b/gnu-efi/gnu-efi-3.0/lib/ia64/math.c @@ -0,0 +1,88 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + math.c + +Abstract: + + + + +Revision History + +--*/ + +#include "lib.h" + + +// +// Declare runtime functions +// + +#ifdef RUNTIME_CODE +#ifndef __GNUC__ +#pragma RUNTIME_CODE(LShiftU64) +#pragma RUNTIME_CODE(RShiftU64) +#pragma RUNTIME_CODE(MultU64x32) +#pragma RUNTIME_CODE(DivU64x32) +#endif +#endif + +// +// +// + + + + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +// Left shift 64bit by 32bit and get a 64bit result +{ + return Operand << Count; +} + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +// Right shift 64bit by 32bit and get a 64bit result +{ + return Operand >> Count; +} + + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +// Multiple 64bit by 32bit and get a 64bit result +{ + return Multiplicand * Multiplier; +} + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +// divide 64bit by 32bit and get a 64bit result +// N.B. only works for 31bit divisors!! +{ + ASSERT (Divisor != 0); + + if (Remainder) { + *Remainder = Dividend % Divisor; + } + + return Dividend / Divisor; +} |