Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 03-10-2013, 05:05 AM   #1
LQ Newbie
Registered: Apr 2012
Posts: 4

Rep: Reputation: Disabled
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__ */
Old 03-10-2013, 11:28 AM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,575

Rep: Reputation: 181Reputation: 181
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.


kernel, macro

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to attach a kernel module with kernel source code Gourab Das Linux - Kernel 2 02-04-2010 08:19 AM
How to access 2.6 kernel macros defined under __KERNEL__ someshwar Linux - Kernel 2 11-01-2006 12:36 AM
kernel source code ashley_31 Linux - General 10 05-23-2006 05:47 PM
Want 2.6.9-5 kernel source code bishalpoudyal Conectiva 1 04-13-2006 12:23 PM
kernel source code nabil_boussetta Linux - Software 7 02-13-2004 07:57 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration