Commit 8f144eb5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntdll: Reimplement _alldiv using 32-bit arithmetic.

Based on compiler-rt. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 744843ed
......@@ -736,7 +736,12 @@ static ULONGLONG udivmod(ULONGLONG a, ULONGLONG b, ULONGLONG *rem)
*/
LONGLONG WINAPI _alldiv( LONGLONG a, LONGLONG b )
{
return a / b;
LONGLONG s_a = a >> 63; /* s_a = a < 0 ? -1 : 0 */
LONGLONG s_b = b >> 63; /* s_b = b < 0 ? -1 : 0 */
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
s_a ^= s_b; /* sign of quotient */
return (udivmod(a, b, NULL) ^ s_a) - s_a; /* negate if s_a == -1 */
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment