From: Zebediah Figura zfigura@codeweavers.com
Based on a patch by Zhao Yi. --- dlls/ntdll/large_int.c | 7 +++++++ dlls/ntdll/tests/large_int.c | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/large_int.c b/dlls/ntdll/large_int.c index 0faabe0a991..c6f9d64884e 100644 --- a/dlls/ntdll/large_int.c +++ b/dlls/ntdll/large_int.c @@ -20,6 +20,7 @@ */
#include <stdarg.h> +#include <limits.h>
#include "ntstatus.h" #define WIN32_NO_STATUS @@ -812,6 +813,8 @@ ULONGLONG WINAPI _aulldiv( ULONGLONG a, ULONGLONG b )
LONGLONG __regs__allshl( LONGLONG a, unsigned char b ) { + if (b > sizeof(a) * CHAR_BIT) + return 0; return a << b; }
@@ -828,6 +831,8 @@ __ASM_GLOBAL_FUNC( _allshl,
LONGLONG __regs__allshr( LONGLONG a, unsigned char b ) { + if (b > sizeof(a) * CHAR_BIT) + return a >> ((sizeof(a) * CHAR_BIT) - 1); return a >> b; }
@@ -844,6 +849,8 @@ __ASM_GLOBAL_FUNC( _allshr,
ULONGLONG __regs__aullshr( ULONGLONG a, unsigned char b ) { + if (b > sizeof(a) * CHAR_BIT) + return 0; return a >> b; }
diff --git a/dlls/ntdll/tests/large_int.c b/dlls/ntdll/tests/large_int.c index a8f628ae989..128c83299a9 100644 --- a/dlls/ntdll/tests/large_int.c +++ b/dlls/ntdll/tests/large_int.c @@ -519,10 +519,10 @@ static void test_builtins(void) ok(l == 0xbcdef00000000000ll, "got %#I64x\n", l);
l = call_shift_func(p_allshl, 0x0123456789abcdefll, 88); - todo_wine ok(!l, "got %#I64x\n", l); + ok(!l, "got %#I64x\n", l);
l = call_shift_func(p_allshl, 0x0123456789abcdefll, 0x88); - todo_wine ok(!l, "got %#I64x\n", l); + ok(!l, "got %#I64x\n", l);
l = call_shift_func(p_allshl, 0x0123456789abcdefll, 0x108); ok(l == 0x23456789abcdef00ll, "got %#I64x\n", l); @@ -534,7 +534,7 @@ static void test_builtins(void) ok(l == 0x01234ll, "got %#I64x\n", l);
l = call_shift_func(p_allshr, 0x0123456789abcdefll, 88); - todo_wine ok(!l, "got %#I64x\n", l); + ok(!l, "got %#I64x\n", l);
l = call_shift_func(p_allshr, 0x8123456789abcdefll, 12); ok(l == 0xfff8123456789abcll, "got %#I64x\n", l); @@ -543,7 +543,7 @@ static void test_builtins(void) ok(l == 0xfffffffffff81234ll, "got %#I64x\n", l);
l = call_shift_func(p_allshr, 0x8123456789abcdefll, 88); - todo_wine ok(l == -1ll, "got %#I64x\n", l); + ok(l == -1ll, "got %#I64x\n", l);
l = call_shift_func(p_allshr, 0x8123456789abcdefll, 0x108); ok(l == 0xff8123456789abcdll, "got %#I64x\n", l); @@ -555,7 +555,7 @@ static void test_builtins(void) ok(l == 0x81234ll, "got %#I64x\n", l);
l = call_shift_func(p_aullshr, 0x8123456789abcdefll, 88); - todo_wine ok(!l, "got %#I64x\n", l); + ok(!l, "got %#I64x\n", l);
l = call_shift_func(p_aullshr, 0x8123456789abcdefll, 0x108); ok(l == 0x8123456789abcdll, "got %#I64x\n", l);