kernel/userland separation in headers ?

Luigi Rizzo rizzo at iet.unipi.it
Thu Jun 11 13:17:32 UTC 2009


Right now, several headers carry both userland and kernel
info, using _KERNEL to tell what should be made visible

	---- sys/sys/foo.h ---

	#ifndef SYS_FOO_H
	#define SYS_FOO_H
	... userland visible stuff

	#ifdef _KERNEL
	... kernel-visible stuff
	#endif /* _KERNEL */

	#endif /* SYS_FOO_H */

This is not completely satisfactory, as there are at least
three different pieces of information in foo.h:

	A	kernel-userland API for subsystem foo
	B	kernel API for subsystem foo
	C	private info for subsystem foo, that should not
		be exported to the rest of the kernel.

and I would like to keep them as separate as possible.

Do we have any established naming convention for #A, #B and #C,
so we can put these pieces in different files (reducing build
dependencies, and making it easier to check that changes are
backward compatible) ?
As an alternative, do we have some standard naming for macros
e.g. _FOO_INTERNAL to tell #B from #C ?

One example is perhaps in sys/netinet where we have

	in.h		perhaps #A
	in_systm.h
	in_var.h

but all of them have an "#ifdef _KERNEL" section and
i am not even sure which header maps to which category.

	cheers
	luigi


More information about the freebsd-current mailing list