]>
sourceware.org Git - glibc.git/blob - nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
b7009d753fe3df5e05840510dea35d60089fecaf
1 /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 # include <nptl/pthreadP.h>
26 #if !defined NOT_IN_libc || defined IS_IN_libpthread
29 # define PSEUDO(name, syscall_name, args) \
33 cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \
34 jne L(pseudo_cancel); \
35 DO_CALL (syscall_name, args); \
37 jae SYSCALL_ERROR_LABEL; \
44 movl $SYS_ify (syscall_name), %eax; \
45 /* Until we can handle unwinding from the sysenter page the kernel \
46 provides we cannot use ENTER_KERNEL here. */ \
51 jae SYSCALL_ERROR_LABEL; \
54 /* Create unwinding information for the syscall wrapper. */ \
55 .section .eh_frame,"a",@progbits; \
57 /* Length of the CIE. */ \
58 .long L(ENDCIE)-L(STARTCIE); \
62 /* Version number. */ \
64 /* NUL-terminated augmentation string. Note "z" means there is an \
65 augmentation value later on. */ \
67 /* Code alignment factor. */ \
69 /* Data alignment factor. */ \
71 /* Return address register column. */ \
73 /* Augmentation value length. */ \
75 /* Encoding: DW_EH_PE_pcrel + DW_EH_PE_sdata4. */ \
77 /* Start of the table initialization. */ \
85 /* Length of the FDE. */ \
86 .long L(ENDFDE)-L(STARTFDE); \
89 .long L(STARTFDE)-L(STARTFRAME); \
90 /* PC-relative start address of the code. */ \
91 .long L(name##START)-.; \
92 /* Length of the code. */ \
93 .long L(name##END)-L(name##START); \
94 /* No augmentation data. */ \
96 /* The rest of the code depends on the number of parameters the syscall \
98 EH_FRAME_##args(name); \
103 /* Callframe description for syscalls without parameters. This is very
104 simple. The only place the stack pointer is changed is when the old
105 cancellation state value is saved. */
106 # define EH_FRAME_0(name) \
108 .long L(PUSHSTATE)-name; \
112 .long L(POPSTATE)-L(PUSHSTATE); \
116 /* For syscalls with one and two parameters the code is the same as for
117 those which take no parameter. */
118 # define EH_FRAME_1(name) EH_FRAME_0 (name)
119 # define EH_FRAME_2(name) EH_FRAME_1 (name)
121 /* For syscalls with three parameters the stack pointer is changed
122 also to save the content of the %ebx register. */
123 # define EH_FRAME_3(name) \
125 .long L(PUSHBX1)-name; \
129 .long L(POPBX1)-L(PUSHBX1); \
133 .long L(PUSHSTATE)-L(POPBX1); \
137 .long L(PUSHBX2)-L(PUSHSTATE); \
141 .long L(POPBX2)-L(PUSHBX2); \
145 .long L(POPSTATE)-L(POPBX2); \
149 /* With four parameters the syscall wrappers have to save %ebx and %esi. */
150 # define EH_FRAME_4(name) \
152 .long L(PUSHSI1)-name; \
156 .long L(PUSHBX1)-L(PUSHSI1); \
160 .long L(POPBX1)-L(PUSHBX1); \
164 .long L(POPSI1)-L(POPBX1); \
168 .long L(PUSHSTATE)-L(POPSI1); \
172 .long L(PUSHSI2)-L(PUSHSTATE); \
176 .long L(PUSHBX2)-L(PUSHSI2); \
180 .long L(POPBX2)-L(PUSHBX2); \
184 .long L(POPSI2)-L(POPBX2); \
188 .long L(POPSTATE)-L(POPSI2); \
192 /* With five parameters the syscall wrappers have to save %ebx, %esi,
194 # define EH_FRAME_5(name) \
196 .long L(PUSHDI1)-name; \
200 .long L(PUSHSI1)-L(PUSHDI1); \
204 .long L(PUSHBX1)-L(PUSHSI1); \
208 .long L(POPBX1)-L(PUSHBX1); \
212 .long L(POPSI1)-L(POPBX1); \
216 .long L(POPDI1)-L(POPSI1); \
220 .long L(PUSHSTATE)-L(POPDI1); \
224 .long L(PUSHDI2)-L(PUSHSTATE); \
228 .long L(PUSHSI2)-L(PUSHDI2); \
232 .long L(PUSHBX2)-L(PUSHSI2); \
236 .long L(POPBX2)-L(PUSHBX2); \
240 .long L(POPSI2)-L(POPBX2); \
244 .long L(POPDI2)-L(POPSI2); \
248 .long L(POPSTATE)-L(POPDI2); \
253 # undef ASM_SIZE_DIRECTIVE
254 # define ASM_SIZE_DIRECTIVE(name) L(name##END): .size name,.-name;
256 # define SAVE_OLDTYPE_0 movl %eax, %edx;
257 # define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0
258 # define SAVE_OLDTYPE_2 pushl %eax; L(PUSHSTATE):
259 # define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2
260 # define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2
261 # define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2
263 # define PUSHCARGS_0 /* No arguments to push. */
264 # define DOCARGS_0 /* No arguments to frob. */
265 # define POPCARGS_0 /* No arguments to pop. */
266 # define _PUSHCARGS_0 /* No arguments to push. */
267 # define _POPCARGS_0 /* No arguments to pop. */
269 # define PUSHCARGS_1 movl %ebx, %edx; PUSHCARGS_0
270 # define DOCARGS_1 _DOARGS_1 (4)
271 # define POPCARGS_1 POPCARGS_0; movl %edx, %ebx
272 # define _PUSHCARGS_1 pushl %ebx; L(PUSHBX2): _PUSHCARGS_0
273 # define _POPCARGS_1 _POPCARGS_0; popl %ebx; L(POPBX2):
275 # define PUSHCARGS_2 PUSHCARGS_1
276 # define DOCARGS_2 _DOARGS_2 (12)
277 # define POPCARGS_2 POPCARGS_1
278 # define _PUSHCARGS_2 _PUSHCARGS_1
279 # define _POPCARGS_2 _POPCARGS_1
281 # define PUSHCARGS_3 _PUSHCARGS_2
282 # define DOCARGS_3 _DOARGS_3 (20)
283 # define POPCARGS_3 _POPCARGS_3
284 # define _PUSHCARGS_3 _PUSHCARGS_2
285 # define _POPCARGS_3 _POPCARGS_2
287 # define PUSHCARGS_4 _PUSHCARGS_4
288 # define DOCARGS_4 _DOARGS_4 (28)
289 # define POPCARGS_4 _POPCARGS_4
290 # define _PUSHCARGS_4 pushl %esi; L(PUSHSI2): _PUSHCARGS_3
291 # define _POPCARGS_4 _POPCARGS_3; popl %esi; L(POPSI2):
293 # define PUSHCARGS_5 _PUSHCARGS_5
294 # define DOCARGS_5 _DOARGS_5 (36)
295 # define POPCARGS_5 _POPCARGS_5
296 # define _PUSHCARGS_5 pushl %edi; L(PUSHDI2): _PUSHCARGS_4
297 # define _POPCARGS_5 _POPCARGS_4; popl %edi; L(POPDI2):
299 # ifdef IS_IN_libpthread
300 # define CENABLE call __pthread_enable_asynccancel;
301 # define CDISABLE call __pthread_disable_asynccancel
303 # define CENABLE call __libc_enable_asynccancel;
304 # define CDISABLE call __libc_disable_asynccancel
306 # define POPSTATE_0 \
307 pushl %eax; L(PUSHSTATE): movl %ecx, %eax; CDISABLE; popl %eax; L(POPSTATE):
308 # define POPSTATE_1 POPSTATE_0
309 # define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; L(POPSTATE):
310 # define POPSTATE_3 POPSTATE_2
311 # define POPSTATE_4 POPSTATE_3
312 # define POPSTATE_5 POPSTATE_4
314 # ifndef __ASSEMBLER__
315 # define SINGLE_THREAD_P \
316 __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
317 header.multiple_threads) == 0, 1)
319 # define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
322 #elif !defined __ASSEMBLER__
324 /* This code should never be used but we define it anyhow. */
325 # define SINGLE_THREAD_P (1)
This page took 0.047717 seconds and 4 git commands to generate.