2004-05-04 06:40:52 +08:00
|
|
|
/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
2003-03-11 17:30:37 +08:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <tls.h>
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
# include <nptl/pthreadP.h>
|
|
|
|
#endif
|
|
|
|
|
Update.
2003-06-15 Ulrich Drepper <drepper@redhat.com>
Fix cancellation point handling wrt exception based cleanup.
* io/Makefile: Compile fcntl.c, poll.c, and lockf.c with exceptions.
* misc/Makefile: Compile pselect.c, readv.c, writev.c, and usleep.c
with exceptions.
* posix/Makefile: Compile pread.c, pread64.c, pwrite.c, pwrite64.c,
sleep.c, wait.c, waitid.c, and waitpid.c with exceptions.
* rt/Makefile: Compile aio_suspend.c and clock_nanosleep.c with
exceptions.
* signal/Makefile: Compile sigpause.c, sigsuspend.c, sigtimedwait.c,
sigwait.c, and sigwaitinfo.c with exceptions.
* stdlib/Makefile: Compile system.c with exceptions.
* sysvipc/Makefile: Compile msgrcv.c and msgsnd.c with exceptions.
* termios/Makefile: Compile tcdrain.c with exceptions.
* sysdeps/generic/lockf.c: Add comment explaining the cancellation
situation.
* sysdeps/generic/pselect.c: Likewise.
* sysdeps/posix/sigpause.c: Likewise.
* sysdeps/posix/system.c: Likewise.
* sysdeps/posix/waitid.c: Likewise.
* sysdeps/unix/sysv/linux/sleep.c: Likewise.
* sysdeps/unix/sysv/linux/usleep.c: Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep.h: Major rewrite of
INTERNAL_SYSCALL to not use push inside asm statement so that
unwind info is correct around the syscall.
* sysdeps/unix/clock_nanosleep.c: Add cancellation support.
* sysdeps/unix/sysv/linux/clock_nanosleep.c: Likewise.
2003-06-16 05:22:26 +08:00
|
|
|
#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
|
2003-03-11 17:30:37 +08:00
|
|
|
|
|
|
|
# undef PSEUDO
|
2003-12-11 07:02:33 +08:00
|
|
|
|
2004-05-05 00:47:14 +08:00
|
|
|
# if USE___THREAD
|
2004-05-04 06:40:52 +08:00
|
|
|
# ifndef NOT_IN_libc
|
|
|
|
# define SYSDEP_CANCEL_ERRNO __libc_errno
|
|
|
|
# else
|
|
|
|
# define SYSDEP_CANCEL_ERRNO errno
|
|
|
|
# endif
|
|
|
|
# define SYSDEP_CANCEL_ERROR(args) \
|
|
|
|
.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
|
|
|
|
.align 32; \
|
|
|
|
.proc __syscall_error_##args; \
|
|
|
|
.global __syscall_error_##args; \
|
|
|
|
.hidden __syscall_error_##args; \
|
|
|
|
.size __syscall_error_##args, 64; \
|
|
|
|
__syscall_error_##args: \
|
|
|
|
.prologue; \
|
|
|
|
.regstk args, 5, args, 0; \
|
|
|
|
.save ar.pfs, loc0; \
|
|
|
|
.save rp, loc1; \
|
|
|
|
.body; \
|
|
|
|
addl loc4 = @ltoff(@tprel(SYSDEP_CANCEL_ERRNO)), gp;; \
|
|
|
|
ld8 loc4 = [loc4]; \
|
|
|
|
mov rp = loc1;; \
|
|
|
|
mov r8 = -1; \
|
|
|
|
add loc4 = loc4, r13;; \
|
|
|
|
st4 [loc4] = loc3; \
|
|
|
|
mov ar.pfs = loc0
|
|
|
|
# else
|
|
|
|
# define SYSDEP_CANCEL_ERROR(args) \
|
|
|
|
.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
|
|
|
|
.align 32; \
|
|
|
|
.proc __syscall_error_##args; \
|
|
|
|
.global __syscall_error_##args; \
|
|
|
|
.hidden __syscall_error_##args; \
|
|
|
|
.size __syscall_error_##args, 64; \
|
|
|
|
__syscall_error_##args: \
|
|
|
|
.prologue; \
|
|
|
|
.regstk args, 5, args, 0; \
|
|
|
|
.save ar.pfs, loc0; \
|
|
|
|
.save rp, loc1; \
|
|
|
|
.body; \
|
|
|
|
mov loc4 = r1;; \
|
|
|
|
br.call.sptk.many b0 = __errno_location;; \
|
|
|
|
st4 [r8] = loc3; \
|
|
|
|
mov r1 = loc4; \
|
|
|
|
mov rp = loc1; \
|
|
|
|
mov r8 = -1; \
|
|
|
|
mov ar.pfs = loc0
|
|
|
|
# endif
|
2003-12-11 07:02:33 +08:00
|
|
|
|
2004-05-04 06:40:52 +08:00
|
|
|
# ifndef USE_DL_SYSINFO
|
|
|
|
|
|
|
|
# define PSEUDO(name, syscall_name, args) \
|
2003-03-11 17:30:37 +08:00
|
|
|
.text; \
|
|
|
|
ENTRY (name) \
|
|
|
|
adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
|
|
|
|
ld4 r14 = [r14]; \
|
|
|
|
mov r15 = SYS_ify(syscall_name);; \
|
|
|
|
cmp4.ne p6, p7 = 0, r14; \
|
|
|
|
(p6) br.cond.spnt .Lpseudo_cancel;; \
|
|
|
|
break __BREAK_SYSCALL;; \
|
|
|
|
cmp.eq p6,p0=-1,r10; \
|
|
|
|
(p6) br.cond.spnt.few __syscall_error; \
|
|
|
|
ret;; \
|
2003-07-08 11:49:44 +08:00
|
|
|
.endp name; \
|
|
|
|
.proc __GC_##name; \
|
|
|
|
.globl __GC_##name; \
|
|
|
|
.hidden __GC_##name; \
|
|
|
|
__GC_##name: \
|
2003-03-11 17:30:37 +08:00
|
|
|
.Lpseudo_cancel: \
|
|
|
|
.prologue; \
|
|
|
|
.regstk args, 5, args, 0; \
|
|
|
|
.save ar.pfs, loc0; \
|
|
|
|
alloc loc0 = ar.pfs, args, 5, args, 0; \
|
|
|
|
.save rp, loc1; \
|
|
|
|
mov loc1 = rp;; \
|
|
|
|
.body; \
|
|
|
|
CENABLE;; \
|
|
|
|
mov loc2 = r8; \
|
|
|
|
COPY_ARGS_##args \
|
|
|
|
mov r15 = SYS_ify(syscall_name); \
|
|
|
|
break __BREAK_SYSCALL;; \
|
|
|
|
mov loc3 = r8; \
|
|
|
|
mov loc4 = r10; \
|
|
|
|
mov out0 = loc2; \
|
|
|
|
CDISABLE;; \
|
|
|
|
cmp.eq p6,p0=-1,loc4; \
|
|
|
|
(p6) br.cond.spnt.few __syscall_error_##args; \
|
|
|
|
mov r8 = loc3; \
|
|
|
|
mov rp = loc1; \
|
|
|
|
mov ar.pfs = loc0; \
|
|
|
|
.Lpseudo_end: \
|
|
|
|
ret; \
|
2003-07-08 11:49:44 +08:00
|
|
|
.endp __GC_##name; \
|
2004-05-04 06:40:52 +08:00
|
|
|
SYSDEP_CANCEL_ERROR(args)
|
2003-03-11 17:30:37 +08:00
|
|
|
|
2004-05-04 06:40:52 +08:00
|
|
|
# else /* USE_DL_SYSINFO */
|
2003-12-11 07:02:33 +08:00
|
|
|
|
2004-05-04 06:40:52 +08:00
|
|
|
# define PSEUDO(name, syscall_name, args) \
|
2003-12-11 07:02:33 +08:00
|
|
|
.text; \
|
|
|
|
ENTRY (name) \
|
|
|
|
.prologue; \
|
|
|
|
adds r2 = SYSINFO_OFFSET, r13; \
|
|
|
|
adds r14 = MULTIPLE_THREADS_OFFSET, r13; \
|
|
|
|
.save ar.pfs, r11; \
|
|
|
|
mov r11 = ar.pfs;; \
|
|
|
|
.body; \
|
|
|
|
ld4 r14 = [r14]; \
|
|
|
|
ld8 r2 = [r2]; \
|
|
|
|
mov r15 = SYS_ify(syscall_name);; \
|
|
|
|
cmp4.ne p6, p7 = 0, r14; \
|
|
|
|
mov b7 = r2; \
|
|
|
|
(p6) br.cond.spnt .Lpseudo_cancel; \
|
|
|
|
br.call.sptk.many b6 = b7;; \
|
|
|
|
mov ar.pfs = r11; \
|
|
|
|
cmp.eq p6,p0 = -1, r10; \
|
|
|
|
(p6) br.cond.spnt.few __syscall_error; \
|
|
|
|
ret;; \
|
|
|
|
.endp name; \
|
|
|
|
.proc __GC_##name; \
|
|
|
|
.globl __GC_##name; \
|
|
|
|
.hidden __GC_##name; \
|
|
|
|
__GC_##name: \
|
|
|
|
.Lpseudo_cancel: \
|
|
|
|
.prologue; \
|
|
|
|
.regstk args, 5, args, 0; \
|
|
|
|
.save ar.pfs, loc0; \
|
|
|
|
alloc loc0 = ar.pfs, args, 5, args, 0; \
|
|
|
|
adds loc4 = SYSINFO_OFFSET, r13; \
|
|
|
|
.save rp, loc1; \
|
|
|
|
mov loc1 = rp;; \
|
|
|
|
.body; \
|
|
|
|
ld8 loc4 = [loc4]; \
|
|
|
|
CENABLE;; \
|
|
|
|
mov loc2 = r8; \
|
|
|
|
mov b7 = loc4; \
|
|
|
|
COPY_ARGS_##args \
|
|
|
|
mov r15 = SYS_ify(syscall_name); \
|
|
|
|
br.call.sptk.many b6 = b7;; \
|
|
|
|
mov loc3 = r8; \
|
|
|
|
mov loc4 = r10; \
|
|
|
|
mov out0 = loc2; \
|
|
|
|
CDISABLE;; \
|
|
|
|
cmp.eq p6,p0=-1,loc4; \
|
|
|
|
(p6) br.cond.spnt.few __syscall_error_##args; \
|
|
|
|
mov r8 = loc3; \
|
|
|
|
mov rp = loc1; \
|
|
|
|
mov ar.pfs = loc0; \
|
|
|
|
.Lpseudo_end: \
|
|
|
|
ret; \
|
|
|
|
.endp __GC_##name; \
|
2004-05-04 06:40:52 +08:00
|
|
|
SYSDEP_CANCEL_ERROR(args)
|
2003-12-11 07:02:33 +08:00
|
|
|
|
2004-05-04 06:40:52 +08:00
|
|
|
# endif /* USE_DL_SYSINFO */
|
2003-12-11 07:02:33 +08:00
|
|
|
|
2004-05-04 06:40:52 +08:00
|
|
|
# undef PSEUDO_END
|
|
|
|
# define PSEUDO_END(name) .endp
|
2003-07-08 11:49:44 +08:00
|
|
|
|
2003-03-11 17:30:37 +08:00
|
|
|
# ifdef IS_IN_libpthread
|
|
|
|
# define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
|
|
|
|
# define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
|
2003-06-17 16:58:31 +08:00
|
|
|
# elif !defined NOT_IN_libc
|
2003-03-11 17:30:37 +08:00
|
|
|
# define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
|
|
|
|
# define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
|
2003-06-17 16:58:31 +08:00
|
|
|
# elif defined IS_IN_librt
|
|
|
|
# define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
|
|
|
|
# define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
|
|
|
|
# else
|
|
|
|
# error Unsupported library
|
2003-03-11 17:30:37 +08:00
|
|
|
# endif
|
|
|
|
|
2004-05-04 06:40:52 +08:00
|
|
|
# define COPY_ARGS_0 /* Nothing */
|
|
|
|
# define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
|
|
|
|
# define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
|
|
|
|
# define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
|
|
|
|
# define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
|
|
|
|
# define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
|
|
|
|
# define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
|
|
|
|
# define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
|
2003-03-11 17:30:37 +08:00
|
|
|
|
|
|
|
# ifndef __ASSEMBLER__
|
|
|
|
# define SINGLE_THREAD_P \
|
2003-04-26 06:28:13 +08:00
|
|
|
__builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1)
|
2003-03-11 17:30:37 +08:00
|
|
|
# else
|
|
|
|
# define SINGLE_THREAD_P \
|
|
|
|
adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#elif !defined __ASSEMBLER__
|
|
|
|
|
|
|
|
# define SINGLE_THREAD_P (1)
|
2004-07-06 12:26:42 +08:00
|
|
|
# define NO_CANCELLATION 1
|
2003-03-11 17:30:37 +08:00
|
|
|
|
|
|
|
#endif
|