作者roylee17 (把我id还我阿......)
看板LinuxDev
标题Re: [问题] 请问关於System Call的问题
时间Sat Jan 13 03:26:07 2007
※ 引述《CriLit (没昵称)》之铭言:
: 标题: [问题] 请问关於System Call的问题
: 时间: Fri Jan 12 11:09:59 2007
:
: 各位版上的前辈好,
: 小弟我有以下的问题想请问各位前辈,
: 假设我已经将System Call编成模组,
: 并挂载起来,
: 在编译User Program的时候,
: 会出现以下的问题,
:
: #include <linux/unistd.h>
: #include <errno.h>
: extern int errno;
: #define __NR_mysyscall 253
: static inline _syscall1(int, mysyscall, int, n);
: int main()
: {
: mysyscall(0);
: return 0;
: }
:
: 在_syscall1那一行出现编译时产生错误,
: error expected decalaration specifiers or '...' before 'mysyscall'
: error expected decalaration specifiers or '...' before 'n'
:
: 请问我还有哪里需要注意的而没注意??
:
: --
: Who am I?
:
: --
:
※ 发信站: 批踢踢实业坊(ptt.cc)
: ◆ From: 220.132.182.103
: 推 elpam:这是作业吗 orz ... 看一下你的 , , 太多了吧 01/12 12:10
: → roylee17:改成 _syscall1(int, mysyscall, int, n) 试试 01/12 17:07
: 推 CriLit:这不是作业, 这是我自己练习的而已... 01/12 21:58
: → CriLit:您说的是逗号吗? _syscallN的参数本来就是这样阿.. 01/12 21:59
: → CriLit:这是巨集@@.... 01/12 21:59
: → CriLit:roylee:您说的方法我之前有试过, 不过也是相同的问题- - 01/12 21:59
嗯嗯,我试了也一样...
asm/unistd.h 里的 _syscallN macro 现在已经被 #ifdef __KERNEL__ 包住了
所以一般的 user program 是看不到的
用 syscall 试试吧
#include <linux/unistd.h>
- #include <errno.h>
- extern int errno;
- #define __NR_mysyscall 253 // 如果有写在 unistd.h 就不用了
- static inline _syscall1(int, mysyscall, int, n);
+ #include <sys/syscall.h>
+ int mysyscall( int n){
+ return syscall( __NR_mysyscall, n);
+ }
int main()
{
mysyscall(0);
return 0;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.104.145.38
※ 编辑: roylee17 来自: 59.104.145.38 (01/13 03:34)
1F:推 CriLit:感谢:) roylee17 01/13 12:50