1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- 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
This commit is contained in:
Olaf Barthel
2005-03-11 16:04:51 +00:00
parent f289140266
commit 419172fb0e
4 changed files with 18 additions and 35 deletions

View File

@ -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)

View File

@ -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 <stdlib.h>
#include <setjmp.h>
/****************************************************************************/
/*
* 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++;

View File

@ -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 <stdlib.h>
#include <setjmp.h>
/****************************************************************************/
@ -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)
{

View File

@ -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();