diff --git a/library/changes b/library/changes index 91c3b13..4738b0e 100644 --- a/library/changes +++ b/library/changes @@ -101,6 +101,13 @@ - Dropped unused stub code which is now redundant because of the constructor/destructor mechanism. +- Moved the call chain printing out of stdlib_main.c and into + separate files. + +- Removed some more redundant data from stdlib_main.c. + +- Added the first real C99 function: _Exit(). + c.lib 1.189 (5.3.2005) diff --git a/library/stdio_vasprintf.c b/library/stdio_vasprintf.c index 5ec2e90..4c32823 100644 --- a/library/stdio_vasprintf.c +++ b/library/stdio_vasprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vasprintf.c,v 1.10 2005-03-18 12:38:23 obarthel Exp $ + * $Id: stdio_vasprintf.c,v 1.11 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -41,6 +41,10 @@ #include "stdlib_headers.h" #endif /* _STDLIB_HEADERS_H */ +#ifndef _STDIO_HEADERS_H +#include "stdio_headers.h" +#endif /* _STDIO_HEADERS_H */ + /****************************************************************************/ #ifndef _STDLIB_MEMORY_H @@ -49,12 +53,6 @@ /****************************************************************************/ -#ifndef _STDIO_HEADERS_H -#include "stdio_headers.h" -#endif /* _STDIO_HEADERS_H */ - -/****************************************************************************/ - /* The following is not part of the ISO 'C' (1994) standard. */ /****************************************************************************/ diff --git a/library/stdio_vasprintf_hook_entry.c b/library/stdio_vasprintf_hook_entry.c index 4298beb..e868b51 100644 --- a/library/stdio_vasprintf_hook_entry.c +++ b/library/stdio_vasprintf_hook_entry.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vasprintf_hook_entry.c,v 1.5 2005-02-20 15:46:52 obarthel Exp $ + * $Id: stdio_vasprintf_hook_entry.c,v 1.6 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -41,14 +41,18 @@ #include "stdio_headers.h" #endif /* _STDIO_HEADERS_H */ -/****************************************************************************/ - #ifndef _STDLIB_HEADERS_H #include "stdlib_headers.h" #endif /* _STDLIB_HEADERS_H */ /****************************************************************************/ +#ifndef _STDLIB_MEMORY_H +#include "stdlib_memory.h" +#endif /* _STDLIB_MEMORY_H */ + +/****************************************************************************/ + int __vasprintf_hook_entry( struct iob * string_iob, diff --git a/library/stdlib_assertion_failure.c b/library/stdlib_assertion_failure.c index 7794429..b41a40d 100644 --- a/library/stdlib_assertion_failure.c +++ b/library/stdlib_assertion_failure.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_assertion_failure.c,v 1.8 2005-03-18 12:38:23 obarthel Exp $ + * $Id: stdlib_assertion_failure.c,v 1.9 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -31,16 +31,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _STDLIB_HEADERS_H -#include "stdlib_headers.h" -#endif /* _STDLIB_HEADERS_H */ - -#ifndef _STDIO_HEADERS_H -#include "stdio_headers.h" -#endif /* _STDIO_HEADERS_H */ - -/****************************************************************************/ - #ifndef PROTO_EXEC_H #include #endif /* PROTO_EXEC_H */ @@ -58,6 +48,16 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +#ifndef _STDIO_HEADERS_H +#include "stdio_headers.h" +#endif /* _STDIO_HEADERS_H */ + +/****************************************************************************/ + void __assertion_failure( const char * file_name, diff --git a/library/stdlib_exit.c b/library/stdlib_exit.c index 9de553c..28ac51a 100644 --- a/library/stdlib_exit.c +++ b/library/stdlib_exit.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_exit.c,v 1.3 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_exit.c,v 1.4 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -52,10 +52,18 @@ _exit(int return_code) /****************************************************************************/ +/* The C99 version of _exit(). */ +void +_Exit(int return_code) +{ + _exit(return_code); +} + +/****************************************************************************/ + void exit(int return_code) { - /* ZZZ what about inifinite recursion in __exit_trap_trigger()? */ __exit_trap_trigger(); _exit(return_code); diff --git a/library/stdlib_main.c b/library/stdlib_main.c index e9b2923..336d790 100644 --- a/library/stdlib_main.c +++ b/library/stdlib_main.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_main.c,v 1.17 2005-03-18 12:38:24 obarthel Exp $ + * $Id: stdlib_main.c,v 1.18 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -41,6 +41,14 @@ /****************************************************************************/ +#include +#include +#include +#include +#include + +/****************************************************************************/ + #ifndef _STDLIB_HEADERS_H #include "stdlib_headers.h" #endif /* _STDLIB_HEADERS_H */ @@ -51,16 +59,9 @@ /****************************************************************************/ -#include -#include -#include -#include -#include - -/****************************************************************************/ - -typedef int (*init_func_ptr)(void); -typedef void (*exit_func_ptr)(void); +#ifndef _STDLIB_PROFILE_MONITORING_H +#include "stdlib_profile_monitoring.h" +#endif /* _STDLIB_PROFILE_MONITORING_H */ /****************************************************************************/ @@ -73,49 +74,6 @@ 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... */ -#if defined(__USE_SAS_PROFILING_FOR_MONITORING) - -/****************************************************************************/ - -static BOOL show_profile_names = FALSE; -static int nest_level; - -void ASM -_PROLOG(REG(a0,char * id)) -{ - nest_level++; - - if(id != NULL && __program_name != NULL) - { - int i; - - kprintf("[%s]",__program_name); - - for(i = 0 ; i < nest_level ; i++) - kputc(' '); - - kprintf("%s\n",id); - } -} - -/****************************************************************************/ - -void ASM -_EPILOG(REG(a0,char * id)) -{ - if(nest_level > 0) - nest_level--; -} - -/****************************************************************************/ - -#endif /* __USE_SAS_PROFILING_FOR_MONITORING */ - -/****************************************************************************/ - STATIC int call_main(void) { @@ -134,11 +92,7 @@ call_main(void) /* If the SAS/C profiling code is set up for printing function call chains, switch it on now. */ - #if defined(__USE_SAS_PROFILING_FOR_MONITORING) - { - show_profile_names = TRUE; - } - #endif /* __USE_SAS_PROFILING_FOR_MONITORING */ + __show_profile_names(); /* After all these preparations, get this show on the road... */ exit(main((int)__argc,(char **)__argv)); @@ -146,11 +100,7 @@ call_main(void) out: /* Switch off function name printing, if it was enabled. */ - #if defined(__USE_SAS_PROFILING_FOR_MONITORING) - { - show_profile_names = FALSE; - } - #endif /* __USE_SAS_PROFILING_FOR_MONITORING */ + __hide_profile_names(); /* If we end up here with the __stack_overflow variable set then the stack overflow handler dropped into diff --git a/library/stdlib_profile_monitoring.c b/library/stdlib_profile_monitoring.c new file mode 100644 index 0000000..3296144 --- /dev/null +++ b/library/stdlib_profile_monitoring.c @@ -0,0 +1,94 @@ +/* + * $Id: stdlib_profile_monitoring.c,v 1.1 2005-03-19 10:15:56 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * 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. + */ + +#if defined(__SASC) + +/****************************************************************************/ + +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +static BOOL show_profile_names = FALSE; +static int nest_level; + +/****************************************************************************/ + +void ASM +_PROLOG(REG(a0,char * id)) +{ + nest_level++; + + if(id != NULL && __program_name != NULL) + { + int i; + + kprintf("[%s]",__program_name); + + for(i = 0 ; i < nest_level ; i++) + kputc(' '); + + kprintf("%s\n",id); + } +} + +/****************************************************************************/ + +void ASM +_EPILOG(REG(a0,char * id)) +{ + if(nest_level > 0) + nest_level--; +} + +/****************************************************************************/ + +void +__show_profile_names(void) +{ + show_profile_names = TRUE; +} + +/****************************************************************************/ + +void +__hide_profile_names(void) +{ + show_profile_names = FALSE; +} + +/****************************************************************************/ + +#endif /* __SASC */ diff --git a/library/stdlib_profile_monitoring.h b/library/stdlib_profile_monitoring.h new file mode 100644 index 0000000..4f0d94f --- /dev/null +++ b/library/stdlib_profile_monitoring.h @@ -0,0 +1,71 @@ +/* + * $Id: stdlib_profile_monitoring.h,v 1.1 2005-03-19 10:15:56 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * 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_PROFILE_MONITORING_H +#define _STDLIB_PROFILE_MONITORING_H + +/****************************************************************************/ + +/* 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... */ + +/****************************************************************************/ + +/*#define USE_PROFILE_MONITORING*/ + +/****************************************************************************/ + +#if defined(__SASC) && defined(USE_PROFILE_MONITORING) + +/****************************************************************************/ + +extern void __show_profile_names(void); +extern void __hide_profile_names(void); + +/****************************************************************************/ + +#else + +/****************************************************************************/ + +#define __show_profile_names() ((void)0) +#define __hide_profile_names() ((void)0) + +/****************************************************************************/ + +#endif /* __SASC && USE_PROFILE_MONITORING */ + +/****************************************************************************/ + +#endif /* _STDLIB_PROFILE_MONITORING_H */ diff --git a/library/string_strdup.c b/library/string_strdup.c index 7f6ed89..e36cbab 100644 --- a/library/string_strdup.c +++ b/library/string_strdup.c @@ -1,5 +1,5 @@ /* - * $Id: string_strdup.c,v 1.7 2005-03-18 12:38:25 obarthel Exp $ + * $Id: string_strdup.c,v 1.8 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -41,8 +41,6 @@ #include "string_headers.h" #endif /* _STRING_HEADERS_H */ -/****************************************************************************/ - #ifndef _STDLIB_HEADERS_H #include "stdlib_headers.h" #endif /* _STDLIB_HEADERS_H */ diff --git a/library/time_gettimeofday.c b/library/time_gettimeofday.c index 9595160..f527347 100644 --- a/library/time_gettimeofday.c +++ b/library/time_gettimeofday.c @@ -1,5 +1,5 @@ /* - * $Id: time_gettimeofday.c,v 1.8 2005-03-18 12:38:25 obarthel Exp $ + * $Id: time_gettimeofday.c,v 1.9 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -31,6 +31,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifndef PROTO_TIMER_H +#include +#endif /* PROTO_TIMER_H */ + +/****************************************************************************/ + +#include + +/****************************************************************************/ + #ifndef _TIME_HEADERS_H #include "time_headers.h" #endif /* _TIME_HEADERS_H */ @@ -45,16 +55,6 @@ /****************************************************************************/ -#include - -/****************************************************************************/ - -#ifndef PROTO_TIMER_H -#include -#endif /* PROTO_TIMER_H */ - -/****************************************************************************/ - /* The following is not part of the ISO 'C' (1994) standard. */ /****************************************************************************/ diff --git a/library/utime_headers.h b/library/utime_headers.h index a774c62..1ec8b59 100644 --- a/library/utime_headers.h +++ b/library/utime_headers.h @@ -1,5 +1,5 @@ /* - * $Id: utime_headers.h,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: utime_headers.h,v 1.3 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -40,6 +40,20 @@ #include "stdio_headers.h" #endif /* _STDIO_HEADERS_H */ +#ifndef _LOCALE_HEADERS_H +#include "locale_headers.h" +#endif /* _LOCALE_HEADERS_H */ + +#ifndef _TIME_HEADERS_H +#include "time_headers.h" +#endif /* _TIME_HEADERS_H */ + +/****************************************************************************/ + +#ifndef _STDLIB_PROFILE_H +#include "stdlib_profile.h" +#endif /* _STDLIB_PROFILE_H */ + /****************************************************************************/ #endif /* _UTIME_HEADERS_H */ diff --git a/library/utime_utime.c b/library/utime_utime.c index c7d9791..fbcb8b6 100644 --- a/library/utime_utime.c +++ b/library/utime_utime.c @@ -1,5 +1,5 @@ /* - * $Id: utime_utime.c,v 1.8 2005-03-18 12:38:25 obarthel Exp $ + * $Id: utime_utime.c,v 1.9 2005-03-19 10:15:56 obarthel Exp $ * * :ts=4 * @@ -41,20 +41,6 @@ #include "utime_headers.h" #endif /* _UTIME_HEADERS_H */ -#ifndef _LOCALE_HEADERS_H -#include "locale_headers.h" -#endif /* _LOCALE_HEADERS_H */ - -#ifndef _TIME_HEADERS_H -#include "time_headers.h" -#endif /* _TIME_HEADERS_H */ - -/****************************************************************************/ - -#ifndef _STDLIB_PROFILE_H -#include "stdlib_profile.h" -#endif /* _STDLIB_PROFILE_H */ - /****************************************************************************/ /* The following is not part of the ISO 'C' (1994) standard. */