mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Moved data out of stdlib_data.c and into the code that references
or initializes it. - The stdlib constructor now performs the CPU/FPU compatibility test. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14879 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.68k,v 1.39 2005-03-10 09:55:03 obarthel Exp $
|
||||
# $Id: GNUmakefile.68k,v 1.40 2005-03-11 09:37:27 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -280,7 +280,6 @@ C_LIB = \
|
||||
stdlib_checkdetach.o \
|
||||
stdlib_constructor.o \
|
||||
stdlib_constructor_begin.o \
|
||||
stdlib_data.o \
|
||||
stdlib_default_pool_size.o \
|
||||
stdlib_default_puddle_size.o \
|
||||
stdlib_destructor.o \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.os4,v 1.40 2005-03-10 09:55:03 obarthel Exp $
|
||||
# $Id: GNUmakefile.os4,v 1.41 2005-03-11 09:37:28 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -279,7 +279,6 @@ C_LIB = \
|
||||
stdlib_checkdetach.o \
|
||||
stdlib_constructor.o \
|
||||
stdlib_constructor_begin.o \
|
||||
stdlib_data.o \
|
||||
stdlib_default_pool_size.o \
|
||||
stdlib_default_puddle_size.o \
|
||||
stdlib_destructor.o \
|
||||
|
||||
@ -54,6 +54,11 @@
|
||||
|
||||
- Added S_IREAD, S_IWRITE and S_IEXEC aliases to <sys/stat.h>.
|
||||
|
||||
- Moved data out of stdlib_data.c and into the code that references
|
||||
or initializes it.
|
||||
|
||||
- The stdlib constructor now performs the CPU/FPU compatibility test.
|
||||
|
||||
|
||||
c.lib 1.189 (5.3.2005)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: smakefile,v 1.31 2005-03-10 09:55:03 obarthel Exp $
|
||||
# $Id: smakefile,v 1.32 2005-03-11 09:37:29 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -382,7 +382,6 @@ STDLIB_OBJ = \
|
||||
stdlib_checkdetach.o \
|
||||
stdlib_constructor_begin.o \
|
||||
stdlib_constructor.o \
|
||||
stdlib_data.o \
|
||||
stdlib_default_pool_size.o \
|
||||
stdlib_default_puddle_size.o \
|
||||
stdlib_destructor.o \
|
||||
@ -652,8 +651,6 @@ stdlib_swapstack.o : stdlib_swapstack.asm
|
||||
|
||||
stdio_fdhookentry.o : stdio_fdhookentry.c stdlib_mem_debug.h
|
||||
|
||||
stdlib_data.o : stdlib_data.c stdlib_mem_debug.h
|
||||
|
||||
stdio_openiob.o : stdio_openiob.c stdlib_mem_debug.h
|
||||
|
||||
stdlib_alloca.o : stdlib_alloca.c stdlib_mem_debug.h
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_file_init.c,v 1.1 2005-03-07 11:16:43 obarthel Exp $
|
||||
* $Id: stdio_file_init.c,v 1.2 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -66,6 +66,10 @@ static BPTR input;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
struct WBStartup * __WBenchMsg;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
CLIB_DESTRUCTOR(workbench_exit)
|
||||
{
|
||||
ENTER();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_growfdtable.c,v 1.5 2005-03-09 10:48:59 obarthel Exp $
|
||||
* $Id: stdio_growfdtable.c,v 1.6 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -43,12 +43,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The file descriptor table. */
|
||||
struct fd ** __fd;
|
||||
int __num_fd;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
__grow_fd_table(int max_fd)
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_growiobtable.c,v 1.5 2005-03-09 10:48:59 obarthel Exp $
|
||||
* $Id: stdio_growiobtable.c,v 1.6 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -43,12 +43,6 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The file handle table. */
|
||||
struct iob ** __iob;
|
||||
int __num_iob;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
__grow_iob_table(int max_iob)
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_init_exit.c,v 1.25 2005-03-09 16:56:05 obarthel Exp $
|
||||
* $Id: stdio_init_exit.c,v 1.26 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -47,6 +47,18 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The file handle table. */
|
||||
struct iob ** __iob;
|
||||
int __num_iob;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The file descriptor table. */
|
||||
struct fd ** __fd;
|
||||
int __num_fd;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
__close_all_files(void)
|
||||
{
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* $Id: stdlib_data.c,v 1.6 2005-03-07 11:16:43 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Neither the name of Olaf Barthel nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _STDLIB_MEM_DEBUG_H
|
||||
#include "stdlib_mem_debug.h"
|
||||
#endif /* _STDLIB_MEM_DEBUG_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _STDLIB_HEADERS_H
|
||||
#include "stdlib_headers.h"
|
||||
#endif /* _STDLIB_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
struct WBStartup * __WBenchMsg;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
BOOL __stack_overflow;
|
||||
ULONG __stk_maxsize;
|
||||
ULONG __stk_extensions;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
struct Library * __UtilityBase;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
struct UtilityIFace * __IUtility;
|
||||
#endif /* __amigaos4__ */
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_headers.h,v 1.13 2005-03-07 11:16:43 obarthel Exp $
|
||||
* $Id: stdlib_headers.h,v 1.14 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -221,7 +221,6 @@ extern unsigned int NOCOMMON (* __get_default_stack_size)(void);
|
||||
/****************************************************************************/
|
||||
|
||||
extern unsigned int NOCOMMON __stack_size;
|
||||
extern BOOL NOCOMMON __stack_overflow;
|
||||
extern UBYTE * NOCOMMON __stk_limit;
|
||||
extern UBYTE * NOCOMMON __base;
|
||||
|
||||
@ -229,9 +228,7 @@ extern UBYTE * NOCOMMON __base;
|
||||
|
||||
extern ULONG NOCOMMON __stk_argbytes;
|
||||
extern ULONG NOCOMMON __stk_safezone;
|
||||
extern ULONG NOCOMMON __stk_maxsize;
|
||||
extern ULONG NOCOMMON __stk_size;
|
||||
extern ULONG NOCOMMON __stk_extensions;
|
||||
extern ULONG NOCOMMON __stk_minframe;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_init_exit.c,v 1.6 2005-03-07 11:16:43 obarthel Exp $
|
||||
* $Id: stdlib_init_exit.c,v 1.7 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -76,6 +76,9 @@ __stdlib_init(void)
|
||||
|
||||
ENTER();
|
||||
|
||||
if(__machine_test() < 0)
|
||||
goto out;
|
||||
|
||||
if(__WBenchMsg == NULL)
|
||||
{
|
||||
const size_t program_name_size = 256;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_main.c,v 1.13 2005-03-07 14:04:09 obarthel Exp $
|
||||
* $Id: stdlib_main.c,v 1.14 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -64,6 +64,11 @@ extern int main(int arg_c,char ** arg_v);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* This will be set to TRUE in case a stack overflow was detected. */
|
||||
BOOL __stack_overflow;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The SAS/C profiling hooks can be used to track call chains. Neat
|
||||
trick, but not always necessary. Don't enable this unless you know
|
||||
what you're doing... */
|
||||
@ -119,7 +124,6 @@ call_main(void)
|
||||
__stk_init,
|
||||
__stdio_init,
|
||||
__stdio_file_init,
|
||||
__machine_test,
|
||||
__math_init,
|
||||
__socket_init,
|
||||
__arg_init,
|
||||
@ -214,7 +218,11 @@ call_main(void)
|
||||
}
|
||||
|
||||
/* If necessary, print stack size usage information. */
|
||||
__stack_usage_exit();
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
__stack_usage_exit();
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
|
||||
SHOWMSG("invoking the destructors");
|
||||
|
||||
@ -300,6 +308,17 @@ get_stack_size(void)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The global utility.library base, as required by clib2. */
|
||||
struct Library * __UtilityBase;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#if defined(__amigaos4__)
|
||||
struct UtilityIFace * __IUtility;
|
||||
#endif /* __amigaos4__ */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
_main(void)
|
||||
{
|
||||
@ -460,7 +479,11 @@ _main(void)
|
||||
stk->stk_Pointer = (APTR)(stk->stk_Upper - 32);
|
||||
|
||||
/* If necessary, set up for stack size usage measurement. */
|
||||
__stack_usage_init(stk);
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
__stack_usage_init(stk);
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
|
||||
return_code = __swap_stack_and_call(stk,(APTR)call_main);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_stack_usage.c,v 1.2 2005-01-02 09:07:18 obarthel Exp $
|
||||
* $Id: stdlib_stack_usage.c,v 1.3 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -31,6 +31,10 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#include "stdlib_headers.h"
|
||||
|
||||
/****************************************************************************/
|
||||
@ -39,12 +43,8 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
static struct StackSwapStruct stack_swap_struct;
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#define STACK_FILL_COOKIE 0xA1
|
||||
@ -52,20 +52,16 @@ static struct StackSwapStruct stack_swap_struct;
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
__stack_usage_init(struct StackSwapStruct * UNUSED stk)
|
||||
__stack_usage_init(struct StackSwapStruct * stk)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if(stk != NULL)
|
||||
{
|
||||
if(stk != NULL)
|
||||
{
|
||||
size_t stack_size = ((ULONG)stk->stk_Upper - (ULONG)stk->stk_Lower);
|
||||
size_t stack_size = ((ULONG)stk->stk_Upper - (ULONG)stk->stk_Lower);
|
||||
|
||||
memset(stk->stk_Lower,STACK_FILL_COOKIE,stack_size);
|
||||
memset(stk->stk_Lower,STACK_FILL_COOKIE,stack_size);
|
||||
|
||||
stack_swap_struct = (*stk);
|
||||
}
|
||||
stack_swap_struct = (*stk);
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@ -73,45 +69,45 @@ __stack_usage_init(struct StackSwapStruct * UNUSED stk)
|
||||
void
|
||||
__stack_usage_exit(void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if(stack_swap_struct.stk_Lower != NULL && stack_swap_struct.stk_Upper != 0)
|
||||
{
|
||||
if(stack_swap_struct.stk_Lower != NULL && stack_swap_struct.stk_Upper != 0)
|
||||
const UBYTE * m = (const UBYTE *)stack_swap_struct.stk_Lower;
|
||||
size_t stack_size = ((ULONG)stack_swap_struct.stk_Upper - (ULONG)stack_swap_struct.stk_Lower);
|
||||
size_t total,i;
|
||||
|
||||
total = 0;
|
||||
|
||||
/* Figure out how much of the stack was used by checking
|
||||
if the fill pattern was overwritten. */
|
||||
for(i = 0 ; i < stack_size ; i++)
|
||||
{
|
||||
const UBYTE * m = (const UBYTE *)stack_swap_struct.stk_Lower;
|
||||
size_t stack_size = ((ULONG)stack_swap_struct.stk_Upper - (ULONG)stack_swap_struct.stk_Lower);
|
||||
size_t total,i;
|
||||
/* Strangely, the first long word is always trashed,
|
||||
even if the stack doesn't grow down this far... */
|
||||
if(i > sizeof(LONG) && m[i] != STACK_FILL_COOKIE)
|
||||
break;
|
||||
|
||||
total = 0;
|
||||
|
||||
/* Figure out how much of the stack was used by checking
|
||||
if the fill pattern was overwritten. */
|
||||
for(i = 0 ; i < stack_size ; i++)
|
||||
{
|
||||
/* Strangely, the first long word is always trashed,
|
||||
even if the stack doesn't grow down this far... */
|
||||
if(i > sizeof(LONG) && m[i] != STACK_FILL_COOKIE)
|
||||
break;
|
||||
|
||||
total++;
|
||||
}
|
||||
|
||||
kprintf("[%s] total amount of stack space used = %ld bytes\n",
|
||||
__program_name,stack_size - total);
|
||||
|
||||
stack_swap_struct.stk_Lower = NULL;
|
||||
stack_swap_struct.stk_Upper = 0;
|
||||
total++;
|
||||
}
|
||||
|
||||
if(__stk_maxsize == 0)
|
||||
{
|
||||
kprintf("[%s] no stack extension was performed\n",
|
||||
__program_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
kprintf("[%s] maximum size of extended stack = %ld bytes, stack was extended %ld times\n",
|
||||
__program_name,__stk_maxsize,__stk_extensions);
|
||||
}
|
||||
kprintf("[%s] total amount of stack space used = %ld bytes\n",
|
||||
__program_name,stack_size - total);
|
||||
|
||||
stack_swap_struct.stk_Lower = NULL;
|
||||
stack_swap_struct.stk_Upper = 0;
|
||||
}
|
||||
|
||||
if(__stk_maxsize == 0)
|
||||
{
|
||||
kprintf("[%s] no stack extension was performed\n",
|
||||
__program_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
kprintf("[%s] maximum size of extended stack = %ld bytes, stack was extended %ld times\n",
|
||||
__program_name,__stk_maxsize,__stk_extensions);
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_stackextension.c,v 1.6 2005-02-27 21:58:21 obarthel Exp $
|
||||
* $Id: stdlib_stackextension.c,v 1.7 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -65,6 +65,11 @@ static struct stackframe * __stk_spare; /* spare stackframes */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
ULONG __stk_extensions; /* number of stack extensions performed */
|
||||
ULONG __stk_maxsize; /* maximum amount of memory allocated for stack extension */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#if defined(SMALL_DATA)
|
||||
#define A4(x) "a4@(" #x ":W)"
|
||||
#elif defined(SMALL_DATA32)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdlib_stackoverflow.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
|
||||
* $Id: stdlib_stackoverflow.c,v 1.3 2005-03-11 09:37:29 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -37,6 +37,10 @@
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
extern BOOL NOCOMMON __stack_overflow;
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user