Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Oct 2000 16:13:46 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Ruslan Ermilov <ru@FreeBSD.org>
Cc:        Mike Smith <msmith@mass.osd.bsdi.com>, Bruce Evans <bde@FreeBSD.org>, Konstantin Chuguev <Konstantin.Chuguev@dante.org.uk>, Brian Somers <brian@Awfulhak.org>, kargl@apl.washington.edu, freebsd-current@FreeBSD.org
Subject:   Re: platform byte order macros?
Message-ID:  <Pine.BSF.4.21.0010281555100.49427-100000@besplex.bde.org>
In-Reply-To: <20001027182758.A41742@sunbay.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 27 Oct 2000, Ruslan Ermilov wrote:

> On Fri, Oct 27, 2000 at 06:11:49PM +0300, Ruslan Ermilov wrote:
> > On Fri, Oct 27, 2000 at 07:34:06AM -0700, Mike Smith wrote:
> > > > +#ifdef __OPTIMIZE__
> > > 
> > > Using macros does not "optimise" anything,

Not quite true.  Using inline functions pessimizes everything that is
compiled without -O since the functions don't get inlined but code
for them is generated in each object file whether or not they are
used.  <sys/types.h> is included a lot, so having inline functions in
it is especially pessimal for the -O0 case.

> > >   and this is a very poor choice 
> > > of defines.  __MACRO_ENDIAN_CONVERSIONS might be better.

__OPTIMIZE__ is the standard gcc macro for telling whether gcc has been
invoked with -O.  It is used sort of backwards here.  There is no reason
to turn off the macros for constants, but turning off the inlines for
non-constants would fix the useless bloat in the -O0 case.

Is the htonl() family used enough on constants for the constant case to
be worth optimizing?

Writing the byte swapping using shifts and masks might be best in all
cases.  The compiler can in theory reduce shifts and masks to bswap on
i386's if that is best, but it can't look inside asm statements.

Bruce



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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0010281555100.49427-100000>