From owner-cvs-all@FreeBSD.ORG Fri Apr 4 22:55:35 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BFBCF37B401; Fri, 4 Apr 2003 22:55:35 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id C0F1943FA3; Fri, 4 Apr 2003 22:55:32 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id QAA28230; Sat, 5 Apr 2003 16:55:27 +1000 Date: Sat, 5 Apr 2003 16:55:26 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Nate Lawson In-Reply-To: Message-ID: <20030405164849.Y37179@gamplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: David O'Brien cc: Ruslan Ermilov cc: Poul-Henning Kamp cc: src-committers@FreeBSD.org cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org cc: Mike Barcroft Subject: Re: cvs commit: src/sys/sys endian.h src/share/man/man9 byteorder.9 X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Apr 2003 06:55:36 -0000 On Fri, 4 Apr 2003, Nate Lawson wrote: > On Fri, 4 Apr 2003, Ruslan Ermilov wrote: > > +#define BSWAP16(x) (uint16_t) \ > > + (((x) >> 8) | ((x) << 8)) > > + > > +#define BSWAP32(x) (uint32_t) \ > > + (((x) >> 24) | (((x) >> 8) & 0xff00) | \ > > + (((x) << 8) & 0xff0000) | ((x) << 24)) > I don't mind the addition of the macros but I don't like the > implementation. Too many unnecessary casts and overly complicated. I fear it has not enough necessary casts :-). E.g., if x = (int16_t)0xfffe, then on 32-bit machines sign extension gives 0xffffffff for BSWAP16(x). Of course, BSWAP16()'s arg should be precisely uint16_t, but the function interfaces don't require it to have the correct type except possibly on non-2's complement machines where coercing the arg's type may cause surprising changes to the arg's value. Bruce