文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>linux内核代码中asmlinkage的含义

linux内核代码中asmlinkage的含义

时间:2009-05-05  来源:litary1986

它的定义如下:#define asmlinkage __attribute__((regparm(0))) 导致gcc对do_IRQ函数不作调用参数的优化工作,即不通过寄存器传递参数,所以在 do_IRQ的二进制代码中,将认为此时的“参数”都到栈中寻找。而进一步,在调用do_IRQ之前,SAVE_ALL推进栈中一些寄存器变量,这样,栈中的变量在do_IRQ的内部被认为是传递的参数。 CSDN中有人的解释: asmlinkage是个宏,使用它是为了保持参数在stack中。因为从汇编语言到C语言代码参数的传递是通过stack的,它也可能从stack中得到一些不需要的参数。Asmlinkage将要解析那些参数。     
  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.

相关阅读 更多 +
排行榜 更多 +
大武道最新版

大武道最新版

休闲益智 下载
宝宝巴士手机版(babybus)

宝宝巴士手机版(babybus)

休闲益智 下载
宝宝巴士快乐启蒙游戏

宝宝巴士快乐启蒙游戏

休闲益智 下载