1 #ifndef _BITS_SYSCALLS_H
2 #define _BITS_SYSCALLS_H
4 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
8 Some of the sneaky macros in the code were taken from
9 glibc-2.2.5/sysdeps/unix/sysv/linux/i386/sysdep.h
16 /* We need some help from the assembler to generate optimal code. We
17 define some macros here which later will be used. */
19 #if defined __SUPPORT_LD_DEBUG__ && defined __DOMULTI__
20 #error LD debugging and DOMULTI are incompatible
24 __asm__ (".L__X'%ebx = 1\n\t"
32 ".ifndef _BITS_SYSCALLS_ASM\n\t"
33 ".set _BITS_SYSCALLS_ASM,1\n\t"
34 ".macro bpushl name reg\n\t"
39 "xchgl \\reg, %ebx\n\t"
43 ".macro bpopl name reg\n\t"
48 "xchgl \\reg, %ebx\n\t"
52 ".macro bmovl name reg\n\t"
55 "movl \\reg, %ebx\n\t"
61 __asm__ (".L__X'%ebx = 1\n\t"
69 ".macro bpushl name reg\n\t"
74 "xchgl \\reg, %ebx\n\t"
78 ".macro bpopl name reg\n\t"
83 "xchgl \\reg, %ebx\n\t"
87 ".macro bmovl name reg\n\t"
90 "movl \\reg, %ebx\n\t"
96 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
98 register unsigned int resultvar; \
99 __asm__ __volatile__ ( \
101 "movl %1, %%eax\n\t" \
105 : "g" (name) ASMFMT_##nr(args) : "memory", "cc"); \
110 "bpushl .L__X'%k2, %k2\n\t" \
111 "bmovl .L__X'%k2, %k2\n\t"
112 #define LOADARGS_2 LOADARGS_1
113 #define LOADARGS_3 LOADARGS_1
114 #define LOADARGS_4 LOADARGS_1
115 #define LOADARGS_5 LOADARGS_1
116 #define LOADARGS_6 LOADARGS_1 "push %%ebp ; movl %7, %%ebp\n\t"
118 #define RESTOREARGS_0
119 #define RESTOREARGS_1 \
120 "bpopl .L__X'%k2, %k2\n\t"
121 #define RESTOREARGS_2 RESTOREARGS_1
122 #define RESTOREARGS_3 RESTOREARGS_1
123 #define RESTOREARGS_4 RESTOREARGS_1
124 #define RESTOREARGS_5 RESTOREARGS_1
125 #define RESTOREARGS_6 "pop %%ebp\n\t" RESTOREARGS_1
128 #define ASMFMT_1(arg1) \
130 #define ASMFMT_2(arg1, arg2) \
131 , "adSD" (arg1), "c" (arg2)
132 #define ASMFMT_3(arg1, arg2, arg3) \
133 , "aSD" (arg1), "c" (arg2), "d" (arg3)
134 #define ASMFMT_4(arg1, arg2, arg3, arg4) \
135 , "aD" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
136 #define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
137 , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
138 #define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
139 , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6)
141 #endif /* __ASSEMBLER__ */
142 #endif /* _BITS_SYSCALLS_H */