Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Apr 2001 00:43:14 -0400 (EDT)
From:      "T. William Wells" <bill@twwells.com>
To:        dillon@earth.backplane.com (Matt Dillon)
Cc:        freebsd-bugs@freebsd.org
Subject:   Re: ntpd patch
Message-ID:  <E14lO5a-000Iy9-00@twwells.com>
In-Reply-To: <200104060410.f364AmX37732@earth.backplane.com> from "Matt Dillon" at Apr 05, 2001 09:10:48 PM

next in thread | previous in thread | raw e-mail | index | archive | help
>     I really doubt any FreeBSD utility would actually run on a 1's
>     complement machine anyway, so there is no particular reason to
>     try to support it,

Odds are, this is true. OTOH, suppose someone else took up the
patch and applied it elsewhere? It would be nice if it actually
did work right. And, who knows? Maybe someone will try to port
*BSD to a Univac someday. :)

>     try to support it, and gcc will have no problem optimizing
>     (unsigned char)*ptr verses *(unsigned char *)ptr...

One would hope.

>     there is a very good chance that both would produce exactly the
>     same code as a result, even without using any optimization flags.
>     Casts are one of the easiest optimizations a C compiler can make.

You'd think. However, back when I did a lot of portable
programming, one thing I found is that compilers, especially when
run without optimization, could produce some really gawdawful
code. For example, I've seen (unsigned char)(int_expression)
generate an 'and 0xFF' instruction whether it needs it or not.

Just for amusement, I went ahead and looked to see what gcc
(without optimization) would do. For my test case, the two
produced identical code. But they both *also* generated code with
a movl %eax,%eax that served absolutely no purpose at all. :)

But really all that is beside the point -- the difference between
the two is trivial to code and one *is* correct, both
theoretically and practically, but the other only correct in
practice -- today's practice that is. If it involved any
significant effort to do it the completely correct way, I wouldn't
be arguing the point. But since it doesn't....

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E14lO5a-000Iy9-00>