]> sourceware.org Git - glibc.git/commitdiff
Clean up __exit_thread.
authorRoland McGrath <roland@hack.frob.com>
Tue, 13 May 2014 16:49:20 +0000 (09:49 -0700)
committerRoland McGrath <roland@hack.frob.com>
Tue, 13 May 2014 16:49:20 +0000 (09:49 -0700)
23 files changed:
ChangeLog
csu/libc-start.c
include/unistd.h
nptl/pthread_create.c
nptl/sysdeps/i386/pthreaddef.h
nptl/sysdeps/powerpc/pthreaddef.h
nptl/sysdeps/s390/pthreaddef.h
nptl/sysdeps/sh/pthreaddef.h
nptl/sysdeps/sparc/sparc32/pthreaddef.h
nptl/sysdeps/sparc/sparc64/pthreaddef.h
nptl/sysdeps/x86_64/pthreaddef.h
sysdeps/aarch64/nptl/pthreaddef.h
sysdeps/alpha/nptl/pthreaddef.h
sysdeps/arm/nptl/pthreaddef.h
sysdeps/generic/exit-thread.h [moved from sysdeps/unix/sysv/linux/exit-thread.S with 62% similarity]
sysdeps/hppa/nptl/pthreaddef.h
sysdeps/ia64/nptl/pthreaddef.h
sysdeps/m68k/nptl/pthreaddef.h
sysdeps/microblaze/nptl/pthreaddef.h
sysdeps/mips/nptl/pthreaddef.h
sysdeps/tile/nptl/pthreaddef.h
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/exit-thread.h [new file with mode: 0644]

index ddba88abc62c4de1b478f93a6fbdedab159c6d99..1bee32a39d6e1498ac0439fd2f35eccf58c996a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2014-05-13  Roland McGrath  <roland@hack.frob.com>
+
+       * sysdeps/generic/exit-thread.h: New file.
+       * sysdeps/unix/sysv/linux/exit-thread.h: New file.
+       * include/unistd.h (__exit_thread): Remove declaration.
+       * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Drop exit-thread.
+       * sysdeps/unix/sysv/linux/exit-thread.S: File removed.
+       * csu/libc-start.c: Include <exit-thread.h>.
+       (LIBC_START_MAIN): Pass no argument to __exit_thread.
+       * nptl/pthread_create.c: Include <exit-thread.h>.
+       (start_thread): Call __exit_thread in place of __exit_thread_inline.
+       * nptl/sysdeps/i386/pthreaddef.h (__exit_thread_inline): Macro removed.
+       * nptl/sysdeps/powerpc/pthreaddef.h: Likewise.
+       * nptl/sysdeps/s390/pthreaddef.h: Likewise.
+       * nptl/sysdeps/sh/pthreaddef.h: Likewise.
+       * nptl/sysdeps/sparc/sparc32/pthreaddef.h: Likewise.
+       * nptl/sysdeps/sparc/sparc64/pthreaddef.h: Likewise.
+       * nptl/sysdeps/x86_64/pthreaddef.h: Likewise.
+       * sysdeps/aarch64/nptl/pthreaddef.h: Likewise.
+       * sysdeps/alpha/nptl/pthreaddef.h: Likewise.
+       * sysdeps/arm/nptl/pthreaddef.h: Likewise.
+       * sysdeps/hppa/nptl/pthreaddef.h: Likewise.
+       * sysdeps/ia64/nptl/pthreaddef.h: Likewise.
+       * sysdeps/m68k/nptl/pthreaddef.h: Likewise.
+       * sysdeps/microblaze/nptl/pthreaddef.h: Likewise.
+       * sysdeps/mips/nptl/pthreaddef.h: Likewise.
+       * sysdeps/tile/nptl/pthreaddef.h: Likewise.
+
 2014-05-13  Andreas Schwab  <schwab@suse.de>
 
        * sysdeps/unix/grantpt.c (grantpt): Fix typo in assertion.
index d571a1aca94bc9eb0d5117ba614294d6b252363f..138418a1d15aff1cacc9e635050833c897c357fd 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <ldsodefs.h>
+#include <exit-thread.h>
 
 extern void __libc_init_first (int argc, char **argv, char **envp);
 #ifndef SHARED
@@ -312,7 +313,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
 
       if (! atomic_decrement_and_test (ptr))
        /* Not much left to do but to exit the thread, not the process.  */
-       __exit_thread (0);
+       __exit_thread ();
     }
 #else
   /* Nothing fancy, just call the function.  */
index a5cbc5d2fc0107f67ecee1d32d9dc8f4cc69014f..5a016b1bf56547f8259aa7fcb4f34955e28ae400 100644 (file)
@@ -161,9 +161,6 @@ extern int __libc_enable_secure_internal attribute_relro attribute_hidden;
 extern void __libc_check_standard_fds (void);
 
 
-/* Special exit function which only terminates the current thread.  */
-extern void __exit_thread (int val) __attribute__ ((noreturn));
-
 /* Internal name for fork function.  */
 extern __pid_t __libc_fork (void);
 
index 38e69cb496bcf5a19e9d3304460ef9dd4af7ffd8..29971637337b579aee0fbd49bda07e50a06b88c6 100644 (file)
@@ -29,6 +29,7 @@
 #include <libc-internal.h>
 #include <resolv.h>
 #include <kernel-features.h>
+#include <exit-thread.h>
 
 #include <shlib-compat.h>
 
@@ -432,7 +433,7 @@ start_thread (void *arg)
 
      The exit code is zero since in case all threads exit by calling
      'pthread_exit' the exit status must be 0 (zero).  */
