-   Linux - Kernel (
-   -   Why use __KERNEL__ and __ASSEMBLY__ in the kernel source code? (

dawei 03-10-2013 04:05 AM

Why use __KERNEL__ and __ASSEMBLY__ in the kernel source code?
Why use following macros in the kernel source code?

#ifdef __KERNEL__


#endif /* __KERNEL__ */

#ifdef __ASSEMBLY__


#endif /* __ASSEMBLY__ */

Mara 03-10-2013 10:28 AM

Those are for kernel headers. In some cases user space programs/libraries use the kernel headers. To make them run/compile/see only things they need, there is the __KERNEL__ macro. It is defined during the kernel compilation.

It is very similar with __ASSEMBLY__. Assembly source uses some kernel headers. Some things are not valid in assembly, however (like C functions...). The macro is defined for assembly code and allows to mark the part of the definitions that is needed in assembly.

In general, you do not have to use those if nobody complains. If it is needed, you will get notified.

All times are GMT -5. The time now is 10:29 AM.