diff --git a/Makefile b/Makefile index 1600ed4e9..3d2f18ae4 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ BUILDDIR = $(ACK_TEMP_DIR)/ack-build # What build flags do you want to use for native code? -CFLAGS = -g -Og -Wno-return-type +CFLAGS = -g -Wno-return-type LDFLAGS = # Various commands. diff --git a/build.lua b/build.lua index 629899415..a1fe98e80 100644 --- a/build.lua +++ b/build.lua @@ -16,6 +16,7 @@ vars.plats = { "pc86", "rpi", "pdpv7", + "em22", } vars.plats_with_tests = { "linux68k", diff --git a/first/build.lua b/first/build.lua index 2f56bf0c6..20d834437 100644 --- a/first/build.lua +++ b/first/build.lua @@ -150,6 +150,7 @@ definerule("clibrary", hdrs = { type="targets", default={} }, deps = { type="targets", default={} }, _cfile = { type="object", default=cfile }, + suffix = { type="string", default=".o" }, commands = { type="strings", default={ @@ -167,6 +168,7 @@ definerule("clibrary", cwd = e.cwd, srcs = {src}, deps = e.deps, + suffix = e.suffix, vars = { ["+cflags"] = { "-I"..e.cwd, }, }, diff --git a/lang/b/compiler/b.h b/lang/b/compiler/b.h index f5a11fd2a..8f1240a65 100644 --- a/lang/b/compiler/b.h +++ b/lang/b/compiler/b.h @@ -47,7 +47,7 @@ struct hshtab hshtab[HSHSIZ]; int hshused; int eof; int peekc; -char ctab[128]; +const char* ctab; struct hshtab *bsym; struct hshtab *paraml, *parame; int cval; diff --git a/lang/b/compiler/b0.c b/lang/b/compiler/b0.c index 2bf936805..d2993daf7 100644 --- a/lang/b/compiler/b0.c +++ b/lang/b/compiler/b0.c @@ -1287,7 +1287,8 @@ int opdope[] = { 000000 /* NAME */ }; -char ctab[128] = { +const char ctaba[129] = { + EOFC, /* -1 */ EOFC, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, LETTER, SPACE, NEWLN, SPACE, SPACE, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, UNKN, @@ -1305,6 +1306,7 @@ char ctab[128] = { LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LBRACE, OR, RBRACE, NOT, UNKN }; +const char* ctab = &ctaba[1]; /* allows indexing with -1 */ /* debug function */ void printtoken(int tok, FILE *out) diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua index a0d6eebc1..27704f208 100644 --- a/lang/cem/libcc.ansi/build.lua +++ b/lang/cem/libcc.ansi/build.lua @@ -71,11 +71,12 @@ for _, plat in ipairs(vars.plats) do } } + local suffix = plat:find("^em") and "m" or "o" installable { name = "pkg_"..plat, map = { "lang/cem/libcc.ansi/headers+pkg", - ["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat, + ["$(PLATIND)/"..plat.."/c-ansi."..suffix] = "+crt_"..plat, ["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat, } } diff --git a/lang/m2/libm2/build.lua b/lang/m2/libm2/build.lua index a1a9e5c0a..dd8968338 100644 --- a/lang/m2/libm2/build.lua +++ b/lang/m2/libm2/build.lua @@ -45,10 +45,11 @@ for _, plat in ipairs(vars.plats) do } } + local suffix = plat:find("^em") and "m" or "o" installable { name = "pkg_"..plat, map = { - ["$(PLATIND)/"..plat.."/modula2.o"] = "+mrt_"..plat, + ["$(PLATIND)/"..plat.."/modula2."..suffix] = "+mrt_"..plat, ["$(PLATIND)/"..plat.."/libmodula2.a"] = "+lib_"..plat, "+headers", } diff --git a/lang/pc/libpc/build.lua b/lang/pc/libpc/build.lua index 215f0c745..0fb5faea5 100644 --- a/lang/pc/libpc/build.lua +++ b/lang/pc/libpc/build.lua @@ -33,10 +33,11 @@ for _, plat in ipairs(vars.plats) do } } + local suffix = plat:find("^em") and "m" or "o" installable { name = "pkg_"..plat, map = { - ["$(PLATIND)/"..plat.."/pascal.o"] = "+prt_"..plat, + ["$(PLATIND)/"..plat.."/pascal."..suffix] = "+prt_"..plat, ["$(PLATIND)/"..plat.."/libpascal.a"] = "+lib_"..plat, } } diff --git a/lib/em22/descr b/lib/em22/descr deleted file mode 100644 index 551222b05..000000000 --- a/lib/em22/descr +++ /dev/null @@ -1,43 +0,0 @@ -# $Revision$ -var w=2 -var p=2 -var s=2 -var l=4 -var f=4 -var d=8 -var M=em22 -var NAME=em22 -var LIB=lib/em22/tail_ -var RT=lib/em22/head_ -var SIZE_FLAG= -var CPP_F=-D__unix -var INCLUDES=-I{EM}/include/_tail_mon -var C_LIB={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g -var OLD_C_LIB={C_LIB} -name asld - from .k.m.a.g - to .out - outfile e.out - program {EM}/lib.bin/em_ass - mapflag -l* LNAME={EM}/{LIB}* - mapflag -+* ASS_F={ASS_F?} -+* - mapflag --* ASS_F={ASS_F?} --* - mapflag -s* SIZE_FLAG=-s* - mapflag -ansi C_LIB={EM}/{LIB}ac - args {SIZE_FLAG} \ - ({RTS}:.ocm.bas={EM}/{RT}cc) \ - ({RTS}{ANSI?}:.c={EM}/{RT}cc) \ - ({RTS}{ANSI?}:.cansi={EM}/{RT}ac) \ - ({RTS}:.mod={EM}/{RT}m2) \ - ({RTS}:.p={EM}/{RT}pc) \ - -o > < \ - (.p:{TAIL}={EM}/{LIB}pc) \ - (.bas:{TAIL}={EM}/{LIB}bc) \ - (.ocm:{TAIL}={EM}/{LIB}ocm) \ - (.mod:{TAIL}={EM}/{LIB}m2) \ - (.ocm.bas:{TAIL}={OLD_C_LIB}) \ - (.c:{TAIL}={C_LIB}) \ - (.b.c.ocm.mod.p.e:{TAIL}={EM}/{LIB}mon) \ - ({RTS}{ANSI?}:.cansi={EM}/lib/em22/end_em) - linker -end diff --git a/mach/em22/libem/build.lua b/mach/em22/libem/build.lua new file mode 100644 index 000000000..c786a6566 --- /dev/null +++ b/mach/em22/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.e" }, + vars = { plat = plat }, + } +end + diff --git a/mach/em22/libem/dummy.e b/mach/em22/libem/dummy.e new file mode 100644 index 000000000..45307ed6f --- /dev/null +++ b/mach/em22/libem/dummy.e @@ -0,0 +1,7 @@ +# + + mes 2,_EM_WSIZE,_EM_PSIZE + + pro $__this_function_is_never_called,0 + end 0 + diff --git a/mach/em22/libend/LIST b/mach/em22/libend/LIST deleted file mode 100644 index 76a30447b..000000000 --- a/mach/em22/libend/LIST +++ /dev/null @@ -1,5 +0,0 @@ -end_e.a -edata.e -em_end.e -end.e -etext.e diff --git a/mach/em22/libend/build.lua b/mach/em22/libend/build.lua new file mode 100644 index 000000000..c786a6566 --- /dev/null +++ b/mach/em22/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.e" }, + vars = { plat = plat }, + } +end + diff --git a/plat/build.lua b/plat/build.lua index 676778dd8..451ba4af9 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -8,10 +8,12 @@ definerule("ackfile", { srcs = { type="targets" }, deps = { type="targets", default={} }, - suffix = { type="string", default=".o" }, + suffix = { type="string", optional=true }, }, function (e) - local c = (e.suffix == ".o" and "-c" or "-c"..e.suffix) + local em = e.vars.plat:find("^em") + local suffix = e.suffix or (em and ".m" or ".o") + local c = "-c"..suffix local plat = e.vars.plat return cfile { @@ -30,7 +32,7 @@ definerule("ackfile", "util/misc+pkg", e.deps }, - suffix = e.suffix, + suffix = suffix, commands = { "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} "..c.." -o %{outs} %{ins} %{hdrpaths} %{ackcflags}" } @@ -45,6 +47,7 @@ definerule("acklibrary", deps = { type="targets", default={} }, }, function (e) + local em = e.vars.plat:find("^em") return clibrary { name = e.name, srcs = e.srcs, @@ -54,6 +57,7 @@ definerule("acklibrary", e.deps }, _cfile = ackfile, + suffix = em and ".m" or ".o", commands = { "rm -f %{outs[1]}", "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal qc %{outs[1]} %{ins}" @@ -101,6 +105,7 @@ definerule("build_plat_libs", { arch = { type="string" }, plat = { type="string" }, + em = { type="boolean", default=false }, }, function(e) local installmap = { diff --git a/plat/em22/build-pkg.lua b/plat/em22/build-pkg.lua new file mode 100644 index 000000000..d69a0f0d9 --- /dev/null +++ b/plat/em22/build-pkg.lua @@ -0,0 +1,17 @@ +include("plat/build.lua") + +build_plat_libs { + name = "libs", + arch = "em22", + plat = "em22", + em = true, +} + +installable { + name = "pkg", + map = { + "+libs", + "./include+pkg", + } +} + diff --git a/plat/em22/build-tools.lua b/plat/em22/build-tools.lua new file mode 100644 index 000000000..ee476da3e --- /dev/null +++ b/plat/em22/build-tools.lua @@ -0,0 +1,9 @@ +include("plat/build.lua") + +return installable { + name = "tools", + map = { + ["$(PLATIND)/descr/em22"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/em22/descr b/plat/em22/descr new file mode 100644 index 000000000..b2e6890c7 --- /dev/null +++ b/plat/em22/descr @@ -0,0 +1,55 @@ +var w=2 +var wa=1 +var p=2 +var pa=1 +var s=2 +var sa=1 +var l=4 +var la=1 +var f=4 +var fa=1 +var d=8 +var da=1 +var x=8 +var xa=1 +var ARCH=em22 +var PLATFORM=em22 +var PLATFORMDIR={EM}/share/ack/{PLATFORM} +var CPP_F=-D__unix +var ALIGN=-a0:2 -a1:2 -a2:2 -a3:2 +var MACHOPT_F=-m8 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr +var SIZE_FLAG=-sl + +# Override the setting in fe so that files compiled for this platform can see +# the platform-specific headers. + +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi + +name asld + from .k.m.a.g + to .out + outfile e.out + program {EM}/lib/ack/em_ass + mapflag -l* LNAME={PLATFORMDIR}/lib* + mapflag -+* ASS_F={ASS_F?} -+* + mapflag --* ASS_F={ASS_F?} --* + mapflag -s* SIZE_FLAG=-s* + mapflag -ansi C_LIB={EM}/{LIB}ac + args {SIZE_FLAG} \ + ({RTS}:.ocm.bas.b={PLATFORMDIR}/c-ansi.m) \ + ({RTS}:.c={PLATFORMDIR}/c-ansi.m) \ + ({RTS}:.mod={PLATFORMDIR}/modula2.m) \ + ({RTS}:.p={PLATFORMDIR}/pascal.m) \ + -o > < \ + (.p:{TAIL}={PLATFORMDIR}/libpascal.a) \ + (.b:{TAIL}={PLATFORMDIR}/libb.a) \ + (.bas:{TAIL}={PLATFORMDIR}/libbasic.a) \ + (.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \ + (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ + (.ocm.bas.mod.b.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ + {FLOATS?} \ + (.e:{TAIL}={PLATFORMDIR}/libmon.a \ + {PLATFORMDIR}/libend.a) + linker +end diff --git a/plat/em22/include/ack/config.h b/plat/em22/include/ack/config.h new file mode 100644 index 000000000..2618ad74c --- /dev/null +++ b/plat/em22/include/ack/config.h @@ -0,0 +1,6 @@ +#ifndef _ACK_CONFIG_H +#define _ACK_CONFIG_H + +#define ACKCONF_TIME_IS_A_SYSCALL + +#endif diff --git a/plat/em22/include/build.lua b/plat/em22/include/build.lua new file mode 100644 index 000000000..a6f60c4c5 --- /dev/null +++ b/plat/em22/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/em22/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + diff --git a/plat/em22/include/unistd.h b/plat/em22/include/unistd.h new file mode 100644 index 000000000..30f13d994 --- /dev/null +++ b/plat/em22/include/unistd.h @@ -0,0 +1,71 @@ +/* + * unistd.h - standard system calls + */ + +#ifndef _UNISTD_H +#define _UNISTD_H + +#include + +/* Types */ + +typedef int pid_t; +typedef int mode_t; + +/* Constants for file access (open and friends) */ + +enum +{ + O_ACCMODE = 0x3, + + O_RDONLY = 0, + O_WRONLY = 1, + O_RDWR = 2, + + O_CREAT = 0100, + O_TRUNC = 01000, + O_APPEND = 02000, + O_NONBLOCK = 04000 +}; + +/* Special variables */ + +extern char** environ; + +/* Implemented system calls */ + +extern void _exit(int); +extern pid_t getpid(void); +extern int brk(void* addr); +extern void* sbrk(int increment); +extern int isatty(int d); +extern off_t lseek(int fildes, off_t offset, int whence); +extern int close(int d); +extern int open(const char* path, int access, ...); +extern int creat(const char* path, mode_t mode); +extern int read(int fd, void* buffer, size_t count); +extern int write(int fd, void* buffer, size_t count); + +/* Unimplemented system calls (these are just prototypes to let the library + * compile). */ + +extern int fcntl(int fd, int op, ...); + +/* Signal handling */ + +typedef int sig_atomic_t; + +#define SIG_ERR ((sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */ + +#define SIGABRT 6 /* Abort (ANSI) */ +#define SIGILL 11 /* Illegal instruction */ + +#define _NSIG 32 /* Biggest signal number + 1 + (not including real-time signals). */ +typedef void (*sighandler_t)(int); +extern sighandler_t signal(int signum, sighandler_t handler); +extern int raise(int signum); + +#endif diff --git a/util/ass/ass30.c b/util/ass/ass30.c index bceb27565..b4de26512 100644 --- a/util/ass/ass30.c +++ b/util/ass/ass30.c @@ -148,6 +148,7 @@ char *findfit(instr,val) int instr ; cons_t val ; { int found, flags, number ; char *opc ; +fprintf(stderr, "findfit(%d)\n", instr); endc = opindex[instr+1] ; for ( currc=opindex[instr], found=0 ; !found && currc