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

- Preparations for clib2 1.205

- Added support for ELF shared objects and libraries. This is implemented through
  constructor/destructor functions, which means that you can use this
  functionality even in Amiga Exec style shared libraries, with the proper
  library initialization code to invoke the constructor/destructor functions
  for you.

- Updated uname() to recognize AmigaOS 4.1.

- The translation from Unix to Amiga path names did not properly process
  multiple occurences of "/./" in the path name. Thanks go to Steven Solie
  for finding the issue.

- The detection of "/./" and "/../" patterns in Unix path names to be
  translated into Amiga path names did not test if it was overrunning
  the end of the string.

- If strcmp(), strncmp() and memcmp() detect a pair of different
  characters, then the function result must be calculated as if the
  characters were of type "unsigned char". This is a requirement
  according to the ISO 'C' (1994) standard. Thanks go to Georg Steger
  for finding the issue.

- The definitions for INT_MIN, INT_MAX and UINT_MAX in <limits.h> no
  longer use long integer types, as prompted by Steven Solie.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15204 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2010-08-20 15:33:36 +00:00
parent 60fbee698e
commit d10027ece7
10 changed files with 232 additions and 25 deletions

View File

@ -1,3 +1,29 @@
- Added support for ELF shared objects and libraries. This is implemented through
constructor/destructor functions, which means that you can use this
functionality even in Amiga Exec style shared libraries, with the proper
library initialization code to invoke the constructor/destructor functions
for you.
- Updated uname() to recognize AmigaOS 4.1.
- The translation from Unix to Amiga path names did not properly process
multiple occurences of "/./" in the path name. Thanks go to Steven Solie
for finding the issue.
- The detection of "/./" and "/../" patterns in Unix path names to be
translated into Amiga path names did not test if it was overrunning
the end of the string.
- If strcmp(), strncmp() and memcmp() detect a pair of different
characters, then the function result must be calculated as if the
characters were of type "unsigned char". This is a requirement
according to the ISO 'C' (1994) standard. Thanks go to Georg Steger
for finding the issue.
- The definitions for INT_MIN, INT_MAX and UINT_MAX in <limits.h> no
longer use long integer types, as prompted by Steven Solie.
c.lib 1.204 (11.11.2008)
- The memory allocated by malloc() and friends is now of type MEMF_PRIVATE

View File

@ -1,5 +1,5 @@
/*
* $Id: limits.h,v 1.11 2006-01-08 12:06:14 obarthel Exp $
* $Id: limits.h,v 1.12 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -78,9 +78,9 @@
/****************************************************************************/
#define INT_MIN (-2147483647L - 1)
#define INT_MAX 2147483647L
#define UINT_MAX 4294967295UL
#define INT_MIN (-2147483647 - 1)
#define INT_MAX 2147483647
#define UINT_MAX 4294967295U
/****************************************************************************/
@ -109,7 +109,7 @@
/****************************************************************************/
#define SSIZE_MAX 2147483647L
#define SSIZE_MAX LONG_MAX
/****************************************************************************/

View File

@ -1,5 +1,5 @@
#
# $Id: libc.gmk,v 1.4 2006-11-16 14:39:23 obarthel Exp $
# $Id: libc.gmk,v 1.5 2010-08-20 15:33:36 obarthel Exp $
#
# :ts=8
#
@ -248,6 +248,7 @@ C_LIB := \
stdlib_setjmp.o \
stdlib_set_errno.o \
stdlib_set_process_window.o \
stdlib_shared_libs.o \
stdlib_shell_escape.o \
stdlib_showerror.o \
stdlib_srand.o \

View File