-  __exit_thread_inline (0);
+  __exit_thread ();
 
   /* NOTREACHED */
   return 0;
index 3a1ea1cee5731f98c41a5f1c6288b381efae1862..bf00c007383ae15ac754e1914dce2e3f2531418b 100644 (file)
 
 /* 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) \
-  while (1) {                                                                \
-    if (__builtin_constant_p (val) && (val) == 0)                            \
-      asm volatile ("xorl %%ebx, %%ebx; int $0x80" :: "a" (__NR_exit));              \
-    else                                                                     \
-      asm volatile ("movl %1, %%ebx; int $0x80"                                      \
-                   :: "a" (__NR_exit), "r" (val));                           \
-  }
index a0db6297a65039994cdd39956a869f9ecb15e731..5c6a0cde522f99f1758bd4e063bd0ed50f72de45 100644 (file)
 
 /* 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))
index 70cb6a44667236aec26f4af22dcb4cb8b44df00f..b2a7c058e68f966748dfe0c5859ab0fdcd4bbc76 100644 (file)
 
 /* 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))
index f0b1ad7355f964c8eeff0b4ad657e1a48e157d1d..7ea338e4d76f94d235f00823310f5f141ef89de9 100644 (file)
 
 /* 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) \
-  while (1) {                                                                \
-    if (__builtin_constant_p (val) && (val) == 0)                            \
-      asm volatile ("mov #0,r4; mov %0,r3; trapa #0x11\n\t" SYSCALL_INST_PAD  \
-                  :: "i" (__NR_exit));  \
-    else                                                                     \
-      asm volatile ("mov %1,r4; mov %0,r3; trapa #0x11\n\t" SYSCALL_INST_PAD  \
-                   :: "i" (__NR_exit), "r" (val));                           \
-  }
index 64d796b0950069f373afa11241cd2d8eb9e85418..eb8d33bcff1f436e9d024d0f28887f1f496a615b 100644 (file)
@@ -31,9 +31,3 @@
 /* Location of current stack frame.  */
 #define CURRENT_STACK_FRAME  (stack_pointer + (2 * 64))
 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))
index de39eefb81893bce581000c2fa958ad6bc0f8e59..ee44bcf1af4984c52cfd3cf7a8aa7f50f4cbe9bb 100644 (file)
@@ -31,9 +31,3 @@
 /* Location of current stack frame.  */
 #define CURRENT_STACK_FRAME  (stack_pointer + (2 * 128))
 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))
index 18a15a1dd4c53b546eaae4ad538f5a2001627cc1..485a6252df65d64345ff2417690be5631da3359d 100644 (file)
 /* Location of current stack frame.  The frame pointer is not usable.  */
 #define CURRENT_STACK_FRAME \
   ({ register char *frame __asm__("rsp"); frame; })
-
-
-/* XXX Until we have a better place keep the definitions here.  */
-
-/* While there is no such syscall.  */
-#define __exit_thread_inline(val) \
-  asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
index 361a95c75d924aaa9a81c29cf9160c90a0182ba5..919831439e751a5c46b2e98a5c381e020753aada 100644 (file)
@@ -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))
index 4e56fd9df2aa5eb793d7649f11503e0709991822..f54400c4f84d8b7faa5d8644f3d30a8c2fa66af0 100644 (file)
@@ -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))
index 2488af98288382a716a95e0caeb97bbf288a5c8c..ab1b05bddc1ca18805e53bab59f73ee30b7a1d33 100644 (file)
@@ -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))
similarity index 62%
rename from sysdeps/unix/sysv/linux/exit-thread.S
rename to sysdeps/generic/exit-thread.h
index 741cea4c589e066d1c7fdd15713cff9115c81654..779e61e41cda9a69c765239540a1578032a15a5b 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-2014 Free Software Foundation, Inc.
+/* 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
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
+/* 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).  */
 
-PSEUDO (__exit_thread, exit, 1)
-       /* Shouldn't get here.  */
-PSEUDO_END(__exit_thread)
+static inline void __attribute__ ((noreturn, always_inline, unused))
+__exit_thread (void)
+{
+  while (1)
+    asm ("write me!");
+}
index ee8765a6f19803e99d79563cb2316a06c918c9f5..d0fffa05b73d03a92902cae905af73b32dcebff4 100644 (file)
@@ -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))
index cf4763c26849f9fd3b5b0b49a6cb93cc1ef92479..8fdd9e35a15ac88e528d3449c66c98d7a711e7bd 100644 (file)
@@ -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))
index 68bf11af14132da6a3c6c9c401014942f93f5460..72d2b3efff95d6f3437278f7b35e52b31cf861b4 100644 (file)
@@ -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))
index 37a44c168c742b4030a29b7b49deaf75507b2729..38a61d17fe384888a56afd30f78565c2f4fbc24f 100644 (file)
@@ -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))
index 60f57de0a59e77e6cef72a25b0cb4405d5af109e..da2366fe489ce3173ca3e51f16e0b238a10a9127 100644 (file)
@@ -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))
index f3997250d21fc4460363a15e28a35afba639ab9f..646d09ec7521390a7ad45712b9d6ddd50ff2888b 100644 (file)
@@ -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))
index 692487fc7b6827bacddce45efb34dce5d1971cad..02eda45067cf17b75092850ae9cd038f2b9fb42c 100644 (file)
@@ -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.h b/sysdeps/unix/sysv/linux/exit-thread.h
new file mode 100644 (file)
index 0000000..52891dd
--- /dev/null
@@ -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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+/* 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);
+    }
+}
This page took 0.128607 seconds and 5 git commands to generate.