/* * arch/i386/include/klibc/archsys.h * * Architecture-specific syscall definitions */ #ifndef _KLIBC_ARCHSYS_H #define _KLIBC_ARCHSYS_H /* * If we're compiling i386 in PIC mode, we need to treat %ebx * specially. Most of these are copied from the equivalent file in * newlib and were written by Werner Almesberger. */ #if defined(__PIC__) /* _syscall0() is the same as non-PIC */ #undef _syscall1 #define _syscall1(type,name,type1,arg1) \ type name(type1 arg1) \ { \ long __res; \ __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \ : "=a" (__res) \ : "0" (__NR_##name),"r" ((long)(arg1))); \ __syscall_return(type,__res); \ } #undef _syscall2 #define _syscall2(type,name,type1,arg1,type2,arg2) \ type name(type1 arg1,type2 arg2) \ { \ long __res; \ __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \ : "=a" (__res) \ : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \ __syscall_return(type,__res); \ } #undef _syscall3 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ type name(type1 arg1,type2 arg2,type3 arg3) \ { \ long __res; \ __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \ : "=a" (__res) \ : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ "d" ((long)(arg3))); \ __syscall_return(type,__res); \ } #undef _syscall4 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ { \ long __res; \ __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \ : "=a" (__res) \ : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \ "d" ((long)(arg3)),"S" ((long)(arg4))); \ __syscall_return(type,__res); \ } #undef _syscall5 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5) \ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ { \ long __res; \ __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \ : "=a" (__res) \ : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \ "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \ __syscall_return(type,__res); \ } #undef _syscall6 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ type5,arg5,type6,arg6) \ type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ { \ long __res; \ __asm__ __volatile__ ("push %%ebx; pushl %%ebp; movl %2,%%ebx; " \ "movl %%eax,%%ebp; movl %1,%%eax; int $0x80; " \ "pop %%ebp ; pop %%ebx" \ : "=a" (__res) \ : "i" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \ "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \ "a" ((long)(arg6))); \ __syscall_return(type,__res); \ } #endif /* __PIC__ */ #endif /* _KLIBC_ARCHSYS_H */