asmlinkage的作用
2006-05-11 22:50
281 查看
相信大家在看linux的source code的时候,都会注意到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.
看一下/usr/include/asm/linkage.h里面的定义:
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
__attribute__是关键字,是gcc的C语言扩展,regparm(0)表示不从寄存器传递参数
如果是__attribute__((regparm(3))),那么调用函数的时候参数不是通过栈传递,而是直接放到寄存器里,被调用函数直接从寄存器取参数。
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))),那么调用函数的时候参数不是通过栈传递,而是直接放到寄存器里,被调用函数直接从寄存器取参数。
相关文章推荐
- Linux内核中__init, __initdata, __initfunc(), asmlinkage, ENTRY(), FASTCALL()等作用
- asmlinkage的作用
- asmlinkage的作用
- “asmlinkage” 的作用
- linux源码中asmlinkage的作用
- Linux内核中__init, __initdata, __initfunc(), asmlinkage, ENTRY(), FASTCALL()等作用
- 什么是 "asmlinkage"?
- linux内核中的fastcall和asmlinkage宏
- 什么是 "asmlinkage"
- linux中asmlinkage宏的解析
- asmlinkage 意义
- asmlinkage
- 什麼是 "asmlinkage"?--syscall原型说明
- asmlinkage 与 FASTCALL
- Linux 2.6.36版本内核分析之asmlinkage
- asmlinkage宏
- 什么是 "asmlinkage"?
- asmlinkage宏
- asmlinkage,Linux i386+源码中常见宏标识tag的定义
- asmlinkage