From 419172fb0e5bb52d3a2f3d61d926d64237b84c67 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Fri, 11 Mar 2005 16:04:51 +0000 Subject: [PATCH] - The destructor function invocation code no longer calls setjmp(). This is now done within stdlib_main.c prior to calling the destructor function invocation code. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14883 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/changes | 4 ++++ library/crtbegin.c | 14 +------------- library/stdlib_constructor_begin.c | 28 +++++++--------------------- library/stdlib_main.c | 7 ++++++- 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/library/changes b/library/changes index 6a32e59..187b73d 100644 --- a/library/changes +++ b/library/changes @@ -66,6 +66,10 @@ constructor/destructor functions for initialization and cleanup purposes. +- The destructor function invocation code no longer calls + setjmp(). This is now done within stdlib_main.c prior to + calling the destructor function invocation code. + c.lib 1.189 (5.3.2005) diff --git a/library/crtbegin.c b/library/crtbegin.c index cf00abb..062a7c7 100644 --- a/library/crtbegin.c +++ b/library/crtbegin.c @@ -1,5 +1,5 @@ /* - * $Id: crtbegin.c,v 1.8 2005-03-10 13:30:11 obarthel Exp $ + * $Id: crtbegin.c,v 1.9 2005-03-11 16:04:50 obarthel Exp $ * * :ts=4 * @@ -14,11 +14,6 @@ /****************************************************************************/ -#include -#include - -/****************************************************************************/ - /* * Dummy constructor and destructor array. The linker script will put these at the * very beginning of section ".ctors" and ".dtors". crtend.o contains a similar entry @@ -48,16 +43,9 @@ _init(void) void _fini(void) { - extern jmp_buf __exit_jmp_buf; - int num_dtors,i; static int j; - /* If one of the destructors drops into - exit(), processing will continue with - the next following destructor. */ - (void)setjmp(__exit_jmp_buf); - for(i = 1, num_dtors = 0 ; __DTOR_LIST__[i] != NULL ; i++) num_dtors++; diff --git a/library/stdlib_constructor_begin.c b/library/stdlib_constructor_begin.c index def5da8..3746d4d 100644 --- a/library/stdlib_constructor_begin.c +++ b/library/stdlib_constructor_begin.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_constructor_begin.c,v 1.5 2005-03-10 09:55:03 obarthel Exp $ + * $Id: stdlib_constructor_begin.c,v 1.6 2005-03-11 16:04:50 obarthel Exp $ * * :ts=4 * @@ -38,7 +38,6 @@ /****************************************************************************/ #include -#include /****************************************************************************/ @@ -52,9 +51,8 @@ extern void (* __far __dtors[])(void); /****************************************************************************/ /* With SAS/C this function is placed in front of the first constructor - * table entry. It will invoke all following constructors and - * finally all the destructors. We don't use this approach here. - */ + table entry. It will invoke all following constructors and + finally all the destructors. We don't use this approach here. */ void __construct(void) { @@ -92,18 +90,11 @@ _fini(void) { static int i; - /* If one of the destructors drops into - * exit(), processing will continue with - * the next following destructor. - */ - (void)setjmp(__exit_jmp_buf); - while(__dtors[i] != NULL) { /* Increment this before jumping in, so that the next - * invocation will always pick up the destructor following - * the one we will invoke rigt now. - */ + invocation will always pick up the destructor following + the one we will invoke rigt now. */ i++; (*__dtors[i-1])(); @@ -129,6 +120,7 @@ void _init(void) { extern func_ptr __CTOR_LIST__[]; + ULONG num_ctors = (ULONG)__CTOR_LIST__[0]; ULONG i; @@ -155,7 +147,7 @@ void _fini(void) { extern func_ptr __DTOR_LIST__[]; - extern jmp_buf __exit_jmp_buf; + ULONG num_dtors = (ULONG)__DTOR_LIST__[0]; static ULONG i; @@ -163,12 +155,6 @@ _fini(void) D(("there are %ld destructors to be called",num_dtors)); - /* If one of the destructors drops into - * exit(), processing will continue with - * the next following destructor. - */ - (void)setjmp(__exit_jmp_buf); - /* Call all destructors in forward order */ while(i++ < num_dtors) { diff --git a/library/stdlib_main.c b/library/stdlib_main.c index a3216e6..06a2979 100644 --- a/library/stdlib_main.c +++ b/library/stdlib_main.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_main.c,v 1.15 2005-03-11 13:23:18 obarthel Exp $ + * $Id: stdlib_main.c,v 1.16 2005-03-11 16:04:51 obarthel Exp $ * * :ts=4 * @@ -184,6 +184,11 @@ call_main(void) SHOWMSG("invoking the destructors"); + /* If one of the destructors drops into exit(), either directly + or through a failed assert() call, processing will resume with + the next following destructor. */ + (void)setjmp(__exit_jmp_buf); + /* Go through the destructor list */ _fini();