@ -0,0 +1,150 @@
/*
* $Id: stdlib_shared_libs.c,v 1.1 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2010 by Olaf Barthel <olsen (at) 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(__amigaos4__)
/****************************************************************************/
/* The following is not part of the ISO 'C' (1994) standard. */
/****************************************************************************/
#ifndef _STDLIB_HEADERS_H
#include "stdlib_headers.h"
#endif /* _STDLIB_HEADERS_H */
/****************************************************************************/
#ifndef _STDLIB_CONSTRUCTOR_H
#include "stdlib_constructor.h"
#endif /* _STDLIB_CONSTRUCTOR_H */
/****************************************************************************/
#include <libraries/elf.h>
#include <proto/elf.h>
#include <proto/dos.h>
/****************************************************************************/
static VOID shared_libs_init_exit(BOOL init_or_exit)
{
struct Library * ElfBase;
struct Library * DOSBase = NULL;
struct ElfIFace * IElf = NULL;
struct DOSIFace * IDOS = NULL;
BPTR segment_list;
ENTER();
/* We need elf.library V52.2 or higher. */
ElfBase = OpenLibrary("elf.library",0);
if(ElfBase == NULL || (ElfBase->lib_Version < 52) || (ElfBase->lib_Version == 52 && ElfBase->lib_Revision < 2))
goto out;
IElf = (struct ElfIFace *)GetInterface(ElfBase,"main",1,NULL);
if(IElf == NULL)
goto out;
DOSBase = OpenLibrary("dos.library",0);
if(DOSBase == NULL)
goto out;
IDOS = (struct DOSIFace *)GetInterface(DOSBase,"main",1,NULL);
if(IDOS == NULL)
goto out;
/* Try to find the Elf handle associated with this
program's segment list. */
segment_list = GetProcSegList(NULL,GPSLF_CLI | GPSLF_SEG);
if(segment_list != ZERO)
{
Elf32_Handle elf_handle = NULL;
if(GetSegListInfoTags(segment_list,
GSLI_ElfHandle,&elf_handle,
TAG_DONE) == 1)
{
/* Initialize the shared object system. Note that
we have no way of finding out whether this actually
worked... */
if(elf_handle != NULL)
InitSHLibs(elf_handle,init_or_exit);
}
}
out:
if(IDOS != NULL)
DropInterface((struct Interface *)IDOS);
if(DOSBase != NULL)
CloseLibrary(DOSBase);
if(IElf != NULL)
DropInterface((struct Interface *)IElf);
if(ElfBase != NULL)
CloseLibrary(ElfBase);
LEAVE();
}
/****************************************************************************/
CLIB_DESTRUCTOR(shared_libs_exit)
{
ENTER();
shared_libs_init_exit(FALSE);
LEAVE();
}
/****************************************************************************/
CLIB_CONSTRUCTOR(shared_libs_init)
{
ENTER();
shared_libs_init_exit(TRUE);
LEAVE();
CONSTRUCTOR_SUCCEED();
}
/****************************************************************************/
#endif /* __amigaos4__ */

View File

