2 * arch/i386/include/klibc/archsys.h
4 * Architecture-specific syscall definitions
7 #ifndef _KLIBC_ARCHSYS_H
8 #define _KLIBC_ARCHSYS_H
11 * If we're compiling i386 in PIC mode, we need to treat %ebx
12 * specially. Most of these are copied from the equivalent file in
13 * newlib and were written by Werner Almesberger.
17 /* _syscall0() is the same as non-PIC */
20 #define _syscall1(type,name,type1,arg1) \
21 type name(type1 arg1) \
24 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
26 : "0" (__NR_##name),"r" ((long)(arg1))); \
27 __syscall_return(type,__res); \
31 #define _syscall2(type,name,type1,arg1,type2,arg2) \
32 type name(type1 arg1,type2 arg2) \
35 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
37 : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
38 __syscall_return(type,__res); \
42 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
43 type name(type1 arg1,type2 arg2,type3 arg3) \
46 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
48 : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
49 "d" ((long)(arg3))); \
50 __syscall_return(type,__res); \
54 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
55 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
58 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
60 : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
61 "d" ((long)(arg3)),"S" ((long)(arg4))); \
62 __syscall_return(type,__res); \
66 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
68 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
71 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
73 : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
74 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
75 __syscall_return(type,__res); \
79 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
80 type5,arg5,type6,arg6) \
81 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
84 __asm__ __volatile__ ("push %%ebx; pushl %%ebp; movl %2,%%ebx; " \
85 "movl %%eax,%%ebp; movl %1,%%eax; int $0x80; " \
86 "pop %%ebp ; pop %%ebx" \
88 : "i" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
89 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
90 "a" ((long)(arg6))); \
91 __syscall_return(type,__res); \
96 #endif /* _KLIBC_ARCHSYS_H */