fastcall是在include/asm-i386/linkage.h中定义的宏,它指导gcc连接时把fastcall修饰的函数的前三个参数用寄存器传递。
宏
asmlinkage则告诉gcc不要用寄存器传递参数.
asmlinkage和fastcall
不能共存。
__user
宏简单告诉编译器(通过
noderef
)不应该解除这个指针的引用(因为在当前地址空间中它是没有意义的)。 不明白什么意义? 有些网友说是为用户空间的, 我自己用了, 用的不是用户空间一样没什么问题.
我查了内核源码是这样定义的:
./include/linux/compiler.h:# define __user __attribute__((noderef, address_space(1)))
希望将来可以真正明白why......
============================================
2008-3-21添加下面的内容:
来源:
asmlinkage long sys_diffjiffies( long ujiffies )
{
return (long)get_jiffies_64() - ujiffies;
}
注意 asmlinkage
修饰符的使用。这个宏(在 linux/include/asm-i386/linkage.h 中定义)告诉编译器将传递栈中的所有函数参数.
"传递栈中的所有函数参数"==> 可以理解为不使用寄存器传递参数吗?现在好长时间没怎么看kernel部分的东西了,快忘了.
============================================
修改于: 2008-03-22
来源:
the asmlinkage tag tells gcc that that the function should not expect to find any of its arguments in registers (a common optimization), but only on the cpu's stack. many kernel functions use the fact, that system_call consumes its first argument, the system call number, and leaves 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.
"asmlinkage" 告诉gcc不要从寄存器中传参数,从cpu栈中读函数参数.
=============================================
阅读(4677) | 评论(2) | 转发(0) |