2013-07-07 134 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上的事情 - 在你的源代碼中。