Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 03 Jul 2013 11:23:00 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        attilio@FreeBSD.org, svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: should_yield problem [Was: svn commit: r251322 - head/sys/kern]
Message-ID:  <51D3DF64.8040500@FreeBSD.org>
In-Reply-To: <20130703134115.C1064@besplex.bde.org>
References:  <201306031736.r53Hain5093431@svn.freebsd.org> <51D30463.50608@FreeBSD.org> <CAJ-FndD5tCxe-L8V73MFtk_4xr0Wq3MHasKY4O_tcA3uYouKAw@mail.gmail.com> <51D30CE8.7030803@FreeBSD.org> <CAJ-FndATxzTwCkZGXw4jD_8O4KbnHbsjk4DwHwbp%2B0gd3VGTCQ@mail.gmail.com> <51D31724.6090807@FreeBSD.org> <20130703134115.C1064@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
on 03/07/2013 07:40 Bruce Evans said the following:
> On Tue, 2 Jul 2013, Andriy Gapon wrote:
>> distance = (signed)( i1 - i2 )
> 
> With 2's complement and benign overflow, this is no different from
> 'distance = i1 - i2'.

Given the particular context I'd say that there is a difference.

> But signed counters are not wanted here.  A
> negative distance, or equivalently with 32-bit unsigned ints, an unsigned
> difference of >= 0x80000000 means overflow or an initialization error.
> Your bug is an initialization error.

Right.  But I'd rather produce a positive (unsigned) number than a negative
number when such an error happens (and is detectable).  Again, I am speaking
about the concrete context.

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51D3DF64.8040500>