Commit bc270a54 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntdll: Correctly handle shift greater than the type width in 64-bit shift functions.

Based on a patch by Zhao Yi.
parent 9ef72462
......@@ -817,6 +817,9 @@ LONGLONG __stdcall __regs__allshl( LONGLONG a, unsigned char b )
if (b >= 32)
{
if (b >= 64)
ret.HighPart = 0;
else
ret.HighPart = x.LowPart << (b & 31);
ret.LowPart = 0;
}
......@@ -847,6 +850,9 @@ LONGLONG __stdcall __regs__allshr( LONGLONG a, unsigned char b )
if (b >= 32)
{
ret.HighPart = x.HighPart >> 31;
if (b >= 64)
ret.LowPart = x.HighPart >> 31;
else
ret.LowPart = x.HighPart >> (b & 31);
}
else
......@@ -876,6 +882,9 @@ ULONGLONG __stdcall __regs__aullshr( ULONGLONG a, unsigned char b )
if (b >= 32)
{
ret.HighPart = 0;
if (b >= 64)
ret.LowPart = 0;
else
ret.LowPart = x.HighPart >> (b & 31);
}
else
......
......@@ -526,10 +526,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);
......@@ -541,7 +541,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);
......@@ -550,7 +550,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);
......@@ -562,7 +562,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);
......
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