From owner-freebsd-current Fri Oct 27 15:58:46 2000 Delivered-To: freebsd-current@freebsd.org Received: from mass.osd.bsdi.com (adsl-63-202-178-14.dsl.snfc21.pacbell.net [63.202.178.14]) by hub.freebsd.org (Postfix) with ESMTP id A4D9B37B479; Fri, 27 Oct 2000 15:58:43 -0700 (PDT) Received: from mass.osd.bsdi.com (localhost [127.0.0.1]) by mass.osd.bsdi.com (8.11.0/8.11.1) with ESMTP id e9RN2uF01866; Fri, 27 Oct 2000 16:02:57 -0700 (PDT) (envelope-from msmith@mass.osd.bsdi.com) Message-Id: <200010272302.e9RN2uF01866@mass.osd.bsdi.com> X-Mailer: exmh version 2.1.1 10/15/1999 To: Ruslan Ermilov Cc: Bruce Evans , Konstantin Chuguev , Brian Somers , kargl@apl.washington.edu, freebsd-current@FreeBSD.org Subject: Re: platform byte order macros? In-reply-to: Your message of "Fri, 27 Oct 2000 18:11:49 +0300." <20001027181149.B39062@sunbay.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 27 Oct 2000 16:02:56 -0700 From: Mike Smith Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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?! No, since it is incapable of dealing with a non-constant argument. > #include > #include > > 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 -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] V I C T O R Y N O T V E N G E A N C E To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message