From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 4 22:55:12 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA43C1065676 for ; Wed, 4 Jun 2008 22:55:12 +0000 (UTC) (envelope-from nlcom_os@ii.nl) Received: from mail1.ii.nl (mail1.ii.nl [82.94.191.120]) by mx1.freebsd.org (Postfix) with ESMTP id 84CCF8FC34 for ; Wed, 4 Jun 2008 22:55:12 +0000 (UTC) (envelope-from nlcom_os@ii.nl) Received: from c53751d89.cable.wanadoo.nl ([83.117.29.137]:49084 helo=[192.168.1.103]) by mail1.ii.nl with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) authenticated as nanno with plain authenticator (Exim 4.63) (envelope-from ) id 1K41Xo-0006Er-Du; Thu, 05 Jun 2008 00:33:25 +0200 Message-ID: <4847182F.80105@ii.nl> Date: Thu, 05 Jun 2008 00:33:19 +0200 From: Nanno Langstraat User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Standard byteorder functions across BSD / Linux X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2008 22:55:13 -0000 Hello, I think it would be nice to have standard byteorder conversion functions for user applications across the BSDs and Linux. betoh64(), htobe64(), etc. (like OpenBSD's sys/endian.h) Just small convenience functions/macros, but useful because it's such a common requirement; applications currently have to roll their own over&over with an annoying tangle of #ifdefs. Summary of the story so far: * glibc added the basic macros to * OpenBSD already had the macros in . They are for both kernel and application use according to the manpage. OpenBSD didn't want my patch that made the standard include file for user applications. * FreeBSD has similar but incompatible macros in . They are for kernel use, not application use according to the manpage. Full details below. (pretty long story for such a tiny feature) ---- My original proposal to the GNU glibc maintainers: * glibc Bugzilla 6442 - Adding cross-Unix endianness functions: betoh() / htobe() 64,32,16 http://sources.redhat.com/bugzilla/show_bug.cgi?id=6442 * Pro/con: http://sourceware.org/ml/libc-alpha/2008-05/msg00022.html ---- I planned to have a little coordination between glibc/FreeBSD/OpenBSD before starting on patches. That didn't happen, the glibc maintainers gave zero response for a full month, then created the basic macros in /usr/include/endian.h without any discussion. * ('endian.h' pre-existed in glibc to define __LITTLE_ENDIAN etc. The file does not pre-exist on OpenBSD / FreeBSD) * (glibc didn't adopt the "swap64()" etc. functions. Glibc already contains variants with a different naming pattern: "bswap_64()" etc.) * (be32enc() and friends only got a small mention by me, not adopted by glibc) ---- The discussion on the OpenBSD mailinglist can be read here: http://thread.gmane.org/gmane.os.openbsd.tech/15161/focus=15161 Of particular interest to FreeBSD: this charmless but informative email by Theo de Raadt, which outlines the history of the BSD kernel byteorder functions: http://thread.gmane.org/gmane.os.openbsd.tech/15161/focus=15179 ============================================================ My question to FreeBSD: I don't use FreeBSD myself, but I'll prepare a patch if you like the idea and if you indicate what you'll accept: * or ? I maintain that it should be for user applications: IMHO is for the user-kernel API, and byteorder belongs to libc not the kernel API. glibc apparently agrees, OpenBSD disagreed. * You're OK with userspace applications standardizing on OpenBSD's original betoh64() instead of FreeBSD's derivate be64toh() ? Regards, Nanno