From bd215ef170fb85b7572b617dacdeab26edd3d21c Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 25 Sep 2016 20:28:03 +0200 Subject: always assume tgkill is present We do not support 2.4 Linux kernels anyway, and almost all newer 2.6 kernels should have tgkill syscall. Cleanup the raise situation, pt-raise.c is unused, sync raise.c with latest GNU libc. Signed-off-by: Waldemar Brodkorb --- libc/sysdeps/linux/common/bits/kernel-features.h | 12 ----- libpthread/nptl/allocatestack.c | 10 ----- libpthread/nptl/pthread_cancel.c | 11 ----- libpthread/nptl/sysdeps/pthread/createthread.c | 4 -- .../sysdeps/unix/sysv/linux/Makefile.commonarch | 1 - libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c | 51 ---------------------- .../nptl/sysdeps/unix/sysv/linux/pthread_kill.c | 10 ----- libpthread/nptl/sysdeps/unix/sysv/linux/raise.c | 21 +-------- libpthread/nptl/sysdeps/xtensa/Makefile.arch | 2 - 9 files changed, 2 insertions(+), 120 deletions(-) delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h index 708bb4906..0b3632063 100644 --- a/libc/sysdeps/linux/common/bits/kernel-features.h +++ b/libc/sysdeps/linux/common/bits/kernel-features.h @@ -382,18 +382,6 @@ # define __ASSUME_CORRECT_SI_PID 1 #endif -/* The tgkill syscall was instroduced for i386 in 2.5.75. For Alpha - it was introduced in 2.6.0-test1 which unfortunately cannot be - distinguished from 2.6.0. On x86-64, ppc, and ppc64 it was - introduced in 2.6.0-test3. */ -#if (__LINUX_KERNEL_VERSION >= 132427 && defined __i386__) \ - || (__LINUX_KERNEL_VERSION >= 132609 && defined __alpha__) \ - || (__LINUX_KERNEL_VERSION >= 132609 && defined __x86_64__) \ - || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \ - || (__LINUX_KERNEL_VERSION >= 132609 && defined __sh__) -# define __ASSUME_TGKILL 1 -#endif - /* The utimes syscall has been available for some architectures forever. For x86 it was introduced after 2.5.75, for x86-64, ppc, and ppc64 it was introduced in 2.6.0-test3. */ diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c index bf9925253..39ec8577e 100644 --- a/libpthread/nptl/allocatestack.c +++ b/libpthread/nptl/allocatestack.c @@ -996,18 +996,8 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) int val; INTERNAL_SYSCALL_DECL (err); -#if defined (__ASSUME_TGKILL) && __ASSUME_TGKILL val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), t->tid, SIGSETXID); -#else -# ifdef __NR_tgkill - val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), - t->tid, SIGSETXID); - if (INTERNAL_SYSCALL_ERROR_P (val, err) - && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS) -# endif - val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID); -#endif /* If this failed, it must have had not started yet or else exited. */ if (!INTERNAL_SYSCALL_ERROR_P (val, err)) diff --git a/libpthread/nptl/pthread_cancel.c b/libpthread/nptl/pthread_cancel.c index a8ba3c8ce..ee9a3202f 100644 --- a/libpthread/nptl/pthread_cancel.c +++ b/libpthread/nptl/pthread_cancel.c @@ -75,20 +75,9 @@ pthread_cancel ( a signal handler. But this is no allowed, pthread_cancel is not guaranteed to be async-safe. */ int val; -#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), pd->tid, SIGCANCEL); -#else -# ifdef __NR_tgkill - val = INTERNAL_SYSCALL (tgkill, err, 3, - THREAD_GETMEM (THREAD_SELF, pid), pd->tid, - SIGCANCEL); - if (INTERNAL_SYSCALL_ERROR_P (val, err) - && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS) -# endif - val = INTERNAL_SYSCALL (tkill, err, 2, pd->tid, SIGCANCEL); -#endif if (INTERNAL_SYSCALL_ERROR_P (val, err)) result = INTERNAL_SYSCALL_ERRNO (val, err); diff --git a/libpthread/nptl/sysdeps/pthread/createthread.c b/libpthread/nptl/sysdeps/pthread/createthread.c index 74146ae95..ebfee16f9 100644 --- a/libpthread/nptl/sysdeps/pthread/createthread.c +++ b/libpthread/nptl/sysdeps/pthread/createthread.c @@ -105,13 +105,9 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, send it the cancellation signal. */ INTERNAL_SYSCALL_DECL (err2); err_out: -#if defined (__ASSUME_TGKILL) && __ASSUME_TGKILL (void) INTERNAL_SYSCALL (tgkill, err2, 3, THREAD_GETMEM (THREAD_SELF, pid), pd->tid, SIGCANCEL); -#else - (void) INTERNAL_SYSCALL (tkill, err2, 2, pd->tid, SIGCANCEL); -#endif return (INTERNAL_SYSCALL_ERROR_P (res, err) ? INTERNAL_SYSCALL_ERRNO (res, err) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch index 81ce813a9..57481fdb5 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch @@ -95,7 +95,6 @@ endif libpthread-a-y += $(if $(DOPIC),$(libpthread_linux_OBJS:.o=.os),$(libpthread_linux_OBJS)) libpthread-so-y += $(libpthread_linux_OBJS:.o=.oS) -libpthread-so-y += $(libpthread_linux_OUT)/pt-raise.oS libc_linux_OBJS := $(libc_linux_arch_OBJS) libc_linux_OBJS += $(patsubst %.c,$(libpthread_linux_OUT)/%.o,$(libc_linux_CSRC)) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c deleted file mode 100644 index 6784b1b58..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 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, see - . */ - -#include -#include -#include -#include -#include - - -int -raise ( - int sig) -{ -#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill - /* raise is an async-safe function. It could be called while the - fork function temporarily invalidated the PID field. Adjust for - that. */ - pid_t pid = THREAD_GETMEM (THREAD_SELF, pid); - if (__builtin_expect (pid < 0, 0)) - pid = -pid; -#endif - -#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL - return INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid), - sig); -#else -# ifdef __NR_tgkill - int res = INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid), - sig); - if (res != -1 || errno != ENOSYS) - return res; -# endif - return INLINE_SYSCALL (tkill, 2, THREAD_GETMEM (THREAD_SELF, tid), sig); -#endif -} diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c index 5bc6e0651..e27ab5104 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c @@ -58,18 +58,8 @@ __pthread_kill ( fork, it would have to happen in a signal handler. But this is no allowed, pthread_kill is not guaranteed to be async-safe. */ int val; -#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), tid, signo); -#else -# ifdef __NR_tgkill - val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), - tid, signo); - if (INTERNAL_SYSCALL_ERROR_P (val, err) - && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS) -# endif - val = INTERNAL_SYSCALL (tkill, err, 2, tid, signo); -#endif return (INTERNAL_SYSCALL_ERROR_P (val, err) ? INTERNAL_SYSCALL_ERRNO (val, err) : 0); diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c index 8aa4830c0..6b159384f 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -21,17 +21,13 @@ #include #include #include -#include int -raise ( - int sig) +raise (int sig) { struct pthread *pd = THREAD_SELF; -#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill pid_t pid = THREAD_GETMEM (pd, pid); -#endif pid_t selftid = THREAD_GETMEM (pd, tid); if (selftid == 0) { @@ -44,30 +40,17 @@ raise ( #endif THREAD_SETMEM (pd, tid, selftid); -#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill /* We do not set the PID field in the TID here since we might be called from a signal handler while the thread executes fork. */ pid = selftid; -#endif } -#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill else /* raise is an async-safe function. It could be called while the fork/vfork function temporarily invalidated the PID field. Adjust for that. */ if (__builtin_expect (pid <= 0, 0)) pid = (pid & INT_MAX) == 0 ? selftid : -pid; -#endif -#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); -#else -# ifdef __NR_tgkill - int res = INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); - if (res != -1 || errno != ENOSYS) - return res; -# endif - return INLINE_SYSCALL (tkill, 2, selftid, sig); -#endif } libc_hidden_def (raise) diff --git a/libpthread/nptl/sysdeps/xtensa/Makefile.arch b/libpthread/nptl/sysdeps/xtensa/Makefile.arch index 23461177c..2c1fc1b5c 100644 --- a/libpthread/nptl/sysdeps/xtensa/Makefile.arch +++ b/libpthread/nptl/sysdeps/xtensa/Makefile.arch @@ -15,8 +15,6 @@ # License along with the GNU C Library; see the file COPYING.LIB. If # not, see . -CFLAGS-pt-raise.c = -DNOT_IN_libc -DIS_IN_libpthread - ASFLAGS-dl-tlsdesc.S = -DNOT_IN_libc=1 ASFLAGS-pthread_spin_lock.S = -DNOT_IN_libc -DIS_IN_libpthread ASFLAGS-pthread_spin_trylock.S = -DNOT_IN_libc -DIS_IN_libpthread -- cgit v1.2.3