This commit was generated by cvs2svn to compensate for changes in r3, which

included commits to RCS files with non-trunk default branches.
This commit is contained in:
jshepher
2004-09-09 22:09:30 +00:00
327 changed files with 13279 additions and 0 deletions
+187
View File
@@ -0,0 +1,187 @@
# Build all models of the libnix libraries.
#
# CFLAGS=-Wall -O3
#
# -fbaserel -DSMALL_DATA for small data model
# -fbaserel32 for large baserel model
# -m68020 for 68020 specific code
# -m68060 for 68060 specific code
# -m68881 for 68881 specific code (FPU)
# -DIXPATHS for Un*x path option
# -DDEBUG_LIB build a library for debugging (not yet fully working)
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
# Common prefix for machine-independent installed files.
prefix = @prefix@
# Common prefix for machine-dependent installed files.
exec_prefix = @exec_prefix@
libdir = $(exec_prefix)/lib
infodir = $(exec_prefix)/info
guidedir = $(exec_prefix)/guide
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
CPP = @CPP@
AS = as
RANLIB = @RANLIB@
#### End system configuration section ####
V=VER: libnix 1.2 (14.7.98)
CURDIR := $(shell pwd)
MAKE=make -f $(CURDIR)/sources/Makefile
SUBDIRS=startup lib libb lib020 libb020 lib881 libb881#lib060 libb060 libb32 libb32881
all: libnix.guide libnix.info $(SUBDIRS)
cd sources; make filelists
cd startup; make -f $(CURDIR)/sources/startup/Makefile V="$(V)"
cd lib; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer"
cd libb; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA"
cd lib020; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -m68020"
cd libb020; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA -m68020"
cd lib881; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -m68020 -m68881"
cd libb881; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA -m68020 -m68881"
# cd lib060; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -m68060 -m68881"
# cd libb060; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel -DSMALL_DATA -m68060 -m68881"
# cd libb32; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel32 -DSMALL_DATA -m68020"
# cd libb32881; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -fbaserel32 -DSMALL_DATA -m68020 -m68881"
# cd libix; $(MAKE) V="$(V)" CFLAGS="-Wall -O3 -fomit-frame-pointer -DIXPATHS"
$(SUBDIRS):
mkdir $@
libamiga:
if [ ! -d lib ] ; then mkdir lib ; else true ; fi
if [ ! -d libb ] ; then mkdir libb ; else true ; fi
if [ ! -d libb32 ] ; then mkdir libb32 ; else true ; fi
cd sources; make filelists
cd lib; $(MAKE) libamiga CFLAGS="-O3 -fomit-frame-pointer"
cd libb; $(MAKE) libamiga CFLAGS="-O3 -fomit-frame-pointer -fbaserel"
cd libb32; $(MAKE) libamiga CFLAGS="-O3 -fomit-frame-pointer -fbaserel32 -m68020"
clean:
cd lib; $(MAKE) clean
cd libb; $(MAKE) clean
cd lib020; $(MAKE) clean
cd libb020; $(MAKE) clean
cd lib881; $(MAKE) clean
cd libb881; $(MAKE) clean
# cd lib060; $(MAKE) clean
# cd libb060; $(MAKE) clean
# cd lib32; $(MAKE) clean
# cd libb32881; $(MAKE) clean
# cd libix; $(MAKE) clean
-rm -f sources/*/filelist sources/stubs/libbases/* sources/stubs/libnames/*
veryclean:
cd lib; $(MAKE) veryclean
cd libb; $(MAKE) veryclean
cd lib020; $(MAKE) veryclean
cd libb020; $(MAKE) veryclean
cd lib881; $(MAKE) veryclean
cd libb881; $(MAKE) veryclean
# cd lib060; $(MAKE) veryclean
# cd libb060; $(MAKE) veryclean
# cd lib32; $(MAKE) veryclean
# cd libb32881; $(MAKE) veryclean
# cd libix; $(MAKE) veryclean
-rm sources/*/filelist
libnix.guide: libnix.texi
makeinfo --amiga $(srcdir)/libnix.texi -o libnix.guide
libnix.info: libnix.texi
makeinfo $(srcdir)/libnix.texi -o libnix.info
install: installdirs
$(INSTALL) startup/*.o $(prefix)/lib/libnix
$(INSTALL) lib/*/lib*.a $(prefix)/lib/libnix
$(INSTALL) lib/misc/*.o $(prefix)/lib/libnix
$(INSTALL) libb/*/lib*.a $(prefix)/lib/libb/libnix
$(INSTALL) libb/misc/*.o $(prefix)/lib/libb/libnix
$(INSTALL) lib020/*/lib*.a $(prefix)/lib/libm020/libnix
$(INSTALL) lib020/misc/*.o $(prefix)/lib/libm020/libnix
$(INSTALL) libb020/*/lib*.a $(prefix)/lib/libb/libm020/libnix
$(INSTALL) libb020/misc/*.o $(prefix)/lib/libb/libm020/libnix
$(INSTALL) lib881/*/lib*.a $(prefix)/lib/libm020/libm881/libnix
$(INSTALL) lib881/misc/*.o $(prefix)/lib/libm020/libm881/libnix
$(INSTALL) libb881/*/lib*.a $(prefix)/lib/libb/libm020/libm881/libnix
$(INSTALL) libb881/misc/*.o $(prefix)/lib/libb/libm020/libm881/libnix
$(INSTALL_DATA) *.info* $(infodir)
$(INSTALL_DATA) libnix.guide $(guidedir)/libnix.guide
# $(INSTALL) lib060/*/lib*.a $(prefix)/lib/libm060/libnix
# $(INSTALL) lib060/misc/*.o $(prefix)/lib/libm060/libnix
# $(INSTALL) libb060/*/lib*.a $(prefix)/lib/libb/libm060/libnix
# $(INSTALL) libb060/misc/*.o $(prefix)/lib/libb/libm060/libnix
# $(INSTALL) libb32/*/lib*.a $(prefix)/lib/libb32/libm020/libnix
# $(INSTALL) libb32/misc/*.o $(prefix)/lib/libb32/libm020/libnix
# $(INSTALL) libb32881/*/lib*.a $(prefix)/lib/libb32/libm020/libm881/libnix
# $(INSTALL) libb32881/misc/*.o $(prefix)/lib/libb32/libm020/libm881/libnix
installdirs: mkinstalldirs
$(srcdir)/mkinstalldirs \
$(infodir) \
$(guidedir) \
$(libdir) \
$(libdir)/libnix \
$(libdir)/libm020 \
$(libdir)/libm020/libnix \
$(libdir)/libm020/libm881 \
$(libdir)/libm020/libm881/libnix \
$(libdir)/libb \
$(libdir)/libb/libnix \
$(libdir)/libb/libm020 \
$(libdir)/libb/libm020/libnix \
$(libdir)/libb/libm020/libm881 \
$(libdir)/libb/libm020/libm881/libnix
# $(libdir)/libm060 \
# $(libdir)/libm060/libnix \
# $(libdir)/libb/libm060 \
# $(libdir)/libb/libm060/libnix
# $(libdir)/libb32 \
# $(libdir)/libb32/libnix \
# $(libdir)/libb32/libm020 \
# $(libdir)/libb32/libm020/libnix \
# $(libdir)/libb32/libm020/libm881 \
# $(libdir)/libb32/libm020/libm881/libnix
distribution:
mkdir t:gg t:gg/lib t:gg/lib/libnix
lha a -mraxez t:gg/libnix-sources.lha Makefile libnix.texi
lha a -mraxez t:gg/libnix-sources.lha sources examples
mkdir t:gg/lib/libm020 t:gg/lib/libm020/libnix \
t:gg/lib/libm020/libm881 t:gg/lib/libm020/libm881/libnix \
t:gg/lib/libb t:gg/lib/libb/libnix \
t:gg/lib/libb/libm020 t:gg/lib/libb/libm020/libnix \
t:gg/lib/libb/libm020/libm881 t:gg/lib/libb/libm020/libm881/libnix
cp -p startup/*.o t:gg/lib/libnix
cp -p lib/*/*.a t:gg/lib/libnix
cp -p lib/misc/*.o t:gg/lib/libnix
cp -p libb/*/*.a t:gg/lib/libb/libnix
cp -p libb/misc/*.o t:gg/lib/libb/libnix
cp -p lib020/*/*.a t:gg/lib/libm020/libnix
cp -p lib020/misc/*.o t:gg/lib/libm020/libnix
cp -p libb020/*/*.a t:gg/lib/libb/libm020/libnix
cp -p libb020/misc/*.o t:gg/lib/libb/libm020/libnix
cp -p lib881/*/*.a t:gg/lib/libm020/libm881/libnix
cp -p lib881/misc/*.o t:gg/lib/libm020/libm881/libnix
cp -p libb881/*/*.a t:gg/lib/libb/libm020/libm881/libnix
cp -p libb881/misc/*.o t:gg/lib/libb/libm020/libm881/libnix
-rm t:gg/lib/libnix/libglue.a t:gg/lib/libb/libnix/libglue.a
-cp * t:gg
rm t:gg/Makefile t:gg/libnix.texi
cd t:gg;lha m -mraxeZ libnix.lha *
rm -rf t:gg
Vendored Executable
+1400
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT()
AC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_OUTPUT(Makefile sources/Makefile sources/amiga/Makefile
sources/math/Makefile sources/misc/Makefile
sources/nix/Makefile sources/nix13/Makefile
sources/nixmain/Makefile sources/nix_main/Makefile
sources/stack/Makefile sources/startup/Makefile
sources/stubs/Makefile examples/Makefile)
+30
View File
@@ -0,0 +1,30 @@
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
#### End system configuration section ####
# Some examples
.PHONY: all
all: lib libr dev helloworld
# normal library
lib: libinit.o simplelib.c
$(CC) -nostdlib -O3 -fomit-frame-pointer -fbaserel $^ -o $@
# multibase library
libr: libinitr.o simplelib.c
$(CC) -nostdlib -O3 -fomit-frame-pointer -resident $^ -o $@
# device
dev: devinit.o simpledev.c
$(CC) -nostdlib -O3 -fomit-frame-pointer -fbaserel $^ -o $@
# helloworld
helloworld: nbcrt0.o helloworld.c libstubs.a
$(CC) -nostdlib -O3 -fomit-frame-pointer -s -fbaserel $^ -o $@
+20
View File
@@ -0,0 +1,20 @@
#include <dos/dos.h>
#include <workbench/workbench.h>
#include <inline/exec.h>
#include <inline/dos.h>
int __nocommandline=1; /* Disable commandline parsing */
int __initlibraries=0; /* Disable auto-library-opening */
struct DosLibrary *DOSBase=NULL;
extern struct WBStartup *_WBenchMsg;
int main(void)
{ if(_WBenchMsg==NULL)
{ if((DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",33))!=NULL)
{ Write(Output(),"Hello world\n",12);
CloseLibrary((struct Library *)DOSBase); } }
return 0;
}
+152
View File
@@ -0,0 +1,152 @@
/******************************************************************************/
/* */
/* includes */
/* */
/******************************************************************************/
#include <exec/types.h>
#include <exec/errors.h>
#include <exec/execbase.h>
#include <proto/exec.h>
#include "stabs.h"
/******************************************************************************/
/* */
/* exports */
/* */
/******************************************************************************/
const BYTE DevName[]="simple.device";
const BYTE DevIdString[]="version 1.0";
const UWORD DevVersion=1;
const UWORD DevRevision=0;
/******************************************************************************/
/* */
/* global declarations */
/* */
/******************************************************************************/
struct Device *myDevPtr;
struct ExecBase *SysBase;
/******************************************************************************/
/* */
/* user device initialization */
/* */
/* !!! CAUTION: This function runs in a forbidden state !!! */
/* */
/******************************************************************************/
int __UserDevInit(struct Device *myDev)
{
/* required !!! */
SysBase=*(struct ExecBase **)4;
/* setup your device base - to access device functions over *this* basePtr! */
myDevPtr = myDev;
/* now do your initialization */
/* ... */
/* return a bool to indicate success */
return 0;
}
/******************************************************************************/
/* */
/* user device cleanup */
/* */
/* !!! CAUTION: This function runs in a forbidden state !!! */
/* */
/******************************************************************************/
void __UserDevCleanup()
{
/* your cleanup comes here */
/* ... */
/* nothing to return */
}
/******************************************************************************/
/* */
/* device dependent open function */
/* */
/* !!! CAUTION: This function runs in a forbidden state !!! */
/* */
/******************************************************************************/
int __UserDevOpen(struct IORequest *iorq,ULONG unit,ULONG flags)
{
int io_err=IOERR_OPENFAIL;
/* return a bool to indicate success */
return io_err;
}
/******************************************************************************/
/* */
/* device dependent close function */
/* */
/* !!! CAUTION: This function runs in a forbidden state !!! */
/* */
/******************************************************************************/
void __UserDevClose(struct IORequest *iorq)
{
/* nothing to return */
}
/******************************************************************************/
/* */
/* device dependent beginio function */
/* */
/******************************************************************************/
ADDTABL_1(__BeginIO,a1);
void __BeginIO(struct IORequest *iorq)
{
};
/******************************************************************************/
/* */
/* device dependent abortio function */
/* */
/******************************************************************************/
ADDTABL_1(__AbortIO,a1);
void __AbortIO(struct IORequest *iorq)
{
};
/******************************************************************************/
/* */
/* additional device dependent functions */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
/* endtable marker (required!) */
/* */
/******************************************************************************/
ADDTABL_END();
/******************************************************************************/
/* */
/* end of simpledev.c */
/* */
/******************************************************************************/
+93
View File
@@ -0,0 +1,93 @@
/******************************************************************************/
/* */
/* includes */
/* */
/******************************************************************************/
#include <exec/types.h>
#include <exec/execbase.h>
#include <dos/dosextens.h>
#include <proto/exec.h>
#include "stabs.h"
/******************************************************************************/
/* */
/* exports */
/* */
/******************************************************************************/
const BYTE LibName[]="simple.library";
const BYTE LibIdString[]="version 1.0";
const UWORD LibVersion=1;
const UWORD LibRevision=0;
/******************************************************************************/
/* */
/* global declarations */
/* */
/******************************************************************************/
struct Library *myLibPtr;
struct ExecBase *SysBase;
struct DosLibrary *DOSBase;
/******************************************************************************/
/* */
/* user library initialization */
/* */
/* !!! CAUTION: This function may run in a forbidden state !!! */
/* */
/******************************************************************************/
int __UserLibInit(struct Library *myLib)
{
/* setup your library base - to access library functions over *this* basePtr! */
myLibPtr = myLib;
/* required !!! */
SysBase=*(struct ExecBase **)4;
return (DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",33))==NULL;
}
/******************************************************************************/
/* */
/* user library cleanup */
/* */
/* !!! CAUTION: This function runs in a forbidden state !!! */
/* */
/******************************************************************************/
void __UserLibCleanup()
{
CloseLibrary((struct Library *)DOSBase);
}
/******************************************************************************/
/* */
/* library dependent function(s) */
/* */
/******************************************************************************/
ADDTABL_1(__UserFunc,d0); /* One Argument in d0 */
int __UserFunc(long a)
{
return a*2;
}
/******************************************************************************/
/* */
/* endtable marker (required!) */
/* */
/******************************************************************************/
ADDTABL_END();
/******************************************************************************/
/* */
/* end of simplelib.c */
/* */
/******************************************************************************/
+1391
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Last modified: 1994-03-25
# Public domain
errstatus=0
for file in ${1+"$@"} ; do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d in ${1+"$@"} ; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" || errstatus=$?
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
+98
View File
@@ -0,0 +1,98 @@
# Built one model of the libnix libraries - use
# make CFLAGS="what you like" to built them.
#
# Combine
#
# CFLAGS=-Wall -O3
#
# -fbaserel -DSMALL_DATA for small data model
# -fbaserel32 for large baserel model
# -m68020 for 68020 specific code
# -m68060 for 68060 specific code
# -m68881 for 68881 specific code
# -DIXPATHS for Un*x path option
# -DDEBUG_LIB build a library for debugging (not recommended)
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CPP = @CPP@
AS = as
RANLIB = @RANLIB@
AWK = @AWK@
#### End system configuration section ####
CURDIR = $(shell pwd)
MAKELIST=make -f $(CURDIR)/Makefile
SUBDIRS=nixmain nix_main misc nix nix13 math stack stubs
all: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f))
for subdir in $(SUBDIRS); do \
( cd $$subdir;make -f ../../sources/$$subdir/Makefile V="$(V)" \
CFLAGS="$(CFLAGS)" ); \
done
$(foreach f,$(SUBDIRS),$(CURDIR)/$(f)):
mkdir $@
libamiga:
if [ ! -d amiga ] ; then mkdir amiga ; else true ; fi
cd amiga;make -f $(CURDIR)/../sources/amiga/Makefile CFLAGS="$(CFLAGS)"
filelists:
-cd $(srcdir)/math; $(MAKELIST) SOURCEFILES="*/*" FLDIR=$(CURDIR)/math $(CURDIR)/math/filelist
-cd $(srcdir)/stack; $(MAKELIST) SOURCEFILES="*.c" FLDIR=$(CURDIR)/stack $(CURDIR)/stack/filelist
-cd $(srcdir)/nix; $(MAKELIST) SOURCEFILES="*/*" FLDIR=$(CURDIR)/nix $(CURDIR)/nix/filelist
-cd $(srcdir)/nix13; $(MAKELIST) SOURCEFILES="*/*" FLDIR=$(CURDIR)/nix13 $(CURDIR)/nix13/filelist
-cd $(srcdir)/stubs; make -f $(CURDIR)/Makefile STUBDIR=$(CURDIR)/stubs libbases/dos.c; \
$(MAKELIST) SOURCEFILES=" \
libbases/* misc/__DOSBase.c misc/__UtilityBase.c \
misc/__MathIeeeSingBasBase.c misc/__MathIeeeDoubBasBase.c \
misc/__MathIeeeSingTransBase.c misc/__MathIeeeDoubTransBase.c \
misc/__initlibraries.c misc/__flush_cache.c misc/__cpucheck.c \
libnames/* stubs/*" \
FLDIR=$(CURDIR)/stubs $(CURDIR)/stubs/filelist
-cd $(srcdir)/amiga; $(MAKELIST) SOURCEFILES="*/*" FLDIR=$(CURDIR)/amiga $(CURDIR)/amiga/filelist
$(FLDIR)/filelist:
echo "#Computer generated partial Makefile-do not edit" >$(FLDIR)/filelist
echo "OBJECTS= \\" >>$(FLDIR)/filelist
( for file in $(SOURCEFILES); do echo $$file; done ) | \
$(AWK) '{ if($$0 !~ /CVS/) { print substr($$0,1,length($$0)-2) ".o \\" } }' >>$(FLDIR)/filelist
echo >>$(FLDIR)/filelist
echo "SUBDIRS= \\" >>$(FLDIR)/filelist
ls -d -F *|$(AWK) '/\// { if($$0 !~ /CVS/) { print substr($$0,1,length($$0)-1) " \\" } }' >>$(FLDIR)/filelist
# build stubs for library base pointers
libbases/dos.c: $(STUBDIR)/Makefile library.list
-rm -f libbases/* libnames/*
$(AWK) <library.list '{ sname=substr($$2,1,length($$2)-8); \
fname="libbases/" sname ".c"; \
print "/* Machine-generated C-file- do not edit ! */" >fname; \
print "#include <stabs.h>" >fname; \
print "extern char __" sname "name[];" >fname; \
print "void *" $$1 "[2]={ 0l,__" sname "name };" >fname; \
print "ADD2LIB(" $$1 ");" >fname; \
fname="libnames/" sname ".c"; \
print "/* Machine-generated C-file- do not edit ! */" >fname; \
print "char __" sname "name[]=\"" $$2 "\";" >fname;}'
clean:
if [ -d nixmain ] ; then (cd nixmain; make -f ../../sources/nixmain/Makefile TARGET=clean clean) ; else true ; fi
if [ -d nix_main ] ; then (cd nix_main; make -f ../../sources/nix_main/Makefile TARGET=clean clean) ; else true ; fi
if [ -d misc ] ; then (cd misc; make -f ../../sources/misc/Makefile TARGET=clean clean) ; else true ; fi
if [ -d math ] ; then (cd math; make -f ../../sources/math/Makefile TARGET=clean clean) ; else true ; fi
if [ -d stack ] ; then (cd stack; make -f ../../sources/stack/Makefile TARGET=clean clean) ; else true ; fi
if [ -d nix ] ; then (cd nix; make -f ../../sources/nix/Makefile TARGET=clean clean) ; else true ; fi
if [ -d nix13 ] ; then (cd nix13; make -f ../../sources/nix13/Makefile TARGET=clean clean) ; else true ; fi
if [ -d stubs ] ; then (cd stubs; make -f ../../sources/stubs/Makefile TARGET=clean clean) ; else true ; fi
veryclean:
-rm -rf *
+134
View File
@@ -0,0 +1,134 @@
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CPP = @CPP@
AS = as
RANLIB = @RANLIB@
AWK = @AWK@
FD2INLINE = fd2inline
CLIBPATH = $(prefix)/os-include/clib/
FDPATH = $(prefix)/os-lib/fd/
#### End system configuration section ####
include ../../sources/amiga/filelist
CURDIR = $(shell pwd)
OPTIONS=-I $(srcdir)/../headers -I../../sources/headers $(CFLAGS)
SOURCEFILES=*/*
FDFILES = $(wildcard $(FDPATH)*.fd)
CLIB = $(addprefix $(CLIBPATH),$(subst _lib.fd,_protos.h,$(notdir $(fd))))
STUB = $(subst _lib.fd,,$(notdir $(fd)))
%.o: %.c
$(CC) $(OPTIONS) -c $^ -o $@ 2>&1|tee $*.err
-if test ! -s $*.err; then rm $*.err; fi
%.o: %.S
$(CC) $(OPTIONS) -c $^ -o $@ 2>&1|tee $*.err
-if test ! -s $*.err; then rm $*.err; fi
.PHONY: all clean veryclean splitinline
all: libamiga.a
clean:
-rm -rf $(SUBDIRS)
veryclean:
-rm -rf *
$(foreach f,$(SUBDIRS),$(CURDIR)/$(f)):
mkdir $@
##libamiga.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) libglue.a ../../sources/amiga/makefile ../../sources/amiga/filelist
libamiga.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) newlibglue.a ../../sources/amiga/makefile ../../sources/amiga/filelist
-rm -f libamiga.a
## -cp libglue.a libamiga.a
-cp newlibglue.a libamiga.a
ar -q libamiga.a $(OBJECTS)
$(RANLIB) libamiga.a
libglue.a:
if [ -d tmp ] ; then rm -rf tmp ; else true ; fi
-mkdir tmp
# Build assembler stubs out of inline headers:
# * First transform all vararg #defines into real functions
# * Compile all functions with 'extern' and '__inline' disabled
# * Split resulting assembler output at function entries
# * This needs old-style inlines!
-cd tmp; \
echo "" >dummy.c; \
for file in /gg/include/inline/*.h; do \
( $(AWK) 'nf==1 { fn=$$1;nf=0 } \
/inline/ { vs="long";rs="return ";nf=1 } \
/void/ { vs="void";rs="";nf=1 } \
/\.\.\./ \
{ st=substr($$0,1,index($$0,"tags...")-1); \
st=substr(st,index(st," ")); \
st2=st;gsub(/\(/,"(long ",st2);gsub(/,/,",long ",st2); \
print "#undef" substr(st,1,index(st,"(")-1) "\n" vs st2 "tags,...)"; \
print "{ " rs fn substr(st,index(st,"(")) "&tags); }\n" \
}' $$file >vararg.c; \
( $(CC) $(CFLAGS) -w -include $$file vararg.c -S -o -; \
$(CC) -Dextern= -D__inline= -D_STRSUP_H -include $$file $(CFLAGS) dummy.c -S -o - ) | \
$(AWK) '/.even/ { next } /.comm/ { next } \
/.globl/ { if(file!="") close(file); file=$$2 ".s"; \
print "\t.even\n" $$0 >file; next; } \
{ if(file!="") print $$0 >file; }' ); done
-cd tmp;rm vararg.c dummy.c;$(CC) -c *.s
-rm libglue.a
-cd tmp;ar -q ../libglue.a *.o
-rm -rf tmp
newlibglue.a: stublibs
if [ ! -f stamp-libglue ];\
then\
pwd;\
rm -f $@;\
$(foreach fd, $(FDFILES),\
echo "adding $(STUB) stubs to $@ ...";\
ar -q $@ stubs/$(STUB)/*.o;)\
touch stamp-libglue;\
else\
true;\
fi;
stublibs: stubsrcs
cd stubs;\
$(foreach fd, $(FDFILES),\
if [ ! -f stamp-$(STUB)-stubs ];\
then\
echo "building $(STUB) stubs...";\
cd $(STUB);\
$(CC) $(OPTIONS) -c *.c;\
cd ..;\
touch stamp-$(STUB)-stubs;\
else\
true;\
fi;\
)
stubsrcs:
if [ ! -d stubs ] ; then mkdir stubs ; else true ; fi
cd stubs;\
$(foreach fd, $(FDFILES),\
if [ ! -f stamp-$(STUB)-srcs ];\
then\
echo "creating $(STUB) stubs sources...";\
rm -rf $(STUB);\
$(FD2INLINE) --splitstubs $(fd) $(CLIB) -o $(STUB);\
touch stamp-$(STUB)-srcs;\
else\
true;\
fi;\
)
+7
View File
@@ -0,0 +1,7 @@
#include <stabs.h>
ABSDEF(AbsExecBase,0x00000004);
ABSDEF(cartridge, 0x00f00000);
ABSDEF(bootrom, 0x00f80000);
ABSDEF(romstart, 0x00fc0000);
ABSDEF(romend, 0x00ffffff);
+27
View File
@@ -0,0 +1,27 @@
#include <exec/interrupts.h>
#include <hardware/intbits.h>
#include <graphics/graphint.h>
#include <clib/alib_protos.h>
#include <proto/graphics.h>
#include <proto/exec.h>
STATIC int stub(struct Isrvstr *intr asm("a1"))
{
(*intr->ccode)(intr->Carg); return 0;
}
VOID AddTOF(struct Isrvstr *intr,LONG (*code)(),LONG arg)
{ APTR SysBase = *(APTR *)4L;
intr->Iptr = intr;
intr->code = (int (*)())stub;
intr->ccode = (int (*)())code;
intr->Carg = (int)arg;
AddIntServer(INTB_VERTB,(struct Interrupt *)intr);
}
VOID RemTOF(struct Isrvstr *intr)
{ APTR SysBase = *(APTR *)4L;
RemIntServer(INTB_VERTB,(struct Interrupt *)intr);
}
+89
View File
@@ -0,0 +1,89 @@
#include <exec/memory.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
#include <libraries/commodities.h>
#include <proto/commodities.h>
#include <proto/icon.h>
#include <proto/exec.h>
#include <proto/dos.h>
#ifdef NEW_ARGARRAY
static UBYTE **argArray;
#endif
static struct DiskObject *dObj;
UBYTE **ArgArrayInit(long argc, UBYTE **argv)
{
if (argc) {
if (argc>1)
#ifdef NEW_ARGARRAY
if ((argArray=AllocVec(argc*sizeof(char *),MEMF_ANY))) {
UBYTE **p,**p1;
p=p1=argArray;
argv++;
do
{
*p1++=*argv++;
}
while(--argc);
return p;
}
#else
{
argv++; return argv;
}
#endif
}
else
if ((dObj=GetDiskObject(((struct WBStartup *)argv)->sm_ArgList->wa_Name)))
return (UBYTE **)dObj->do_ToolTypes;
return NULL;
}
STRPTR ArgString(UBYTE **tt, STRPTR entry, STRPTR defstr)
{
STRPTR str;
if (!entry || !(str=FindToolType(tt,entry)))
str=defstr;
return str;
}
LONG ArgInt(UBYTE **tt, STRPTR entry, long defval)
{
STRPTR str;
if (entry && (str=FindToolType(tt,entry)))
StrToLong(str,&defval);
return defval;
}
#ifdef 0 /* only a example ??? */
CxObj *UserFilter(UBYTE **tt, STRPTR entry, STRPTR defstr)
{
STRPTR str;
if (!entry || !(str=FindToolType(tt,entry)))
str=defstr;
return (CreateCxObj(CX_FILTER,(long)str,NULL));
}
#endif
void ArgArrayDone(void)
{
struct DiskObject **d;
#ifdef NEW_ARGARRAY
UBYTE ***a;
if (*(a=&argArray)) {
FreeVec(*a); *a=NULL;
}
#endif
if (*(d=&dObj)) {
FreeDiskObject(*d); *d=NULL;
}
}
@@ -0,0 +1,62 @@
#include <pool.h>
APTR ASM AsmAllocPooled(REG(a0,POOL *poolHeader),REG(d0,ULONG memSize),REG(a6,APTR SysBase))
{
if (((struct Library *)SysBase)->lib_Version>=39)
return (AllocPooled(poolHeader,memSize));
else {
ULONG *puddle=NULL;
if (poolHeader!=NULL && memSize!=0) {
ULONG *p,size;
if (poolHeader->ThreshSize>memSize) {
struct MemHeader *a=(struct MemHeader *)poolHeader->PuddleList.mlh_Head;
for(;;) {
if (a->mh_Node.ln_Succ!=NULL) {
if (a->mh_Node.ln_Type && (puddle=(ULONG *)Allocate(a,memSize))!=NULL)
break;
a=(struct MemHeader *)a->mh_Node.ln_Succ; continue;
}
size=poolHeader->PuddleSize+sizeof(struct MemHeader)+2*sizeof(ULONG);
if ((puddle=(ULONG *)AllocMem(size,poolHeader->MemoryFlags))==NULL)
goto out; /* why is gcc so dumb ??? */
*puddle++=size;
a=(struct MemHeader *)puddle;
a->mh_Node.ln_Type=NT_MEMORY;
a->mh_Lower=a->mh_First=(struct MemChunk *)((UBYTE *)a+sizeof(struct MemHeader)+sizeof(UBYTE *));
a->mh_First->mc_Next=NULL;
a->mh_Free=a->mh_First->mc_Bytes=poolHeader->PuddleSize;
a->mh_Upper=(char *)a->mh_First+a->mh_Free;
AddHead((struct List *)&poolHeader->PuddleList,&a->mh_Node);
puddle=(ULONG *)Allocate(a,memSize);
break;
}
if (poolHeader->MemoryFlags&MEMF_CLEAR) {
p=puddle; memSize+=7; memSize>>=3;
do { *p++=0; *p++=0; } while(--memSize);
}
}
else {
size=memSize+sizeof(struct MinNode)+2*sizeof(ULONG);
if ((puddle=(ULONG *)AllocMem(size,poolHeader->MemoryFlags))!=NULL) {
*puddle++=size;
AddTail((struct List *)&poolHeader->PuddleList,(struct Node *)puddle);
puddle=(ULONG *)((struct MinNode *)puddle+1);
*puddle++=0;
}
}
}
out:
return puddle;
}
}
+37
View File
@@ -0,0 +1,37 @@
#include <pool.h>
#define NEWLIST(l) ((l)->mlh_Head = (struct MinNode *)&(l)->mlh_Tail, \
(l)->mlh_Tail = NULL, \
(l)->mlh_TailPred = (struct MinNode *)&(l)->mlh_Head)
APTR ASM AsmCreatePool(REG(d0,ULONG requirements),REG(d1,ULONG puddleSize),REG(d2,ULONG threshSize),REG(a6,APTR SysBase))
{
if (((struct Library *)SysBase)->lib_Version>=39)
return (CreatePool(requirements,puddleSize,threshSize));
else {
POOL *pool=NULL;
if (threshSize<=puddleSize) {
puddleSize+=7;
if ((pool=(POOL *)AllocMem(sizeof(POOL),MEMF_ANY))!=NULL) {
NEWLIST(&pool->PuddleList);
pool->MemoryFlags=requirements;
pool->PuddleSize=puddleSize&~7;
pool->ThreshSize=threshSize;
}
}
return pool;
}
}
VOID ASM AsmDeletePool(REG(a0,POOL *poolHeader),REG(a6,APTR SysBase))
{ ULONG *pool,size;
if (((struct Library *)SysBase)->lib_Version>=39)
DeletePool(poolHeader);
else if (poolHeader!=NULL) {
while((pool=(ULONG *)RemHead((struct List *)&poolHeader->PuddleList))!=NULL) {
size=*--pool; FreeMem(pool,size);
}
FreeMem(poolHeader,sizeof(POOL));
}
}
+30
View File
@@ -0,0 +1,30 @@
#include <pool.h>
VOID ASM AsmFreePooled(REG(a0,POOL *poolHeader),REG(a1,APTR memory),REG(d0,ULONG memSize),REG(a6,APTR SysBase))
{
if (((struct Library *)SysBase)->lib_Version>=39)
return (FreePooled(poolHeader,memory,memSize));
else if (poolHeader!=NULL && memory!=NULL) {
ULONG size,*puddle=(ULONG *)((struct MinNode *)memory-1)-1;
if (poolHeader->ThreshSize>memSize) {
struct MemHeader *a=(struct MemHeader *)&poolHeader->PuddleList.mlh_Head;
for(;;) {
a=(struct MemHeader *)a->mh_Node.ln_Succ;
if (a->mh_Node.ln_Succ==NULL)
return;
if (a->mh_Node.ln_Type && memory>=a->mh_Lower && memory<a->mh_Upper)
break;
}
Deallocate(a,memory,memSize);
if (a->mh_Free!=poolHeader->PuddleSize)
return;
puddle=(ULONG *)&a->mh_Node;
}
Remove((struct Node *)puddle);
size=*--puddle; FreeMem(puddle,size);
}
}
+10
View File
@@ -0,0 +1,10 @@
#ifdef __GNUC__
#include <exec/devices.h>
#include <exec/io.h>
void BeginIO(struct IORequest *iorequest)
{ register struct IORequest *a1 asm("a1")=iorequest;
register struct Device *a6 asm("a6")=iorequest->io_Device;
asm("jsr a6@(-30)"::"r"(a1),"r"(a6):"a0","a1","d0","d1");
}
#endif
+23
View File
@@ -0,0 +1,23 @@
asm("
.text
.globl _CallHook
.globl _CallHookA
_CallHook: lea sp@(12:W),a1
jra L_CallHook
_CallHookA: movel sp@(12:W),a1
L_CallHook: movel a6,sp@-
movel a2,sp@-
movel sp@(12:W),a0
movel sp@(16:W),a2
jbsr L_callit
movel sp@+,a2
movel sp@+,a6
rts
L_callit: movel a0@(8:W),sp@-
rts
");
+39
View File
@@ -0,0 +1,39 @@
#include <stabs.h>
/* Absolute definitions for the cia registers
* some of the are recommended to use
* and very useful when hacking hardware ;-)
*/
ABSDEF(ciab, 0x00bfd000);
ABSDEF(ciabpra, 0x00bfd000);
ABSDEF(ciabprb, 0x00bfd100);
ABSDEF(ciabddra, 0x00bfd200);
ABSDEF(ciabddrb, 0x00bfd300);
ABSDEF(ciabtalo, 0x00bfd400);
ABSDEF(ciabtahi, 0x00bfd500);
ABSDEF(ciabtblo, 0x00bfd600);
ABSDEF(ciabtbhi, 0x00bfd700);
ABSDEF(ciabtodlow,0x00bfd800);
ABSDEF(ciabtodmid,0x00bfd900);
ABSDEF(ciabtodhi, 0x00bfda00);
ABSDEF(ciabsdr, 0x00bfdc00);
ABSDEF(ciabicr, 0x00bfdd00);
ABSDEF(ciabcra, 0x00bfde00);
ABSDEF(ciabcrb, 0x00bfdf00);
ABSDEF(ciaa, 0x00bfe001);
ABSDEF(ciaapra, 0x00bfe001);
ABSDEF(ciaaprb, 0x00bfe101);
ABSDEF(ciaaddra, 0x00bfe201);
ABSDEF(ciaaddrb, 0x00bfe301);
ABSDEF(ciaatalo, 0x00bfe401);
ABSDEF(ciaatahi, 0x00bfe501);
ABSDEF(ciaatblo, 0x00bfe601);
ABSDEF(ciaatbhi, 0x00bfe701);
ABSDEF(ciaatodlow,0x00bfe801);
ABSDEF(ciaatodmid,0x00bfe901);
ABSDEF(ciaatodhi, 0x00bfea01);
ABSDEF(ciaasdr, 0x00bfec01);
ABSDEF(ciaaicr, 0x00bfed01);
ABSDEF(ciaacra, 0x00bfee01);
ABSDEF(ciaacrb, 0x00bfef01);
+24
View File
@@ -0,0 +1,24 @@
asm("
.text
.globl _CoerceMethod
.globl _CoerceMethodA
_CoerceMethod: lea sp@(12:W),a1
jra L_CoerceMethod
_CoerceMethodA: movel sp@(12:W),a1
L_CoerceMethod: movel a2,sp@-
moveml sp@(8:W),a0/a2
movel a0,d0
beqs L_Null
movel a2,d0
beqs L_Null
jbsr L_Invoke
L_Null: movel sp@+,a2
rts
L_Invoke: movel a0@(8:W),sp@-
rts
");
+35
View File
@@ -0,0 +1,35 @@
#include <exec/io.h>
#include <exec/memory.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <stabs.h>
struct IORequest *CreateExtIO(struct MsgPort *port,LONG iosize)
{ APTR SysBase = *(APTR *)4L;
struct IORequest *ioreq = NULL;
if (port && (ioreq=AllocMem(iosize,MEMF_CLEAR|MEMF_PUBLIC))) {
ioreq->io_Message.mn_Node.ln_Type = NT_REPLYMSG;
ioreq->io_Message.mn_ReplyPort = port;
ioreq->io_Message.mn_Length = iosize;
}
return ioreq;
}
struct IOStdReq *CreateStdIO(struct MsgPort *port)
{
return (struct IOStdReq *)CreateExtIO(port,sizeof(struct IOStdReq));
}
VOID DeleteExtIO(struct IORequest *ioreq)
{ APTR SysBase = *(APTR *)4L;
LONG i;
i = -1;
ioreq->io_Message.mn_Node.ln_Type = i;
ioreq->io_Device = (struct Device *)i;
ioreq->io_Unit = (struct Unit *)i;
FreeMem(ioreq,ioreq->io_Message.mn_Length);
}
ALIAS(DeleteStdIO,DeleteExtIO);
+41
View File
@@ -0,0 +1,41 @@
#include <exec/ports.h>
#include <exec/memory.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \
/*(l)->lh_Tail = NULL,*/ \
(l)->lh_TailPred = (struct Node *)&(l)->lh_Head)
struct MsgPort *CreatePort(STRPTR name,LONG pri)
{ APTR SysBase = *(APTR *)4L;
struct MsgPort *port = NULL;
UBYTE portsig;
if ((BYTE)(portsig=AllocSignal(-1)) >= 0) {
if (!(port=AllocMem(sizeof(*port),MEMF_CLEAR|MEMF_PUBLIC)))
FreeSignal(portsig);
else {
port->mp_Node.ln_Type = NT_MSGPORT;
port->mp_Node.ln_Pri = pri;
port->mp_Node.ln_Name = name;
/* done via AllocMem
port->mp_Flags = PA_SIGNAL;
*/
port->mp_SigBit = portsig;
port->mp_SigTask = FindTask(NULL);
NEWLIST(&port->mp_MsgList);
if (port->mp_Node.ln_Name)
AddPort(port);
}
}
return port;
}
VOID DeletePort(struct MsgPort *port)
{ APTR SysBase = *(APTR *)4L;
if (port->mp_Node.ln_Name)
RemPort(port);
FreeSignal(port->mp_SigBit); FreeMem(port,sizeof(*port));
}
+126
View File
@@ -0,0 +1,126 @@
#if 1
#include <exec/tasks.h>
#include <exec/memory.h>
#include <proto/exec.h>
struct newMemList {
struct Node nml_Node;
UWORD nml_NumEntries;
struct MemEntry nml_ME[2];
};
const struct newMemList MemTemplate = {
{0,},
2,
{ {MEMF_CLEAR|MEMF_PUBLIC, sizeof(struct Task)},
{MEMF_CLEAR, 0} }
};
#define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \
/*(l)->lh_Tail = NULL,*/ \
(l)->lh_TailPred = (struct Node *)&(l)->lh_Head)
struct Task *CreateTask(STRPTR name, LONG pri, APTR initpc, ULONG stacksize)
{ struct Library *SysBase = *(struct Library **)4L;
struct newMemList nml;
struct MemList *ml;
struct Task *newtask;
APTR task2;
stacksize=(stacksize+3)&~3;
{
long *p1,*p2;
int i;
for (p1=(long *)&nml,p2=(long*)&MemTemplate,i=7; i; *p1++=*p2++,i--) ;
*p1=stacksize;
}
if (!(((unsigned int)ml=AllocEntry((struct MemList *)&nml)) & (1<<31))) {
newtask=ml->ml_ME[0].me_Addr;
newtask->tc_Node.ln_Type = NT_TASK;
newtask->tc_Node.ln_Pri = pri;
newtask->tc_Node.ln_Name = name;
newtask->tc_SPReg = (APTR)((ULONG)ml->ml_ME[1].me_Addr+stacksize);
newtask->tc_SPLower = ml->ml_ME[1].me_Addr;
newtask->tc_SPUpper = newtask->tc_SPReg;
NEWLIST(&newtask->tc_MemEntry);
AddHead(&newtask->tc_MemEntry,&ml->ml_Node);
task2=AddTask(newtask,initpc,0);
if (SysBase->lib_Version>36 && !task2) {
FreeEntry(ml); newtask = NULL;
}
}
else
newtask = NULL;
return newtask;
}
#else
asm("
.globl _CreateTask
_CreateTask: moveml d2/d3/a2/a3/a6,sp@-
movel sp@(12+6*4:W),d0
addql #3,d0
moveq #-4,d2
andl d0,d2 | stack adjusted
movel d2,sp@-
lea pc@(Lmemlist-.+2+7*4),a0
moveq #6,d0
L3: movel a0@-,sp@- | copy memlist
dbra d0,L3
movel sp,a0
movel 4:W,a6
jsr a6@(-222:W) | AllocEntry()
movel d0,a2
movel a2,d0
lea sp@(32:W),sp
blts L2
movel a2@(16:W),a3
moveb #1,a3@(8:W) | ln_Type
moveb sp@(7+6*4:W),a3@(9:W) | ln_Pri
movel sp@(0+6*4:W),a3@(10:W) | ln_Name
movel a2@(24:W),d0
addl d0,d2
movel d2,a3@(54:W) | tc_SPReg
movel d0,a3@(58:W) | tc_SPLower
movel d2,a3@(62:W) | tc_SPUpper
lea a3@(74:W),a0 | tc_MemList
movel a0,a0@(8:W)
addqw #4,a0
movel a0,a0@-
movel a2,a1
jsr a6@(-240:W) | AddHead()
movel a3,d3
movel d3,a1
movel sp@(8+6*4:W),d2
exg d2,a2
subal a3,a3
jsr a6@(-282:W) | AddTask()
cmpw #37,a6@(20:W)
bcss L1 | kick2.0+ ?
tstl d0
bnes L1 | task added
movel d2,a0
jsr a6@(-228:W) | FreeEntry()
L2: moveq #0,d3
L1: movel d3,d0 | new task
moveml sp@+,d2/d3/a2/a3/a6
rts
.align 2
Lmemlist: .long 0,0 | Succ,Pred
.byte 0,0 | Pri,Type
.long 0 | Name
.word 2 | NumEntries
.long 0x10001 | MemType
.long 92 | Length
.long 0x10000 | MemType
| .long 0 | Length
");
#endif
+75
View File
@@ -0,0 +1,75 @@
#include <stabs.h>
/* Absolute definitions for the custom chips
* Most of them are recommended not to use
*/
ABSDEF(custom, 0x00dff000);
ABSDEF(bltddat,0x00dff000);
ABSDEF(dmaconr,0x00dff002);
ABSDEF(vposr, 0x00dff004);
ABSDEF(vhposr, 0x00dff006);
ABSDEF(dskdatr,0x00dff008);
ABSDEF(joy0dat,0x00dff00a);
ABSDEF(joy1dat,0x00dff00c);
ABSDEF(clxdat, 0x00dff00e);
ABSDEF(adkconr,0x00dff010);
ABSDEF(pot0dat,0x00dff012);
ABSDEF(pot1dat,0x00dff014);
ABSDEF(potinp, 0x00dff016);
ABSDEF(serdatr,0x00dff018);
ABSDEF(dskbytr,0x00dff01a);
ABSDEF(intenar,0x00dff01c);
ABSDEF(intreqr,0x00dff01e);
ABSDEF(dskpt, 0x00dff020);
ABSDEF(dsklen, 0x00dff024);
ABSDEF(dskdat, 0x00dff026);
ABSDEF(refptr, 0x00dff028);
ABSDEF(vposw, 0x00dff02a);
ABSDEF(vhposw, 0x00dff02c);
ABSDEF(copcon, 0x00dff02e);
ABSDEF(serdat, 0x00dff030);
ABSDEF(serper, 0x00dff032);
ABSDEF(potgo, 0x00dff034);
ABSDEF(joytest,0x00dff036);
ABSDEF(bltcon0,0x00dff040);
ABSDEF(bltcon1,0x00dff042);
ABSDEF(bltafwm,0x00dff044);
ABSDEF(bltalwm,0x00dff046);
ABSDEF(bltcpt, 0x00dff048);
ABSDEF(bltbpt, 0x00dff04c);
ABSDEF(bltapt, 0x00dff050);
ABSDEF(bltdpt, 0x00dff054);
ABSDEF(bltsize,0x00dff058);
ABSDEF(bltcmod,0x00dff060);
ABSDEF(bltbmod,0x00dff062);
ABSDEF(bltamod,0x00dff064);
ABSDEF(bltdmod,0x00dff066);
ABSDEF(bltcdat,0x00dff070);
ABSDEF(bltbdat,0x00dff072);
ABSDEF(bltadat,0x00dff074);
ABSDEF(cop1lc, 0x00dff080);
ABSDEF(cop2lc, 0x00dff084);
ABSDEF(copjmp1,0x00dff088);
ABSDEF(copjmp2,0x00dff08a);
ABSDEF(copins, 0x00dff08c);
ABSDEF(diwstrt,0x00dff08e);
ABSDEF(diwstop,0x00dff090);
ABSDEF(ddfstrt,0x00dff092);
ABSDEF(ddfstop,0x00dff094);
ABSDEF(dmacon, 0x00dff096);
ABSDEF(clxcon, 0x00dff098);
ABSDEF(intena, 0x00dff09a);
ABSDEF(intreq, 0x00dff09c);
ABSDEF(adkcon, 0x00dff09e);
ABSDEF(aud, 0x00dff0a0);
ABSDEF(bplpt, 0x00dff0e0);
ABSDEF(bplcon0,0x00dff100);
ABSDEF(bplcon1,0x00dff102);
ABSDEF(bplcon2,0x00dff104);
ABSDEF(bpl1mod,0x00dff108);
ABSDEF(bpl2mod,0x00dff10a);
ABSDEF(bpldat, 0x00dff110);
ABSDEF(sprpt, 0x00dff120);
ABSDEF(spr, 0x00dff140);
ABSDEF(color, 0x00dff180);
+3
View File
@@ -0,0 +1,3 @@
#include <stabs.h>
ALIAS (DeleteTask,RemTask);
+23
View File
@@ -0,0 +1,23 @@
asm("
.text
.globl _DoMethod
.globl _DoMethodA
_DoMethod: lea sp@(8:W),a1
jra L_DoMethod
_DoMethodA: movel sp@(8:W),a1
L_DoMethod: movel sp@(4:W),d0
beqs L_Null
movel a2,sp@-
movel d0,a2
movel a2@(-4:W),a0
jbsr L_Invoke
movel sp@+,a2
L_Null: rts
L_Invoke: movel a0@(8:W),sp@-
rts
");
+28
View File
@@ -0,0 +1,28 @@
asm("
.text
.globl _DoSuperMethod
.globl _DoSuperMethodA
_DoSuperMethod: lea sp@(12:W),a1
jra L_DoSuperMethod
_DoSuperMethodA:
movel sp@(12:W),a1
L_DoSuperMethod:
movel a2,sp@-
moveml sp@(8:W),a0/a2
movel a2,d0
beqs L_Null
movel a0,d0
beqs L_Null
movel a0@(24:W),a0
jbsr L_Invoke
L_Null: movel sp@+,a2
rts
L_Invoke: movel a0@(8:W),sp@-
rts
");
+26
View File
@@ -0,0 +1,26 @@
#if 1
#include <exec/types.h>
ULONG FastRand(ULONG seed)
{ ULONG a=seed<<1;
if((LONG)seed<=0)
a^=0x1d872b41;
return a;
}
#else
asm("
.text
.globl _FastRand
_FastRand: movel sp@(4:W),d0
addl d0,d0
bhis L1
eoril #0x1D872B41,d0
L1: rts
");
#endif
+13
View File
@@ -0,0 +1,13 @@
#include <devices/inputevent.h>
#include <proto/exec.h>
VOID FreeIEvents(struct InputEvent *events)
{ APTR SysBase = *(APTR *)4L;
struct InputEvent *next;
while (events != NULL) {
next = events->ie_NextEvent;
FreeMem(events,sizeof(*events));
events = next;
}
}
+26
View File
@@ -0,0 +1,26 @@
#if 0
#include <utility/hooks.h>
ULONG HookEntry(struct Hook *hook asm("a0"),APTR obj asm("a2"),APTR msg asm("a1"))
{
return (*hook->h_SubEntry)(hook,obj,msg);
}
#else
asm("
.text
.globl _HookEntry
_HookEntry: movel a1,sp@-
movel a2,sp@-
movel a0,sp@-
movel a0@(12:W),a0
jsr a0@
lea sp@(12:W),sp
rts
");
#endif
+15
View File
@@ -0,0 +1,15 @@
#include <libraries/commodities.h>
#include <proto/commodities.h>
CxObj *HotKey(STRPTR description,struct MsgPort *port,LONG id)
{ CxObj *filter;
if ((filter=CreateCxObj(CX_FILTER,(LONG)description,NULL))) {
AttachCxObj(filter,CreateCxObj(CX_SEND,(LONG)port,id));
AttachCxObj(filter,CreateCxObj(CX_TRANSLATE,NULL,NULL));
if (CxObjError(filter)) {
DeleteCxObjAll(filter); filter=NULL;
}
}
return filter;
}
+6
View File
@@ -0,0 +1,6 @@
#include <pool.h>
APTR LibAllocPooled(APTR poolHeader, ULONG memSize)
{
return AsmAllocPooled(poolHeader,memSize,*(APTR *)4L);
}
+11
View File
@@ -0,0 +1,11 @@
#include <pool.h>
APTR LibCreatePool(ULONG requirements, ULONG puddleSize, ULONG threshSize)
{
return AsmCreatePool(requirements,puddleSize,threshSize,*(APTR *)4L);
}
VOID LibDeletePool(APTR poolHeader)
{
AsmDeletePool(poolHeader,*(APTR *)4L);
}
+6
View File
@@ -0,0 +1,6 @@
#include <pool.h>
VOID LibFreePooled(APTR poolHeader, APTR memory, ULONG memSize)
{
AsmFreePooled(poolHeader,memory,memSize,*(APTR *)4L);
}
+11
View File
@@ -0,0 +1,11 @@
#include <exec/lists.h>
#include <clib/alib_protos.h>
VOID NewList(struct List *list)
{ LONG *p;
list->lh_TailPred=(struct Node *)list;
((LONG *)list)++;
*(LONG *)list=0;
p=(LONG *)list; *--p=(LONG)list;
}
+18
View File
@@ -0,0 +1,18 @@
#include <exec/types.h>
ULONG RangeSeed;
ULONG RangeRand(ULONG maxValue)
{ ULONG a=RangeSeed;
UWORD i=maxValue-1;
do
{ ULONG b=a;
a<<=1;
if((LONG)b<=0)
a^=0x1d872b41;
}while((i>>=1));
RangeSeed=a;
if((UWORD)maxValue)
return (UWORD)((UWORD)a*(UWORD)maxValue>>16);
return (UWORD)a;
}
+24
View File
@@ -0,0 +1,24 @@
asm("
.text
.globl _SetSuperAttrs
_SetSuperAttrs: movel a2,sp@-
moveml sp@(8:W),a0/a2
movel a2,d0
beqs L_Null
movel a0,d0
beqs L_Null
clrl sp@-
pea sp@(20:W)
pea 259:W
movel sp,a1
movel sp@(24:W),a0
jbsr L_Invoke
lea sp@(12:W),sp
L_Null: movel sp@+,a2
rts
L_Invoke: movel a0@(8:W),sp@-
rts
");
+38
View File
@@ -0,0 +1,38 @@
#include <exec/memory.h>
#include <devices/timer.h>
#include <proto/exec.h>
#define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \
/*(l)->lh_Tail = NULL,*/ \
(l)->lh_TailPred = (struct Node *)&(l)->lh_Head)
LONG TimeDelay(LONG unit,ULONG secs,ULONG microsecs)
{ APTR SysBase = *(APTR *)4L;
struct PortIO {
struct timerequest treq;
struct MsgPort port;
} *portio;
LONG ret=-1;
if ((portio=(struct PortIO *)AllocMem(sizeof(*portio),MEMF_CLEAR|MEMF_PUBLIC))) {
portio->port.mp_Node.ln_Type=NT_MSGPORT;
if ((BYTE)(portio->port.mp_SigBit=AllocSignal(-1))>=0) {
portio->port.mp_SigTask=FindTask(NULL);
NEWLIST(&portio->port.mp_MsgList);
portio->treq.tr_node.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
portio->treq.tr_node.io_Message.mn_ReplyPort=&portio->port;
if (!(OpenDevice(TIMERNAME,unit,&portio->treq.tr_node,0))) {
portio->treq.tr_node.io_Command=TR_ADDREQUEST;
portio->treq.tr_time.tv_secs=secs;
portio->treq.tr_time.tv_micro=microsecs;
if (!DoIO(&portio->treq.tr_node))
ret=0;
CloseDevice(&portio->treq.tr_node);
}
FreeSignal(portio->port.mp_SigBit);
}
FreeMem(portio,sizeof(*portio));
}
return ret;
}
+7
View File
@@ -0,0 +1,7 @@
#include <clib/alib_protos.h>
#include <proto/graphics.h>
VOID waitbeam(LONG pos)
{
do {} while(pos>VBeamPos());
}
+10
View File
@@ -0,0 +1,10 @@
#include <proto/exec.h>
STATIC const ULONG tricky=0x16c04e75; /* move.b d0,(a3)+ ; rts */
VOID sprintf(STRPTR buffer,STRPTR fmt,...)
{ APTR SysBase = *(APTR *)4L;
STRPTR *arg = &fmt+1;
RawDoFmt(fmt,arg,(void (*)())&tricky,buffer);
} /* Not very clean, but ... */
+24
View File
@@ -0,0 +1,24 @@
#ifndef _BASE_H_
#define _BASE_H_
#ifndef SMALL_DATA
#define A4(x) #x
#else
#define A4(x) "a4@(" #x ":W)"
#endif
#define GETAGBASE movel A4(_AmigaGuideBase),a6
#define GETASLBASE movel A4(_AslBase),a6
#define GETBULBASE movel A4(_BulletBase),a6
#define GETDOSBASE movel A4(_DOSBase),a6
#define GETDTBASE movel A4(_DataTypesBase),a6
#define GETGADBASE movel A4(_GadToolsBase),a6
#define GETGFXBASE movel A4(_GfxBase),a6
#define GETINTBASE movel A4(_IntuitionBase),a6
#define GETLOCBASE movel A4(_LocaleBase),a6
#define GETLOWBASE movel A4(_LowLevelBase),a6
#define GETRETBASE movel A4(_RealTimeBase),a6
#define GETUTLBASE movel A4(_UtilityBase),a6
#define GETWBBASE movel A4(_WorkbenchBase),a6
#endif _BASE_H_
+14
View File
@@ -0,0 +1,14 @@
#ifdef DEBUG_LIB
#ifndef _DEBUGLIB_H_
#define _DEBUGLIB_H_
/* Yet nothing - could be a debug-requester or something */
/*
#define FATALERROR(a)
*/
#endif
#endif
+33
View File
@@ -0,0 +1,33 @@
#include <dos/exall.h>
#include <dos/dosextens.h>
struct dirent {
ULONG d_fileno;
USHORT d_reclen;
USHORT d_namlen;
BYTE d_name[256];
};
typedef struct _dirdesc {
int dd_fd;
struct dirent dd_ent;
BPTR d_lock;
ULONG d_count;
LONG d_more;
struct ExAllControl *d_eac;
struct ExAllData *current;
union {
char ead[2048];
struct FileInfoBlock fib;
} _dirun;
} DIR;
#define d_ead _dirun.ead
#define d_info _dirun.fib
/* prototypes */
DIR *opendir(const char *dirname);
struct dirent *readdir(DIR *dirp);
void rewinddir(DIR *dirp);
int closedir(DIR *dirp);
+81
View File
@@ -0,0 +1,81 @@
/******************************************************************************/
/* */
/* special define(s) */
/* */
/******************************************************************************/
#if !defined(REG)
#define REG(reg,arg) arg __asm(#reg)
#endif
#include <exec/resident.h>
#include <exec/libraries.h>
#include <proto/exec.h>
#include "stabs.h"
/******************************************************************************/
/* */
/* structure definition for a *** PRIVATE *** library/device base */
/* */
/******************************************************************************/
struct LibBase {
struct Library LibNode;
UWORD Pad;
LONG SegList;
APTR DataSeg,
SysBase;
#ifdef EXTENDED
ULONG DataSize;
struct LibBase *Parent;
#endif
};
/******************************************************************************/
/* */
/* prototypes for basic library functions */
/* */
/******************************************************************************/
LONG LibExtFunc(VOID);
LONG LibExpunge(REG(a6,struct LibBase *));
LONG LibClose(REG(a6,struct LibBase *));
APTR LibOpen(REG(a6,struct LibBase *));
APTR LibInit(REG(a0,LONG),REG(d0,struct LibBase *),REG(a6,struct Library *));
/******************************************************************************/
/* */
/* prototypes for basic device functions */
/* */
/******************************************************************************/
APTR DevInit();
VOID DevOpen();
APTR DevClose();
APTR DevExpunge();
APTR DevExtFunc();
/******************************************************************************/
/* */
/* imports */
/* */
/******************************************************************************/
extern LONG __stdargs __UserLibInit(struct Library *,REG(a4,APTR));
extern VOID __stdargs __UserLibCleanup(REG(a4,APTR));
extern const UWORD LibVersion;
extern const UWORD LibRevision;
extern const char LibIdString[];
extern const char LibName[];
extern APTR __LibTable__[];
extern APTR __FuncTable__[];
extern LONG __datadata_relocs[];
/******************************************************************************/
/* */
/* end of libinit.h */
/* */
/******************************************************************************/
+34
View File
@@ -0,0 +1,34 @@
#include <exec/types.h>
#if defined(__GNUC__)
#define ASM
#define REG(reg,arg) arg __asm(#reg)
#else
#define ASM __asm
#define REG(reg,arg) register __##reg arg
#endif
#include <exec/lists.h>
#include <exec/memory.h>
#include <proto/exec.h>
/*
** our PRIVATE! memory pool structure
** (_NOT_ compatible with original amiga.lib!)
*/
typedef struct Pool {
struct MinList PuddleList;
ULONG MemoryFlags;
ULONG PuddleSize;
ULONG ThreshSize;
} POOL;
/*
** required prototypes ;)
*/
APTR ASM AsmCreatePool(REG(d0,ULONG),REG(d1,ULONG),REG(d2,ULONG),REG(a6,APTR));
APTR ASM AsmAllocPooled(REG(a0,POOL *),REG(d0,ULONG),REG(a6,APTR));
VOID ASM AsmFreePooled(REG(a0,POOL *),REG(a1,APTR),REG(d0,ULONG),REG(a6,APTR));
VOID ASM AsmDeletePool(REG(a0,POOL *),REG(a6,APTR));
+9
View File
@@ -0,0 +1,9 @@
void srand48(long);
unsigned short *seed48(unsigned short *);
void lcong48(unsigned short *);
long lrand48(void);
long nrand48(unsigned short *);
long mrand48(void);
long jrand48(unsigned short *);
double drand48(void);
double erand48(unsigned short *seed);
+31
View File
@@ -0,0 +1,31 @@
#define ___PUSH(a) "movel\t" #a ",sp@-\n"
#define ___POP(a) "movel\tsp@+," #a "\n"
#ifndef SMALL_DATA
#define __REGP(functype,funcname,pushlist,popval) \
asm(".even\n" ".globl _" #funcname "\n" "_" #funcname ":\n" \
pushlist "jbsr\t___" #funcname "\n" "addqw\t#" #popval ",sp\n" \
"rts\n"); functype __##funcname
#else
#define __REGP(functype,funcname,pushlist,popval) \
asm(".even\n" ".globl _" #funcname "\n" "_" #funcname ":\n" ___PUSH(a4) \
pushlist "jbsr\t_geta4\n" "jbsr\t___" #funcname "\n" "addqw\t#" #popval ",sp\n" \
___POP(a4) "rts\n"); functype __##funcname
#endif
#define REGPARM1(functype,funcname,a1,r1) \
__REGP(functype,funcname,___PUSH(r1),4) (a1)
#define REGPARM2(functype,funcname,a1,r1,a2,r2) \
__REGP(functype,funcname,___PUSH(r2)___PUSH(r1),8) (a1,a2)
#define REGPARM3(functype,funcname,a1,r1,a2,r2,a3,r3) \
__REGP(functype,funcname,___PUSH(r3)___PUSH(r2)___PUSH(r1),12) (a1,a2,a3)
#define REGPARM4(functype,funcname,a1,r1,a2,r2,a3,r3,a4,r4) \
__REGP(functype,funcname,___PUSH(r4)___PUSH(r3)___PUSH(r2)___PUSH(r1),16) (a1,a2,a3,a4)
+102
View File
@@ -0,0 +1,102 @@
#ifndef _STABS_H_
#define _STABS_H_
/* These are some macros for handling of symboltable information
*/
/* linker can use symbol b for symbol a if a is not defined */
#define ALIAS(a,b) asm(".stabs \"_" #a "\",11,0,0,0\n.stabs \"_" #b "\",1,0,0,0")
/* add symbol a to list b (type c (22=text 24=data 26=bss)) */
#define ADD2LIST(a,b,c) asm(".stabs \"_" #b "\"," #c ",0,0,_" #a )
/* Install private constructors and destructors pri MUST be -127<=pri<=127 */
#define ADD2INIT(a,pri) ADD2LIST(a,__INIT_LIST__,22); \
asm(".stabs \"___INIT_LIST__\",20,0,0," #pri "+128")
#define ADD2EXIT(a,pri) ADD2LIST(a,__EXIT_LIST__,22); \
asm(".stabs \"___EXIT_LIST__\",20,0,0," #pri "+128")
/* Add to library list */
#define ADD2LIB(a) ADD2LIST(a,__LIB_LIST__,24)
/* This one does not really handle symbol tables
* it's just pointless to write a header file for one macro
*
* define a as a label for an absolute address b
*/
#define ABSDEF(a,b) asm("_" #a "=" #b ";.globl _" #a )
/* Generate assembler stub for a shared library entry
* and add it to the jump table
* ADDTABL_X(name,...) means function with X arguments
* ADDTABL_END() ends the list
* Usage: ADDTABL_2(AddHead,a0,a1);
* No more than 4 arguments supported, use structures!
*/
#define _ADDTABL_START(name) \
asm(".globl ___" #name); \
asm("___" #name ":\tmovel a4,sp@-")
#define _ADDTABL_ARG(arg) \
asm("\tmovel " #arg ",sp@-")
#define _ADDTABL_CALL(name) \
asm("\tmovel a6@(40:W),a4"); \
asm("\tbsr _" #name)
#define _ADDTABL_END0(name,numargs) \
asm("\tmovel sp@+,a4"); \
asm("\trts"); \
ADD2LIST(__##name,__FuncTable__,22)
#define _ADDTABL_END2(name,numargs) \
asm("\taddqw #4*" #numargs ",sp"); \
asm("\tmovel sp@+,a4"); \
asm("\trts"); \
ADD2LIST(__##name,__FuncTable__,22)
#define _ADDTABL_ENDN(name,numargs) \
asm("\taddaw #4*" #numargs ",sp"); \
asm("\tmovel sp@+,a4"); \
asm("\trts"); \
ADD2LIST(__##name,__FuncTable__,22)
#define ADDTABL_0(name) \
_ADDTABL_START(name); \
_ADDTABL_CALL(name); \
_ADDTABL_END0(name,0)
#define ADDTABL_1(name,arg1) \
_ADDTABL_START(name); \
_ADDTABL_ARG(arg1); \
_ADDTABL_CALL(name); \
_ADDTABL_END2(name,1)
#define ADDTABL_2(name,arg1,arg2) \
_ADDTABL_START(name); \
_ADDTABL_ARG(arg2); \
_ADDTABL_ARG(arg1); \
_ADDTABL_CALL(name); \
_ADDTABL_END2(name,2)
#define ADDTABL_3(name,arg1,arg2,arg3) \
_ADDTABL_START(name); \
_ADDTABL_ARG(arg3); \
_ADDTABL_ARG(arg2); \
_ADDTABL_ARG(arg1); \
_ADDTABL_CALL(name); \
_ADDTABL_ENDN(name,3)
#define ADDTABL_4(name,arg1,arg2,arg3,arg4) \
_ADDTABL_START(name); \
_ADDTABL_ARG(arg4); \
_ADDTABL_ARG(arg3); \
_ADDTABL_ARG(arg2); \
_ADDTABL_ARG(arg1); \
_ADDTABL_CALL(name); \
_ADDTABL_ENDN(name,4)
#define ADDTABL_END() asm(".stabs \"___FuncTable__\",20,0,0,-1")
#endif
+116
View File
@@ -0,0 +1,116 @@
#ifndef STDIO_H
#define STDIO_H
#include <stdarg.h>
#include <string.h>
#include <exec/lists.h>
#include <exec/nodes.h>
/* Adjusted to be compatible with the bsd headers
* (At least for normal ANSI stuff)
* Member names are not the same, but they need not be :-)
*/
typedef long fpos_t;
typedef struct __FILE
{
unsigned char *p; /* pointer to actual character */
int incount; /* Bytes left in buffer for reading, writemode: 0 */
int outcount; /* Space left in buffer for writing + fp->linebufsize,
* readmode: 0
*/
short flags; /* Some flags: 0x01 line buffered
* 0x02 unbuffered
* 0x04 read mode
* 0x08 write mode
* 0x20 EOF read
* 0x40 error encountered
* 0x80 buffer malloc'ed by library
* 0x200 sprintf/sscanf buffer
*/
short file; /* The filehandle */
unsigned char *buffer; /* original buffer pointer */
int bufsize; /* size of the buffer */
int linebufsize; /* 0 full buffered
* -bufsize line buffered&write mode
* readmode: undefined */
/* from this point on not binary compatible to bsd headers */
unsigned char unget[4]; /* ungetc buffer 4 bytes necessary (for -Na*)
* ANSI requires 3 bytes (for -.*), so one more
* doesn't matter
*/
unsigned char *tmpp; /* Stored p if ungetc pending, otherwise NULL */
int tmpinc; /* Stored incount if ungetc pending, otherwise undefined */
long tmpdir; /* lock to directory if temporary file */
char *name; /* filename if temporary file */
} FILE;
#ifndef NULL
#define NULL ((void *)0l)
#endif
#define BUFSIZ 1024
#define EOF (-1)
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define _IOFBF 0
#define _IOLBF 1
#define _IONBF 2
extern FILE *fopen(const char *filename,const char *mode);
extern FILE *freopen(const char *filename,const char *mode,FILE *stream);
extern int fclose(FILE *stream);
extern int fgetc(FILE *stream);
extern int fputc(int c,FILE *stream);
extern int ungetc(int c,FILE *stream);
extern int sprintf(char *s,const char *format,...);
extern int sscanf(const char *s,const char *format,...);
extern int vprintf(const char *format,va_list args);
extern int vsprintf(char *s,const char *format,va_list args);
extern int vfprintf(FILE *stream,const char *format,va_list args);
extern int vscanf(const char *format,va_list args);
extern int vsscanf(const char *s,const char *format,va_list args);
extern int vfscanf(FILE *stream,const char *format,va_list args);
extern int snprintf(char *s,size_t size,const char *format,...);
extern int vsnprintf(char *s,size_t size,const char *format,va_list args);
extern int fseek(FILE *stream,long int offset,int whence);
extern int fputs(const char *s,FILE *stream);
extern long int ftell(FILE *stream);
extern int setvbuf(FILE *stream,char *buf,int mode,unsigned long size);
extern int fread(void *,unsigned long,unsigned long,FILE *);
extern int fwrite(const void *,unsigned long,unsigned long,FILE *);
/* More bsd headers compatibility */
extern int __swbuf(int c,FILE *stream);
extern int __srget(FILE *stream);
extern FILE **__sF; /* Standard I/O streams */
#define stdin (__sF[0]) /* Other streams are not in __sF */
#define stdout (__sF[1])
#define stderr (__sF[2])
/* Be careful: We have side effects and use incount in __srget -
must use comma-operator */
#define getc(fp) ((fp)->incount--,(fp)->incount>=0?(int)*(fp)->p++:__srget(fp))
#define putc(c,fp) \
((fp)->outcount--,(fp)->outcount>=0|| \
((fp)->outcount>=(fp)->linebufsize&&(char)(c)!='\n')? \
*(fp)->p++=(c):__swbuf((c),(fp)))
#define ferror(fp) ((fp)->flags&64)
#define feof(fp) ((fp)->flags&32)
/* own stuff */
extern struct MinList __filelist; /* List of all fopen'ed files */
extern unsigned long *__stdfiledes; /* List of Amiga OS filehandles */
extern struct MinList __memorylist; /* List of memory puddles */
extern int __fflush(FILE *stream); /* fflush single file */
extern void __chkabort(void); /* check for SIGABRT */
struct filenode /* objects in __filelist */
{
struct MinNode node;
FILE FILE;
};
#endif
+164
View File
@@ -0,0 +1,164 @@
#ifndef _STRSUP_H
#define _STRSUP_H
#include <sys/types.h>
#ifdef __OPTIMIZE__
extern __inline__ void *memcpy(void *s1,const void *s2,size_t n)
{ register char *a6 __asm("a6") = *(char **)4;
register const void *a0 __asm("a0") = s2;
register const void *a1 __asm("a1") = s1;
register size_t d0 __asm("d0") = n;
__asm __volatile ("jsr a6@(-0x270)"
: /* no output */
: "r" (a6), "r" (a0), "r" (a1), "r" (d0)
: "a0","a1","d0","d1", "memory");
return s1;
}
extern __inline__ void *memmove(void *s1,const void *s2,size_t n)
{ extern void bcopy();
bcopy(s2,s1,n); return s1;
}
extern __inline__ void *memset(void *s,int c,size_t n)
{
if (n) {
unsigned char *p=s;
do;while(*p++=c,--n);
}
return s;
}
extern __inline__ int memcmp(const void *s1,const void *s2,size_t n)
{ const unsigned char *p1=s1,*p2=s2;
unsigned long r,c;
if ((r=n))
do;while(r=*p1++,c=*p2++,!(r-=c) && --n);
return r;
}
extern __inline__ void *memchr(const void *s,int c,size_t n)
{
if (n) {
unsigned char *p=(unsigned char *)s;
do {
if (*p++==(unsigned char)c)
return --p;
} while(--n);
}
return (void *)n;
}
extern __inline__ size_t strlen(const char *string)
{ const char *s=string;
do;while(*s++); return ~(string-s);
}
extern __inline__ char *strcpy(char *s1,const char *s2)
{ char *s=s1;
#if 0
do;while(*s1++=*s2,*s2++!='\0');
#else
do;while((*s1++=*s2++));
#endif
return s;
}
extern __inline__ char *strncpy(char *s1,const char *s2,size_t n)
{
if (n) {
char *s=s1;
do;while((*s++=*s2++) && --n);
if (n)
while(--n) *s++=0;
}
return s1;
}
extern __inline__ char *strcat(char *s1,const char *s2)
{ char *s=s1;
do;while(*s++); --s; do;while((*s++=*s2++)); return s1;
}
extern __inline__ char *strncat(char *s1,const char *s2,size_t n)
{
if (n) {
char *s=s1;
do;while(*s++); --s;
for(;;) {
if (!(*s++=*s2++))
return s1;
if (!--n) {
*s=0; return s1;
}
}
}
return s1;
}
extern __inline__ int strcmp(const char *s1,const char *s2)
{ unsigned char *p1=(unsigned char *)s1, *p2=(unsigned char *)s2;
unsigned long r,c;
do;while(r=*p1++,c=*p2++,!(r-=c) && (char)c); return r;
}
extern __inline__ int strncmp(const char *s1,const char *s2,size_t n)
{ unsigned char *p1=(unsigned char *)s1,*p2=(unsigned char *)s2;
unsigned long r,c;
if ((r=n))
do;while(r=*p1++,c=*p2++,!(r-=c) && (char)c && --n);
return r;
}
#if 0
extern __inline__ char *strchr(const char *s,int c)
{
while (*s!=(char)c)
if (!*s++)
return (char *)0;
return (char *)s;
}
#endif
extern __inline__ char *strupr(char *s)
{ unsigned char *s1=(unsigned char *)s;
while(*s1) {
if ((*s1>('a'-1)) && (*s1<('z'+1)))
*s1-='a'-'A';
s1++;
}
return s;
}
extern __inline__ char *strlwr(char *s)
{ unsigned char *s1=(unsigned char *)s;
while(*s1) {
if ((*s1>('A'-1)) && (*s1<('Z'+1)))
*s1+='a'-'A';
s1++;
}
return s;
}
extern __inline__ char *stpcpy(char *dst,char *src)
{
do;while((*dst++=*src++)); return(--dst);
}
#endif /* __OPTIMIZE__ */
static __inline__ size_t strlen_plus_one(const char *string)
{ const char *s=string;
do;while(*s++); return (s-string);
}
#endif /* _STRSUP_H */
+308
View File
@@ -0,0 +1,308 @@
B=Bugfix
S=Specification changed
P=Performance gain
M=Memory gain
F=New Feature
Start (V0.1)
B A symbol and it's indirected counterpart cannot be used both - fixed.
B __stdio.c used the wrong flag for testing if filehandle has to be closed
so the standard filehandle was closed three times - fixed.
P memchr.c changed - the C code looks not very good, but the assembler
code is very smart now.
F Half initialized local arrays reference bzero() - added.
M malloc now rounds even _MSTEP up to full MMU page.
P strcat(),strncat(),strcpy(),strncpy(),strchr(),strrchr() rewritten in asm.
B strcmp(),strncmp() work on signed char - fixed.
P Removed __chkabort() in fgetc() and fputc() - it's not necessary to poll
CTRL-C for EVERY character written.
B Extraneous semicolon (';') in freopen() deleted.
M Changed the code for setting buffer flags in setvbuf().
B setvbuf() should set the buffer size ;-) - fixed.
S _main() has the commandline as argument INCLUDING the program's name.
Had to change the interface - easiest way was to rename _main as __submain
and write a new __submain calling _main. Moved the call to open
the shared libraries out of the startups, too.
S The private library bases now have two '_'.
B libm.a needs the private library bases, too.
S Some changes for Gerhard's gerlib: All I/O functions now run over
a unix-alike interface. The standard I/O streams now use fopen.
F Added setbuffer() to be able to compile gas1.38 .
F changed 'static char *errorlist[]' to 'char *sys_errlist[]' for better
compatibility. Added 'int sys_nerr' too :-P.
F Rewrote documentation & some new chapters in texinfo format.
F Changed the directory structure to the distribution form.
Added a 'distribution' makefile entry.
V0.2
B Adjusted global makefile for auto detach startups.
F specs file added.
F The gcc frontend has libgcc.a hardcoded. Added a stub libgcc.a to get
specs file to work.
B gas writes EOF and expects it to be handled as 0xff - fixed.
B Symbol redirections didn't work the way I expected - removed most of them.
B -lm links libm.a BEFORE libnix. Moved some functions.
B vfscanf() does no longer ungetc EOF
M Optimized __udivsi3, __umodsi3, __divsi3, __modsi3, div, ldiv.
F Some functions added to libamiga.a.
V0.3
B strtod() gave a warning - fixed.
B strftime() didn't count correctly - fixed.
M Optimized atan2, fmod, strlen.
B Bug in makefile for the math libraries - fixed.
F The low level standard-I/O functions are now posix compliant.
F access(), stricmp(), unlink(), fstat(), bcmp() added.
V0.4
B Fixed bug in fstat().
B Bugs in fread() and fwrite() when processing no data at all - fixed.
P Added an inline version of strlen() in vfprintf, vsscanf, strxfrm, setlocale.
M Rewrote all stub functions as symbol redirections to a single one.
F strcasecmp() added.
S moved __modsi3, __umodsi3 into the div-equivalents.
B A missing locale.library should not cause a program exit - fixed.
B asctime used 'c' instead of 'C' - fixed.
B strftime didn't work correctly on numbers longer than 2 characters - fixed.
B Some additional work on the low level I/O needed.
S Did some work on the startups.
S The auto-detach startups had some holes. I removed them
from distribution until I get a better method :'(.
V0.5
F Added Open("*",MODE_NEWFILE) as a fallback for process->pr_CES.
F strdup, stricmp, strlower, strnicmp, strupper added.
(first official release)
B Fixed a bug in the low-level-I/O cleanup routine.
B Added more error handling to open().
M Changed the kludge in the library startup module.
F Added optional support for Un*x style pathnames.
B Bug in the low-level-I/O cleanup function fixed.
B Yet another bug in strftime() fixed.
M Optimized the standard I/O initialization.
S Changed the disk layout for better handling of different library compilations.
B The glue code generator didn't work correctly on void-'...'-functions - fixed.
B Bug in freopen when using mode "w" on a already existing file fixed.
S Cleaned the __initlibraries function up.
F Hook and boopsi functions added to libamiga.a.
B The commandline parser overwrote the __commandline variable
(this is not a real bug but a NASTY feature) - fixed.
F Auto-detach reintegrated (clean this time) as an object module.
F FastRand and RangeRand added to libamiga.a.
B LocaleBase was defined twice - fixed.
B Moved __decimalpoint from libm.a into libnix.a.
F Added 3.1 system libraries to libstubs.a
F Added Un*x functions (mkdir,chdir,rmdir,getwd,getcwd,opendir,readdir,closedir)
S main and _exit implemented with symbol redirection. This gives full C++ support
with libg++.a.
F Added support for shared amiga-library creation (library and device initcode)
V0.6
F Added a stackswap-module
S Changed stat() to work silently (now suppresses all *DOS* requesters)
B Fixed a bug in __swbuf() - overrun buffersize by one character, oops...
B __chkabort() didn't clear ctrl-c signal - fixed
S signal handling heavily changed - now more unix-like
F Added default values to libstubs.a for some by certain modules used variables
(__stack, _procname, __priority)
S moved redirection of 'main' to '_main' into a separate file (in libnix_main.a)
B improved precision of vfprintf.
B fixed returncode of vfscanf on EOF
F version string added to libnix.a
V0.7 (second official release)
B fseek didn't clear the EOF flag.
S Dropped the ChangeMode call in open(). Now mode "a" files have a shared lock,
but the other method didn't work with all handlers :-(.
B Made fread() and fwrite() buffered.
S Got rid of those ARexx-scripts when building the library :-). Now you can
build libnix on a sun using a cross-compiler.
B Fixed some holes in the commandline parser that could give empty arguments.
F Prepared startups for the third argument of main(int argc,char *argv[],char *env[]).
It's not supported, but you could now ;-).
B Fixed a bug in the floating point part of vprintf (introduced with the last
revision :-( ).
F fileno() and fdtofh() added.
F Version string added to ALL the modules - let's see if this hack works :-).
V0.8 (third official release)
B Fixed the returncode of close(STDIN_FILENO) and errno after lseek().
B fflush(NULL) flushed stdout and stderr twice - fixed.
B Fixed a bug in atan2().
F All libnix requesters now check pr_WindowPtr first.
S Moved __chkabort() one level down into read(), write(), lseek().
B Fixed missing terminator in strncat().
F Added code to handle stackextension/checking :-).
S Changed all includes to use proto/ instead of inline/
V0.9
B ANSI demands flushing of line or unbuffered output files write reading from
line buffered input.
B Fixed the bug that wrote weird characters for floats on some machines -
the system math libraries don't work correct if you open them in alphabetical
order (like the computer generated libstubs.a did - thanks ls :-( ).
M Optimized the commandline parsers and shared library opener.
M Removed some unused prototypes in C-files.
V1.0
B If no characters are read gets() should return NULL. Dropped unnecessary
ferror() call in fgets by the way.
B strtoul() read characters which were invalid for the current base.
S switched from fputs() to write(2,..) in raise()
F addded a bunch of non-ansi function (mktemp,getrusage,etc.)
F snprintf() and vsnprintf() added.
F Added CPU check with error requester for the non-68000 versions (changed
startups, too).
V1.1
F cache flush function for gcc support added
B fixed a macro in stabs.h for shared library support
F replaced asm functions for automatic library with c functions
F updated support functions for amiga.lib
F code cleanup
V1.1a
B fixed "off-by-one" error of portable strncpy()
B fixed open() so that it ignores stdio slots now
V1.1b
B fixed longjmp() not returning 1 if passed a 0
M changed automatic library opening once again ;(
(moved openliberror() function into __initlibraries source)
P tweaked string functions and removed some asm versions
P updated headers/strsup.h with new string functions
F moved all 1.3 compatibility stuff into a separate lib called libnix13.a
(contains integer math functions eg. useful for linking with -nostdlib)
S added some const qualifiers at several places
F tweaked libamiga.a functions
F rewrote libinit.c, libinitr.c and devinit.c (requires ADE/GG GCC 2.7.2.1 or up)
F added three math functions from vc.lib: frexp.c, ldexp.c and modf.c
B fixed serious bug in atol() and atoi()
S added "/WAIT" to default stdiowin options
(suggested by Martin Hauner)
V1.2
+71
View File
@@ -0,0 +1,71 @@
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CPP = @CPP@
AS = as
RANLIB = @RANLIB@
AWK = @AWK@
#### End system configuration section ####
ifneq ($(TARGET),clean)
include ../../sources/math/filelist
endif
CURDIR = $(shell pwd)
OPTIONS=-I $(srcdir)/../headers -I ../../sources/headers -DFULL_SPECIFIERS $(CFLAGS)
SOURCEFILES=*/*
OBJECTS2=$(OBJECTS) \
../nix/stdio/printf.o ../nix/stdio/fprintf.o ../nix/stdio/sprintf.o \
../nix/stdio/vprintf.o ../nix/stdio/vsprintf.o stdio/vfprintf.o \
../nix/stdio/scanf.o ../nix/stdio/fscanf.o ../nix/stdio/sscanf.o \
../nix/stdio/vscanf.o ../nix/stdio/vsscanf.o stdio/vfscanf.o
SUBDIRS2=$(SUBDIRS) ../nix/stdio
REDEF=-D_DOSBase=___DOSBase \
-D_UtilityBase=___UtilityBase \
-D_MathIeeeSingBasBase=___MathIeeeSingBasBase \
-D_MathIeeeSingTransBase=___MathIeeeSingTransBase \
-D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \
-D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \
-D_LocaleBase=___LocaleBase
%.o: %.c
$(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err
$(CPP) -traditional $(REDEF) $*.S -o $*2.S
$(CC) $(OPTIONS) $*2.S -c -o $*.o
-rm $*.S $*2.S
-if test ! -s $*.err; then rm $*.err; fi
.PHONY: all clean veryclean
all: libm.a
clean:
-rm -rf $(SUBDIRS2)
veryclean:
-rm -rf *
$(foreach f,$(SUBDIRS2),$(CURDIR)/$(f)):
mkdir $@
libm.a: $(foreach f,$(SUBDIRS2),$(CURDIR)/$(f)) $(OBJECTS2) ../../sources/math/makefile ../../sources/math/filelist
-rm -f $@
ar -q $@ $(OBJECTS2)
$(RANLIB) $@
echo "\$$$(V)" >>$@
stdio/vfprintf.o: $(srcdir)/../nix/stdio/vfprintf.c
$(CC) $(OPTIONS) $^ -c -o stdio/vfprintf.o
stdio/vfscanf.o: $(srcdir)/../nix/stdio/vfscanf.c
$(CC) $(OPTIONS) $^ -c -o stdio/vfscanf.o
+27
View File
@@ -0,0 +1,27 @@
#undef __HAVE_68881__
#include <math.h>
double frexp(double x,int *p)
{
int neg,j;
j=neg=0;
if(x<0){
x=-x;
neg=1;
}
if(x>=1){
while(x>=1){
j++;
x/=2;
}
}else if(x<0.5&&x!=0){
while(x<0.5){
j--;
x*=2;
}
}
*p = j;
if(neg) x=-x;
return x;
}
+36
View File
@@ -0,0 +1,36 @@
#undef __HAVE_68881__
#include <math.h>
#define MANT_MASK 0x800FFFFF /* Mantissa extraction mask */
#define ZPOS_MASK 0x3FF00000 /* Positive # mask for exp = 0 */
#define ZNEG_MASK 0x3FF00000 /* Negative # mask for exp = 0 */
#define EXP_MASK 0x7FF00000 /* Mask for exponent */
#define EXP_SHIFTS 20 /* Shifts to get into LSB's */
#define EXP_BIAS 1023 /* Exponent bias */
union dtol
{
double dval;
int ival[2];
};
double ldexp (double x,int n)
{
union dtol number;
int *iptr, cn;
if (x == 0.0)
return (0.0);
else
{
number.dval = x;
iptr = &number.ival[0];
cn = (((*iptr) & EXP_MASK) >> EXP_SHIFTS) - EXP_BIAS;
*iptr &= ~EXP_MASK;
n += EXP_BIAS;
*iptr |= ((n + cn) << EXP_SHIFTS) & EXP_MASK;
return (number.dval);
}
}
+13
View File
@@ -0,0 +1,13 @@
#undef __HAVE_68881__
#include <math.h>
double modf(double x,double *p)
{
if(x<0){
*p=ceil(x);
return(*p-x);
}else{
*p=floor(x);
return(x-*p);
}
}
+232
View File
@@ -0,0 +1,232 @@
/* Random number generation using the linear congruential algorithm
X(n+1) = (a * X(n) + c) mod m
with a precision of 48 bits.
Author: Kriton Kyrimis (kyrimis@theseas.softlab.ece.ntua.gr)
Code status: Public Domain.
*/
#include <limits.h>
#include <float.h>
/* Parameters for the linear congruential algorithm:
parm[0..2] is the current value of Xn (internal seed, m.s.word last)
parm[3..5] is the value of a (m.s.word last)
parm[6] is the value of c.
*/
#define X0 0x1234 /* MSB * Initial value for Xn, obtained using seed48() */
#define X1 0xABCD /* on SunOS 4.1.3 */
#define X2 0x330E
#define A0 0x0005 /* MSB * Default value for a, taken from the man page */
#define A1 0xDEEC
#define A2 0xE66D
#define C0 0x000B /* Default value for c, taken from the man page */
static unsigned short parm[7] = {
X2, X1, X0,
A2, A1, A0,
C0
};
/* To produce a double random number in [0,1) we get a 32-bit unsigned long
random number, convert it to double, and divide it by ULONG_MAX + EPSILON.
(We add the EPSILON to exclude 1.0 from the set of possible results.)
We derive EPSILON by noting that for a random value of ULONG_MAX,
we want to return the smallest double that is less than 1.0.
Therefore:
ULONG_MAX
--------------------- = (1.0 - DBL_EPSILON)
(ULONG_MAX + EPSILON)
(This is probably overkill.)
*/
#define EPSILON (double)ULONG_MAX*(1.0/(1.0-DBL_EPSILON)-1.0)
/*--------------------------------------------------------------------------*
* Parameter initialization functions *
*--------------------------------------------------------------------------*/
/* This function sets the two m.s.words of the internal seed to the value
supplied by the caller, and the l.s.word of the internal seed to 0x330E.
*/
void
srand48(long seed)
{
parm[0] = 0x330E;
parm[1] = ((unsigned long)seed) & 0xFFFF;
parm[2] = ((unsigned long)seed >> 16) & 0xFFFF;
parm[3] = A2;
parm[4] = A1;
parm[5] = A0;
parm[6] = C0;
}
/* This function sets all three words of the internal seed to the value
supplied by the caller. It returns a pointer to an array containing
a copy of the previous value of the internal seed.
*/
unsigned short *
seed48(unsigned short *seed)
{
static unsigned short oldparm[3];
unsigned short tmpparm[3];
/* Can't assign oldparm[] = parm[] directly, because seed[] may be a pointer
to oldparm[], obtained from a previous call to seed48 , in which case
we would destroy the contents of seed[] */
tmpparm[0] = parm[0];
tmpparm[1] = parm[1];
tmpparm[2] = parm[2];
parm[0] = seed[0];
parm[1] = seed[1];
parm[2] = seed[2];
oldparm[0] = tmpparm[0];
oldparm[1] = tmpparm[1];
oldparm[2] = tmpparm[2];
parm[3] = A2;
parm[4] = A1;
parm[5] = A0;
parm[6] = C0;
return oldparm;
}
/* This function sets all seven words of the internal parameters array to the
values supplied by the caller.
*/
void
lcong48(unsigned short *new_parm)
{
parm[0] = new_parm[0];
parm[1] = new_parm[1];
parm[2] = new_parm[2];
parm[3] = new_parm[3];
parm[4] = new_parm[4];
parm[5] = new_parm[5];
parm[6] = new_parm[6];
}
/*--------------------------------------------------------------------------*
* Random number generator *
*--------------------------------------------------------------------------*/
/* This function implements the linear congruential algorithm. Thanks to
gcc's long long ints, implementing 48-bit arithmetic (actually 64-bit,
truncating the result) is trivial. Limitations of long long int
implementation in (amiga?) gcc 2.7.0, made me use the kludge with the union
to convert from short[3] to long long int. (It's probably faster though!)
This function takes an array of three shorts (a 48-bit seed, m.s.word
last) and returns a long between -2**31 and 2**31-1, updating the seed
(the result is the two m.s.words of the updated seed).
*/
static long
rng(unsigned short *seed)
{
long long int Xn, Xn1, a, c;
union {
long long int l;
unsigned short s[4];
} i;
i.s[0] = 0;
i.s[1] = seed[2];
i.s[2] = seed[1];
i.s[3] = seed[0];
Xn = i.l;
i.s[0] = 0;
i.s[1] = parm[5];
i.s[2] = parm[4];
i.s[3] = parm[3];
a = i.l;
c = (long long int)(parm[6]);
Xn1 = a * Xn + c;
i.l = Xn1;
seed[0] = i.s[3];
seed[1] = i.s[2];
seed[2] = i.s[1];
return (long)((((unsigned long)seed[2]) << 16) + seed[1]);
}
/*--------------------------------------------------------------------------*
* Interface functions to the random number generator *
*--------------------------------------------------------------------------*/
/* This function returns a long between 0 and 2**31-1 by calling rng
with the internal seed, returning the 15 most significant bits of the
result shifted by one position to the right.
*/
long
lrand48(void)
{
return (rng(parm) >> 1) & 0x7FFFFFFF;
}
/* Same as lrand48(), but using an external seed. */
long
nrand48(unsigned short seed[3])
{
return (rng(seed) >> 1) & 0x7FFFFFFF;
}
/* This function returns a long between -2**31 and 2**31-1 by calling rng
with the internal seed.
*/
long
mrand48(void)
{
return rng(parm);
}
/* Same as mrand48(), but using an external seed. */
long
jrand48(unsigned short seed[3])
{
return rng(seed);
}
/* This function returns a double in the interval [0,1) by calling mrand48()
and dividing the result by ULONG_MAX + EPSILON. */
double
drand48(void)
{
union {
long l;
unsigned long u;
} x;
x.l = mrand48();
return (double)x.u / ((double)(ULONG_MAX) + EPSILON);
}
/* Same as drand48(), but using an external seed. */
double
erand48(unsigned short seed[3])
{
union {
long l;
unsigned long u;
} x;
x.l = nrand48(seed);
return (double)x.u / ((double)(ULONG_MAX) + EPSILON);
}
+5
View File
@@ -0,0 +1,5 @@
int isinf(double a)
{
unsigned long *b=(unsigned long *)&a;
return (b[0]&0x7ff00000)==0x7ff00000&&!(b[0]&0xfffff)&&!b[1];
}
+5
View File
@@ -0,0 +1,5 @@
int isnan(double a)
{
unsigned long *b=(unsigned long *)&a;
return (b[0]&0x7ff00000)==0x7ff00000&&((b[0]&0xfffff)||b[1]);
}
+7
View File
@@ -0,0 +1,7 @@
#include <stdio.h>
double atof(const char *nptr)
{ double a;
sscanf(nptr,"%lf",&a);
return a;
}
+10
View File
@@ -0,0 +1,10 @@
#include <stdio.h>
double strtod(const char *nptr,char **endptr)
{ double a;
unsigned long n=0;
sscanf(nptr,"%lf%ln",&a,&n);
if(endptr)
*endptr=(char *)nptr+n;
return a;
}
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double acos(double x)
{ return IEEEDPAcos(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double asin(double x)
{ return IEEEDPAsin(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double atan(double x)
{ return IEEEDPAtan(x); }
+12
View File
@@ -0,0 +1,12 @@
#include <proto/mathieeedoubtrans.h>
#define PI 3.14159265358979323846
static inline double atan(double x)
{ return IEEEDPAtan(x); }
double atan2(double y,double x)
{ return x>=y?(x>=-y? atan(y/x): -PI/2-atan(x/y)):
(x>=-y? PI/2-atan(x/y):y>=0? PI +atan(y/x):
-PI +atan(y/x));
}
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubbas.h>
double ceil(double x)
{ return IEEEDPCeil(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double cos(double x)
{ return IEEEDPCos(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double cosh(double x)
{ return IEEEDPCosh(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double exp(double x)
{ return IEEEDPExp(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubbas.h>
double fabs(double x)
{ return IEEEDPAbs(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubbas.h>
double floor(double x)
{ return IEEEDPFloor(x); }
+16
View File
@@ -0,0 +1,16 @@
#include <proto/mathieeedoubbas.h>
static inline double floor(double x)
{ return IEEEDPFloor(x); }
static inline double ceil(double x)
{ return IEEEDPCeil(x); }
double fmod(double x,double y)
{
double a=x/y;
if(a>=0)
return x-y*floor(a);
else
return x-y*ceil(a);
}
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double log(double x)
{ return IEEEDPLog(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double log10(double x)
{ return IEEEDPLog10(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double pow(double x,double y)
{ return IEEEDPPow(y,x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double sin(double x)
{ return IEEEDPSin(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double sinh(double x)
{ return IEEEDPSinh(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double sqrt(double x)
{ return IEEEDPSqrt(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double tan(double x)
{ return IEEEDPTan(x); }
+4
View File
@@ -0,0 +1,4 @@
#include <proto/mathieeedoubtrans.h>
double tanh(double x)
{ return IEEEDPTanh(x); }
+49
View File
@@ -0,0 +1,49 @@
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CPP = @CPP@
AS = as
RANLIB = @RANLIB@
AWK = @AWK@
#### End system configuration section ####
OBJECTS=detach.o swapstack.o
OPTIONS=-I $(srcdir)/../headers -I../../sources/headers $(CFLAGS)
vpath %.c $(SOURCEDIR)
REDEF=-D_DOSBase=___DOSBase \
-D_UtilityBase=___UtilityBase \
-D_MathIeeeSingBasBase=___MathIeeeSingBasBase \
-D_MathIeeeSingTransBase=___MathIeeeSingTransBase \
-D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \
-D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \
-D_LocaleBase=___LocaleBase
#Use private library bases to avoid naming collisions
%.o: %.c
$(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err
$(CPP) -traditional $(REDEF) $*.S -o $*2.S
$(CC) $(OPTIONS) $*2.S -c -o $*.o
-rm $*.S $*2.S
-if test ! -s $*.err; then rm $*.err; fi
echo "\$$$(V)" >>$*.o
.PHONY: all filelist subdirs clean veryclean
all: $(OBJECTS)
filelist:
subdirs:
clean:
-rm -f *.o *.err
veryclean: clean
+86
View File
@@ -0,0 +1,86 @@
#include <exec/memory.h>
#include <dos/dostags.h>
#include <dos/dosextens.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stabs.h>
/* Sorry, but the assembler code produced by gcc for this function is too bad.
* This one is much better!
*/
#ifdef CreateNewProcTags
#undef CreateNewProcTags
static APTR createnewproctags(APTR DOSBase,ULONG Tag,...)
{ return CreateNewProc((struct TagItem *)&Tag); }
#define CreateNewProcTags(tag...) createnewproctags(DOSBase,tag)
#endif
extern struct WBStart *_WBenchMsg;
extern char *__commandline;
extern void *__SaveSP;
extern char __dosname[];
extern char *__procname;
extern long __priority;
extern unsigned long __stack;
/* I must close a library after my child is running -
* and closing a library requires a working dispatcher (IMHO).
* Also semaphores are much smarter ;). Therefore:
*/
static struct SignalSemaphore *sem = NULL;
void __initdetach(void)
{ struct Library *DOSBase,*SysBase = *(struct Library **)4;
struct SignalSemaphore *sema;
if (_WBenchMsg)
return;
if ((sema=sem)) { /* I must be the child process */
ObtainSemaphore(sema); /* Assert that my parent is already dead */
ReleaseSemaphore(sema);
FreeMem(sema,sizeof(*sema));
return;
}
/* I must be the parent */
if ((sem=sema=(struct SignalSemaphore *)AllocMem(sizeof(*sema),MEMF_PUBLIC|MEMF_CLEAR))) {
InitSemaphore(sema);
if ((DOSBase=OpenLibrary(__dosname,37))) {
struct CommandLineInterface *cli = Cli();
APTR pr,stack = __SaveSP;
ObtainSemaphore(sema); /* Assert that my child is suspended until I'm finished */
pr = CreateNewProcTags(NP_Seglist,cli->cli_Module, /* child process gets my seglist */
NP_FreeSeglist,1, /* and must free it */
NP_Cli,1, /* it must be a CLI process */
NP_StackSize,__stack, /* it gets a stack */
NP_Name,(ULONG)__procname, /* a name */
NP_Priority,__priority, /* a priority */
NP_Arguments,(ULONG)__commandline,/* and my commandline Arguments */
TAG_END);
CloseLibrary(DOSBase);
if (pr) {
cli->cli_Module = 0; /* I'm no longer owner of this */
/* Adjust stack, release semaphore and return 0 in one.
* Maybe the 3 movel are a bit too cautious, but they ARE working
*/
asm("movel %0,sp;movel %1,a6;movel %2,a0;moveql #0,d0;jmp a6@(-570)"::
"r"(stack),"r"(SysBase),"r"(sema):"sp","a6","a0");
}
ReleaseSemaphore(sema); /* Again only caution - you never know */
}
FreeMem(sema,sizeof(*sema)); /* Couldn't start child :( */
}
exit(20);
}
ADD2INIT(__initdetach,-70); /* A very high priority */
+104
View File
@@ -0,0 +1,104 @@
#include <exec/memory.h>
#include <dos/dosextens.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdlib.h>
#include "stabs.h"
/*
* swapstack.c
*
* A libnix startup module to swap to a new stack if the old one is not
* big enough (minimum value set by the value of the __stack variable).
*
* WARNING!
* Compile with -O3, or your Amiga will explode!
*
* Code derived from a stackswap module by Kriton Kyrimis (kyrimis@theseas.ntua.gr)
* with some changes to work with the libnix startups (MF).
* You use it at your own risk.
*
* Usage: Define some variable 'unsigned long __stack={desired size};'
* somewhere in your code and link with this module.
* The file stabs.h is in the headers directory of the libnix sources.
*/
extern unsigned long __stack;
void __request(const char *text);
static struct StackSwapStruct stack;
static char *newstack;
void __stkinit(long a)
{ APTR SysBase = *(APTR *)4;
register char *sp asm("sp");
ULONG size,needed=__stack;
struct Process *pr;
char *new;
asm("":"=r"(sp)); /* touch sp to get compiler happy */
/* Determine original stack size */
pr=(struct Process *)FindTask(NULL);
size = (char *)pr->pr_Task.tc_SPUpper - (char *)pr->pr_Task.tc_SPLower;
if (pr->pr_CLI) {
size = *(ULONG *)pr->pr_ReturnAddr;
}
if (needed <= size)
return;
/* Round size to next long word */
needed = (needed+(sizeof(LONG)-1))&~(sizeof(LONG)-1);
/* Allocate new stack */
newstack = new = AllocVec(needed,MEMF_PUBLIC);
if (!new) {
__request("Couldn't allocate new stack!");
exit(RETURN_FAIL);
}
/* Build new stack structure */
size=(char *)&a-sp+2*sizeof(ULONG);
stack.stk_Lower =new;
stack.stk_Upper =(ULONG)(new+=needed);
stack.stk_Pointer=(APTR)(new-=size);
/* Copy required parts of old stack */
CopyMem(sp,new,size);
/* Switch to new stack */
StackSwap(&stack);
}
void __stkexit(ULONG a)
{ APTR SysBase = *(APTR *)4;
register char *sp asm("sp");
ULONG size;
char *new;
asm("":"=r"(sp)); /* touch sp to get compiler happy */
if(!(new=newstack))
return;
/* Prepare old stack */
size=(char *)&a-sp+3*sizeof(ULONG);
stack.stk_Pointer=(APTR)((char *)stack.stk_Pointer-size);
/* Copy required parts of current stack */
CopyMem(sp,stack.stk_Pointer,size);
/* Switch back to old stack */
StackSwap(&stack);
/* And clean up */
FreeVec(new);
}
/* The same priority as the detach module - you cannot use them both */
ADD2INIT(__stkinit,-70);
ADD2EXIT(__stkexit,-70);
+57
View File
@@ -0,0 +1,57 @@
#### Start of system configuration section. ####
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
CPP = @CPP@
AS = as
RANLIB = @RANLIB@
AWK = @AWK@
#### End system configuration section ####
ifneq ($(TARGET),clean)
include ../../sources/nix/filelist
endif
CURDIR = $(shell pwd)
OPTIONS=-I $(srcdir)/../headers -I ../../sources/headers $(CFLAGS)
SOURCEFILES=*/*
REDEF=-D_DOSBase=___DOSBase \
-D_UtilityBase=___UtilityBase \
-D_MathIeeeSingBasBase=___MathIeeeSingBasBase \
-D_MathIeeeSingTransBase=___MathIeeeSingTransBase \
-D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \
-D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \
-D_LocaleBase=___LocaleBase
%.o: %.c
$(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err
$(CPP) -traditional $(REDEF) $*.S -o $*2.S
$(CC) $(OPTIONS) $*2.S -c -o $*.o
-rm $*.S $*2.S
-if test ! -s $*.err; then rm $*.err; fi
.PHONY: all clean veryclean
all: libnix.a
clean:
-rm -rf $(SUBDIRS)
veryclean:
-rm -rf *
$(foreach f,$(SUBDIRS),$(CURDIR)/$(f)):
mkdir $@
libnix.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) ../../sources/nix/makefile ../../sources/nix/filelist
-rm -f $@
ar -q $@ $(OBJECTS)
$(RANLIB) $@
echo "\$$$(V)" >>$@
+10
View File
@@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdarg.h>
void __eprintf(const char *format,...) /* for asserts */
{ va_list args;
va_start(args,format);
vfprintf(stderr,format,args);
va_end(args);
abort();
}
+22
View File
@@ -0,0 +1,22 @@
unsigned char __ctype[]=
{ 0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x28,0x28,0x28,0x28,0x28,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x88,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x41,0x41,0x41,0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x10,0x10,0x10,0x10,
0x10,0x42,0x42,0x42,0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x10,0x10,0x10,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x00,0x00,0x00
};
const unsigned char *_ctype_=__ctype;
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isalnum(int c)
{ return _ctype_[1+c]&7; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isalpha(int c)
{ return _ctype_[1+c]&3; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int iscntrl(int c)
{ return _ctype_[1+c]&32; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isdigit(int c)
{ return _ctype_[1+c]&4; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isgraph(int c)
{ return _ctype_[1+c]&23; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int islower(int c)
{ return _ctype_[1+c]&2; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isprint(int c)
{ return _ctype_[1+c]&151; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int ispunct(int c)
{ return _ctype_[1+c]&16; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isspace(int c)
{ return _ctype_[1+c]&8; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isupper(int c)
{ return _ctype_[1+c]&1; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int isxdigit(int c)
{ return _ctype_[1+c]&68; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int tolower(int c)
{ return _ctype_[1+c]&1?c+'a'-'A':c; }
+4
View File
@@ -0,0 +1,4 @@
extern char *_ctype_;
int toupper(int c)
{ return _ctype_[1+c]&2?c+'A'-'a':c; }
+77
View File
@@ -0,0 +1,77 @@
#include <errno.h>
#include <dos/dosasl.h>
#include <proto/dos.h>
/* Table to convert amigados error messages to unix ones */
extern int errno;
static long _errortable[]=
{
ERROR_NO_FREE_STORE ,ENOMEM,
ERROR_TASK_TABLE_FULL ,EPROCLIM,
/*ERROR_BAD_TEMPLATE
ERROR_BAD_NUMBER
ERROR_REQUIRED_ARG_MISSING
ERROR_KEY_NEEDS_ARG*/
ERROR_TOO_MANY_ARGS ,E2BIG,
/*ERROR_UNMATCHED_QUOTES*/
ERROR_LINE_TOO_LONG ,E2BIG,
/*ERROR_FILE_NOT_OBJECT
ERROR_INVALID_RESIDENT_LIBRARY
ERROR_NO_DEFAULT_DIR*/
ERROR_OBJECT_IN_USE ,ETXTBSY,
ERROR_OBJECT_EXISTS ,EEXIST,
ERROR_DIR_NOT_FOUND ,ENOENT,
ERROR_OBJECT_NOT_FOUND ,ENOENT,
ERROR_BAD_STREAM_NAME ,ENAMETOOLONG,
ERROR_OBJECT_TOO_LARGE ,EFBIG,
ERROR_ACTION_NOT_KNOWN ,ENODEV,
/*ERROR_INVALID_COMPONENT_NAME
ERROR_INVALID_LOCK
ERROR_OBJECT_WRONG_TYPE*/
ERROR_DISK_NOT_VALIDATED ,EBUSY,
ERROR_DISK_WRITE_PROTECTED ,EROFS,
/*ERROR_RENAME_ACROSS_DEVICES*/
ERROR_DIRECTORY_NOT_EMPTY ,ENOTEMPTY,
ERROR_TOO_MANY_LEVELS ,ENAMETOOLONG,
ERROR_DEVICE_NOT_MOUNTED ,ENXIO,
ERROR_SEEK_ERROR ,ESPIPE,
/*ERROR_COMMENT_TOO_BIG*/
ERROR_DISK_FULL ,ENOSPC,
ERROR_DELETE_PROTECTED ,EACCES,
ERROR_WRITE_PROTECTED ,EACCES,
ERROR_READ_PROTECTED ,EACCES,
ERROR_NOT_A_DOS_DISK ,EFTYPE,
ERROR_NO_DISK ,ENXIO,
/*ERROR_NO_MORE_ENTRIES
ERROR_IS_SOFT_LINK
ERROR_OBJECT_LINKED*/
ERROR_BAD_HUNK ,ENOEXEC,
/*ERROR_NOT_IMPLEMENTED
ERROR_RECORD_NOT_LOCKED
ERROR_LOCK_COLLISION
ERROR_LOCK_TIMEOUT
ERROR_UNLOCK_ERROR
ERROR_BUFFER_OVERFLOW
ERROR_BREAK*/
ERROR_NOT_EXECUTABLE ,EACCES,
0
};
void __seterrno(void)
{
long amigaerror;
long *ptr=_errortable;
amigaerror=IoErr();
while(*ptr)
{
if(*ptr++==amigaerror)
{
errno=*ptr;
return;
}
ptr++;
}
errno=EPERM;
}

Some files were not shown because too many files have changed in this diff Show More