- 论坛徽章:
- 0
|
在查看代码的时候,在fs/open.c里的
SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode)
{
long ret;
if (force_o_largefile())
flags |= O_LARGEFILE;
ret = do_sys_open(AT_FDCWD, filename, flags, mode);
/* avoid REGPARM breakage on x86: */
asmlinkage_protect(3, ret, filename, flags, mode);
return ret;
} |
的asmlinkage_protect(3, ret, filename, flags, mode);是什么意思,它展开后应该是这样的
__asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), "g" (filename), "g" (flags), "g" (mode));
然后看了这个代码上有一个注释如下
/*
* Make sure the compiler doesn't do anything stupid with the
* arguments on the stack - they are owned by the *caller*, not
* the callee. This just fools gcc into not spilling into them,
* and keeps it from doing tailcall recursion and/or using the
* stack slots for temporaries, since they are live and "used"
* all the way to the end of the function.
*
* NOTE! On x86-64, all the arguments are in registers, so this
* only matters on a 32-bit kernel.
*/
/*
为了防止编译器操作栈上的参数 -它是属于调用函数的,而不是被调用函数的,
所以这些参数在调用者里都是有效的,并且一直被使用,因而这只是为了告诉
gcc不要影响它们(这些参数),并且不能用其(这些参数)做递归调用或者
用作临时变量。
注意:因为只有在x86-64上,这些参数都是在寄存器里的,所以在32位的内核上不
存在这个问题。
*/
请大虾指教,为什么会存在这样的问题,在__asm里的"g"表示什么意思? |
|