chiark / gitweb /
[PATCH] added klibc version 0.82 (cvs tree) to the udev tree.
[elogind.git] / klibc / klibc / arch / i386 / include / klibc / archsys.h
1 /*
2  * arch/i386/include/klibc/archsys.h
3  *
4  * Architecture-specific syscall definitions
5  */
6
7 #ifndef _KLIBC_ARCHSYS_H
8 #define _KLIBC_ARCHSYS_H
9
10 /*
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.
14  */
15 #if defined(__PIC__)
16
17 /* _syscall0() is the same as non-PIC */
18
19 #undef _syscall1
20 #define _syscall1(type,name,type1,arg1) \
21 type name(type1 arg1) \
22 { \
23 long __res; \
24 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
25         : "=a" (__res) \
26         : "0" (__NR_##name),"r" ((long)(arg1))); \
27 __syscall_return(type,__res); \
28 }
29
30 #undef _syscall2
31 #define _syscall2(type,name,type1,arg1,type2,arg2) \
32 type name(type1 arg1,type2 arg2) \
33 { \
34 long __res; \
35 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
36         : "=a" (__res) \
37         : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2))); \
38 __syscall_return(type,__res); \
39 }
40
41 #undef _syscall3
42 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
43 type name(type1 arg1,type2 arg2,type3 arg3) \
44 { \
45 long __res; \
46 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
47         : "=a" (__res) \
48         : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
49                 "d" ((long)(arg3))); \
50 __syscall_return(type,__res); \
51 }
52
53 #undef _syscall4
54 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
55 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
56 { \
57 long __res; \
58 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
59         : "=a" (__res) \
60         : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
61           "d" ((long)(arg3)),"S" ((long)(arg4))); \
62 __syscall_return(type,__res); \
63 }
64
65 #undef _syscall5
66 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
67           type5,arg5) \
68 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
69 { \
70 long __res; \
71 __asm__ __volatile__ ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
72         : "=a" (__res) \
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); \
76 }
77
78 #undef _syscall6
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) \
82 { \
83 long __res; \
84 __asm__ __volatile__ ("push %%ebx; pushl %%ebp; movl %2,%%ebx; " \
85                       "movl %%eax,%%ebp; movl %1,%%eax; int $0x80; " \
86                       "pop %%ebp ; pop %%ebx" \
87         : "=a" (__res) \
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); \
92 }
93
94 #endif /* __PIC__ */
95
96 #endif /* _KLIBC_ARCHSYS_H */