THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
- Module Name: Math64.c\r
-\r
**/\r
\r
+\r
+\r
+\r
+#include "BaseLibInternals.h"\r
+\r
/**\r
- Worker functons that shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
+ Shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
are filled with zeros. The shifted value is returned.\r
\r
This function shifts the 64-bit value Operand to the left by Count bits. The\r
\r
**/\r
UINT64\r
+EFIAPI\r
InternalMathLShiftU64 (\r
IN UINT64 Operand,\r
IN UINTN Count\r
}\r
\r
/**\r
- Worker functon that shifts a 64-bit integer right between 0 and 63 bits. This high bits\r
+ Shifts a 64-bit integer right between 0 and 63 bits. This high bits\r
are filled with zeros. The shifted value is returned.\r
\r
This function shifts the 64-bit value Operand to the right by Count bits. The\r
}\r
\r
/**\r
- Worker function that shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
+ Shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
are filled with original integer's bit 63. The shifted value is returned.\r
\r
This function shifts the 64-bit value Operand to the right by Count bits. The\r
IN UINTN Count\r
)\r
{\r
+ INTN TestValue;\r
+\r
//\r
// Test if this compiler supports arithmetic shift\r
//\r
- if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) {\r
+ TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));\r
+ if (TestValue == -1) {\r
//\r
// Arithmetic shift is supported\r
//\r
\r
\r
/**\r
- Worker function that rotates a 64-bit integer left between 0 and 63 bits, filling \r
+ Rotates a 64-bit integer left between 0 and 63 bits, filling\r
the low bits with the high bits that were rotated.\r
\r
This function rotates the 64-bit value Operand to the left by Count bits. The\r
}\r
\r
/**\r
- Worker function that rotates a 64-bit integer right between 0 and 63 bits, filling\r
+ Rotates a 64-bit integer right between 0 and 63 bits, filling\r
the high bits with the high low bits that were rotated.\r
\r
This function rotates the 64-bit value Operand to the right by Count bits.\r
}\r
\r
/**\r
- Worker function that switches the endianess of a 64-bit integer.\r
+ Switches the endianess of a 64-bit integer.\r
\r
This function swaps the bytes in a 64-bit unsigned value to switch the value\r
from little endian to big endian or vice versa. The byte swapped value is\r
IN UINT64 Operand\r
)\r
{\r
- return (UINT64)(\r
- ((UINT64)SwapBytes32 ((UINT32)Operand) << 32) |\r
- ((UINT64)SwapBytes32 ((UINT32)(Operand >> 32)))\r
- );\r
+ UINT64 LowerBytes;\r
+ UINT64 HigherBytes;\r
+\r
+ LowerBytes = (UINT64) SwapBytes32 ((UINT32) Operand);\r
+ HigherBytes = (UINT64) SwapBytes32 ((UINT32) (Operand >> 32));\r
+\r
+ return (LowerBytes << 32 | HigherBytes);\r
}\r
\r
/**\r
- Worker function that multiples a 64-bit unsigned integer by a 32-bit unsigned integer\r
+ Multiples a 64-bit unsigned integer by a 32-bit unsigned integer\r
and generates a 64-bit unsigned result.\r
\r
This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
\r
\r
/**\r
- Worker function that multiples a 64-bit unsigned integer by a 64-bit unsigned integer\r
+ Multiples a 64-bit unsigned integer by a 64-bit unsigned integer\r
and generates a 64-bit unsigned result.\r
\r
This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
}\r
\r
/**\r
- Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
generates a 64-bit unsigned result.\r
- \r
+\r
This function divides the 64-bit unsigned value Dividend by the 32-bit\r
unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
function returns the 64-bit unsigned quotient.\r
}\r
\r
/**\r
- Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer\r
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer\r
and generates a 32-bit unsigned remainder.\r
\r
This function divides the 64-bit unsigned value Dividend by the 32-bit\r
\r
**/\r
UINT32\r
+EFIAPI\r
InternalMathModU64x32 (\r
IN UINT64 Dividend,\r
IN UINT32 Divisor\r
}\r
\r
/**\r
- Worker function that divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
\r
This function divides the 64-bit unsigned value Dividend by the 32-bit\r
\r
**/\r
UINT64\r
+EFIAPI\r
InternalMathDivRemU64x32 (\r
IN UINT64 Dividend,\r
IN UINT32 Divisor,\r
}\r
\r
/**\r
- Worker function that divides a 64-bit unsigned integer by a 64-bit unsigned integer and \r
+ Divides a 64-bit unsigned integer by a 64-bit unsigned integer and\r
generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
\r
This function divides the 64-bit unsigned value Dividend by the 64-bit\r
\r
**/\r
UINT64\r
+EFIAPI\r
InternalMathDivRemU64x64 (\r
IN UINT64 Dividend,\r
IN UINT64 Divisor,\r
}\r
\r
/**\r
- Worker function that divides a 64-bit signed integer by a 64-bit signed integer and \r
+ Divides a 64-bit signed integer by a 64-bit signed integer and\r
generates a 64-bit signed result and a optional 64-bit signed remainder.\r
\r
This function divides the 64-bit unsigned value Dividend by the 64-bit\r
\r
**/\r
INT64\r
+EFIAPI\r
InternalMathDivRemS64x64 (\r
IN INT64 Dividend,\r
IN INT64 Divisor,\r