Date: Fri, 27 Oct 2000 18:11:49 +0300 From: Ruslan Ermilov <ru@FreeBSD.org> To: Mike Smith <msmith@mass.osd.bsdi.com> Cc: 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: <20001027181149.B39062@sunbay.com> In-Reply-To: <200010271434.e9REY6F00412@mass.osd.bsdi.com>; from msmith@mass.osd.bsdi.com on Fri, Oct 27, 2000 at 07:34:06AM -0700 References: <20001027160724.A29559@sunbay.com> <200010271434.e9REY6F00412@mass.osd.bsdi.com>
index | next in thread | previous in thread | raw e-mail
On Fri, Oct 27, 2000 at 07:34:06AM -0700, Mike Smith wrote:
> > On Fri, Oct 27, 2000 at 09:49:57PM +1100, Bruce Evans wrote:
> > [...]
> > >
> > > NetBSD supports the ntohl family on constants, but only on some arches
> > > (at least in last year's version). It takes fancier macros to support
> > > constants. This gives an excuse to change the inline functions back to
> > > macros :-).
> > >
> > Cool! My upcoming byte-swapping changes to IPv4 code would benefit from
> > having these macros. Could you please review the attached patch (it was
> > obtained from NetBSD)?
> ...
> > +#ifdef __OPTIMIZE__
>
> Using macros does not "optimise" anything, and this is a very poor choice
> of defines. __MACRO_ENDIAN_CONVERSIONS might be better.
>
Huh, you would not call this optimization?!
#include <sys/types.h>
#include <stdio.h>
void
foo(void)
{
printf("%hx\n", htons(0x80));
}
--- a.s.without Fri Oct 27 18:11:26 2000
+++ a.s.with Fri Oct 27 18:11:59 2000
@@ -13,12 +13,7 @@
movl %esp,%ebp
subl $8,%esp
addl $-8,%esp
- movl $128,%eax
-#APP
- xchgb %ah, %al
-#NO_APP
- andl $65535,%eax
- pushl %eax
+ pushl $32768
pushl $.LC0
call printf
leave
--
Ruslan Ermilov Oracle Developer/DBA,
ru@sunbay.com Sunbay Software AG,
ru@FreeBSD.org FreeBSD committer,
+380.652.512.251 Simferopol, Ukraine
http://www.FreeBSD.org The Power To Serve
http://www.oracle.com Enabling The Information Age
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001027181149.B39062>
