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

- Moved the __UtilityBase/__IUtility variable declarations into

a separate file.

- Simplified the library/open close code in "stdlib_main.c".


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14908 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-03-30 19:37:47 +00:00
parent 9c2c44b008
commit 09b52e077f
12 changed files with 275 additions and 116 deletions

View File

@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.68k,v 1.46 2005-03-20 17:14:58 obarthel Exp $
# $Id: GNUmakefile.68k,v 1.47 2005-03-30 19:37:13 obarthel Exp $
#
# :ts=8
#
@ -346,6 +346,7 @@ C_LIB = \
stdlib_system.o \
stdlib_termination_message.o \
stdlib_threshold.o \
stdlib_utilitybase.o \
stdlib_udivsi3.o \
stdlib_udivsi4.o \
stdlib_umodsi3.o \

View File

@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.os4,v 1.48 2005-03-26 10:53:35 obarthel Exp $
# $Id: GNUmakefile.os4,v 1.49 2005-03-30 19:37:24 obarthel Exp $
#
# :ts=8
#
@ -345,6 +345,7 @@ C_LIB = \
stdlib_system.o \
stdlib_termination_message.o \
stdlib_threshold.o \
stdlib_utilitybase.o \
stdlib_udivsi3.o \
stdlib_udivsi4.o \
stdlib_umodsi3.o \

View File

@ -15,6 +15,11 @@
effect of printing a different termination message but otherwise
program flow takes the same path as abort().
- Moved the __UtilityBase/__IUtility variable declarations into
a separate file.
- Simplified the library/open close code in "stdlib_main.c".
c.lib 1.190 (25.3.2005)

View File

@ -1,5 +1,5 @@
/*
* $Id: ctype_headers.h,v 1.3 2005-03-18 12:38:22 obarthel Exp $
* $Id: ctype_headers.h,v 1.4 2005-03-30 19:37:26 obarthel Exp $
*
* :ts=4
*
@ -42,9 +42,13 @@
/****************************************************************************/
#ifndef _STDLIB_LOCALE_UTILITY_H
#include "stdlib_locale_utility.h"
#endif /* _STDLIB_LOCALE_UTILITY_H */
#ifndef _STDLIB_LOCALEBASE_H
#include "stdlib_localebase.h"
#endif /* _STDLIB_LOCALEBASE_H */
#ifndef _STDLIB_UTILITYBASE_H
#include "stdlib_utilitybase.h"
#endif /* _STDLIB_UTILITYBASE_H */
/****************************************************************************/

View File

@ -1,5 +1,5 @@
#
# $Id: smakefile,v 1.35 2005-03-19 11:06:57 obarthel Exp $
# $Id: smakefile,v 1.36 2005-03-30 19:37:26 obarthel Exp $
#
# :ts=8
#
@ -439,6 +439,7 @@ STDLIB_OBJ = \
stdlib_swapstack.o \
stdlib_system.o \
stdlib_unsetenv.o \
stdlib_utilitybase.o \
stdlib_wildcard_expand.o \
stdlib_stdio_window_spec.o

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_headers.h,v 1.16 2005-03-18 12:38:24 obarthel Exp $
* $Id: stdlib_headers.h,v 1.17 2005-03-30 19:37:27 obarthel Exp $
*
* :ts=4
*
@ -106,9 +106,13 @@
/****************************************************************************/
#ifndef _STDLIB_LOCALE_UTILITY_H
#include "stdlib_locale_utility.h"
#endif /* _STDLIB_LOCALE_UTILITY_H */
#ifndef _STDLIB_LOCALEBASE_H
#include "stdlib_localebase.h"
#endif /* _STDLIB_LOCALEBASE_H */
#ifndef _STDLIB_UTILITYBASE_H
#include "stdlib_utilitybase.h"
#endif /* _STDLIB_UTILITYBASE_H */
/****************************************************************************/

View File

