Chinaunix

标题: ARM平台上的asmlinkage [打印本页]

作者: rocky1972    时间: 2008-04-17 10:32
标题: ARM平台上的asmlinkage
这段话是在网上搜到的:

The asmlinkage tag is one other thing that we should observe about this simple function. This is a #define for some gcc magic that tells the compiler that the function should not expect to find any of its arguments in registers (a common optimization), but only on the CPU's stack. Recall our earlier assertion that system_call consumes its first argument, the system call number, and allows up to four more arguments that are passed along to the real system call. system_call achieves this feat simply by leaving its other arguments (which were passed to it in registers) on the stack. All system calls are marked with the asmlinkage tag, so they all look to the stack for arguments. Of course, in sys_ni_syscall's case, this doesn't make any difference, because sys_ni_syscall doesn't take any arguments, but it's an issue for most other system calls.

文中提到的system_call和the real system call有什么不同吗?

理解上面的文字,可以看出asmlinkage的作用就是指定system_call要给the real system call 传递参数的话,参数是在STACK中,不是在寄存器中。

另外:在ARM平台上好像没有对asmlinkage作出任何定义,只是在KERNEL_SRC/include/linux/linkage.h中找到如下定义:
#ifdef __cplusplus
#define CPP_ASMLINKAGE extern "C"
#else
#define CPP_ASMLINKAGE
#endif

#ifndef asmlinkage
#define asmlinkage CPP_ASMLINKAGE   //难道asmlinkage就仅仅是一个extern C了?
#endif

请高手讲讲asmlinkage的作用。谢谢




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2