Make the atexit mutex recursive and initialize it in __libc_init()
as suggested by ad@, based on the patch provided by Sverre Froyen in lib/37654. Reviewed by ad@ and jmcneill@.
This commit is contained in:
parent
8b793ad476
commit
95157b046e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: initfini.c,v 1.3 2008/02/10 18:45:41 ad Exp $ */
|
||||
/* $NetBSD: initfini.c,v 1.4 2008/02/25 14:06:13 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: initfini.c,v 1.3 2008/02/10 18:45:41 ad Exp $");
|
||||
__RCSID("$NetBSD: initfini.c,v 1.4 2008/02/25 14:06:13 xtraeme Exp $");
|
||||
|
||||
#ifdef _LIBC
|
||||
#include "namespace.h"
|
||||
@ -48,6 +48,7 @@ static void __libc_init(void) __attribute__((__constructor__, __used__));
|
||||
void __guard_setup(void);
|
||||
void __libc_thr_init(void);
|
||||
void __libc_atomic_init(void);
|
||||
void __libc_atexit_init(void);
|
||||
|
||||
/* LINTED used */
|
||||
static void
|
||||
@ -62,4 +63,7 @@ __libc_init(void)
|
||||
|
||||
/* Threads */
|
||||
__libc_thr_init();
|
||||
|
||||
/* Initialize the atexit mutexes */
|
||||
__libc_atexit_init();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atexit.c,v 1.19 2007/08/08 01:05:34 kristerw Exp $ */
|
||||
/* $NetBSD: atexit.c,v 1.20 2008/02/25 14:06:13 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: atexit.c,v 1.19 2007/08/08 01:05:34 kristerw Exp $");
|
||||
__RCSID("$NetBSD: atexit.c,v 1.20 2008/02/25 14:06:13 xtraeme Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "reentrant.h"
|
||||
@ -81,9 +81,11 @@ static struct atexit_handler *atexit_handler_stack;
|
||||
|
||||
#ifdef _REENTRANT
|
||||
/* ..and a mutex to protect it all. */
|
||||
static mutex_t atexit_mutex = MUTEX_INITIALIZER;
|
||||
static mutex_t atexit_mutex;
|
||||
#endif /* _REENTRANT */
|
||||
|
||||
void __libc_atexit_init(void) __attribute__ ((visibility("hidden")));
|
||||
|
||||
/*
|
||||
* Allocate an atexit handler descriptor. If "dso" is NULL, it indicates
|
||||
* a normal atexit handler, which must be allocated from the static pool,
|
||||
@ -118,6 +120,15 @@ atexit_handler_alloc(void *dso)
|
||||
return (ah);
|
||||
}
|
||||
|
||||
void
|
||||
__libc_atexit_init(void)
|
||||
{
|
||||
mutexattr_t atexit_mutex_attr;
|
||||
mutexattr_init(&atexit_mutex_attr);
|
||||
mutexattr_settype(&atexit_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
mutex_init(&atexit_mutex, &atexit_mutex_attr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register an atexit routine. This is suitable either for a cxa_atexit
|
||||
* or normal atexit type handler. The __cxa_atexit() name and arguments
|
||||
|
Loading…
x
Reference in New Issue
Block a user