Commit 83fcb515481f72b9bc74c22490fe5a4f4de20dd6
1 parent
5b9053a5
use glibc syscall (David Woodhouse)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1966 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
38 additions
and
103 deletions
linux-user/syscall.c
@@ -79,127 +79,59 @@ | @@ -79,127 +79,59 @@ | ||
79 | #define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) | 79 | #define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) |
80 | 80 | ||
81 | 81 | ||
82 | -#if defined(__powerpc__) | ||
83 | -#undef __syscall_nr | ||
84 | -#undef __sc_loadargs_0 | ||
85 | -#undef __sc_loadargs_1 | ||
86 | -#undef __sc_loadargs_2 | ||
87 | -#undef __sc_loadargs_3 | ||
88 | -#undef __sc_loadargs_4 | ||
89 | -#undef __sc_loadargs_5 | ||
90 | -#undef __sc_asm_input_0 | ||
91 | -#undef __sc_asm_input_1 | ||
92 | -#undef __sc_asm_input_2 | ||
93 | -#undef __sc_asm_input_3 | ||
94 | -#undef __sc_asm_input_4 | ||
95 | -#undef __sc_asm_input_5 | ||
96 | #undef _syscall0 | 82 | #undef _syscall0 |
97 | #undef _syscall1 | 83 | #undef _syscall1 |
98 | #undef _syscall2 | 84 | #undef _syscall2 |
99 | #undef _syscall3 | 85 | #undef _syscall3 |
100 | #undef _syscall4 | 86 | #undef _syscall4 |
101 | #undef _syscall5 | 87 | #undef _syscall5 |
88 | +#undef _syscall6 | ||
102 | 89 | ||
103 | -/* need to redefine syscalls as Linux kernel defines are incorrect for | ||
104 | - the clobber list */ | ||
105 | -/* On powerpc a system call basically clobbers the same registers like a | ||
106 | - * function call, with the exception of LR (which is needed for the | ||
107 | - * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal | ||
108 | - * an error return status). | ||
109 | - */ | 90 | +#define _syscall0(type,name) \ |
91 | +type name (void) \ | ||
92 | +{ \ | ||
93 | + return syscall(__NR_##name); \ | ||
94 | +} | ||
110 | 95 | ||
111 | -#define __syscall_nr(nr, type, name, args...) \ | ||
112 | - unsigned long __sc_ret, __sc_err; \ | ||
113 | - { \ | ||
114 | - register unsigned long __sc_0 __asm__ ("r0"); \ | ||
115 | - register unsigned long __sc_3 __asm__ ("r3"); \ | ||
116 | - register unsigned long __sc_4 __asm__ ("r4"); \ | ||
117 | - register unsigned long __sc_5 __asm__ ("r5"); \ | ||
118 | - register unsigned long __sc_6 __asm__ ("r6"); \ | ||
119 | - register unsigned long __sc_7 __asm__ ("r7"); \ | ||
120 | - \ | ||
121 | - __sc_loadargs_##nr(name, args); \ | ||
122 | - __asm__ __volatile__ \ | ||
123 | - ("sc \n\t" \ | ||
124 | - "mfcr %0 " \ | ||
125 | - : "=&r" (__sc_0), \ | ||
126 | - "=&r" (__sc_3), "=&r" (__sc_4), \ | ||
127 | - "=&r" (__sc_5), "=&r" (__sc_6), \ | ||
128 | - "=&r" (__sc_7) \ | ||
129 | - : __sc_asm_input_##nr \ | ||
130 | - : "cr0", "ctr", "memory", \ | ||
131 | - "r8", "r9", "r10","r11", "r12"); \ | ||
132 | - __sc_ret = __sc_3; \ | ||
133 | - __sc_err = __sc_0; \ | ||
134 | - } \ | ||
135 | - if (__sc_err & 0x10000000) \ | ||
136 | - { \ | ||
137 | - errno = __sc_ret; \ | ||
138 | - __sc_ret = -1; \ | ||
139 | - } \ | ||
140 | - return (type) __sc_ret | ||
141 | - | ||
142 | -#define __sc_loadargs_0(name, dummy...) \ | ||
143 | - __sc_0 = __NR_##name | ||
144 | -#define __sc_loadargs_1(name, arg1) \ | ||
145 | - __sc_loadargs_0(name); \ | ||
146 | - __sc_3 = (unsigned long) (arg1) | ||
147 | -#define __sc_loadargs_2(name, arg1, arg2) \ | ||
148 | - __sc_loadargs_1(name, arg1); \ | ||
149 | - __sc_4 = (unsigned long) (arg2) | ||
150 | -#define __sc_loadargs_3(name, arg1, arg2, arg3) \ | ||
151 | - __sc_loadargs_2(name, arg1, arg2); \ | ||
152 | - __sc_5 = (unsigned long) (arg3) | ||
153 | -#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \ | ||
154 | - __sc_loadargs_3(name, arg1, arg2, arg3); \ | ||
155 | - __sc_6 = (unsigned long) (arg4) | ||
156 | -#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \ | ||
157 | - __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \ | ||
158 | - __sc_7 = (unsigned long) (arg5) | ||
159 | - | ||
160 | -#define __sc_asm_input_0 "0" (__sc_0) | ||
161 | -#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3) | ||
162 | -#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4) | ||
163 | -#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5) | ||
164 | -#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6) | ||
165 | -#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7) | ||
166 | - | ||
167 | -#define _syscall0(type,name) \ | ||
168 | -type name(void) \ | ||
169 | -{ \ | ||
170 | - __syscall_nr(0, type, name); \ | 96 | +#define _syscall1(type,name,type1,arg1) \ |
97 | +type name (type1 arg1) \ | ||
98 | +{ \ | ||
99 | + return syscall(__NR_##name, arg1); \ | ||
171 | } | 100 | } |
172 | 101 | ||
173 | -#define _syscall1(type,name,type1,arg1) \ | ||
174 | -type name(type1 arg1) \ | ||
175 | -{ \ | ||
176 | - __syscall_nr(1, type, name, arg1); \ | 102 | +#define _syscall2(type,name,type1,arg1,type2,arg2) \ |
103 | +type name (type1 arg1,type2 arg2) \ | ||
104 | +{ \ | ||
105 | + return syscall(__NR_##name, arg1, arg2); \ | ||
177 | } | 106 | } |
178 | 107 | ||
179 | -#define _syscall2(type,name,type1,arg1,type2,arg2) \ | ||
180 | -type name(type1 arg1, type2 arg2) \ | ||
181 | -{ \ | ||
182 | - __syscall_nr(2, type, name, arg1, arg2); \ | 108 | +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ |
109 | +type name (type1 arg1,type2 arg2,type3 arg3) \ | ||
110 | +{ \ | ||
111 | + return syscall(__NR_##name, arg1, arg2, arg3); \ | ||
183 | } | 112 | } |
184 | 113 | ||
185 | -#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ | ||
186 | -type name(type1 arg1, type2 arg2, type3 arg3) \ | ||
187 | -{ \ | ||
188 | - __syscall_nr(3, type, name, arg1, arg2, arg3); \ | 114 | +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ |
115 | +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \ | ||
116 | +{ \ | ||
117 | + return syscall(__NR_##name, arg1, arg2, arg3, arg4); \ | ||
189 | } | 118 | } |
190 | 119 | ||
191 | -#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ | ||
192 | -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ | ||
193 | -{ \ | ||
194 | - __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \ | 120 | +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
121 | + type5,arg5) \ | ||
122 | +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ | ||
123 | +{ \ | ||
124 | + return syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5); \ | ||
195 | } | 125 | } |
196 | 126 | ||
197 | -#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \ | ||
198 | -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \ | ||
199 | -{ \ | ||
200 | - __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \ | 127 | + |
128 | +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | ||
129 | + type5,arg5,type6,arg6) \ | ||
130 | +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \ | ||
131 | +{ \ | ||
132 | + return syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ | ||
201 | } | 133 | } |
202 | -#endif | 134 | + |
203 | 135 | ||
204 | #define __NR_sys_uname __NR_uname | 136 | #define __NR_sys_uname __NR_uname |
205 | #define __NR_sys_getcwd1 __NR_getcwd | 137 | #define __NR_sys_getcwd1 __NR_getcwd |
target-i386/helper2.c
@@ -35,7 +35,10 @@ | @@ -35,7 +35,10 @@ | ||
35 | #include <linux/unistd.h> | 35 | #include <linux/unistd.h> |
36 | #include <linux/version.h> | 36 | #include <linux/version.h> |
37 | 37 | ||
38 | -_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount) | 38 | +int modify_ldt(int func, void *ptr, unsigned long bytecount) |
39 | +{ | ||
40 | + return syscall(__NR_modify_ldt, func, ptr, bytecount); | ||
41 | +} | ||
39 | 42 | ||
40 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 66) | 43 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 66) |
41 | #define modify_ldt_ldt_s user_desc | 44 | #define modify_ldt_ldt_s user_desc |