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

- Moved all the constructor code out of "stdlib_init_exit.c" and into the

files which initialize global data, such as the new "stdlib_program_name.c"
  and "stdlib_malloc.c".

- Until I can find a way to invoke it from within the library, the
  __machine_test() function is no longer invoked.

- Tagged global data with NOCOMMON attributes.

- Added the __lib_init() and __lib_exit() functions, which are part of the
  thread-safe library and which can be used to hook up clib2 with standard
  Amiga shared library/device code. Some documentation on how to use them
  can be found in the <dos.h> header file.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14999 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-07-03 10:36:48 +00:00
parent 2421ffcbb9
commit ebf5d63bc6
46 changed files with 540 additions and 157 deletions

View File

@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.68k,v 1.64 2005-06-26 10:23:05 obarthel Exp $
# $Id: GNUmakefile.68k,v 1.65 2005-07-03 10:36:46 obarthel Exp $
#
# :ts=8
#
@ -306,12 +306,13 @@ C_LIB = \
stdlib_getenv.o \
stdlib_getsp.o \
stdlib_get_errno.o \
stdlib_init_exit.o \
stdlib_isresident.o \
stdlib_labs.o \
stdlib_llabs.o \
stdlib_ldiv.o \
stdlib_lldiv.o \
stdlib_lib_main.o \
stdlib_lib_startup.o \
stdlib_machine_test.o \
stdlib_main.o \
stdlib_malloc.o \
@ -326,6 +327,7 @@ C_LIB = \
stdlib_oslibversion.o \
stdlib_priority.o \
stdlib_process_name.o \
stdlib_program_name.o \
stdlib_putenv.o \
stdlib_qsort.o \
stdlib_rand.o \
@ -1035,8 +1037,6 @@ $(LIBC_OBJS)/stdlib_calloc.o : stdlib_calloc.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_free.o : stdlib_free.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_init_exit.o : stdlib_init_exit.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_malloc.o : stdlib_malloc.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_realloc.o : stdlib_realloc.c stdlib_memory.h
@ -1229,7 +1229,8 @@ CONSTRUCTOR_FILES = \
stdio_init_exit.c \
stdlib_alloca.c \
stdlib_arg.c \
stdlib_init_exit.c \
stdlib_malloc.c \
stdlib_program_name.c \
stdlib_setenv.c \
stdlib_stackcheck.c \
stdlib_stackextension.c \

View File

@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.os4,v 1.71 2005-06-26 11:46:21 obarthel Exp $
# $Id: GNUmakefile.os4,v 1.72 2005-07-03 10:36:46 obarthel Exp $
#
# :ts=8
#
@ -317,12 +317,13 @@ C_LIB = \
stdlib_getenv.o \
stdlib_getsp.o \
stdlib_get_errno.o \
stdlib_init_exit.o \
stdlib_isresident.o \
stdlib_labs.o \
stdlib_llabs.o \
stdlib_ldiv.o \
stdlib_lldiv.o \
stdlib_lib_main.o \
stdlib_lib_startup.o \
stdlib_machine_test.o \
stdlib_main.o \
stdlib_malloc.o \
@ -337,6 +338,7 @@ C_LIB = \
stdlib_oslibversion.o \
stdlib_priority.o \
stdlib_process_name.o \
stdlib_program_name.o \
stdlib_putenv.o \
stdlib_qsort.o \
stdlib_rand.o \
@ -1057,8 +1059,6 @@ $(LIBC_OBJS)/stdlib_calloc.o : stdlib_calloc.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_free.o : stdlib_free.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_init_exit.o : stdlib_init_exit.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_malloc.o : stdlib_malloc.c stdlib_memory.h
$(LIBC_OBJS)/stdlib_realloc.o : stdlib_realloc.c stdlib_memory.h

View File

@ -31,6 +31,20 @@
- Added file system names to statfx <tfrieden>
- Moved all the constructor code out of "stdlib_init_exit.c" and into the
files which initialize global data, such as the new "stdlib_program_name.c"
and "stdlib_malloc.c".
- Until I can find a way to invoke it from within the library, the
__machine_test() function is no longer invoked.
- Tagged global data with NOCOMMON attributes.
- Added the __lib_init() and __lib_exit() functions, which are part of the
thread-safe library and which can be used to hook up clib2 with standard
Amiga shared library/device code. Some documentation on how to use them
can be found in the <dos.h> header file.
c.lib 1.193 (4.6.2005)

