diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-02-14 23:31:11 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-02-14 23:31:11 +0000 |
commit | 472022708ee08ac559dde540891eb2f8c2a9afcf (patch) | |
tree | f30a25b8039eab48c7b6e2737a5f856bdb853b78 /sysdeps/generic | |
parent | e320ef46a7283517aeba1decc20ffb38ed131281 (diff) | |
download | glibc-472022708ee08ac559dde540891eb2f8c2a9afcf.zip glibc-472022708ee08ac559dde540891eb2f8c2a9afcf.tar.gz glibc-472022708ee08ac559dde540891eb2f8c2a9afcf.tar.bz2 |
Update.
2003-02-14 Ulrich Drepper <drepper@redhat.com>
* sysdeps/generic/libc-start.c [HAVE_PTR_NTHREADS]: Decrement thread
counter and only call __exit_thread if this is not the last thread.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/libc-start.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c index b4c29dd..a6dbebe 100644 --- a/sysdeps/generic/libc-start.c +++ b/sysdeps/generic/libc-start.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1998,1999,2000,2001,2002,2003 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 @@ -38,6 +38,11 @@ extern void __pthread_initialize_minimal (void) ; #endif +#ifdef HAVE_PTR_NTHREADS +/* We need atomic operations. */ +# include <atomic.h> +#endif + extern int BP_SYM (__libc_start_main) (int (*main) (int, char **, char **), int argc, @@ -148,8 +153,24 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **), } #ifdef HAVE_CANCELBUF else - /* Not much left to do but to exit the thread, not the process. */ - __exit_thread (0); + { +# ifdef HAVE_PTR_NTHREADS + /* One less thread. Decrement the counter. If it is zero we + terminate the entire process. */ + result = 0; + int *const ptr; +# ifdef SHARED + ptr = __libc_pthread_functions.ptr_nthreads; +# else + extern int __nptl_nthreads __attribute ((weak)); + ptr = &__nptl_nthreads; +# endif + + if (! atomic_decrement_and_test (ptr)) +# endif + /* Not much left to do but to exit the thread, not the process. */ + __exit_thread (0); + } #endif exit (result); |