Linux kernel headers' organization

随声附和 提交于 2021-02-07 13:47:57

问题


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


回答1:


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.




回答2:


The headers in directories arch/_arch_name_/include/asm are specific architecture dependent, such as for x86, ARM architectures. So the logic inside is platform-specific and highly depends on the underlying hardware. You will only include what your platform architecture is.

Headers in include/linux are common and platform independent. They're common logics and will be shared cross architectures.



来源:https://stackoverflow.com/questions/9798561/linux-kernel-headers-organization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!