Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Feb 2006 16:58:33 +0530
From:      Joseph Koshy <joseph.koshy@gmail.com>
To:        Tanmay <tanmayinamdar@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: What is '_KERNEL' in the source ?
Message-ID:  <84dead720602060328o39c8f964h3fcf355930262816@mail.gmail.com>
In-Reply-To: <cdc1d1310602060234p1ade9a3dh545c57e0dfc76794@mail.gmail.com>
References:  <cdc1d1310602060234p1ade9a3dh545c57e0dfc76794@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>           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 head=
ers.
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?84dead720602060328o39c8f964h3fcf355930262816>