2 Leaf math worker functions that require 64-bit arithmetic support from the
5 Copyright (c) 2006, Intel Corporation<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 InternalMathLShiftU64 (
25 return Operand
<< Count
;
30 InternalMathRShiftU64 (
35 return Operand
>> Count
;
40 InternalMathARShiftU64 (
46 // Test if this compiler supports arithmetic shift
48 if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) {
50 // Arithmetic shift is supported
52 return (UINT64
)((INT64
)Operand
>> Count
);
56 // Arithmetic is not supported
58 return (Operand
>> Count
) |
59 ((INTN
)Operand
< 0 ? ~((UINTN
)-1 >> Count
) : 0);
69 return (Operand
<< Count
) | (Operand
>> (64 - Count
));
79 return (Operand
>> Count
) | (Operand
<< (64 - Count
));
84 InternalMathSwapBytes64 (
89 ((UINT64
)SwapBytes32 ((UINT32
)Operand
) << 32) |
90 ((UINT64
)SwapBytes32 ((UINT32
)(Operand
>> 32)))
96 InternalMathMultU64x32 (
97 IN UINT64 Multiplicand
,
101 return Multiplicand
* Multiplier
;
106 InternalMathMultU64x64 (
107 IN UINT64 Multiplicand
,
111 return Multiplicand
* Multiplier
;
116 InternalMathDivU64x32 (
121 return Dividend
/ Divisor
;
126 InternalMathModU64x32 (
131 return Dividend
% Divisor
;
136 InternalMathDivRemU64x32 (
139 OUT UINT32
*Remainder
142 if (Remainder
!= NULL
) {
143 *Remainder
= (UINT32
)(Dividend
% Divisor
);
145 return Dividend
/ Divisor
;
150 InternalMathDivRemU64x64 (
153 OUT UINT64
*Remainder
156 if (Remainder
!= NULL
) {
157 *Remainder
= Dividend
% Divisor
;
159 return Dividend
/ Divisor
;
164 InternalMathDivRemS64x64 (
170 if (Remainder
!= NULL
) {
171 *Remainder
= Dividend
% Divisor
;
173 return Dividend
/ Divisor
;