syscall调用接口从2.6.19开始移到应用层

转自:http://crquan.blogbus.com/logs/5618102.html


syscall调用接口从2.6.19开始移到应用层,原来内核中使用_syscallN宏的方式来声明函数原型的方法不再有效:

如声明:

_syscall1(int, sysinfo, struct sysinfo *, info);

不再需要,而是在程序中需要的时候直接调用:

int syscall(int number, ...);
  • 第一个number是后面要接的参数个数,不是该系统调用的参数个数;(注:关于这个number,man手册上说的是: syscall()  performs the system call whose assembly language interface has the specified number with the specified arguments.  Symbolic constants for system
           calls can be found in the header file <sys/syscall.h>.
  • number后面顺序接上该系统调用的所有参数即可

相应头文件包含也改变为

于是调用sysinfo就变为:

struct sysinfo s_info;
syscall(2, __NR_sysinfo, &s_info);

可见新的调用方式变得更为简洁了。

References:

  • http://lxr.linux.no/source/include/asm-i386/unistd.h
  • http://lxr.linux.no/source/include/asm-i386/unistd.h?v=2.6.18
  • http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/patch-2.6.19-git13.log
  • commit f5738ceed46782aea7663d62cb6398eb05fc4ce0 of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值