View File

@ -1,5 +1,5 @@
/*
* $Id: dirent_closedir.c,v 1.13 2005-04-24 08:46:37 obarthel Exp $
* $Id: dirent_closedir.c,v 1.14 2005-07-03 10:36:46 obarthel Exp $
*
* :ts=4
*
@ -54,7 +54,7 @@
/****************************************************************************/
/* Directories being scanned whose locks need to be freed when shutting down. */
struct MinList __directory_list;
struct MinList NOCOMMON __directory_list;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: dos.h,v 1.9 2005-03-06 09:04:44 obarthel Exp $
* $Id: dos.h,v 1.10 2005-07-03 10:36:48 obarthel Exp $
*
* :ts=4
*
@ -52,6 +52,10 @@ extern "C" {
/****************************************************************************/
#ifndef EXEC_LIBRARIES_H
#include <exec/libraries.h>
#endif /* EXEC_LIBRARIES_H */
#ifndef WORKBENCH_STARTUP_H
#include <workbench/startup.h>
#endif /* WORKBENCH_STARTUP_H */
@ -328,6 +332,38 @@ extern int __translate_io_error_to_errno(LONG io_error);
/****************************************************************************/
/*
* Routines for use with shared libraries: invoke __lib_init() in your own
* shared library initialization function and __lib_exit() in your shared
* library cleanup function.
*
* __lib_init() will initialize the global SysBase/DOSBase variables
* (and the IExec/IDOS variables for OS4) and invoke the constructor
* functions required by your library code. It returns FALSE upon
* failure and TRUE otherwise. Make this the very first function you
* call in your shared library initialization function. The __lib_init()
* function expects to be called with a pointer to the exec.library
* base, which is normally passed to your shared library as part of the
* library startup code initialization performed by the operating
* system.
*
* __lib_exit() will undo all the initializations performed by the
* __lib_init() function, but leave the global SysBase variable
* (and the IExec variable for OS4) intact. Make this the very last
* function you call in your shared library cleanup function.
*
* Note that neither __lib_init() nor __lib_exit() are reentrant. You must
* make sure that while you are calling them no other library user can
* call them by accident.
*
* Both functions are only available as part of the thread-safe clib2
* linker library.
*/
extern VOID __lib_exit(VOID);
extern BOOL __lib_init(struct Library * SysBase);
/****************************************************************************/
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1,5 +1,5 @@
/*
* $Id: locale_init_exit.c,v 1.13 2005-04-24 08:46:37 obarthel Exp $
* $Id: locale_init_exit.c,v 1.14 2005-07-03 10:36:46 obarthel Exp $
*
* :ts=4
*
@ -43,22 +43,22 @@
/****************************************************************************/
struct Library * __LocaleBase;
struct Library * NOCOMMON __LocaleBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct LocaleIFace * __ILocale;
struct LocaleIFace * NOCOMMON __ILocale;
#endif /* __amigaos4__ */
/****************************************************************************/
struct Locale * __default_locale;
struct Locale * __locale_table[NUM_LOCALES];
struct Locale * NOCOMMON __default_locale;
struct Locale * NOCOMMON __locale_table[NUM_LOCALES];
/****************************************************************************/
char __locale_name_table[NUM_LOCALES][MAX_LOCALE_NAME_LEN];
char NOCOMMON __locale_name_table[NUM_LOCALES][MAX_LOCALE_NAME_LEN];
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: math_init_exit.c,v 1.17 2005-05-29 10:09:54 obarthel Exp $
* $Id: math_init_exit.c,v 1.18 2005-07-03 10:36:46 obarthel Exp $
*
* :ts=4
*
@ -65,21 +65,21 @@
#if defined(IEEE_FLOATING_POINT_SUPPORT)
struct Library * MathIeeeSingBasBase;
struct Library * MathIeeeDoubBasBase;
struct Library * MathIeeeDoubTransBase;
struct Library * NOCOMMON MathIeeeSingBasBase;
struct Library * NOCOMMON MathIeeeDoubBasBase;
struct Library * NOCOMMON MathIeeeDoubTransBase;
#endif /* IEEE_FLOATING_POINT_SUPPORT */
/****************************************************************************/
float __infinity;
float __nan;
float NOCOMMON __infinity;
float NOCOMMON __nan;
/****************************************************************************/
float __huge_val_float;
double __huge_val;
float NOCOMMON __huge_val_float;
double NOCOMMON __huge_val;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: mount_convertinfo.c,v 1.4 2005-06-26 11:59:37 tfrieden Exp $
* $Id: mount_convertinfo.c,v 1.5 2005-07-03 10:36:46 obarthel Exp $
*
* :ts=4
*
@ -90,50 +90,62 @@ __convert_info_to_statfs(struct InfoData * id,struct statfs * f)
if(id->id_DiskState != ID_VALIDATED)
SET_FLAG(f->f_flags,MNT_RDONLY);
switch (id->id_DiskType)
{
case ID_NO_DISK_PRESENT:
strcpy(f->f_fstypename, "None");
break;
case ID_UNREADABLE_DISK:
strcpy(f->f_fstypename, "NDOS");
break;
case ID_BUSY_DISK:
strcpy(f->f_fstypename, "Busy");
break;
case ID_DOS_DISK:
strcpy(f->f_fstypename, "DOS\\0");
break;
case ID_FFS_DISK:
strcpy(f->f_fstypename, "DOS\\1");
break;
case ID_INTER_DOS_DISK:
strcpy(f->f_fstypename, "DOS\\2");
break;
case ID_INTER_FFS_DISK:
strcpy(f->f_fstypename, "DOS\\3");
break;
case ID_FASTDIR_DOS_DISK:
strcpy(f->f_fstypename, "DOS\\4");
break;
case ID_FASTDIR_FFS_DISK:
strcpy(f->f_fstypename, "DOS\\5");
break;
case ID_LONGNAME_DOS_DISK:
strcpy(f->f_fstypename, "DOS\\6");
break;
case ID_LONGNAME_FFS_DISK:
strcpy(f->f_fstypename, "DOS\\7");
break;
case 0x53465300:
strcpy(f->f_fstypename, "SFS\\0");
break;
case ID_NOT_REALLY_DOS:
strcpy(f->f_fstypename, "NDOS");
break;
default:
strcpy(f->f_fstypename, "Unkown");
strcpy(f->f_fstypename, "Unknown");
break;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: signal_raise.c,v 1.8 2005-04-24 08:46:37 obarthel Exp $
* $Id: signal_raise.c,v 1.9 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -38,7 +38,7 @@
/****************************************************************************/
/* This table holds pointers to all signal handlers configured at a time. */
signal_handler_t __signal_handler_table[NUM_SIGNALS] =
signal_handler_t NOCOMMON __signal_handler_table[NUM_SIGNALS] =
{
SIG_DFL, /* SIGABRT */
SIG_DFL, /* SIGFPE */
@ -53,7 +53,7 @@ signal_handler_t __signal_handler_table[NUM_SIGNALS] =
/* This holds a mask of all signals whose delivery is currently blocked.
The sigaddset(), sigblock(), sigprocmask() and sigsetmask() functions
modify or query it. */
int __signals_blocked;
int NOCOMMON __signals_blocked;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
#
# $Id: smakefile,v 1.47 2005-06-18 07:23:16 obarthel Exp $
# $Id: smakefile,v 1.48 2005-07-03 10:36:47 obarthel Exp $
#
# :ts=8
#
@ -478,10 +478,11 @@ STDLIB_OBJ = \
stdlib_getdefstacksize.o \
stdlib_getenv.o \
stdlib_getsp.o \
stdlib_init_exit.o \
stdlib_isresident.o \
stdlib_labs.o \
stdlib_ldiv.o \
stdlib_lib_main.o \
stdlib_lib_startup.o \
stdlib_main.o \
stdlib_malloc.o \
stdlib_machine_test.o \
@ -493,6 +494,7 @@ STDLIB_OBJ = \
stdlib_oslibversion.o \
stdlib_priority.o \
stdlib_process_name.o \
stdlib_program_name.o \
stdlib_putenv.o \
stdlib_qsort.o \
stdlib_rand.o \
@ -753,8 +755,6 @@ stdlib_calloc.o : stdlib_calloc.c stdlib_memory.h
stdlib_free.o : stdlib_free.c stdlib_memory.h
stdlib_init_exit.o : stdlib_init_exit.c stdlib_memory.h
stdlib_malloc.o : stdlib_malloc.c stdlib_memory.h
stdlib_realloc.o : stdlib_realloc.c stdlib_memory.h

View File

@ -1,5 +1,5 @@
/*
* $Id: socket_init_exit.c,v 1.19 2005-03-18 12:38:23 obarthel Exp $
* $Id: socket_init_exit.c,v 1.20 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -80,17 +80,17 @@ struct DaemonMessage
/****************************************************************************/
struct Library * __SocketBase;
struct Library * NOCOMMON __SocketBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct SocketIFace *__ISocket;
struct SocketIFace * NOCOMMON __ISocket;
#endif /* __amigaos4__ */
/****************************************************************************/
int h_errno;
int NOCOMMON h_errno;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stat_umask.c,v 1.5 2005-04-24 14:04:36 obarthel Exp $
* $Id: stat_umask.c,v 1.6 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -41,7 +41,7 @@
/****************************************************************************/
mode_t __current_umask = S_IWGRP | S_IWOTH;
mode_t NOCOMMON __current_umask = S_IWGRP | S_IWOTH;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_file_init.c,v 1.9 2005-04-24 08:46:37 obarthel Exp $
* $Id: stdio_file_init.c,v 1.10 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -72,7 +72,7 @@ static BPTR input;
/****************************************************************************/
struct WBStartup * __WBenchMsg;
struct WBStartup * NOCOMMON __WBenchMsg;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_init_exit.c,v 1.31 2005-03-27 10:02:50 obarthel Exp $
* $Id: stdio_init_exit.c,v 1.32 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -54,14 +54,14 @@
/****************************************************************************/
/* The file handle table. */
struct iob ** __iob;
int __num_iob;
struct iob ** NOCOMMON __iob;
int NOCOMMON __num_iob;
/****************************************************************************/
/* The file descriptor table. */
struct fd ** __fd;
int __num_fd;
struct fd ** NOCOMMON __fd;
int NOCOMMON __num_fd;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_locksemaphorename.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $
* $Id: stdio_locksemaphorename.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,4 @@
/****************************************************************************/
char * __file_lock_semaphore_name = "Advisory File Locking";
char * NOCOMMON __file_lock_semaphore_name = "Advisory File Locking";

View File

@ -1,5 +1,5 @@
/*
* $Id: stdio_nostdio.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $
* $Id: stdio_nostdio.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,4 @@
/****************************************************************************/
BOOL __no_standard_io;
BOOL NOCOMMON __no_standard_io;

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_arg.c,v 1.7 2005-06-26 10:23:05 obarthel Exp $
* $Id: stdlib_arg.c,v 1.8 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -65,8 +65,8 @@
/****************************************************************************/
char ** __argv;
int __argc;
char ** NOCOMMON __argv;
int NOCOMMON __argc;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_default_pool_size.c,v 1.2 2005-01-02 09:07:18 obarthel Exp $
* $Id: stdlib_default_pool_size.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,4 @@
/****************************************************************************/
int __default_pool_size = 4096;
int NOCOMMON __default_pool_size = 4096;

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_default_puddle_size.c,v 1.2 2005-01-02 09:07:18 obarthel Exp $
* $Id: stdlib_default_puddle_size.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,4 @@
/****************************************************************************/
int __default_puddle_size = 4096;
int NOCOMMON __default_puddle_size = 4096;

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_exit.c,v 1.4 2005-03-19 10:15:56 obarthel Exp $
* $Id: stdlib_exit.c,v 1.5 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,17 +37,21 @@
/****************************************************************************/
jmp_buf __exit_jmp_buf;
int __exit_value = RETURN_FAIL;
jmp_buf NOCOMMON __exit_jmp_buf;
int NOCOMMON __exit_value = RETURN_FAIL;
BOOL NOCOMMON __exit_blocked;
/****************************************************************************/
void
_exit(int return_code)
{
__exit_value = return_code;
if(NOT __exit_blocked)
{
__exit_value = return_code;
longjmp(__exit_jmp_buf,1);
longjmp(__exit_jmp_buf,1);
}
}
/****************************************************************************/
@ -56,7 +60,8 @@ _exit(int return_code)
void
_Exit(int return_code)
{
_exit(return_code);
if(NOT __exit_blocked)
_exit(return_code);
}
/****************************************************************************/
@ -64,7 +69,10 @@ _Exit(int return_code)
void
exit(int return_code)
{
__exit_trap_trigger();
if(NOT __exit_blocked)
{
__exit_trap_trigger();
_exit(return_code);
_exit(return_code);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_headers.h,v 1.17 2005-03-30 19:37:27 obarthel Exp $
* $Id: stdlib_headers.h,v 1.18 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -150,6 +150,7 @@ extern unsigned int NOCOMMON __random_seed;
extern jmp_buf NOCOMMON __exit_jmp_buf;
extern int NOCOMMON __exit_value;
extern BOOL NOCOMMON __exit_blocked;
/****************************************************************************/
@ -188,6 +189,10 @@ extern int NOCOMMON __argc;
/****************************************************************************/
extern BOOL NOCOMMON __lib_startup;
/****************************************************************************/
#ifndef _STDLIB_PROTOS_H
#include "stdlib_protos.h"
#endif /* _STDLIB_PROTOS_H */

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_isresident.c,v 1.3 2005-03-18 12:38:24 obarthel Exp $
* $Id: stdlib_isresident.c,v 1.4 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,8 @@
/****************************************************************************/
BOOL __is_resident;
#include "macros.h"
/****************************************************************************/
BOOL NOCOMMON __is_resident;

234
library/stdlib_lib_main.c Executable file
View File

@ -0,0 +1,234 @@
/*
* $Id: stdlib_lib_main.c,v 1.1 2005-07-03 10:36:47 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.
*/
#if defined(__THREAD_SAFE)
/****************************************************************************/
#ifndef EXEC_EXECBASE_H
#include <exec/execbase.h>
#endif /* EXEC_EXECBASE_H */
/****************************************************************************/
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
/****************************************************************************/
#ifndef _STDLIB_HEADERS_H
#include "stdlib_headers.h"
#endif /* _STDLIB_HEADERS_H */
#ifndef _STDIO_HEADERS_H
#include "stdio_headers.h"
#endif /* _STDIO_HEADERS_H */
/****************************************************************************/
STATIC BOOL lib_init_successful;
/****************************************************************************/
STATIC BOOL
open_libraries(struct Library * sys_base)
{
BOOL success = FALSE;
int os_version;
SysBase = sys_base;
#if defined(__amigaos4__)
{
/* Get exec interface */
IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
}
#endif /* __amigaos4__ */
/* Check which minimum operating system version we actually require. */
os_version = 37;
if(__minimum_os_lib_version > 37)
os_version = __minimum_os_lib_version;
/* Open the minimum required libraries. */
DOSBase = (struct Library *)OpenLibrary("dos.library",os_version);
if(DOSBase == NULL)
goto out;
__UtilityBase = OpenLibrary("utility.library",os_version);
if(__UtilityBase == NULL)
goto out;
#if defined(__amigaos4__)
{
/* Obtain the interfaces for these libraries. */
IDOS = (struct DOSIFace *)GetInterface(DOSBase, "main", 1, 0);
if(IDOS == NULL)
goto out;
__IUtility = (struct UtilityIFace *)GetInterface(__UtilityBase, "main", 1, 0);
if(__IUtility == NULL)
goto out;
}
#endif /* __amigaos4__ */
success = TRUE;
out:
return(success);
}
/****************************************************************************/
STATIC VOID
close_libraries(VOID)
{
#if defined(__amigaos4__)
{
if(__IUtility != NULL)
{
DropInterface((struct Interface *)__IUtility);
__IUtility = NULL;
}
if(IDOS != NULL)
{
DropInterface((struct Interface *)IDOS);
IDOS = NULL;
}
}
#endif /* __amigaos4__ */
if(__UtilityBase != NULL)
{
CloseLibrary(__UtilityBase);
__UtilityBase = NULL;
}
if(DOSBase != NULL)
{
CloseLibrary(DOSBase);
DOSBase = NULL;
}
}
/****************************************************************************/
VOID
__lib_exit(VOID)
{
ENTER();
if(lib_init_successful)
{
/* Enable exit() again. */
__exit_blocked = FALSE;
/* 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();
close_libraries();
lib_init_successful = FALSE;
}
LEAVE();
}
/****************************************************************************/
BOOL
__lib_init(struct Library * sys_base)
{
int result = FALSE;
ENTER();
/* Make sure that no requesters and such pop up if anything
goes wrong during initialization. */
__lib_startup = TRUE;
/* Open dos.library and utility.library. */
if(CANNOT open_libraries(sys_base))
goto out;
/* This plants the return buffer for _exit(). */
if(setjmp(__exit_jmp_buf) != 0)
{
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();
goto out;
}
SHOWMSG("now invoking the constructors");
/* Go through the constructor list */
_init();
/* Disable exit() and its kin. */
__exit_blocked = TRUE;
/* Remember this so that __lib_exit() will know what to do. */
lib_init_successful = TRUE;
result = TRUE;
out:
if(NOT lib_init_successful)
close_libraries();
RETURN(result);
return(result);
}
/****************************************************************************/
#endif /* __THREAD_SAFE */

View File

@ -0,0 +1,44 @@
/*
* $Id: stdlib_lib_startup.c,v 1.1 2005-07-03 10:36:47 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 EXEC_TYPES_H
#include <exec/types.h>
#endif /* EXEC_TYPES_H */
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
BOOL NOCOMMON __lib_startup;

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_machine_test.c,v 1.6 2005-03-20 17:14:58 obarthel Exp $
* $Id: stdlib_machine_test.c,v 1.7 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -43,6 +43,7 @@
/****************************************************************************/
/* ZZZ this function should be called somewhere, but where from? */
int
__machine_test(void)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_main.c,v 1.24 2005-04-24 14:04:36 obarthel Exp $
* $Id: stdlib_main.c,v 1.25 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -66,7 +66,7 @@ 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;
BOOL NOCOMMON __stack_overflow;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_malloc.c,v 1.12 2005-03-18 12:38:24 obarthel Exp $
* $Id: stdlib_malloc.c,v 1.13 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -43,6 +43,12 @@
/****************************************************************************/
#ifndef _STDLIB_CONSTRUCTOR_H
#include "stdlib_constructor.h"
#endif /* _STDLIB_CONSTRUCTOR_H */
/****************************************************************************/
#undef malloc
#undef __malloc
@ -50,21 +56,21 @@
#ifdef __MEM_DEBUG
unsigned long __maximum_memory_allocated;
unsigned long __current_memory_allocated;
unsigned long __maximum_num_memory_chunks_allocated;
unsigned long __current_num_memory_chunks_allocated;
unsigned long NOCOMMON __maximum_memory_allocated;
unsigned long NOCOMMON __current_memory_allocated;
unsigned long NOCOMMON __maximum_num_memory_chunks_allocated;
unsigned long NOCOMMON __current_num_memory_chunks_allocated;
#if defined(__USE_MEM_TREES)
struct MemoryTree __memory_tree;
struct MemoryTree NOCOMMON __memory_tree;
#endif /* __USE_MEM_TREES */
#endif /* __MEM_DEBUG */
/****************************************************************************/
APTR __memory_pool;
struct MinList __memory_list;
APTR NOCOMMON __memory_pool;
struct MinList NOCOMMON __memory_list;
/****************************************************************************/
@ -296,8 +302,7 @@ __memory_unlock(void)
/****************************************************************************/
void
__memory_exit(void)
STDLIB_DESTRUCTOR(stdlib_memory_exit)
{
ENTER();
@ -368,10 +373,9 @@ __memory_exit(void)
/****************************************************************************/
int
__memory_init(void)
STDLIB_CONSTRUCTOR(stdlib_memory_init)
{
int result = ERROR;
BOOL success = FALSE;
ENTER();
@ -402,10 +406,15 @@ __memory_init(void)
}
#endif /* __amigaos4__ */
result = OK;
success = TRUE;
out:
RETURN(result);
return(result);
SHOWVALUE(success);
LEAVE();
if(success)
CONSTRUCTOR_SUCCEED();
else
CONSTRUCTOR_FAIL();
}

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_init_exit.c,v 1.11 2005-03-18 12:38:24 obarthel Exp $
* $Id: stdlib_program_name.c,v 1.1 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -53,16 +53,14 @@ static BOOL free_program_name;
/****************************************************************************/
char * __program_name;
char * NOCOMMON __program_name;
/****************************************************************************/
STDLIB_DESTRUCTOR(stdlib_exit)
STDLIB_DESTRUCTOR(stdlib_program_name_exit)
{
ENTER();
__memory_exit();
if(free_program_name && __program_name != NULL)
{
FreeVec(__program_name);
@ -74,15 +72,12 @@ STDLIB_DESTRUCTOR(stdlib_exit)
/****************************************************************************/
STDLIB_CONSTRUCTOR(stdlib_init)
STDLIB_CONSTRUCTOR(stdlib_program_name_init)
{
BOOL success = FALSE;
ENTER();
if(__machine_test() < 0)
goto out;
if(__WBenchMsg == NULL)
{
const size_t program_name_size = 256;
@ -102,9 +97,6 @@ STDLIB_CONSTRUCTOR(stdlib_init)
__program_name = (char *)__WBenchMsg->sm_ArgList[0].wa_Name;
}
if(__memory_init() < 0)
goto out;
success = TRUE;
out:

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_protos.h,v 1.14 2005-03-20 11:18:06 obarthel Exp $
* $Id: stdlib_protos.h,v 1.15 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -134,8 +134,6 @@ extern int __arg_init(void);
/****************************************************************************/
/* stdlib_malloc.c */
extern int __memory_init(void);
extern void __memory_exit(void);
extern size_t __get_allocation_size(size_t size);
extern void * __allocate_memory(size_t size,BOOL never_free,const char * file,int line);

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_rand.c,v 1.4 2005-02-27 18:09:11 obarthel Exp $
* $Id: stdlib_rand.c,v 1.5 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,7 +37,7 @@
/****************************************************************************/
unsigned int __random_seed = 1;
unsigned int NOCOMMON __random_seed = 1;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_shell_escape.c,v 1.3 2005-03-18 12:38:25 obarthel Exp $
* $Id: stdlib_shell_escape.c,v 1.4 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -43,12 +43,16 @@
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
/* Quick "hack" to help GCC compile itself */
#if defined(GCC_HELP_SUPPORT)
/******************************************************************************/
UBYTE __shell_escape_character = '\\';
UBYTE NOCOMMON __shell_escape_character = '\\';
/******************************************************************************/
@ -56,7 +60,7 @@ UBYTE __shell_escape_character = '\\';
/******************************************************************************/
UBYTE __shell_escape_character = '*';
UBYTE NOCOMMON __shell_escape_character = '*';
/******************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_showerror.c,v 1.11 2005-03-18 12:38:25 obarthel Exp $
* $Id: stdlib_showerror.c,v 1.12 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -135,11 +135,20 @@ __show_error(const char * message)
struct DOSIFace * IDOS = NULL;
#endif /* __amigaos4__ */
struct Library * IntuitionBase;
struct Library * DOSBase;
struct Library * IntuitionBase = NULL;
struct Library * DOSBase = NULL;
PROFILE_OFF();
/* Don't show anything if this is the thread-safe library and
we were invoked indirectly by shared library startup code. */
#if defined(__THREAD_SAFE)
{
if(__lib_startup)
goto out;
}
#endif /* __THREAD_SAFE */
DOSBase = OpenLibrary("dos.library",0);
IntuitionBase = OpenLibrary("intuition.library",0);

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_stackcheck.c,v 1.8 2005-03-18 12:38:25 obarthel Exp $
* $Id: stdlib_stackcheck.c,v 1.9 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -105,7 +105,7 @@ overflow: \n\
/****************************************************************************/
UBYTE * __stk_limit;
UBYTE * NOCOMMON __stk_limit;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_stackextension.c,v 1.11 2005-03-18 12:38:25 obarthel Exp $
* $Id: stdlib_stackextension.c,v 1.12 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -77,8 +77,8 @@ 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 */
ULONG NOCOMMON __stk_extensions; /* number of stack extensions performed */
ULONG NOCOMMON __stk_maxsize; /* maximum amount of memory allocated for stack extension */
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_stacksize.c,v 1.3 2005-02-25 10:14:21 obarthel Exp $
* $Id: stdlib_stacksize.c,v 1.4 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,6 +37,10 @@
/****************************************************************************/
#include "macros.h"
/****************************************************************************/
/* Quick "hack" to help GCC compile itself */
#if defined(GCC_HELP_SUPPORT)
@ -73,7 +77,7 @@ unsigned int __stack_size = 200000;
/******************************************************************************/
unsigned int __stack_size;
unsigned int NOCOMMON __stack_size;
/******************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_sysbase.c,v 1.3 2005-03-18 12:38:25 obarthel Exp $
* $Id: stdlib_sysbase.c,v 1.4 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -39,12 +39,16 @@
/****************************************************************************/
struct ExecBase * SysBase;
#include "macros.h"
/****************************************************************************/
struct ExecBase * NOCOMMON SysBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct ExecIFace * IExec;
struct ExecIFace * NOCOMMON IExec;
#endif /* __amigaos4__ */

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_utilitybase.c,v 1.1 2005-03-30 19:37:47 obarthel Exp $
* $Id: stdlib_utilitybase.c,v 1.2 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -39,12 +39,16 @@
/****************************************************************************/
struct Library * __UtilityBase;
#include "macros.h"
/****************************************************************************/
struct Library * NOCOMMON __UtilityBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct UtilityIFace * __IUtility;
struct UtilityIFace * NOCOMMON __IUtility;
#endif /* __amigaos4__ */

View File

@ -1,5 +1,5 @@
/*
* $Id: time_data.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
* $Id: time_data.c,v 1.4 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,7 +37,7 @@
/****************************************************************************/
const char * const __abbreviated_week_day_names[7] =
const char * const NOCOMMON __abbreviated_week_day_names[7] =
{
"Sun",
"Mon",
@ -48,7 +48,7 @@ const char * const __abbreviated_week_day_names[7] =
"Sat"
};
const char * const __week_day_names[7] =
const char * const NOCOMMON __week_day_names[7] =
{
"Sunday",
"Monday",
@ -59,7 +59,7 @@ const char * const __week_day_names[7] =
"Saturday"
};
const char * const __abbreviated_month_names[12] =
const char * const NOCOMMON __abbreviated_month_names[12] =
{
"Jan",
"Feb",
@ -75,7 +75,7 @@ const char * const __abbreviated_month_names[12] =
"Dec"
};
const char * const __month_names[12] =
const char * const NOCOMMON __month_names[12] =
{
"January",
"February",

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_chdir_exit.c,v 1.5 2005-03-18 12:38:25 obarthel Exp $
* $Id: unistd_chdir_exit.c,v 1.6 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -49,9 +49,9 @@
/* If the program's current directory was changed, here is where
we find out about it. */
BPTR __original_current_directory;
BOOL __current_directory_changed;
BOOL __unlock_current_directory;
BPTR NOCOMMON __original_current_directory;
BOOL NOCOMMON __current_directory_changed;
BOOL NOCOMMON __unlock_current_directory;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_currentpathname.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
* $Id: unistd_currentpathname.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,4 @@
/****************************************************************************/
char __current_path_name[MAXPATHLEN];
char NOCOMMON __current_path_name[MAXPATHLEN];

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_init_exit.c,v 1.11 2005-03-18 12:38:25 obarthel Exp $
* $Id: unistd_init_exit.c,v 1.12 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -44,7 +44,7 @@
/****************************************************************************/
/* Names of files and directories to delete when shutting down. */
struct MinList __unlink_list;
struct MinList NOCOMMON __unlink_list;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_timer.c,v 1.7 2005-03-18 12:38:25 obarthel Exp $
* $Id: unistd_timer.c,v 1.8 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -52,15 +52,15 @@
/****************************************************************************/
/* Local timer I/O. */
struct MsgPort * __timer_port;
struct timerequest * __timer_request;
BOOL __timer_busy;
struct Library * __TimerBase;
struct MsgPort * NOCOMMON __timer_port;
struct timerequest * NOCOMMON __timer_request;
BOOL NOCOMMON __timer_busy;
struct Library * NOCOMMON __TimerBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct TimerIFace * __ITimer;
struct TimerIFace * NOCOMMON __ITimer;
#endif /* __amigaos4__ */
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_unix_path_semantics.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
* $Id: unistd_unix_path_semantics.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -37,4 +37,4 @@
/****************************************************************************/
BOOL __unix_path_semantics = TRUE;
BOOL NOCOMMON __unix_path_semantics = TRUE;

View File

@ -1,5 +1,5 @@
/*
* $Id: usergroup_data.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $
* $Id: usergroup_data.c,v 1.4 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -41,10 +41,10 @@
/****************************************************************************/
int __root_uid;
int __root_gid;
int __root_euid;
int __root_egid;
int NOCOMMON __root_uid;
int NOCOMMON __root_gid;
int NOCOMMON __root_euid;
int NOCOMMON __root_egid;
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: usergroup_init_exit.c,v 1.10 2005-03-18 12:38:25 obarthel Exp $
* $Id: usergroup_init_exit.c,v 1.11 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -52,12 +52,12 @@
/****************************************************************************/
struct Library * __UserGroupBase;
struct Library * NOCOMMON __UserGroupBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct UserGroupIFace * __IUserGroup;
struct UserGroupIFace * NOCOMMON __IUserGroup;
#endif /* __amigaos4__ */
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: usergroup_rootmode.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $
* $Id: usergroup_rootmode.c,v 1.3 2005-07-03 10:36:47 obarthel Exp $
*
* :ts=4
*
@ -41,7 +41,7 @@
/****************************************************************************/
BOOL __root_mode;
BOOL NOCOMMON __root_mode;
/****************************************************************************/