ntdll: Reimplement _allrem using 32-bit arithmetic.

Based on compiler-rt.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-06-08 18:12:27 +02:00 committed by Alexandre Julliard
parent 8f144eb566
commit 0547da64a3
1 changed files with 7 additions and 1 deletions

View File

@ -777,7 +777,13 @@ LONGLONG WINAPI _allmul( LONGLONG a, LONGLONG b )
*/
LONGLONG WINAPI _allrem( LONGLONG a, LONGLONG b )
{
return a % b;
LONGLONG s = b >> 63; /* s = b < 0 ? -1 : 0 */
ULONGLONG r;
b = (b ^ s) - s; /* negate if s == -1 */
s = a >> 63; /* s = a < 0 ? -1 : 0 */
a = (a ^ s) - s; /* negate if s == -1 */
udivmod(a, b, &r);
return ((LONGLONG)r ^ s) - s; /* negate if s == -1 */
}