From owner-freebsd-arch Mon Dec 9 12:34:44 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D151637B404; Mon, 9 Dec 2002 12:34:42 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E30B43EB2; Mon, 9 Dec 2002 12:34:42 -0800 (PST) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 64616AE265; Mon, 9 Dec 2002 12:34:42 -0800 (PST) Date: Mon, 9 Dec 2002 12:34:42 -0800 From: Maxime Henrion To: Nate Lawson Cc: phk@FreeBSD.ORG, "M. Warner Losh" , arch@FreeBSD.ORG Subject: Re: le??toh, etc in userland Message-ID: <20021209203442.GB27086@elvis.mu.org> References: <74122.1039458137@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Nate Lawson wrote: > On Mon, 9 Dec 2002 phk@FreeBSD.ORG wrote: > > In message <20021209.095032.102181079.imp@bsdimp.com>, "M. Warner Losh" writes: > > > > >We should provide an implementation of {b,l}e{16,32}toh and > > >hto{b,l}e{16,32} in libc. Any objections? > > > > None as such. > > > > I would really like to also have the "byte-encoding" version in a > > more general place than in GEOM, but I am not aware of any suitable > > standards in this area. > > > > The reason of these is that the data encoded/decoded may not live > > on native alignment boundaries, so the normal "swap-as-needed" > > functions are not very efficient. > > Already present in CAM (sys/cam/ssi_all.h): > static __inline void scsi_ulto2b(u_int32_t val, u_int8_t *bytes); > static __inline void scsi_ulto3b(u_int32_t val, u_int8_t *bytes); > static __inline void scsi_ulto4b(u_int32_t val, u_int8_t *bytes); > static __inline u_int32_t scsi_2btoul(u_int8_t *bytes); > static __inline u_int32_t scsi_3btoul(u_int8_t *bytes); > static __inline int32_t scsi_3btol(u_int8_t *bytes); > static __inline u_int32_t scsi_4btoul(u_int8_t *bytes); > > I would love to have a 64 bit version and map these to a generic host > version. It should use u_int8_t instead of u_char though. It should even use uintXX_t instead of u_intXX_t, since the former is the standard C99 types. Maxime To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message