Am 21.02.2017 20:28, schrieb Mihail Konev: > On Tue, Feb 21, 2017 at 05:48:19PM +0100, walter harms wrote: >>> >> >> XSyncValueSubtract is doing as expected, >> XSyncValue is the simulation of 64bitvalues on 32bit. >> see this in hex: >> 100000001 >> -000000002 >> 0FFFFFFFF = 4294967295 in .lo >> > > Kind of - it errorneously returns > > 1 0000 0001 > -0 0000 0002 > 1 ffff ffff > > Test source attached. > > I.e. > XSyncValueSubtract should handle the .lo becoming <0, > and it checks only for .lo_after_subtract < .lo, > which would only be aplicable to uint. > > E.g. there is a typo in XSyncValue.lo definition - it should be uint > instead. > Also in ServertimeBlockHandler, "timeout" is unsigned, > while it is get from signed .lo and used as signed arg to > AdjustWaitForTimeout.
yep, i noticed that "int t = (a).lo;" and was confused. But the experiments showed is seems to work. #define _XSyncValueSubtract(presult,a,b,poverflow) {\ int t = (a).lo;\ Bool signa = XSyncValueIsNegative(a);\ Bool signb = XSyncValueIsNegative(b);\ ((presult)->lo = (a).lo - (b).lo);\ ((presult)->hi = (a).hi - (b).hi);\ if (t>(presult)->lo) (presult)->hi--;\ *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presu lt)));\ } my test code: #include <stdio.h> #include <X11/Xlibint.h> #include <X11/extensions/sync.h> // gcc xsync.c -lXext int main() { XSyncValue a,b,c; XSyncValue result; Bool ov; XSyncIntToValue(&a, 100); XSyncIntToValue(&b, 200); XSyncValueSubtract(&result, b, a, &ov); printf("result.hi = %d, result.lo = %d, overflow = %d\n", result.hi, result.lo, ov); } I did not look at the asm level but the interessting question is: can that be replace by int64_t ? is it done somewhere else ? re, wh > > Perhaps also: > AdjustWaitForTimeout should not be used if overflow != 0 > Because something is wrong then as (pnext_time < Now) ? > > Mihail _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel