From owner-cvs-all Sat Sep 14 8:51:32 2002 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 05C5737B400; Sat, 14 Sep 2002 08:51:27 -0700 (PDT) Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC29F43E6E; Sat, 14 Sep 2002 08:51:25 -0700 (PDT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.12.3/8.12.3) with ESMTP id g8EFpO9R043010; Sat, 14 Sep 2002 09:51:24 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 14 Sep 2002 09:51:20 -0600 (MDT) Message-Id: <20020914.095120.48398209.imp@bsdimp.com> To: grog@FreeBSD.org Cc: phk@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/geom geom.h geom_enc.c From: "M. Warner Losh" In-Reply-To: <20020914013012.GU25003@wantadilla.lemis.com> References: <200209131033.g8DAXA0q006395@freefall.freebsd.org> <20020914013012.GU25003@wantadilla.lemis.com> X-Mailer: Mew version 2.1 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message: <20020914013012.GU25003@wantadilla.lemis.com> "Greg 'groggy' Lehey" writes: : On Friday, 13 September 2002 at 3:33:10 -0700, Poul-Henning Kamp wrote: : > phk 2002/09/13 03:33:10 PDT : > : > Modified files: : > sys/geom geom.h geom_enc.c : > Log: : > Add a couple more of the big/little-endian conversion routines and make : > them visible from userland, if need be. : > : > I wish that the C language contained this as part of struct definintions, : > but failing that, I would settle for an agreed upon set of functions for : > packing/unpacking integers in various sizes from byte-streams which may : > have unfriendly alignment. : : Is there any reason not to use the Linux function names (be32_to_cpu, : cpu_to_le16, etc.)? Because BSD already has these defined in sys/endian.h: #define htobe16(x) bswap16((x)) #define htobe32(x) bswap32((x)) #define htobe64(x) bswap64((x)) #define htole16(x) ((uint16_t)(x)) #define htole32(x) ((uint32_t)(x)) #define htole64(x) ((uint64_t)(x)) #define be16toh(x) bswap16((x)) #define be32toh(x) bswap32((x)) #define be64toh(x) bswap64((x)) #define le16toh(x) ((uint16_t)(x)) #define le32toh(x) ((uint32_t)(x)) #define le64toh(x) ((uint64_t)(x)) But this is different than what phk wants, since they may not work in the case of unfriendly alignment. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message