While I was doing some reading on system calls, I did a search for syscalls.h
to find the header file in LXR. The search results puzzled me. There is a dozen of syscalls.h
files coming from directories under arch/_arch_name_/include/asm
. These are ok, they are architecture specific definitions or something else needed. The question is why do we have two different syscalls.h
headers under both include/linux
and include/asm-generic
?
Also, I want to find out that what include/linux
headers are for and what include/asm-generic
headers are for. How do they differentiate between each other? What is the logic behind having two separate header folders? How do they relate to each other?
Thanks
Linux kernel headers are components usually used to compile drivers and loadable modules adding support to the kernel. For this purpose, kernel headers include C headers with functions and structures needed to compile modules. Thanks to kernel headers, modules or drivers can interact with the kernel.
The system's libc headers are usually installed at the default location /usr/include and the kernel headers in subdirectories under that (most notably /usr/include/linux and /usr/include/asm).
A common question regarding linux-headers is whether you need to keep them synced with your kernel version. The answer is no. You can have a newer linux-headers version than your running kernel binary. So for example, if you have kernel 4.1 installed, you can have linux-headers 4.4.
I've asked this question on Kernel Newbies ML. I got the following answer which makes things clear:
Cihangir Akturk wrote:
AFAIK, headers found in /include/asm-generic directory is for architechture independent (probably shared across architectures) code. Most likely you do not need to include these headers directly, instead we include these headers indirectly via architecthure dependent headers.
OTOH, /include/linux directory is for generic header files to define interfaces between components of the kernel. In most situations, you will find all the kernel functionalities you need in these headers.
regards, chngr.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With