Date: Mon, 09 Dec 2002 19:22:17 +0100 From: phk@FreeBSD.ORG To: "M. Warner Losh" <imp@bsdimp.com> Cc: arch@FreeBSD.ORG Subject: Re: le??toh, etc in userland Message-ID: <74122.1039458137@critter.freebsd.dk> In-Reply-To: Your message of "Mon, 09 Dec 2002 09:50:32 MST." <20021209.095032.102181079.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?74122.1039458137>