What is '_KERNEL' in the source ?
Joseph Koshy
joseph.koshy at gmail.com
Mon Feb 6 03:28:35 PST 2006
> In various kernel source files,i came across '#ifdef _KERNEL'.
> What is '_KERNEL' used for ? In some files _KERNEL is #defined to nothing ??
> Can anybody please explain this ?
It is used to control the visibility of types and prototypes in system headers.
Kernel builds define _KERNEL, but userland compiles usually do not. Thus a
#include <sys/foo.h> has a different meaning in userland than in the kernel.
See: src/sys/conf/{kern.pre,kmod}.mk
A few userland utilities (e.g., fstat) define _KERNEL before including
headers from <sys/*> because they need more knowledge of kernel
data structures than is the norm for userland.
--
FreeBSD Volunteer, http://people.freebsd.org/~jkoshy
More information about the freebsd-hackers
mailing list