From owner-freebsd-current Fri Oct 27 22:14:13 2000 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 6EA9137B4D7; Fri, 27 Oct 2000 22:14:08 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id QAA28917; Sat, 28 Oct 2000 16:13:58 +1100 Date: Sat, 28 Oct 2000 16:13:46 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Ruslan Ermilov Cc: Mike Smith , Bruce Evans , Konstantin Chuguev , Brian Somers , kargl@apl.washington.edu, freebsd-current@FreeBSD.org Subject: Re: platform byte order macros? In-Reply-To: <20001027182758.A41742@sunbay.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. 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