@ -0,0 +1,88 @@
/*
* $Id: stdlib_localebase.h,v 1.1 2005-03-30 19:37: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_LOCALEBASE_H
#define _STDLIB_LOCALEBASE_H
/****************************************************************************/
#ifndef __NOLIBBASE__
#define __NOLIBBASE__
#endif /* __NOLIBBASE__ */
#ifndef __NOGLOBALIFACE__
#define __NOGLOBALIFACE__
#endif /* __NOGLOBALIFACE__ */
#include <proto/locale.h>
/****************************************************************************/
#ifndef _MACROS_H
#include "macros.h"
#endif /* _MACROS_H */
/****************************************************************************/
extern struct Library * NOCOMMON __LocaleBase;
/****************************************************************************/
#if defined(__amigaos4__)
/****************************************************************************/
extern struct LocaleIFace NOCOMMON * __ILocale;
/****************************************************************************/
#define DECLARE_LOCALEBASE() \
struct Library * UNUSED LocaleBase = __LocaleBase; \
struct LocaleIFace * ILocale = __ILocale
/****************************************************************************/
#else
/****************************************************************************/
#define DECLARE_LOCALEBASE() \
struct Library * LocaleBase = __LocaleBase
/****************************************************************************/
#endif /* __amigaos4__ */
/****************************************************************************/
#endif /* _STDLIB_LOCALEBASE_H */

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_main.c,v 1.20 2005-03-20 11:18:06 obarthel Exp $
* $Id: stdlib_main.c,v 1.21 2005-03-30 19:37:43 obarthel Exp $
*
* :ts=4
*
@ -147,18 +147,86 @@ call_main(void)
/****************************************************************************/
STATIC VOID ASM
detach_cleanup(REG(d0, LONG UNUSED unused_return_code),REG(d1, BPTR segment_list))
STATIC BOOL
open_libraries(VOID)
{
BOOL success = FALSE;
int os_version;
/* 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;
}
#else
}
#endif /* __amigaos4__ */
if(__UtilityBase != NULL)
{
CloseLibrary(__UtilityBase);
__UtilityBase = NULL;
}
if(DOSBase != NULL)
{
CloseLibrary(DOSBase);
DOSBase = NULL;
}
}
/****************************************************************************/
STATIC VOID ASM
detach_cleanup(REG(d0, LONG UNUSED unused_return_code),REG(d1, BPTR segment_list))
{
#if NOT defined(__amigaos4__)
{
/* The following trick is necessary only under dos.library V40 and below. */
if(((struct Library *)DOSBase)->lib_Version < 50)
@ -177,11 +245,7 @@ detach_cleanup(REG(d0, LONG UNUSED unused_return_code),REG(d1, BPTR segment_list
}
#endif /* __amigaos4__ */
if(__UtilityBase != NULL)
CloseLibrary(__UtilityBase);
if(DOSBase != NULL)
CloseLibrary(DOSBase);
close_libraries();
}
/****************************************************************************/
@ -204,17 +268,6 @@ 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)
{
@ -225,7 +278,6 @@ _main(void)
struct Process * this_process;
int return_code = RETURN_FAIL;
ULONG current_stack_size;
int os_version;
SysBase = *(struct Library **)4;
@ -254,43 +306,30 @@ _main(void)
__WBenchMsg = (struct WBStartup *)startup_message;
/* Check which minimum operating system version we actually require. */
os_version = 37;
if(__minimum_os_lib_version > 37)
os_version = __minimum_os_lib_version;
/* We will need dos.library V37 and utility.library V37. */
DOSBase = (struct Library *)OpenLibrary("dos.library",os_version);
__UtilityBase = OpenLibrary("utility.library",os_version);
if(DOSBase == NULL || __UtilityBase == NULL)
/* Try to open the libraries we need to proceed. */
if(CANNOT open_libraries())
{
char * error_message;
/* If available, use the error message provided by the client. */
if(__minimum_os_lib_error != NULL)
error_message = __minimum_os_lib_error;
else
#if defined(__amigaos4__)
{
if(error_message == NULL)
error_message = "This program requires AmigaOS 4.0 or higher.";
}
#else
{
if(error_message == NULL)
error_message = "This program requires AmigaOS 2.04 or higher.";
}
#endif /* __amigaos4__ */
__show_error(error_message);
goto out;
}
#if defined(__amigaos4__)
{
/* Get interfaces for DOS and Utility */
IDOS = (struct DOSIFace *)GetInterface(DOSBase, "main", 1, 0);
__IUtility = (struct UtilityIFace *)GetInterface(__UtilityBase, "main", 1, 0);
if (IDOS == NULL || __IUtility == NULL)
{
__show_error("This program requires AmigaOS 4.0 or higher.");
goto out;
}
}
#endif /* __amigaos4__ */
if(__disable_dos_requesters)
{
/* Don't display any requesters. */
@ -483,39 +522,7 @@ _main(void)
__set_process_window(old_window_pointer);
if(child_process == NULL)
{
#if defined(__amigaos4__)
{
if(__IUtility != NULL)
{
DropInterface((struct Interface *)__IUtility);
__IUtility = NULL;
}
}
#endif /* __amigaos4__ */
if(__UtilityBase != NULL)
{
CloseLibrary(__UtilityBase);
__UtilityBase = NULL;
}
#if defined(__amigaos4__)
{
if(IDOS != NULL)
{
DropInterface((struct Interface *)IDOS);
IDOS = NULL;
}
}
#endif /* __amigaos4__ */
if(DOSBase != NULL)
{
CloseLibrary(DOSBase);
DOSBase = NULL;
}
}
close_libraries();
if(startup_message != NULL)
{

View File

@ -0,0 +1,50 @@
/*
* $Id: stdlib_utilitybase.c,v 1.1 2005-03-30 19:37: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.
*/
#define __NOLIBBASE__
#ifndef PROTO_UTILITY_H
#include <proto/utility.h>
#endif /* PROTO_UTILITY_H */
/****************************************************************************/
struct Library * __UtilityBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct UtilityIFace * __IUtility;
#endif /* __amigaos4__ */

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_locale_utility.h,v 1.3 2005-01-02 09:07:18 obarthel Exp $
* $Id: stdlib_utilitybase.h,v 1.1 2005-03-30 19:37:47 obarthel Exp $
*
* :ts=4
*
@ -31,8 +31,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _STDLIB_LOCALE_UTILITY_H
#define _STDLIB_LOCALE_UTILITY_H
#ifndef _STDLIB_UTILITYBASE_H
#define _STDLIB_UTILITYBASE_H
/****************************************************************************/
@ -45,7 +45,6 @@
#endif /* __NOGLOBALIFACE__ */
#include <proto/utility.h>
#include <proto/locale.h>
/****************************************************************************/
@ -56,7 +55,6 @@
/****************************************************************************/
extern struct Library * NOCOMMON __UtilityBase;
extern struct Library * NOCOMMON __LocaleBase;
/****************************************************************************/
@ -65,7 +63,6 @@ extern struct Library * NOCOMMON __LocaleBase;
/****************************************************************************/
extern struct UtilityIFace NOCOMMON * __IUtility;
extern struct LocaleIFace NOCOMMON * __ILocale;
/****************************************************************************/
@ -73,10 +70,6 @@ extern struct LocaleIFace NOCOMMON * __ILocale;
struct Library * UNUSED UtilityBase = __UtilityBase; \
struct UtilityIFace * IUtility = __IUtility
#define DECLARE_LOCALEBASE() \
struct Library * UNUSED LocaleBase = __LocaleBase; \
struct LocaleIFace * ILocale = __ILocale
/****************************************************************************/
#else
@ -86,13 +79,10 @@ extern struct LocaleIFace NOCOMMON * __ILocale;
#define DECLARE_UTILITYBASE() \
struct Library * UtilityBase = __UtilityBase
#define DECLARE_LOCALEBASE() \
struct Library * LocaleBase = __LocaleBase
/****************************************************************************/
#endif /* __amigaos4__ */
/****************************************************************************/
#endif /* _STDLIB_LOCALE_UTILITY_H */
#endif /* _STDLIB_UTILITYBASE_H */

View File

@ -1,5 +1,5 @@
/*
* $Id: string_headers.h,v 1.5 2005-03-18 12:38:25 obarthel Exp $
* $Id: string_headers.h,v 1.6 2005-03-30 19:37:47 obarthel Exp $
*
* :ts=4
*
@ -46,9 +46,13 @@
/****************************************************************************/
#ifndef _STDLIB_LOCALE_UTILITY_H
#include "stdlib_locale_utility.h"
#endif /* _STDLIB_LOCALE_UTILITY_H */
#ifndef _STDLIB_LOCALEBASE_H
#include "stdlib_localebase.h"
#endif /* _STDLIB_LOCALEBASE_H */
#ifndef _STDLIB_UTILITYBASE_H
#include "stdlib_utilitybase.h"
#endif /* _STDLIB_UTILITYBASE_H */
/****************************************************************************/

View File

@ -1,5 +1,5 @@
/*
* $Id: time_headers.h,v 1.10 2005-03-18 12:38:25 obarthel Exp $
* $Id: time_headers.h,v 1.11 2005-03-30 19:37:47 obarthel Exp $
*
* :ts=4
*
@ -90,9 +90,13 @@
/****************************************************************************/
#ifndef _STDLIB_LOCALE_UTILITY_H
#include "stdlib_locale_utility.h"
#endif /* _STDLIB_LOCALE_UTILITY_H */
#ifndef _STDLIB_LOCALEBASE_H
#include "stdlib_localebase.h"
#endif /* _STDLIB_LOCALEBASE_H */
#ifndef _STDLIB_UTILITYBASE_H
#include "stdlib_utilitybase.h"
#endif /* _STDLIB_UTILITYBASE_H */
/****************************************************************************/