From owner-cvs-all@FreeBSD.ORG Fri Apr 4 11:54:10 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 1AB2937B409 for ; Fri, 4 Apr 2003 11:54:10 -0800 (PST) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 852F943FCB for ; Fri, 4 Apr 2003 11:54:06 -0800 (PST) (envelope-from nate@rootlabs.com) Received: (qmail 17079 invoked by uid 1000); 4 Apr 2003 19:54:07 -0000 Date: Fri, 4 Apr 2003 11:54:07 -0800 (PST) From: Nate Lawson To: Ruslan Ermilov In-Reply-To: <20030404085200.GA1765@sunbay.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: src-committers@FreeBSD.org cc: Poul-Henning Kamp cc: David O'Brien 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: Fri, 04 Apr 2003 19:54:10 -0000 On Fri, 4 Apr 2003, Ruslan Ermilov wrote: > > > On Thu, 3 Apr 2003, Poul-Henning Kamp wrote: > > > > Modified files: > > > > sys/sys endian.h > > > > share/man/man9 byteorder.9 > > > > Log: > > > > Add inline functions {be,le}{16,32,64}{enc,dec}() for encoding decoding > > > > into byte strings of unknown alignment. > > /* > + * General byte order swapping macros. > + */ > +#define BSWAP16(x) (uint16_t) \ > + (((x) >> 8) | ((x) << 8)) > + > +#define BSWAP32(x) (uint32_t) \ > + (((x) >> 24) | (((x) >> 8) & 0xff00) | \ > + (((x) << 8) & 0xff0000) | ((x) << 24)) > + > +#define BSWAP64(x) (uint64_t) \ > + (((x) >> 56) | (((x) >> 40) & 0xff00) | (((x) >> 24) & 0xff0000) | \ > + (((x) >> 8) & 0xff000000) | (((x) << 8) & ((uint64_t)0xff << 32)) | \ > + (((x) << 24) & ((uint64_t)0xff << 40)) | \ > + (((x) << 40) & ((uint64_t)0xff << 48)) | (((x) << 56))) > + > +/* > * Host to big endian, host to little endian, big endian to host, and little > * endian to host byte order functions as detailed in byteorder(9). > */ > #if _BYTE_ORDER == _LITTLE_ENDIAN > #define htobe16(x) bswap16((x)) > +#define HTOBE16(x) BSWAP16((x)) I don't mind the addition of the macros but I don't like the implementation. Too many unnecessary casts and overly complicated. -Nate