[PATCH v3 1/4] ntdll: Fix the calling convention for runtime 64-bit shift functions.

Jinoh Kang jinoh.kang.kr at gmail.com
Thu Jul 7 06:31:55 CDT 2022


On 7/7/22 15:51, Dmitry Timoshkov wrote:
> Zebediah Figura <wine at gitlab.winehq.org> wrote:
> 
>> --- a/dlls/ntdll/ntdll.spec
>> +++ b/dlls/ntdll/ntdll.spec
>> @@ -1492,13 +1492,13 @@
>>  @ cdecl -norelay -arch=i386 -ret64 _allmul(int64 int64)
>>  @ cdecl -arch=i386 -norelay _alloca_probe()
>>  @ cdecl -norelay -arch=i386 -ret64 _allrem(int64 int64)
>> -@ stdcall -arch=i386 -ret64 _allshl(int64 long)
>> -@ stdcall -arch=i386 -ret64 _allshr(int64 long)
>> +@ cdecl -norelay -arch=i386 -ret64 _allshl(int64 long)
>> +@ cdecl -norelay -arch=i386 -ret64 _allshr(int64 long)
>>  @ cdecl -ret64 _atoi64(str)
>>  @ cdecl -norelay -arch=i386 -ret64 _aulldiv(int64 int64)
>>  @ cdecl -arch=i386 -norelay _aulldvrm(int64 int64)
>>  @ cdecl -norelay -arch=i386 -ret64 _aullrem(int64 int64)
>> -@ stdcall -arch=i386 -ret64 _aullshr(int64 long)
>> +@ cdecl -norelay -arch=i386 -ret64 _aullshr(int64 long)
>>  @ cdecl -arch=i386 -norelay _chkstk()
>>  @ stub _fltused
>>  @ cdecl -arch=i386 -ret64 _ftol()
>> diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
>> index 8b0ee1c4b51..460d7d0459f 100644
>> --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
>> +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
>> @@ -1540,12 +1540,12 @@
>>  @ cdecl -arch=i386 -norelay -ret64 _allmul(int64 int64)
>>  @ cdecl -arch=i386 -norelay _alloca_probe()
>>  @ cdecl -arch=i386 -norelay -ret64 _allrem(int64 int64)
>> -@ stdcall -arch=i386 -ret64 _allshl(int64 long)
>> -@ stdcall -arch=i386 -ret64 _allshr(int64 long)
>> +@ cdecl -arch=i386 -norelay -ret64 _allshl(int64 long)
>> +@ cdecl -arch=i386 -norelay -ret64 _allshr(int64 long)
>>  @ cdecl -arch=i386 -norelay -ret64 _aulldiv(int64 int64)
>>  @ cdecl -arch=i386 -norelay _aulldvrm(int64 int64)
>>  @ cdecl -arch=i386 -norelay -ret64 _aullrem(int64 int64)
>> -@ stdcall -arch=i386 -ret64 _aullshr(int64 long)
>> +@ cdecl -arch=i386 -norelay -ret64 _aullshr(int64 long)
>>  @ cdecl -arch=i386 -norelay _chkstk()
>>  @ cdecl -arch=i386 _except_handler2(ptr ptr ptr ptr)
>>  @ cdecl -arch=i386 _except_handler3(ptr ptr ptr ptr)
> 
> According to the tests these APIs use stdcall calling convention,

The functions are neither cdecl nor stdcall.  They use a custom calling convention where
arguments are passed in the order EAX (low 32-bit), EDX (high 32-bit), and ECX (shift amount).

> what is the reason to change them to cdecl in the spec? Existing
> spec entries also break that rule though...

Because the functions don't really "pop off" arguments from the stack.


-- 
Sincerely,
Jinoh Kang



More information about the wine-devel mailing list