linux内核 asmlinkage宏
来源:互联网 发布:软件外包开发 编辑:程序博客网 时间:2024/05/20 18:44
asmlinkage是个宏,使用它是为了保持参数在stack中。
看一下/usr/include/asm/linkage.h里面的定义:
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
其中 __attribute__是关键字,是gcc的C语言扩展。
__attribute__机制是GNU C的一大特色,它可以设置函数属性、变量属性和类型属性等。可以通过它们向编译器提供更多数据,帮助编译器执行优化等。
__attribute__((regparm(0))):告诉gcc编译器该函数不需要通过任何寄存器来传递参数,参数只是通过堆栈来传递。
__attribute__((regparm(3))):告诉gcc编译器这个函数可以通过寄存器传递多达3个的参数,这3个寄存器依次为EAX、EDX 和 ECX。更多的参数才通过堆栈传递。这样可以减少一些入栈出栈操作,因此调用比较快。
asmlinkage大都用在系统调用中。有一些情况下是需要明确的告诉编译器,我们是使用stack来传递参数的,比如X86中的系统调用,是先将参数压入stack以后调用sys_*函数的,所以所有的sys_*函数都有asmlinkage来告诉编译器不要使用寄存器来编译,
The asmlinkage tag is one other thing that we should observe about thissimple function. This is a #define for some gcc magic that tells thecompiler that the function should not expect to find any of itsarguments in registers (a common optimization), but only on the CPU'sstack. Recall our earlier assertion that system_call consumes its firstargument, the system call number, and allows up to four more argumentsthat are passed along to the real system call. system_call achievesthis feat simply by leaving its other arguments (which were passed toit in registers) on the stack. All system calls are marked with theasmlinkage tag, so they all look to the stack for arguments. Of course,in sys_ni_syscall's case, this doesn't make any difference, becausesys_ni_syscall doesn't take any arguments, but it's an issue for mostother system calls. And, because you'll be seeing asmlinkage in frontof many other functions, I thought you should know what it was about.
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
其中 __attribute__是关键字,是gcc的C语言扩展。
__attribute__机制是GNU C的一大特色,它可以设置函数属性、变量属性和类型属性等。可以通过它们向编译器提供更多数据,帮助编译器执行优化等。
__attribute__((regparm(0))):告诉gcc编译器该函数不需要通过任何寄存器来传递参数,参数只是通过堆栈来传递。
__attribute__((regparm(3))):告诉gcc编译器这个函数可以通过寄存器传递多达3个的参数,这3个寄存器依次为EAX、EDX 和 ECX。更多的参数才通过堆栈传递。这样可以减少一些入栈出栈操作,因此调用比较快。
asmlinkage大都用在系统调用中。有一些情况下是需要明确的告诉编译器,我们是使用stack来传递参数的,比如X86中的系统调用,是先将参数压入stack以后调用sys_*函数的,所以所有的sys_*函数都有asmlinkage来告诉编译器不要使用寄存器来编译,
The asmlinkage tag is one other thing that we should observe about thissimple function. This is a #define for some gcc magic that tells thecompiler that the function should not expect to find any of itsarguments in registers (a common optimization), but only on the CPU'sstack. Recall our earlier assertion that system_call consumes its firstargument, the system call number, and allows up to four more argumentsthat are passed along to the real system call. system_call achievesthis feat simply by leaving its other arguments (which were passed toit in registers) on the stack. All system calls are marked with theasmlinkage tag, so they all look to the stack for arguments. Of course,in sys_ni_syscall's case, this doesn't make any difference, becausesys_ni_syscall doesn't take any arguments, but it's an issue for mostother system calls. And, because you'll be seeing asmlinkage in frontof many other functions, I thought you should know what it was about.
0
上一篇:AT&T资料(留着以后能看)
下一篇:android编译环境配置总结
相关热门文章
- linux 常见服务端口
- xmanager 2.0 for linux配置
- 【ROOTFS搭建】busybox的httpd...
- openwrt中luci学习笔记
- 什么是shell
- linux dhcp peizhi roc
- 关于Unix文件的软链接
- 求教这个命令什么意思,我是新...
- sed -e "/grep/d" 是什么意思...
- 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
评论热议
0 0
- linux内核 asmlinkage宏
- linux内核 asmlinkage宏
- linux内核 asmlinkage宏
- linux内核 asmlinkage宏
- linux内核 asmlinkage宏
- linux内核 asmlinkage宏
- linux内核 asmlinkage宏
- linux内核中的fastcall和asmlinkage宏
- linux内核中的fastcall和asmlinkage宏
- Linux内核中的fastcall和asmlinkage宏
- linux内核中的fastcall和asmlinkage宏
- linux内核中asmlinkage的含义
- asmlinkage(linux内核特殊的c语言用法)
- Linux 2.6.36版本内核分析之asmlinkage
- linux中asmlinkage宏的使用
- linux中asmlinkage宏的解析
- asmlinkage宏
- asmlinkage宏
- 详解微信小程序开发教程
- caffe利用训练好的模型进行实际测试
- 控制寄存器(CR0,CR1,CR2,CR3)和CR4
- 2017超星慕课尔雅古希腊的思想世界答案题库
- AT&T资料(留着以后能看)
- linux内核 asmlinkage宏
- android编译环境配置总结
- linux应用编程学习(5)管道
- linux实用技巧:你该使用ctags查找源码了
- 内核模块下载和编译、安装
- 3.18内核的sk_buff
- 不可睡眠锁:自旋锁spinlock编码学习
- 8.可变对象(无序表和有序表——含java库中应用)
- LoRa笔记02 LoRa sx1276 sx1278的发射功率研究
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
旗扬
旗扬 兽道
时事分析
昊天经纬时事分析
旗木快乐风男
旗木朔茂
旗木佐云
旗木
旗木一族
木叶之旗木的快乐风男
旗木家的小白毛
旗木卡卡西的妻子
木叶之旗木
旗木卡卡西的写轮眼
旗木卡卡西的真面目
旗木家的藏剑二少
木叶之旗木家的
旗木家的
木叶之旗木家的快乐风男
旗杆高度
天安门旗杆
旗杆
旗杆拼音
旗杆的拼音
旗杆图片
一什么旗杆
不锈钢旗杆
电动旗杆
旗杆顶端
旗杆读音
旗杆规格
旗杆台
旗杆的读音
昆明旗杆
旗杆不锈钢旗杆
旗杆工程
买旗杆
升降旗杆
工厂旗杆
注水旗杆
旗杆制作