From owner-freebsd-arch@FreeBSD.ORG Wed Apr 9 12:25:09 2003 Return-Path: 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 7EA4F37B401 for ; Wed, 9 Apr 2003 12:25:09 -0700 (PDT) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id B3C1843FBF for ; Wed, 9 Apr 2003 12:25:08 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org (12-232-168-4.client.attbi.com[12.232.168.4]) by sccrmhc01.attbi.com (sccrmhc01) with ESMTP id <2003040919250700100ok20qe>; Wed, 9 Apr 2003 19:25:07 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id MAA81395; Wed, 9 Apr 2003 12:25:04 -0700 (PDT) Date: Wed, 9 Apr 2003 12:24:59 -0700 (PDT) From: Julian Elischer To: Poul-Henning Kamp In-Reply-To: <32183.1049881186@critter.freebsd.dk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: arch@freebsd.org Subject: Re: Sharing code between kernel and userland.... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Apr 2003 19:25:09 -0000 I prefer option 4 either a macro or an inline Note that fsck uses macros from the kernel ufs includes. So there is a precedent. On Wed, 9 Apr 2003, Poul-Henning Kamp wrote: > > This is a problem I have hit before, and now I hit it again: I need > to share a function between kernel and userland. > > In the present case it is the endianess conversions for struct disklabel > which currently live in > > src/sys/geom/geom_bsd.c > as > g_bsd_ledec_partition() & g_bsd_ledec_disklabel() > > which now are needed in disklabel(8), libdisk and possibly other > places as well also. > > The other partitioning formats will result in the same issue. > > It is vitally important that there be no discrepancy between the kernel > and userland versions, so obviously they should share the same source > code. > > We have a rule that it should be possible to compile the kernel > with only the src/sys tree, so obviously the source code should live > somewhere in src/sys, but the good question is: where and how ? > > As I see these functions, they are library functions, and the library > is used both by userland and the kernel, but right now we have no > such library in our system. > > We have a number of other bits of code which are in the same set > of circumstances, the sbuf stuff for instance and various bits in > libkern as well. > > Amongst the options I see for avoiding code duplication are: > > 1. > put it in sys/geom/bsdlabel_encode.c > have libdisk pull it into userland from there. > > 2. > put it in sys/libkern/disklabel.c > have libdisk pull it from there. > > 3. > put it in some more or less random place in the kernel > have libdisk pull it from there. > > 4. > use static __inline ... in > It is after all a rather trivial bit of code, but not quite > trivial enough to make me comfortable with this. > > What do people think ? > > -- > 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. > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" >