From e0db65176fa88b9497cbd6362b24e3225382bfb6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 13 May 2014 09:49:20 -0700 Subject: Clean up __exit_thread. --- sysdeps/aarch64/nptl/pthreaddef.h | 5 ----- sysdeps/alpha/nptl/pthreaddef.h | 6 ------ sysdeps/arm/nptl/pthreaddef.h | 5 ----- sysdeps/generic/exit-thread.h | 28 ++++++++++++++++++++++++++ sysdeps/hppa/nptl/pthreaddef.h | 6 ------ sysdeps/ia64/nptl/pthreaddef.h | 6 ------ sysdeps/m68k/nptl/pthreaddef.h | 5 ----- sysdeps/microblaze/nptl/pthreaddef.h | 5 ----- sysdeps/mips/nptl/pthreaddef.h | 6 ------ sysdeps/tile/nptl/pthreaddef.h | 5 ----- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/exit-thread.S | 22 -------------------- sysdeps/unix/sysv/linux/exit-thread.h | 38 +++++++++++++++++++++++++++++++++++ 13 files changed, 67 insertions(+), 72 deletions(-) create mode 100644 sysdeps/generic/exit-thread.h delete mode 100644 sysdeps/unix/sysv/linux/exit-thread.S create mode 100644 sysdeps/unix/sysv/linux/exit-thread.h (limited to 'sysdeps') diff --git a/sysdeps/aarch64/nptl/pthreaddef.h b/sysdeps/aarch64/nptl/pthreaddef.h index 361a95c75d..919831439e 100644 --- a/sysdeps/aarch64/nptl/pthreaddef.h +++ b/sysdeps/aarch64/nptl/pthreaddef.h @@ -30,8 +30,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) - - -/* XXX Until we have a better place keep the definitions here. */ -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/alpha/nptl/pthreaddef.h b/sysdeps/alpha/nptl/pthreaddef.h index 4e56fd9df2..f54400c4f8 100644 --- a/sysdeps/alpha/nptl/pthreaddef.h +++ b/sysdeps/alpha/nptl/pthreaddef.h @@ -29,9 +29,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) - -/* XXX Until we have a better place keep the definitions here. */ - -/* While there is no such syscall. */ -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/arm/nptl/pthreaddef.h b/sysdeps/arm/nptl/pthreaddef.h index 2488af9828..ab1b05bddc 100644 --- a/sysdeps/arm/nptl/pthreaddef.h +++ b/sysdeps/arm/nptl/pthreaddef.h @@ -39,8 +39,3 @@ return the hard FP minus 12. Of course, this makes no sense without the obsolete APCS stack layout... */ #define CURRENT_STACK_FRAME (__builtin_frame_address (0) - 12) - - -/* XXX Until we have a better place keep the definitions here. */ -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/generic/exit-thread.h b/sysdeps/generic/exit-thread.h new file mode 100644 index 0000000000..779e61e41c --- /dev/null +++ b/sysdeps/generic/exit-thread.h @@ -0,0 +1,28 @@ +/* Call to terminate the current thread. Stub version. + Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +/* This causes the current thread to exit, without affecting other + threads in the process if there are any. If there are no other + threads left, then this has the effect of _exit (0). */ + +static inline void __attribute__ ((noreturn, always_inline, unused)) +__exit_thread (void) +{ + while (1) + asm ("write me!"); +} diff --git a/sysdeps/hppa/nptl/pthreaddef.h b/sysdeps/hppa/nptl/pthreaddef.h index ee8765a6f1..d0fffa05b7 100644 --- a/sysdeps/hppa/nptl/pthreaddef.h +++ b/sysdeps/hppa/nptl/pthreaddef.h @@ -31,9 +31,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME stack_pointer register char * stack_pointer __asm__ ("%r30"); - - -/* XXX Until we have a better place keep the definitions here. */ - -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/ia64/nptl/pthreaddef.h b/sysdeps/ia64/nptl/pthreaddef.h index cf4763c268..8fdd9e35a1 100644 --- a/sysdeps/ia64/nptl/pthreaddef.h +++ b/sysdeps/ia64/nptl/pthreaddef.h @@ -34,9 +34,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __stack_pointer register char *__stack_pointer __asm__ ("sp"); - -/* XXX Until we have a better place keep the definitions here. */ - -/* While there is no such syscall. */ -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/m68k/nptl/pthreaddef.h b/sysdeps/m68k/nptl/pthreaddef.h index 68bf11af14..72d2b3efff 100644 --- a/sysdeps/m68k/nptl/pthreaddef.h +++ b/sysdeps/m68k/nptl/pthreaddef.h @@ -31,8 +31,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) - - -/* XXX Until we have a better place keep the definitions here. */ -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/microblaze/nptl/pthreaddef.h b/sysdeps/microblaze/nptl/pthreaddef.h index 37a44c168c..38a61d17fe 100644 --- a/sysdeps/microblaze/nptl/pthreaddef.h +++ b/sysdeps/microblaze/nptl/pthreaddef.h @@ -33,8 +33,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) - -/* XXX Until we have a better place keep the definitions here. */ - -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/mips/nptl/pthreaddef.h b/sysdeps/mips/nptl/pthreaddef.h index 60f57de0a5..da2366fe48 100644 --- a/sysdeps/mips/nptl/pthreaddef.h +++ b/sysdeps/mips/nptl/pthreaddef.h @@ -30,9 +30,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) - - -/* XXX Until we have a better place keep the definitions here. */ - -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/tile/nptl/pthreaddef.h b/sysdeps/tile/nptl/pthreaddef.h index f3997250d2..646d09ec75 100644 --- a/sysdeps/tile/nptl/pthreaddef.h +++ b/sysdeps/tile/nptl/pthreaddef.h @@ -34,8 +34,3 @@ /* Location of current stack frame. */ #define CURRENT_STACK_FRAME __builtin_frame_address (0) - -/* XXX Until we have a better place keep the definitions here. */ - -#define __exit_thread_inline(val) \ - INLINE_SYSCALL (exit, 1, (val)) diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 692487fc7b..02eda45067 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -141,7 +141,7 @@ endif ifeq ($(subdir),posix) sysdep_headers += bits/initspin.h -sysdep_routines += exit-thread sched_getcpu +sysdep_routines += sched_getcpu tests += tst-getcpu endif diff --git a/sysdeps/unix/sysv/linux/exit-thread.S b/sysdeps/unix/sysv/linux/exit-thread.S deleted file mode 100644 index 741cea4c58..0000000000 --- a/sysdeps/unix/sysv/linux/exit-thread.S +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 1991-2014 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - -PSEUDO (__exit_thread, exit, 1) - /* Shouldn't get here. */ -PSEUDO_END(__exit_thread) diff --git a/sysdeps/unix/sysv/linux/exit-thread.h b/sysdeps/unix/sysv/linux/exit-thread.h new file mode 100644 index 0000000000..52891dd22f --- /dev/null +++ b/sysdeps/unix/sysv/linux/exit-thread.h @@ -0,0 +1,38 @@ +/* Call to terminate the current thread. Linux version. + Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + +/* This causes the current thread to exit, without affecting other + threads in the process if there are any. If there are no other + threads left, then this has the effect of _exit (0). */ + +static inline void __attribute__ ((noreturn, always_inline, unused)) +__exit_thread (void) +{ + /* Doing this in a loop is mostly just to satisfy the compiler that the + function really qualifies as noreturn. It also means that in some + pathological situation where the system call does not get made or does + not work, the thread will simply spin rather than running off the end + of the caller and doing unexpectedly strange things. */ + while (1) + { + INTERNAL_SYSCALL_DECL (err); + INTERNAL_SYSCALL (exit, err, 1, 0); + } +} -- cgit 1.4.1