diff options
| author | joerg <joerg@NetBSD.org> | 2017-07-11 15:21:31 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2017-07-11 15:21:31 +0000 |
| commit | 44436c4d98a5361e80b2e3d468a80e56dc6dd447 (patch) | |
| tree | 7f3682fcf633e56772e70f6fbf90ef6771029d78 /lib/libpthread | |
| parent | f9025168b1bb1a00f759c41ec3bdda6ceb92bf71 (diff) | |
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/pthread.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index 65c5bc246f1..de74d783e64 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.149 2017/07/02 17:13:07 joerg Exp $ */ +/* $NetBSD: pthread.c,v 1.150 2017/07/11 15:21:35 joerg Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread.c,v 1.149 2017/07/02 17:13:07 joerg Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.150 2017/07/11 15:21:35 joerg Exp $"); #define __EXPOSE_STACK 1 @@ -59,6 +59,7 @@ __RCSID("$NetBSD: pthread.c,v 1.149 2017/07/02 17:13:07 joerg Exp $"); #include <unistd.h> #include <sched.h> +#include "atexit.h" #include "pthread.h" #include "pthread_int.h" #include "pthread_makelwp.h" @@ -654,6 +655,10 @@ pthread_exit(void *retval) pthread_mutex_lock(&self->pt_lock); } + pthread_mutex_unlock(&self->pt_lock); + __cxa_thread_run_atexit(); + pthread_mutex_lock(&self->pt_lock); + /* Perform cleanup of thread-specific data */ pthread__destroy_tsd(self); |
