]>
Commit | Line | Data |
---|---|---|
26420023 | 1 | /* Copyright (C) 1992-2025 Free Software Foundation, Inc. |
bfbc5754 | 2 | This file is part of the GNU C Library. |
bfbc5754 UD |
3 | |
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
bfbc5754 UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
bfbc5754 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
d2f5be2a | 17 | |
ec4b0518 UD |
18 | #ifndef _LINUX_I386_SYSDEP_H |
19 | #define _LINUX_I386_SYSDEP_H 1 | |
20 | ||
d2f5be2a | 21 | /* There is some commonality. */ |
fb1cf108 | 22 | #include <sysdeps/unix/sysv/linux/sysdep.h> |
d2f5be2a | 23 | #include <sysdeps/unix/i386/sysdep.h> |
131fd126 | 24 | /* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */ |
5f5843e3 | 25 | #include <dl-sysdep.h> |
739d440d | 26 | #include <tls.h> |
d2f5be2a | 27 | |
ce460d04 | 28 | |
d2f5be2a UD |
29 | /* For Linux we can use the system call table in the header file |
30 | /usr/include/asm/unistd.h | |
31 | of the kernel. But these symbols do not follow the SYS_* syntax | |
32 | so we have to redefine the `SYS_ify' macro here. */ | |
33 | #undef SYS_ify | |
6ed0492f | 34 | #define SYS_ify(syscall_name) __NR_##syscall_name |
d2f5be2a | 35 | |
627c69c8 L |
36 | #ifndef I386_USE_SYSENTER |
37 | # if defined USE_DL_SYSINFO \ | |
38 | && (IS_IN (libc) || IS_IN (libpthread)) | |
39 | # define I386_USE_SYSENTER 1 | |
40 | # else | |
41 | # define I386_USE_SYSENTER 0 | |
42 | # endif | |
5f5843e3 UD |
43 | #endif |
44 | ||
60f0f213 FW |
45 | #if !I386_USE_SYSENTER && IS_IN (libc) && !defined SHARED |
46 | /* Inside static libc, we have two versions. For compilation units | |
47 | with !I386_USE_SYSENTER, the vDSO entry mechanism cannot be | |
48 | used. */ | |
49 | # define I386_DO_SYSCALL_STRING "__libc_do_syscall_int80" | |
50 | #else | |
51 | # define I386_DO_SYSCALL_STRING "__libc_do_syscall" | |
52 | #endif | |
53 | ||
c2afe833 RM |
54 | #ifdef __ASSEMBLER__ |
55 | ||
cccda09f UD |
56 | /* Linux uses a negative return value to indicate syscall errors, |
57 | unlike most Unices, which use the condition codes' carry flag. | |
58 | ||
59 | Since version 2.1 the return value of a system call might be | |
60 | negative even if the call succeeded. E.g., the `lseek' system call | |
61 | might return a large offset. Therefore we must not anymore test | |
62 | for < 0, but test for a real error by making sure the value in %eax | |
b5791037 | 63 | is a real error number. Linus said he will make sure the no syscall |
d13733c1 | 64 | returns a value in -1 .. -4095 as a valid result so we can safely |
b5791037 | 65 | test with -4095. */ |
c0fb8a56 UD |
66 | |
67 | /* We don't want the label for the error handle to be global when we define | |
68 | it here. */ | |
fcb78a55 | 69 | #undef SYSCALL_ERROR_LABEL |
fb1cf108 | 70 | #define SYSCALL_ERROR_LABEL __syscall_error |
c0fb8a56 | 71 | |
d2f5be2a UD |
72 | #undef PSEUDO |
73 | #define PSEUDO(name, syscall_name, args) \ | |
74 | .text; \ | |
d2f5be2a | 75 | ENTRY (name) \ |
ffa8d2a0 | 76 | DO_CALL (syscall_name, args); \ |
b5791037 | 77 | cmpl $-4095, %eax; \ |
842a39cd | 78 | jae SYSCALL_ERROR_LABEL |
d2f5be2a | 79 | |
6ed0492f UD |
80 | #undef PSEUDO_END |
81 | #define PSEUDO_END(name) \ | |
82 | SYSCALL_ERROR_HANDLER \ | |
83 | END (name) | |
84 | ||
9eb88290 UD |
85 | #undef PSEUDO_NOERRNO |
86 | #define PSEUDO_NOERRNO(name, syscall_name, args) \ | |
87 | .text; \ | |
88 | ENTRY (name) \ | |
89 | DO_CALL (syscall_name, args) | |
90 | ||
91 | #undef PSEUDO_END_NOERRNO | |
92 | #define PSEUDO_END_NOERRNO(name) \ | |
93 | END (name) | |
94 | ||
95 | #define ret_NOERRNO ret | |
96 | ||
bfef9264 UD |
97 | /* The function has to return the error code. */ |
98 | #undef PSEUDO_ERRVAL | |
99 | #define PSEUDO_ERRVAL(name, syscall_name, args) \ | |
100 | .text; \ | |
101 | ENTRY (name) \ | |
102 | DO_CALL (syscall_name, args); \ | |
103 | negl %eax | |
104 | ||
105 | #undef PSEUDO_END_ERRVAL | |
106 | #define PSEUDO_END_ERRVAL(name) \ | |
107 | END (name) | |
108 | ||
109 | #define ret_ERRVAL ret | |
110 | ||
fb1cf108 | 111 | #define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.c is used. */ |
f051627f UD |
112 | |
113 | /* The original calling convention for system calls on Linux/i386 is | |
114 | to use int $0x80. */ | |
627c69c8 L |
115 | #if I386_USE_SYSENTER |
116 | # ifdef PIC | |
5f5843e3 UD |
117 | # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET |
118 | # else | |
119 | # define ENTER_KERNEL call *_dl_sysinfo | |
120 | # endif | |
121 | #else | |
122 | # define ENTER_KERNEL int $0x80 | |
123 | #endif | |
f051627f | 124 | |
d2f5be2a UD |
125 | /* Linux takes system call arguments in registers: |
126 | ||
127 | syscall number %eax call-clobbered | |
128 | arg 1 %ebx call-saved | |
129 | arg 2 %ecx call-clobbered | |
130 | arg 3 %edx call-clobbered | |
131 | arg 4 %esi call-saved | |
132 | arg 5 %edi call-saved | |
b2bcd249 | 133 | arg 6 %ebp call-saved |
d2f5be2a UD |
134 | |
135 | The stack layout upon entering the function is: | |
136 | ||
b2bcd249 | 137 | 24(%esp) Arg# 6 |
d2f5be2a UD |
138 | 20(%esp) Arg# 5 |
139 | 16(%esp) Arg# 4 | |
140 | 12(%esp) Arg# 3 | |
141 | 8(%esp) Arg# 2 | |
142 | 4(%esp) Arg# 1 | |
143 | (%esp) Return address | |
144 | ||
145 | (Of course a function with say 3 arguments does not have entries for | |
b2bcd249 | 146 | arguments 4, 5, and 6.) |
d2f5be2a | 147 | |
6ed0492f | 148 | The following code tries hard to be optimal. A general assumption |
03a75825 | 149 | (which is true according to the data books I have) is that |
d2f5be2a UD |
150 | |
151 | 2 * xchg is more expensive than pushl + movl + popl | |
152 | ||
153 | Beside this a neat trick is used. The calling conventions for Linux | |
154 | tell that among the registers used for parameters %ecx and %edx need | |
155 | not be saved. Beside this we may clobber this registers even when | |
156 | they are not used for parameter passing. | |
157 | ||
158 | As a result one can see below that we save the content of the %ebx | |
159 | register in the %edx register when we have less than 3 arguments | |
160 | (2 * movl is less expensive than pushl + popl). | |
161 | ||
162 | Second unlike for the other registers we don't save the content of | |
6ed0492f | 163 | %ecx and %edx when we have more than 1 and 2 registers resp. |
8f5ca04b RM |
164 | |
165 | The code below might look a bit long but we have to take care for | |
63bda0c1 | 166 | the pipelined processors (i586). Here the `pushl' and `popl' |
8f5ca04b RM |
167 | instructions are marked as NP (not pairable) but the exception is |
168 | two consecutive of these instruction. This gives no penalty on | |
63bda0c1 | 169 | other processors though. */ |
d2f5be2a UD |
170 | |
171 | #undef DO_CALL | |
ffa8d2a0 | 172 | #define DO_CALL(syscall_name, args) \ |
8f5ca04b | 173 | PUSHARGS_##args \ |
d2f5be2a | 174 | DOARGS_##args \ |
c14e4c32 | 175 | movl $SYS_ify (syscall_name), %eax; \ |
f051627f | 176 | ENTER_KERNEL \ |
8f5ca04b | 177 | POPARGS_##args |
d2f5be2a | 178 | |
8f5ca04b | 179 | #define PUSHARGS_0 /* No arguments to push. */ |
d2f5be2a | 180 | #define DOARGS_0 /* No arguments to frob. */ |
8f5ca04b RM |
181 | #define POPARGS_0 /* No arguments to pop. */ |
182 | #define _PUSHARGS_0 /* No arguments to push. */ | |
183 | #define _DOARGS_0(n) /* No arguments to frob. */ | |
184 | #define _POPARGS_0 /* No arguments to pop. */ | |
185 | ||
bd4f43b4 | 186 | #define PUSHARGS_1 movl %ebx, %edx; L(SAVEBX1): PUSHARGS_0 |
8f5ca04b | 187 | #define DOARGS_1 _DOARGS_1 (4) |
bd4f43b4 | 188 | #define POPARGS_1 POPARGS_0; movl %edx, %ebx; L(RESTBX1): |
62d01985 UD |
189 | #define _PUSHARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \ |
190 | cfi_rel_offset (ebx, 0); L(PUSHBX1): _PUSHARGS_0 | |
8f5ca04b | 191 | #define _DOARGS_1(n) movl n(%esp), %ebx; _DOARGS_0(n-4) |
62d01985 UD |
192 | #define _POPARGS_1 _POPARGS_0; popl %ebx; cfi_adjust_cfa_offset (-4); \ |
193 | cfi_restore (ebx); L(POPBX1): | |
8f5ca04b RM |
194 | |
195 | #define PUSHARGS_2 PUSHARGS_1 | |
196 | #define DOARGS_2 _DOARGS_2 (8) | |
197 | #define POPARGS_2 POPARGS_1 | |
198 | #define _PUSHARGS_2 _PUSHARGS_1 | |
d2f5be2a | 199 | #define _DOARGS_2(n) movl n(%esp), %ecx; _DOARGS_1 (n-4) |
8f5ca04b | 200 | #define _POPARGS_2 _POPARGS_1 |
d2f5be2a | 201 | |
8f5ca04b RM |
202 | #define PUSHARGS_3 _PUSHARGS_2 |
203 | #define DOARGS_3 _DOARGS_3 (16) | |
204 | #define POPARGS_3 _POPARGS_3 | |
205 | #define _PUSHARGS_3 _PUSHARGS_2 | |
d2f5be2a | 206 | #define _DOARGS_3(n) movl n(%esp), %edx; _DOARGS_2 (n-4) |
8f5ca04b RM |
207 | #define _POPARGS_3 _POPARGS_2 |
208 | ||
209 | #define PUSHARGS_4 _PUSHARGS_4 | |
210 | #define DOARGS_4 _DOARGS_4 (24) | |
211 | #define POPARGS_4 _POPARGS_4 | |
62d01985 UD |
212 | #define _PUSHARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \ |
213 | cfi_rel_offset (esi, 0); L(PUSHSI1): _PUSHARGS_3 | |
8f5ca04b | 214 | #define _DOARGS_4(n) movl n(%esp), %esi; _DOARGS_3 (n-4) |
62d01985 UD |
215 | #define _POPARGS_4 _POPARGS_3; popl %esi; cfi_adjust_cfa_offset (-4); \ |
216 | cfi_restore (esi); L(POPSI1): | |
8f5ca04b RM |
217 | |
218 | #define PUSHARGS_5 _PUSHARGS_5 | |
219 | #define DOARGS_5 _DOARGS_5 (32) | |
220 | #define POPARGS_5 _POPARGS_5 | |
62d01985 UD |
221 | #define _PUSHARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \ |
222 | cfi_rel_offset (edi, 0); L(PUSHDI1): _PUSHARGS_4 | |
8f5ca04b | 223 | #define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4) |
62d01985 UD |
224 | #define _POPARGS_5 _POPARGS_4; popl %edi; cfi_adjust_cfa_offset (-4); \ |
225 | cfi_restore (edi); L(POPDI1): | |
d2f5be2a | 226 | |
0da7bcc5 | 227 | #define PUSHARGS_6 _PUSHARGS_6 |
46c38bd7 | 228 | #define DOARGS_6 _DOARGS_6 (40) |
0da7bcc5 | 229 | #define POPARGS_6 _POPARGS_6 |
62d01985 UD |
230 | #define _PUSHARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \ |
231 | cfi_rel_offset (ebp, 0); L(PUSHBP1): _PUSHARGS_5 | |
0da7bcc5 | 232 | #define _DOARGS_6(n) movl n(%esp), %ebp; _DOARGS_5 (n-4) |
62d01985 UD |
233 | #define _POPARGS_6 _POPARGS_5; popl %ebp; cfi_adjust_cfa_offset (-4); \ |
234 | cfi_restore (ebp); L(POPBP1): | |
0da7bcc5 | 235 | |
adcb550c UD |
236 | #else /* !__ASSEMBLER__ */ |
237 | ||
fb1cf108 L |
238 | extern int __syscall_error (int) |
239 | attribute_hidden __attribute__ ((__regparm__ (1))); | |
240 | ||
a9fe4c5a JM |
241 | /* Six-argument syscalls use an out-of-line helper, because an inline |
242 | asm using all registers apart from %esp cannot work reliably and | |
243 | the assembler does not support describing an asm that saves and | |
244 | restores %ebp itself as a separate stack frame. This structure | |
245 | stores the arguments not passed in registers; %edi is passed with a | |
246 | pointer to this structure. */ | |
247 | struct libc_do_syscall_args | |
248 | { | |
249 | int ebx, edi, ebp; | |
250 | }; | |
251 | ||
b8386c28 AZ |
252 | # define VDSO_NAME "LINUX_2.6" |
253 | # define VDSO_HASH 61765110 | |
254 | ||
1395ef21 | 255 | /* List of system calls which are supported as vsyscalls. */ |
b8a7c7da | 256 | # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" |
2d77a447 | 257 | # define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime64" |
b8a7c7da | 258 | # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" |
eca6aec6 AZ |
259 | # define HAVE_TIME_VSYSCALL "__vdso_time" |
260 | # define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" | |
1395ef21 | 261 | |
c25c3216 | 262 | # define HAVE_CLONE3_WRAPPER 1 |
5adb0e14 | 263 | |
72048093 AZ |
264 | # undef HAVE_INTERNAL_BRK_ADDR_SYMBOL |
265 | # define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1 | |
266 | ||
ce460d04 RM |
267 | /* Define a macro which expands inline into the wrapper code for a system |
268 | call. This use is for internal calls that do not need to handle errors | |
269 | normally. It will never touch errno. This returns just what the kernel | |
2edb61e3 UD |
270 | gave back. |
271 | ||
272 | The _NCS variant allows non-constant syscall numbers but it is not | |
273 | possible to use more than four parameters. */ | |
ce460d04 | 274 | #undef INTERNAL_SYSCALL |
bc2eb932 AZ |
275 | #define INTERNAL_SYSCALL_MAIN_0(name, args...) \ |
276 | INTERNAL_SYSCALL_MAIN_INLINE(name, 0, args) | |
277 | #define INTERNAL_SYSCALL_MAIN_1(name, args...) \ | |
278 | INTERNAL_SYSCALL_MAIN_INLINE(name, 1, args) | |
279 | #define INTERNAL_SYSCALL_MAIN_2(name, args...) \ | |
280 | INTERNAL_SYSCALL_MAIN_INLINE(name, 2, args) | |
281 | #define INTERNAL_SYSCALL_MAIN_3(name, args...) \ | |
282 | INTERNAL_SYSCALL_MAIN_INLINE(name, 3, args) | |
283 | #define INTERNAL_SYSCALL_MAIN_4(name, args...) \ | |
284 | INTERNAL_SYSCALL_MAIN_INLINE(name, 4, args) | |
285 | #define INTERNAL_SYSCALL_MAIN_5(name, args...) \ | |
286 | INTERNAL_SYSCALL_MAIN_INLINE(name, 5, args) | |
4b850b1f AZ |
287 | |
288 | #define INTERNAL_SYSCALL_MAIN_NCS_0(name, args...) \ | |
289 | INTERNAL_SYSCALL_MAIN_NCS(name, 0, args) | |
290 | #define INTERNAL_SYSCALL_MAIN_NCS_1(name, args...) \ | |
291 | INTERNAL_SYSCALL_MAIN_NCS(name, 1, args) | |
292 | #define INTERNAL_SYSCALL_MAIN_NCS_2(name, args...) \ | |
293 | INTERNAL_SYSCALL_MAIN_NCS(name, 2, args) | |
294 | #define INTERNAL_SYSCALL_MAIN_NCS_3(name, args...) \ | |
295 | INTERNAL_SYSCALL_MAIN_NCS(name, 3, args) | |
296 | #define INTERNAL_SYSCALL_MAIN_NCS_4(name, args...) \ | |
297 | INTERNAL_SYSCALL_MAIN_NCS(name, 4, args) | |
298 | #define INTERNAL_SYSCALL_MAIN_NCS_5(name, args...) \ | |
299 | INTERNAL_SYSCALL_MAIN_NCS(name, 5, args) | |
300 | ||
a9fe4c5a JM |
301 | /* Each object using 6-argument inline syscalls must include a |
302 | definition of __libc_do_syscall. */ | |
a78e6a10 FW |
303 | #define INTERNAL_SYSCALL_MAIN_6(name, arg1, arg2, arg3, \ |
304 | arg4, arg5, arg6) \ | |
a9fe4c5a JM |
305 | struct libc_do_syscall_args _xv = \ |
306 | { \ | |
307 | (int) (arg1), \ | |
308 | (int) (arg5), \ | |
309 | (int) (arg6) \ | |
310 | }; \ | |
311 | asm volatile ( \ | |
312 | "movl %1, %%eax\n\t" \ | |
60f0f213 | 313 | "call " I386_DO_SYSCALL_STRING \ |
a9fe4c5a JM |
314 | : "=a" (resultvar) \ |
315 | : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \ | |
316 | : "memory", "cc") | |
a78e6a10 FW |
317 | #define INTERNAL_SYSCALL_MAIN_NCS_6(name, arg1, arg2, arg3, \ |
318 | arg4, arg5, arg6) \ | |
4b850b1f AZ |
319 | struct libc_do_syscall_args _xv = \ |
320 | { \ | |
321 | (int) (arg1), \ | |
322 | (int) (arg5), \ | |
323 | (int) (arg6) \ | |
324 | }; \ | |
325 | asm volatile ( \ | |
326 | "movl %1, %%eax\n\t" \ | |
60f0f213 | 327 | "call " I386_DO_SYSCALL_STRING \ |
4b850b1f AZ |
328 | : "=a" (resultvar) \ |
329 | : "a" (name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \ | |
330 | : "memory", "cc") | |
4b850b1f | 331 | |
bc2eb932 | 332 | #define INTERNAL_SYSCALL(name, nr, args...) \ |
5f5843e3 | 333 | ({ \ |
7a114794 | 334 | register unsigned int resultvar; \ |
bc2eb932 | 335 | INTERNAL_SYSCALL_MAIN_##nr (name, args); \ |
a9fe4c5a | 336 | (int) resultvar; }) |
4b850b1f AZ |
337 | #define INTERNAL_SYSCALL_NCS(name, nr, args...) \ |
338 | ({ \ | |
339 | register unsigned int resultvar; \ | |
340 | INTERNAL_SYSCALL_MAIN_NCS_##nr (name, args); \ | |
341 | (int) resultvar; }) | |
342 | ||
627c69c8 | 343 | #if I386_USE_SYSENTER |
a78e6a10 FW |
344 | # ifdef PIC |
345 | # define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \ | |
98ad631c L |
346 | LOADREGS_##nr(args) \ |
347 | asm volatile ( \ | |
348 | "call *%%gs:%P2" \ | |
349 | : "=a" (resultvar) \ | |
350 | : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \ | |
351 | ASMARGS_##nr(args) : "memory", "cc") | |
a78e6a10 | 352 | # define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \ |
98ad631c L |
353 | LOADREGS_##nr(args) \ |
354 | asm volatile ( \ | |
355 | "call *%%gs:%P2" \ | |
356 | : "=a" (resultvar) \ | |
357 | : "a" (name), "i" (offsetof (tcbhead_t, sysinfo)) \ | |
4b850b1f | 358 | ASMARGS_##nr(args) : "memory", "cc") |
a78e6a10 FW |
359 | # else /* I386_USE_SYSENTER && !PIC */ |
360 | # define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \ | |
98ad631c L |
361 | LOADREGS_##nr(args) \ |
362 | asm volatile ( \ | |
363 | "call *_dl_sysinfo" \ | |
364 | : "=a" (resultvar) \ | |
365 | : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc") | |
a78e6a10 | 366 | # define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \ |
98ad631c L |
367 | LOADREGS_##nr(args) \ |
368 | asm volatile ( \ | |
369 | "call *_dl_sysinfo" \ | |
370 | : "=a" (resultvar) \ | |
4b850b1f | 371 | : "a" (name) ASMARGS_##nr(args) : "memory", "cc") |
a78e6a10 FW |
372 | # endif /* I386_USE_SYSENTER && !PIC */ |
373 | #else /* !I386_USE_SYSENTER */ | |
374 | # define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \ | |
98ad631c L |
375 | LOADREGS_##nr(args) \ |
376 | asm volatile ( \ | |
377 | "int $0x80" \ | |
378 | : "=a" (resultvar) \ | |
379 | : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc") | |
a78e6a10 | 380 | # define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \ |
98ad631c L |
381 | LOADREGS_##nr(args) \ |
382 | asm volatile ( \ | |
383 | "int $0x80" \ | |
384 | : "=a" (resultvar) \ | |
4b850b1f | 385 | : "a" (name) ASMARGS_##nr(args) : "memory", "cc") |
a78e6a10 | 386 | #endif /* !I386_USE_SYSENTER */ |
44129238 | 387 | |
a78e6a10 FW |
388 | #define LOADREGS_0() |
389 | #define ASMARGS_0() | |
390 | #define LOADREGS_1(arg1) \ | |
98ad631c | 391 | LOADREGS_0 () |
a78e6a10 | 392 | #define ASMARGS_1(arg1) \ |
98ad631c | 393 | ASMARGS_0 (), "b" ((unsigned int) (arg1)) |
a78e6a10 | 394 | #define LOADREGS_2(arg1, arg2) \ |
98ad631c | 395 | LOADREGS_1 (arg1) |
a78e6a10 | 396 | #define ASMARGS_2(arg1, arg2) \ |
98ad631c | 397 | ASMARGS_1 (arg1), "c" ((unsigned int) (arg2)) |
a78e6a10 | 398 | #define LOADREGS_3(arg1, arg2, arg3) \ |
98ad631c | 399 | LOADREGS_2 (arg1, arg2) |
a78e6a10 | 400 | #define ASMARGS_3(arg1, arg2, arg3) \ |
98ad631c | 401 | ASMARGS_2 (arg1, arg2), "d" ((unsigned int) (arg3)) |
a78e6a10 | 402 | #define LOADREGS_4(arg1, arg2, arg3, arg4) \ |
98ad631c | 403 | LOADREGS_3 (arg1, arg2, arg3) |
a78e6a10 | 404 | #define ASMARGS_4(arg1, arg2, arg3, arg4) \ |
98ad631c | 405 | ASMARGS_3 (arg1, arg2, arg3), "S" ((unsigned int) (arg4)) |
a78e6a10 | 406 | #define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \ |
98ad631c | 407 | LOADREGS_4 (arg1, arg2, arg3, arg4) |
a78e6a10 | 408 | #define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \ |
98ad631c | 409 | ASMARGS_4 (arg1, arg2, arg3, arg4), "D" ((unsigned int) (arg5)) |
98ad631c | 410 | |
7bb38c70 | 411 | #define ASMFMT_0() |
7a114794 UD |
412 | #ifdef __PIC__ |
413 | # define ASMFMT_1(arg1) \ | |
414 | , "cd" (arg1) | |
415 | # define ASMFMT_2(arg1, arg2) \ | |
3a370de8 | 416 | , "d" (arg1), "c" (arg2) |
7a114794 UD |
417 | # define ASMFMT_3(arg1, arg2, arg3) \ |
418 | , "D" (arg1), "c" (arg2), "d" (arg3) | |
419 | # define ASMFMT_4(arg1, arg2, arg3, arg4) \ | |
420 | , "D" (arg1), "c" (arg2), "d" (arg3), "S" (arg4) | |
421 | # define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \ | |
422 | , "0" (arg1), "m" (_xv), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) | |
423 | #else | |
424 | # define ASMFMT_1(arg1) \ | |
425 | , "b" (arg1) | |
426 | # define ASMFMT_2(arg1, arg2) \ | |
427 | , "b" (arg1), "c" (arg2) | |
428 | # define ASMFMT_3(arg1, arg2, arg3) \ | |
429 | , "b" (arg1), "c" (arg2), "d" (arg3) | |
430 | # define ASMFMT_4(arg1, arg2, arg3, arg4) \ | |
431 | , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4) | |
432 | # define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \ | |
433 | , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) | |
434 | #endif | |
435 | ||
436 | #define EXTRAVAR_0 | |
437 | #define EXTRAVAR_1 | |
438 | #define EXTRAVAR_2 | |
439 | #define EXTRAVAR_3 | |
440 | #define EXTRAVAR_4 | |
441 | #ifdef __PIC__ | |
442 | # define EXTRAVAR_5 int _xv; | |
443 | #else | |
444 | # define EXTRAVAR_5 | |
445 | #endif | |
adcb550c | 446 | |
66715f83 | 447 | #endif /* __ASSEMBLER__ */ |
ec4b0518 UD |
448 | |
449 | #endif /* linux/i386/sysdep.h */ |