From owner-freebsd-arch Mon Dec 9 10:22:38 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 67D1537B401 for ; Mon, 9 Dec 2002 10:22:37 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3662F43EBE for ; Mon, 9 Dec 2002 10:22:36 -0800 (PST) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id gB9IMH3p074123; Mon, 9 Dec 2002 19:22:23 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: "M. Warner Losh" Cc: arch@FreeBSD.ORG Subject: Re: le??toh, etc in userland From: phk@FreeBSD.ORG In-Reply-To: Your message of "Mon, 09 Dec 2002 09:50:32 MST." <20021209.095032.102181079.imp@bsdimp.com> Date: Mon, 09 Dec 2002 19:22:17 +0100 Message-ID: <74122.1039458137@critter.freebsd.dk> 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 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. The current implementation in GEOM is currently strictly MD and not optimized, that could and probably should change if we make this a generic API: void g_enc_le4(u_char *p, uint32_t u) { p[0] = u & 0xff; p[1] = (u >> 8) & 0xff; p[2] = (u >> 16) & 0xff; p[3] = (u >> 24) & 0xff; } -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message