[PATCH] msvcp120: Fix _Xtime_diff_to_millis2 overflow behavior.

Piotr Caban piotr.caban at gmail.com
Fri Oct 13 02:46:04 CDT 2017


> On 12 Oct 2017, at 20:07, Stefan Dösinger <stefan at codeweavers.com> wrote:
> 
> Am 2017-10-12 um 11:32 schrieb Piotr Caban:
>> On 10/11/17 17:07, Stefan Dösinger wrote:
>>> +        {0x7FFFFFFFFFFFFFFF, 0, 0x7FFFFFFFFFFFFFFD, 0, 0}, /* Not an
>>> overflow */
>> Defining LONGLONG constants this way is not portable.
> Any better way? Does (LONGLONG)0x7FFFFFFFFFFFFFFF work, or do I need
> something more elaborate? The information I can find online points to
> C99 :-\ .
You can use ((LONGLONG)0x7fffffff << 32) | 0xffffffff or _I64_MAX here.

>> It looks like the function should be treating negative time differences
>> in special way. Except of that it seems to be ignoring overflows. I
>> think that following code is much easier to read. Is something like this
>> working for you?
> Your code looks more elegant than mine for sure, and I believe it should
> work. I'll double check it with WGC to be on the safe side.
> 
> As I've mentioned in the patch description I think native uses 128 bit
> integers, probably through
> https://msdn.microsoft.com/en-us/library/windows/desktop/hh802931(v=vs.85).aspx
> or
> https://msdn.microsoft.com/en-us/library/windows/desktop/82cxdw50(v=vs.85).aspx
> . Unfortunately neither function is currently implemented in Wine. The
> MS headers suggest that they are msvc compiler intrinsics.
I don’t see why 128-bit operations should be needed here.

Thanks,
Piotr




More information about the wine-devel mailing list