asmlinkage 的意义
来源:互联网 发布:breed修改mac 编辑:程序博客网 时间:2024/05/21 20:30
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.
看一下/usr/include/asm/linkage.h里面的定义:
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
__attribute__是关键字,是gcc的C语言扩展,regparm(0)表示不从寄存器传递参数
如果是__attribute__((regparm(3))),那么调用函数的时候参数不是通过栈传递,而是直接放到寄存器里,被调用函数直接从寄存器取参数。
在 x86 上,regparm 属性会传递一个数值给编译器,这个数值会告诉编译器要用多少个寄存器来传递函数参数(EAX, EDX 或 ECX,最多 3 个寄存器),通常情况下函数是用堆栈来传递参数的。如果参数比较多,那么其余的参数仍然通过堆栈来传递。
比如我们指定 __attribute__((regparm(0))) ,则表示不用寄存器来传递参数,所有参数都通过堆栈来传递;如果我们指定 __attribute__((regparm(3))),那么就是说会用 3 个寄存器来传递参数(EAX, EDX, ECX),其余的参数通过堆栈来传递。
- asmlinkage 的意义
- asmlinkage 意义
- asmlinkage的作用
- asmlinkage的作用
- asmlinkage的用法
- “asmlinkage” 的作用
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- asmlinkage
- 1106: 火柴棒等式
- 用U盘启动盘安装Ubuntu
- 沉寂心念,独看落花碎
- /DJava ${container_loc}/${resource_name}
- 下一世让心自由飞翔
- asmlinkage 的意义
- 解决Win8系统下驱动安装“数据无效”错误
- 远程取回Win7系统电脑的任何文件
- Windows系统关闭自动更新显示
- Windows 7系统里释放带宽限制
- LR测试https协议设置方法
- C/C++内存释放应注意的问题
- 初创公司最爱使用的那些开发工具
- C/C++实现十进制向二进制转换