[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: apr_off_t is of an ambiguous size.

From: mark benedetto king <mbk_at_lowlatency.com>
Date: 2004-01-17 15:10:47 CET

On Sat, Jan 17, 2004 at 12:11:36AM -0800, Ben Reser wrote:
> On Sat, Jan 17, 2004 at 12:07:19AM -0500, Greg Hudson wrote:
> > > const apr_off_t min = (apr_off_t) 1 << ((sizeof (apr_off_t)*8)-1);
> >
> > The behavior of this expression is undefined by C99. If we're going
> > to rely on common signed overflow behavior, "if ((apr_off_t) *offset
> > == *offset)" would appear to be simpler.
> >
> > I'm not sure if there's a good way to perform this check which is
> > totally standards-conformant. C99 allows two's-complement,
> > one's-complement, and sign-and-magnitude representation of integers.
> > It would be nice if APR would help us out by defining *_MIN and *_MAX
> > constants for apr_off_t, but it doesn't; moreover, it looks like it
> > would have a difficult job doing so, since there are apparently no
> > system constants for the minimum or maximum off_t value.
>
> I'd say the comparision test looks brilliant. My only concern is will a
> compiler optimize it out?
>

It would take a very smart compiler. Regardless: this is a single compare
and branch; it's not the end of the world.

--ben

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 17 15:13:05 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.