2013-07-07 133 views
0

我试图获得所有系统调用的常量,但在内核源代码中的include/asm/unistd.h,include/asm/unistd_XX.hinclude/asm-generic/unistd.h之间似乎有一个巨大的混乱。对unistd_XX.h感到困惑

其中每一个之间有什么区别?

我应该使用哪一个,如果我想获得:

a) x86 syscalls 
b) x64 syscalls 
c) IA32 emulation syscalls 

回答

0

所以,正确的方法是使用unistd.h用于x64和/或unistd_32.hx86ia32。这些文件位于你的linux发行版的头文件中。但请记住,路径是发行版之间的变化(甚至内核之间),所以最好的办法,找出其中正是这些文件是:

uni_hack.h 

#if defined(CONFIG_X86) <---- replace with whatever you want, #ifdef CONFIG_IA32_EMULATION for example 
# include <asm/unistd_32.h> 
#endif 

-

Kbuild file 

obj-m += kernel_module_example.o 

$(obj)/kernel_module_example.o: $(obj)/real_unistd.h 

$(obj)/real_unistd.h: $(src)/uni_hack.h FORCE 
    cpp $(c_flags) -E -dM <$< >[email protected] <---- this will generate "real_unistd.h" in the directory of your kernel module, and it will contain the content of unistd_32.h 

使用unistd.h对于x64只是在#include上的事情 - 在你的源代码中。