@ -1,5 +1,5 @@
/*
* $Id: string_memcmp.c,v 1.7 2006-01-08 12:04:26 obarthel Exp $
* $Id: string_memcmp.c,v 1.8 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -135,7 +135,14 @@ __memcmp(const char *m1,const char *m2,size_t len)
{
if((*m1) != (*m2))
{
result = (*m1) - (*m2);
int b1,b2;
/* The comparison must be performed as if the
bytes were unsigned characters. */
b1 = *(unsigned char *)m1;
b2 = *(unsigned char *)m2;
result = b1 - b2;
break;
}
@ -185,7 +192,12 @@ memcmp(const void *ptr1, const void *ptr2, size_t len)
{
if((*m1) != (*m2))
{
result = (*m1) - (*m2);
int b1,b2;
b1 = *(unsigned char *)m1;
b2 = *(unsigned char *)m2;
result = b1 - b2;
break;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: string_strcmp.c,v 1.4 2006-01-08 12:04:27 obarthel Exp $
* $Id: string_strcmp.c,v 1.5 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -62,6 +62,8 @@ strcmp(const char *s1, const char * s2)
if(s1 != s2)
{
int c1,c2;
while((*s1) == (*s2))
{
if((*s1) == '\0')
@ -71,7 +73,12 @@ strcmp(const char *s1, const char * s2)
s2++;
}
result = (*s1) - (*s2);
/* The comparison must be performed as if the
characters were unsigned characters. */
c1 = *(unsigned char *)s1;
c2 = *(unsigned char *)s2;
result = c1 - c2;
}
out:

View File

@ -1,5 +1,5 @@
/*
* $Id: string_strncmp.c,v 1.4 2006-01-08 12:04:27 obarthel Exp $
* $Id: string_strncmp.c,v 1.5 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -78,7 +78,14 @@ strncmp(const char *s1, const char *s2, size_t n)
}
else
{
result = (*s1) - (*s2);
int c1,c2;
/* The comparison must be performed as if the
characters were unsigned characters. */
c1 = *(unsigned char *)s1;
c2 = *(unsigned char *)s2;
result = c1 - c2;
break;
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: systeminfo_sysinfo.c,v 1.5 2006-09-22 09:02:51 obarthel Exp $
* $Id: systeminfo_sysinfo.c,v 1.6 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -141,7 +141,7 @@ sysinfo(int cmd,char *buf,long buflen)
GetCPUInfoTags(GCIT_VectorUnit,&vecu,TAG_DONE);
if(vecu == VECTORTYPE_ALTIVEC || vecu == VECTORTYPE_VMX) /* AltiVec and VMX are the same. */
if(vecu == VECTORTYPE_ALTIVEC || vecu == 2 /* VECTORTYPE_VMX == 2 */) /* AltiVec and VMX are the same. */
s = "ppc+altivec ppc common";
else
s = "ppc common";

View File

@ -1,5 +1,5 @@
/*
* $Id: unistd_translateu2a.c,v 1.11 2006-10-03 16:36:47 obarthel Exp $
* $Id: unistd_translateu2a.c,v 1.12 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -50,6 +50,7 @@
* ././foo
* foo/./baz
* foo/./bar/./baz
* foo/./././bar
* foo/.
* /.
* /tmp
@ -260,7 +261,7 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
D(("name = '%s' (line %ld)",name,__LINE__));
}
/* Ditch all embedded '/./' ('foo/./bar' -> 'foo/bar'). */
/* Ditch all embedded '/./' ('foo/./bar' -> 'foo/bar', 'foo/././bar' -> 'foo/bar'). */
if(len > 2)
{
BOOL have_slash_dot_slash = FALSE;
@ -278,10 +279,11 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
{
for(i = j = 0 ; i < len ; i++)
{
replace[j++] = name[i];
if(name[i] == '/' && name[i + 1] == '.' && name[i + 2] == '/')
while(i < len - 2 && name[i] == '/' && name[i + 1] == '.' && name[i + 2] == '/')
i += 2;
if(i < len)
replace[j++] = name[i];
}
len = j;
@ -474,10 +476,10 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati
{
for(i = j = 0 ; i < len ; i++)
{
replace[j++] = name[i];
if(name[i] == '/' && name[i + 1] == '.' && name[i + 2] == '.' && name[i + 3] == '/')
if(i < len - 3 && name[i] == '/' && name[i + 1] == '.' && name[i + 2] == '.' && name[i + 3] == '/')
i += 2;
replace[j++] = name[i];
}
len = j;

View File

@ -1,5 +1,5 @@
/*
* $Id: utsname_uname.c,v 1.7 2006-11-13 09:25:28 obarthel Exp $
* $Id: utsname_uname.c,v 1.8 2010-08-20 15:33:36 obarthel Exp $
*
* :ts=4
*
@ -135,7 +135,9 @@ uname(struct utsname *info)
* 45.3 3.9-BB2
*/
if (46 <= Version && Version <= 52)
if (Version == 53)
version_string = "4.1";
else if (46 <= Version && Version <= 52)
version_string = "4.0";
else if (Version == 45)
version_string = "3.9";