Line 0
Link Here
|
|
|
1 |
// x86_64 |
2 |
//#define __syscall_clobber "r11","rcx","memory" |
3 |
//#endif |
4 |
|
5 |
#include <linux/err.h> |
6 |
|
7 |
/* |
8 |
* user-visible error numbers are in the range -1 - -MAX_ERRNO: see |
9 |
* <asm-i386/errno.h> |
10 |
*/ |
11 |
#define __syscall_return(type, res) \ |
12 |
do { \ |
13 |
if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \ |
14 |
errno = -(res); \ |
15 |
res = -1; \ |
16 |
} \ |
17 |
return (type) (res); \ |
18 |
} while (0) |
19 |
|
20 |
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ |
21 |
#define _syscall0(type,name) \ |
22 |
type name(void) \ |
23 |
{ \ |
24 |
long __res; \ |
25 |
__asm__ volatile ("int $0x80" \ |
26 |
: "=a" (__res) \ |
27 |
: "0" (__NR_##name)); \ |
28 |
__syscall_return(type,__res); \ |
29 |
} |
30 |
|
31 |
#define _syscall1(type,name,type1,arg1) \ |
32 |
type name(type1 arg1) \ |
33 |
{ \ |
34 |
long __res; \ |
35 |
__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \ |
36 |
: "=a" (__res) \ |
37 |
: "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \ |
38 |
__syscall_return(type,__res); \ |
39 |
} |
40 |
|
41 |
#define _syscall2(type,name,type1,arg1,type2,arg2) \ |
42 |
type name(type1 arg1,type2 arg2) \ |
43 |
{ \ |
44 |
long __res; \ |
45 |
__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \ |
46 |
: "=a" (__res) \ |
47 |
: "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \ |
48 |
: "memory"); \ |
49 |
__syscall_return(type,__res); \ |
50 |
} |
51 |
|
52 |
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ |
53 |
type name(type1 arg1,type2 arg2,type3 arg3) \ |
54 |
{ \ |
55 |
long __res; \ |
56 |
__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \ |
57 |
: "=a" (__res) \ |
58 |
: "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \ |
59 |
"d" ((long)(arg3)) : "memory"); \ |
60 |
__syscall_return(type,__res); \ |
61 |
} |
62 |
|