mirror of
https://github.com/adtools/clib2.git
synced 2026-09-18 06:33:46 +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:
@@ -66,6 +66,10 @@
|
|||||||
constructor/destructor functions for initialization and cleanup
|
constructor/destructor functions for initialization and cleanup
|
||||||
purposes.
|
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)
|
c.lib 1.189 (5.3.2005)
|
||||||
|
|
||||||
|
|||||||
+1
-13
@@ -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
|
* :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
|
* 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
|
* very beginning of section ".ctors" and ".dtors". crtend.o contains a similar entry
|
||||||
@@ -48,16 +43,9 @@ _init(void)
|
|||||||
void
|
void
|
||||||
_fini(void)
|
_fini(void)
|
||||||
{
|
{
|
||||||
extern jmp_buf __exit_jmp_buf;
|
|
||||||
|
|
||||||
int num_dtors,i;
|
int num_dtors,i;
|
||||||
static int j;
|
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++)
|
for(i = 1, num_dtors = 0 ; __DTOR_LIST__[i] != NULL ; i++)
|
||||||
num_dtors++;
|
num_dtors++;
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#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
|
/* With SAS/C this function is placed in front of the first constructor
|
||||||
* table entry. It will invoke all following constructors and
|
table entry. It will invoke all following constructors and
|
||||||
* finally all the destructors. We don't use this approach here.
|
finally all the destructors. We don't use this approach here. */
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
__construct(void)
|
__construct(void)
|
||||||
{
|
{
|
||||||
@@ -92,18 +90,11 @@ _fini(void)
|
|||||||
{
|
{
|
||||||
static int i;
|
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)
|
while(__dtors[i] != NULL)
|
||||||
{
|
{
|
||||||
/* Increment this before jumping in, so that the next
|
/* Increment this before jumping in, so that the next
|
||||||
* invocation will always pick up the destructor following
|
invocation will always pick up the destructor following
|
||||||
* the one we will invoke rigt now.
|
the one we will invoke rigt now. */
|
||||||
*/
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
(*__dtors[i-1])();
|
(*__dtors[i-1])();
|
||||||
@@ -129,6 +120,7 @@ void
|
|||||||
_init(void)
|
_init(void)
|
||||||
{
|
{
|
||||||
extern func_ptr __CTOR_LIST__[];
|
extern func_ptr __CTOR_LIST__[];
|
||||||
|
|
||||||
ULONG num_ctors = (ULONG)__CTOR_LIST__[0];
|
ULONG num_ctors = (ULONG)__CTOR_LIST__[0];
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
@@ -155,7 +147,7 @@ void
|
|||||||
_fini(void)
|
_fini(void)
|
||||||
{
|
{
|
||||||
extern func_ptr __DTOR_LIST__[];
|
extern func_ptr __DTOR_LIST__[];
|
||||||
extern jmp_buf __exit_jmp_buf;
|
|
||||||
ULONG num_dtors = (ULONG)__DTOR_LIST__[0];
|
ULONG num_dtors = (ULONG)__DTOR_LIST__[0];
|
||||||
static ULONG i;
|
static ULONG i;
|
||||||
|
|
||||||
@@ -163,12 +155,6 @@ _fini(void)
|
|||||||
|
|
||||||
D(("there are %ld destructors to be called",num_dtors));
|
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 */
|
/* Call all destructors in forward order */
|
||||||
while(i++ < num_dtors)
|
while(i++ < num_dtors)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -184,6 +184,11 @@ call_main(void)
|
|||||||
|
|
||||||
SHOWMSG("invoking the destructors");
|
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 */
|
/* Go through the destructor list */
|
||||||
_fini();
|
_fini();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user