-amiga/stdlib.c
amiga/launch.c
amiga/expat_68k.c
amiga/expat_68k.h
amiga/expat_68k_handler_stubs.c
+amiga/expat_base.h
amiga/expat_vectors.c
amiga/expat_lib.c
amiga/expat.xml
#############################################################################
-libs/expat.library: libs/expat_lib.o libs/expat_68k.o libs/expat_68k_handler_stubs.o libs/expat_vectors.o libs/stdlib.o newlib/libexpat.a
- $(CC) -mcrt=newlib -nostartfiles -nostdlib $^ -o $@ newlib/libexpat.a
+libs/expat.library: libs/expat_lib.o libs/expat_68k.o libs/expat_68k_handler_stubs.o libs/expat_vectors.o newlib/libexpat.a
+ $(CC) -mcrt=newlib -nostartfiles $^ -o $@ newlib/libexpat.a -Wl,--cref,-M,-Map=$@.map
protect $@ -e
+ $(STRIP) $(STRIPFLAGS) $@
-libs/expat_lib.o: expat_lib.c
+libs/expat_lib.o: expat_lib.c expat_base.h
-libs/expat_68k.o: expat_68k.c expat_68k.h
+libs/expat_68k.o: expat_68k.c expat_68k.h expat_base.h
libs/expat_68k_handler_stubs.o: expat_68k_handler_stubs.c expat_68k.h
libs/expat_vectors.o: expat_vectors.c
-libs/stdlib.o: stdlib.c
-
libs/launch.o: launch.c
#############################################################################
HISTORY
=======
+53.1 - bumped version to match AmigaOS streaming
+ - modified to remove all global variables (except INewLib)
+ - removed replacements for malloc(), etc. which are now
+ handled by the respective C library
+ - compiled with the latest binutils which bumps the
+ AMIGAOS_DYNVERSION to 2 for the libexpat.so target
+ - now strips the expat.library binary
+
5.2 - fixed XML_Parse 68k stub which enables xmlviewer to work
without crashing
- added some new functions to the 68k jump table available
*/
/*
-** This file was originally automatically generated by fdtrans.
+** Note: This file was originally automatically generated by fdtrans.
*/
#ifdef __USE_INLINE__
#include <proto/exec.h>
#include <interfaces/expat.h>
#include "expat_68k.h"
+#include "expat_base.h"
STATIC ULONG stub_OpenPPC(ULONG *regarray)
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((ULONG)Base + Base->lib_PosSize);
struct ExpatIFace *Self = (struct ExpatIFace *) ExtLib->MainIFace;
+ struct ExecIFace *IExec = ((struct ExpatBase *)Self->Data.LibBase)->IExec;
M68kXML_Parser p;
p = IExec->AllocVec(sizeof(*p), MEMF_SHARED|MEMF_CLEAR);
if (p) {
p->p = Self->XML_ParserCreate((const XML_Char *)regarray[8]);
if (p->p) {
+ p->IExec = IExec;
Self->XML_SetUserData(p->p, p);
return p;
}
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((ULONG)Base + Base->lib_PosSize);
struct ExpatIFace *Self = (struct ExpatIFace *) ExtLib->MainIFace;
+ struct ExecIFace *IExec = ((struct ExpatBase *)Self->Data.LibBase)->IExec;
M68kXML_Parser p;
p = IExec->AllocVec(sizeof(*p), MEMF_SHARED|MEMF_CLEAR);
if (p) {
p->p = Self->XML_ParserCreateNS((const XML_Char *)regarray[8], (XML_Char)regarray[0]);
if (p->p) {
+ p->IExec = IExec;
Self->XML_SetUserData(p->p, p);
return p;
}
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((ULONG)Base + Base->lib_PosSize);
struct ExpatIFace *Self = (struct ExpatIFace *) ExtLib->MainIFace;
+ struct ExecIFace *IExec = ((struct ExpatBase *)Self->Data.LibBase)->IExec;
M68kXML_Parser p;
p = IExec->AllocVec(sizeof(*p), MEMF_SHARED|MEMF_CLEAR);
(const XML_Memory_Handling_Suite *)regarray[9],
(const XML_Char *)regarray[10]);
if (p->p) {
+ p->IExec = IExec;
Self->XML_SetUserData(p->p, p);
return p;
}
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((ULONG)Base + Base->lib_PosSize);
struct ExpatIFace *Self = (struct ExpatIFace *) ExtLib->MainIFace;
+ struct ExecIFace *IExec = ((struct ExpatBase *)Self->Data.LibBase)->IExec;
M68kXML_Parser p;
p = IExec->AllocVec(sizeof(*p), MEMF_SHARED|MEMF_CLEAR);
p->p = Self->XML_ExternalEntityParserCreate((XML_Parser)regarray[8],
(const XML_Char *)regarray[9], (const XML_Char *)regarray[10]);
if (p->p) {
+ p->IExec = IExec;
Self->XML_SetUserData(p->p, p);
return p;
}
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((ULONG)Base + Base->lib_PosSize);
struct ExpatIFace *Self = (struct ExpatIFace *) ExtLib->MainIFace;
+ struct ExecIFace *IExec = ((struct ExpatBase *)Self->Data.LibBase)->IExec;
M68kXML_Parser p = (M68kXML_Parser)regarray[8];
if (p) {
+/*
+** Copyright (c) 2001-2009 Expat maintainers.
+**
+** Permission is hereby granted, free of charge, to any person obtaining
+** a copy of this software and associated documentation files (the
+** "Software"), to deal in the Software without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Software, and to
+** permit persons to whom the Software is furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
#ifndef EXPAT_68K_H
#define EXPAT_68K_H
typedef struct M68kXML_ParserStruct {
XML_Parser p;
+ struct ExecIFace *IExec;
void *handlerarg;
void *extenthandlerarg;
void *enchandlerarg;
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#ifdef __USE_INLINE__
+#undef __USE_INLINE__
+#endif
+
#include "expat_68k.h"
#include <exec/emulation.h>
#include <proto/exec.h>
#include <stdarg.h>
-static uint32 VARARGS68K call_68k_code (void *code, int num_args, ...) {
+static uint32 VARARGS68K call_68k_code (struct ExecIFace *IExec, void *code, int num_args, ...) {
uint32 res = 0;
va_list vargs;
va_startlinear(vargs, num_args);
uint32 *args = va_getlinearva(vargs, uint32 *);
- uint8 *stack = AllocVec(4096, MEMF_SHARED);
+ uint8 *stack = IExec->AllocVec(4096, MEMF_SHARED);
if (stack) {
uint32 *sp = (uint32 *)(stack + 4096);
args += num_args;
*--sp = *--args;
}
- res = EmulateTags(code, ET_StackPtr, sp, TAG_END);
- FreeVec(stack);
+ res = IExec->EmulateTags(code, ET_StackPtr, sp, TAG_END);
+ IExec->FreeVec(stack);
}
va_end(vargs);
void _68k_startelementhandler(void *userdata, const char *name, const char **attrs) {
M68kXML_Parser p = userdata;
- call_68k_code(p->startelementhandler, 3, p->handlerarg, name, attrs);
+ call_68k_code(p->IExec, p->startelementhandler, 3, p->handlerarg, name, attrs);
}
void _68k_endelementhandler(void *userdata, const char *name) {
M68kXML_Parser p = userdata;
- call_68k_code(p->endelementhandler, 2, p->handlerarg, name);
+ call_68k_code(p->IExec, p->endelementhandler, 2, p->handlerarg, name);
}
void _68k_chardatahandler(void *userdata, const char *s, int len) {
M68kXML_Parser p = userdata;
- call_68k_code(p->chardatahandler, 3, p->handlerarg, s, len);
+ call_68k_code(p->IExec, p->chardatahandler, 3, p->handlerarg, s, len);
}
void _68k_procinsthandler(void *userdata, const char *target, const char *data) {
M68kXML_Parser p = userdata;
- call_68k_code(p->procinsthandler, 3, p->handlerarg, target, data);
+ call_68k_code(p->IExec, p->procinsthandler, 3, p->handlerarg, target, data);
}
void _68k_commenthandler(void *userdata, const char *data) {
M68kXML_Parser p = userdata;
- call_68k_code(p->commenthandler, 2, p->handlerarg, data);
+ call_68k_code(p->IExec, p->commenthandler, 2, p->handlerarg, data);
}
void _68k_startcdatahandler(void *userdata) {
M68kXML_Parser p = userdata;
- call_68k_code(p->startcdatahandler, 1, p->handlerarg);
+ call_68k_code(p->IExec, p->startcdatahandler, 1, p->handlerarg);
}
void _68k_endcdatahandler(void *userdata) {
M68kXML_Parser p = userdata;
- call_68k_code(p->endcdatahandler, 1, p->handlerarg);
+ call_68k_code(p->IExec, p->endcdatahandler, 1, p->handlerarg);
}
void _68k_defaulthandler(void *userdata, const char *s, int len) {
M68kXML_Parser p = userdata;
- call_68k_code(p->defaulthandler, 3, p->handlerarg, s, len);
+ call_68k_code(p->IExec, p->defaulthandler, 3, p->handlerarg, s, len);
}
void _68k_defaulthandlerexp(void *userdata, const char *s, int len) {
M68kXML_Parser p = userdata;
- call_68k_code(p->defaulthandlerexp, 3, p->handlerarg, s, len);
+ call_68k_code(p->IExec, p->defaulthandlerexp, 3, p->handlerarg, s, len);
}
int _68k_extentrefhandler(XML_Parser parser, const char *context, const char *base,
{
M68kXML_Parser p = XML_GetUserData(parser);
void *arg = p->extenthandlerarg;
- return (int)call_68k_code(p->extentrefhandler, 5, arg ? arg : p, context, base, sysid, pubid);
+ return (int)call_68k_code(p->IExec, p->extentrefhandler, 5, arg ? arg : p, context, base, sysid, pubid);
}
int _68k_unknownenchandler(void *enchandlerdata, const char *name, XML_Encoding *info) {
M68kXML_Parser p = enchandlerdata;
- return (int)call_68k_code(p->unknownenchandler, 3, p->enchandlerarg, name, info);
+ return (int)call_68k_code(p->IExec, p->unknownenchandler, 3, p->enchandlerarg, name, info);
}
void _68k_startnamespacehandler(void *userdata, const char *prefix, const char *uri) {
M68kXML_Parser p = userdata;
- call_68k_code(p->startnamespacehandler, 3, p->handlerarg, prefix, uri);
+ call_68k_code(p->IExec, p->startnamespacehandler, 3, p->handlerarg, prefix, uri);
}
void _68k_endnamespacehandler(void *userdata, const char *prefix) {
M68kXML_Parser p = userdata;
- call_68k_code(p->endnamespacehandler, 2, p->handlerarg, prefix);
+ call_68k_code(p->IExec, p->endnamespacehandler, 2, p->handlerarg, prefix);
}
void _68k_xmldeclhandler(void *userdata, const char *version, const char *encoding, int standalone) {
M68kXML_Parser p = userdata;
- call_68k_code(p->xmldeclhandler, 4, p->handlerarg, version, encoding, standalone);
+ call_68k_code(p->IExec, p->xmldeclhandler, 4, p->handlerarg, version, encoding, standalone);
}
void _68k_startdoctypehandler(void *userdata, const char *doctypename,
const char *sysid, const char *pubid, int has_internal_subset)
{
M68kXML_Parser p = userdata;
- call_68k_code(p->startdoctypehandler, 5, p->handlerarg, doctypename, sysid, pubid, has_internal_subset);
+ call_68k_code(p->IExec, p->startdoctypehandler, 5, p->handlerarg, doctypename, sysid, pubid, has_internal_subset);
}
void _68k_enddoctypehandler(void *userdata) {
M68kXML_Parser p = userdata;
- call_68k_code(p->enddoctypehandler, 1, p->handlerarg);
+ call_68k_code(p->IExec, p->enddoctypehandler, 1, p->handlerarg);
}
void _68k_elementdeclhandler(void *userdata, const char *name, XML_Content *model) {
M68kXML_Parser p = userdata;
- call_68k_code(p->elementdeclhandler, 3, p->handlerarg, name, model);
+ call_68k_code(p->IExec, p->elementdeclhandler, 3, p->handlerarg, name, model);
}
void _68k_attlistdeclhandler(void *userdata, const char *elname, const char *attname,
const char *att_type, const char *dflt, int isrequired)
{
M68kXML_Parser p = userdata;
- call_68k_code(p->attlistdeclhandler, 6, p->handlerarg, elname, attname, att_type, dflt, isrequired);
+ call_68k_code(p->IExec, p->attlistdeclhandler, 6, p->handlerarg, elname, attname, att_type, dflt, isrequired);
}
void _68k_entitydeclhandler(void *userdata, const char *entityname, int is_param_entity,
const char *notationname)
{
M68kXML_Parser p = userdata;
- call_68k_code(p->entitydeclhandler, 9, p->handlerarg, entityname, is_param_entity,
+ call_68k_code(p->IExec, p->entitydeclhandler, 9, p->handlerarg, entityname, is_param_entity,
value, value_length, base, sysid, pubid, notationname);
}
const char *sysid, const char *pubid, const char *notationname)
{
M68kXML_Parser p = userdata;
- call_68k_code(p->unparseddeclhandler, 6, p->handlerarg, entityname, base, sysid, pubid, notationname);
+ call_68k_code(p->IExec, p->unparseddeclhandler, 6, p->handlerarg, entityname, base, sysid, pubid, notationname);
}
void _68k_notationdeclhandler(void *userdata, const char *notationname, const char *base,
const char *sysid, const char *pubid)
{
M68kXML_Parser p = userdata;
- call_68k_code(p->notationdeclhandler, 5, p->handlerarg, notationname, base, sysid, pubid);
+ call_68k_code(p->IExec, p->notationdeclhandler, 5, p->handlerarg, notationname, base, sysid, pubid);
}
int _68k_notstandalonehandler(void *userdata) {
M68kXML_Parser p = userdata;
- return (int)call_68k_code(p->notstandalonehandler, 1, p->handlerarg);
+ return (int)call_68k_code(p->IExec, p->notstandalonehandler, 1, p->handlerarg);
}
void _68k_skippedentityhandler(void *userdata, const char *entityname, int is_param_entity) {
M68kXML_Parser p = userdata;
- call_68k_code(p->skippedentityhandler, 3, p->handlerarg, entityname, is_param_entity);
+ call_68k_code(p->IExec, p->skippedentityhandler, 3, p->handlerarg, entityname, is_param_entity);
}
--- /dev/null
+/*
+** Copyright (c) 2001-2009 Expat maintainers.
+**
+** Permission is hereby granted, free of charge, to any person obtaining
+** a copy of this software and associated documentation files (the
+** "Software"), to deal in the Software without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Software, and to
+** permit persons to whom the Software is furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef EXPAT_BASE_H
+#define EXPAT_BASE_H
+
+#include <exec/libraries.h>
+#include <dos/dos.h>
+#include <interfaces/exec.h>
+#include <interfaces/utility.h>
+
+
+struct ExpatBase {
+ struct Library libNode;
+ uint16 pad;
+ BPTR SegList;
+ struct ExecIFace *IExec;
+};
+
+#endif
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#ifdef __USE_INLINE__
+#undef __USE_INLINE__
+#endif
+
+#define __NOLIBBASE__
+#define __NOGLOBALIFACE__
+
#include <dos/dos.h>
#include <proto/exec.h>
+#include "expat_base.h"
+
+
#define LIBNAME "expat.library"
#define LIBPRI 0
-#define VERSION 5
-#define REVISION 2
-#define VSTRING "expat.library 5.2 (9.2.2009)" /* dd.mm.yyyy */
+#define VERSION 53
+#define REVISION 1
+#define VSTRING "expat.library 53.1 (7.8.2009)" /* dd.mm.yyyy */
static const char* __attribute__((used)) verstag = "\0$VER: " VSTRING;
-struct ExpatBase {
- struct Library libNode;
- uint16 pad;
- BPTR SegList;
-};
+struct Interface *INewlib = 0;
struct ExpatBase * libInit(struct ExpatBase *libBase, BPTR seglist, struct ExecIFace *ISys);
struct ExpatBase *libOpen (struct LibraryManagerInterface *Self, uint32 version);
BPTR libClose (struct LibraryManagerInterface *Self);
BPTR libExpunge (struct LibraryManagerInterface *Self);
+struct Interface *openInterface(struct ExecIFace *IExec, CONST_STRPTR libName, uint32 libVer);
+void closeInterface(struct ExecIFace *IExec, struct Interface *iface);
static APTR lib_manager_vectors[] = {
};
-struct Library *DOSLib = 0;
-struct Library *UtilityBase = 0;
-
-struct ExecIFace *IExec = 0;
-struct DOSIFace *IDOS = 0;
-struct UtilityIFace *IUtility = 0;
-
-
-void _start()
+int32 _start()
{
+ return RETURN_FAIL;
}
-struct ExpatBase *libInit(struct ExpatBase *libBase, BPTR seglist, struct ExecIFace *ISys)
+struct ExpatBase *libInit(struct ExpatBase *libBase, BPTR seglist, struct ExecIFace *iexec)
{
libBase->libNode.lib_Node.ln_Type = NT_LIBRARY;
libBase->libNode.lib_Node.ln_Pri = LIBPRI;
libBase->libNode.lib_Version = VERSION;
libBase->libNode.lib_Revision = REVISION;
libBase->libNode.lib_IdString = VSTRING;
+
libBase->SegList = seglist;
- IExec = ISys;
+ libBase->IExec = iexec;
+ INewlib = openInterface(iexec, "newlib.library", 0);
- DOSLib = OpenLibrary("dos.library", 51);
- if ( DOSLib != 0 ) {
- IDOS = (struct DOSIFace *)GetInterface(DOSLib, "main", 1, NULL);
- if ( IDOS != 0 ) {
- UtilityBase = OpenLibrary("utility.library", 51);
- if ( UtilityBase != 0 ) {
- IUtility = (struct UtilityIFace*)GetInterface(UtilityBase, "main", 1, NULL);
- if ( IUtility != 0 ) {
- return libBase;
- }
+ if ( INewlib != 0 ) {
+ return libBase;
+ }
- CloseLibrary(UtilityBase);
- }
+ closeInterface(iexec, INewlib);
+ INewlib = 0;
- DropInterface((struct Interface *)IDOS);
- }
-
- CloseLibrary(DOSLib);
- }
+ iexec->DeleteLibrary(&libBase->libNode);
return NULL;
}
return (BPTR)Self->LibExpunge();
}
else {
- return 0;
+ return ZERO;
}
}
BPTR libExpunge( struct LibraryManagerInterface *Self )
{
- struct ExpatBase *libBase;
- BPTR result = 0;
-
- libBase = (struct ExpatBase *)Self->Data.LibBase;
+ struct ExpatBase *libBase = (struct ExpatBase *)Self->Data.LibBase;
+ BPTR result = ZERO;
if (libBase->libNode.lib_OpenCnt == 0) {
- Remove(&libBase->libNode.lib_Node);
+ libBase->IExec->Remove(&libBase->libNode.lib_Node);
result = libBase->SegList;
- DropInterface((struct Interface *)IUtility);
- CloseLibrary(UtilityBase);
- DropInterface((struct Interface *)IDOS);
- CloseLibrary(DOSLib);
+ closeInterface(libBase->IExec, INewlib);
+ INewlib = 0;
- DeleteLibrary(&libBase->libNode);
+ libBase->IExec->DeleteLibrary(&libBase->libNode);
}
else {
libBase->libNode.lib_Flags |= LIBF_DELEXP;
return result;
}
+
+
+struct Interface *openInterface(struct ExecIFace *IExec, CONST_STRPTR libName, uint32 libVer)
+{
+ struct Library *base = IExec->OpenLibrary(libName, libVer);
+ struct Interface *iface = IExec->GetInterface(base, "main", 1, 0);
+ if (iface == 0) {
+ IExec->CloseLibrary(base);
+ }
+
+ return iface;
+}
+
+
+void closeInterface(struct ExecIFace *IExec, struct Interface *iface)
+{
+ if (iface != 0)
+ {
+ struct Library *base = iface->Data.LibBase;
+ IExec->DropInterface(iface);
+ IExec->CloseLibrary(base);
+ }
+}
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#ifdef __USE_INLINE__
+#undef __USE_INLINE__
+#endif
+
#include <stdlib.h>
#include <proto/exec.h>
void setup()
{
- ExpatBase = OpenLibrary("expat.library", 5);
- IExpat = (struct ExpatIFace*)GetInterface(ExpatBase, "main", 1, NULL);
+ ExpatBase = IExec->OpenLibrary("expat.library", 53);
+ IExpat = (struct ExpatIFace*)IExec->GetInterface(ExpatBase, "main", 1, NULL);
if ( IExpat == 0 ) {
- DebugPrintF("Can't open expat.library\n");
+ IExec->DebugPrintF("Can't open expat.library\n");
}
}
void cleanup()
{
- DropInterface((struct Interface*)IExpat);
+ IExec->DropInterface((struct Interface*)IExpat);
IExpat = 0;
- CloseLibrary(ExpatBase);
+ IExec->CloseLibrary(ExpatBase);
ExpatBase = 0;
}
+++ /dev/null
-/*
-** Copyright (c) 2001-2009 Expat maintainers.
-**
-** Permission is hereby granted, free of charge, to any person obtaining
-** a copy of this software and associated documentation files (the
-** "Software"), to deal in the Software without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Software, and to
-** permit persons to whom the Software is furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Software.
-**
-** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include <stdlib.h>
-#include <exec/memory.h>
-#include <proto/exec.h>
-#include <proto/utility.h>
-
-void * malloc (size_t len)
-{
- uint32 size = sizeof(uint32) + len;
-
- uint32 *mem = AllocMem(size, MEMF_SHARED);
- if ( mem != 0 ) {
- *mem = size;
- ++mem;
- }
-
- return mem;
-}
-
-
-void * realloc (void * mem, size_t len2)
-{
- if ( mem == 0 ) {
- return malloc(len2);
- }
-
- if ( len2 == 0 ) {
- free(mem);
- return 0;
- }
-
- void * new_mem = malloc(len2);
- if ( new_mem == 0 ) {
- return 0;
- }
-
- uint32 mem_size = *(((uint32*)mem) - 1);
- CopyMem(mem, new_mem, mem_size);
- free(mem);
-
- return new_mem;
-}
-
-
-void free (void * mem)
-{
- if ( mem != 0 ) {
- uint32 * size_ptr = ((uint32*)mem) - 1;
- FreeMem(size_ptr, *size_ptr);
- }
-}
-
-
-int memcmp (const void * a, const void * b, size_t len)
-{
- size_t i;
- int diff;
-
- for ( i = 0; i < len; ++i ) {
- diff = *((uint8 *)a++) - *((uint8 *)b++);
- if ( diff ) {
- return diff;
- }
- }
-
- return 0;
-}
-
-
-void * memcpy (void * t, const void * a, size_t len)
-{
- CopyMem((APTR)a, t, len);
- return t;
-}
-
-
-void * memmove (void * t1, const void * t2, size_t len)
-{
- MoveMem((APTR)t2, t1, len);
- return t1;
-}
-
-
-void * memset (void * t, int c, size_t len)
-{
- return SetMem(t, c, len);
-}