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

- The start time used by clock() is now initialized by a constructor

function.

- NOTE THAT ALL THE CHANGES WITH REGARD TO USE OF DESTRUCTOR AND
  CONSTRUCTOR FUNCTIONS REQUIRE A COMPLETE REBUILD OF THE LIBRARY! IF
  YOU DO NOT DO THIS, THE CONSTRUCTOR/DESTRUCTOR FUNCTIONS MAY NOT
  GET CALLED.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14744 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2004-09-29 19:57:58 +00:00
parent f49a45f6a8
commit 5d9e4c07a6
19 changed files with 148 additions and 147 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_constructor_begin.c,v 1.1.1.1 2004-07-26 16:31:52 obarthel Exp $
* $Id: stdlib_constructor_begin.c,v 1.2 2004-09-29 19:57:57 obarthel Exp $
*
* :ts=4
*
@ -42,80 +42,7 @@
/****************************************************************************/
#if defined(__amigaos4__)
/****************************************************************************/
/*
* 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
* with a NULL pointer entry and is put at the end of the sections. This way, the init
* code can find the global constructor/destructor pointers
*/
static void (*__CTOR_LIST__[1]) (void) __attribute__((section(".ctors"))) = { (void *)-1 };
static void (*__DTOR_LIST__[1]) (void) __attribute__((section(".dtors"))) = { (void *)-1 };
/****************************************************************************/
static void
_do_ctors(void)
{
void (**pFuncPtr)(void);
/* Skip the first entry in the list (it's -1 anyway) */
pFuncPtr = __CTOR_LIST__ + 1;
/* Call all constructors in forward order */
while (*pFuncPtr != NULL)
(**pFuncPtr++)();
}
/****************************************************************************/
static void
_do_dtors(void)
{
static ULONG i = ~0UL;
void (**pFuncPtr)(void);
if(i == ~0UL)
{
ULONG j = (ULONG)__DTOR_LIST__[0];
if(j == ~0UL)
{
/* Find the end of the destructors list. */
j = 1;
while(__DTOR_LIST__[j] != NULL)
j++;
/* We're at the NULL entry now. Go back by one. */
j--;
}
i = j;
}
/* 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 reverse order. */
pFuncPtr = &__DTOR_LIST__[i];
while(i > 0)
{
i--;
(**pFuncPtr--)();
}
}
/****************************************************************************/
#elif defined(__SASC)
#if defined(__SASC)
/****************************************************************************/
@ -201,9 +128,21 @@ _do_ctors(void)
ULONG nptrs = (ULONG)__CTOR_LIST__[0];
ULONG i;
ENTER();
D(("there are %ld constructors to be called",nptrs));
/* Call all constructors in forward order */
for(i = 0 ; i < nptrs ; i++)
{
D(("calling constructor #%ld, 0x%08lx",i,__CTOR_LIST__[1+i]));
__CTOR_LIST__[1+i]();
}
SHOWMSG("all done.");
LEAVE();
}
/****************************************************************************/
@ -216,6 +155,10 @@ _do_dtors(void)
ULONG nptrs = (ULONG)__DTOR_LIST__[0];
static ULONG i;
ENTER();
D(("there are %ld destructors to be called",nptrs));
/* If one of the destructors drops into
* exit(), processing will continue with
* the next following destructor.
@ -224,7 +167,15 @@ _do_dtors(void)
/* Call all destructors in reverse order */
while(i++ < nptrs)
{
D(("calling destructor #%ld, 0x%08lx",i,__DTOR_LIST__[1+nptrs - i]));
__DTOR_LIST__[1+nptrs - i]();
}
SHOWMSG("all done.");
LEAVE();
}
/****************************************************************************/