Sharing code between kernel and userland....
M. Warner Losh
imp at bsdimp.com
Wed Apr 9 09:08:13 PDT 2003
In message: <32183.1049881186 at critter.freebsd.dk>
Poul-Henning Kamp <phk at phk.freebsd.dk> writes:
: 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 <sys/disklabel.h>
: 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 ?
Why reinvent a way of doing it. Put the thing in sys somewhere
(sys/geom) and use a reachover Makefile like cam does (simplified from
the actual Makefile a little):
LIB= cam
SRCS= camlib.c scsi_cmdparse.c scsi_all.c scsi_da.c scsi_sa.c cam.c
INCS= camlib.h
.PATH: ${.CURDIR}/../../sys/cam/scsi ${.CURDIR}/../../sys/cam
SDIR= ${.CURDIR}/../../sys
CFLAGS+= -I${.CURDIR} -I${SDIR}
.include <bsd.lib.mk>
just have libdisk do the same thing.
Warner
More information about the freebsd-arch
mailing list