From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzpOO-0006q3-RG for qemu-devel@nongnu.org; Tue, 21 Feb 2012 08:04:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzpON-0001rX-Mu for qemu-devel@nongnu.org; Tue, 21 Feb 2012 08:04:28 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:63935) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzpON-0001r3-Fp for qemu-devel@nongnu.org; Tue, 21 Feb 2012 08:04:27 -0500 From: Paul Brook Date: Tue, 21 Feb 2012 13:04:17 +0000 References: <4468eade8e51e235bc98a60b926e1e6a5657c5aa.1329702076.git.peter.crosthwaite@petalogix.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201202211304.18584.paul@codesourcery.com> Subject: Re: [Qemu-devel] [PATCH v6 2/4] cadence_ttc: initial version of device model List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: monstr@monstr.eu, qemu-devel@nongnu.org, John Linn , "Peter A. G. Crosthwaite" , duyl@xilinx.com, linnj@xilinx.com, edgar.iglesias@gmail.com, afaerber@suse.de, john.williams@petalogix.com > > +static inline int64_t is_between(int64_t x, int64_t a, int64_t b) > > +{ > > + if (a < b) { > > + return x > a && x <= b; > > + } > > + return x < a && x >= b; > > +} > > This looks slightly odd -- should the boundary condition for whether > a value equal to the max/min really change depending on :whether a > or b is greater? This is a ugly hack. Instead of figuring out whether we have a count-up or count-down timer the code checks for both, and have the "in_between" function magically DTRT. I haven't followed the paths through in enough detail to figure out whether it gets all the corner cases right. Paul