From d89f1728417bdfbcb6e3390ca2774dce8e42657d Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 10 May 2013 12:04:21 +0100 Subject: [PATCH 001/231] Change fatal() and error() to use varargs. --- util/ncgg/emlookup.c | 1 + util/ncgg/error.c | 38 +++++++++++++++++++++++++++----------- util/ncgg/extern.h | 4 ++++ util/ncgg/hall.c | 1 + util/ncgg/lookup.c | 1 + util/ncgg/main.c | 1 + util/ncgg/strlookup.c | 1 + util/ncgg/var.c | 1 + 8 files changed, 37 insertions(+), 11 deletions(-) diff --git a/util/ncgg/emlookup.c b/util/ncgg/emlookup.c index 6d0d9a3f1..6927f9259 100644 --- a/util/ncgg/emlookup.c +++ b/util/ncgg/emlookup.c @@ -10,6 +10,7 @@ static char rcsid[]= "$Id$"; #include #include "param.h" #include "expr.h" +#include "extern.h" #include #include diff --git a/util/ncgg/error.c b/util/ncgg/error.c index 48cac2c00..5d083d577 100644 --- a/util/ncgg/error.c +++ b/util/ncgg/error.c @@ -8,6 +8,8 @@ static char rcsid[]= "$Id$"; #include #include +#include +#include "extern.h" int nerrors=0; @@ -24,24 +26,38 @@ goodbye() { #endif } -/*VARARGS1*/ -fatal(s,a,b,c,d) char *s; { +void errorv(const char* s, va_list ap) +{ + extern int lineno; + extern char *filename; + + fprintf(stderr, "\"%s\", line %d:", filename, lineno); + vfprintf(stderr, s, ap); + fprintf(stderr, "\n"); + nerrors++; +} + +void fatal(const char* s, ...) +{ + + va_list ap; + + va_start(ap, s); + errorv(s, ap); + va_end(ap); - error(s,a,b,c,d); errorexit(); goodbye(); exit(-1); } -/*VARARGS1*/ -error(s,a,b,c,d) char *s; { - extern int lineno; - extern char *filename; +void error(const char* s, ...) +{ + va_list ap; - fprintf(stderr,"\"%s\", line %d:",filename,lineno); - fprintf(stderr,s,a,b,c,d); - fprintf(stderr,"\n"); - nerrors++; + va_start(ap, s); + errorv(s, ap); + va_end(ap); } #ifndef NDEBUG diff --git a/util/ncgg/extern.h b/util/ncgg/extern.h index ff5260704..561591627 100644 --- a/util/ncgg/extern.h +++ b/util/ncgg/extern.h @@ -40,3 +40,7 @@ extern int use_tes; extern char *mystrcpy(); extern char *myalloc(); + +extern void error(const char* s, ...); +extern void fatal(const char* s, ...); + diff --git a/util/ncgg/hall.c b/util/ncgg/hall.c index b22f03210..f8a5364c7 100644 --- a/util/ncgg/hall.c +++ b/util/ncgg/hall.c @@ -9,6 +9,7 @@ static char rcsid[]= "$Id$"; #include "assert.h" #include "param.h" #include "set.h" +#include "extern.h" #include /* diff --git a/util/ncgg/lookup.c b/util/ncgg/lookup.c index c59610fdd..ab31baebc 100644 --- a/util/ncgg/lookup.c +++ b/util/ncgg/lookup.c @@ -9,6 +9,7 @@ static char rcsid[]= "$Id$"; #include "assert.h" #include "param.h" #include "lookup.h" +#include "extern.h" char *myalloc(); char *mystrcpy(); diff --git a/util/ncgg/main.c b/util/ncgg/main.c index 2c805e7a8..330e08c98 100644 --- a/util/ncgg/main.c +++ b/util/ncgg/main.c @@ -8,6 +8,7 @@ static char rcsid[]= "$Id$"; #include #include +#include "extern.h" char *filename; char *beg_sbrk; diff --git a/util/ncgg/strlookup.c b/util/ncgg/strlookup.c index 5d5877abc..d473341aa 100644 --- a/util/ncgg/strlookup.c +++ b/util/ncgg/strlookup.c @@ -7,6 +7,7 @@ static char rcsid[]= "$Id$"; #endif #include "param.h" +#include "extern.h" int nstrings=0; char *l_strings[MAXSTRINGS]; diff --git a/util/ncgg/var.c b/util/ncgg/var.c index 792b78923..72a3f825d 100644 --- a/util/ncgg/var.c +++ b/util/ncgg/var.c @@ -13,6 +13,7 @@ static char rcsid[]= "$Id$"; #include "set.h" #include "instruct.h" #include "lookup.h" +#include "extern.h" #include int wordsize; From c1aca7dae5fd36249da452c79d2d928590253f11 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 12 May 2013 20:45:55 +0100 Subject: [PATCH 002/231] First milestone of replacing the build system. --HG-- branch : dtrg-buildsystem rename : lang/cem/cpp.ansi/Parameters => lang/cem/cpp.ansi/parameters.h --- Makefile | 84 ++++++++ first/core.mk | 199 ++++++++++++++++++ lang/cem/build.mk | 6 + lang/cem/cemcom.ansi/LLlex.c | 7 +- lang/cem/cemcom.ansi/LLlex.h | 1 - lang/cem/cemcom.ansi/LLmessage.c | 1 - lang/cem/cemcom.ansi/align.h | 3 +- lang/cem/cemcom.ansi/arith.c | 5 +- lang/cem/cemcom.ansi/arith.h | 2 +- lang/cem/cemcom.ansi/assert.h | 4 +- lang/cem/cemcom.ansi/blocks.c | 2 +- lang/cem/cemcom.ansi/build.mk | 156 ++++++++++++++ lang/cem/cemcom.ansi/ch3.c | 6 +- lang/cem/cemcom.ansi/ch3bin.c | 5 +- lang/cem/cemcom.ansi/ch3mon.c | 6 +- lang/cem/cemcom.ansi/code.c | 9 +- lang/cem/cemcom.ansi/conversion.c | 2 +- lang/cem/cemcom.ansi/cstoper.c | 3 +- lang/cem/cemcom.ansi/dataflow.c | 2 +- lang/cem/cemcom.ansi/declar.g | 7 +- lang/cem/cemcom.ansi/declarator.c | 4 +- lang/cem/cemcom.ansi/def.str | 2 +- lang/cem/cemcom.ansi/domacro.c | 17 +- lang/cem/cemcom.ansi/dumpidf.c | 5 +- lang/cem/cemcom.ansi/error.c | 7 +- lang/cem/cemcom.ansi/eval.c | 9 +- lang/cem/cemcom.ansi/expr.c | 8 +- lang/cem/cemcom.ansi/expression.g | 4 +- lang/cem/cemcom.ansi/field.c | 5 +- lang/cem/cemcom.ansi/fltcstoper.c | 4 +- lang/cem/cemcom.ansi/idf.c | 9 +- lang/cem/cemcom.ansi/idf.str | 2 +- lang/cem/cemcom.ansi/init.c | 4 +- lang/cem/cemcom.ansi/input.c | 5 +- lang/cem/cemcom.ansi/ival.g | 8 +- lang/cem/cemcom.ansi/l_comment.c | 3 +- lang/cem/cemcom.ansi/l_ev_ord.c | 3 +- lang/cem/cemcom.ansi/l_lint.c | 4 +- lang/cem/cemcom.ansi/l_misc.c | 3 +- lang/cem/cemcom.ansi/l_outdef.c | 3 +- lang/cem/cemcom.ansi/l_states.c | 4 +- lang/cem/cemcom.ansi/label.c | 3 +- lang/cem/cemcom.ansi/macro.str | 2 +- lang/cem/cemcom.ansi/main.c | 10 +- lang/cem/cemcom.ansi/make.next | 2 +- lang/cem/cemcom.ansi/options.c | 10 +- lang/cem/cemcom.ansi/pragma.c | 3 +- lang/cem/cemcom.ansi/program.g | 6 +- lang/cem/cemcom.ansi/proto.c | 8 +- lang/cem/cemcom.ansi/replace.c | 12 +- lang/cem/cemcom.ansi/sizes.h | 3 +- lang/cem/cemcom.ansi/skip.c | 2 +- lang/cem/cemcom.ansi/stab.c | 4 +- lang/cem/cemcom.ansi/stack.c | 6 +- lang/cem/cemcom.ansi/statement.g | 8 +- lang/cem/cemcom.ansi/struct.c | 6 +- lang/cem/cemcom.ansi/switch.c | 6 +- lang/cem/cemcom.ansi/tokenname.c | 3 +- lang/cem/cemcom.ansi/type.c | 6 +- lang/cem/cemcom.ansi/type.str | 3 +- lang/cem/cemcom.ansi/util.c | 5 +- lang/cem/cemcom/eval.c | 2 +- lang/cem/cemcom/replace.c | 2 +- lang/cem/cpp.ansi/LLlex.c | 4 +- lang/cem/cpp.ansi/bits.h | 2 +- lang/cem/cpp.ansi/build.mk | 104 +++++++++ lang/cem/cpp.ansi/domacro.c | 10 +- lang/cem/cpp.ansi/error.c | 2 +- lang/cem/cpp.ansi/input.h | 1 - lang/cem/cpp.ansi/main.c | 4 +- lang/cem/cpp.ansi/make.hfiles | 35 --- lang/cem/cpp.ansi/options.c | 2 +- .../cem/cpp.ansi/{Parameters => parameters.h} | 33 ++- lang/cem/cpp.ansi/preprocess.c | 5 +- lang/cem/cpp.ansi/replace.c | 8 +- lang/cem/libcc.ansi/build.mk | 36 ++++ lang/pc/comp/enter.c | 2 +- lib/descr/fe | 30 +-- mach/proto/as/build.mk | 43 ++++ mach/proto/ncg/build.mk | 46 ++++ modules/src/alloc/build.mk | 23 ++ modules/src/em_code/build.mk | 89 ++++++++ modules/src/em_code/insert.c | 1 + modules/src/em_mes/build.mk | 26 +++ modules/src/flt_arith/build.mk | 29 +++ modules/src/idf/build.mk | 14 ++ modules/src/input/build.mk | 20 ++ modules/src/object/build.mk | 27 +++ modules/src/print/build.mk | 22 ++ modules/src/string/build.mk | 19 ++ modules/src/system/build.mk | 29 +++ plat/build.mk | 26 +++ plat/cpm/build.mk | 14 ++ plat/cpm/descr | 12 +- plat/cpm/libsys/build.mk | 28 +++ plat/pc86/build.mk | 14 ++ plat/pc86/descr | 12 +- plat/pc86/libsys/build.mk | 26 +++ util/LLgen/build.mk | 55 +++++ util/LLgen/src/compute.c | 1 + util/LLgen/src/gencode.c | 1 + util/LLgen/src/savegram.c | 1 + util/ack/build.mk | 57 +++++ util/ack/files.c | 1 + util/ack/grows.c | 1 + util/ack/list.c | 1 + util/ack/rmach.c | 3 +- util/amisc/build.mk | 22 ++ util/arch/build.mk | 23 ++ util/cmisc/build.mk | 31 +++ util/cpp/replace.c | 2 +- util/data/build.mk | 29 +++ util/ego/sr/sr.h | 2 +- util/ncgg/build.mk | 41 ++++ util/ncgg/cgg.y | 1 - util/ncgg/scan.l | 14 ++ util/opt/build.mk | 78 +++++++ util/opt/mktab.y | 1 - util/opt/scan.l | 5 + 119 files changed, 1584 insertions(+), 319 deletions(-) create mode 100644 Makefile create mode 100644 first/core.mk create mode 100644 lang/cem/build.mk create mode 100644 lang/cem/cemcom.ansi/build.mk create mode 100644 lang/cem/cpp.ansi/build.mk delete mode 100755 lang/cem/cpp.ansi/make.hfiles rename lang/cem/cpp.ansi/{Parameters => parameters.h} (72%) create mode 100644 lang/cem/libcc.ansi/build.mk create mode 100644 mach/proto/as/build.mk create mode 100644 mach/proto/ncg/build.mk create mode 100644 modules/src/alloc/build.mk create mode 100644 modules/src/em_code/build.mk create mode 100644 modules/src/em_mes/build.mk create mode 100644 modules/src/flt_arith/build.mk create mode 100644 modules/src/idf/build.mk create mode 100644 modules/src/input/build.mk create mode 100644 modules/src/object/build.mk create mode 100644 modules/src/print/build.mk create mode 100644 modules/src/string/build.mk create mode 100644 modules/src/system/build.mk create mode 100644 plat/build.mk create mode 100644 plat/cpm/build.mk create mode 100644 plat/cpm/libsys/build.mk create mode 100644 plat/pc86/build.mk create mode 100644 plat/pc86/libsys/build.mk create mode 100644 util/LLgen/build.mk create mode 100644 util/ack/build.mk create mode 100644 util/amisc/build.mk create mode 100644 util/arch/build.mk create mode 100644 util/cmisc/build.mk create mode 100644 util/data/build.mk create mode 100644 util/ncgg/build.mk create mode 100644 util/opt/build.mk diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..7c6371dfc --- /dev/null +++ b/Makefile @@ -0,0 +1,84 @@ +BUILDDIR = /tmp/obj +OBJDIR = $(BUILDDIR)/obj +BINDIR = $(BUILDDIR)/bin +LIBDIR = $(BUILDDIR)/lib +INCDIR = $(BUILDDIR)/include +INSDIR = $(BUILDDIR)/staging + +PLATIND = $(INSDIR)/share/ack +PLATDEP = $(INSDIR)/lib/ack + +CC = gcc +AR = ar +RM = rm -f +CP = cp + +hide = @ + +CFLAGS = \ + -g \ + -I$(INCDIR) \ + -Imodules/h \ + -Ih + +LDFLAGS = + +all: installables + +.DELETE_ON_ERROR: + +include first/core.mk + +include modules/src/object/build.mk +include modules/src/alloc/build.mk +include modules/src/input/build.mk +include modules/src/idf/build.mk +include modules/src/system/build.mk +include modules/src/string/build.mk +include modules/src/print/build.mk +include modules/src/flt_arith/build.mk +include modules/src/em_code/build.mk +include modules/src/em_mes/build.mk + +include util/amisc/build.mk +include util/cmisc/build.mk +include util/ack/build.mk +include util/LLgen/build.mk +include util/data/build.mk +include util/opt/build.mk +include util/ncgg/build.mk +include util/arch/build.mk + +include lang/cem/build.mk + +include mach/proto/as/build.mk +include mach/proto/ncg/build.mk + +include plat/build.mk +include plat/pc86/build.mk +include plat/cpm/build.mk + +.PHONY: installables +installables: $(INSTALLABLES) + +.PHONY: clean +clean: + @echo CLEAN + $(hide) $(RM) $(CLEANABLES) + +$(INCDIR)/local.h: + @echo LOCAL + @mkdir -p $(dir $@) + $(hide) echo '#define VERSION 3' > $@ + $(hide) echo '#define ACKM "pc86"' >> $@ + $(hide) echo '#define BIGMACHINE 1' >> $@ + $(hide) echo '#define SYS_5' >> $@ + +$(INCDIR)/em_path.h: + @echo EM_PATH + @mkdir -p $(dir $@) + $(hide) echo '#define TMP_DIR "/tmp"' > $@ + $(hide) echo '#define EM_DIR "/tmp/obj/staging"' >> $@ + $(hide) echo '#define ACK_PATH "share/ack/descr"' >> $@ + +-include $(DEPENDS) diff --git a/first/core.mk b/first/core.mk new file mode 100644 index 000000000..898cf0d03 --- /dev/null +++ b/first/core.mk @@ -0,0 +1,199 @@ +define reset + $(eval q :=) + $(eval o :=) + $(eval s :=) + $(eval cflags :=) + $(eval ldflags :=) + $(eval objdir :=) +endef + +# --- Host compiler + +define cfile-rule +$o: $s + @echo CC $o + @mkdir -p $(dir $o) + @$(CC) $(CFLAGS) $(cflags) -MM -MQ $d -o $d $s + $(hide) $(CC) $(CFLAGS) $(cflags) -c -o $o $s +endef + +define cfile + $(eval s := $1) + $(eval o := $(OBJDIR)/$(objdir)/$(1:.c=.o)) + $(eval d := $(OBJDIR)/$(objdir)/$(1:.c=.d)) + $(eval DEPENDS += $d) + $(eval CLEANABLES += $o $d) + $(eval q += $o) + $(eval $(cfile-rule)) +endef + +# --- ACK compiler + +define ackfile-rule +$o: $s $(ACK) \ + $(PLATIND)/descr/$(PLATFORM) \ + $(PLATDEP)/$(PLATFORM)/as \ + $(CCOMPILER) \ + $(PLATFORM_$(PLATFORM)) + @echo ACK $o + @mkdir -p $(dir $o) + $(hide) ACKDIR=$(INSDIR) $(ACK) $(ACKFLAGS) $(ackflags) -m$(PLATFORM) -c -o $o $s +endef + +define ackfile + $(eval s := $1) + $(eval o := $(OBJDIR)/$(basename $1).o) + $(eval d := $(OBJDIR)/$(basename $1).d) + $(eval DEPENDS += $d) + $(eval CLEANABLES += $o $d) + $(eval q += $o) + $(eval $(ackfile-rule)) +endef + +# --- Add a raw to the queue + +define file + $(eval q += $1) +endef + +# --- Host compiler linking + +define cprogram-rule +$o: $s + @echo CPROGRAM $o + @mkdir -p $(dir $o) + $(hide) $(CC) $(CFLAGS) $(cflags) $(LDFLAGS) $(ldflags) -o $o $s +endef + +define cprogram + $(eval o := $1) + $(eval s := $q) + $(eval CLEANABLES += $o) + $(eval q := $o) + $(eval $(cprogram-rule)) +endef + +# --- Host library linking + +define clibrary-rule +$o: $s + @echo CLIBRARY $o + @mkdir -p $(dir $o) + @$(RM) $o + $(hide) $(AR) qsc $o $s +endef + +define clibrary + $(eval o := $1) + $(eval s := $q) + $(eval CLEANABLES += $o) + $(eval q := $o) + $(eval $(clibrary-rule)) +endef + +# --- ACK library linking + +define acklibrary-rule +$o: $s $(ACKAR) + @echo ACKLIBRARY $o + @mkdir -p $(dir $o) + @$(RM) $o + $(hide) $(AAL) q $o $s +endef + +define acklibrary + $(eval o := $1) + $(eval s := $q) + $(eval CLEANABLES += $o) + $(eval q := $o) + $(eval $(acklibrary-rule)) +endef + +# --- Copies a file. + +define copyto-rule +$o: $s + @echo CP $o + @mkdir -p $(dir $o) + $(hide) $(CP) $s $o +endef + +define copyto + $(eval o := $1) + $(eval s := $q) + $(eval CLEANABLES += $o) + $(eval q := $o) + $(eval $(copyto-rule)) +endef + +# --- Installs a file (copies it and adds it to INSTALLABLES). + +define installto-rule +$o: $s + @echo INSTALL $o + @mkdir -p $(dir $o) + $(hide) $(CP) $s $o +endef + +define installto + $(eval o := $1) + $(eval s := $q) + $(eval CLEANABLES += $o) + $(eval INSTALLABLES += $o) + $(eval q := $o) + $(eval $(installto-rule)) +endef + +# --- Adds a dependency for the last object file + +define dependson + $(eval $o: $1) +endef + +# --- Runs yacc. + +# $1: directory to put output files +# $2: input files +# +# Output files are compiled via cfile and queued. + +define yacc-impl + $(eval o := $1/y.tab.c) + $(eval CLEANABLES += $o $1/y.tab.h) + +$o: $2 + @echo YACC $o + @mkdir -p $(dir $o) + $(hide) yacc -t -b $1/y -d $2 + + $(call cfile, $o) + +$1/y.tab.h: $o + +endef + +yacc = $(eval $(call yacc-impl,$1,$2)) + +# --- Runs flex. + +# $1: directory to put output files +# $2: input files +# +# Output files are compiled via cfile and queued. + +define flex-impl + +$(eval o := $1/lex.yy.c) +$(eval CLEANABLES += $o) + +$o: $2 + @echo FLEX $o + @mkdir -p $(dir $o) + $(hide) flex -s -t $2 > $o + +$(call cfile, $o) + +endef + +flex = $(eval $(call flex-impl,$1,$2)) + diff --git a/lang/cem/build.mk b/lang/cem/build.mk new file mode 100644 index 000000000..23e0dba95 --- /dev/null +++ b/lang/cem/build.mk @@ -0,0 +1,6 @@ +include lang/cem/cpp.ansi/build.mk +include lang/cem/cemcom.ansi/build.mk +include lang/cem/libcc.ansi/build.mk + +$(eval CCOMPILER := $(CPPANSI) $(CEMCOMANSI) $(LIBCCANSIHEADERS)) + diff --git a/lang/cem/cemcom.ansi/LLlex.c b/lang/cem/cemcom.ansi/LLlex.c index 9736b4420..07a79ad8e 100644 --- a/lang/cem/cemcom.ansi/LLlex.c +++ b/lang/cem/cemcom.ansi/LLlex.c @@ -5,13 +5,8 @@ /* $Id$ */ /* L E X I C A L A N A L Y Z E R */ -#include "debug.h" -#include "lint.h" #include -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" -#include "nopp.h" +#include "parameters.h" #include "input.h" #include "arith.h" #include "def.h" diff --git a/lang/cem/cemcom.ansi/LLlex.h b/lang/cem/cemcom.ansi/LLlex.h index 7fb88292d..90b003954 100644 --- a/lang/cem/cemcom.ansi/LLlex.h +++ b/lang/cem/cemcom.ansi/LLlex.h @@ -11,7 +11,6 @@ */ #include "file_info.h" -#include "nopp.h" /* the structure of a token: */ struct token { diff --git a/lang/cem/cemcom.ansi/LLmessage.c b/lang/cem/cemcom.ansi/LLmessage.c index c88c5eb24..9010ce45d 100644 --- a/lang/cem/cemcom.ansi/LLmessage.c +++ b/lang/cem/cemcom.ansi/LLmessage.c @@ -6,7 +6,6 @@ /* PARSER ERROR ADMINISTRATION */ #include -#include "idf.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" diff --git a/lang/cem/cemcom.ansi/align.h b/lang/cem/cemcom.ansi/align.h index 1e4ee3f94..79b9be97b 100644 --- a/lang/cem/cemcom.ansi/align.h +++ b/lang/cem/cemcom.ansi/align.h @@ -5,8 +5,7 @@ /* $Id$ */ /* A L I G N M E N T D E F I N I T I O N S */ -#include "nocross.h" -#include "trgt_sizes.h" +#include "parameters.h" #ifndef NOCROSS extern int diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index ed3dc5004..d5f3af3e7 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -11,11 +11,8 @@ semantics of C is a mess. */ +#include "parameters.h" #include -#include "debug.h" -#include "lint.h" -#include "nobitfield.h" -#include "idf.h" #include #include "arith.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/arith.h b/lang/cem/cemcom.ansi/arith.h index 399e2645a..4bb403458 100644 --- a/lang/cem/cemcom.ansi/arith.h +++ b/lang/cem/cemcom.ansi/arith.h @@ -13,7 +13,7 @@ be handy. */ -#include "spec_arith.h" +#include "parameters.h" #ifndef SPECIAL_ARITHMETICS diff --git a/lang/cem/cemcom.ansi/assert.h b/lang/cem/cemcom.ansi/assert.h index 2210f792a..da650dad3 100644 --- a/lang/cem/cemcom.ansi/assert.h +++ b/lang/cem/cemcom.ansi/assert.h @@ -1,5 +1,6 @@ /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ @@ -10,7 +11,8 @@ there is no reasonable method to prove that a program is 100% correct, these assertions are needed in some places. */ -#include "debug.h" /* UF */ + +#include "parameters.h" #ifdef DEBUG /* Note: this macro uses parameter substitution inside strings */ diff --git a/lang/cem/cemcom.ansi/blocks.c b/lang/cem/cemcom.ansi/blocks.c index 88c6a49e3..6d75a3670 100644 --- a/lang/cem/cemcom.ansi/blocks.c +++ b/lang/cem/cemcom.ansi/blocks.c @@ -5,7 +5,7 @@ /* $Id$ */ /* B L O C K S T O R I N G A N D L O A D I N G */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include diff --git a/lang/cem/cemcom.ansi/build.mk b/lang/cem/cemcom.ansi/build.mk new file mode 100644 index 000000000..f47959ab9 --- /dev/null +++ b/lang/cem/cemcom.ansi/build.mk @@ -0,0 +1,156 @@ +D := lang/cem/cemcom.ansi + +define build-cemcom-ansi-allocd-header +$(eval g := $(OBJDIR)/$D/$(strip $1).h) +$g: $D/$(strip $1).str $D/make.allocd + @echo ALLOCD $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.allocd < $$^ > $$@ + +$(eval CLEANABLES += $g) +$(eval $q: $g) +endef + +define build-cemcom-ansi-next +$(eval CLEANABLES += $(OBJDIR)/$D/next.c) +$(OBJDIR)/$D/next.c: $D/make.next $1 + @echo NEXT $$@ + @mkdir -p $$(dir $$@) + $(hide) $$^ > $$@ +$(call cfile, $(OBJDIR)/$D/next.c) + +$(foreach f, $1, $(call build-cemcom-ansi-allocd-header, \ + $(basename $(notdir $f)))) +endef + +define build-cemcom-ansi-impl + +$(call reset) +$(eval cflags += -I$(OBJDIR)/$D -I$D) + +$(call cfile, $D/arith.c) +$(call dependson, $(INCDIR)/flt_arith.h) + +$(call cfile, $D/blocks.c) +$(call dependson, $(INCDIR)/em_codeEK.h) + +$(call cfile, $D/LLlex.c) +$(call cfile, $D/LLmessage.c) + +$(call cfile, $D/ch3.c) +$(call cfile, $D/ch3bin.c) +$(call cfile, $D/ch3mon.c) +$(call cfile, $D/code.c) +$(call cfile, $D/conversion.c) +$(call cfile, $D/cstoper.c) +$(call cfile, $D/dataflow.c) +$(call cfile, $D/declarator.c) +$(call cfile, $D/decspecs.c) +$(call cfile, $D/domacro.c) +$(call cfile, $D/dumpidf.c) +$(call cfile, $D/error.c) +$(call cfile, $D/eval.c) +$(call cfile, $D/expr.c) +$(call cfile, $D/field.c) +$(call cfile, $D/fltcstoper.c) +$(call cfile, $D/idf.c) +$(call cfile, $D/init.c) +$(call cfile, $D/input.c) +$(call cfile, $D/l_comment.c) +$(call cfile, $D/l_ev_ord.c) +$(call cfile, $D/l_lint.c) +$(call cfile, $D/l_misc.c) +$(call cfile, $D/l_outdef.c) +$(call cfile, $D/l_states.c) +$(call cfile, $D/label.c) +$(call cfile, $D/main.c) +$(call cfile, $D/options.c) +$(call cfile, $D/pragma.c) +$(call cfile, $D/proto.c) +$(call cfile, $D/replace.c) +$(call cfile, $D/skip.c) +$(call cfile, $D/stab.c) +$(call cfile, $D/stack.c) +$(call cfile, $D/struct.c) +$(call cfile, $D/switch.c) +$(call cfile, $D/tokenname.c) +$(call cfile, $D/type.c) +$(call cfile, $D/util.c) + +$(call llgen, $(OBJDIR)/$D, \ + $(OBJDIR)/$D/tokenfile.g \ + $D/program.g \ + $D/declar.g \ + $D/expression.g \ + $D/statement.g \ + $D/ival.g) + +$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) +$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c + @echo TOKENFILE $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ + +$(call tabgen, $D/char.tab) + +$(eval $q: $(OBJDIR)/$D/parameters.h) + +$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) +$(OBJDIR)/$D/parameters.h: $D/BigPars + @echo PARAMETERS $$@ + @mkdir -p $$(dir $$@) + $(hide) echo '#ifndef PARAMETERS_H' > $$@ + $(hide) echo '#define PARAMETERS_H' >> $$@ + $(hide) grep -v '^!' < $D/BigPars >> $$@ + $(hide) echo '#endif' >> $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) +$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c + @echo TOKCASE $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.tokcase < $D/tokenname.c > $$@ +$(call cfile, $(OBJDIR)/$D/symbol2str.c) + +$(call build-cemcom-ansi-next, \ + $D/code.str \ + $D/declar.str \ + $D/def.str \ + $D/expr.str \ + $D/field.str \ + $D/estack.str \ + $D/util.str \ + $D/proto.str \ + $D/replace.str \ + $D/idf.str \ + $D/macro.str \ + $D/stack.str \ + $D/stmt.str \ + $D/struct.str \ + $D/switch.str \ + $D/type.str \ + $D/l_brace.str \ + $D/l_state.str \ + $D/l_outdef.str) + +$(eval $q: $(OBJDIR)/$D/Lpars.h) + +$(call file, $(LIBEM_MES)) +$(call file, $(LIBEMK)) +$(call file, $(LIBEM_DATA)) +$(call file, $(LIBINPUT)) +$(call file, $(LIBASSERT)) +$(call file, $(LIBALLOC)) +$(call file, $(LIBFLT_ARITH)) +$(call file, $(LIBPRINT)) +$(call file, $(LIBSYSTEM)) +$(call file, $(LIBSTRING)) +$(call cprogram, $(BINDIR)/cemcom.ansi) +$(call installto, $(PLATDEP)/em_cemcom.ansi) +$(eval CEMCOMANSI := $o) + +$(call reset) +$(eval q := $D/cemcom.1) +$(call installto, $(INSDIR)/share/man/man1/cemcom.6) +endef + +$(eval $(build-cemcom-ansi-impl)) diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index 6270dfd4a..bebe77efa 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -5,12 +5,10 @@ /* $Id$ */ /* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */ -#include "debug.h" -#include "lint.h" -#include "nobitfield.h" -#include "idf.h" +#include "parameters.h" #include #include "arith.h" +#include "idf.h" #include "proto.h" #include "type.h" #include "struct.h" diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index cb30e1087..8145b933d 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -5,11 +5,8 @@ /* $Id$ */ /* SEMANTIC ANALYSIS (CHAPTER 3.3) -- BINARY OPERATORS */ -#include "botch_free.h" -#include "debug.h" +#include "parameters.h" #include -#include "lint.h" -#include "idf.h" #include #include "arith.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/ch3mon.c b/lang/cem/cemcom.ansi/ch3mon.c index 40cc44025..8cffc2c9d 100644 --- a/lang/cem/cemcom.ansi/ch3mon.c +++ b/lang/cem/cemcom.ansi/ch3mon.c @@ -5,17 +5,15 @@ /* $Id$ */ /* SEMANTIC ANALYSIS (CHAPTER 3.3) -- MONADIC OPERATORS */ -#include "botch_free.h" -#include "debug.h" +#include "parameters.h" #include -#include "nobitfield.h" #include "Lpars.h" #include +#include "idf.h" #include "arith.h" #include "type.h" #include "label.h" #include "expr.h" -#include "idf.h" #include "def.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/code.c b/lang/cem/cemcom.ansi/code.c index 6289529ae..1beeb12c4 100644 --- a/lang/cem/cemcom.ansi/code.c +++ b/lang/cem/cemcom.ansi/code.c @@ -7,23 +7,18 @@ #include #include -#include "lint.h" -#include "debug.h" -#include "dbsymtab.h" +#include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #include "l_lint.h" #endif /* LINT */ -#include "botch_free.h" #include -#include "dataflow.h" -#include "use_tmp.h" #include +#include "idf.h" #include "arith.h" #include "type.h" -#include "idf.h" #include "label.h" #include "code.h" #include "stmt.h" diff --git a/lang/cem/cemcom.ansi/conversion.c b/lang/cem/cemcom.ansi/conversion.c index 6627a30e1..485d8b8bd 100644 --- a/lang/cem/cemcom.ansi/conversion.c +++ b/lang/cem/cemcom.ansi/conversion.c @@ -5,7 +5,7 @@ /* $Id$ */ /* C O N V E R S I O N - C O D E G E N E R A T O R */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include diff --git a/lang/cem/cemcom.ansi/cstoper.c b/lang/cem/cemcom.ansi/cstoper.c index c86f122be..ac11c2ca9 100644 --- a/lang/cem/cemcom.ansi/cstoper.c +++ b/lang/cem/cemcom.ansi/cstoper.c @@ -5,8 +5,7 @@ /* $Id$ */ /* C O N S T A N T E X P R E S S I O N H A N D L I N G */ -#include "trgt_sizes.h" -#include "idf.h" +#include "parameters.h" #include #include "arith.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/dataflow.c b/lang/cem/cemcom.ansi/dataflow.c index e6f00abac..6a3fbcf65 100644 --- a/lang/cem/cemcom.ansi/dataflow.c +++ b/lang/cem/cemcom.ansi/dataflow.c @@ -9,7 +9,7 @@ Use the compiler option --d. */ -#include "dataflow.h" /* UF */ +#include "parameters.h" /* UF */ #ifdef DATAFLOW char *CurrentFunction = 0; diff --git a/lang/cem/cemcom.ansi/declar.g b/lang/cem/cemcom.ansi/declar.g index 4322cbeb0..d6119f59d 100644 --- a/lang/cem/cemcom.ansi/declar.g +++ b/lang/cem/cemcom.ansi/declar.g @@ -6,17 +6,14 @@ /* DECLARATION SYNTAX PARSER */ { -#include "lint.h" -#include "dbsymtab.h" +#include "parameters.h" #include -#include "nobitfield.h" -#include "debug.h" #include +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "label.h" #include "code.h" -#include "idf.h" #include "type.h" #include "proto.h" #include "struct.h" diff --git a/lang/cem/cemcom.ansi/declarator.c b/lang/cem/cemcom.ansi/declarator.c index 3d33a83be..212b8aeb1 100644 --- a/lang/cem/cemcom.ansi/declarator.c +++ b/lang/cem/cemcom.ansi/declarator.c @@ -5,8 +5,7 @@ /* $Id$ */ /* D E C L A R A T O R M A N I P U L A T I O N */ -#include "debug.h" -#include "botch_free.h" +#include "parameters.h" #include #include #include "arith.h" @@ -15,7 +14,6 @@ #include "Lpars.h" #include "declar.h" #include "def.h" -#include "idf.h" #include "label.h" #include "expr.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/def.str b/lang/cem/cemcom.ansi/def.str index adee48607..0ad7af339 100644 --- a/lang/cem/cemcom.ansi/def.str +++ b/lang/cem/cemcom.ansi/def.str @@ -5,7 +5,7 @@ /* $Id$ */ /* IDENTIFIER DEFINITION DESCRIPTOR */ -#include "lint.h" +#include "parameters.h" struct def { /* for ordinary tags */ struct def *next; diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index f2ac213aa..4173a11b2 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -5,29 +5,20 @@ /* $Id$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ -#include "debug.h" +#include +#include "parameters.h" +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" -#include "idf.h" #include "input.h" -#include "nopp.h" -#include "lint.h" +#include "replace.h" #ifndef NOPP -#include "ifdepth.h" -#include "botch_free.h" -#include "nparams.h" -#include "parbufsize.h" -#include "textsize.h" -#include "idfsize.h" #include "assert.h" #include #include "class.h" #include "macro.h" -#include "macbuf.h" -#include "replace.h" -#include "dbsymtab.h" #ifdef DBSYMTAB #include #include diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index 18f425f26..849354bd3 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -5,16 +5,13 @@ /* $Id$ */ /* DUMP ROUTINES */ -#include "debug.h" #ifdef DEBUG +#include "parameters.h" #include -#include "nopp.h" -#include "nobitfield.h" #include #include "arith.h" #include "stack.h" -#include "idf.h" #include "def.h" #include "type.h" #include "proto.h" diff --git a/lang/cem/cemcom.ansi/error.c b/lang/cem/cemcom.ansi/error.c index 4b92b3261..10b237db4 100644 --- a/lang/cem/cemcom.ansi/error.c +++ b/lang/cem/cemcom.ansi/error.c @@ -5,7 +5,7 @@ /* $Id$ */ /* E R R O R A N D D I A G N O S T I C R O U T I N E S */ -#include "lint.h" +#include "parameters.h" #if __STDC__ #include #else @@ -18,11 +18,6 @@ #include "l_em.h" #endif /* LINT */ -#include "debug.h" -#include "lint.h" -#include "nopp.h" -#include "errout.h" - #include "tokenname.h" #include #include "arith.h" diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index 78a283c62..16f19c0ad 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -5,19 +5,16 @@ /* $Id$ */ /* EXPRESSION-CODE GENERATOR */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #include #include -#include "debug.h" -#include "nobitfield.h" -#include "dataflow.h" #include +#include "idf.h" #include "arith.h" #include "type.h" -#include "idf.h" #include "label.h" #include "code.h" #include "assert.h" @@ -41,7 +38,7 @@ arith NewLocal(); /* util.c */ extern int err_occurred; /* error.c */ /* EVAL() is the main expression-tree evaluator, which turns - any legal expression tree into EM code. Parameters: + any legal expression tree into EM code. parameters.h: struct expr *expr pointer to root of the expression tree to be evaluated diff --git a/lang/cem/cemcom.ansi/expr.c b/lang/cem/cemcom.ansi/expr.c index 6f0eb2c4f..6d8c1e23d 100644 --- a/lang/cem/cemcom.ansi/expr.c +++ b/lang/cem/cemcom.ansi/expr.c @@ -5,13 +5,12 @@ /* $Id$ */ /* EXPRESSION TREE HANDLING */ -#include "lint.h" -#include "debug.h" +#include +#include "parameters.h" #include "assert.h" -#include "botch_free.h" #include -#include "idf.h" #include +#include "idf.h" #include "arith.h" #include "def.h" #include "type.h" @@ -23,7 +22,6 @@ #include "declar.h" #include "sizes.h" #include "level.h" -#include "use_tmp.h" extern char *symbol2str(); extern char options[]; diff --git a/lang/cem/cemcom.ansi/expression.g b/lang/cem/cemcom.ansi/expression.g index e80281299..3a1284e69 100644 --- a/lang/cem/cemcom.ansi/expression.g +++ b/lang/cem/cemcom.ansi/expression.g @@ -7,13 +7,11 @@ { #include -#include "lint.h" -#include "debug.h" +#include "parameters.h" #include #include "arith.h" #include "LLlex.h" #include "type.h" -#include "idf.h" #include "label.h" #include "expr.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/field.c b/lang/cem/cemcom.ansi/field.c index 3f8c07a57..1514942e2 100644 --- a/lang/cem/cemcom.ansi/field.c +++ b/lang/cem/cemcom.ansi/field.c @@ -5,19 +5,16 @@ /* $Id$ */ /* BITFIELD EXPRESSION EVALUATOR */ -#include "lint.h" +#include "parameters.h" #ifndef LINT -#include "nobitfield.h" #ifndef NOBITFIELD #include #include -#include "debug.h" #include #include "arith.h" #include "type.h" -#include "idf.h" #include "label.h" #include "code.h" #include "assert.h" diff --git a/lang/cem/cemcom.ansi/fltcstoper.c b/lang/cem/cemcom.ansi/fltcstoper.c index 8ac330df7..de4d26e51 100644 --- a/lang/cem/cemcom.ansi/fltcstoper.c +++ b/lang/cem/cemcom.ansi/fltcstoper.c @@ -6,11 +6,9 @@ /* C O N S T A N T E X P R E S S I O N H A N D L I N G */ /* F O R F L O A T I N G P O I N T N U M B E R S */ -#include "debug.h" +#include "parameters.h" #include "assert.h" #include -#include "trgt_sizes.h" -#include "idf.h" #include #include "arith.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 56db5c20e..eb43e34bb 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -7,20 +7,15 @@ #include #include -#include "lint.h" +#include "parameters.h" #include -#include "debug.h" -#include "idfsize.h" -#include "botch_free.h" -#include "nopp.h" -#include "nparams.h" #include +#include "idf.h" #include "arith.h" #include "align.h" #include "LLlex.h" #include "level.h" #include "stack.h" -#include "idf.h" #include "label.h" #include "def.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/idf.str b/lang/cem/cemcom.ansi/idf.str index c4d01ea4b..fab968321 100644 --- a/lang/cem/cemcom.ansi/idf.str +++ b/lang/cem/cemcom.ansi/idf.str @@ -5,7 +5,7 @@ /* $Id$ */ /* IDENTIFIER DESCRIPTOR */ -#include "nopp.h" +#include "parameters.h" struct id_u { #ifndef NOPP diff --git a/lang/cem/cemcom.ansi/init.c b/lang/cem/cemcom.ansi/init.c index d59b1de18..bb1fd5559 100644 --- a/lang/cem/cemcom.ansi/init.c +++ b/lang/cem/cemcom.ansi/init.c @@ -7,15 +7,15 @@ #include #include -#include "nopp.h" +#include "parameters.h" #ifndef NOPP #include #include #include +#include "idf.h" #include "class.h" #include "macro.h" -#include "idf.h" extern char *sprint(); diff --git a/lang/cem/cemcom.ansi/input.c b/lang/cem/cemcom.ansi/input.c index e10aacb5a..fc1e99f28 100644 --- a/lang/cem/cemcom.ansi/input.c +++ b/lang/cem/cemcom.ansi/input.c @@ -4,10 +4,10 @@ */ /* $Id$ */ +#include "parameters.h" #include #include #include -#include "inputtype.h" #include "file_info.h" #include "input.h" @@ -15,12 +15,9 @@ #define INP_TYPE struct file_info #define INP_VAR finfo struct file_info finfo; -#include "nopp.h" #include #include -#include "dbsymtab.h" -#include "lint.h" #ifndef NOPP #ifdef DBSYMTAB #include diff --git a/lang/cem/cemcom.ansi/ival.g b/lang/cem/cemcom.ansi/ival.g index 0304d75ef..b085ebc73 100644 --- a/lang/cem/cemcom.ansi/ival.g +++ b/lang/cem/cemcom.ansi/ival.g @@ -6,18 +6,18 @@ /* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */ { -#include "lint.h" +#include +#include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #include "l_lint.h" #endif /* LINT */ -#include "debug.h" #include #include -#include "nobitfield.h" #include +#include "idf.h" #include "arith.h" #include "label.h" #include "expr.h" @@ -29,11 +29,11 @@ #include "Lpars.h" #include "sizes.h" #include "align.h" -#include "idf.h" #include "level.h" #include "def.h" #include "LLlex.h" #include "estack.h" +#include "stack.h" #define con_nullbyte() C_con_ucon("0", (arith)1) #define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT) diff --git a/lang/cem/cemcom.ansi/l_comment.c b/lang/cem/cemcom.ansi/l_comment.c index da9d2b776..2ab983a85 100644 --- a/lang/cem/cemcom.ansi/l_comment.c +++ b/lang/cem/cemcom.ansi/l_comment.c @@ -5,10 +5,9 @@ /* $Id$ */ /* Lint-specific comment handling */ +#include "parameters.h" #include -#include "lint.h" - #ifdef LINT #include diff --git a/lang/cem/cemcom.ansi/l_ev_ord.c b/lang/cem/cemcom.ansi/l_ev_ord.c index 56515ebb0..c5d7550a3 100644 --- a/lang/cem/cemcom.ansi/l_ev_ord.c +++ b/lang/cem/cemcom.ansi/l_ev_ord.c @@ -5,7 +5,7 @@ /* $Id$ */ /* Lint evaluation order checking */ -#include "lint.h" +#include "parameters.h" #ifdef LINT @@ -18,7 +18,6 @@ #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/l_lint.c b/lang/cem/cemcom.ansi/l_lint.c index 497d7bd64..5f95cb0fa 100644 --- a/lang/cem/cemcom.ansi/l_lint.c +++ b/lang/cem/cemcom.ansi/l_lint.c @@ -5,12 +5,11 @@ /* $Id$ */ /* Lint main routines */ -#include "lint.h" +#include "parameters.h" #ifdef LINT #include /* for st_free */ -#include "debug.h" #include "interface.h" #include "assert.h" #ifdef ANSI @@ -19,7 +18,6 @@ #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/l_misc.c b/lang/cem/cemcom.ansi/l_misc.c index 5e8cd080d..c09c84b8b 100644 --- a/lang/cem/cemcom.ansi/l_misc.c +++ b/lang/cem/cemcom.ansi/l_misc.c @@ -5,7 +5,7 @@ /* $Id$ */ /* Lint miscellaneous routines */ -#include "lint.h" +#include "parameters.h" #ifdef LINT @@ -17,7 +17,6 @@ #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/l_outdef.c b/lang/cem/cemcom.ansi/l_outdef.c index a88945f6e..32e2172b8 100644 --- a/lang/cem/cemcom.ansi/l_outdef.c +++ b/lang/cem/cemcom.ansi/l_outdef.c @@ -5,7 +5,7 @@ /* $Id$ */ /* Lint outdef construction */ -#include "lint.h" +#include "parameters.h" #ifdef LINT @@ -26,7 +26,6 @@ #include "def.h" #include "struct.h" #include "field.h" -#include "idf.h" #include "level.h" #include "label.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/l_states.c b/lang/cem/cemcom.ansi/l_states.c index 99e1a4971..74d31b359 100644 --- a/lang/cem/cemcom.ansi/l_states.c +++ b/lang/cem/cemcom.ansi/l_states.c @@ -5,21 +5,19 @@ /* $Id$ */ /* Lint status checking */ -#include "lint.h" +#include "parameters.h" #ifdef LINT #include /* for st_free */ #include "interface.h" #include "assert.h" -#include "debug.h" #ifdef ANSI #include #endif /* ANSI */ #include "arith.h" #include "label.h" #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/label.c b/lang/cem/cemcom.ansi/label.c index 643000452..fb200956e 100644 --- a/lang/cem/cemcom.ansi/label.c +++ b/lang/cem/cemcom.ansi/label.c @@ -5,9 +5,10 @@ /* $Id$ */ /* L A B E L H A N D L I N G */ +#include "parameters.h" +#include "idf.h" #include "Lpars.h" #include "level.h" -#include "idf.h" #include "label.h" #include "arith.h" #include "def.h" diff --git a/lang/cem/cemcom.ansi/macro.str b/lang/cem/cemcom.ansi/macro.str index 1414741c4..f229cac9b 100644 --- a/lang/cem/cemcom.ansi/macro.str +++ b/lang/cem/cemcom.ansi/macro.str @@ -5,7 +5,7 @@ /* $Id$ */ /* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */ -#include "nopp.h" +#include "parameters.h" #ifndef NOPP /* The flags of the mc_flag field of the macro structure. Note that diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 4f56feb1d..556e23495 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -5,16 +5,11 @@ /* $Id$ */ /* MAIN PROGRAM */ -#include "lint.h" +#include "parameters.h" #include -#include "debug.h" -#include "nopp.h" -#include "trgt_sizes.h" -#include "use_tmp.h" -#include "inputtype.h" +#include "idf.h" #include "input.h" #include "level.h" -#include "idf.h" #include "arith.h" #include "type.h" #include "proto.h" @@ -24,7 +19,6 @@ #include "LLlex.h" #include #include "specials.h" -#include "nocross.h" #include "sizes.h" #include "align.h" #include "macro.h" diff --git a/lang/cem/cemcom.ansi/make.next b/lang/cem/cemcom.ansi/make.next index 26c24d0ce..06d50f0e0 100755 --- a/lang/cem/cemcom.ansi/make.next +++ b/lang/cem/cemcom.ansi/make.next @@ -1,6 +1,6 @@ #!/bin/sh -echo '#include "debug.h"' +echo '#include "parameters.h"' sed -n ' s:^.*ALLOCDEF.*"\(.*\)".*$:struct \1 *h_\1 = 0;\ #ifdef DEBUG\ diff --git a/lang/cem/cemcom.ansi/options.c b/lang/cem/cemcom.ansi/options.c index 379c7c603..a8f382302 100644 --- a/lang/cem/cemcom.ansi/options.c +++ b/lang/cem/cemcom.ansi/options.c @@ -5,23 +5,15 @@ /* $Id$ */ /* U S E R O P T I O N - H A N D L I N G */ +#include "parameters.h" #include #include -#include "lint.h" -#include "botch_free.h" #include -#include "nopp.h" -#include "idfsize.h" -#include "nobitfield.h" #include "class.h" #include "macro.h" -#include "idf.h" #include "arith.h" #include "sizes.h" #include "align.h" -#include "use_tmp.h" -#include "dataflow.h" -#include "dbsymtab.h" #ifndef NOPP extern char **inctable; diff --git a/lang/cem/cemcom.ansi/pragma.c b/lang/cem/cemcom.ansi/pragma.c index 92739dd9a..b4198d92b 100644 --- a/lang/cem/cemcom.ansi/pragma.c +++ b/lang/cem/cemcom.ansi/pragma.c @@ -5,8 +5,7 @@ /* $Id$ */ /* PREPROCESSOR: PRAGMA INTERPRETER */ -#include "debug.h" -#include "idf.h" +#include "parameters.h" #define P_UNKNOWN 0 #define NR_PRAGMAS 0 diff --git a/lang/cem/cemcom.ansi/program.g b/lang/cem/cemcom.ansi/program.g index 937effab6..861c97b2e 100644 --- a/lang/cem/cemcom.ansi/program.g +++ b/lang/cem/cemcom.ansi/program.g @@ -45,13 +45,10 @@ %start If_expr, control_if_expression; { -#include "lint.h" -#include "nopp.h" -#include "debug.h" +#include "parameters.h" #include #include "arith.h" #include "LLlex.h" -#include "idf.h" #include "label.h" #include "type.h" #include "declar.h" @@ -59,6 +56,7 @@ #include "code.h" #include "expr.h" #include "def.h" +#include "stack.h" #ifdef LINT #include "l_lint.h" #endif /* LINT */ diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index e1ff73a5e..1f7f6bf6d 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -5,19 +5,15 @@ /* $Id$ */ /* P R O T O T Y P E F I D D L I N G */ -#include "lint.h" -#include "debug.h" -#include "idfsize.h" -#include "nparams.h" -#include "botch_free.h" +#include "parameters.h" #include +#include "idf.h" #include "Lpars.h" #include "level.h" #include #include "arith.h" #include "align.h" #include "stack.h" -#include "idf.h" #include "def.h" #include "type.h" #include "struct.h" diff --git a/lang/cem/cemcom.ansi/replace.c b/lang/cem/cemcom.ansi/replace.c index 856c38d03..cde3aaf43 100644 --- a/lang/cem/cemcom.ansi/replace.c +++ b/lang/cem/cemcom.ansi/replace.c @@ -7,26 +7,18 @@ #include #include -#include "nopp.h" +#include "parameters.h" #ifndef NOPP -#include "debug.h" -#include "pathlength.h" -#include "strsize.h" -#include "nparams.h" -#include "idfsize.h" -#include "numsize.h" #include -#include "idf.h" +#include "idf.h" #include "input.h" #include "macro.h" #include "arith.h" #include "LLlex.h" #include "class.h" #include "assert.h" -#include "static.h" -#include "macbuf.h" #include "replace.h" extern struct idf *GetIdentifier(); diff --git a/lang/cem/cemcom.ansi/sizes.h b/lang/cem/cemcom.ansi/sizes.h index 69785fd04..0f38c5668 100644 --- a/lang/cem/cemcom.ansi/sizes.h +++ b/lang/cem/cemcom.ansi/sizes.h @@ -5,8 +5,7 @@ /* $Id$ */ /* VARIOUS TARGET MACHINE SIZE DESCRIPTORS */ -#include "nocross.h" -#include "trgt_sizes.h" +#include "parameters.h" #ifndef NOCROSS extern arith diff --git a/lang/cem/cemcom.ansi/skip.c b/lang/cem/cemcom.ansi/skip.c index c3687fd0a..d4a67142e 100644 --- a/lang/cem/cemcom.ansi/skip.c +++ b/lang/cem/cemcom.ansi/skip.c @@ -5,7 +5,7 @@ /* $Id$ */ /* PREPROCESSOR: INPUT SKIP FUNCTIONS */ -#include "nopp.h" +#include "parameters.h" #include "arith.h" #include "LLlex.h" #include "class.h" diff --git a/lang/cem/cemcom.ansi/stab.c b/lang/cem/cemcom.ansi/stab.c index 401d91b40..8c00838e3 100644 --- a/lang/cem/cemcom.ansi/stab.c +++ b/lang/cem/cemcom.ansi/stab.c @@ -9,7 +9,7 @@ /* $Id$ */ -#include "dbsymtab.h" +#include "parameters.h" #ifdef DBSYMTAB @@ -20,13 +20,13 @@ #include #include +#include "idf.h" #include "LLlex.h" #include "stack.h" #include "def.h" #include "type.h" #include "struct.h" #include "field.h" -#include "idf.h" #include "Lpars.h" #include "level.h" diff --git a/lang/cem/cemcom.ansi/stack.c b/lang/cem/cemcom.ansi/stack.c index b0cf97cab..49dfbfab4 100644 --- a/lang/cem/cemcom.ansi/stack.c +++ b/lang/cem/cemcom.ansi/stack.c @@ -5,21 +5,19 @@ /* $Id$ */ /* S T A C K / U N S T A C K R O U T I N E S */ -#include "lint.h" +#include "parameters.h" #include #ifndef LINT #include #else #include "l_em.h" #endif /* LINT */ -#include "debug.h" -#include "botch_free.h" #include +#include "idf.h" #include "Lpars.h" #include "arith.h" #include "stack.h" #include "type.h" -#include "idf.h" #include "def.h" #include "struct.h" #include "level.h" diff --git a/lang/cem/cemcom.ansi/statement.g b/lang/cem/cemcom.ansi/statement.g index 97fd969cc..9eb60d2ed 100644 --- a/lang/cem/cemcom.ansi/statement.g +++ b/lang/cem/cemcom.ansi/statement.g @@ -6,7 +6,7 @@ /* STATEMENT SYNTAX PARSER */ { -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #else @@ -14,15 +14,11 @@ #include "l_lint.h" #endif /* LINT */ -#include "debug.h" -#include "botch_free.h" -#include "dbsymtab.h" - #include +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "type.h" -#include "idf.h" #include "label.h" #include "expr.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/struct.c b/lang/cem/cemcom.ansi/struct.c index 805df0ba5..505107cc8 100644 --- a/lang/cem/cemcom.ansi/struct.c +++ b/lang/cem/cemcom.ansi/struct.c @@ -5,13 +5,11 @@ /* $Id$ */ /* ADMINISTRATION OF STRUCT AND UNION DECLARATIONS */ -#include "nobitfield.h" -#include "debug.h" -#include "botch_free.h" +#include "parameters.h" #include +#include "idf.h" #include "arith.h" #include "stack.h" -#include "idf.h" #include "def.h" #include "type.h" #include "proto.h" diff --git a/lang/cem/cemcom.ansi/switch.c b/lang/cem/cemcom.ansi/switch.c index 59413f668..856e1b115 100644 --- a/lang/cem/cemcom.ansi/switch.c +++ b/lang/cem/cemcom.ansi/switch.c @@ -5,18 +5,14 @@ /* $Id$ */ /* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #endif /* LINT */ -#include "debug.h" -#include "botch_free.h" #include -#include "density.h" #include "Lpars.h" -#include "idf.h" #include "label.h" #include #include "arith.h" diff --git a/lang/cem/cemcom.ansi/tokenname.c b/lang/cem/cemcom.ansi/tokenname.c index 75e593174..8c52b4dcb 100644 --- a/lang/cem/cemcom.ansi/tokenname.c +++ b/lang/cem/cemcom.ansi/tokenname.c @@ -5,7 +5,8 @@ /* $Id$ */ /* TOKEN NAME DEFINITIONS */ -#include "idf.h" +#include "parameters.h" +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "tokenname.h" diff --git a/lang/cem/cemcom.ansi/type.c b/lang/cem/cemcom.ansi/type.c index ef0d2cdf0..2b477a725 100644 --- a/lang/cem/cemcom.ansi/type.c +++ b/lang/cem/cemcom.ansi/type.c @@ -5,14 +5,12 @@ /* $Id$ */ /* T Y P E D E F I N I T I O N M E C H A N I S M */ -#include "nobitfield.h" -#include "debug.h" -#include "botch_free.h" +#include "parameters.h" #include +#include "idf.h" #include "Lpars.h" #include "arith.h" #include "type.h" -#include "idf.h" #include "def.h" #include "proto.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/type.str b/lang/cem/cemcom.ansi/type.str index c1c6205d6..8796d61a4 100644 --- a/lang/cem/cemcom.ansi/type.str +++ b/lang/cem/cemcom.ansi/type.str @@ -5,8 +5,7 @@ /* $Id$ */ /* TYPE DESCRIPTOR */ -#include "nobitfield.h" -#include "dbsymtab.h" +#include "parameters.h" struct type { struct type *next; /* used for ARRAY and for qualifiers */ diff --git a/lang/cem/cemcom.ansi/util.c b/lang/cem/cemcom.ansi/util.c index 9b9d1151c..7326f04ec 100644 --- a/lang/cem/cemcom.ansi/util.c +++ b/lang/cem/cemcom.ansi/util.c @@ -11,7 +11,7 @@ allowing re-use. */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #else @@ -22,10 +22,7 @@ #include #include -#include "debug.h" #include "util.h" -#include "use_tmp.h" -#include "regcount.h" #include "sizes.h" #include "align.h" #include "stack.h" diff --git a/lang/cem/cemcom/eval.c b/lang/cem/cemcom/eval.c index abfc1a2b1..542980db4 100644 --- a/lang/cem/cemcom/eval.c +++ b/lang/cem/cemcom/eval.c @@ -39,7 +39,7 @@ arith NewLocal(); /* util.c */ #define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER) /* EVAL() is the main expression-tree evaluator, which turns - any legal expression tree into EM code. Parameters: + any legal expression tree into EM code. parameters.h: struct expr *expr pointer to root of the expression tree to be evaluated diff --git a/lang/cem/cemcom/replace.c b/lang/cem/cemcom/replace.c index 15f9c1df8..758d14df8 100644 --- a/lang/cem/cemcom/replace.c +++ b/lang/cem/cemcom/replace.c @@ -70,7 +70,7 @@ replace(idef) return 0; } if (++mac->mc_count > 100) { - /* 100 must be some number in Parameters */ + /* 100 must be some number in parameters.h */ lexwarning("macro %s is assumed recursive", idef->id_text); return 0; diff --git a/lang/cem/cpp.ansi/LLlex.c b/lang/cem/cpp.ansi/LLlex.c index e828ac704..3cd162898 100644 --- a/lang/cem/cpp.ansi/LLlex.c +++ b/lang/cem/cpp.ansi/LLlex.c @@ -5,9 +5,7 @@ /* $Id$ */ /* L E X I C A L A N A L Y Z E R */ -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" +#include "parameters.h" #include #include "input.h" diff --git a/lang/cem/cpp.ansi/bits.h b/lang/cem/cpp.ansi/bits.h index 95eb2f3ca..7473d935a 100644 --- a/lang/cem/cpp.ansi/bits.h +++ b/lang/cem/cpp.ansi/bits.h @@ -3,7 +3,7 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ -#include "dobits.h" +#include "parameters.h" #ifdef DOBITS #define bit0 0x01 #define bit1 0x02 diff --git a/lang/cem/cpp.ansi/build.mk b/lang/cem/cpp.ansi/build.mk new file mode 100644 index 000000000..e102c523b --- /dev/null +++ b/lang/cem/cpp.ansi/build.mk @@ -0,0 +1,104 @@ +D := lang/cem/cpp.ansi + +define build-cpp-ansi-allocd-header +$1: $2 $D/make.allocd + @echo ALLOCD $1 + @mkdir -p $(dir $1) + $(hide) $D/make.allocd < $2 > $1 + +$(eval CLEANABLES += $1) +endef + +define build-cpp-ansi-tokfile +$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c + @echo TOKENFILE $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) +endef + +define build-cpp-ansi-tokcase +$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c + @echo TOKCASE $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.tokcase < $D/tokenname.c > $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) +endef + +define build-cpp-ansi-next +$(OBJDIR)/$D/next.c: $D/make.next $D/macro.str $D/replace.str + @echo NEXT $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.next $D/macro.str $D/replace.str > $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/next.c) +endef + +define build-cpp-ansi-impl + $(eval $(call build-cpp-ansi-next)) + $(eval $(call build-cpp-ansi-tokcase)) + $(eval $(call build-cpp-ansi-tokfile)) + $(eval $(call build-cpp-ansi-allocd-header, \ + $(OBJDIR)/$D/macro.h, $D/macro.str \ + )) + $(eval $(call build-cpp-ansi-allocd-header, \ + $(OBJDIR)/$D/replace.h, $D/replace.str \ + )) + + $(call reset) + $(eval cflags += -I$(OBJDIR)/$D -I$D) + + $(call cfile, $D/LLlex.c) + $(call cfile, $D/LLmessage.c) + $(call cfile, $D/ch3bin.c) + $(call cfile, $D/ch3mon.c) + $(call cfile, $D/domacro.c) + $(call cfile, $D/error.c) + $(call cfile, $D/idf.c) + $(call cfile, $D/init.c) + $(call cfile, $D/input.c) + $(call cfile, $D/main.c) + $(call cfile, $D/options.c) + $(call cfile, $D/preprocess.c) + $(call cfile, $D/replace.c) + $(call cfile, $D/skip.c) + $(call cfile, $D/tokenname.c) + $(call cfile, $D/expr.c) + $(call cfile, $(OBJDIR)/$D/symbol2str.c) + $(call cfile, $(OBJDIR)/$D/next.c) + + $(call llgen, $(OBJDIR)/$D, $(OBJDIR)/$D/tokenfile.g $D/expression.g) + + $(call file, $(LIBINPUT)) + $(call file, $(LIBASSERT)) + $(call file, $(LIBALLOC)) + $(call file, $(LIBPRINT)) + $(call file, $(LIBSYSTEM)) + $(call file, $(LIBSTRING)) + + $(call tabgen, $D/char.tab) + + $(eval $q: \ + $(OBJDIR)/$D/macro.h \ + $(OBJDIR)/$D/Lpars.h \ + $(INCDIR)/alloc.h \ + $(INCDIR)/inp_pkg.spec \ + $(INCDIR)/idf_pkg.spec \ + $(OBJDIR)/$D/replace.h \ + $(INCDIR)/system.h \ + $(INCDIR)/inp_pkg.body \ + $(INCDIR)/inp_pkg.spec \ + $(INCDIR)/idf_pkg.body) + + $(call cprogram, $(BINDIR)/cpp.ansi) + $(call installto, $(PLATDEP)/cpp.ansi) + $(eval CPPANSI := $o) + + $(call reset) + $(eval q := $D/ncpp.6) + $(call installto, $(INSDIR)/share/man/man6/cpp.ansi.6) +endef + +$(eval $(build-cpp-ansi-impl)) diff --git a/lang/cem/cpp.ansi/domacro.c b/lang/cem/cpp.ansi/domacro.c index 47f09af28..a5cc9407d 100644 --- a/lang/cem/cpp.ansi/domacro.c +++ b/lang/cem/cpp.ansi/domacro.c @@ -5,25 +5,19 @@ /* $Id$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ +#include #include "arith.h" #include "LLlex.h" #include "Lpars.h" #include "idf.h" #include "input.h" -#include "ifdepth.h" -#include "botch_free.h" -#include "nparams.h" -#include "parbufsize.h" -#include "textsize.h" -#include "idfsize.h" -#include "debug.h" +#include "parameters.h" #include #include #include "class.h" #include "macro.h" #include "bits.h" -#include "macbuf.h" #include "replace.h" extern char options[]; diff --git a/lang/cem/cpp.ansi/error.c b/lang/cem/cpp.ansi/error.c index a567b3d4a..0920976b8 100644 --- a/lang/cem/cpp.ansi/error.c +++ b/lang/cem/cpp.ansi/error.c @@ -12,8 +12,8 @@ #include #endif +#include "parameters.h" #include "arith.h" -#include "errout.h" #include "LLlex.h" /* This file contains the (non-portable) error-message and diagnostic diff --git a/lang/cem/cpp.ansi/input.h b/lang/cem/cpp.ansi/input.h index 97a81983a..55a79acde 100644 --- a/lang/cem/cpp.ansi/input.h +++ b/lang/cem/cpp.ansi/input.h @@ -4,7 +4,6 @@ */ /* $Id$ */ #define INP_PUSHBACK 3 -#include "inputtype.h" #include /* Note: The following macro only garuantees one PushBack. diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index 46f9fd2b7..db444ae80 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -5,14 +5,14 @@ /* $Id$ */ /* MAIN PROGRAM */ -#include "debug.h" +#include +#include "parameters.h" #include #include #include #include "arith.h" #include "file_info.h" -#include "idfsize.h" #include "idf.h" #include "macro.h" diff --git a/lang/cem/cpp.ansi/make.hfiles b/lang/cem/cpp.ansi/make.hfiles deleted file mode 100755 index 3bc972faf..000000000 --- a/lang/cem/cpp.ansi/make.hfiles +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -: Update Files from database - -PATH=/bin:/usr/bin - -case $# in -1) ;; -*) echo use: $0 file >&2 - exit 1 -esac - -( -IFCOMMAND="if [ -r \$FN ] ;\ - then if cmp -s \$FN \$TMP;\ - then rm \$TMP;\ - else mv \$TMP \$FN;\ - echo update \$FN;\ - fi;\ - else mv \$TMP \$FN;\ - echo create \$FN;\ - fi" -echo 'TMP=.uf$$' -echo 'FN=$TMP' -echo 'cat >$TMP <<\!EOF!' -sed -n '/^!File:/,${ -/^$/d -/^!File:[ ]*\(.*\)$/s@@!EOF!\ -'"$IFCOMMAND"'\ -FN=\1\ -cat >$TMP <<\\!EOF!@ -p -}' $1 -echo '!EOF!' -echo $IFCOMMAND -) | eval "$(cat)" diff --git a/lang/cem/cpp.ansi/options.c b/lang/cem/cpp.ansi/options.c index fb16ef8fb..21d1e2212 100644 --- a/lang/cem/cpp.ansi/options.c +++ b/lang/cem/cpp.ansi/options.c @@ -8,7 +8,7 @@ #include #include #include "alloc.h" -#include "idfsize.h" +#include "parameters.h" #include "class.h" #include "macro.h" #include "idf.h" diff --git a/lang/cem/cpp.ansi/Parameters b/lang/cem/cpp.ansi/parameters.h similarity index 72% rename from lang/cem/cpp.ansi/Parameters rename to lang/cem/cpp.ansi/parameters.h index 091744391..37bdebe12 100644 --- a/lang/cem/cpp.ansi/Parameters +++ b/lang/cem/cpp.ansi/parameters.h @@ -1,72 +1,67 @@ -!File: pathlength.h +#ifndef PARAMETERS_H +#define PARAMETERS_H + #define PATHLENGTH 1024 /* max. length of path to file */ -!File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ #define MAXERR_LINE 5 /* maximum number of error messages given on the same input line. */ -!File: idfsize.h #define IDFSIZE 64 /* maximum significant length of an identifier */ -!File: numsize.h #define NUMSIZE 256 /* maximum length of a numeric constant */ -!File: nparams.h #define NPARAMS 32 /* maximum number of parameters of macros */ #define STDC_NPARAMS 31 /* ANSI limit on number of parameters */ -!File: ifdepth.h #define IFDEPTH 256 /* maximum number of nested if-constructions */ -!File: macbuf.h #define LAPBUF 128 /* initial size of macro replacement buffer */ #define ARGBUF 128 /* initial size of macro parameter buffer(s) */ -!File: strsize.h #define ISTRSIZE 16 /* minimum number of bytes allocated for storing a string */ -!File: botch_free.h -/*#define BOTCH_FREE 1 /* botch freed memory, as a check */ +#if 0 +#define BOTCH_FREE 1 /* botch freed memory, as a check */ +#endif -!File: debug.h -/*#define DEBUG 1 /* perform various self-tests */ +#if 0 +#define DEBUG 1 /* perform various self-tests */ +#endif #define NDEBUG 1 /* disable assertions */ -!File: parbufsize.h #define PARBUFSIZE 1024 -!File: textsize.h #define ITEXTSIZE 16 /* 1st piece of memory for repl. text */ -!File: inputtype.h -/*#define INP_READ_IN_ONE 1 /* read input file in one. */ +#if 0 +#define INP_READ_IN_ONE 1 /* read input file in one. */ /* If defined, we cannot read from a pipe */ +#endif -!File: obufsize.h #define OBUFSIZE 8192 /* output buffer size */ -!File: dobits.h #define DOBITS 1 /* use trick to reduce symboltable accesses */ -!File: ln_prefix.h #define LINE_PREFIX "#" /* prefix for generated line directives, either "#" or "#line" */ +#endif + diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index 72fa647e9..7c3840d80 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -10,16 +10,13 @@ #include #include #include "input.h" -#include "obufsize.h" +#include "parameters.h" #include "arith.h" #include "LLlex.h" #include "class.h" #include "macro.h" #include "idf.h" -#include "idfsize.h" #include "bits.h" -#include "ln_prefix.h" -#include "textsize.h" char _obuf[OBUFSIZE]; #ifdef DOBITS diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index 94bb22f3a..255902f68 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -9,11 +9,7 @@ #include #include -#include "pathlength.h" -#include "strsize.h" -#include "nparams.h" -#include "idfsize.h" -#include "numsize.h" +#include "parameters.h" #include "alloc.h" #include "idf.h" #include "input.h" @@ -21,9 +17,7 @@ #include "arith.h" #include "LLlex.h" #include "class.h" -#include "debug.h" #include "assert.h" -#include "macbuf.h" #include "replace.h" extern char *GetIdentifier(); diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk new file mode 100644 index 000000000..640f7f344 --- /dev/null +++ b/lang/cem/libcc.ansi/build.mk @@ -0,0 +1,36 @@ +define build-libcc-ansi-headers-install-one-impl + $(call reset) + $(eval q := lang/cem/libcc.ansi/headers/$(strip $1)) + $(call installto, $(PLATIND)/include/ansi/$(strip $1)) + $(eval LIBCCANSIHEADERS += $o) +endef + +define build-libcc-ansi-headers-impl + $(eval g := \ + sys/time.h \ + sys/ioctl.h \ + assert.h \ + ctype.h \ + errno.h \ + float.h \ + limits.h \ + math.h \ + setjmp.h \ + signal.h \ + stdarg.h \ + stddef.h \ + stdint.h \ + stdio.h \ + stdlib.h \ + string.h \ + time.h \ + iso646.h \ + stdbool.h \ + locale.h \ + tgmath.h) + + $(eval LIBCCANSIHEADERS :=) + $(foreach f,$g,$(call build-libcc-ansi-headers-install-one-impl,$f)) +endef + +$(eval $(build-libcc-ansi-headers-impl)) diff --git a/lang/pc/comp/enter.c b/lang/pc/comp/enter.c index 703b37671..ec50ae9c2 100644 --- a/lang/pc/comp/enter.c +++ b/lang/pc/comp/enter.c @@ -219,7 +219,7 @@ EnterParTypes(fpl, parlist) register struct node *fpl; struct paramlist **parlist; { - /* Parameters in heading of procedural and functional + /* parameters.h in heading of procedural and functional parameters (only types are important, not the names). */ register arith nb_pars = 0; diff --git a/lib/descr/fe b/lib/descr/fe index aa2f33bac..2e69b0f3b 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -4,15 +4,15 @@ # Don't generate line updating code by default (i.e.: -L flag provided to cem). # To put it on again: use -NL var LFLAG=-L -var MODULA2_INCLUDES=-I{EM}/include/m2 -var OCCAM_INCLUDES=-I{EM}/include/occam -var C_INCLUDES=-I{EM}/include/ansi +var MODULA2_INCLUDES=-I{EM}/share/ack/include/m2 +var OCCAM_INCLUDES=-I{EM}/share/ack/include/occam +var C_INCLUDES=-I{EM}/share/ack/include/ansi callname ack name cpp # no from, this is a preprocessor to .i - program {EM}/lib.bin/cpp.ansi + program {EM}/lib/ack/cpp.ansi mapflag -I* CPP_F={CPP_F?} -I* mapflag -U* CPP_F={CPP_F?} -U* mapflag -D* CPP_F={CPP_F?} -D* @@ -38,7 +38,7 @@ end name f77 from .f to .c - program {EM}/lib.bin/f2c + program {EM}/lib/ack/f2c mapflag -ansi F2_F={F2_F?} -A mapflag -w* F2_F={F2_F?} -w* args \ @@ -54,7 +54,7 @@ end name cem from .c to .k - program {EM}/lib.bin/em_cemcom.ansi + program {EM}/lib/ack/em_cemcom.ansi # mapflag -I* CPP_F={CPP_F?} -I* # mapflag -U* CPP_F={CPP_F?} -U* # mapflag -D* CPP_F={CPP_F?} -D* @@ -93,7 +93,7 @@ end name pc from .p to .k - program {EM}/lib.bin/em_pc + program {EM}/lib/ack/em_pc mapflag -L PC_F={PC_F?} -L # mapflag -s PC_F={PC_F?} -s mapflag -_ PC_F={PC_F?} -U @@ -118,7 +118,7 @@ end name m2 from .mod.def to .k - program {EM}/lib.bin/em_m2 + program {EM}/lib/ack/em_m2 mapflag -I* M2_INCL={M2_INCL?} -I* mapflag -L M2_F={M2_F?} -L mapflag -g* M2_F={M2_F?} -g* @@ -142,7 +142,7 @@ end name ocm from .ocm to .k - program {EM}/lib.bin/em_occam + program {EM}/lib/ack/em_occam mapflag -L OCM_F={OCM_F?} -L mapflag -V* OCM_F={OCM_F?} -V* args -Vw{w}p{p}l{l} {OCM_F?} @@ -168,7 +168,7 @@ name abc need .b callname abc end -var A68INIT={EM}/lib.bin/em_a68s_init +var A68INIT={EM}/lib/ack/em_a68s_init name a68s from .8.a68 to .k @@ -183,7 +183,7 @@ end name encode from .e to .k - program {EM}/lib.bin/em_encode + program {EM}/lib/ack/em_encode args < prep cond stdout @@ -191,7 +191,7 @@ end name opt from .k to .m - program {EM}/lib.bin/em_opt + program {EM}/lib/ack/em_opt mapflag -LIB OPT_F={OPT_F?} -L # when running the global optimizer, no multiplication optimization here. mapflag -O2 OPT2_F=-m0 @@ -204,7 +204,7 @@ end name ego from .m.ma to .gk - program {EM}/lib.bin/em_ego + program {EM}/lib/ack/em_ego mapflag -EGO-* EGO_F={EGO_F?} -* # The following lines are obsolete, but here for backwards compatibility. # They should be removed some day. @@ -237,7 +237,7 @@ name opt2 # of the em peephole optimizer from .gk to .g - program {EM}/lib.bin/em_opt2 + program {EM}/lib/ack/em_opt2 # mapflag -LIB OPT_F={OPT_F?} -L args {OPT_F?} {MACHOPT_F?} < optimizer @@ -246,7 +246,7 @@ end name decode from .k.m.g.gk to .e - program {EM}/lib.bin/em_decode + program {EM}/lib/ack/em_decode args < stdout end diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk new file mode 100644 index 000000000..d98fe7454 --- /dev/null +++ b/mach/proto/as/build.mk @@ -0,0 +1,43 @@ +define build-as-impl + $(call reset) + + $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D) + $(eval objdir := $D) + + $(call cfile, mach/proto/as/comm3.c) + $(call dependson, $(OBJDIR)/$D/y.tab.h) + + $(call cfile, mach/proto/as/comm4.c) + $(call dependson, $(OBJDIR)/$D/y.tab.h) + + $(call cfile, mach/proto/as/comm5.c) + $(call dependson, $(OBJDIR)/$D/y.tab.h) + + $(call cfile, mach/proto/as/comm6.c) + $(call dependson, $(OBJDIR)/$D/y.tab.h) + + $(call cfile, mach/proto/as/comm7.c) + $(call dependson, $(OBJDIR)/$D/y.tab.h) + + $(call cfile, mach/proto/as/comm8.c) + $(call dependson, $(OBJDIR)/$D/y.tab.h) + + $(call yacc, $(OBJDIR)/$D, $(OBJDIR)/$D/preprocessed-comm2.y) + +$(eval CLEANABLES += $(OBJDIR)/$D/preprocessed-comm2.y) +$(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) + @echo PREPROCESS $$@ + @mkdir -p $$(dir $$@) + $(hide) $(CPPANSI) -P \ + -Imach/$(ARCH)/as \ + -Imach/proto/as \ + -Ih \ + mach/proto/as/comm2.y > $$@ + + $(call file, $(LIBOBJECT)) + $(call cprogram, $(BINDIR)/$(PLATFORM)/as) + $(call installto, $(PLATDEP)/$(PLATFORM)/as) +endef + +build-as = $(eval $(build-as-impl)) + diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk new file mode 100644 index 000000000..e3843b7f3 --- /dev/null +++ b/mach/proto/ncg/build.mk @@ -0,0 +1,46 @@ +define build-ncg-impl + +$(call reset) + +$(eval cflags += -Imach/$(ARCH)/ncg -I$(OBJDIR)/$D -Imach/proto/ncg) +$(eval objdir := $D/ncg) + +$(call cfile, mach/proto/ncg/codegen.c) +$(call cfile, mach/proto/ncg/compute.c) +$(call cfile, mach/proto/ncg/equiv.c) +$(call cfile, mach/proto/ncg/fillem.c) +$(call cfile, mach/proto/ncg/gencode.c) +$(call cfile, mach/proto/ncg/glosym.c) +$(call cfile, mach/proto/ncg/label.c) +$(call cfile, mach/proto/ncg/main.c) +$(call cfile, mach/proto/ncg/move.c) +$(call cfile, mach/proto/ncg/nextem.c) +$(call cfile, mach/proto/ncg/reg.c) +$(call cfile, mach/proto/ncg/regvar.c) +$(call cfile, mach/proto/ncg/salloc.c) +$(call cfile, mach/proto/ncg/state.c) +$(call cfile, mach/proto/ncg/subr.c) +$(call cfile, mach/proto/ncg/var.c) + +$(eval $q: $(OBJDIR)/$D/tables.h) +$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/table.c) +$(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h +$(OBJDIR)/$D/tables.h: $(NCGG) $(CPPANSI) mach/$(ARCH)/ncg/table + @echo NCGG $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $$(dir $$@) && \ + $(abspath $(CPPANSI)) $(abspath mach/$(ARCH)/ncg/table) | $(abspath $(NCGG)) + $(hide) mv $(OBJDIR)/$D/tables.H $(OBJDIR)/$D/tables.h + +$(call cfile, $(OBJDIR)/$D/tables.c) + +$(call file, $(LIBEM_DATA)) +$(call file, $(LIBFLT_ARITH)) + +$(call cprogram, $(BINDIR)/$(PLATFORM)/ncg) +$(call installto, $(PLATDEP)/$(PLATFORM)/ncg) + +endef + +build-ncg = $(eval $(build-ncg-impl)) + diff --git a/modules/src/alloc/build.mk b/modules/src/alloc/build.mk new file mode 100644 index 000000000..808dcca4a --- /dev/null +++ b/modules/src/alloc/build.mk @@ -0,0 +1,23 @@ +D := modules/src/alloc + +define build-liballoc-impl + $(call reset) + $(call cfile, $D/Malloc.c) + $(call cfile, $D/Salloc.c) + $(call cfile, $D/Srealloc.c) + $(call cfile, $D/Realloc.c) + $(call cfile, $D/botch.c) + $(call cfile, $D/clear.c) + $(call cfile, $D/st_alloc.c) + $(call cfile, $D/std_alloc.c) + $(call cfile, $D/No_Mem.c) + $(call clibrary, $(LIBDIR)/liballoc.a) + LIBALLOC := $o + + $(call reset) + $(eval q := $D/alloc.h) + $(call copyto, $(INCDIR)/alloc.h) +endef + +$(eval $(build-liballoc-impl)) + diff --git a/modules/src/em_code/build.mk b/modules/src/em_code/build.mk new file mode 100644 index 000000000..8fcba3c7f --- /dev/null +++ b/modules/src/em_code/build.mk @@ -0,0 +1,89 @@ +D := modules/src/em_code + +# $1 = capital letter for library specialisation (E or K) +# $2 = lowercase letter for library specialisation (e or k) +# $3 = cflags that specalise this library + +define build-em_code-impl + $(call reset) + $(eval cflags += $3) + $(eval objdir := $D/$1) + $(call cfile, $D/bhcst.c) + $(call cfile, $D/bhdlb.c) + $(call cfile, $D/bhdnam.c) + $(call cfile, $D/bhfcon.c) + $(call cfile, $D/bhicon.c) + $(call cfile, $D/bhilb.c) + $(call cfile, $D/bhpnam.c) + $(call cfile, $D/bhucon.c) + $(call cfile, $D/crcst.c) + $(call cfile, $D/crdlb.c) + $(call cfile, $D/crdnam.c) + $(call cfile, $D/crxcon.c) + $(call cfile, $D/crilb.c) + $(call cfile, $D/crpnam.c) + $(call cfile, $D/crscon.c) + $(call cfile, $D/cst.c) + $(call cfile, $D/dfdlb.c) + $(call cfile, $D/dfdnam.c) + $(call cfile, $D/dfilb.c) + $(call cfile, $D/dlb.c) + $(call cfile, $D/dnam.c) + $(call cfile, $D/end.c) + $(call cfile, $D/endarg.c) + $(call cfile, $D/exc.c) + $(call cfile, $D/fcon.c) + $(call cfile, $D/getid.c) + $(call cfile, $D/icon.c) + $(call cfile, $D/ilb.c) + $(call cfile, $D/insert.c) + $(call cfile, $D/internerr.c) + $(call cfile, $D/msend.c) + $(call cfile, $D/op.c) + $(call cfile, $D/opcst.c) + $(call cfile, $D/opdlb.c) + $(call cfile, $D/opdnam.c) + $(call cfile, $D/opilb.c) + $(call cfile, $D/opnarg.c) + $(call cfile, $D/oppnam.c) + $(call cfile, $D/pnam.c) + $(call cfile, $D/pro.c) + $(call cfile, $D/pronarg.c) + $(call cfile, $D/msstart.c) + $(call cfile, $D/psdlb.c) + $(call cfile, $D/psdnam.c) + $(call cfile, $D/pspnam.c) + $(call cfile, $D/scon.c) + $(call cfile, $D/ucon.c) + $(call cfile, $D/C_out.c) + $(call cfile, $D/failed.c) + $(call cfile, $D/em.c) + + $(eval $q: $(INCDIR)/em_codeEK.h) + + $(call clibrary, $(LIBDIR)/libem$2.a) + $(eval LIBEM$1 := $o) +endef + +define build-em_code-header-impl +$(OBJDIR)/$D/em_codeEK.h: $D/make.em.gen $D/em.nogen h/em_table + @echo MAKE_EM_GEN $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.em.gen h/em_table > $$@ + $(hide) cat $D/em.nogen >> $$@ + +$(call reset) +$(eval q := $(OBJDIR)/$D/em_codeEK.h) +$(eval CLEANABLES += $q) +$(call copyto, $(INCDIR)/em_codeEK.h) + +$(eval CLEANABLES += $o) +$(eval $o: $(INCDIR)/em_pseu.h) + +endef + +$(eval $(call build-em_code-header-impl)) +$(eval $(call build-em_code-impl,E,e, -DREADABLE_EM)) +$(eval $(call build-em_code-impl,K,k, )) + + diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index 9da09a430..f7526b8e4 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -9,6 +9,7 @@ they can be written immediately. */ +#include #include #include #include "insert.h" diff --git a/modules/src/em_mes/build.mk b/modules/src/em_mes/build.mk new file mode 100644 index 000000000..7ae262114 --- /dev/null +++ b/modules/src/em_mes/build.mk @@ -0,0 +1,26 @@ +D := modules/src/em_mes + +define build-em_mes-impl + $(call reset) + $(call cfile, $D/C_ms_err.c) + $(call cfile, $D/C_ms_opt.c) + $(call cfile, $D/C_ms_emx.c) + $(call cfile, $D/C_ms_reg.c) + $(call cfile, $D/C_ms_src.c) + $(call cfile, $D/C_ms_flt.c) + $(call cfile, $D/C_ms_com.c) + $(call cfile, $D/C_ms_par.c) + $(call cfile, $D/C_ms_ego.c) + $(call cfile, $D/C_ms_gto.c) + $(call cfile, $D/C_ms_stb.c) + $(call cfile, $D/C_ms_std.c) + + $(eval $q: $(INCDIR)/em_codeEK.h) + + $(call clibrary, $(LIBDIR)/libem_mes.a) + $(eval LIBEM_MES := $o) +endef + +$(eval $(call build-em_mes-impl)) + + diff --git a/modules/src/flt_arith/build.mk b/modules/src/flt_arith/build.mk new file mode 100644 index 000000000..6a34b7d46 --- /dev/null +++ b/modules/src/flt_arith/build.mk @@ -0,0 +1,29 @@ +D := modules/src/flt_arith + +define build-libflt_arith-impl + $(call reset) + $(call cfile, $D/flt_ar2flt.c) + $(call cfile, $D/flt_div.c) + $(call cfile, $D/flt_flt2ar.c) + $(call cfile, $D/flt_modf.c) + $(call cfile, $D/flt_str2fl.c) + $(call cfile, $D/flt_cmp.c) + $(call cfile, $D/flt_add.c) + $(call cfile, $D/b64_add.c) + $(call cfile, $D/flt_mul.c) + $(call cfile, $D/flt_nrm.c) + $(call cfile, $D/b64_sft.c) + $(call cfile, $D/flt_umin.c) + $(call cfile, $D/flt_chk.c) + $(call cfile, $D/split.c) + $(call cfile, $D/ucmp.c) + $(call clibrary, $(LIBDIR)/libflt_arith.a) + LIBFLT_ARITH := $o + + $(call reset) + $(eval q := $D/flt_arith.h) + $(call copyto, $(INCDIR)/flt_arith.h) +endef + +$(eval $(build-libflt_arith-impl)) + diff --git a/modules/src/idf/build.mk b/modules/src/idf/build.mk new file mode 100644 index 000000000..b8dee6f79 --- /dev/null +++ b/modules/src/idf/build.mk @@ -0,0 +1,14 @@ +D := modules/src/idf + +define build-libidf-impl + $(call reset) + $(eval q := $D/idf_pkg.body) + $(call copyto, $(INCDIR)/idf_pkg.body) + + $(call reset) + $(eval q := $D/idf_pkg.spec) + $(call copyto, $(INCDIR)/idf_pkg.spec) +endef + +$(eval $(build-libidf-impl)) + diff --git a/modules/src/input/build.mk b/modules/src/input/build.mk new file mode 100644 index 000000000..ef6e1aac0 --- /dev/null +++ b/modules/src/input/build.mk @@ -0,0 +1,20 @@ +D := modules/src/input + +define build-libinput-impl + $(call reset) + $(call cfile, $D/AtEoIF.c) + $(call cfile, $D/AtEoIT.c) + $(call clibrary, $(LIBDIR)/libinput.a) + $(eval LIBINPUT := $o) + + $(call reset) + $(eval q := $D/inp_pkg.body) + $(call copyto, $(INCDIR)/inp_pkg.body) + + $(call reset) + $(eval q := $D/inp_pkg.spec) + $(call copyto, $(INCDIR)/inp_pkg.spec) +endef + +$(eval $(build-libinput-impl)) + diff --git a/modules/src/object/build.mk b/modules/src/object/build.mk new file mode 100644 index 000000000..d256cba92 --- /dev/null +++ b/modules/src/object/build.mk @@ -0,0 +1,27 @@ +D := modules/src/object + +define build-libobject-impl + $(call reset) + $(call cfile, $D/rd.c) + $(call cfile, $D/rd_arhdr.c) + $(call cfile, $D/rd_bytes.c) + $(call cfile, $D/rd_int2.c) + $(call cfile, $D/rd_long.c) + $(call cfile, $D/rd_ranlib.c) + $(call cfile, $D/rd_unsig2.c) + $(call cfile, $D/wr.c) + $(call cfile, $D/wr_arhdr.c) + $(call cfile, $D/wr_bytes.c) + $(call cfile, $D/wr_int2.c) + $(call cfile, $D/wr_long.c) + $(call cfile, $D/wr_putc.c) + $(call cfile, $D/wr_ranlib.c) + + $(eval $q: $(INCDIR)/local.h) + + $(call clibrary, $(LIBDIR)/libobject.a) + LIBOBJECT := $o +endef + +$(eval $(build-libobject-impl)) + diff --git a/modules/src/print/build.mk b/modules/src/print/build.mk new file mode 100644 index 000000000..17974b4d6 --- /dev/null +++ b/modules/src/print/build.mk @@ -0,0 +1,22 @@ +D := modules/src/print + +define build-libprint-impl + $(call reset) + $(call cfile, $D/doprnt.c) + $(call cfile, $D/fprint.c) + $(call cfile, $D/print.c) + $(call cfile, $D/sprint.c) + $(call cfile, $D/format.c) + + $(eval $q: $(INCDIR)/system.h) + + $(call clibrary, $(LIBDIR)/libprint.a) + LIBPRINT := $o + + $(call reset) + $(eval q := $D/print.h) + $(call copyto, $(INCDIR)/print.h) +endef + +$(eval $(build-libprint-impl)) + diff --git a/modules/src/string/build.mk b/modules/src/string/build.mk new file mode 100644 index 000000000..7139f1e8e --- /dev/null +++ b/modules/src/string/build.mk @@ -0,0 +1,19 @@ +D := modules/src/string + +define build-libstring-impl + $(call reset) + $(call cfile, $D/bts2str.c) + $(call cfile, $D/btscat.c) + $(call cfile, $D/btscmp.c) + $(call cfile, $D/btscpy.c) + $(call cfile, $D/btszero.c) + $(call cfile, $D/long2str.c) + $(call cfile, $D/str2bts.c) + $(call cfile, $D/str2long.c) + $(call cfile, $D/strzero.c) + $(call clibrary, $(LIBDIR)/libstring.a) + LIBSTRING := $o +endef + +$(eval $(build-libstring-impl)) + diff --git a/modules/src/system/build.mk b/modules/src/system/build.mk new file mode 100644 index 000000000..e76b5c5e3 --- /dev/null +++ b/modules/src/system/build.mk @@ -0,0 +1,29 @@ +D := modules/src/system + +define build-libsystem-impl + $(call reset) + $(call cfile, $D/access.c) + $(call cfile, $D/break.c) + $(call cfile, $D/chmode.c) + $(call cfile, $D/close.c) + $(call cfile, $D/create.c) + $(call cfile, $D/filesize.c) + $(call cfile, $D/open.c) + $(call cfile, $D/read.c) + $(call cfile, $D/remove.c) + $(call cfile, $D/stop.c) + $(call cfile, $D/system.c) + $(call cfile, $D/time.c) + $(call cfile, $D/write.c) + $(call cfile, $D/seek.c) + $(call cfile, $D/rename.c) + $(call clibrary, $(LIBDIR)/libsystem.a) + LIBSYSTEM := $o + + $(call reset) + $(eval q := $D/system.h) + $(call copyto, $(INCDIR)/system.h) +endef + +$(eval $(build-libsystem-impl)) + diff --git a/plat/build.mk b/plat/build.mk new file mode 100644 index 000000000..dde75784c --- /dev/null +++ b/plat/build.mk @@ -0,0 +1,26 @@ + +define build-platform-headers +$(call reset) +$(eval q := $D/include/$(strip $1)) +$(call installto, $(PLATIND)/$(PLATFORM)/include/$(strip $1)) +$(eval PLATFORM_HEADERS_$(PLATFORM) += $q) +endef + +define build-platform-impl + $(call reset) + $(eval q := $D/descr) + $(call installto, $(PLATIND)/descr/$(PLATFORM)) + + $(foreach f, $1, $(call build-platform-headers, $f)) + + $(eval PLATFORM_$(PLATFORM) := \ + $(PLATFORM_HEADERS_$(PLATFORM)) \ + $(PLATDEP)/$(PLATFORM)/ncg) + + $(call build-as) + $(call build-ncg) +endef + +build-platform = $(eval $(call build-platform-impl, $1)) + + diff --git a/plat/cpm/build.mk b/plat/cpm/build.mk new file mode 100644 index 000000000..83f029fb5 --- /dev/null +++ b/plat/cpm/build.mk @@ -0,0 +1,14 @@ +ARCH := i80 +PLATFORM := cpm +OPTIMISATION := -O + +D := plat/cpm + +$(eval $(call build-platform, \ + ack/config.h \ + cpm.h \ + unistd.h \ +)) + +include plat/cpm/libsys/build.mk + diff --git a/plat/cpm/descr b/plat/cpm/descr index da320fe39..b1b579938 100644 --- a/plat/cpm/descr +++ b/plat/cpm/descr @@ -10,7 +10,7 @@ var f=4 var d=8 var ARCH=i80 var PLATFORM=cpm -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/lib/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 -b0:0x0100 var MACHOPT_F=-m8 @@ -18,12 +18,12 @@ var MACHOPT_F=-m8 # Override the setting in fe so that files compiled for linux386 can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{EM}/share/ack/{PLATFORM}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg args < stdout need .e @@ -31,7 +31,7 @@ end name asopt from .s to .so - program {EM}/lib.bin/{PLATFORM}/top + program {EM}/lib/ack/{PLATFORM}/top args optimizer stdin @@ -40,14 +40,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -i SEPID=-b1:0 mapflag -fp FLOATS={EM}/{ILIB}fp diff --git a/plat/cpm/libsys/build.mk b/plat/cpm/libsys/build.mk new file mode 100644 index 000000000..be6dfa335 --- /dev/null +++ b/plat/cpm/libsys/build.mk @@ -0,0 +1,28 @@ +D := plat/cpm/libsys + +define build-cpm-libsys-impl + $(call reset) + $(call ackfile, $D/_bdos.s) + $(call ackfile, $D/_hol0.s) + $(call ackfile, $D/_inn2.s) + $(call ackfile, $D/_trap.s) + $(call ackfile, $D/brk.c) + $(call ackfile, $D/close.c) + $(call ackfile, $D/creat.c) + $(call ackfile, $D/errno.s) + $(call ackfile, $D/getpid.c) + $(call ackfile, $D/isatty.c) + $(call ackfile, $D/kill.c) + $(call ackfile, $D/lseek.c) + $(call ackfile, $D/open.c) + $(call ackfile, $D/read.c) + $(call ackfile, $D/signal.c) + $(call ackfile, $D/time.c) + $(call ackfile, $D/write.c) + + $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) + $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) +endef + +$(eval $(build-cpm-libsys-impl)) + diff --git a/plat/pc86/build.mk b/plat/pc86/build.mk new file mode 100644 index 000000000..e7e67136c --- /dev/null +++ b/plat/pc86/build.mk @@ -0,0 +1,14 @@ +ARCH := i86 +PLATFORM := pc86 +OPTIMISATION := -O + +D := plat/pc86/ + +$(eval $(call build-platform, \ + ack/config.h \ + unistd.h \ +)) + +include plat/pc86/libsys/build.mk + + diff --git a/plat/pc86/descr b/plat/pc86/descr index 65b63a1f8..a3f11fc4f 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -10,20 +10,20 @@ var f=4 var d=8 var ARCH=i86 var PLATFORM=pc86 -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 var MACHOPT_F=-m8 -# Override the setting in fe so that files compiled for linux386 can see +# 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}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg args < stdout need .e @@ -31,14 +31,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -i SEPID=-b1:0 mapflag -fp FLOATS={EM}/{ILIB}fp diff --git a/plat/pc86/libsys/build.mk b/plat/pc86/libsys/build.mk new file mode 100644 index 000000000..bf0fda6d5 --- /dev/null +++ b/plat/pc86/libsys/build.mk @@ -0,0 +1,26 @@ +D := plat/pc86/libsys + +define build-pc86-libsys-impl + $(call reset) + $(call ackfile, $D/errno.s) + $(call ackfile, $D/_hol0.s) + $(call ackfile, $D/_sys_rawread.s) + $(call ackfile, $D/_sys_rawwrite.s) + $(call ackfile, $D/open.c) + $(call ackfile, $D/creat.c) + $(call ackfile, $D/close.c) + $(call ackfile, $D/read.c) + $(call ackfile, $D/write.c) + $(call ackfile, $D/brk.c) + $(call ackfile, $D/getpid.c) + $(call ackfile, $D/kill.c) + $(call ackfile, $D/isatty.c) + $(call ackfile, $D/lseek.c) + $(call ackfile, $D/time.c) + $(call ackfile, $D/signal.c) + $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) + $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) +endef + +$(eval $(build-pc86-libsys-impl)) + diff --git a/util/LLgen/build.mk b/util/LLgen/build.mk new file mode 100644 index 000000000..44b63f891 --- /dev/null +++ b/util/LLgen/build.mk @@ -0,0 +1,55 @@ +D := util/LLgen + +# Rule to build LLgen. + +define build-llgen-impl + $(call reset) + $(eval cflags += -DNON_CORRECTING -DLIBDIR=\"$(abspath $D/lib)\") + $(call cfile, $D/src/main.c) + $(call cfile, $D/src/gencode.c) + $(call cfile, $D/src/compute.c) + $(call cfile, $D/src/check.c) + $(call cfile, $D/src/reach.c) + $(call cfile, $D/src/global.c) + $(call cfile, $D/src/name.c) + $(call cfile, $D/src/sets.c) + $(call cfile, $D/src/alloc.c) + $(call cfile, $D/src/machdep.c) + $(call cfile, $D/src/cclass.c) + $(call cfile, $D/src/savegram.c) + + # These use pre-LLgen'd version of the files. If LLgen.g gets updated, + # they need rebuilding. Use the bootstrap script to do this. + + $(call cfile, $D/src/LLgen.c) + $(call cfile, $D/src/Lpars.c) + $(call cfile, $D/src/tokens.c) + + $(call cprogram, $(BINDIR)/LLgen) + LLGEN := $o +endef + +$(eval $(build-llgen-impl)) + +# Rule to invoke to *use* LLgen. +# +# $1: directory to put output files +# $2: input files +# +# Output files are compiled via cfile and queued. + +define llgen-impl +$(eval o := $1/Lpars.c $(patsubst %.g, $(strip $1)/%.c, $(notdir $2))) +$(eval CLEANABLES += $o $1/Lpars.h) + +$o: $1/Lpars.h +$1/Lpars.h: $2 $(LLGEN) + @echo LLGEN $1/Lpars.c + @mkdir -p $(dir $o) + $(hide) cd $(dir $o) && $(LLGEN) $(abspath $2) + +$(foreach f,$o,$(call cfile,$f)) + +endef + +llgen = $(eval $(call llgen-impl,$1,$2)) diff --git a/util/LLgen/src/compute.c b/util/LLgen/src/compute.c index ef6b28499..c17d99d73 100644 --- a/util/LLgen/src/compute.c +++ b/util/LLgen/src/compute.c @@ -17,6 +17,7 @@ * Also checks the continuation grammar from the specified grammar. */ +# include # include "types.h" # include "extern.h" # include "sets.h" diff --git a/util/LLgen/src/gencode.c b/util/LLgen/src/gencode.c index 20d0d6cb2..94dd312ca 100644 --- a/util/LLgen/src/gencode.c +++ b/util/LLgen/src/gencode.c @@ -18,6 +18,7 @@ * This file is a mess, it should be cleaned up some time. */ +#include # include "types.h" # include "io.h" # include "extern.h" diff --git a/util/LLgen/src/savegram.c b/util/LLgen/src/savegram.c index d1b6a57ec..625dc1bab 100644 --- a/util/LLgen/src/savegram.c +++ b/util/LLgen/src/savegram.c @@ -25,6 +25,7 @@ */ +#include # include "types.h" # include "extern.h" # include "io.h" diff --git a/util/ack/build.mk b/util/ack/build.mk new file mode 100644 index 000000000..1b4fc146c --- /dev/null +++ b/util/ack/build.mk @@ -0,0 +1,57 @@ +D := util/ack + +define util-ack-makeheaders-rule +$(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) +$(wordlist 2, $(words $g), $g): $(firstword $g) +$(firstword $g): $(util-ack-mktables) + @echo MKTABLES + @mkdir -p $(dir $g) + $(hide) cd $(dir $g) && $(util-ack-mktables) $(INSDIR)/share + +$(eval CLEANABLES += $g) +endef + +define build-ack-impl + $(call reset) + $(call cfile, $D/mktables.c) + $(call cprogram, $(OBJDIR)/$D/mktables) + $(eval util-ack-mktables := $o) + + $(call reset) + $(eval cflags += -I$D) + $(call cfile, $D/list.c) + $(call cfile, $D/data.c) + $(call cfile, $D/main.c) + $(call cfile, $D/scan.c) + $(call cfile, $D/svars.c) + $(call cfile, $D/trans.c) + $(call cfile, $D/util.c) + + $(call cfile, $D/rmach.c) + $(call dependson, $(INCDIR)/em_path.h) + + $(call cfile, $D/run.c) + $(call cfile, $D/grows.c) + + $(call cfile, $D/files.c) + $(call dependson, $(INCDIR)/em_path.h) + + $(eval $(util-ack-makeheaders-rule)) + $(call cfile, $(OBJDIR)/$D/dmach.c) + $(call cfile, $(OBJDIR)/$D/intable.c) + + $(call cprogram, $(BINDIR)/ack) + $(call installto, $(INSDIR)/bin/ack) + $(eval ACK := $o) + + $(call reset) + $(eval q := lib/descr/fe) + $(call installto, $(PLATIND)/descr/fe) + $(eval $(ACK): $o) + + $(call reset) + $(eval q := $D/ack.1.X) + $(call installto, $(INSDIR)/share/man/man1/ack.1) +endef + +$(eval $(build-ack-impl)) diff --git a/util/ack/files.c b/util/ack/files.c index 0218c80f9..b47376b24 100644 --- a/util/ack/files.c +++ b/util/ack/files.c @@ -4,6 +4,7 @@ * */ +#include #include "ack.h" #include "list.h" #include "trans.h" diff --git a/util/ack/grows.c b/util/ack/grows.c index 4fbc054d9..ca089d48c 100644 --- a/util/ack/grows.c +++ b/util/ack/grows.c @@ -10,6 +10,7 @@ /* */ /**************************************************************************/ +#include #include "ack.h" #include "grows.h" diff --git a/util/ack/list.c b/util/ack/list.c index 7bc62a841..278f55580 100644 --- a/util/ack/list.c +++ b/util/ack/list.c @@ -4,6 +4,7 @@ * */ +#include #include "ack.h" #include "list.h" diff --git a/util/ack/rmach.c b/util/ack/rmach.c index d1ce5d2f7..38b2a54b3 100644 --- a/util/ack/rmach.c +++ b/util/ack/rmach.c @@ -4,6 +4,8 @@ * */ +#include +#include #include "ack.h" #include #include "list.h" @@ -11,7 +13,6 @@ #include "grows.h" #include "dmach.h" #include "data.h" -#include #ifndef NORCSID static char rcs_id[] = "$Id$" ; diff --git a/util/amisc/build.mk b/util/amisc/build.mk new file mode 100644 index 000000000..e7f71e33f --- /dev/null +++ b/util/amisc/build.mk @@ -0,0 +1,22 @@ + +define build-simple-tool-impl + $(call reset) + $(call cfile, util/amisc/$1.c) + $(call file, $(LIBOBJECT)) + $(call cprogram, $(BINDIR)/$1) + $(eval INSTALLABLES += $o) + $(call installto, $(INSDIR)/bin/$1) + + $(call reset) + $(eval q := util/amisc/$1.1) + $(call installto, $(INSDIR)/share/man/man1/$1.1) +endef + +build-simple-tool = $(eval $(build-simple-tool-impl)) + +$(call build-simple-tool,anm) +$(call build-simple-tool,ashow) +$(call build-simple-tool,asize) +$(call build-simple-tool,aslod) +$(call build-simple-tool,astrip) + diff --git a/util/arch/build.mk b/util/arch/build.mk new file mode 100644 index 000000000..b70893f41 --- /dev/null +++ b/util/arch/build.mk @@ -0,0 +1,23 @@ +D := util/arch + +define build-aal-impl + $(call reset) + $(eval cflags += -DAAL) + + $(call cfile, $D/archiver.c) + + $(call file, $(LIBOBJECT)) + $(call file, $(LIBPRINT)) + $(call file, $(LIBSTRING)) + $(call file, $(LIBSYSTEM)) + + $(call cprogram, $(BINDIR)/aal) + $(call installto, $(INSDIR)/bin/aal) + $(eval AAL := $o) + + $(call reset) + $(eval q := $D/aal.1) + $(call installto, $(INSDIR)/share/man/man1/aal.1) +endef + +$(eval $(build-aal-impl)) diff --git a/util/cmisc/build.mk b/util/cmisc/build.mk new file mode 100644 index 000000000..185c3ace6 --- /dev/null +++ b/util/cmisc/build.mk @@ -0,0 +1,31 @@ +# Building tabgen. + +define build-tabgen-impl + $(call reset) + $(call cfile, util/cmisc/tabgen.c) + $(call cprogram, $(BINDIR)/tabgen) + $(eval TABGEN := $o) +endef + +$(eval $(build-tabgen-impl)) + +# Using tabgen. +# +# $1 = input file +# +# Output file is compiled with cfile and queued. + +define tabgen-impl +$(eval g := $(OBJDIR)/$(strip $1).c) + +$g: $1 $(TABGEN) + @echo TABGEN $g + @mkdir -p $(dir $g) + $(hide) $(TABGEN) -f$(strip $1) > $g || $(RM) $g + +$(eval CLEANABLES += $g) +$(call cfile,$g) +endef + +tabgen = $(eval $(call tabgen-impl,$1)) + diff --git a/util/cpp/replace.c b/util/cpp/replace.c index 923b2c902..1951e1bda 100644 --- a/util/cpp/replace.c +++ b/util/cpp/replace.c @@ -61,7 +61,7 @@ replace(idef) return 0; } if (++mac->mc_count > 100) { - /* 100 must be some number in Parameters */ + /* 100 must be some number in parameters.h */ warning("macro %s is assumed recursive", idef->id_text); return 0; diff --git a/util/data/build.mk b/util/data/build.mk new file mode 100644 index 000000000..196bdd52a --- /dev/null +++ b/util/data/build.mk @@ -0,0 +1,29 @@ +D := util/data + +define util-data-impl + +$(eval g := \ + $(INCDIR)/em_spec.h \ + $(INCDIR)/em_pseu.h \ + $(INCDIR)/em_mnem.h \ + $(OBJDIR)/$D/em_flag.c \ + $(OBJDIR)/$D/em_pseu.c \ + $(OBJDIR)/$D/em_mnem.c) + +$(eval CLEANABLES += $g) +$g: $D/new_table h/em_table + @echo DATA + @mkdir -p $(dir $g) + $(hide) $D/new_table h/em_table $(INCDIR) $(OBJDIR)/$D + +$(call reset) +$(call cfile, $(OBJDIR)/$D/em_flag.c) +$(call cfile, $(OBJDIR)/$D/em_pseu.c) +$(call cfile, $(OBJDIR)/$D/em_mnem.c) +$(call cfile, $D/em_ptyp.c) +$(call clibrary, $(LIBDIR)/libem_data.a) +$(eval LIBEM_DATA := $q) + +endef + +$(eval $(util-data-impl)) diff --git a/util/ego/sr/sr.h b/util/ego/sr/sr.h index cf301831c..796641587 100644 --- a/util/ego/sr/sr.h +++ b/util/ego/sr/sr.h @@ -57,7 +57,7 @@ struct code_info { #define LP_HEADER lp_extend->lpx_sr.lpx_header #define LP_INSTR lp_extend->lpx_sr.lpx_instr -/* Parameters to be provided by environment: */ +/* parameters.h to be provided by environment: */ extern int ovfl_harmful; /* Does overflow during multiplication * cause a trap ? diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk new file mode 100644 index 000000000..97576794d --- /dev/null +++ b/util/ncgg/build.mk @@ -0,0 +1,41 @@ +D := util/ncgg + +define build-ncgg-impl + +$(call reset) +$(eval cflags += -I$D) + +$(call yacc, $(OBJDIR)/$D, $D/cgg.y) + +$(call flex, $(OBJDIR)/$D, $D/scan.l) +$(call dependson, $(OBJDIR)/$D/y.tab.h) + +$(call cfile, $D/subr.c) +$(call cfile, $D/main.c) +$(call cfile, $D/coerc.c) +$(call cfile, $D/error.c) +$(call cfile, $D/emlookup.c) +$(call cfile, $D/expr.c) +$(call cfile, $D/instruct.c) +$(call cfile, $D/iocc.c) +$(call cfile, $D/lookup.c) +$(call cfile, $D/output.c) +$(call cfile, $D/set.c) +$(call cfile, $D/strlookup.c) +$(call cfile, $D/var.c) +$(call cfile, $D/hall.c) + +$(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c) +$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords + @echo KEYWORDS $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) +$(call cfile, $(OBJDIR)/$D/enterkeyw.c) + +$(call file, $(LIBEM_DATA)) +$(call cprogram, $(BINDIR)/ncgg) +$(eval NCGG := $o) + +endef + +$(eval $(build-ncgg-impl)) diff --git a/util/ncgg/cgg.y b/util/ncgg/cgg.y index f46d2d724..24948abad 100644 --- a/util/ncgg/cgg.y +++ b/util/ncgg/cgg.y @@ -1100,4 +1100,3 @@ optregvartype { $$ = $2; } ; %% -#include "scan.c" diff --git a/util/ncgg/scan.l b/util/ncgg/scan.l index 93552b6bd..46ea6d5e4 100644 --- a/util/ncgg/scan.l +++ b/util/ncgg/scan.l @@ -7,6 +7,20 @@ static char rcsid2[]= "$Id$"; #endif +#include "param.h" +#include "varinfo.h" +#include "lookup.h" +#include "set.h" +#include "iocc.h" +#include "instruct.h" +#include "expr.h" +#include "extern.h" +#include +#include +#include "y.tab.h" + +extern int emhere; + char *mystrcpy(); int myatoi(); diff --git a/util/opt/build.mk b/util/opt/build.mk new file mode 100644 index 000000000..bb3c464a6 --- /dev/null +++ b/util/opt/build.mk @@ -0,0 +1,78 @@ +D := util/opt + +define build-opt-mktab-impl + +$(call reset) +$(eval cflags += -I$D) + +$(call yacc, $(OBJDIR)/$D, $D/mktab.y) + +$(call flex, $(OBJDIR)/$D, $D/scan.l) +$(call dependson, $(OBJDIR)/$D/y.tab.h) + +$(call file, $(LIBEM_DATA)) +$(call file, -lfl) +$(call cprogram, $D/mktab) + +endef + +define build-opt-impl + +$(call reset) +$(eval cflags += -I$D) +$(call cfile, $D/main.c) +$(call cfile, $D/getline.c) +$(call cfile, $D/lookup.c) +$(call cfile, $D/var.c) +$(call cfile, $D/process.c) +$(call cfile, $D/backward.c) +$(call cfile, $D/util.c) +$(call cfile, $D/alloc.c) +$(call cfile, $D/putline.c) +$(call cfile, $D/cleanup.c) +$(call cfile, $D/peephole.c) +$(call cfile, $D/flow.c) +$(call cfile, $D/tes.c) +$(call cfile, $D/reg.c) + +$(eval CLEANABLES += $(OBJDIR)/$D/pop_push.c) +$(OBJDIR)/$D/pop_push.c: $D/pop_push.awk h/em_table + @echo POP_PUSH $$@ + @mkdir -p $$(dir $$@) + $(hide) awk -f $D/pop_push.awk < h/em_table > $$@ +$(call cfile, $(OBJDIR)/$D/pop_push.c) + +$(eval CLEANABLES += $(OBJDIR)/$D/pattern.c) +$(OBJDIR)/$D/pattern.c: $D/mktab $(OBJDIR)/$D/patterns + @echo PATTERNS $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/mktab < $(OBJDIR)/$D/patterns > $$@ +$(call cfile, $(OBJDIR)/$D/pattern.c) + +$(eval CLEANABLES += $(OBJDIR)/$D/patterns) +$(OBJDIR)/$D/patterns: $(CPPANSI) $D/patterns + @echo PREPROCESS $$@ + @mkdir -p $$(dir $$@) + $(hide) $(CPPANSI) < $D/patterns > $$@ + +$(call file, $(LIBEM_DATA)) +$(call file, $(LIBASSERT)) +$(call file, $(LIBPRINT)) +$(call file, $(LIBALLOC)) +$(call file, $(LIBSYSTEM)) +$(call file, $(LIBSTRING)) + +$(eval $q: $(INCDIR)/em_spec.h) + +$(call cprogram, $(BINDIR)/em_opt) +$(call installto, $(PLATDEP)/em_opt) +$(eval EM_OPT := $o) + +$(call reset) +$(eval q := $D/em_opt.6) +$(call installto, $(INSDIR)/share/man/man6/em_opt.6) + +endef + +$(eval $(build-opt-mktab-impl)) +$(eval $(build-opt-impl)) diff --git a/util/opt/mktab.y b/util/opt/mktab.y index a4b5c845c..08beaeccc 100644 --- a/util/opt/mktab.y +++ b/util/opt/mktab.y @@ -421,4 +421,3 @@ out(w) { } } -#include "scan.c" diff --git a/util/opt/scan.l b/util/opt/scan.l index 85d4aeefe..1c26f1857 100644 --- a/util/opt/scan.l +++ b/util/opt/scan.l @@ -11,6 +11,11 @@ static char rcsid2[] = "$Id$"; */ extern long atol(); +extern char patid[128]; +extern int lino; + +#include "y.tab.h" + %} %% \"[^"]*\" { strncpy(patid,yytext,sizeof(patid)); return(STRING); } From b0c238eb5d6d403b675171a70833584c1ba5c0ce Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 12 May 2013 23:51:55 +0100 Subject: [PATCH 003/231] Made a start on building the runtimes for each platform and language; the Linuxes all build. --HG-- branch : dtrg-buildsystem rename : modules/src/em_mes/build.mk => modules/src/read_em/build.mk rename : plat/pc86/build.mk => plat/linux386/build.mk rename : plat/pc86/build.mk => plat/linux68k/build.mk rename : plat/pc86/build.mk => plat/linuxppc/build.mk rename : util/ack/build.mk => util/misc/build.mk --- Makefile | 7 ++ first/core.mk | 7 +- lang/cem/libcc.ansi/build.mk | 226 +++++++++++++++++++++++++++++++++++ mach/m68020/as/mach0.c | 2 +- mach/proto/as/build.mk | 2 +- mach/proto/ncg/build.mk | 4 +- modules/src/em_code/build.mk | 2 +- modules/src/read_em/build.mk | 54 +++++++++ plat/build.mk | 11 +- plat/cpm/build.mk | 28 ++++- plat/cpm/libsys/build.mk | 28 ----- plat/linux/liblinux/build.mk | 27 +++++ plat/linux386/build.mk | 17 +++ plat/linux386/descr | 10 +- plat/linux68k/build.mk | 18 +++ plat/linux68k/descr | 10 +- plat/linuxppc/build.mk | 19 +++ plat/linuxppc/descr | 12 +- plat/pc86/build.mk | 25 +++- plat/pc86/libsys/build.mk | 26 ---- util/cmisc/build.mk | 7 +- util/data/build.mk | 3 +- util/misc/build.mk | 48 ++++++++ 23 files changed, 501 insertions(+), 92 deletions(-) create mode 100644 modules/src/read_em/build.mk delete mode 100644 plat/cpm/libsys/build.mk create mode 100644 plat/linux/liblinux/build.mk create mode 100644 plat/linux386/build.mk create mode 100644 plat/linux68k/build.mk create mode 100644 plat/linuxppc/build.mk delete mode 100644 plat/pc86/libsys/build.mk create mode 100644 util/misc/build.mk diff --git a/Makefile b/Makefile index 7c6371dfc..b121d3e28 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,7 @@ include modules/src/print/build.mk include modules/src/flt_arith/build.mk include modules/src/em_code/build.mk include modules/src/em_mes/build.mk +include modules/src/read_em/build.mk include util/amisc/build.mk include util/cmisc/build.mk @@ -48,15 +49,21 @@ include util/data/build.mk include util/opt/build.mk include util/ncgg/build.mk include util/arch/build.mk +include util/misc/build.mk include lang/cem/build.mk include mach/proto/as/build.mk include mach/proto/ncg/build.mk +include plat/linux/liblinux/build.mk + include plat/build.mk include plat/pc86/build.mk include plat/cpm/build.mk +include plat/linux386/build.mk +include plat/linux68k/build.mk +include plat/linuxppc/build.mk .PHONY: installables installables: $(INSTALLABLES) diff --git a/first/core.mk b/first/core.mk index 898cf0d03..09b51a925 100644 --- a/first/core.mk +++ b/first/core.mk @@ -34,7 +34,8 @@ $o: $s $(ACK) \ $(PLATIND)/descr/$(PLATFORM) \ $(PLATDEP)/$(PLATFORM)/as \ $(CCOMPILER) \ - $(PLATFORM_$(PLATFORM)) + $(PLATFORM_$(PLATFORM)) \ + $(EM_ENCODE) @echo ACK $o @mkdir -p $(dir $o) $(hide) ACKDIR=$(INSDIR) $(ACK) $(ACKFLAGS) $(ackflags) -m$(PLATFORM) -c -o $o $s @@ -42,8 +43,8 @@ endef define ackfile $(eval s := $1) - $(eval o := $(OBJDIR)/$(basename $1).o) - $(eval d := $(OBJDIR)/$(basename $1).d) + $(eval o := $(OBJDIR)/$(objdir)/$(basename $1).o) + $(eval d := $(OBJDIR)/$(objdir)/$(basename $1).d) $(eval DEPENDS += $d) $(eval CLEANABLES += $o $d) $(eval q += $o) diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 640f7f344..727d04718 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -12,6 +12,7 @@ define build-libcc-ansi-headers-impl assert.h \ ctype.h \ errno.h \ + fcntl.h \ float.h \ limits.h \ math.h \ @@ -34,3 +35,228 @@ define build-libcc-ansi-headers-impl endef $(eval $(build-libcc-ansi-headers-impl)) + +define build-runtime-libcc-ansi-impl + +$(call reset) +$(eval objdir := $(PLATFORM)) + +# Assert + +$(call ackfile, lang/cem/libcc.ansi/assert/assert.c) + +# CType + +$(call ackfile, lang/cem/libcc.ansi/ctype/tolower.c) +$(call ackfile, lang/cem/libcc.ansi/ctype/toupper.c) +$(call acktabgen, lang/cem/libcc.ansi/ctype/char.tab) + +$(eval g := \ + isalnum.c \ + isalpha.c \ + iscntrl.c \ + isdigit.c \ + isgraph.c \ + islower.c \ + isprint.c \ + ispunct.c \ + isspace.c \ + isupper.c \ + isxdigit.c \ + isascii.c) +$(eval g := $(addprefix $(OBJDIR)/$(objdir)/ctype/, $g)) + +$(wordlist 2, $(words $g), $g): $(firstword $g) +$(firstword $g): lang/cem/libcc.ansi/ctype/genfiles + @echo GENFILES $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $$(dir $$@) && sh $$(abspath $$^) + +$(eval CLEANABLES += $g) +$(foreach f, $g, $(call ackfile, $f)) + +# errno + +$(call ackfile, lang/cem/libcc.ansi/errno/errlist.c) + +# locale + +$(call ackfile, lang/cem/libcc.ansi/locale/localeconv.c) +$(call ackfile, lang/cem/libcc.ansi/locale/setlocale.c) + +# math + +$(call ackfile, lang/cem/libcc.ansi/math/asin.c) +$(call ackfile, lang/cem/libcc.ansi/math/atan2.c) +$(call ackfile, lang/cem/libcc.ansi/math/atan.c) +$(call ackfile, lang/cem/libcc.ansi/math/ceil.c) +$(call ackfile, lang/cem/libcc.ansi/math/fabs.c) +$(call ackfile, lang/cem/libcc.ansi/math/pow.c) +$(call ackfile, lang/cem/libcc.ansi/math/log10.c) +$(call ackfile, lang/cem/libcc.ansi/math/log.c) +$(call ackfile, lang/cem/libcc.ansi/math/sin.c) +$(call ackfile, lang/cem/libcc.ansi/math/sinh.c) +$(call ackfile, lang/cem/libcc.ansi/math/sqrt.c) +$(call ackfile, lang/cem/libcc.ansi/math/tan.c) +$(call ackfile, lang/cem/libcc.ansi/math/tanh.c) +$(call ackfile, lang/cem/libcc.ansi/math/exp.c) +$(call ackfile, lang/cem/libcc.ansi/math/ldexp.c) +$(call ackfile, lang/cem/libcc.ansi/math/fmod.c) +$(call ackfile, lang/cem/libcc.ansi/math/floor.c) +$(call ackfile, lang/cem/libcc.ansi/math/hugeval.c) +$(call ackfile, lang/cem/libcc.ansi/math/frexp.e) +$(call ackfile, lang/cem/libcc.ansi/math/modf.e) +$(call ackfile, lang/cem/libcc.ansi/math/isnan.c) + +# Misc + +$(call ackfile, lang/cem/libcc.ansi/misc/environ.c) +# (lots of stuff missing here, as not being appropriate on modern systems) + +# setjmp + +$(call ackfile, lang/cem/libcc.ansi/setjmp/setjmp.e) + +# signal + +$(call ackfile, lang/cem/libcc.ansi/signal/raise.c) + +# stdio + +$(call ackfile, lang/cem/libcc.ansi/stdio/tmpfile.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/tmpnam.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fopen.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/freopen.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/setbuf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/setvbuf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/perror.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/printf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/sprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/vfprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/vprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/vsprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/doprnt.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/icompute.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fscanf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/scanf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/sscanf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/doscan.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fgetc.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fgets.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/getc.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/getchar.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/gets.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/putc.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/putchar.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fputc.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/puts.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fputs.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/ungetc.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fread.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fwrite.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fgetpos.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fsetpos.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/rewind.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fseek.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/ftell.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/clearerr.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/feof.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/ferror.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fileno.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fltpr.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/ecvt.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fillbuf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fclose.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/flushbuf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/fflush.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/data.c) + +# stdlib + +$(call ackfile, lang/cem/libcc.ansi/stdlib/abort.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/abs.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/atof.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/atoi.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/atol.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/bsearch.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/div.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/atexit.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/exit.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/getenv.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/labs.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/ldiv.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/mblen.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/mbstowcs.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/mbtowc.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/qsort.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/rand.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/strtod.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/strtol.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/wcstombs.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/wctomb.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/ext_comp.c) + +$(eval g := $(OBJDIR)/$(objdir)/malloc.c) +$(eval CLEANABLES += $g) +$(eval srcs := \ + READ_ME size_type.h param.h impl.h check.h \ + log.h phys.h mal.c log.c phys.c check.c) +$(eval srcs := $(addprefix lang/cem/libcc.ansi/stdlib/malloc/, $(srcs))) + +$g: lang/cem/libcc.ansi/stdlib/malloc/add_file $(srcs) + @echo MALLOC $g + @mkdir -p $(dir $g) + $(hide) $(RM) $g && for i in $(srcs); do \ + lang/cem/libcc.ansi/stdlib/malloc/add_file $$$$i >> $g; done + +$(call ackfile, $g) + +# String + +$(call ackfile, lang/cem/libcc.ansi/string/memchr.c) +$(call ackfile, lang/cem/libcc.ansi/string/memcmp.c) +$(call ackfile, lang/cem/libcc.ansi/string/memcpy.c) +$(call ackfile, lang/cem/libcc.ansi/string/memmove.c) +$(call ackfile, lang/cem/libcc.ansi/string/memset.c) +$(call ackfile, lang/cem/libcc.ansi/string/strcat.c) +$(call ackfile, lang/cem/libcc.ansi/string/strchr.c) +$(call ackfile, lang/cem/libcc.ansi/string/strcmp.c) +$(call ackfile, lang/cem/libcc.ansi/string/strcoll.c) +$(call ackfile, lang/cem/libcc.ansi/string/strcpy.c) +$(call ackfile, lang/cem/libcc.ansi/string/strcspn.c) +$(call ackfile, lang/cem/libcc.ansi/string/strerror.c) +$(call ackfile, lang/cem/libcc.ansi/string/strncat.c) +$(call ackfile, lang/cem/libcc.ansi/string/strncpy.c) +$(call ackfile, lang/cem/libcc.ansi/string/strrchr.c) +$(call ackfile, lang/cem/libcc.ansi/string/strstr.c) +$(call ackfile, lang/cem/libcc.ansi/string/strlen.c) +$(call ackfile, lang/cem/libcc.ansi/string/strtok.c) +$(call ackfile, lang/cem/libcc.ansi/string/strpbrk.c) +$(call ackfile, lang/cem/libcc.ansi/string/strspn.c) +$(call ackfile, lang/cem/libcc.ansi/string/strncmp.c) +$(call ackfile, lang/cem/libcc.ansi/string/strxfrm.c) + +# Time + +$(call ackfile, lang/cem/libcc.ansi/time/ctime.c) +$(call ackfile, lang/cem/libcc.ansi/time/asctime.c) +$(call ackfile, lang/cem/libcc.ansi/time/localtime.c) +$(call ackfile, lang/cem/libcc.ansi/time/clock.c) +$(call ackfile, lang/cem/libcc.ansi/time/difftime.c) +$(call ackfile, lang/cem/libcc.ansi/time/gmtime.c) +$(call ackfile, lang/cem/libcc.ansi/time/mktime.c) +$(call ackfile, lang/cem/libcc.ansi/time/strftime.c) +$(call ackfile, lang/cem/libcc.ansi/time/time.c) +$(call ackfile, lang/cem/libcc.ansi/time/tzset.c) +$(call ackfile, lang/cem/libcc.ansi/time/misc.c) + +$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libc.a) +$(call installto, $(PLATIND)/$(PLATFORM)/libc.a) + +endef + +build-runtime-libcc-ansi = $(eval $(build-runtime-libcc-ansi-impl)) + +$(eval RUNTIMES += libcc-ansi) + diff --git a/mach/m68020/as/mach0.c b/mach/m68020/as/mach0.c index 2884213be..498620c0e 100644 --- a/mach/m68020/as/mach0.c +++ b/mach/m68020/as/mach0.c @@ -10,7 +10,7 @@ #define THREE_PASS /* branch and offset optimization */ #define BYTES_REVERSED /* high order byte has lowest address */ #define WORDS_REVERSED /* high order word has lowest address */ -/*#define LISTING /* enable listing facilities */ +/*#define LISTING */ /* enable listing facilities */ #define RELOCATION /* generate relocatable code */ #define DEBUG 0 diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index d98fe7454..9404f13b9 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -2,7 +2,7 @@ define build-as-impl $(call reset) $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D) - $(eval objdir := $D) + $(eval objdir := $(PLATFORM)) $(call cfile, mach/proto/as/comm3.c) $(call dependson, $(OBJDIR)/$D/y.tab.h) diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index e3843b7f3..100ece434 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -3,7 +3,7 @@ define build-ncg-impl $(call reset) $(eval cflags += -Imach/$(ARCH)/ncg -I$(OBJDIR)/$D -Imach/proto/ncg) -$(eval objdir := $D/ncg) +$(eval objdir := $(PLATFORM)) $(call cfile, mach/proto/ncg/codegen.c) $(call cfile, mach/proto/ncg/compute.c) @@ -29,7 +29,7 @@ $(OBJDIR)/$D/tables.h: $(NCGG) $(CPPANSI) mach/$(ARCH)/ncg/table @echo NCGG $$@ @mkdir -p $$(dir $$@) $(hide) cd $$(dir $$@) && \ - $(abspath $(CPPANSI)) $(abspath mach/$(ARCH)/ncg/table) | $(abspath $(NCGG)) + $(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/ncg) $(abspath mach/$(ARCH)/ncg/table) | $(abspath $(NCGG)) $(hide) mv $(OBJDIR)/$D/tables.H $(OBJDIR)/$D/tables.h $(call cfile, $(OBJDIR)/$D/tables.c) diff --git a/modules/src/em_code/build.mk b/modules/src/em_code/build.mk index 8fcba3c7f..dbef43003 100644 --- a/modules/src/em_code/build.mk +++ b/modules/src/em_code/build.mk @@ -7,7 +7,7 @@ D := modules/src/em_code define build-em_code-impl $(call reset) $(eval cflags += $3) - $(eval objdir := $D/$1) + $(eval objdir := $1) $(call cfile, $D/bhcst.c) $(call cfile, $D/bhdlb.c) $(call cfile, $D/bhdnam.c) diff --git a/modules/src/read_em/build.mk b/modules/src/read_em/build.mk new file mode 100644 index 000000000..17606718c --- /dev/null +++ b/modules/src/read_em/build.mk @@ -0,0 +1,54 @@ +D := modules/src/read_em + +define build-read_em-headers-impl + +$(eval g := $(OBJDIR)/$D/C_mnem_narg.h) +$(eval CLEANABLES += $g) +$g: $D/m_C_mnem_na h/em_table + @echo M_C_MNEM_NA $g + @mkdir -p $(dir $g) + $(hide) cd $D && $(abspath $D/m_C_mnem_na) $(abspath h/em_table) > $(abspath $g) + +$(eval g := $(OBJDIR)/$D/C_mnem.h) +$(eval CLEANABLES += $g) +$g: $D/m_C_mnem h/em_table + @echo M_C_MNEM $g + @mkdir -p $(dir $g) + $(hide) cd $D && $(abspath $D/m_C_mnem) $(abspath h/em_table) > $(abspath $g) + +endef + +define build-read_em-impl + +$(call reset) +$(eval objdir := emev) +$(eval cflags += -I$(OBJDIR)/$D -DPRIVATE=static -DEXPORT= -DNDEBUG -DCHECKING) +$(call cfile, $D/EM_vars.c) +$(call cfile, $D/read_em.c) +$(call cfile, $D/mkcalls.c) +$(eval $q: $(OBJDIR)/$D/C_mnem_narg.h) +$(eval $q: $(OBJDIR)/$D/C_mnem.h) +$(call clibrary, $(LIBDIR)/lib_read_emeV.a) +$(eval LIBREAD_EMEV := $q) + +$(call reset) +$(eval objdir := emkv) +$(eval cflags += -I$(OBJDIR)/$D -DPRIVATE=static -DEXPORT= -DNDEBUG -DCHECKING -DCOMPACT) +$(call cfile, $D/EM_vars.c) +$(call cfile, $D/read_em.c) +$(call cfile, $D/mkcalls.c) +$(eval $q: $(OBJDIR)/$D/C_mnem_narg.h) +$(eval $q: $(OBJDIR)/$D/C_mnem.h) +$(call clibrary, $(LIBDIR)/lib_read_emkV.a) +$(eval LIBREAD_EMKV := $q) + +$(call reset) +$(eval q := $D/em_comp.h) +$(call installto, $(INCDIR)/em_comp.h) + +endef + +$(eval $(call build-read_em-headers-impl)) +$(eval $(call build-read_em-impl)) + + diff --git a/plat/build.mk b/plat/build.mk index dde75784c..e43b02614 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -11,14 +11,21 @@ define build-platform-impl $(eval q := $D/descr) $(call installto, $(PLATIND)/descr/$(PLATFORM)) - $(foreach f, $1, $(call build-platform-headers, $f)) - $(eval PLATFORM_$(PLATFORM) := \ $(PLATFORM_HEADERS_$(PLATFORM)) \ $(PLATDEP)/$(PLATFORM)/ncg) + $(foreach f, $(platform-headers), $(call build-platform-headers, $f)) + + $(call reset) + $(foreach f, $(platform-libsys), $(call ackfile, $D/libsys/$f)) + $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) + $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) + $(call build-as) $(call build-ncg) + + $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime))) endef build-platform = $(eval $(call build-platform-impl, $1)) diff --git a/plat/cpm/build.mk b/plat/cpm/build.mk index 83f029fb5..2f8836956 100644 --- a/plat/cpm/build.mk +++ b/plat/cpm/build.mk @@ -4,11 +4,31 @@ OPTIMISATION := -O D := plat/cpm -$(eval $(call build-platform, \ +platform-headers := \ ack/config.h \ cpm.h \ - unistd.h \ -)) + unistd.h + +platform-libsys := \ + _bdos.s \ + _hol0.s \ + _inn2.s \ + _trap.s \ + brk.c \ + close.c \ + creat.c \ + errno.s \ + getpid.c \ + isatty.c \ + kill.c \ + lseek.c \ + open.c \ + read.c \ + signal.c \ + time.c \ + write.c + +$(eval $(call build-platform)) + -include plat/cpm/libsys/build.mk diff --git a/plat/cpm/libsys/build.mk b/plat/cpm/libsys/build.mk deleted file mode 100644 index be6dfa335..000000000 --- a/plat/cpm/libsys/build.mk +++ /dev/null @@ -1,28 +0,0 @@ -D := plat/cpm/libsys - -define build-cpm-libsys-impl - $(call reset) - $(call ackfile, $D/_bdos.s) - $(call ackfile, $D/_hol0.s) - $(call ackfile, $D/_inn2.s) - $(call ackfile, $D/_trap.s) - $(call ackfile, $D/brk.c) - $(call ackfile, $D/close.c) - $(call ackfile, $D/creat.c) - $(call ackfile, $D/errno.s) - $(call ackfile, $D/getpid.c) - $(call ackfile, $D/isatty.c) - $(call ackfile, $D/kill.c) - $(call ackfile, $D/lseek.c) - $(call ackfile, $D/open.c) - $(call ackfile, $D/read.c) - $(call ackfile, $D/signal.c) - $(call ackfile, $D/time.c) - $(call ackfile, $D/write.c) - - $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) - $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) -endef - -$(eval $(build-cpm-libsys-impl)) - diff --git a/plat/linux/liblinux/build.mk b/plat/linux/liblinux/build.mk new file mode 100644 index 000000000..3cff634f9 --- /dev/null +++ b/plat/linux/liblinux/build.mk @@ -0,0 +1,27 @@ +define build-liblinux-impl + +$(call reset) +$(eval objdir := $(PLATFORM)) +$(call ackfile, plat/linux/liblinux/_exit.c) +$(call ackfile, plat/linux/liblinux/_hol0.s) +$(call ackfile, plat/linux/liblinux/brk.c) +$(call ackfile, plat/linux/liblinux/close.c) +$(call ackfile, plat/linux/liblinux/creat.c) +$(call ackfile, plat/linux/liblinux/errno.s) +$(call ackfile, plat/linux/liblinux/getpid.c) +$(call ackfile, plat/linux/liblinux/gettimeofday.c) +$(call ackfile, plat/linux/liblinux/isatty.c) +$(call ackfile, plat/linux/liblinux/kill.c) +$(call ackfile, plat/linux/liblinux/lseek.c) +$(call ackfile, plat/linux/liblinux/open.c) +$(call ackfile, plat/linux/liblinux/read.c) +$(call ackfile, plat/linux/liblinux/sbrk.c) +$(call ackfile, plat/linux/liblinux/signal.c) +$(call ackfile, plat/linux/liblinux/write.c) + +$(call acklibrary, $(OBJDIR)/$D/liblinux.a) +$(call installto, $(PLATIND)/$(PLATFORM)/liblinux.a) + +endef + +build-liblinux = $(eval $(build-liblinux-impl)) diff --git a/plat/linux386/build.mk b/plat/linux386/build.mk new file mode 100644 index 000000000..760cc69f6 --- /dev/null +++ b/plat/linux386/build.mk @@ -0,0 +1,17 @@ +ARCH := i386 +PLATFORM := linux386 +OPTIMISATION := -O + +D := plat/linux386/ + +platform-headers := \ + ack/config.h \ + sys/ioctl.h \ + unistd.h + +platform-libsys := \ + _syscall.s + +$(eval $(call build-platform)) +$(eval $(call build-liblinux)) + diff --git a/plat/linux386/descr b/plat/linux386/descr index 6b7b1a0af..73fbf1779 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -10,7 +10,7 @@ var f=4 var d=8 var ARCH=i386 var PLATFORM=linux386 -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08048054 var C_LIB={PLATFORMDIR}/libc-ansi.a @@ -22,12 +22,12 @@ var MACHOPT_F=-m10 # Override the setting in fe so that files compiled for linux386 can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,14 +36,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{LIB}fp args {ALIGN} {SEPID?} \ diff --git a/plat/linux68k/build.mk b/plat/linux68k/build.mk new file mode 100644 index 000000000..b230b2500 --- /dev/null +++ b/plat/linux68k/build.mk @@ -0,0 +1,18 @@ +ARCH := m68020 +PLATFORM := linux68k +OPTIMISATION := -O6 + +D := plat/linux68k/ + +platform-headers := \ + ack/config.h \ + sys/ioctl.h \ + unistd.h + +platform-libsys := \ + _syscall.s + +$(eval $(call build-platform)) +$(eval $(call build-liblinux)) + + diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 4758a48c2..1fb157c59 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -10,7 +10,7 @@ var f=4 var d=8 var ARCH=m68020 var PLATFORM=linux68k -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix -D__mc68020 -D__m68k -D__mc68000 -D__M68020 var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08000054 var C_LIB={PLATFORMDIR}/libc-ansi.a @@ -22,12 +22,12 @@ var MACHOPT_F=-ml10 # Override the setting in fe so that files compiled for linux68k can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,14 +36,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{LIB}fp args {ALIGN} {SEPID?} \ diff --git a/plat/linuxppc/build.mk b/plat/linuxppc/build.mk new file mode 100644 index 000000000..515d498a6 --- /dev/null +++ b/plat/linuxppc/build.mk @@ -0,0 +1,19 @@ +ARCH := powerpc +PLATFORM := linuxppc +OPTIMISATION := -O6 + +D := plat/linuxppc/ + +platform-headers := \ + ack/config.h \ + sys/ioctl.h \ + unistd.h + +platform-libsys := \ + _syscall.s \ + trap.s + +$(eval $(call build-platform)) +$(eval $(call build-liblinux)) + + diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr index 64f838e61..2e54a5da8 100644 --- a/plat/linuxppc/descr +++ b/plat/linuxppc/descr @@ -10,7 +10,7 @@ var f=4 var d=8 var ARCH=powerpc var PLATFORM=linuxppc -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix -D__POWERPC var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x80000054 var C_LIB={PLATFORMDIR}/libc-ansi.a @@ -22,12 +22,12 @@ var MACHOPT_F= # Override the setting in fe so that files compiled for linuxppc can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +36,7 @@ end name asopt from .s to .so - program {EM}/lib.bin/{PLATFORM}/top + program {EM}/lib/ack/{PLATFORM}/top args optimizer stdin @@ -45,14 +45,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{LIB}fp args {ALIGN} {SEPID?} \ diff --git a/plat/pc86/build.mk b/plat/pc86/build.mk index e7e67136c..8a7ec92f1 100644 --- a/plat/pc86/build.mk +++ b/plat/pc86/build.mk @@ -4,11 +4,28 @@ OPTIMISATION := -O D := plat/pc86/ -$(eval $(call build-platform, \ +platform-headers := \ ack/config.h \ - unistd.h \ -)) + unistd.h -include plat/pc86/libsys/build.mk +platform-libsys := \ + errno.s \ + _hol0.s \ + _sys_rawread.s \ + _sys_rawwrite.s \ + open.c \ + creat.c \ + close.c \ + read.c \ + write.c \ + brk.c \ + getpid.c \ + kill.c \ + isatty.c \ + lseek.c \ + time.c \ + signal.c + +$(eval $(call build-platform)) diff --git a/plat/pc86/libsys/build.mk b/plat/pc86/libsys/build.mk deleted file mode 100644 index bf0fda6d5..000000000 --- a/plat/pc86/libsys/build.mk +++ /dev/null @@ -1,26 +0,0 @@ -D := plat/pc86/libsys - -define build-pc86-libsys-impl - $(call reset) - $(call ackfile, $D/errno.s) - $(call ackfile, $D/_hol0.s) - $(call ackfile, $D/_sys_rawread.s) - $(call ackfile, $D/_sys_rawwrite.s) - $(call ackfile, $D/open.c) - $(call ackfile, $D/creat.c) - $(call ackfile, $D/close.c) - $(call ackfile, $D/read.c) - $(call ackfile, $D/write.c) - $(call ackfile, $D/brk.c) - $(call ackfile, $D/getpid.c) - $(call ackfile, $D/kill.c) - $(call ackfile, $D/isatty.c) - $(call ackfile, $D/lseek.c) - $(call ackfile, $D/time.c) - $(call ackfile, $D/signal.c) - $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) - $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) -endef - -$(eval $(build-pc86-libsys-impl)) - diff --git a/util/cmisc/build.mk b/util/cmisc/build.mk index 185c3ace6..ae4b7fb2c 100644 --- a/util/cmisc/build.mk +++ b/util/cmisc/build.mk @@ -16,7 +16,7 @@ $(eval $(build-tabgen-impl)) # Output file is compiled with cfile and queued. define tabgen-impl -$(eval g := $(OBJDIR)/$(strip $1).c) +$(eval g := $(OBJDIR)/$(objdir)/$(strip $1).c) $g: $1 $(TABGEN) @echo TABGEN $g @@ -24,8 +24,9 @@ $g: $1 $(TABGEN) $(hide) $(TABGEN) -f$(strip $1) > $g || $(RM) $g $(eval CLEANABLES += $g) -$(call cfile,$g) +$(call $2,$g) endef -tabgen = $(eval $(call tabgen-impl,$1)) +tabgen = $(eval $(call tabgen-impl,$1,cfile)) +acktabgen = $(eval $(call tabgen-impl,$1,ackfile)) diff --git a/util/data/build.mk b/util/data/build.mk index 196bdd52a..c9b601da1 100644 --- a/util/data/build.mk +++ b/util/data/build.mk @@ -11,7 +11,8 @@ $(eval g := \ $(OBJDIR)/$D/em_mnem.c) $(eval CLEANABLES += $g) -$g: $D/new_table h/em_table +$(wordlist 2, $(words $g), $g): $(firstword $g) +$(firstword $g): $D/new_table h/em_table @echo DATA @mkdir -p $(dir $g) $(hide) $D/new_table h/em_table $(INCDIR) $(OBJDIR)/$D diff --git a/util/misc/build.mk b/util/misc/build.mk new file mode 100644 index 000000000..52367113c --- /dev/null +++ b/util/misc/build.mk @@ -0,0 +1,48 @@ +D := util/misc + +define build-misc-impl + $(call reset) + $(call cfile, $D/esize.c) + $(call cprogram, $(BINDIR)/esize) + $(call installto, $(INSDIR)/bin/esize) + + $(call reset) + $(eval q := $D/esize.1) + $(call installto, $(INSDIR)/share/man/man1/esize.1) + + $(call reset) + $(eval objdir := encode) + $(call cfile, $D/convert.c) + $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) + $(call file, $(LIBREAD_EMEV)) + $(call file, $(LIBEMK)) + $(call file, $(LIBEM_DATA)) + $(call file, $(LIBALLOC)) + $(call file, $(LIBPRINT)) + $(call file, $(LIBSTRING)) + $(call file, $(LIBSYSTEM)) + $(call cprogram, $(BINDIR)/em_encode) + $(call installto, $(PLATDEP)/em_encode) + $(eval EM_ENCODE := $o) + + $(call reset) + $(eval objdir := decode) + $(call cfile, $D/convert.c) + $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) + $(call file, $(LIBREAD_EMKV)) + $(call file, $(LIBEME)) + $(call file, $(LIBEM_DATA)) + $(call file, $(LIBALLOC)) + $(call file, $(LIBPRINT)) + $(call file, $(LIBSTRING)) + $(call file, $(LIBSYSTEM)) + $(call cprogram, $(BINDIR)/em_decode) + $(call installto, $(PLATDEP)/em_decode) + $(eval EM_DECODE := $o) + + $(call reset) + $(eval q := $D/em_decode.6) + $(call installto, $(INSDIR)/share/man/man6/em_decode.6) +endef + +$(eval $(build-misc-impl)) From af0dedeb6e8674deb62c0a4d916a67d2a4e05a8c Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 13 May 2013 11:14:10 +0100 Subject: [PATCH 004/231] Fix typo. --HG-- branch : dtrg-buildsystem --- lang/cem/cemcom.ansi/build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/cem/cemcom.ansi/build.mk b/lang/cem/cemcom.ansi/build.mk index f47959ab9..0e6b45267 100644 --- a/lang/cem/cemcom.ansi/build.mk +++ b/lang/cem/cemcom.ansi/build.mk @@ -149,7 +149,7 @@ $(call installto, $(PLATDEP)/em_cemcom.ansi) $(eval CEMCOMANSI := $o) $(call reset) -$(eval q := $D/cemcom.1) +$(eval q := $D/cemcom.ansi.1) $(call installto, $(INSDIR)/share/man/man1/cemcom.6) endef From 442306d557e279d94fb9fe79bc2989568daa0184 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 13 May 2013 22:12:46 +0100 Subject: [PATCH 005/231] Split off some of the platform-independent stuff (such as as and ncg). --HG-- branch : dtrg-buildsystem rename : plat/pc86/build.mk => mach/i386/build.mk rename : plat/pc86/build.mk => mach/i80/build.mk rename : plat/pc86/build.mk => mach/i86/build.mk rename : plat/pc86/build.mk => mach/m68020/build.mk rename : plat/pc86/build.mk => mach/powerpc/build.mk --- Makefile | 7 +++++++ first/core.mk | 2 -- mach/build.mk | 12 ++++++++++++ mach/i386/build.mk | 8 ++++++++ mach/i80/build.mk | 8 ++++++++ mach/i86/build.mk | 8 ++++++++ mach/m68020/build.mk | 8 ++++++++ mach/powerpc/build.mk | 8 ++++++++ mach/proto/as/build.mk | 6 +++--- mach/proto/ncg/build.mk | 6 +++--- plat/build.mk | 6 ++---- plat/cpm/descr | 6 +++--- plat/linux386/descr | 4 ++-- plat/linux68k/descr | 4 ++-- plat/linuxppc/descr | 6 +++--- plat/pc86/descr | 4 ++-- 16 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 mach/build.mk create mode 100644 mach/i386/build.mk create mode 100644 mach/i80/build.mk create mode 100644 mach/i86/build.mk create mode 100644 mach/m68020/build.mk create mode 100644 mach/powerpc/build.mk diff --git a/Makefile b/Makefile index 596a7cbca..637e8baaf 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,13 @@ include mach/proto/ncg/build.mk include plat/linux/liblinux/build.mk +include mach/build.mk +include mach/i80/build.mk +include mach/i386/build.mk +include mach/i86/build.mk +include mach/m68020/build.mk +# include mach/powerpc/build.mk + include plat/build.mk include plat/pc86/build.mk include plat/cpm/build.mk diff --git a/first/core.mk b/first/core.mk index 09b51a925..143748d98 100644 --- a/first/core.mk +++ b/first/core.mk @@ -31,8 +31,6 @@ endef define ackfile-rule $o: $s $(ACK) \ - $(PLATIND)/descr/$(PLATFORM) \ - $(PLATDEP)/$(PLATFORM)/as \ $(CCOMPILER) \ $(PLATFORM_$(PLATFORM)) \ $(EM_ENCODE) diff --git a/mach/build.mk b/mach/build.mk new file mode 100644 index 000000000..368e6b0ca --- /dev/null +++ b/mach/build.mk @@ -0,0 +1,12 @@ +define build-architecture-impl + $(eval ARCHITECTURE_$(ARCH) := \ + $(PLATDEP)/$(ARCH)/as \ + $(PLATDEP)/$(ARCH)/ncg) + + $(eval PLATFORM := $(ARCH)) + $(call build-as) + $(call build-ncg) +endef + +build-architecture = $(eval $(build-architecture-impl)) + diff --git a/mach/i386/build.mk b/mach/i386/build.mk new file mode 100644 index 000000000..f4670cc2f --- /dev/null +++ b/mach/i386/build.mk @@ -0,0 +1,8 @@ +ARCH := i386 +OPTIMISATION := -O + +D := mach/i386 + +$(eval $(call build-architecture)) + + diff --git a/mach/i80/build.mk b/mach/i80/build.mk new file mode 100644 index 000000000..bd3cfc2b3 --- /dev/null +++ b/mach/i80/build.mk @@ -0,0 +1,8 @@ +ARCH := i80 +OPTIMISATION := -O + +D := mach/i80 + +$(eval $(call build-architecture)) + + diff --git a/mach/i86/build.mk b/mach/i86/build.mk new file mode 100644 index 000000000..2f999023d --- /dev/null +++ b/mach/i86/build.mk @@ -0,0 +1,8 @@ +ARCH := i86 +OPTIMISATION := -O + +D := mach/i86 + +$(eval $(call build-architecture)) + + diff --git a/mach/m68020/build.mk b/mach/m68020/build.mk new file mode 100644 index 000000000..2ddaf85a0 --- /dev/null +++ b/mach/m68020/build.mk @@ -0,0 +1,8 @@ +ARCH := m68020 +OPTIMISATION := -O6 + +D := mach/m68020 + +$(eval $(call build-architecture)) + + diff --git a/mach/powerpc/build.mk b/mach/powerpc/build.mk new file mode 100644 index 000000000..75cbeb5d0 --- /dev/null +++ b/mach/powerpc/build.mk @@ -0,0 +1,8 @@ +ARCH := powerpc +OPTIMISATION := -O + +D := mach/powerpc + +$(eval $(call build-architecture)) + + diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 9404f13b9..f7b56ca66 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -2,7 +2,7 @@ define build-as-impl $(call reset) $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D) - $(eval objdir := $(PLATFORM)) + $(eval objdir := $(ARCH)) $(call cfile, mach/proto/as/comm3.c) $(call dependson, $(OBJDIR)/$D/y.tab.h) @@ -35,8 +35,8 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) mach/proto/as/comm2.y > $$@ $(call file, $(LIBOBJECT)) - $(call cprogram, $(BINDIR)/$(PLATFORM)/as) - $(call installto, $(PLATDEP)/$(PLATFORM)/as) + $(call cprogram, $(BINDIR)/$(ARCH)/as) + $(call installto, $(PLATDEP)/$(ARCH)/as) endef build-as = $(eval $(build-as-impl)) diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index 100ece434..f3782322b 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -3,7 +3,7 @@ define build-ncg-impl $(call reset) $(eval cflags += -Imach/$(ARCH)/ncg -I$(OBJDIR)/$D -Imach/proto/ncg) -$(eval objdir := $(PLATFORM)) +$(eval objdir := $(ARCH)) $(call cfile, mach/proto/ncg/codegen.c) $(call cfile, mach/proto/ncg/compute.c) @@ -37,8 +37,8 @@ $(call cfile, $(OBJDIR)/$D/tables.c) $(call file, $(LIBEM_DATA)) $(call file, $(LIBFLT_ARITH)) -$(call cprogram, $(BINDIR)/$(PLATFORM)/ncg) -$(call installto, $(PLATDEP)/$(PLATFORM)/ncg) +$(call cprogram, $(BINDIR)/$(ARCH)/ncg) +$(call installto, $(PLATDEP)/$(ARCH)/ncg) endef diff --git a/plat/build.mk b/plat/build.mk index e43b02614..3a80c438d 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -12,8 +12,9 @@ define build-platform-impl $(call installto, $(PLATIND)/descr/$(PLATFORM)) $(eval PLATFORM_$(PLATFORM) := \ + $(PLATIND)/descr/$(PLATFORM) \ $(PLATFORM_HEADERS_$(PLATFORM)) \ - $(PLATDEP)/$(PLATFORM)/ncg) + $(ARCHITECTURE_$(ARCH))) $(foreach f, $(platform-headers), $(call build-platform-headers, $f)) @@ -22,9 +23,6 @@ define build-platform-impl $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) - $(call build-as) - $(call build-ncg) - $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime))) endef diff --git a/plat/cpm/descr b/plat/cpm/descr index b1b579938..436dc40cc 100644 --- a/plat/cpm/descr +++ b/plat/cpm/descr @@ -23,7 +23,7 @@ var C_INCLUDES=-I{EM}/share/ack/{PLATFORM}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{PLATFORM}/ncg + program {EM}/lib/ack/{ARCH}/ncg args < stdout need .e @@ -31,7 +31,7 @@ end name asopt from .s to .so - program {EM}/lib/ack/{PLATFORM}/top + program {EM}/lib/ack/{ARCH}/top args optimizer stdin @@ -40,7 +40,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{PLATFORM}/as + program {EM}/lib/ack/{ARCH}/as args - -o > < prep cond end diff --git a/plat/linux386/descr b/plat/linux386/descr index ff2b26dfb..a0d23ad3b 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{PLATFORM}/ncg + program {EM}/lib/ack/{ARCH}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +36,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{PLATFORM}/as + program {EM}/lib/ack/{ARCH}/as args - -o > < prep cond end diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 14f973d52..124955b55 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{PLATFORM}/ncg + program {EM}/lib/ack/{ARCH}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +36,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{PLATFORM}/as + program {EM}/lib/ack/{ARCH}/as args - -o > < prep cond end diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr index 2cfb9ac48..3311f24c6 100644 --- a/plat/linuxppc/descr +++ b/plat/linuxppc/descr @@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{PLATFORM}/ncg + program {EM}/lib/ack/{ARCH}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +36,7 @@ end name asopt from .s to .so - program {EM}/lib/ack/{PLATFORM}/top + program {EM}/lib/ack/{ARCH}/top args optimizer stdin @@ -45,7 +45,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{PLATFORM}/as + program {EM}/lib/ack/{ARCH}/as args - -o > < prep cond end diff --git a/plat/pc86/descr b/plat/pc86/descr index a3f11fc4f..f02ab3eed 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -23,7 +23,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{PLATFORM}/ncg + program {EM}/lib/ack/{ARCH}/ncg args < stdout need .e @@ -31,7 +31,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{PLATFORM}/as + program {EM}/lib/ack/{ARCH}/as args - -o > < prep cond end From 07453d184ac318a19d18c93e15786296e2227070 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 13 May 2013 23:26:15 +0100 Subject: [PATCH 006/231] Top, topgen, aelflod. Moved the libraries back into the platform-specific directories --- wrangling descr files was too hard. C programs can be built for cpm, pc86, linux386, linux68k! --HG-- branch : dtrg-buildsystem rename : util/ack/build.mk => util/led/build.mk rename : util/LLgen/build.mk => util/topgen/build.mk --- Makefile | 4 ++- lang/cem/libcc.ansi/build.mk | 8 +++++ mach/build.mk | 12 ------- mach/i386/build.mk | 55 +++++++++++++++++++++++++--- mach/i80/build.mk | 49 ++++++++++++++++++++++--- mach/i86/build.mk | 70 +++++++++++++++++++++++++++++++++--- mach/m68020/build.mk | 35 +++++++++++++++--- mach/powerpc/build.mk | 8 ----- mach/proto/as/build.mk | 4 +-- mach/proto/ncg/build.mk | 4 +-- mach/proto/top/build.mk | 15 ++++++++ plat/build.mk | 33 +++++++++++++++++ plat/cpm/build.mk | 8 +++++ plat/cpm/descr | 8 ++--- plat/linux386/build.mk | 11 ++++++ plat/linux386/descr | 4 +-- plat/linux68k/build.mk | 7 ++++ plat/linux68k/descr | 4 +-- plat/linuxppc/build.mk | 12 +++++++ plat/pc86/build.mk | 7 ++++ plat/pc86/descr | 4 +-- util/LLgen/build.mk | 1 + util/amisc/build.mk | 1 + util/data/build.mk | 3 ++ util/led/build.mk | 34 ++++++++++++++++++ util/ncgg/build.mk | 2 ++ util/topgen/build.mk | 50 ++++++++++++++++++++++++++ 27 files changed, 398 insertions(+), 55 deletions(-) delete mode 100644 mach/build.mk create mode 100644 mach/proto/top/build.mk create mode 100644 util/led/build.mk create mode 100644 util/topgen/build.mk diff --git a/Makefile b/Makefile index 637e8baaf..98f36bef3 100644 --- a/Makefile +++ b/Makefile @@ -50,15 +50,17 @@ include util/opt/build.mk include util/ncgg/build.mk include util/arch/build.mk include util/misc/build.mk +include util/led/build.mk +include util/topgen/build.mk include lang/cem/build.mk include mach/proto/as/build.mk include mach/proto/ncg/build.mk +include mach/proto/top/build.mk include plat/linux/liblinux/build.mk -include mach/build.mk include mach/i80/build.mk include mach/i386/build.mk include mach/i86/build.mk diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 727d04718..a9434ceb4 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -254,6 +254,14 @@ $(call ackfile, lang/cem/libcc.ansi/time/misc.c) $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libc.a) $(call installto, $(PLATIND)/$(PLATFORM)/libc.a) +# CRT + +$(call reset) +$(eval objdir := $(PLATFORM)) +$(eval ackflags += -Ih) +$(call ackfile, lang/cem/libcc.ansi/head_ac.e) +$(call installto, $(PLATIND)/$(PLATFORM)/c-ansi.o) + endef build-runtime-libcc-ansi = $(eval $(build-runtime-libcc-ansi-impl)) diff --git a/mach/build.mk b/mach/build.mk deleted file mode 100644 index 368e6b0ca..000000000 --- a/mach/build.mk +++ /dev/null @@ -1,12 +0,0 @@ -define build-architecture-impl - $(eval ARCHITECTURE_$(ARCH) := \ - $(PLATDEP)/$(ARCH)/as \ - $(PLATDEP)/$(ARCH)/ncg) - - $(eval PLATFORM := $(ARCH)) - $(call build-as) - $(call build-ncg) -endef - -build-architecture = $(eval $(build-architecture-impl)) - diff --git a/mach/i386/build.mk b/mach/i386/build.mk index f4670cc2f..acd5e51eb 100644 --- a/mach/i386/build.mk +++ b/mach/i386/build.mk @@ -1,8 +1,53 @@ -ARCH := i386 -OPTIMISATION := -O +arch-libem-i386 = \ + adi.s \ + and.s \ + blm.s \ + cii.s \ + cms.s \ + com.s \ + csa4.s \ + csb4.s \ + cuu.s \ + dup.s \ + dvi.s \ + dvu.s \ + error.s \ + exg.s \ + fp8087.s \ + fat.s \ + gto.s \ + iaar.s \ + ilar.s \ + inn.s \ + ior.s \ + isar.s \ + lar4.s \ + loi.s \ + mli.s \ + mon.s \ + ngi.s \ + nop.s \ + print.s \ + rck.s \ + rmi.s \ + rmu.s \ + rol.s \ + ror.s \ + sar4.s \ + sbi.s \ + set.s \ + sli.s \ + sri.s \ + sti.s \ + strhp.s \ + trp.s \ + unknown.s \ + xor.s -D := mach/i386 - -$(eval $(call build-architecture)) +arch-libend-i386 = \ + edata.s \ + em_end.s \ + end.s \ + etext.s diff --git a/mach/i80/build.mk b/mach/i80/build.mk index bd3cfc2b3..ce9b07c67 100644 --- a/mach/i80/build.mk +++ b/mach/i80/build.mk @@ -1,8 +1,47 @@ -ARCH := i80 -OPTIMISATION := -O +arch-libem-i80 = \ + aar2.s \ + adi4.s \ + and.s \ + blm.s \ + cii.s \ + cmi4.s \ + cms.s \ + com.s \ + csa.s \ + csb.s \ + dup.s \ + dvi2.s \ + exg.s \ + flp.s \ + inn.s \ + ior.s \ + lar2.s \ + mli2.s \ + mli4.s \ + mlu2.s \ + ngi4.s \ + nop.s \ + rol4.s \ + ror4.s \ + sar2.s \ + sbi4.s \ + set.s \ + set2.s \ + sli2.s \ + sli4.s \ + sri2.s \ + sri4.s \ + xor.s \ + loi.s \ + sti.s \ + dvi4.s \ + rck.s -D := mach/i80 - -$(eval $(call build-architecture)) +arch-libend-i80 = \ + edata.s \ + em_end.s \ + end.s \ + etext.s +arch-top-i80 = yes diff --git a/mach/i86/build.mk b/mach/i86/build.mk index 2f999023d..1613b651f 100644 --- a/mach/i86/build.mk +++ b/mach/i86/build.mk @@ -1,8 +1,68 @@ -ARCH := i86 -OPTIMISATION := -O +arch-libem-i86 := \ + adi.s \ + and.s \ + cii.s \ + cms.s \ + cmi4.s \ + cmu4.s \ + com.s \ + csa2.s \ + csb2.s \ + csa4.s \ + csb4.s \ + cuu.s \ + dup.s \ + dvi.s \ + dvi4.s \ + dvu.s \ + dvu4.s \ + exg.s \ + fp8087.s \ + gto.s \ + iaar.s \ + ilar.s \ + inn.s \ + ior.s \ + isar.s \ + lar2.s \ + loi.s \ + mli.s \ + mli4.s \ + mon.s \ + ngi.s \ + nop.s \ + rck.s \ + rmi.s \ + rmi4.s \ + rmu.s \ + rmu4.s \ + rol.s \ + ror.s \ + sar2.s \ + sbi.s \ + set.s \ + sli.s \ + sri.s \ + sti.s \ + strhp.s \ + xor.s \ + error.s \ + unknown.s \ + fat.s \ + trp.s \ + print.s \ + ret6.s \ + ret8.s \ + lfr6.s \ + lfr8.s \ + retarea.s \ + blm.s \ + return.s -D := mach/i86 - -$(eval $(call build-architecture)) +arch-libend-i86 = \ + edata.s \ + em_end.s \ + end.s \ + etext.s diff --git a/mach/m68020/build.mk b/mach/m68020/build.mk index 2ddaf85a0..5dac37653 100644 --- a/mach/m68020/build.mk +++ b/mach/m68020/build.mk @@ -1,8 +1,33 @@ -ARCH := m68020 -OPTIMISATION := -O6 +arch-libem-m68020 = \ + fp68881.s \ + aar.s \ + lar.s \ + sar.s \ + csa.s \ + csb.s \ + shp.s \ + set.s \ + inn.s \ + fat.s \ + trp.s \ + trpstr.c \ + mon.s \ + nop.s \ + dia.s \ + cii.s \ + cuu.s \ + cmi.s \ + cms.s \ + cmu.s \ + cvf.s \ + exg.s \ + los.s \ + sts.s -D := mach/m68020 - -$(eval $(call build-architecture)) +arch-libend-m68020 = \ + edata.s \ + em_end.s \ + end.s \ + etext.s diff --git a/mach/powerpc/build.mk b/mach/powerpc/build.mk index 75cbeb5d0..e69de29bb 100644 --- a/mach/powerpc/build.mk +++ b/mach/powerpc/build.mk @@ -1,8 +0,0 @@ -ARCH := powerpc -OPTIMISATION := -O - -D := mach/powerpc - -$(eval $(call build-architecture)) - - diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index f7b56ca66..039630f75 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -35,8 +35,8 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) mach/proto/as/comm2.y > $$@ $(call file, $(LIBOBJECT)) - $(call cprogram, $(BINDIR)/$(ARCH)/as) - $(call installto, $(PLATDEP)/$(ARCH)/as) + $(call cprogram, $(BINDIR)/$(PLATFORM)/as) + $(call installto, $(PLATDEP)/$(PLATFORM)/as) endef build-as = $(eval $(build-as-impl)) diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index f3782322b..d37c623d4 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -37,8 +37,8 @@ $(call cfile, $(OBJDIR)/$D/tables.c) $(call file, $(LIBEM_DATA)) $(call file, $(LIBFLT_ARITH)) -$(call cprogram, $(BINDIR)/$(ARCH)/ncg) -$(call installto, $(PLATDEP)/$(ARCH)/ncg) +$(call cprogram, $(BINDIR)/$(PLATFORM)/ncg) +$(call installto, $(PLATDEP)/$(PLATFORM)/ncg) endef diff --git a/mach/proto/top/build.mk b/mach/proto/top/build.mk new file mode 100644 index 000000000..56f41c276 --- /dev/null +++ b/mach/proto/top/build.mk @@ -0,0 +1,15 @@ +define build-top-impl + $(call reset) + $(eval cflags += -I$(OBJDIR)/$(PLATFORM)/top) + + $(call cfile, mach/proto/top/queue.c) + $(call cfile, mach/proto/top/top.c) + $(eval $q: $(OBJDIR)/$(PLATFORM)/top/gen.h) + + $(call topgen, $(OBJDIR)/$(PLATFORM)/top, mach/$(ARCH)/top/table) + + $(call cprogram, $(OBJDIR)/$(PLATFORM)/top/top) + $(call installto, $(PLATDEP)/$(PLATFORM)/top) +endef + +build-top = $(eval $(build-top-impl)) diff --git a/plat/build.mk b/plat/build.mk index 3a80c438d..3f8994fc9 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -14,15 +14,48 @@ define build-platform-impl $(eval PLATFORM_$(PLATFORM) := \ $(PLATIND)/descr/$(PLATFORM) \ $(PLATFORM_HEADERS_$(PLATFORM)) \ + $(PLATDEP)/$(PLATFORM)/as \ + $(PLATDEP)/$(PLATFORM)/ncg \ $(ARCHITECTURE_$(ARCH))) $(foreach f, $(platform-headers), $(call build-platform-headers, $f)) + # libsys + $(call reset) $(foreach f, $(platform-libsys), $(call ackfile, $D/libsys/$f)) $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) + # libem + + $(call reset) + $(eval objdir := $(PLATFORM)) + $(eval ackflags += -Ih) + $(foreach f, $(arch-libem-$(ARCH)), $(call ackfile, mach/$(ARCH)/libem/$f)) + $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libem.a) + $(call installto, $(PLATIND)/$(PLATFORM)/libem.a) + + # libend + + $(call reset) + $(eval objdir := $(PLATFORM)) + $(eval ackflags += -Ih) + $(foreach f, $(arch-libend-$(ARCH)), $(call ackfile, mach/$(ARCH)/libend/$f)) + $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libend.a) + $(call installto, $(PLATIND)/$(PLATFORM)/libend.a) + + # The tools themselves + + $(call build-as) + $(call build-ncg) + + # Build top only if the architecture asks for it. + + $(if $(arch-top-$(ARCH)), $(call build-top)) + + # Language runtimes + $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime))) endef diff --git a/plat/cpm/build.mk b/plat/cpm/build.mk index 2f8836956..54ed3d839 100644 --- a/plat/cpm/build.mk +++ b/plat/cpm/build.mk @@ -30,5 +30,13 @@ platform-libsys := \ $(eval $(call build-platform)) +define build-cpm-boot-impl + $(call reset) + $(call ackfile, $D/boot.s) + $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) +endef + +$(eval $(build-cpm-boot-impl)) + diff --git a/plat/cpm/descr b/plat/cpm/descr index 436dc40cc..a72f50276 100644 --- a/plat/cpm/descr +++ b/plat/cpm/descr @@ -10,7 +10,7 @@ var f=4 var d=8 var ARCH=i80 var PLATFORM=cpm -var PLATFORMDIR={EM}/lib/ack/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 -b0:0x0100 var MACHOPT_F=-m8 @@ -23,7 +23,7 @@ var C_INCLUDES=-I{EM}/share/ack/{PLATFORM}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{ARCH}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg args < stdout need .e @@ -31,7 +31,7 @@ end name asopt from .s to .so - program {EM}/lib/ack/{ARCH}/top + program {EM}/lib/ack/{PLATFORM}/top args optimizer stdin @@ -40,7 +40,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{ARCH}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end diff --git a/plat/linux386/build.mk b/plat/linux386/build.mk index 760cc69f6..f35fa6be7 100644 --- a/plat/linux386/build.mk +++ b/plat/linux386/build.mk @@ -15,3 +15,14 @@ platform-libsys := \ $(eval $(call build-platform)) $(eval $(call build-liblinux)) +define build-linux386-boot-impl + $(call reset) + $(call ackfile, $D/boot.s) + $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) +endef + +$(eval $(build-linux386-boot-impl)) + + + + diff --git a/plat/linux386/descr b/plat/linux386/descr index a0d23ad3b..ff2b26dfb 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{ARCH}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +36,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{ARCH}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end diff --git a/plat/linux68k/build.mk b/plat/linux68k/build.mk index b230b2500..7a1e7223b 100644 --- a/plat/linux68k/build.mk +++ b/plat/linux68k/build.mk @@ -15,4 +15,11 @@ platform-libsys := \ $(eval $(call build-platform)) $(eval $(call build-liblinux)) +define build-linux68k-boot-impl + $(call reset) + $(call ackfile, $D/boot.s) + $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) +endef + +$(eval $(build-linux68k-boot-impl)) diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 124955b55..14f973d52 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -27,7 +27,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{ARCH}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +36,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{ARCH}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end diff --git a/plat/linuxppc/build.mk b/plat/linuxppc/build.mk index 515d498a6..d19fa5aa3 100644 --- a/plat/linuxppc/build.mk +++ b/plat/linuxppc/build.mk @@ -16,4 +16,16 @@ platform-libsys := \ $(eval $(call build-platform)) $(eval $(call build-liblinux)) +define build-linuxppc-boot-impl + $(call reset) + $(call ackfile, $D/boot.s) + $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) +endef + +$(eval $(build-linuxppc-boot-impl)) + + + + + diff --git a/plat/pc86/build.mk b/plat/pc86/build.mk index 8a7ec92f1..1ae9e5f49 100644 --- a/plat/pc86/build.mk +++ b/plat/pc86/build.mk @@ -28,4 +28,11 @@ platform-libsys := \ $(eval $(call build-platform)) +define build-pc86-boot-impl + $(call reset) + $(call ackfile, $D/boot.s) + $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) +endef + +$(eval $(build-pc86-boot-impl)) diff --git a/plat/pc86/descr b/plat/pc86/descr index f02ab3eed..a3f11fc4f 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -23,7 +23,7 @@ var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib/ack/{ARCH}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg args < stdout need .e @@ -31,7 +31,7 @@ end name as from .s.so to .o - program {EM}/lib/ack/{ARCH}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end diff --git a/util/LLgen/build.mk b/util/LLgen/build.mk index 44b63f891..3c40d1886 100644 --- a/util/LLgen/build.mk +++ b/util/LLgen/build.mk @@ -46,6 +46,7 @@ $o: $1/Lpars.h $1/Lpars.h: $2 $(LLGEN) @echo LLGEN $1/Lpars.c @mkdir -p $(dir $o) + $(hide) $(RM) $o $1/Lpars.h $(hide) cd $(dir $o) && $(LLGEN) $(abspath $2) $(foreach f,$o,$(call cfile,$f)) diff --git a/util/amisc/build.mk b/util/amisc/build.mk index e7f71e33f..03f44b5e9 100644 --- a/util/amisc/build.mk +++ b/util/amisc/build.mk @@ -19,4 +19,5 @@ $(call build-simple-tool,ashow) $(call build-simple-tool,asize) $(call build-simple-tool,aslod) $(call build-simple-tool,astrip) +$(call build-simple-tool,aelflod) diff --git a/util/data/build.mk b/util/data/build.mk index c9b601da1..424712956 100644 --- a/util/data/build.mk +++ b/util/data/build.mk @@ -22,6 +22,9 @@ $(call cfile, $(OBJDIR)/$D/em_flag.c) $(call cfile, $(OBJDIR)/$D/em_pseu.c) $(call cfile, $(OBJDIR)/$D/em_mnem.c) $(call cfile, $D/em_ptyp.c) + +$(eval $q: $g) + $(call clibrary, $(LIBDIR)/libem_data.a) $(eval LIBEM_DATA := $q) diff --git a/util/led/build.mk b/util/led/build.mk new file mode 100644 index 000000000..d96dd35c6 --- /dev/null +++ b/util/led/build.mk @@ -0,0 +1,34 @@ +D := util/led + +define build-led-impl + $(call reset) + $(call cfile, $D/archive.c) + $(call cfile, $D/error.c) + $(call cfile, $D/extract.c) + $(call cfile, $D/finish.c) + $(call cfile, $D/main.c) + $(call cfile, $D/memory.c) + $(call cfile, $D/output.c) + $(call cfile, $D/read.c) + $(call cfile, $D/relocate.c) + $(call cfile, $D/save.c) + $(call cfile, $D/scan.c) + $(call cfile, $D/sym.c) + $(call cfile, $D/write.c) + + $(call file, $(LIBSTRING)) + $(call file, $(LIBOBJECT)) + + $(call cprogram, $(BINDIR)/em_led) + $(call installto, $(PLATDEP)/em_led) + + $(call reset) + $(eval q := $D/ack.out.5) + $(call installto, $(INSDIR)/share/man/man5/ack.out.5) + + $(call reset) + $(eval q := $D/led.6) + $(call installto, $(INSDIR)/share/man/man6/led.6) +endef + +$(eval $(build-led-impl)) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk index 97576794d..c3a7f31fa 100644 --- a/util/ncgg/build.mk +++ b/util/ncgg/build.mk @@ -32,6 +32,8 @@ $(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) $(call cfile, $(OBJDIR)/$D/enterkeyw.c) +$(eval $q: $(INCDIR)/em_spec.h) + $(call file, $(LIBEM_DATA)) $(call cprogram, $(BINDIR)/ncgg) $(eval NCGG := $o) diff --git a/util/topgen/build.mk b/util/topgen/build.mk new file mode 100644 index 000000000..4ef15c278 --- /dev/null +++ b/util/topgen/build.mk @@ -0,0 +1,50 @@ +D := util/topgen + +# Rule to build topgen. + +define build-topgen-impl + $(call reset) + $(eval cflags += -I$(OBJDIR)/$D -I$D) + + $(call cfile, $D/LLlex.c) + $(call cfile, $D/hash.c) + $(call cfile, $D/main.c) + $(call cfile, $D/pattern.c) + $(call cfile, $D/symtab.c) + $(eval $q: $(OBJDIR)/$D/Lpars.h) + + $(call llgen, $(OBJDIR)/$D, $D/topgen.g) + + $(call file, $(LIBASSERT)) + $(call file, $(LIBPRINT)) + $(call file, $(LIBALLOC)) + $(call file, $(LIBSYSTEM)) + $(call file, $(LIBSTRING)) + + $(call cprogram, $(BINDIR)/topgen) + TOPGEN := $o +endef + +$(eval $(build-topgen-impl)) + +# Rule to invoke to *use* LLgen. +# +# $1: directory to put output files +# $2: input files +# +# Output files are *not* compiled (gen.c is expected to be included by +# something). + +define topgen-impl +$(eval CLEANABLES += $1/gen.h $1/gen.c) + +$1/gen.h: $1/gen.c +$1/gen.c: $2 $(TOPGEN) + @echo TOPGEN $$@ + @mkdir -p $$(dir $$@) + $(hide) $(RM) $1/gen.h $1/gen.c + $(hide) cd $$(dir $$@) && $(abspath $(TOPGEN)) $(abspath $2) + +endef + +topgen = $(eval $(call topgen-impl,$1,$2)) From a68b117e9674817c116745b449f6845a3ab07072 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 14 May 2013 14:55:29 +0100 Subject: [PATCH 007/231] Add missing dependency. --HG-- branch : dtrg-buildsystem --- mach/proto/ncg/build.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index d37c623d4..4494a8905 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -34,6 +34,8 @@ $(OBJDIR)/$D/tables.h: $(NCGG) $(CPPANSI) mach/$(ARCH)/ncg/table $(call cfile, $(OBJDIR)/$D/tables.c) +$(eval $q: $(INCDIR)/flt_arith.h) + $(call file, $(LIBEM_DATA)) $(call file, $(LIBFLT_ARITH)) From d5f01077467f6113539221b6abc8c1897b3f1015 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 14 May 2013 16:11:29 +0100 Subject: [PATCH 008/231] Build the Basic run-time library (after some modernisation). --HG-- branch : dtrg-buildsystem --- Makefile | 1 + first/core.mk | 2 +- lang/basic/build.mk | 4 ++ lang/basic/lib/atn.c | 57 +------------------------ lang/basic/lib/build.mk | 48 +++++++++++++++++++++ lang/basic/lib/error.c | 3 +- lang/basic/lib/exp.c | 85 +----------------------------------- lang/basic/lib/hlt.c | 2 +- lang/basic/lib/io.c | 12 ++---- lang/basic/lib/log.c | 45 +------------------ lang/basic/lib/oct.c | 2 + lang/basic/lib/power.c | 32 +------------- lang/basic/lib/print.c | 2 + lang/basic/lib/random.c | 3 +- lang/basic/lib/salloc.c | 4 +- lang/basic/lib/sin.c | 95 ++--------------------------------------- lang/basic/lib/sqt.c | 59 +------------------------ lang/basic/lib/stop.c | 3 +- lang/basic/lib/string.c | 2 + lang/basic/lib/trap.c | 2 + plat/build.mk | 4 +- util/arch/build.mk | 1 + util/misc/build.mk | 1 + util/opt/build.mk | 1 + 24 files changed, 89 insertions(+), 381 deletions(-) create mode 100644 lang/basic/build.mk create mode 100644 lang/basic/lib/build.mk diff --git a/Makefile b/Makefile index 98f36bef3..52e792e64 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ include util/led/build.mk include util/topgen/build.mk include lang/cem/build.mk +include lang/basic/build.mk include mach/proto/as/build.mk include mach/proto/ncg/build.mk diff --git a/first/core.mk b/first/core.mk index 143748d98..f1530d4d9 100644 --- a/first/core.mk +++ b/first/core.mk @@ -33,7 +33,7 @@ define ackfile-rule $o: $s $(ACK) \ $(CCOMPILER) \ $(PLATFORM_$(PLATFORM)) \ - $(EM_ENCODE) + $(ACK_CORE_TOOLS) @echo ACK $o @mkdir -p $(dir $o) $(hide) ACKDIR=$(INSDIR) $(ACK) $(ACKFLAGS) $(ackflags) -m$(PLATFORM) -c -o $o $s diff --git a/lang/basic/build.mk b/lang/basic/build.mk new file mode 100644 index 000000000..9a61c3578 --- /dev/null +++ b/lang/basic/build.mk @@ -0,0 +1,4 @@ +include lang/basic/lib/build.mk +#include lang/cem/cemcom.ansi/build.mk +#include lang/cem/libcc.ansi/build.mk + diff --git a/lang/basic/lib/atn.c b/lang/basic/lib/atn.c index db53b81bd..18c4dc6ef 100644 --- a/lang/basic/lib/atn.c +++ b/lang/basic/lib/atn.c @@ -7,62 +7,7 @@ /* $Id$ */ -#define __NO_DEFS #include -double -_atn(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ +double _atn(double x) { return atan(x); } - static double p[] = { - -0.13688768894191926929e+2, - -0.20505855195861651981e+2, - -0.84946240351320683534e+1, - -0.83758299368150059274e+0 - }; - static double q[] = { - 0.41066306682575781263e+2, - 0.86157349597130242515e+2, - 0.59578436142597344465e+2, - 0.15024001160028576121e+2, - 1.0 - }; - static double a[] = { - 0.0, - 0.52359877559829887307710723554658381, /* pi/6 */ - M_PI_2, - 1.04719755119659774615421446109316763 /* pi/3 */ - }; - - int neg = x < 0; - int n; - double g; - - if (neg) { - x = -x; - } - if (x > 1.0) { - x = 1.0/x; - n = 2; - } - else n = 0; - - if (x > 0.26794919243112270647) { /* 2-sqtr(3) */ - n = n + 1; - x = (((0.73205080756887729353*x-0.5)-0.5)+x)/ - (1.73205080756887729353+x); - } - - /* ??? avoid underflow ??? */ - - g = x * x; - x += x * g * POLYNOM3(g, p) / POLYNOM4(g, q); - if (n > 1) x = -x; - x += a[n]; - return neg ? -x : x; -} diff --git a/lang/basic/lib/build.mk b/lang/basic/lib/build.mk new file mode 100644 index 000000000..9f54a4b4e --- /dev/null +++ b/lang/basic/lib/build.mk @@ -0,0 +1,48 @@ +define build-runtime-libbasic-impl + +$(call reset) +$(eval objdir := $(PLATFORM)) + +$(call ackfile, lang/basic/lib/fif.e) +$(call ackfile, lang/basic/lib/fef.e) +$(call ackfile, lang/basic/lib/setline.e) +$(call ackfile, lang/basic/lib/abs.c) +$(call ackfile, lang/basic/lib/asc.c) +$(call ackfile, lang/basic/lib/asrt.c) +$(call ackfile, lang/basic/lib/atn.c) +$(call ackfile, lang/basic/lib/chr.c) +$(call ackfile, lang/basic/lib/conversion.c) +$(call ackfile, lang/basic/lib/error.c) +$(call ackfile, lang/basic/lib/exp.c) +$(call ackfile, lang/basic/lib/file.c) +$(call ackfile, lang/basic/lib/hlt.c) +$(call ackfile, lang/basic/lib/io.c) +$(call ackfile, lang/basic/lib/log.c) +$(call ackfile, lang/basic/lib/mki.c) +$(call ackfile, lang/basic/lib/oct.c) +$(call ackfile, lang/basic/lib/peek.c) +$(call ackfile, lang/basic/lib/power.c) +$(call ackfile, lang/basic/lib/print.c) +$(call ackfile, lang/basic/lib/random.c) +$(call ackfile, lang/basic/lib/read.c) +$(call ackfile, lang/basic/lib/return.c) +$(call ackfile, lang/basic/lib/salloc.c) +$(call ackfile, lang/basic/lib/sgn.c) +$(call ackfile, lang/basic/lib/sin.c) +$(call ackfile, lang/basic/lib/sqt.c) +$(call ackfile, lang/basic/lib/stop.c) +$(call ackfile, lang/basic/lib/string.c) +$(call ackfile, lang/basic/lib/swap.c) +$(call ackfile, lang/basic/lib/trace.c) +$(call ackfile, lang/basic/lib/trap.c) +$(call ackfile, lang/basic/lib/write.c) + +$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libbasic.a) +$(call installto, $(PLATIND)/$(PLATFORM)/libbasic.a) + +endef + +build-runtime-libbasic = $(eval $(build-runtime-libbasic-impl)) + +$(eval RUNTIMES += libbasic) + diff --git a/lang/basic/lib/error.c b/lang/basic/lib/error.c index 6d8f9aa3c..b2d893adc 100644 --- a/lang/basic/lib/error.c +++ b/lang/basic/lib/error.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include /* error takes an error value in the range of 0-255 */ /* and generates a trap */ diff --git a/lang/basic/lib/exp.c b/lang/basic/lib/exp.c index 32cb9eff9..c16344e56 100644 --- a/lang/basic/lib/exp.c +++ b/lang/basic/lib/exp.c @@ -10,88 +10,7 @@ #define __NO_DEFS #include -static double -ldexp(fl,exp) - double fl; - int exp; +double _exp(double x) { - extern double _fef(); - int sign = 1; - int currexp; - - if (fl<0) { - fl = -fl; - sign = -1; - } - fl = _fef(fl,&currexp); - exp += currexp; - if (exp > 0) { - while (exp>30) { - fl *= (double) (1L << 30); - exp -= 30; - } - fl *= (double) (1L << exp); - } - else { - while (exp<-30) { - fl /= (double) (1L << 30); - exp += 30; - } - fl /= (double) (1L << -exp); - } - return sign * fl; -} - -double -_exp(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - - static double p[] = { - 0.25000000000000000000e+0, - 0.75753180159422776666e-2, - 0.31555192765684646356e-4 - }; - - static double q[] = { - 0.50000000000000000000e+0, - 0.56817302698551221787e-1, - 0.63121894374398503557e-3, - 0.75104028399870046114e-6 - }; - double xn, g; - int n; - int negative = x < 0; - - if (x <= M_LN_MIN_D) { - return M_MIN_D; - } - if (x >= M_LN_MAX_D) { - if (x > M_LN_MAX_D) error(3); - return M_MAX_D; - } - if (negative) x = -x; - - /* ??? avoid underflow ??? */ - - n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */ - xn = n; - { - double x1 = (long) x; - double x2 = x - x1; - - g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4); - } - if (negative) { - g = -g; - n = -n; - } - xn = g * g; - x = g * POLYNOM2(xn, p); - n += 1; - return (ldexp(0.5 + x/(POLYNOM3(xn, q) - x), n)); + return exp(x); } diff --git a/lang/basic/lib/hlt.c b/lang/basic/lib/hlt.c index 3ba8a681f..20f4d5276 100644 --- a/lang/basic/lib/hlt.c +++ b/lang/basic/lib/hlt.c @@ -1,4 +1,4 @@ -/* $Id$ */ +#include _hlt(nr) int nr; diff --git a/lang/basic/lib/io.c b/lang/basic/lib/io.c index b7343e278..e0d7581f0 100644 --- a/lang/basic/lib/io.c +++ b/lang/basic/lib/io.c @@ -1,9 +1,8 @@ #include "bc_io.h" -#include -/* $Id$ */ - -struct sgttyb _ttydef; +/* dtrg --- this originally used sgtty.h to do clever tty manipulation. + * Strictly this should be converted to use termios, but for simplicity + * we're going to stick with plain stdio for now. */ /* BASIC has some nasty io characteristics */ @@ -65,9 +64,6 @@ char *buf; if( _chann == -1) { pos= _pos; - gtty(0,_ttydef); - _ttydef.sg_flags &= ~ECHO; - stty(0,_ttydef); }else pos= _fdtable[_chann].pos; c= buf; while( (holder = fgetc(_chanrd)) != EOF && holder != '\n'){ @@ -79,8 +75,6 @@ char *buf; if( _chann== -1) { _pos=pos; - _ttydef.sg_flags |= ECHO; - stty(0,_ttydef); } else _fdtable[_chann].pos= pos; } _tab(x) diff --git a/lang/basic/lib/log.c b/lang/basic/lib/log.c index 06833cd0a..e194f51d7 100644 --- a/lang/basic/lib/log.c +++ b/lang/basic/lib/log.c @@ -10,48 +10,7 @@ #define __NO_DEFS #include -double -_log(x) - double x; +double _log(double x) { - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - static double a[] = { - -0.64124943423745581147e2, - 0.16383943563021534222e2, - -0.78956112887491257267e0 - }; - static double b[] = { - -0.76949932108494879777e3, - 0.31203222091924532844e3, - -0.35667977739034646171e2, - 1.0 - }; - - extern double _fef(); - double znum, zden, z, w; - int exponent; - - if (x <= 0) { - error(3); - return -HUGE; - } - - x = _fef(x, &exponent); - if (x > M_1_SQRT2) { - znum = (x - 0.5) - 0.5; - zden = x * 0.5 + 0.5; - } - else { - znum = x - 0.5; - zden = znum * 0.5 + 0.5; - exponent--; - } - z = znum/zden; w = z * z; - x = z + z * w * (POLYNOM2(w,a)/POLYNOM3(w,b)); - z = exponent; - x += z * (-2.121944400546905827679e-4); - return x + z * 0.693359375; + return log(x); } diff --git a/lang/basic/lib/oct.c b/lang/basic/lib/oct.c index 29a9040c3..ea73bc11d 100644 --- a/lang/basic/lib/oct.c +++ b/lang/basic/lib/oct.c @@ -1,3 +1,5 @@ +#include +#include #include "bc_string.h" /* $Id$ */ diff --git a/lang/basic/lib/power.c b/lang/basic/lib/power.c index 517262342..4a33806cd 100644 --- a/lang/basic/lib/power.c +++ b/lang/basic/lib/power.c @@ -1,32 +1,4 @@ -/* $Id$ */ +#include -/* - computes a^b. - uses log and exp -*/ +double _power(double x, double y) { return pow(x, y); } -double _log(), _exp(); - -double -_power(base,pownr) -double pownr, base; -{ - double temp; - long l; - - if(pownr <= 0.0) { - if(pownr == 0.0) { - if(base <= 0.0) - error(3); - return(0.0); - } - l = base; - if(l != base) - error(3); - temp = _exp(base * _log(-pownr)); - if(l & 1) - temp = -temp; - return(temp); - } - return(_exp(base * _log(pownr))); -} diff --git a/lang/basic/lib/print.c b/lang/basic/lib/print.c index 4ed9806bf..a4bdebfc1 100644 --- a/lang/basic/lib/print.c +++ b/lang/basic/lib/print.c @@ -1,3 +1,5 @@ +#include +#include #include "bc_string.h" #include "bc_io.h" diff --git a/lang/basic/lib/random.c b/lang/basic/lib/random.c index 3707d1e70..17340eddb 100644 --- a/lang/basic/lib/random.c +++ b/lang/basic/lib/random.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include #if !defined(EM_WSIZE) #define EM_WSIZE _EM_WSIZE diff --git a/lang/basic/lib/salloc.c b/lang/basic/lib/salloc.c index c8e36b372..ef221a273 100644 --- a/lang/basic/lib/salloc.c +++ b/lang/basic/lib/salloc.c @@ -1,6 +1,4 @@ -/* $Id$ */ - -extern char *malloc() ; +#include char * salloc(length) unsigned length; diff --git a/lang/basic/lib/sin.c b/lang/basic/lib/sin.c index b6c3daab6..6503d92e6 100644 --- a/lang/basic/lib/sin.c +++ b/lang/basic/lib/sin.c @@ -10,96 +10,7 @@ #define __NO_DEFS #include -static double -sinus(x, cos_flag) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ +double _sin(double x) { return sin(x); } +double _cos(double x) { return cos(x); } +double _tan(double x) { return tan(x); } - static double r[] = { - -0.16666666666666665052e+0, - 0.83333333333331650314e-2, - -0.19841269841201840457e-3, - 0.27557319210152756119e-5, - -0.25052106798274584544e-7, - 0.16058936490371589114e-9, - -0.76429178068910467734e-12, - 0.27204790957888846175e-14 - }; - - double xsqr; - double y; - int neg = 0; - - if (x < 0) { - x = -x; - neg = 1; - } - if (cos_flag) { - neg = 0; - y = M_PI_2 + x; - } - else y = x; - - /* ??? avoid loss of significance, if y is too large, error ??? */ - - y = y * M_1_PI + 0.5; - - /* Use extended precision to calculate reduced argument. - Here we used 12 bits of the mantissa for a1. - Also split x in integer part x1 and fraction part x2. - */ -#define A1 3.1416015625 -#define A2 -8.908910206761537356617e-6 - { - double x1, x2; - extern double _fif(); - - _fif(y, 1.0, &y); - if (_fif(y, 0.5, &x1)) neg = !neg; - if (cos_flag) y -= 0.5; - x2 = _fif(x, 1.0, &x1); - x = x1 - y * A1; - x += x2; - x -= y * A2; -#undef A1 -#undef A2 - } - - if (x < 0) { - neg = !neg; - x = -x; - } - - /* ??? avoid underflow ??? */ - - y = x * x; - x += x * y * POLYNOM7(y, r); - return neg ? -x : x; -} - -double -_sin(x) - double x; -{ - return sinus(x, 0); -} - -double -_cos(x) - double x; -{ - if (x < 0) x = -x; - return sinus(x, 1); -} - -/* EXTENSION */ -double -_tan(x) - double x; -{ - return _sin(x)/_cos(x); -} diff --git a/lang/basic/lib/sqt.c b/lang/basic/lib/sqt.c index dbc9fa7a3..b71483ef7 100644 --- a/lang/basic/lib/sqt.c +++ b/lang/basic/lib/sqt.c @@ -10,62 +10,5 @@ #define __NO_DEFS #include -#define NITER 5 +double _sqt(double x) { return sqrt(x); } -static double -ldexp(fl,exp) - double fl; - int exp; -{ - extern double _fef(); - int sign = 1; - int currexp; - - if (fl<0) { - fl = -fl; - sign = -1; - } - fl = _fef(fl,&currexp); - exp += currexp; - if (exp > 0) { - while (exp>30) { - fl *= (double) (1L << 30); - exp -= 30; - } - fl *= (double) (1L << exp); - } - else { - while (exp<-30) { - fl /= (double) (1L << 30); - exp += 30; - } - fl /= (double) (1L << -exp); - } - return sign * fl; -} - -double -_sqt(x) - double x; -{ - extern double _fef(); - int exponent; - double val; - - if (x <= 0) { - if (x < 0) error(3); - return 0; - } - - val = _fef(x, &exponent); - if (exponent & 1) { - exponent--; - val *= 2; - } - val = ldexp(val + 1.0, exponent/2 - 1); - /* was: val = (val + 1.0)/2.0; val = ldexp(val, exponent/2); */ - for (exponent = NITER - 1; exponent >= 0; exponent--) { - val = (val + x / val) / 2.0; - } - return val; -} diff --git a/lang/basic/lib/stop.c b/lang/basic/lib/stop.c index 571562a89..8ef27cabf 100644 --- a/lang/basic/lib/stop.c +++ b/lang/basic/lib/stop.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include _stop() { diff --git a/lang/basic/lib/string.c b/lang/basic/lib/string.c index bc8485991..4ccc69191 100644 --- a/lang/basic/lib/string.c +++ b/lang/basic/lib/string.c @@ -1,3 +1,5 @@ +#include +#include #include "bc_string.h" /* $Id$ */ diff --git a/lang/basic/lib/trap.c b/lang/basic/lib/trap.c index 6079686d0..4bcf742ee 100644 --- a/lang/basic/lib/trap.c +++ b/lang/basic/lib/trap.c @@ -1,3 +1,5 @@ +#include +#include #include #include diff --git a/plat/build.mk b/plat/build.mk index 3f8994fc9..89acb8c2e 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -11,6 +11,8 @@ define build-platform-impl $(eval q := $D/descr) $(call installto, $(PLATIND)/descr/$(PLATFORM)) + $(foreach f, $(platform-headers), $(call build-platform-headers, $f)) + $(eval PLATFORM_$(PLATFORM) := \ $(PLATIND)/descr/$(PLATFORM) \ $(PLATFORM_HEADERS_$(PLATFORM)) \ @@ -18,8 +20,6 @@ define build-platform-impl $(PLATDEP)/$(PLATFORM)/ncg \ $(ARCHITECTURE_$(ARCH))) - $(foreach f, $(platform-headers), $(call build-platform-headers, $f)) - # libsys $(call reset) diff --git a/util/arch/build.mk b/util/arch/build.mk index b70893f41..4d283f881 100644 --- a/util/arch/build.mk +++ b/util/arch/build.mk @@ -14,6 +14,7 @@ define build-aal-impl $(call cprogram, $(BINDIR)/aal) $(call installto, $(INSDIR)/bin/aal) $(eval AAL := $o) + $(eval ACK_CORE_TOOLS += $o) $(call reset) $(eval q := $D/aal.1) diff --git a/util/misc/build.mk b/util/misc/build.mk index 52367113c..dfa8ac7c1 100644 --- a/util/misc/build.mk +++ b/util/misc/build.mk @@ -24,6 +24,7 @@ define build-misc-impl $(call cprogram, $(BINDIR)/em_encode) $(call installto, $(PLATDEP)/em_encode) $(eval EM_ENCODE := $o) + $(eval ACK_CORE_TOOLS += $o) $(call reset) $(eval objdir := decode) diff --git a/util/opt/build.mk b/util/opt/build.mk index bb3c464a6..9928d40cf 100644 --- a/util/opt/build.mk +++ b/util/opt/build.mk @@ -67,6 +67,7 @@ $(eval $q: $(INCDIR)/em_spec.h) $(call cprogram, $(BINDIR)/em_opt) $(call installto, $(PLATDEP)/em_opt) $(eval EM_OPT := $o) +$(eval ACK_CORE_TOOLS += $o) $(call reset) $(eval q := $D/em_opt.6) From a6ebaeabd02866c8a79ffc3d23574dc8f5496655 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 14 May 2013 18:01:38 +0100 Subject: [PATCH 009/231] Basic compiler now runs. --HG-- branch : dtrg-buildsystem --- lang/basic/build.mk | 3 +-- lang/basic/src/basic.lex | 2 +- lang/basic/src/build.mk | 44 ++++++++++++++++++++++++++++++++++++++++ lang/basic/src/compile.c | 2 +- lang/basic/src/gencode.c | 2 +- lib/descr/fe | 2 +- 6 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 lang/basic/src/build.mk diff --git a/lang/basic/build.mk b/lang/basic/build.mk index 9a61c3578..c14c7f358 100644 --- a/lang/basic/build.mk +++ b/lang/basic/build.mk @@ -1,4 +1,3 @@ include lang/basic/lib/build.mk -#include lang/cem/cemcom.ansi/build.mk -#include lang/cem/libcc.ansi/build.mk +include lang/basic/src/build.mk diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index 974768932..0f514c97d 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -237,7 +237,7 @@ File *stream; extern char *strchr(); -getline() +getinputline() { /* get next input line */ diff --git a/lang/basic/src/build.mk b/lang/basic/src/build.mk new file mode 100644 index 000000000..e8a6f3cfb --- /dev/null +++ b/lang/basic/src/build.mk @@ -0,0 +1,44 @@ +D := lang/basic/src + +define build-bem-impl + +$(call reset) +$(eval cflags += -I$(OBJDIR)/$D -I$D) + +$(call cfile, $D/bem.c) +$(call cfile, $D/symbols.c) +$(call cfile, $D/initialize.c) +$(call cfile, $D/compile.c) +$(call cfile, $D/parsepar.c) +$(call cfile, $D/gencode.c) +$(call cfile, $D/util.c) +$(call cfile, $D/graph.c) +$(call cfile, $D/eval.c) +$(call cfile, $D/func.c) + +$(call llgen, $(OBJDIR)/$D, $D/basic.g) + +$(eval g := $(OBJDIR)/$D/token.h) +$(eval CLEANABLES += $g) +$g: $D/maketokentab $(OBJDIR)/$D/Lpars.h + @echo TOKENTAB $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $(OBJDIR)/$D && $(abspath $$^) + +$(eval $q: $(OBJDIR)/$D/token.h) +$(eval $q: $(OBJDIR)/$D/Lpars.h) +$(eval $q: $(INCDIR)/print.h) + +$(call file, $(LIBEM_MES)) +$(call file, $(LIBEMK)) +$(call file, $(LIBEM_DATA)) +$(call file, $(LIBALLOC)) +$(call file, $(LIBPRINT)) +$(call file, $(LIBSTRING)) +$(call file, $(LIBSYSTEM)) +$(call cprogram, $(BINDIR)/em_bem) +$(call installto, $(PLATDEP)/em_bem) + +endef + +$(eval $(build-bem-impl)) diff --git a/lang/basic/src/compile.c b/lang/basic/src/compile.c index 7325cdf74..eee685910 100644 --- a/lang/basic/src/compile.c +++ b/lang/basic/src/compile.c @@ -23,7 +23,7 @@ compileprogram() prolog2(); /* Some statements are moved from prolog2 to epilogcode in the new version of the compiler */ - while( basicline = 0, getline()) + while( basicline = 0, getinputline()) (void) LLparse(); epilogcode(); sys_close(yyin); diff --git a/lang/basic/src/gencode.c b/lang/basic/src/gencode.c index 4facb3af9..8c7a50e95 100644 --- a/lang/basic/src/gencode.c +++ b/lang/basic/src/gencode.c @@ -644,7 +644,7 @@ prolog2() C_loi((arith) BEMPTRSIZE); C_exa_dnam("trpbuf"); C_lae_dnam("trpbuf",(arith)0); - C_cal("setjmp"); + C_cal("__setjmp"); C_df_ilb(l); C_asp((arith)(BEMPTRSIZE+BEMPTRSIZE)); C_lfr((arith)BEMINTSIZE); diff --git a/lib/descr/fe b/lib/descr/fe index 2e69b0f3b..ac9b8b114 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -156,7 +156,7 @@ end name abc from .b to .k - program {EM}/lib.bin/em_bem + program {EM}/lib/ack/em_bem mapflag -h ABC_F={ABC_F?} -h mapflag -w ABC_F={ABC_F?} -w mapflag -L ABC_F={ABC_F?} -L From 66aebcdd91a2aa248b2b505595ca9c4ae4d2a130 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 14 May 2013 20:47:04 +0100 Subject: [PATCH 010/231] Pascal compiler now runs. --HG-- branch : dtrg-buildsystem rename : lang/basic/build.mk => lang/pc/build.mk rename : lang/cem/cemcom.ansi/build.mk => lang/pc/comp/build.mk rename : lang/basic/lib/build.mk => lang/pc/libpc/build.mk --- Makefile | 1 + lang/basic/src/build.mk | 4 +- lang/pc/build.mk | 3 + lang/pc/comp/LLlex.c | 4 +- lang/pc/comp/LLmessage.c | 1 + lang/pc/comp/body.c | 1 + lang/pc/comp/build.mk | 132 +++++++++++++++++++++++++++++++++++ lang/pc/comp/casestat.C | 2 +- lang/pc/comp/chk_expr.c | 2 + lang/pc/comp/code.c | 1 + lang/pc/comp/cstoper.c | 2 +- lang/pc/comp/debug.h | 2 - lang/pc/comp/declar.g | 4 +- lang/pc/comp/def.c | 1 + lang/pc/comp/desig.c | 1 + lang/pc/comp/enter.c | 2 +- lang/pc/comp/error.c | 2 +- lang/pc/comp/idf.c | 1 + lang/pc/comp/input.c | 1 + lang/pc/comp/input.h | 2 - lang/pc/comp/label.c | 1 + lang/pc/comp/lookup.c | 1 + lang/pc/comp/main.c | 2 +- lang/pc/comp/make.next | 1 + lang/pc/comp/misc.c | 1 + lang/pc/comp/node.c | 1 + lang/pc/comp/options.c | 4 +- lang/pc/comp/program.g | 2 +- lang/pc/comp/progs.c | 1 + lang/pc/comp/readwrite.c | 1 + lang/pc/comp/scope.c | 1 + lang/pc/comp/stab.c | 2 +- lang/pc/comp/statement.g | 2 +- lang/pc/comp/tokenname.c | 1 + lang/pc/comp/type.H | 3 - lang/pc/comp/type.c | 2 +- lang/pc/comp/typequiv.c | 1 + lang/pc/libpc/build.mk | 92 ++++++++++++++++++++++++ modules/src/em_code/build.mk | 3 + 39 files changed, 265 insertions(+), 26 deletions(-) create mode 100644 lang/pc/build.mk create mode 100644 lang/pc/comp/build.mk create mode 100644 lang/pc/libpc/build.mk diff --git a/Makefile b/Makefile index 52e792e64..5e21f2e73 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ include util/topgen/build.mk include lang/cem/build.mk include lang/basic/build.mk +include lang/pc/build.mk include mach/proto/as/build.mk include mach/proto/ncg/build.mk diff --git a/lang/basic/src/build.mk b/lang/basic/src/build.mk index e8a6f3cfb..00d429107 100644 --- a/lang/basic/src/build.mk +++ b/lang/basic/src/build.mk @@ -18,14 +18,14 @@ $(call cfile, $D/func.c) $(call llgen, $(OBJDIR)/$D, $D/basic.g) -$(eval g := $(OBJDIR)/$D/token.h) +$(eval g := $(OBJDIR)/$D/tokentab.h) +$(eval $q: $g) $(eval CLEANABLES += $g) $g: $D/maketokentab $(OBJDIR)/$D/Lpars.h @echo TOKENTAB $$@ @mkdir -p $$(dir $$@) $(hide) cd $(OBJDIR)/$D && $(abspath $$^) -$(eval $q: $(OBJDIR)/$D/token.h) $(eval $q: $(OBJDIR)/$D/Lpars.h) $(eval $q: $(INCDIR)/print.h) diff --git a/lang/pc/build.mk b/lang/pc/build.mk new file mode 100644 index 000000000..82b8f2d5f --- /dev/null +++ b/lang/pc/build.mk @@ -0,0 +1,3 @@ +include lang/pc/libpc/build.mk +include lang/pc/comp/build.mk + diff --git a/lang/pc/comp/LLlex.c b/lang/pc/comp/LLlex.c index 4c2b6b66d..6074870f7 100644 --- a/lang/pc/comp/LLlex.c +++ b/lang/pc/comp/LLlex.c @@ -3,10 +3,8 @@ #include #include #include +#include "parameters.h" #include "debug.h" -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" #include #include diff --git a/lang/pc/comp/LLmessage.c b/lang/pc/comp/LLmessage.c index 1f7fe0487..965887f41 100644 --- a/lang/pc/comp/LLmessage.c +++ b/lang/pc/comp/LLmessage.c @@ -10,6 +10,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "Lpars.h" #include "idf.h" diff --git a/lang/pc/comp/body.c b/lang/pc/comp/body.c index d628d85b2..f2f7a1a04 100644 --- a/lang/pc/comp/body.c +++ b/lang/pc/comp/body.c @@ -1,3 +1,4 @@ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/build.mk b/lang/pc/comp/build.mk new file mode 100644 index 000000000..2939c4524 --- /dev/null +++ b/lang/pc/comp/build.mk @@ -0,0 +1,132 @@ +D := lang/pc/comp + +define build-pc-allocd-header +$2: $1 $D/make.allocd + @echo ALLOCD $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.allocd < $$^ > $$@ + +$(eval CLEANABLES += $2) +$(eval $q: $2) +endef + +define build-pc-next +$(eval CLEANABLES += $(OBJDIR)/$D/next.c) +$(OBJDIR)/$D/next.c: $D/make.next $1 + @echo NEXT $$@ + @mkdir -p $$(dir $$@) + $(hide) $$^ > $$@ +$(call cfile, $(OBJDIR)/$D/next.c) + +$(foreach f, $1, $(call build-pc-allocd-header, \ + $f, $(OBJDIR)/$(basename $f).h)) +endef + +define build-pc-impl + +$(call reset) +$(eval cflags += -I$(OBJDIR)/$D -I$D -DSTATIC=static) + +$(call cfile, $D/LLlex.c) +$(call cfile, $D/LLmessage.c) +$(call cfile, $D/body.c) +$(call cfile, $D/chk_expr.c) +$(call cfile, $D/code.c) +$(call cfile, $D/cstoper.c) +$(call cfile, $D/def.c) +$(call cfile, $D/desig.c) +$(call cfile, $D/enter.c) +$(call cfile, $D/error.c) +$(call cfile, $D/idf.c) +$(call cfile, $D/input.c) +$(call cfile, $D/label.c) +$(call cfile, $D/lookup.c) +$(call cfile, $D/main.c) +$(call cfile, $D/misc.c) +$(call cfile, $D/node.c) +$(call cfile, $D/options.c) +$(call cfile, $D/progs.c) +$(call cfile, $D/readwrite.c) +$(call cfile, $D/scope.c) +$(call cfile, $D/stab.c) +$(call cfile, $D/tokenname.c) +$(call cfile, $D/type.c) +$(call cfile, $D/typequiv.c) + +$(call llgen, $(OBJDIR)/$D, \ + $(OBJDIR)/$D/tokenfile.g \ + $D/program.g \ + $D/declar.g \ + $D/expression.g \ + $D/statement.g) + +$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) +$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c + @echo TOKENFILE $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ + +$(call tabgen, $D/char.tab) + +$(eval $q: $(OBJDIR)/$D/parameters.h) + +$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) +$(OBJDIR)/$D/parameters.h: $D/Parameters + @echo PARAMETERS $$@ + @mkdir -p $$(dir $$@) + $(hide) echo '#ifndef PARAMETERS_H' > $$@ + $(hide) echo '#define PARAMETERS_H' >> $$@ + $(hide) grep -v '^!' < $$^ >> $$@ + $(hide) echo '#endif' >> $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) +$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c + @echo TOKCASE $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.tokcase < $D/tokenname.c > $$@ +$(call cfile, $(OBJDIR)/$D/symbol2str.c) + +$(call build-pc-next, \ + $D/def.H \ + $D/type.H \ + $D/node.H \ + $D/scope.H \ + $D/desig.H \ + $D/tmpvar.C \ + $D/casestat.C) + +$(call build-pc-allocd-header, $D/tmpvar.C, $(OBJDIR)/$D/tmpvar.c) +$(call cfile, $(OBJDIR)/$D/tmpvar.c) + +$(call build-pc-allocd-header, $D/casestat.C, $(OBJDIR)/$D/casestat.c) +$(call cfile, $(OBJDIR)/$D/casestat.c) + +$(eval $q: $(OBJDIR)/$D/Lpars.h) +$(eval $q: $(INCDIR)/idf_pkg.spec) +$(eval $q: $(INCDIR)/idf_pkg.body) +$(eval $q: $(INCDIR)/inp_pkg.spec) +$(eval $q: $(INCDIR)/inp_pkg.body) +$(eval $q: $(INCDIR)/alloc.h) +$(eval $q: $(INCDIR)/em_codeEK.h) +$(eval $q: $(INCDIR)/print.h) +$(eval $q: $(INCDIR)/system.h) + +$(call file, $(LIBEM_MES)) +$(call file, $(LIBEMK)) +$(call file, $(LIBEM_DATA)) +$(call file, $(LIBINPUT)) +$(call file, $(LIBASSERT)) +$(call file, $(LIBALLOC)) +$(call file, $(LIBFLT_ARITH)) +$(call file, $(LIBPRINT)) +$(call file, $(LIBSYSTEM)) +$(call file, $(LIBSTRING)) +$(call cprogram, $(BINDIR)/em_pc) +$(call installto, $(PLATDEP)/em_pc) + +$(call reset) +$(eval q := $D/em_pc.6) +$(call installto, $(INSDIR)/share/man/man6/em_pc.6) +endef + +$(eval $(build-pc-impl)) diff --git a/lang/pc/comp/casestat.C b/lang/pc/comp/casestat.C index 83223c09d..61eba13f7 100644 --- a/lang/pc/comp/casestat.C +++ b/lang/pc/comp/casestat.C @@ -1,4 +1,5 @@ /* C A S E S T A T E M E N T C O D E G E N E R A T I O N */ +#include "parameters.h" #include "debug.h" #include @@ -8,7 +9,6 @@ #include "LLlex.h" #include "Lpars.h" #include "chk_expr.h" -#include "density.h" #include "main.h" #include "node.h" #include "type.h" diff --git a/lang/pc/comp/chk_expr.c b/lang/pc/comp/chk_expr.c index 82e14c768..1c5cb58ea 100644 --- a/lang/pc/comp/chk_expr.c +++ b/lang/pc/comp/chk_expr.c @@ -3,8 +3,10 @@ /* Check expressions, and try to evaluate them as far as possible. */ +#include "parameters.h" #include "debug.h" +#include #include #include #include diff --git a/lang/pc/comp/code.c b/lang/pc/comp/code.c index 8f2efd8f0..17f0f7c32 100644 --- a/lang/pc/comp/code.c +++ b/lang/pc/comp/code.c @@ -2,6 +2,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include #include diff --git a/lang/pc/comp/cstoper.c b/lang/pc/comp/cstoper.c index fea4c7e14..be9dbc387 100644 --- a/lang/pc/comp/cstoper.c +++ b/lang/pc/comp/cstoper.c @@ -2,8 +2,8 @@ #include #include +#include "parameters.h" #include "debug.h" -#include "target_sizes.h" #include #include diff --git a/lang/pc/comp/debug.h b/lang/pc/comp/debug.h index 670c29d18..0da1c95c8 100644 --- a/lang/pc/comp/debug.h +++ b/lang/pc/comp/debug.h @@ -1,8 +1,6 @@ /* A debugging macro */ -#include "debugcst.h" - #ifdef DEBUG #define DO_DEBUG(x, y) ((x) && (y)) #else diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index 5f3a21ab8..4ee1fcf89 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -1,7 +1,8 @@ /* D E C L A R A T I O N S */ { -/* next line DEBUG */ +#include "parameters.h" +/* next line DEBUG */ #include "debug.h" #include @@ -19,7 +20,6 @@ #include "node.h" #include "scope.h" #include "type.h" -#include "dbsymtab.h" #define PC_BUFSIZ (sizeof(struct file) - (int)((struct file *)0)->bufadr) diff --git a/lang/pc/comp/def.c b/lang/pc/comp/def.c index bce524163..dfc33f459 100644 --- a/lang/pc/comp/def.c +++ b/lang/pc/comp/def.c @@ -1,5 +1,6 @@ /* D E F I N I T I O N M E C H A N I S M */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/desig.c b/lang/pc/comp/desig.c index a996aef6b..68c5512a9 100644 --- a/lang/pc/comp/desig.c +++ b/lang/pc/comp/desig.c @@ -7,6 +7,7 @@ or perform a store. */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/enter.c b/lang/pc/comp/enter.c index ec50ae9c2..80e99f4c7 100644 --- a/lang/pc/comp/enter.c +++ b/lang/pc/comp/enter.c @@ -5,6 +5,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "def.h" #include "idf.h" @@ -12,7 +13,6 @@ #include "node.h" #include "scope.h" #include "type.h" -#include "dbsymtab.h" extern int proclevel; extern int parlevel; diff --git a/lang/pc/comp/error.c b/lang/pc/comp/error.c index aa604fa6f..8a381c6fe 100644 --- a/lang/pc/comp/error.c +++ b/lang/pc/comp/error.c @@ -5,8 +5,8 @@ number of arguments! */ +#include "parameters.h" #include "debug.h" -#include "errout.h" #if __STDC__ #include diff --git a/lang/pc/comp/idf.c b/lang/pc/comp/idf.c index 6fc41b525..aa9781482 100644 --- a/lang/pc/comp/idf.c +++ b/lang/pc/comp/idf.c @@ -1,4 +1,5 @@ /* I N S T A N T I A T I O N O F I D F P A C K A G E */ +#include "parameters.h" #include "idf.h" #include diff --git a/lang/pc/comp/input.c b/lang/pc/comp/input.c index 34bb8b2c7..7497440c6 100644 --- a/lang/pc/comp/input.c +++ b/lang/pc/comp/input.c @@ -3,6 +3,7 @@ #include #include #include +#include "parameters.h" #include "f_info.h" struct f_info file_info; #include "input.h" diff --git a/lang/pc/comp/input.h b/lang/pc/comp/input.h index fcdeb21cb..4bc0b1eb8 100644 --- a/lang/pc/comp/input.h +++ b/lang/pc/comp/input.h @@ -1,7 +1,5 @@ /* I N S T A N T I A T I O N O F I N P U T M O D U L E */ -#include "inputtype.h" - #define INP_NPUSHBACK 3 #define INP_TYPE struct f_info #define INP_VAR file_info diff --git a/lang/pc/comp/label.c b/lang/pc/comp/label.c index 0f0fe8a7a..73745ba21 100644 --- a/lang/pc/comp/label.c +++ b/lang/pc/comp/label.c @@ -3,6 +3,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "def.h" #include "idf.h" diff --git a/lang/pc/comp/lookup.c b/lang/pc/comp/lookup.c index bcf4704a0..f051c99f4 100644 --- a/lang/pc/comp/lookup.c +++ b/lang/pc/comp/lookup.c @@ -5,6 +5,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "def.h" #include "idf.h" diff --git a/lang/pc/comp/main.c b/lang/pc/comp/main.c index fcab091a2..cef708fcd 100644 --- a/lang/pc/comp/main.c +++ b/lang/pc/comp/main.c @@ -2,6 +2,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include @@ -23,7 +24,6 @@ #include "tokenname.h" #include "type.h" #include "scope.h" -#include "dbsymtab.h" char options[128]; char *ProgName; diff --git a/lang/pc/comp/make.next b/lang/pc/comp/make.next index 727867594..fa45e585c 100755 --- a/lang/pc/comp/make.next +++ b/lang/pc/comp/make.next @@ -1,3 +1,4 @@ +echo '#include "parameters.h"' echo '#include "debug.h"' sed -n ' s:^.*[ ]ALLOCDEF[ ].*"\(.*\)".*$:struct \1 *h_\1 = 0;\ diff --git a/lang/pc/comp/misc.c b/lang/pc/comp/misc.c index 9ded3ef6a..cb9a40ef9 100644 --- a/lang/pc/comp/misc.c +++ b/lang/pc/comp/misc.c @@ -5,6 +5,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "f_info.h" #include "idf.h" diff --git a/lang/pc/comp/node.c b/lang/pc/comp/node.c index bdb1804cb..889e855f8 100644 --- a/lang/pc/comp/node.c +++ b/lang/pc/comp/node.c @@ -1,5 +1,6 @@ /* N O D E O F A N A B S T R A C T P A R S E T R E E */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/options.c b/lang/pc/comp/options.c index b80a98b72..4ecf51a68 100644 --- a/lang/pc/comp/options.c +++ b/lang/pc/comp/options.c @@ -3,13 +3,11 @@ #include #include +#include "parameters.h" #include "class.h" #include "const.h" -#include "idfsize.h" #include "main.h" #include "type.h" -#include "nocross.h" -#include "dbsymtab.h" #define MINIDFSIZE 9 diff --git a/lang/pc/comp/program.g b/lang/pc/comp/program.g index 45eacde05..dfd649e8e 100644 --- a/lang/pc/comp/program.g +++ b/lang/pc/comp/program.g @@ -1,6 +1,7 @@ /* The grammar of ISO-Pascal as given by the specification, BS6192: 1982. */ { +#include "parameters.h" #include #include #include @@ -14,7 +15,6 @@ #include "main.h" #include "node.h" #include "scope.h" -#include "dbsymtab.h" } %lexical LLlex; diff --git a/lang/pc/comp/progs.c b/lang/pc/comp/progs.c index fde2e2f12..173767526 100644 --- a/lang/pc/comp/progs.c +++ b/lang/pc/comp/progs.c @@ -1,3 +1,4 @@ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/readwrite.c b/lang/pc/comp/readwrite.c index e38c16163..7b62aaede 100644 --- a/lang/pc/comp/readwrite.c +++ b/lang/pc/comp/readwrite.c @@ -1,5 +1,6 @@ /* R E A D ( L N ) & W R I T E ( L N ) */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/scope.c b/lang/pc/comp/scope.c index f0f9e2cba..5c09ff925 100644 --- a/lang/pc/comp/scope.c +++ b/lang/pc/comp/scope.c @@ -1,5 +1,6 @@ /* S C O P E M E C H A N I S M */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index 8ae0514f1..d5e4ee3fb 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -9,7 +9,7 @@ /* $Id$ */ -#include "dbsymtab.h" +#include "parameters.h" #ifdef DBSYMTAB diff --git a/lang/pc/comp/statement.g b/lang/pc/comp/statement.g index 3c4f6f4bb..686e20682 100644 --- a/lang/pc/comp/statement.g +++ b/lang/pc/comp/statement.g @@ -1,5 +1,6 @@ /* S T A T E M E N T S */ { +#include "parameters.h" #include #include #include @@ -15,7 +16,6 @@ #include "node.h" #include "scope.h" #include "type.h" -#include "dbsymtab.h" int slevel = 0; /* nesting level of statements */ } diff --git a/lang/pc/comp/tokenname.c b/lang/pc/comp/tokenname.c index 3f1e3fa49..547287347 100644 --- a/lang/pc/comp/tokenname.c +++ b/lang/pc/comp/tokenname.c @@ -1,5 +1,6 @@ /* T O K E N D E F I N I T I O N S */ +#include "parameters.h" #include "Lpars.h" #include "idf.h" #include "tokenname.h" diff --git a/lang/pc/comp/type.H b/lang/pc/comp/type.H index 2ee4f04ba..92e91231b 100644 --- a/lang/pc/comp/type.H +++ b/lang/pc/comp/type.H @@ -1,7 +1,5 @@ /* T Y P E D E S C R I P T O R S T R U C T U R E */ -#include "dbsymtab.h" - struct paramlist { /* structure for parameterlist of a PROCEDURE */ struct paramlist *next; struct def *par_def; /* "df" of parameter */ @@ -131,7 +129,6 @@ extern struct type *void_type, *error_type; /* All from type.c */ -#include "nocross.h" #ifdef NOCROSS #include "target_sizes.h" #define word_align (AL_WORD) diff --git a/lang/pc/comp/type.c b/lang/pc/comp/type.c index 6dd131b7a..b5662c658 100644 --- a/lang/pc/comp/type.c +++ b/lang/pc/comp/type.c @@ -1,5 +1,6 @@ /* T Y P E D E F I N I T I O N M E C H A N I S M */ +#include "parameters.h" #include "debug.h" #include @@ -18,7 +19,6 @@ #include "type.h" #ifndef NOCROSS -#include "target_sizes.h" int word_align = AL_WORD, int_align = AL_INT, diff --git a/lang/pc/comp/typequiv.c b/lang/pc/comp/typequiv.c index bb00760ce..1b90f39a2 100644 --- a/lang/pc/comp/typequiv.c +++ b/lang/pc/comp/typequiv.c @@ -3,6 +3,7 @@ /* Routines for testing type equivalence & type compatibility. */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/libpc/build.mk b/lang/pc/libpc/build.mk new file mode 100644 index 000000000..bfb9d545f --- /dev/null +++ b/lang/pc/libpc/build.mk @@ -0,0 +1,92 @@ +define build-runtime-libpascal-impl + +$(call reset) +$(eval objdir := $(PLATFORM)) + +$(call ackfile, lang/pc/libpc/abi.c) +$(call ackfile, lang/pc/libpc/abl.c) +$(call ackfile, lang/pc/libpc/abr.c) +$(call ackfile, lang/pc/libpc/arg.c) +$(call ackfile, lang/pc/libpc/ass.c) +$(call ackfile, lang/pc/libpc/asz.c) +$(call ackfile, lang/pc/libpc/atn.c) +$(call ackfile, lang/pc/libpc/bcp.c) +$(call ackfile, lang/pc/libpc/bts.e) +$(call ackfile, lang/pc/libpc/buff.c) +$(call ackfile, lang/pc/libpc/catch.c) +$(call ackfile, lang/pc/libpc/clock.c) +$(call ackfile, lang/pc/libpc/cls.c) +$(call ackfile, lang/pc/libpc/cvt.c) +$(call ackfile, lang/pc/libpc/diag.c) +$(call ackfile, lang/pc/libpc/dis.c) +$(call ackfile, lang/pc/libpc/efl.c) +$(call ackfile, lang/pc/libpc/eln.c) +$(call ackfile, lang/pc/libpc/encaps.e) +$(call ackfile, lang/pc/libpc/exp.c) +$(call ackfile, lang/pc/libpc/fef.e) +$(call ackfile, lang/pc/libpc/fif.e) +$(call ackfile, lang/pc/libpc/get.c) +$(call ackfile, lang/pc/libpc/gto.e) +$(call ackfile, lang/pc/libpc/hlt.c) +$(call ackfile, lang/pc/libpc/hol0.e) +$(call ackfile, lang/pc/libpc/incpt.c) +$(call ackfile, lang/pc/libpc/ini.c) +$(call ackfile, lang/pc/libpc/log.c) +$(call ackfile, lang/pc/libpc/mdi.c) +$(call ackfile, lang/pc/libpc/mdl.c) +$(call ackfile, lang/pc/libpc/new.c) +$(call ackfile, lang/pc/libpc/nfa.c) +$(call ackfile, lang/pc/libpc/nobuff.c) +$(call ackfile, lang/pc/libpc/notext.c) +$(call ackfile, lang/pc/libpc/opn.c) +$(call ackfile, lang/pc/libpc/outcpt.c) +$(call ackfile, lang/pc/libpc/pac.c) +$(call ackfile, lang/pc/libpc/pclose.c) +$(call ackfile, lang/pc/libpc/pcreat.c) +$(call ackfile, lang/pc/libpc/pentry.c) +$(call ackfile, lang/pc/libpc/perrno.c) +$(call ackfile, lang/pc/libpc/pexit.c) +$(call ackfile, lang/pc/libpc/popen.c) +$(call ackfile, lang/pc/libpc/put.c) +$(call ackfile, lang/pc/libpc/rcka.c) +$(call ackfile, lang/pc/libpc/rdc.c) +$(call ackfile, lang/pc/libpc/rdi.c) +$(call ackfile, lang/pc/libpc/rdl.c) +$(call ackfile, lang/pc/libpc/rdr.c) +$(call ackfile, lang/pc/libpc/rf.c) +$(call ackfile, lang/pc/libpc/rln.c) +$(call ackfile, lang/pc/libpc/rnd.c) +$(call ackfile, lang/pc/libpc/sav.e) +$(call ackfile, lang/pc/libpc/sig.e) +$(call ackfile, lang/pc/libpc/sin.c) +$(call ackfile, lang/pc/libpc/sqt.c) +$(call ackfile, lang/pc/libpc/string.c) +$(call ackfile, lang/pc/libpc/trap.e) +$(call ackfile, lang/pc/libpc/trp.e) +$(call ackfile, lang/pc/libpc/unp.c) +$(call ackfile, lang/pc/libpc/uread.c) +$(call ackfile, lang/pc/libpc/uwrite.c) +$(call ackfile, lang/pc/libpc/wdw.c) +$(call ackfile, lang/pc/libpc/wf.c) +$(call ackfile, lang/pc/libpc/wrc.c) +$(call ackfile, lang/pc/libpc/wrf.c) +$(call ackfile, lang/pc/libpc/wri.c) +$(call ackfile, lang/pc/libpc/wrl.c) +$(call ackfile, lang/pc/libpc/wrr.c) +$(call ackfile, lang/pc/libpc/wrs.c) +$(call ackfile, lang/pc/libpc/wrz.c) + +$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libpascal.a) +$(call installto, $(PLATIND)/$(PLATFORM)/libpascal.a) + +$(call reset) +$(eval objdir := $(PLATFORM)) +$(call ackfile, lang/pc/libpc/head_pc.e) +$(call installto, $(PLATIND)/$(PLATFORM)/pascal.o) + +endef + +build-runtime-libpascal = $(eval $(build-runtime-libpascal-impl)) + +$(eval RUNTIMES += libpascal) + diff --git a/modules/src/em_code/build.mk b/modules/src/em_code/build.mk index dbef43003..0fca5191c 100644 --- a/modules/src/em_code/build.mk +++ b/modules/src/em_code/build.mk @@ -60,6 +60,9 @@ define build-em_code-impl $(call cfile, $D/em.c) $(eval $q: $(INCDIR)/em_codeEK.h) + $(eval $q: $(INCDIR)/em_path.h) + $(eval $q: $(INCDIR)/system.h) + $(eval $q: $(INCDIR)/local.h) $(call clibrary, $(LIBDIR)/libem$2.a) $(eval LIBEM$1 := $o) From f6c43b95efb472e631aa3b93accf837f01b92477 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 14 May 2013 22:24:38 +0100 Subject: [PATCH 011/231] Modula-2 now works. --HG-- branch : dtrg-buildsystem rename : lang/pc/build.mk => lang/m2/build.mk rename : lang/pc/libpc/build.mk => lang/m2/comp/build.mk rename : lang/pc/libpc/build.mk => lang/m2/libm2/build.mk --- Makefile | 1 + lang/m2/build.mk | 3 + lang/m2/comp/LLlex.c | 5 +- lang/m2/comp/LLmessage.c | 1 + lang/m2/comp/build.mk | 129 ++++++++++++++++++++++++++++++++++++++ lang/m2/comp/casestat.C | 3 +- lang/m2/comp/chk_expr.c | 3 +- lang/m2/comp/code.c | 2 +- lang/m2/comp/cstoper.c | 4 +- lang/m2/comp/debug.h | 2 - lang/m2/comp/declar.g | 3 +- lang/m2/comp/def.c | 1 + lang/m2/comp/defmodule.c | 1 + lang/m2/comp/desig.c | 2 +- lang/m2/comp/enter.c | 2 +- lang/m2/comp/error.c | 4 +- lang/m2/comp/expression.g | 1 + lang/m2/comp/idf.c | 1 + lang/m2/comp/input.c | 1 + lang/m2/comp/input.h | 2 - lang/m2/comp/lookup.c | 1 + lang/m2/comp/main.c | 3 +- lang/m2/comp/misc.c | 1 + lang/m2/comp/node.c | 1 + lang/m2/comp/options.c | 7 +-- lang/m2/comp/program.g | 3 +- lang/m2/comp/scope.C | 1 + lang/m2/comp/stab.c | 2 +- lang/m2/comp/statement.g | 1 + lang/m2/comp/tmpvar.C | 1 + lang/m2/comp/tokenname.c | 1 + lang/m2/comp/type.H | 4 -- lang/m2/comp/type.c | 4 +- lang/m2/comp/typequiv.c | 2 +- lang/m2/comp/walk.c | 5 +- lang/m2/comp/walk.h | 2 - lang/m2/libm2/build.mk | 103 ++++++++++++++++++++++++++++++ lib/descr/fe | 2 +- 38 files changed, 267 insertions(+), 48 deletions(-) create mode 100644 lang/m2/build.mk create mode 100644 lang/m2/comp/build.mk create mode 100644 lang/m2/libm2/build.mk diff --git a/Makefile b/Makefile index 5e21f2e73..4188b584e 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ include util/topgen/build.mk include lang/cem/build.mk include lang/basic/build.mk include lang/pc/build.mk +include lang/m2/build.mk include mach/proto/as/build.mk include mach/proto/ncg/build.mk diff --git a/lang/m2/build.mk b/lang/m2/build.mk new file mode 100644 index 000000000..9d3f87be8 --- /dev/null +++ b/lang/m2/build.mk @@ -0,0 +1,3 @@ +include lang/m2/libm2/build.mk +include lang/m2/comp/build.mk + diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index edd166490..c118e997a 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -13,10 +13,8 @@ #include #include +#include "parameters.h" #include "debug.h" -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" #include "alloc.h" #include "em_arith.h" @@ -32,7 +30,6 @@ #include "def.h" #include "type.h" #include "warning.h" -#include "errout.h" extern char *getwdir(); diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index f8bc0cc43..673083f0b 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -19,6 +19,7 @@ #include #include +#include "parameters.h" #include "idf.h" #include "LLlex.h" #include "Lpars.h" diff --git a/lang/m2/comp/build.mk b/lang/m2/comp/build.mk new file mode 100644 index 000000000..a3be0ee7a --- /dev/null +++ b/lang/m2/comp/build.mk @@ -0,0 +1,129 @@ +D := lang/m2/comp + +define build-m2-allocd-header +$2: $1 $D/make.allocd + @echo ALLOCD $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.allocd < $$^ > $$@ + +$(eval CLEANABLES += $2) +$(eval $q: $2) +endef + +define build-m2-next +$(eval CLEANABLES += $(OBJDIR)/$D/next.c) +$(OBJDIR)/$D/next.c: $D/make.next $1 + @echo NEXT $$@ + @mkdir -p $$(dir $$@) + $(hide) $$^ > $$@ +$(call cfile, $(OBJDIR)/$D/next.c) + +$(foreach f, $1, $(call build-m2-allocd-header, \ + $f, $(OBJDIR)/$(basename $f).h)) +endef + +define build-m2-impl + +$(call reset) +$(eval cflags += -I$(OBJDIR)/$D -I$D) + +$(call cfile, $D/LLlex.c) +$(call cfile, $D/LLmessage.c) +$(call cfile, $D/chk_expr.c) +$(call cfile, $D/code.c) +$(call cfile, $D/cstoper.c) +$(call cfile, $D/def.c) +$(call cfile, $D/defmodule.c) +$(call cfile, $D/desig.c) +$(call cfile, $D/enter.c) +$(call cfile, $D/error.c) +$(call cfile, $D/idf.c) +$(call cfile, $D/input.c) +$(call cfile, $D/lookup.c) +$(call cfile, $D/main.c) +$(call cfile, $D/misc.c) +$(call cfile, $D/node.c) +$(call cfile, $D/options.c) +$(call cfile, $D/stab.c) +$(call cfile, $D/tokenname.c) +$(call cfile, $D/type.c) +$(call cfile, $D/typequiv.c) +$(call cfile, $D/walk.c) + +$(call llgen, $(OBJDIR)/$D, \ + $(OBJDIR)/$D/tokenfile.g \ + $D/program.g \ + $D/declar.g \ + $D/expression.g \ + $D/statement.g) + +$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) +$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c + @echo TOKENFILE $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ + +$(call tabgen, $D/char.tab) + +$(eval $q: $(OBJDIR)/$D/parameters.h) + +$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) +$(OBJDIR)/$D/parameters.h: $D/BigPars + @echo PARAMETERS $$@ + @mkdir -p $$(dir $$@) + $(hide) echo '#ifndef PARAMETERS_H' > $$@ + $(hide) echo '#define PARAMETERS_H' >> $$@ + $(hide) grep -v '^!' < $$^ >> $$@ + $(hide) echo '#endif' >> $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) +$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c + @echo TOKCASE $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.tokcase < $D/tokenname.c > $$@ +$(call cfile, $(OBJDIR)/$D/symbol2str.c) + +$(call build-m2-next, \ + $D/def.H \ + $D/type.H \ + $D/real.H \ + $D/node.H) + +$(call build-m2-allocd-header, $D/tmpvar.C, $(OBJDIR)/$D/tmpvar.c) +$(call cfile, $(OBJDIR)/$D/tmpvar.c) + +$(call build-m2-allocd-header, $D/casestat.C, $(OBJDIR)/$D/casestat.c) +$(call cfile, $(OBJDIR)/$D/casestat.c) + +$(call build-m2-allocd-header, $D/scope.C, $(OBJDIR)/$D/scope.c) +$(call cfile, $(OBJDIR)/$D/scope.c) + +$(eval $q: $(OBJDIR)/$D/Lpars.h) +$(eval $q: $(INCDIR)/idf_pkg.spec) +$(eval $q: $(INCDIR)/idf_pkg.body) +$(eval $q: $(INCDIR)/inp_pkg.spec) +$(eval $q: $(INCDIR)/inp_pkg.body) +$(eval $q: $(INCDIR)/alloc.h) +$(eval $q: $(INCDIR)/em_codeEK.h) +$(eval $q: $(INCDIR)/print.h) +$(eval $q: $(INCDIR)/system.h) + +$(call file, $(LIBEM_MES)) +$(call file, $(LIBEMK)) +$(call file, $(LIBEM_DATA)) +$(call file, $(LIBINPUT)) +$(call file, $(LIBASSERT)) +$(call file, $(LIBALLOC)) +$(call file, $(LIBFLT_ARITH)) +$(call file, $(LIBPRINT)) +$(call file, $(LIBSYSTEM)) +$(call file, $(LIBSTRING)) +$(call cprogram, $(BINDIR)/em_m2) +$(call installto, $(PLATDEP)/em_m2) + +$(call reset) +$(eval q := $D/em_m2.6) +$(call installto, $(INSDIR)/share/man/man6/em_m2.6) +endef + +$(eval $(build-m2-impl)) diff --git a/lang/m2/comp/casestat.C b/lang/m2/comp/casestat.C index d5bedf503..d227e3117 100644 --- a/lang/m2/comp/casestat.C +++ b/lang/m2/comp/casestat.C @@ -16,6 +16,7 @@ cases themselves. */ +#include "parameters.h" #include "debug.h" #include @@ -33,8 +34,6 @@ #include "chk_expr.h" #include "def.h" -#include "density.h" - struct switch_hdr { label sh_break; /* label of statement after this one */ label sh_default; /* label of ELSE part, or 0 */ diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index d9a39c3a2..7dbe5abc6 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -14,6 +14,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include @@ -21,7 +22,6 @@ #include #include -#include "strict3rd.h" #include "Lpars.h" #include "idf.h" #include "type.h" @@ -34,7 +34,6 @@ #include "misc.h" #include "warning.h" #include "main.h" -#include "nostrict.h" extern char *symbol2str(); extern char *sprint(); diff --git a/lang/m2/comp/code.c b/lang/m2/comp/code.c index e0d05c584..f74231cb0 100644 --- a/lang/m2/comp/code.c +++ b/lang/m2/comp/code.c @@ -12,6 +12,7 @@ /* Code generation for expressions and coercions */ +#include "parameters.h" #include "debug.h" #include @@ -30,7 +31,6 @@ #include "Lpars.h" #include "standards.h" #include "walk.h" -#include "bigresult.h" extern int proclevel; extern char options[]; diff --git a/lang/m2/comp/cstoper.c b/lang/m2/comp/cstoper.c index fafb560f2..c55d4389f 100644 --- a/lang/m2/comp/cstoper.c +++ b/lang/m2/comp/cstoper.c @@ -9,9 +9,9 @@ /* $Id$ */ +#include +#include "parameters.h" #include "debug.h" -#include "target_sizes.h" -#include "uns_arith.h" #include #include diff --git a/lang/m2/comp/debug.h b/lang/m2/comp/debug.h index 865168335..1c2c34cb2 100644 --- a/lang/m2/comp/debug.h +++ b/lang/m2/comp/debug.h @@ -9,8 +9,6 @@ /* $Id$ */ -#include "debugcst.h" - #ifdef DEBUG #define DO_DEBUG(x, y) ((x) && (y)) #define STATIC diff --git a/lang/m2/comp/declar.g b/lang/m2/comp/declar.g index 9d7816e0c..49dac19c5 100644 --- a/lang/m2/comp/declar.g +++ b/lang/m2/comp/declar.g @@ -10,6 +10,7 @@ /* $Id$ */ { +#include "parameters.h" #include "debug.h" #include @@ -17,7 +18,6 @@ #include #include -#include "strict3rd.h" #include "idf.h" #include "LLlex.h" #include "def.h" @@ -28,7 +28,6 @@ #include "main.h" #include "chk_expr.h" #include "warning.h" -#include "nostrict.h" int proclevel = 0; /* nesting level of procedures */ int return_occurred; /* set if a return occurs in a block */ diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 711f2d7e4..586875f5e 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -11,6 +11,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index e327f309b..fc83d36fd 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/desig.c b/lang/m2/comp/desig.c index 5550b2720..f2ea83a81 100644 --- a/lang/m2/comp/desig.c +++ b/lang/m2/comp/desig.c @@ -16,6 +16,7 @@ or perform a store. */ +#include "parameters.h" #include "debug.h" #include @@ -32,7 +33,6 @@ #include "node.h" #include "warning.h" #include "walk.h" -#include "squeeze.h" extern int proclevel; extern arith NewPtr(); diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 002caa838..12f3e4e9d 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -13,6 +13,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include "alloc.h" @@ -21,7 +22,6 @@ #include "em_code.h" #include "assert.h" -#include "dbsymtab.h" #include "idf.h" #include "LLlex.h" #include "def.h" diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index 2c265f7b6..410f7d15f 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -14,7 +14,7 @@ number of arguments! */ -#include "errout.h" +#include "parameters.h" #include "debug.h" #if __STDC__ @@ -28,14 +28,12 @@ #include #include -#include "strict3rd.h" #include "input.h" #include "f_info.h" #include "LLlex.h" #include "main.h" #include "node.h" #include "warning.h" -#include "nostrict.h" /* error classes */ #define ERROR 1 diff --git a/lang/m2/comp/expression.g b/lang/m2/comp/expression.g index 431b3aa93..1fe8024d3 100644 --- a/lang/m2/comp/expression.g +++ b/lang/m2/comp/expression.g @@ -10,6 +10,7 @@ /* $Id$ */ { +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/idf.c b/lang/m2/comp/idf.c index 471c5f5e8..697b3e011 100644 --- a/lang/m2/comp/idf.c +++ b/lang/m2/comp/idf.c @@ -9,5 +9,6 @@ /* $Id$ */ +#include "parameters.h" #include "idf.h" #include diff --git a/lang/m2/comp/input.c b/lang/m2/comp/input.c index 4c516a44e..ef8ee2982 100644 --- a/lang/m2/comp/input.c +++ b/lang/m2/comp/input.c @@ -12,6 +12,7 @@ #include #include #include +#include "parameters.h" #include "f_info.h" struct f_info file_info; #include "input.h" diff --git a/lang/m2/comp/input.h b/lang/m2/comp/input.h index 3a557a9f3..23c1ac582 100644 --- a/lang/m2/comp/input.h +++ b/lang/m2/comp/input.h @@ -9,8 +9,6 @@ /* $Id$ */ -#include "inputtype.h" - #define INP_NPUSHBACK 2 #define INP_TYPE struct f_info #define INP_VAR file_info diff --git a/lang/m2/comp/lookup.c b/lang/m2/comp/lookup.c index 39708353e..6d58791d6 100644 --- a/lang/m2/comp/lookup.c +++ b/lang/m2/comp/lookup.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 4b181eb83..a21ecf8a5 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include @@ -19,8 +20,6 @@ #include #include -#include "strict3rd.h" -#include "dbsymtab.h" #include "input.h" #include "f_info.h" #include "idf.h" diff --git a/lang/m2/comp/misc.c b/lang/m2/comp/misc.c index d7a88ea5a..ada35fb02 100644 --- a/lang/m2/comp/misc.c +++ b/lang/m2/comp/misc.c @@ -17,6 +17,7 @@ #include "em_arith.h" #include "em_label.h" +#include "parameters.h" #include "f_info.h" #include "misc.h" #include "LLlex.h" diff --git a/lang/m2/comp/node.c b/lang/m2/comp/node.c index 2e2302504..910769e0d 100644 --- a/lang/m2/comp/node.c +++ b/lang/m2/comp/node.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/options.c b/lang/m2/comp/options.c index 568101cb3..b4b734fef 100644 --- a/lang/m2/comp/options.c +++ b/lang/m2/comp/options.c @@ -9,21 +9,16 @@ /* $Id$ */ -#include "idfsize.h" +#include "parameters.h" #include #include #include -#include "strict3rd.h" -#include "dbsymtab.h" #include "type.h" #include "main.h" #include "warning.h" -#include "nostrict.h" -#include "nocross.h" #include "class.h" -#include "squeeze.h" #define MINIDFSIZE 14 diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index 05fedef61..e8ea7a0f3 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -12,6 +12,7 @@ { #include #include +#include "parameters.h" #include "debug.h" #include @@ -20,8 +21,6 @@ #include #include -#include "dbsymtab.h" -#include "strict3rd.h" #include "main.h" #include "idf.h" #include "LLlex.h" diff --git a/lang/m2/comp/scope.C b/lang/m2/comp/scope.C index 796475c23..085662232 100644 --- a/lang/m2/comp/scope.C +++ b/lang/m2/comp/scope.C @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index 54bf67408..5aae2a1e5 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -9,7 +9,7 @@ /* $Id$ */ -#include "dbsymtab.h" +#include "parameters.h" #ifdef DBSYMTAB diff --git a/lang/m2/comp/statement.g b/lang/m2/comp/statement.g index 0a60226e1..ca5e72bb3 100644 --- a/lang/m2/comp/statement.g +++ b/lang/m2/comp/statement.g @@ -14,6 +14,7 @@ #include #include +#include "parameters.h" #include "idf.h" #include "LLlex.h" #include "scope.h" diff --git a/lang/m2/comp/tmpvar.C b/lang/m2/comp/tmpvar.C index da91114e1..03acdaba0 100644 --- a/lang/m2/comp/tmpvar.C +++ b/lang/m2/comp/tmpvar.C @@ -16,6 +16,7 @@ have local variabes. */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/tokenname.c b/lang/m2/comp/tokenname.c index be72a8418..cea9139b4 100644 --- a/lang/m2/comp/tokenname.c +++ b/lang/m2/comp/tokenname.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "tokenname.h" #include "Lpars.h" #include "idf.h" diff --git a/lang/m2/comp/type.H b/lang/m2/comp/type.H index b677fa516..588ef28c7 100644 --- a/lang/m2/comp/type.H +++ b/lang/m2/comp/type.H @@ -9,8 +9,6 @@ /* $Id$ */ -#include "dbsymtab.h" - struct paramlist { /* structure for parameterlist of a PROCEDURE */ struct paramlist *par_next; struct def *par_def; /* "df" of parameter */ @@ -142,9 +140,7 @@ extern t_type *std_type, *error_type; /* All from type.c */ -#include "nocross.h" #ifdef NOCROSS -#include "target_sizes.h" #define word_align (AL_WORD) #define short_align (AL_SHORT) #define int_align (AL_INT) diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index fa0283d73..247e5e280 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include @@ -17,7 +18,6 @@ #include #include -#include "nostrict.h" #include "LLlex.h" #include "def.h" #include "type.h" @@ -28,10 +28,8 @@ #include "main.h" #include "chk_expr.h" #include "warning.h" -#include "uns_arith.h" #ifndef NOCROSS -#include "target_sizes.h" int word_align = AL_WORD, short_align = AL_SHORT, diff --git a/lang/m2/comp/typequiv.c b/lang/m2/comp/typequiv.c index 2a3efbb7c..017e7a1d0 100644 --- a/lang/m2/comp/typequiv.c +++ b/lang/m2/comp/typequiv.c @@ -12,13 +12,13 @@ /* Routines for testing type equivalence, type compatibility, and assignment compatibility */ +#include "parameters.h" #include "debug.h" #include #include #include -#include "strict3rd.h" #include "type.h" #include "LLlex.h" #include "idf.h" diff --git a/lang/m2/comp/walk.c b/lang/m2/comp/walk.c index c79daed19..de9a63552 100644 --- a/lang/m2/comp/walk.c +++ b/lang/m2/comp/walk.c @@ -15,6 +15,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include @@ -26,8 +27,6 @@ #include #include -#include "strict3rd.h" -#include "dbsymtab.h" #include "LLlex.h" #include "def.h" #include "type.h" @@ -42,8 +41,6 @@ #include "walk.h" #include "misc.h" #include "warning.h" -#include "bigresult.h" -#include "use_insert.h" extern arith NewPtr(); extern arith NewInt(); diff --git a/lang/m2/comp/walk.h b/lang/m2/comp/walk.h index c81a57a59..cf43c3074 100644 --- a/lang/m2/comp/walk.h +++ b/lang/m2/comp/walk.h @@ -19,8 +19,6 @@ extern int (*WalkTable[])(); extern label text_label; extern label data_label; -#include "squeeze.h" - #ifndef SQUEEZE #define c_loc(x) C_loc((arith) (x)) #define c_lae_dlb(x) C_lae_dlb(x,(arith) 0) diff --git a/lang/m2/libm2/build.mk b/lang/m2/libm2/build.mk new file mode 100644 index 000000000..7dadeb347 --- /dev/null +++ b/lang/m2/libm2/build.mk @@ -0,0 +1,103 @@ +define build-runtime-libmodula2-impl + +$(call reset) +$(eval objdir := $(PLATFORM)) + +$(call ackfile, lang/m2/libm2/Termcap.mod) +$(call ackfile, lang/m2/libm2/CSP.mod) +$(call ackfile, lang/m2/libm2/PascalIO.mod) +$(call ackfile, lang/m2/libm2/RealInOut.mod) +$(call ackfile, lang/m2/libm2/InOut.mod) +$(call ackfile, lang/m2/libm2/Streams.mod) +$(call ackfile, lang/m2/libm2/MathLib0.mod) +$(call ackfile, lang/m2/libm2/Mathlib.mod) +$(call ackfile, lang/m2/libm2/Processes.mod) +$(call ackfile, lang/m2/libm2/RealConver.mod) +$(call ackfile, lang/m2/libm2/Storage.mod) +$(call ackfile, lang/m2/libm2/Conversion.mod) +$(call ackfile, lang/m2/libm2/Semaphores.mod) +$(call ackfile, lang/m2/libm2/random.mod) +$(call ackfile, lang/m2/libm2/Strings.mod) +$(call ackfile, lang/m2/libm2/ArraySort.mod) +$(call ackfile, lang/m2/libm2/catch.c) +$(call ackfile, lang/m2/libm2/Traps.mod) +$(call ackfile, lang/m2/libm2/XXTermcap.c) +$(call ackfile, lang/m2/libm2/dvi.c) +$(call ackfile, lang/m2/libm2/Arguments.c) +$(call ackfile, lang/m2/libm2/LtoUset.e) +$(call ackfile, lang/m2/libm2/StrAss.c) +$(call ackfile, lang/m2/libm2/cap.c) +$(call ackfile, lang/m2/libm2/absd.c) +$(call ackfile, lang/m2/libm2/absf.e) +$(call ackfile, lang/m2/libm2/absi.c) +$(call ackfile, lang/m2/libm2/absl.c) +$(call ackfile, lang/m2/libm2/halt.c) +$(call ackfile, lang/m2/libm2/SYSTEM.c) +$(call ackfile, lang/m2/libm2/par_misc.e) +$(call ackfile, lang/m2/libm2/init.c) +$(call ackfile, lang/m2/libm2/sigtrp.c) +$(call ackfile, lang/m2/libm2/store.c) +$(call ackfile, lang/m2/libm2/confarray.c) +$(call ackfile, lang/m2/libm2/load.c) +$(call ackfile, lang/m2/libm2/blockmove.c) +$(call ackfile, lang/m2/libm2/stackprio.c) +$(call ackfile, lang/m2/libm2/ucheck.c) +$(call ackfile, lang/m2/libm2/rcka.c) +$(call ackfile, lang/m2/libm2/rcku.c) +$(call ackfile, lang/m2/libm2/rcki.c) +$(call ackfile, lang/m2/libm2/rckul.c) +$(call ackfile, lang/m2/libm2/rckil.c) +$(call ackfile, lang/m2/libm2/EM.e) + +$(eval $q: $(EM_M2)) + +$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libmodula2.a) +$(call installto, $(PLATIND)/$(PLATFORM)/libmodula2.a) + +$(call reset) +$(eval objdir := $(PLATFORM)) +$(call ackfile, lang/m2/libm2/head_m2.e) +$(call installto, $(PLATIND)/$(PLATFORM)/modula2.o) + +endef + +build-runtime-libmodula2 = $(eval $(build-runtime-libmodula2-impl)) + +$(eval RUNTIMES += libmodula2) + +define build-headers-libmodula2-impl + +$(eval g := \ + Arguments.def \ + ArraySort.def \ + ASCII.def \ + Conversion.def \ + CSP.def \ + EM.def \ + Epilogue.def \ + InOut.def \ + MathLib0.def \ + Mathlib.def \ + PascalIO.def \ + Processes.def \ + random.def \ + RealConver.def \ + RealInOut.def \ + Semaphores.def \ + Storage.def \ + Streams.def \ + Strings.def \ + StripUnix.def \ + Termcap.def \ + Traps.def \ + Unix.def \ + XXTermcap.def) + +$(foreach f, $g, \ + $(call reset) \ + $(call file, lang/m2/libm2/$f) \ + $(call installto, $(PLATIND)/include/modula2/$f)) + +endef + +$(eval $(build-headers-libmodula2-impl)) diff --git a/lib/descr/fe b/lib/descr/fe index ac9b8b114..96a03ee8f 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -4,7 +4,7 @@ # Don't generate line updating code by default (i.e.: -L flag provided to cem). # To put it on again: use -NL var LFLAG=-L -var MODULA2_INCLUDES=-I{EM}/share/ack/include/m2 +var MODULA2_INCLUDES=-I{EM}/share/ack/include/modula2 var OCCAM_INCLUDES=-I{EM}/share/ack/include/occam var C_INCLUDES=-I{EM}/share/ack/include/ansi From e9233b471260d849ac8ef2fb57754bb7a4b7a9ea Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 15 May 2013 21:14:06 +0100 Subject: [PATCH 012/231] Build ego. --HG-- branch : dtrg-buildsystem rename : util/arch/build.mk => util/ego/build.mk --- Makefile | 1 + config.pm | 2 +- lib/descr/fe | 6 +- plat/build.mk | 4 + util/ego/build.mk | 205 +++++++++++++++++++++++++++++++++++++++ util/ego/cf/cf_loop.c | 1 + util/ego/cs/cs_alloc.c | 1 + util/ego/il/il1_aux.c | 1 + util/ego/il/il2_aux.c | 1 + util/ego/il/il3_change.c | 1 + util/ego/il/il_aux.c | 1 + util/ego/ra/ra_interv.c | 1 + util/ego/ra/ra_pack.c | 1 + util/ego/share/locals.c | 1 + util/ego/share/lset.c | 1 + util/ego/share/put.c | 1 + util/ego/sr/sr_reduce.c | 1 + 17 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 util/ego/build.mk diff --git a/Makefile b/Makefile index 4188b584e..2d78f03d9 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,7 @@ include util/arch/build.mk include util/misc/build.mk include util/led/build.mk include util/topgen/build.mk +include util/ego/build.mk include lang/cem/build.mk include lang/basic/build.mk diff --git a/config.pm b/config.pm index 1d59b7f0c..79dc7c55a 100644 --- a/config.pm +++ b/config.pm @@ -13,7 +13,7 @@ ACK_TEMP_DIR = "/tmp" -- Where is the ACK going to be installed, eventually? -PREFIX = "/usr/local" +PREFIX = "/tmp/ack-temp/staging" -- ======================================================================= -- -- BROKEN ACK CONFIGURATION -- diff --git a/lib/descr/fe b/lib/descr/fe index 96a03ee8f..a8d610362 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -172,7 +172,7 @@ var A68INIT={EM}/lib/ack/em_a68s_init name a68s from .8.a68 to .k - program {EM}/lib.bin/em_a68s{w}{p} + program {EM}/lib/ack/em_a68s{w}{p} mapflag -PA* A68INIT=* args < > {SOURCE}.lst {A68INIT}{w}{p} /dev/null prep cond @@ -226,8 +226,8 @@ name ego mapflag -a EGO_F={EGO_F?} -a mapflag -O* EGO_F={EGO_F?} -O* args \ - {EGO_F?} -P {EM}/lib.bin/ego \ - -M{EM}/lib.bin/ego/{ARCH}descr < + {EGO_F?} -P {EM}/lib/ack/ego \ + -M{EM}/share/ack/ego/{ARCH}.descr < optimizer 2 stdout combiner diff --git a/plat/build.mk b/plat/build.mk index 89acb8c2e..aff84c04c 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -57,6 +57,10 @@ define build-platform-impl # Language runtimes $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime))) + + # Install the ego descr file for this architecture + + $(call build-ego-descr) endef build-platform = $(eval $(call build-platform-impl, $1)) diff --git a/util/ego/build.mk b/util/ego/build.mk new file mode 100644 index 000000000..ee1e7f865 --- /dev/null +++ b/util/ego/build.mk @@ -0,0 +1,205 @@ +D := util/ego + +define build-ego-backend-impl + +$(call reset) +$(eval cflags += -DVERBOSE -DNOTCOMPACT) +$(eval cflags += -I$D/share -I$(OBJDIR)/$D) +$(foreach f, $2, $(call cfile, $f)) +$(call file, $(LIBDIR)/libegocore.a) +$(call file, $(LIBEM_DATA)) +$(call cprogram, $(BINDIR)/ego/$(strip $1)) +$(call installto, $(PLATDEP)/ego/$(strip $1)) +$(eval EGO_MODULES += $q) + +endef + +define build-ego-impl + +# Generated files that egocore needs. + +$(call reset) +$(call cfile, $D/share/makecldef.c) +$(call cprogram, $(OBJDIR)/$D/makecldef) + +$(eval g := $(OBJDIR)/$D/classdefs.h) +$(eval CLEANABLES += $g) +$g: $(OBJDIR)/$D/makecldef $(INCDIR)/em_mnem.h $D/share/cldefs.src + @echo MAKECLDEF $g + @mkdir -p $(dir $g) + $(hide) $$^ > $g + +$(eval g := $(OBJDIR)/$D/pop_push.h) +$(eval CLEANABLES += $g) +$g: $D/share/pop_push.awk h/em_table + @echo POP_PUSH $g + @mkdir -p $(dir $g) + $(hide) awk -f $D/share/pop_push.awk < h/em_table > $g + +# Build the egocore library. + +$(call reset) +$(eval cflags += -I$D/share -I$(OBJDIR)/$D) +$(eval cflags += -DVERBOSE -DNOTCOMPACT) + +$(call cfile, $D/share/debug.c) +$(call cfile, $D/share/global.c) +$(call cfile, $D/share/files.c) +$(call cfile, $D/share/go.c) +$(call cfile, $D/share/map.c) +$(call cfile, $D/share/aux.c) +$(call cfile, $D/share/get.c) +$(call cfile, $D/share/put.c) +$(call cfile, $D/share/alloc.c) +$(call cfile, $D/share/lset.c) +$(call cfile, $D/share/cset.c) +$(call cfile, $D/share/parser.c) +$(call cfile, $D/share/stack_chg.c) +$(call cfile, $D/share/locals.c) +$(call cfile, $D/share/init_glob.c) +$(eval $q: $(OBJDIR)/$D/classdefs.h $(OBJDIR)/$D/pop_push.h) + +$(call clibrary, $(LIBDIR)/libegocore.a) +$(eval CLEANABLES += $q) + +# Now build each of the back ends. + +$(call build-ego-backend-impl, bo, \ + $D/bo/bo.c) + +$(call build-ego-backend-impl, ca, \ + $D/ca/ca.c \ + $D/ca/ca_put.c) + +$(call build-ego-backend-impl, cf, \ + $D/cf/cf.c \ + $D/cf/cf_idom.c \ + $D/cf/cf_loop.c \ + $D/cf/cf_succ.c) + +$(call build-ego-backend-impl, cj, \ + $D/cj/cj.c) + +$(call build-ego-backend-impl, cs, \ + $D/cs/cs.c \ + $D/cs/cs_alloc.c \ + $D/cs/cs_aux.c \ + $D/cs/cs_avail.c \ + $D/cs/cs_debug.c \ + $D/cs/cs_elim.c \ + $D/cs/cs_entity.c \ + $D/cs/cs_getent.c \ + $D/cs/cs_kill.c \ + $D/cs/cs_partit.c \ + $D/cs/cs_profit.c \ + $D/cs/cs_stack.c \ + $D/cs/cs_vnm.c) + +$(call build-ego-backend-impl, ic, \ + $D/ic/ic.c \ + $D/ic/ic_aux.c \ + $D/ic/ic_io.c \ + $D/ic/ic_lib.c \ + $D/ic/ic_lookup.c) + +$(call build-ego-backend-impl, il, \ + $D/il/il.c \ + $D/il/il1_anal.c \ + $D/il/il1_aux.c \ + $D/il/il1_cal.c \ + $D/il/il1_formal.c \ + $D/il/il2_aux.c \ + $D/il/il3_aux.c \ + $D/il/il3_change.c \ + $D/il/il3_subst.c \ + $D/il/il_aux.c) + +$(call build-ego-backend-impl, lv, \ + $D/lv/lv.c) + +$(call build-ego-backend-impl, ra, \ + $D/ra/ra.c \ + $D/ra/ra_allocl.c \ + $D/ra/ra_aux.c \ + $D/ra/ra_interv.c \ + $D/ra/ra_lifet.c \ + $D/ra/ra_pack.c \ + $D/ra/ra_profits.c \ + $D/ra/ra_xform.c \ + $D/ra/ra_items.c) + +$(eval g := $(OBJDIR)/$D/itemtab.h) +$(eval CLEANABLES += $g) +$D/ra/ra_items.c: $g +$g: $(OBJDIR)/$D/makeitems $(INCDIR)/em_mnem.h $D/ra/itemtab.src + @echo MAKEITEMS $g + @mkdir -p $(dir $g) + $(hide) $$^ > $g + +$(call reset) +$(call cfile, $D/ra/makeitems.c) +$(call cprogram, $(OBJDIR)/$D/makeitems) + +$(call build-ego-backend-impl, sp, \ + $D/sp/sp.c) + +$(call build-ego-backend-impl, sr, \ + $D/sr/sr.c \ + $D/sr/sr_aux.c \ + $D/sr/sr_cand.c \ + $D/sr/sr_expr.c \ + $D/sr/sr_iv.c \ + $D/sr/sr_reduce.c \ + $D/sr/sr_xform.c) + +$(call build-ego-backend-impl, ud, \ + $D/ud/ud.c \ + $D/ud/ud_aux.c \ + $D/ud/ud_const.c \ + $D/ud/ud_copy.c \ + $D/ud/ud_defs.c) + +# ...and now the front end, which depends on all the backends. + +$(call reset) +$(call cfile, $D/em_ego/em_ego.c) +$(eval $q: $(INCDIR)/print.h $(INCDIR)/system.h) +$(eval $q: $(INCDIR)/em_path.h) + +$(call file, $(LIBPRINT)) +$(call file, $(LIBSTRING)) +$(call file, $(LIBSYSTEM)) + +$(call cprogram, $(BINDIR)/em_ego) +$(call installto, $(PLATDEP)/em_ego) +$(eval EM_EGO := $q) +$(eval $q: $(EGO_MODULES)) +$(eval ACK_CORE_TOOLS += $q) + +endef + +$(eval $(build-ego-impl)) + +# Install the ego descr file for the current architecture, if one exists. +# This is a bit annoying because it's called by each platform, so we need +# to protect against the architecture being seen more than once. And some +# architectures don't get descr files. + +define build-ego-descr-impl + +$(eval EGO_DESCR_$(ARCH) := 1) + +$(eval g := $(PLATIND)/ego/$(ARCH).descr) +$(eval CLEANABLES += $g) +$(eval $(EM_EGO): $g) +$g: util/ego/descr/descr.sed util/ego/descr/$(ARCH).descr $(CPPANSI) \ + $(INCDIR)/em_mnem.h + @echo EGODESCR $g + @mkdir -p $(dir $g) + $(hide) $(CPPANSI) -P -I$(INCDIR) util/ego/descr/$(ARCH).descr | sed -f util/ego/descr/descr.sed > $g + +endef + +build-ego-descr = $(if $(EGO_DESCR_$(ARCH)),, \ + $(if $(wildcard util/ego/descr/$(ARCH).descr), \ + $(eval $(call build-ego-descr-impl, $1)))) \ No newline at end of file diff --git a/util/ego/cf/cf_loop.c b/util/ego/cf/cf_loop.c index 6f27288ce..c14bdba3f 100644 --- a/util/ego/cf/cf_loop.c +++ b/util/ego/cf/cf_loop.c @@ -9,6 +9,7 @@ */ +#include #include "../share/types.h" #include "../share/debug.h" #include "../share/lset.h" diff --git a/util/ego/cs/cs_alloc.c b/util/ego/cs/cs_alloc.c index f1cfe209d..6a1128286 100644 --- a/util/ego/cs/cs_alloc.c +++ b/util/ego/cs/cs_alloc.c @@ -3,6 +3,7 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ +#include #include "../share/types.h" #include "../share/alloc.h" #include "cs.h" diff --git a/util/ego/il/il1_aux.c b/util/ego/il/il1_aux.c index 8ef4923e2..76e8ae2f3 100644 --- a/util/ego/il/il1_aux.c +++ b/util/ego/il/il1_aux.c @@ -8,6 +8,7 @@ * I L 1 _ A U X . C */ +#include #include #include "../share/types.h" #include "il.h" diff --git a/util/ego/il/il2_aux.c b/util/ego/il/il2_aux.c index 54d950156..01a13f0fc 100644 --- a/util/ego/il/il2_aux.c +++ b/util/ego/il/il2_aux.c @@ -8,6 +8,7 @@ * I L 2 _ A U X . C */ +#include #include #include #include diff --git a/util/ego/il/il3_change.c b/util/ego/il/il3_change.c index 8f8fd393c..6347167c3 100644 --- a/util/ego/il/il3_change.c +++ b/util/ego/il/il3_change.c @@ -9,6 +9,7 @@ */ +#include #include #include #include diff --git a/util/ego/il/il_aux.c b/util/ego/il/il_aux.c index beff6f4dd..2bb5e4564 100644 --- a/util/ego/il/il_aux.c +++ b/util/ego/il/il_aux.c @@ -9,6 +9,7 @@ * I L _ A U X . C */ +#include #include #include #include diff --git a/util/ego/ra/ra_interv.c b/util/ego/ra/ra_interv.c index a6c6b7c1d..b333124ad 100644 --- a/util/ego/ra/ra_interv.c +++ b/util/ego/ra/ra_interv.c @@ -9,6 +9,7 @@ */ +#include #include #include "../share/types.h" #include "../share/debug.h" diff --git a/util/ego/ra/ra_pack.c b/util/ego/ra/ra_pack.c index 3687b44de..373191b90 100644 --- a/util/ego/ra/ra_pack.c +++ b/util/ego/ra/ra_pack.c @@ -8,6 +8,7 @@ * R A _ P A C K . C */ +#include #include #include "../share/types.h" #include "../share/debug.h" diff --git a/util/ego/share/locals.c b/util/ego/share/locals.c index f8d4ba268..b8b92f253 100644 --- a/util/ego/share/locals.c +++ b/util/ego/share/locals.c @@ -7,6 +7,7 @@ * L O C A L S . C */ +#include #include #include #include diff --git a/util/ego/share/lset.c b/util/ego/share/lset.c index d95d256b7..682494a77 100644 --- a/util/ego/share/lset.c +++ b/util/ego/share/lset.c @@ -9,6 +9,7 @@ */ +#include #include "types.h" #include "lset.h" #include "alloc.h" diff --git a/util/ego/share/put.c b/util/ego/share/put.c index 473443a99..bbb4aedd6 100644 --- a/util/ego/share/put.c +++ b/util/ego/share/put.c @@ -5,6 +5,7 @@ */ /* P U T . C */ +#include #include #include #include diff --git a/util/ego/sr/sr_reduce.c b/util/ego/sr/sr_reduce.c index c656dcecb..5b8e78295 100644 --- a/util/ego/sr/sr_reduce.c +++ b/util/ego/sr/sr_reduce.c @@ -10,6 +10,7 @@ */ +#include #include #include #include From aaa3f14a79539f2075d576155cfab90e1353e57c Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 15 May 2013 22:09:28 +0100 Subject: [PATCH 013/231] Fix build error in opt which was causing all code, everywhere, to be broken. Remember to build opt2 too. --HG-- branch : dtrg-buildsystem --- util/opt/build.mk | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/util/opt/build.mk b/util/opt/build.mk index 9928d40cf..39eafe355 100644 --- a/util/opt/build.mk +++ b/util/opt/build.mk @@ -12,14 +12,16 @@ $(call dependson, $(OBJDIR)/$D/y.tab.h) $(call file, $(LIBEM_DATA)) $(call file, -lfl) -$(call cprogram, $D/mktab) +$(call cprogram, $(OBJDIR)/$D/mktab) endef define build-opt-impl $(call reset) -$(eval cflags += -I$D) +$(eval objdir := $1) + +$(eval cflags += -I$D $2) $(call cfile, $D/main.c) $(call cfile, $D/getline.c) $(call cfile, $D/lookup.c) @@ -35,25 +37,21 @@ $(call cfile, $D/flow.c) $(call cfile, $D/tes.c) $(call cfile, $D/reg.c) -$(eval CLEANABLES += $(OBJDIR)/$D/pop_push.c) -$(OBJDIR)/$D/pop_push.c: $D/pop_push.awk h/em_table +$(eval g := $(OBJDIR)/$D/$(objdir)/pop_push.c) +$(eval CLEANABLES += $g) +$g: $D/pop_push.awk h/em_table @echo POP_PUSH $$@ @mkdir -p $$(dir $$@) $(hide) awk -f $D/pop_push.awk < h/em_table > $$@ -$(call cfile, $(OBJDIR)/$D/pop_push.c) +$(call cfile, $g) -$(eval CLEANABLES += $(OBJDIR)/$D/pattern.c) -$(OBJDIR)/$D/pattern.c: $D/mktab $(OBJDIR)/$D/patterns +$(eval g := $(OBJDIR)/$D/$(objdir)/pattern.c) +$(eval CLEANABLES += $g) +$g: $(OBJDIR)/$D/mktab $D/patterns $(BINDIR)/cpp.ansi @echo PATTERNS $$@ @mkdir -p $$(dir $$@) - $(hide) $D/mktab < $(OBJDIR)/$D/patterns > $$@ -$(call cfile, $(OBJDIR)/$D/pattern.c) - -$(eval CLEANABLES += $(OBJDIR)/$D/patterns) -$(OBJDIR)/$D/patterns: $(CPPANSI) $D/patterns - @echo PREPROCESS $$@ - @mkdir -p $$(dir $$@) - $(hide) $(CPPANSI) < $D/patterns > $$@ + $(hide) $(BINDIR)/cpp.ansi < $D/patterns | $(OBJDIR)/$D/mktab > $$@ +$(call cfile, $g) $(call file, $(LIBEM_DATA)) $(call file, $(LIBASSERT)) @@ -64,11 +62,14 @@ $(call file, $(LIBSTRING)) $(eval $q: $(INCDIR)/em_spec.h) -$(call cprogram, $(BINDIR)/em_opt) -$(call installto, $(PLATDEP)/em_opt) -$(eval EM_OPT := $o) +$(call cprogram, $(BINDIR)/$(strip $1)) +$(call installto, $(PLATDEP)/$(strip $1)) $(eval ACK_CORE_TOOLS += $o) +endef + +define build-opt-manpage-impl + $(call reset) $(eval q := $D/em_opt.6) $(call installto, $(INSDIR)/share/man/man6/em_opt.6) @@ -76,4 +77,6 @@ $(call installto, $(INSDIR)/share/man/man6/em_opt.6) endef $(eval $(build-opt-mktab-impl)) -$(eval $(build-opt-impl)) +$(eval $(call build-opt-impl, em_opt,)) +$(eval $(call build-opt-impl, em_opt2, -DGLOBAL_OPT)) +$(eval $(build-opt-manpage-impl)) \ No newline at end of file From 8fbce949f594b5ea3ae7bfce21b4c526a254e92c Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 15 May 2013 23:12:05 +0100 Subject: [PATCH 014/231] Now describe the make-based build system in the README. --HG-- branch : dtrg-buildsystem --- Makefile | 50 +- README | 72 +- mach/proto/ncg/build.mk | 2 +- pm | 5669 --------------------------------------- 4 files changed, 79 insertions(+), 5714 deletions(-) delete mode 100755 pm diff --git a/Makefile b/Makefile index 2d78f03d9..c50e79b10 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,36 @@ -BUILDDIR = /tmp/obj +# ======================================================================= # +# ACK CONFIGURATION # +# (Edit this before building) # +# ======================================================================= # + +# What platform to build for by default? + +DEFAULT_PLATFORM = pc86 + +# Where should the ACK put its temporary files? + +ACK_TEMP_DIR = /tmp + +# Where is the ACK going to be installed, eventually? + +PREFIX = /usr/local + +# Where do you want to put the object files used when building? + +BUILDDIR = $(ACK_TEMP_DIR)/ack-build + +# What build flags do you want to use? + +CFLAGS = -g +LDFLAGS = -s + +# ======================================================================= # +# END OF CONFIGURATION # +# ======================================================================= # +# +# You shouldn't need to change anything below this point unless you are +# actually developing ACK. + OBJDIR = $(BUILDDIR)/obj BINDIR = $(BUILDDIR)/bin LIBDIR = $(BUILDDIR)/lib @@ -15,13 +47,12 @@ CP = cp hide = @ -CFLAGS = \ - -g \ +CFLAGS += \ -I$(INCDIR) \ -Imodules/h \ -Ih -LDFLAGS = +LDFLAGS += all: installables @@ -81,6 +112,11 @@ include plat/linux68k/build.mk .PHONY: installables installables: $(INSTALLABLES) +.PHONY: install +install: installables + @echo INSTALLING into $(PREFIX) + $(hide) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) + .PHONY: clean clean: @echo CLEAN @@ -90,15 +126,15 @@ $(INCDIR)/local.h: @echo LOCAL @mkdir -p $(dir $@) $(hide) echo '#define VERSION 3' > $@ - $(hide) echo '#define ACKM "pc86"' >> $@ + $(hide) echo '#define ACKM "$(DEFAULT_PLATFORM)"' >> $@ $(hide) echo '#define BIGMACHINE 1' >> $@ $(hide) echo '#define SYS_5' >> $@ $(INCDIR)/em_path.h: @echo EM_PATH @mkdir -p $(dir $@) - $(hide) echo '#define TMP_DIR "/tmp"' > $@ - $(hide) echo '#define EM_DIR "/tmp/obj/staging"' >> $@ + $(hide) echo '#define TMP_DIR "$(ACK_TEMP_DIR)"' > $@ + $(hide) echo '#define EM_DIR "$(PREFIX)"' >> $@ $(hide) echo '#define ACK_PATH "share/ack/descr"' >> $@ -include $(DEPENDS) diff --git a/README b/README index 956623d1e..d6a56b050 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ - THE AMSTERDAM COMPILER KIT V6.0pre4 + THE AMSTERDAM COMPILER KIT V6.0pre5 =================================== © 1987-2005 Vrije Universiteit, Amsterdam - 2010-08-08 + 2013-05-15 INTRODUCTION @@ -24,59 +24,58 @@ SUPPORT Languages: -ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler. +ANSI C, Pascal, Modula 2, Basic. K&R is supported via the ANSI C compiler. Platforms: pc86 produces bootable floppy disk images for 8086 PCs linux386 produces ELF executables for PC Linux systems +linux68k produces ELF executables for m68020 Linux systems cpm produces i80 CP/M .COM files INSTALLATION ============ -The version 6.0 build mechanism has been completely rewritten and is based -around the Prime Mover build tool (see http://primemover.sf.net for more -information). Installation ought to be fairly straightforward. +The version 5.0 build mechanism has been completely rewritten. Installation +ought to be fairly straightforward. Requirements: -- an ANSI C compiler. Currently, I'm afraid, it's hard-coded to use gcc. - To change, try changing the variable definitions in first/c.pm. This also - needs to be available as 'cc' from the shell. - -- about 20MB free in /tmp (or some other temporary directory). +- an ANSI C compiler. This defaults to gcc. You can change this by setting + the CC make variable. + +- about 40MB free in /tmp (or some other temporary directory). - about 6MB in the target directory. Instructions: -- edit config.pm. There's a small section at the top containing some editable - variables. Probably the only one you may want to edit is PREFIX, which - changes where the ACK installs to. - +- edit the Makefile. There's a small section at the top where you can change + the configuration. Probably the only one you may want to edit is PREFIX, + which changes where the ACK installs to. + - Run: - ./pm configure - - ...from the command line. This will write out a configuration file. - + make + + ...from the command line. This will do the build. + + The make system is fully parallelisable. If you have a multicore system, + you probably want to do: + + make -j8 + + ...instead (substituting the right number of cores, of course). You can + also shave a few seconds of the build time by using the -r flag. + - Run: - ./pm - - ...from the command line. This will actually do the build. This takes - about two minutes on my 1.6GHz Athlon Linux machine and about 30 on my - 166MHz Pentium OpenBSD machine. - -- Run: + sudo make install + + ...from the command line. This will install the ACK in your PREFIX + directory (by default, /usr/local). - ./pm install - - ...from the command line (possibly with sudo). This will install the built - ACK into whatever directory you nominated in PREFIX. - The ACK should now be ready to use. @@ -94,8 +93,9 @@ Some useful options include: -o specifies the output file -c produce a .o file -c.s produce a .s assembly file - -O enable optimisation + -O enable optimisation (optimisation levels go up to 6) -ansi compile ANSI C (when using the C compiler) + -v be more verbose (repeatable) build file ack figures out which language to use from the file extension: @@ -107,6 +107,7 @@ ack figures out which language to use from the file extension: .p Pascal .o object files .s assembly files + .e ACK intermediate code assembly files For further information, see the man page (which actually does get installed, but is rather out of date). @@ -117,6 +118,7 @@ A sample command line is: ack -mlinux386 -O examples/paranoia.c + GOTCHAS ======= @@ -163,8 +165,4 @@ Please enjoy. David Given (dtrg on Sourceforge) dg@cowlark.com -2010-08-08 - -# $Source$ -# $State$ -# $Revision$ +2013-05-13 diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index 4494a8905..1bbda2b49 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -23,7 +23,7 @@ $(call cfile, mach/proto/ncg/subr.c) $(call cfile, mach/proto/ncg/var.c) $(eval $q: $(OBJDIR)/$D/tables.h) -$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/table.c) +$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.c) $(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.h: $(NCGG) $(CPPANSI) mach/$(ARCH)/ncg/table @echo NCGG $$@ diff --git a/pm b/pm deleted file mode 100755 index 23560e2c6..000000000 --- a/pm +++ /dev/null @@ -1,5669 +0,0 @@ -#!/bin/sh -# Prime Mover -# -# (C) 2006 David Given. -# Prime Mover is licensed under the MIT open source license. To get the full -# license text, run this file with the '--license' option. -# -# $Id: shell 52 2006-10-03 22:12:33Z dtrg $ - -if [ -x "$(which arch 2>/dev/null)" ]; then - ARCH="$(arch)" -elif [ -x "$(which machine 2>/dev/null)" ]; then - ARCH="$(machine)" -elif [ -x "$(which uname 2>/dev/null)" ]; then - ARCH="$(uname -m)" -else - echo "pm: unable to determine target type, proceeding anyway" - ARCH=unknown -fi - -THISFILE="$0" -PMEXEC="./.pm-exec-$ARCH" -set -e - -GZFILE=/tmp/pm-$$.gz -CFILE=/tmp/pm-$$.c -trap "rm -f $GZFILE $CFILE" EXIT - -extract_section() { - sed -e "1,/^XXXXSTART$1/d" "$THISFILE" | ( - read size - dd bs=1 count=$size 2> /dev/null - ) > $GZFILE - cat $GZFILE | cat -} - -# If the bootstrap's built, run it. - -if [ "$PMEXEC" -nt $0 ]; then - extract_section script | "$PMEXEC" /dev/stdin "$@" - exit $? -fi - -# Otherwise, compile it and restart. - -echo "pm: bootstrapping..." - -if [ -x "$(which gcc 2>/dev/null)" ]; then - CC="gcc -O -s" -else - CC="cc" -fi - -extract_section interpreter > /tmp/pm-$$.c -$CC $CFILE -o "$PMEXEC" && exec "$THISFILE" "$@" - -echo "pm: bootstrap failed." -exit 1 - -XXXXSTARTscript -38405 -#!/usr/bin/lua --- Prime Mover --- --- © 2006 David Given. --- Prime Mover is licensed under the MIT open source license. Search --- for 'MIT' in this file to find the full license text. --- --- $Id: pm 93 2007-02-24 21:20:53Z dtrg $ - --- ======================================================================= -- --- GLOBALS -- --- ======================================================================= -- - -local VERSION = "0.1.1" - --- Fast versions of useful system variables. - -local stdin = io.stdin -local stdout = io.stdout -local stderr = io.stderr - -local string_find = string.find -local string_gsub = string.gsub -local string_sub = string.sub -local string_byte = string.byte - -local table_insert = table.insert -local table_getn = table.getn -local table_concat = table.concat - -local posix_stat = posix.stat -local posix_readlink = posix.readlink -local posix_unlink = posix.unlink -local posix_rmdir = posix.rmdir - -local os_time = os.time - -local _G = _G -local _ - --- Option settings. - -local delete_output_files_on_error = true -local purge_intermediate_cache = false -local no_execute = false -local input_files = {} -local targets = {} -intermediate_cache_dir = ".pm-cache/" -verbose = false -quiet = false - --- Application globals. - -local sandbox = {} -local scope = {object=sandbox, next=nil} -local intermediate_cache = {} -local intermediate_cache_count = 0 -local buildstages = 0 - --- Atoms. - -local PARENT = {} -local EMPTY = {} -local REDIRECT = {} - --- Exported symbols (set to dummy values). - -message = 0 -filetime = 0 -filetouch = 0 -install = 0 -rendertable = 0 -stringmodifier = {} - -setmetatable(_G, {__newindex = function(t, key, value) - error("Attempt to write to new global "..key) -end}) - --- ======================================================================= -- --- UTILITIES -- --- ======================================================================= -- - -local function message(...) - stderr:write("pm: ") - stderr:write(unpack(arg)) - stderr:write("\n") -end -_G.message = message - -local function usererror(...) - stderr:write("pm: ") - stderr:write(unpack(arg)) - stderr:write("\n") - os.exit(1) -end - -local function traceoutput(...) - stdout:write(unpack(arg)) - stdout:write("\n") -end - -local function assert(message, result, e) - if result then - return result - end - - if (type(message) == "string") then - message = {message} - end - - table.insert(message, ": ") - table.insert(message, e) - usererror(unpack(message)) -end - --- Concatenates the contents of its arguments to the specified table. --- (Numeric indices only.) - -local function table_append(t, ...) - for _, i in ipairs(arg) do - if (type(i) == "table") then - for _, j in ipairs(i) do - table_insert(t, j) - end - else - table_insert(t, i) - end - end -end - --- Merge the contents of its arguments to the specified table. --- (Name indices. Will break on numeric indices.) - -local function table_merge(t, ...) - for _, i in ipairs(arg) do - for j, k in pairs(i) do - t[j] = k - end - end -end - --- Turn a list of strings into a single quoted string. - -function rendertable(i) - if (type(i) == "string") or (type(i) == "number") then - return i - end - - if (i == nil) or (i == EMPTY) then - return "" - end - - local t = {} - for _, j in ipairs(i) do - local r = string_gsub(j, "\\", "\\\\") - r = string_gsub(r, '"', '\\"') - table_insert(t, r) - end - return '"'..table_concat(t, '" "')..'"' -end -local rendertable = rendertable - --- Returns just the directory part of a path. - -local function dirname(f) - local f, n = string_gsub(f, "/[^/]*$", "") - if (n == 0) then - return "." - end - return f -end -posix.dirname = dirname - --- Makes an absolute path. - -local function absname(f) - if string.find(f, "^/") then - return f - end - - return posix.getcwd().."/"..f -end -posix.absname = absname - --- Copies a file. - -local function copy(src, dest) - local s = string_gsub(src, "'", "'\"'\"'") - local d = string_gsub(dest, "'", "'\"'\"'") - local r = os.execute("cp '"..s.."' '"..d.."'") - if (r ~= 0) then - return nil, "unable to copy file" - end - return 0, nil -end -posix.copy = copy - --- Makes all directories that contain f - -local function mkcontainerdir(f) - f = dirname(f) - if not posix_stat(f, "type") then - mkcontainerdir(f) - local r = posix.mkdir(f) - if not r then - usererror("unable to create directory '"..f.."'") - end - end -end - --- Install a file (suitable as a command list entry). - -local function do_install(self, src, dest) - src = absname(self:__expand(src)) - dest = absname(self:__expand(dest)) - if verbose then - message("installing '", src, "' --> '", dest, "'") - end - - mkcontainerdir(dest) - local f, e = posix.symlink(src, dest) - if f then - return - end - - if (e ~= nil) then - f, e = posix.unlink(dest) - if f then - f, e = posix.symlink(src, dest) - if f then - return - end - end - end - - self:__error("couldn't install '", src, "' to '", dest, - "': ", e) -end - -function install(src, dest) - return function(self, inputs, outputs) - local src = src - local dest = dest - - if (dest == nil) then - dest = src - src = outputs[1] - end - if (type(src) ~= "string") then - self:__error("pm.install needs a string or an object for an input") - end - if (type(dest) ~= "string") then - self:__error("pm.install needs a string for a destination") - end - return do_install(self, src, dest) - end -end - --- Perform an error traceback. - -local function traceback(e) - local i = 1 - while true do - local t = debug.getinfo(i) - if not t then - break - end - if (t.short_src ~= "stdin") and (t.short_src ~= "[C]") then - if (t.currentline == -1) then - t.currentline = "" - end - message(" ", t.short_src, ":", t.currentline) - end - i = i + 1 - end - - e = string_gsub(e, "^stdin:[0-9]*: ", "") - usererror("error: ", e) -end - --- ======================================================================= -- --- CACHE MANAGEMENT -- --- ======================================================================= -- - -local statted_files = {} -local function clear_stat_cache() - statted_files = {} -end - --- Returns the timestamp of a file, or 0 if it doesn't exist. - -local statted_files = {} -local function filetime(f) - local t = statted_files[f] - if t then - return t - end - - -- Stupid BeOS doesn't dereference symlinks on stat(). - - local realf = f - while true do - local newf, e = posix_readlink(realf) - if e then - break - end - realf = newf - end - - t = posix_stat(realf, "mtime") or 0 - statted_files[f] = t - return t -end -_G.filetime = filetime - --- Pretends to touch a file by manipulating the stat cache. - -local function filetouch(f) - if (type(f) == "string") then - f = {f} - end - - local t = os_time() - for _, i in ipairs(f) do - statted_files[i] = t - end -end -_G.filetouch = filetouch - -local function create_intermediate_cache() - local d = dirname(intermediate_cache_dir) - if not quiet then - message("creating new intermediate file cache in '"..d.."'") - end - - -- Attempt to wipe the old cache directory. - - local f = posix.files(d) - if not f then - -- The directory doesn't exist, so create it. - - mkcontainerdir(d) - f = posix.mkdir(d) - if not f then - usererror("unable to create intermediate file cache directory") - end - else - -- The directory exists. Delete all files in it recursively. - - local function rmdir(root) - local f = posix.files(root) - if not f then - return - end - - for i in f do - if ((i ~= ".") and (i ~= "..")) then - local fn = root.."/"..i - local t = posix_stat(fn, "type") - if (t == "regular") then - if not posix_unlink(fn) then - usererror("unable to purge intermediate file cache directory") - end - elseif (t == "directory") then - rmdir(fn) - posix_rmdir(fn) - end - end - end - end - - rmdir(d) - end -end - -local function save_intermediate_cache() - local fn = intermediate_cache_dir.."index" - local f = io.open(fn, "w") - if not f then - usererror("unable to save intermediate cache index file '", fn, "'") - end - - f:write(intermediate_cache_count, "\n") - for i, j in pairs(intermediate_cache) do - f:write(i, "\n") - f:write(j, "\n") - end - - f:close() -end - -local function load_intermediate_cache() - local fn = intermediate_cache_dir.."index" - local f = io.open(fn, "r") - if not f then - create_intermediate_cache() - return - end - - intermediate_cache_count = f:read("*l") - while true do - local l1 = f:read("*l") - local l2 = f:read("*l") - - if (l1 == nil) or (l2 == nil) then - break - end - - intermediate_cache[l1] = l2 - end - - f:close() -end - -local function create_intermediate_cache_key(key) - local u = intermediate_cache[key] - if not u then - intermediate_cache_count = intermediate_cache_count + 1 - u = intermediate_cache_count - intermediate_cache[key] = u - save_intermediate_cache() - end - - return u -end - --- ======================================================================= -- --- STRING MODIFIERS -- --- ======================================================================= -- - -function stringmodifier.dirname(self, s) - if (type(s) == "table") then - if (table_getn(s) == 1) then - s = s[1] - else - self:__error("tried to use string modifier 'dirname' on a table with more than one entry") - end - end - - return dirname(s) -end - --- ======================================================================= -- --- CLASS SYSTEM -- --- ======================================================================= -- - ---- Base class -------------------------------------------------------------- - -local metaclass = { - class = "metaclass", - - -- Creates a new instance of a class by creating a new object and cloning - -- all properties of the called class onto it. - - __call = function (self, ...) - local o = {} - for i, j in pairs(self) do - o[i] = j - end - setmetatable(o, o) - - -- Determine where this object was defined. - - local i = 1 - while true do - local s = debug.getinfo(i, "Sl") - if s then - if (string_byte(s.source) == 64) then - o.definedat = string_sub(s.source, 2)..":"..s.currentline - end - else - break - end - i = i + 1 - end - - -- Call the object's constructor and return it. - - o:__init(unpack(arg)) - return o - end, - - -- Dummy constructor. - - __init = function (self, ...) - end, -} -setmetatable(metaclass, metaclass) - ---- Top-level build node ---------------------------------------------------- - -local node = metaclass() -node.class = "node" - --- When constructed, nodes initialise themselves from a supplied table of --- properties. All node children take exactly one argument, allowing the --- "constructor {properties}" construction pattern. - -function node:__init(t) - metaclass.__init(self) - - if (type(t) == "string") then - t = {t} - end - if (type(t) ~= "table") then - self:__error("can't be constructed with a ", type(t), "; try a table or a string") - end - - -- Copy over non-numeric parameters. - - for i, j in pairs(t) do - if (tonumber(i) == nil) then - self[i] = j - end - end - - -- Copy any numeric parameters. - - for _, i in ipairs(t) do - table_insert(self, i) - end - - -- If we're a class, don't verify. - - if t.class then - return - end - - -- ensure_n_children - -- When true, ensures that the node has exactly the number of children - -- specified. - - if self.ensure_n_children then - local n = self.ensure_n_children - if (table.getn(self) ~= n) then - local one - if (n == 1) then - one = "one child" - else - one = n.." children" - end - self:_error("must have exactly ", one) - end - end - - -- ensure_at_least_one_child - -- When true, ensures the the node has at least one child. - - if self.ensure_at_least_one_child then - if (table_getn(self) < 1) then - self:__error("must have at least one child") - end - end - - -- construct_string_children_with - -- If set, any string children are automatically converted using the - -- specified constructor. - - if self.construct_string_children_with then - local constructor = self.construct_string_children_with - for i, j in ipairs(self) do - if (type(j) == "string") then - self[i] = constructor {j} - end - end - end - - -- all_children_are_objects - -- When true, verifies that all children are objects and not something - -- else (such as strings). - - if self.all_children_are_objects then - for i, j in ipairs(self) do - if (type(j) ~= "table") then - self:__error("doesn't know what to do with child ", i, - ", which is a ", type(j)) - end - end - end - - -- Ensure that self.install is valid. - - if self.install then - local t = type(self.install) - if (t == "string") or - (t == "function") then - self.install = {self.install} - end - - if (type(self.install) ~= "table") then - self:__error("doesn't know what to do with its installation command, ", - "which is a ", type(self.install), " but should be a table, function ", - "or string") - end - end -end - --- If an attempt is made to access a variable on a node that doesn't exist, --- and the variable starts with a capital letter, it's looked up in the --- property scope. - -function node:__index(key) - local i = string_byte(key, 1) - if (i >= 65) and (i <= 90) then - -- Scan up the class hierarchy. - - local recurse - recurse = function(s, key) - if not s then - return nil - end - local o = rawget(s.object, key) - if o then - if (type(o) == "table") then - - -- Handle lists of the form {PARENT, "foo", "bar"...} - if (o[1] == PARENT) then - local parent = recurse(s.next, key) - local newo = {} - - if parent then - if (type(parent) ~= "table") then - parent = {parent} - end - for _, j in ipairs(parent) do - table_insert(newo, j) - end - end - for _, j in ipairs(o) do - if (j ~= PARENT) then - table_insert(newo, j) - end - end - return newo - - -- Handle lists of the form {REDIRECT, "newkey"} - elseif (o[1] == REDIRECT) then - return self:__index(o[2]) - end - end - return o - end - -- Tail recursion. - return recurse(s.next, key) - end - - -- We want this node looked at first, so fake up a scope entry for it. - local fakescope = { - next = scope, - object = self - } - - -- Tail recursion. - return recurse(fakescope, key) - end - - -- For local properties, just return what's here. - return rawget(self, key) -end - --- Little utility that emits an error message. - -function node:__error(...) - usererror("object '", self.class, "', defined at ", - self.definedat, ", ", unpack(arg)) -end - --- Causes a node to return its outputs; that is, the files the node will --- produce when built. The parameter contains a list of input filenames; the --- outputs of the node's children. - -function node:__outputs(inputs) - self:__error("didn't implement __outputs when it should have") -end - --- Causes a node to return its dependencies; that is, a list of *filenames* --- whose timestamps need to be considered when checking whether a node needs --- to be rebuilt. This is usually, but not always, the same as the inputs. - -function node:__dependencies(inputs, outputs) - return inputs -end - --- Returns the node's timestamp. It will only get built if this is older than its --- children's timestamps. - -function node:__timestamp(inputs, outputs) - local t = 0 - for _, i in ipairs(outputs) do - local tt = filetime(i) - if (tt > t) then - t = tt - end - end - return t -end - --- Unconditionally builds the nodes' children, collating their outputs. We --- push a new scope while we do so, to make this object's definitions visible --- to the children. (Almost never overridden. Only file() will want to do --- this, most likely.) - -function node:__buildchildren() - local inputs = {} - scope = {object=self, next=scope} - - for _, i in ipairs(self) do - table_append(inputs, i:__build()) - end - self:__buildadditionalchildren() - scope = scope.next - return inputs -end - --- Provides a hook for building any additional children that aren't actually --- in the child list. - -function node:__buildadditionalchildren() -end - --- Cause the node's children to be built, collating their outputs, and if --- any output is newer than the node itself, causes the node to be built. - -function node:__build() - -- Build children and collate their outputs. These will become this node's - -- inputs. - - local inputs = self:__buildchildren() - - -- Determine the node's outputs. This will usually be automatically - -- generated, in which case the name will depend on the overall environment --- - -- including the inputs. - - local outputs = self:__outputs(inputs) - - -- Get the current node's timestamp. If anything this node depends on is - -- newer than that, the node needs rebuilding. - - local t = self:__timestamp(inputs, outputs) - local depends = self:__dependencies(inputs, outputs) - local rebuild = false - - if (t == 0) then - rebuild = true - end - - if (not rebuild and depends) then - for _, i in ipairs(depends) do - local tt = filetime(i) --- message("comparing ", t, " with ", tt, " (", rendertable({i}), ")") - if (tt > t) then - if verbose then - message("rebuilding ", self.class, " because ", i, " newer than ", rendertable(outputs)) - end - rebuild = true - break - end - end - end - - if rebuild then - self:__dobuild(inputs, outputs) - filetouch(outputs) - end - - -- If an installation command was specified, execute it now. - - if self.install then - self:__invoke(self.install, inputs, outputs) - end - - -- And return this nodes' outputs. - - return outputs -end - --- Builds this node from the specified input files (the node's childrens' --- outputs). - -function node:__dobuild(inputs, outputs) - self:__error("didn't implement __dobuild when it should have") -end - --- Recursively expands any variables in a string. - -function node:__expand(s) - local searching = true - while searching do - searching = false - - -- Expand %{expressions}% - - s = string_gsub(s, "%%{(.-)}%%", function (expr) - searching = true - - local f, e = loadstring(expr, "expression") - if not f then - self:__error("couldn't compile the expression '", expr, "': ", e) - end - - local env = {self=self} - setmetatable(env, { - __index = function(_, key) - return sandbox[key] - end - }) - setfenv(f, env) - - f, e = pcall(f, self) - if not f then - self:__error("couldn't evaluate the expression '", expr, "': ", e) - end - - return rendertable(e) - end) - - -- Expand %varnames% - - s = string_gsub(s, "%%(.-)%%", function (varname) - searching = true - - -- Parse the string reference. - - local _, _, leftcolon, rightcolon = string_find(varname, "([^:]*):?(.*)$") - local _, _, varname, selectfrom, hyphen, selectto = string_find(leftcolon, "^([^[]*)%[?([^-%]]*)(%-?)([^%]]*)]?$") - - -- Get the basic value that the rest of the reference is going to - -- depend on. - - local result = self:__index(varname) - if not result then - self:__error("doesn't understand variable '", varname, "'") - end - - -- Process any selector, if specified. - - if (selectfrom ~= "") or (hyphen ~= "") or (selectto ~= "") then - if (type(result) ~= "table") then - self:__error("tried to use a [] selector on variable '", varname, - "', which doesn't contain a table") - end - local n = table_getn(result) - - selectfrom = tonumber(selectfrom) - selectto = tonumber(selectto) - - if (hyphen ~= "") then - if not selectfrom then - selectfrom = 1 - end - if not selectto then - selectto = n - end - else - if not selectto then - selectto = selectfrom - end - if not selectfrom then - self:__error("tried to use an empty selector on variable '", varname, "'") - end - end - - if (selectfrom < 1) or (selectto < 1) or - (selectfrom > n) or (selectto > n) or - (selectto < selectfrom) then - self:__error("tried to use an invalid selector [", - selectfrom, "-", selectto, "] on variable '", varname, - "'; only [1-", n, "] is valid") - end - - local newresult = {} - for i = selectfrom, selectto do - table_insert(newresult, result[i]) - end - result = newresult - end - - -- Process any string modifier, if supplied. - - if (rightcolon ~= "") then - local f = stringmodifier[rightcolon] - if not f then - self:__error("tried to use an unknown string modifier '", - rightcolon, "' on variable '", varname, "'") - end - - result = f(self, result) - end - - return rendertable(result) - end) - end - - -- Any remaining %% sequences must be empty, and so convert them into - -- single % sequences. - - s = string_gsub(s, "%%%%", "%") - return s -end - --- Expands any variables in a command table, and executes it. - -function node:__invoke(command, inputs, outputs) - if (type(command) ~= "table") then - command = {command} - end - - for _, s in ipairs(command) do - if (type(s) == "string") then - s = self:__expand(s) - if not quiet then - traceoutput(s) - end - if not no_execute then - local r = os.execute(s) - if (r ~= 0) then - return r - end - end - elseif (type(s) == "function") then - local r = s(self, inputs, outputs) - if r then - return r - end - end - end - return false -end - --- ======================================================================= -- --- PROLOGUE -- --- ======================================================================= -- - --- The prologue contains the standard library that all pmfiles can refer to. --- For simplicity, it's implemented by code running inside the sandbox, --- which means that it's basically identical to user code (and could, in --- fact, be kept in a seperate file). - --- Here we set up the sandbox. - -table_merge(sandbox, { - VERSION = VERSION, - - assert = assert, - collectgarbage = collectgarbage, - dofile = dofile, - error = error, - getfenv = getfenv, - getmetatable = getmetatable, - gcinfo = gcinfo, - ipairs = ipairs, - loadfile = loadfile, - loadlib = loadlib, - loadstring = loadstring, - next = next, - pairs = pairs, - pcall = pcall, - print = print, - rawequal = rawequal, - rawget = rawget, - rawset = rawset, - require = require, - setfenv = setfenv, - setmetatable = setmetatable, - tonumber = tonumber, - tostring = tostring, - type = type, - unpack = unpack, - _VERSION = _VERSION, - xpcall = xpcall, - - table = table, - io = io, - os = os, - posix = posix, - string = string, - debug = debug, - loadlib = loadlib, - - pm = _G, - node = node, - - PARENT = PARENT, - EMPTY = EMPTY, - REDIRECT = REDIRECT, -}) - --- Cause any reads from undefined keys in the sandbox to fail with an error. --- This helps debugging pmfiles somewhat. - -setmetatable(sandbox, { - __index = function(self, key) - local value = rawget(self, key) - if (value == nil) then - error(key.." could not be found in any applicable scope") - end - return value - end -}) - --- Switch into sandbox mode. - -setfenv(1, sandbox) - ---- Assorted utilities ------------------------------------------------------ - --- Includes a file. - -function include(f, ...) - local c, e = loadfile(f) - if not c then - usererror("script compilation error: ", e) - end - - setfenv(c, sandbox) - local arguments = arg - xpcall( - function() - c(unpack(arguments)) - end, - function(e) - message("script execution error --- traceback follows:") - traceback(e) - end - ) -end - ---- file -------------------------------------------------------------------- - --- file() is pretty much the simplest clause. It takes a list of filenames, --- and outputs them. --- --- * Building does nothing. --- * Its outputs are its inputs. --- --- Note: this clause only takes *strings* as its children. If a reference is --- made to a file that doesn't exist, an error occurs. - -file = node { - class = "file", - ensure_at_least_one_child = true, - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- Ensure that the file's children are strings. - - for i, j in ipairs(self) do - if (type(j) ~= "string") then - self:__error("doesn't know what to do with child ", i, - ", which is a ", type(j)) - end - end - end, - - -- File's timestamp is special and will bail if it meets a nonexistant file. - - __timestamp = function(self, inputs, outputs) - local t = 0 - for _, i in ipairs(outputs) do - i = self:__expand(i) - local tt = filetime(i) - if (tt == 0) then - self:__error("is referring to the file '", i, "' which does not exist") - end - if (tt > t) then - t = tt - end - end - return t - end, - - -- Outputs are inputs. - - __outputs = function(self, inputs) - local o = {} - local n - if self.only_n_children_are_outputs then - n = self.only_n_children_are_outputs - else - n = table_getn(inputs) - end - - for i = 1, n do - o[i] = inputs[i] - end - - return o - end, - - -- Building children does nothing; outputs are inputs. - - __buildchildren = function(self) - local outputs = {} - table_append(outputs, self) - return outputs - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- group ------------------------------------------------------------------- - --- group() is also the simplest clause. It does nothing, existing only to --- group together its children. - -group = node { - class = "group", - - -- Outputs are inputs. - - __outputs = function(self, inputs) - return inputs - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- deponly ----------------------------------------------------------------- - --- deponly() is the one-and-a-halfth most simplest clause. It acts like --- group {}, but returns no outputs. It's useful for ensuring that building --- one node causes another node to be built without actually using the --- second node's outputs. - -deponly = node { - class = "deponly", - ensure_at_least_one_child = true, - - -- Emits no outputs - - __outputs = function(self, inputs) - return {} - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- ith --------------------------------------------------------------------- - --- ith() is the second simplest clause. It acts like group {}, but returns --- only some of the specified output. It is suitable for extracting, say, --- one output from a clause to pass to cfile {}. - -ith = node { - class = "ith", - ensure_at_least_one_child = true, - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- If we have an i property, ensure we don't have a from or - -- to property. - - if self.i then - if self.from or self.to then - self:__error("can't have both an i property and a from or to property") - end - - if (type(self.i) ~= "number") then - self:__error("doesn't know what to do with its i property, ", - "which is a ", type(self.i), " where a number was expected") - end - - self.from = self.i - self.to = self.i - end - - -- Ensure the from and to properties are numbers, if they exist. - - if self.from then - if (type(self.from) ~= "number") then - self:__error("doesn't know what to do with its from property, ", - "which is a ", type(self.from), " where a number was expected") - end - end - - if self.to then - if (type(self.to) ~= "number") then - self:__error("doesn't know what to do with its to property, ", - "which is a ", type(self.to), " where a number was expected") - end - end - end, - - -- Emits one output, which is one of the inputs. - - __outputs = function(self, inputs) - local n = table_getn(inputs) - local from = self.from or 1 - local to = self.to or n - - if (from < 1) or (to > n) then - self:__error("tried to select range ", from, " to ", to, - " from only ", n, " inputs") - end - - local range = {} - for i = from, to do - table_append(range, inputs[i]) - end - return range - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - - ---- foreach ----------------------------------------------------------------- - --- foreach {} is the counterpart to ith {}. It applies a particular rule to --- all of its children. - -foreach = node { - class = "foreach", - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- Ensure we have a rule property which is a table. - - if not self.rule then - self:__error("must have a rule property") - end - if (type(self.rule) ~= "table") then - self:__error("doesn't know what to do with its rule property, ", - "which is a ", type(self.rule), " where a table was expected") - end - end, - - -- Build all our children via the rule. - -- - -- This is pretty much a copy of node.__buildchildren(). - - __buildchildren = function(self) - scope = {object=self, next=scope} - - local intermediate = {} - for _, i in ipairs(self) do - table_append(intermediate, i:__build()) - end - - local inputs = {} - for _, i in ipairs(intermediate) do - local r = self.rule { i } - table_append(inputs, r:__build()) - end - - self:__buildadditionalchildren() - scope = scope.next - return inputs - end, - - -- Inputs are outputs --- because __buildchildren has already done the - -- necessary work. - - __outputs = function(self, inputs) - return inputs - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- Simple --------------------------------------------------------------- - --- simple is the most common clause, and implements make-like behaviour: --- the named command is executed in order to rebuild the node. --- --- * The timestamp is the newest timestamp of its outputs. --- * Building executes the command. --- * Its outputs are automatically generated by expanding the templates --- in the 'outputs' variable. - -simple = node { - class = "file", - construct_string_children_with = file, - all_children_are_objects = true, - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- outputs must exist, and must be a table. - - if not self.outputs then - self:__error("must have an outputs template set") - end - - if (type(self.outputs) ~= "table") then - self:__error("doesn't know what to do with its outputs, which is a ", - type(self.outputs), " but should be a table") - end - - -- There must be a command which must be a string or table. - - if not self.command then - self:__error("must have a command specified") - end - if (type(self.command) == "string") then - self.command = {self.command} - end - if (type(self.command) ~= "table") then - self:__error("doesn't know what to do with its command, which is a ", - type(self.command), " but should be a string or a table") - end - end, - - -- Outputs are specified manually. - - __outputs = function(self, inputs) - self["in"] = inputs - - local input - if inputs then - input = inputs[1] - end - if not input then - input = "" - end - - self.I = string_gsub(input, "^.*/", "") - self.I = string_gsub(self.I, "%..-$", "") - - -- Construct an outputs array for use in the cache key. This mirrors - -- what the final array will be, but the unique ID is going to be 0. - - self.out = {} - self.U = 0 - for _, i in ipairs(self.outputs) do - i = self:__expand(i) - table_append(self.out, i) - end - - -- Determine the cache key we're going to use. - - local cachekey = table_concat(self.command, " && ") - cachekey = self:__expand(cachekey) - cachekey = create_intermediate_cache_key(cachekey) - - -- Work out the unique ID. - -- - -- Note: we're running in the sandbox, so we need to fully qualify - -- pm.intermediate_cache_dir. - - self.U = pm.intermediate_cache_dir..cachekey - - -- Construct the real outputs array. - - self.out = {} - for _, i in ipairs(self.outputs) do - i = self:__expand(i) - mkcontainerdir(i) - table_append(self.out, i) - end - - return self.out - end, - - -- Building causes the command to be expanded and invoked. The 'children' - -- variable is set to the input files. - - __dobuild = function(self, inputs, outputs) - self["in"] = inputs - self.out = outputs - local r = self:__invoke(self.command, inputs, outputs) - if r then - if delete_output_files_on_error then - self:__invoke({"%RM% %out%"}) - end - self:__error("failed to build with return code ", r) - end - end, -} - ---- End of prologue --------------------------------------------------------- - --- Set a few useful global variables. - -RM = "rm -f" -INSTALL = "ln -f" - --- Now we're done, switch out of sandbox mode again. This only works --- because we made _G local at the top of the file, which makes it --- lexically scoped rather than looked up via the environment. - -setfenv(1, _G) - --- ======================================================================= -- --- APPLICATION DRIVER -- --- ======================================================================= -- - --- Parse and process the command line options. - -do - local function do_help(opt) - message("Prime Mover version ", VERSION, " © 2006 David Given") - stdout:write([[ -Syntax: pm [] [] -Options: - -h --help Displays this message. - --license List Prime Mover's redistribution license. - -cX --cachedir X Sets the object file cache to directory X. - -p --purge Purges the cache before execution. - WARNING: will remove *everything* in the cache dir! - -fX --file X Reads in the pmfile X. May be specified multiple times. - -DX=Y --define X=Y Defines variable X to value Y (or true if Y omitted) - -n --no-execute Don't actually execute anything - -v --verbose Be more verbose - -q --quiet Be more quiet - -If no pmfiles are explicitly specified, 'pmfile' is read. -If no targets are explicitly specified, 'default' is built. -Options and targets may be specified in any order. -]]) - os.exit(0) - end - - local function do_license(opt) - message("Prime Mover version ", VERSION, " © 2006 David Given") - stdout:write([[ - -Prime Mover is licensed under the MIT open source license. - -Copyright © 2006 David Given - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -]]) - os.exit(0) - end - - local function needarg(opt) - if not opt then - usererror("missing option parameter") - end - end - - local function do_cachedir(opt) - needarg(opt) - intermediate_cache_dir = opt - return 1 - end - - local function do_inputfile(opt) - needarg(opt) - table_append(input_files, opt) - return 1 - end - - local function do_purgecache(opt) - purge_intermediate_cache = true - return 0 - end - - local function do_define(opt) - needarg(opt) - - local s, e, key, value = string_find(opt, "^([^=]*)=(.*)$") - if not key then - key = opt - value = true - end - - sandbox[key] = value - return 1 - end - - local function do_no_execute(opt) - no_execute = true - return 0 - end - - local function do_verbose(opt) - verbose = true - return 0 - end - - local function do_quiet(opt) - quiet = true - return 0 - end - - local argmap = { - ["h"] = do_help, - ["help"] = do_help, - ["c"] = do_cachedir, - ["cachedir"] = do_cachedir, - ["p"] = do_purgecache, - ["purge"] = do_purgecache, - ["f"] = do_inputfile, - ["file"] = do_inputfile, - ["D"] = do_define, - ["define"] = do_define, - ["n"] = do_no_execute, - ["no-execute"] = do_no_execute, - ["v"] = do_verbose, - ["verbose"] = do_verbose, - ["q"] = do_quiet, - ["quiet"] = do_quiet, - ["license"] = do_license, - } - - -- Called on an unrecognised option. - - local function unrecognisedarg(arg) - usererror("unrecognised option '", arg, "' --- try --help for help") - end - - -- Do the actual argument parsing. - - for i = 1, table_getn(arg) do - local o = arg[i] - local op - - if (string_byte(o, 1) == 45) then - -- This is an option. - if (string_byte(o, 2) == 45) then - -- ...with a -- prefix. - o = string_sub(o, 3) - local fn = argmap[o] - if not fn then - unrecognisedarg("--"..o) - end - local op = arg[i+1] - i = i + fn(op) - else - -- ...without a -- prefix. - local od = string_sub(o, 2, 2) - local fn = argmap[od] - if not fn then - unrecognisedarg("-"..od) - end - op = string_sub(o, 3) - if (op == "") then - op = arg[i+1] - i = i + fn(op) - else - fn(op) - end - end - else - -- This is a target name. - table_append(targets, o) - end - end - - -- Option fallbacks. - - if (table_getn(input_files) == 0) then - input_files = {"pmfile"} - end - - if (table_getn(targets) == 0) then - targets = {"default"} - end -end - --- Load any input files. - -for _, i in ipairs(input_files) do - sandbox.include(i, unpack(arg)) -end - --- Set up the intermediate cache. - -if purge_intermediate_cache then - create_intermediate_cache() -else - load_intermediate_cache() -end - --- Build any targets. - -for _, i in ipairs(targets) do - local o = sandbox[i] - if not o then - usererror("don't know how to build '", i, "'") - end - if ((type(o) ~= "table") and not o.class) then - usererror("'", i, "' doesn't seem to be a valid target") - end - - xpcall( - function() - o:__build() - end, - function(e) - message("rule engine execution error --- traceback follows:") - traceback(e) - end - ) -end - -XXXXSTARTinterpreter -253583 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#line 1 "lapi.c" -#define lapi_c -#line 1 "lua.h" -#ifndef lua_h -#define lua_h -#define LUA_NUMBER int -#define LUA_NUMBER_SCAN "%d" -#define LUA_NUMBER_FMT "%d" -#define LUA_VERSION "Lua 5.0.2 (patched for Prime Mover)" -#define LUA_COPYRIGHT "Copyright (C) 1994-2004 Tecgraf, PUC-Rio" -#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" -#define LUA_MULTRET (-1) -#define LUA_REGISTRYINDEX (-10000) -#define LUA_GLOBALSINDEX (-10001) -#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) -#define LUA_ERRRUN 1 -#define LUA_ERRFILE 2 -#define LUA_ERRSYNTAX 3 -#define LUA_ERRMEM 4 -#define LUA_ERRERR 5 -typedef struct lua_State lua_State;typedef int(*lua_CFunction)(lua_State*L); -typedef const char*(*lua_Chunkreader)(lua_State*L,void*ud,size_t*sz);typedef -int(*lua_Chunkwriter)(lua_State*L,const void*p,size_t sz,void*ud); -#define LUA_TNONE (-1) -#define LUA_TNIL 0 -#define LUA_TBOOLEAN 1 -#define LUA_TLIGHTUSERDATA 2 -#define LUA_TNUMBER 3 -#define LUA_TSTRING 4 -#define LUA_TTABLE 5 -#define LUA_TFUNCTION 6 -#define LUA_TUSERDATA 7 -#define LUA_TTHREAD 8 -#define LUA_MINSTACK 20 -#ifdef LUA_USER_H -#include LUA_USER_H -#endif -#ifndef LUA_NUMBER -typedef double lua_Number; -#else -typedef LUA_NUMBER lua_Number; -#endif -#ifndef LUA_API -#define LUA_API extern -#endif -LUA_API lua_State*lua_open(void);LUA_API void lua_close(lua_State*L);LUA_API -lua_State*lua_newthread(lua_State*L);LUA_API lua_CFunction lua_atpanic( -lua_State*L,lua_CFunction panicf);LUA_API int lua_gettop(lua_State*L);LUA_API -void lua_settop(lua_State*L,int idx);LUA_API void lua_pushvalue(lua_State*L, -int idx);LUA_API void lua_remove(lua_State*L,int idx);LUA_API void lua_insert( -lua_State*L,int idx);LUA_API void lua_replace(lua_State*L,int idx);LUA_API int - lua_checkstack(lua_State*L,int sz);LUA_API void lua_xmove(lua_State*from, -lua_State*to,int n);LUA_API int lua_isnumber(lua_State*L,int idx);LUA_API int -lua_isstring(lua_State*L,int idx);LUA_API int lua_iscfunction(lua_State*L,int -idx);LUA_API int lua_isuserdata(lua_State*L,int idx);LUA_API int lua_type( -lua_State*L,int idx);LUA_API const char*lua_typename(lua_State*L,int tp); -LUA_API int lua_equal(lua_State*L,int idx1,int idx2);LUA_API int lua_rawequal( -lua_State*L,int idx1,int idx2);LUA_API int lua_lessthan(lua_State*L,int idx1, -int idx2);LUA_API lua_Number lua_tonumber(lua_State*L,int idx);LUA_API int -lua_toboolean(lua_State*L,int idx);LUA_API const char*lua_tostring(lua_State*L -,int idx);LUA_API size_t lua_strlen(lua_State*L,int idx);LUA_API lua_CFunction - lua_tocfunction(lua_State*L,int idx);LUA_API void*lua_touserdata(lua_State*L, -int idx);LUA_API lua_State*lua_tothread(lua_State*L,int idx);LUA_API const -void*lua_topointer(lua_State*L,int idx);LUA_API void lua_pushnil(lua_State*L); -LUA_API void lua_pushnumber(lua_State*L,lua_Number n);LUA_API void -lua_pushlstring(lua_State*L,const char*s,size_t l);LUA_API void lua_pushstring -(lua_State*L,const char*s);LUA_API const char*lua_pushvfstring(lua_State*L, -const char*fmt,va_list argp);LUA_API const char*lua_pushfstring(lua_State*L, -const char*fmt,...);LUA_API void lua_pushcclosure(lua_State*L,lua_CFunction fn -,int n);LUA_API void lua_pushboolean(lua_State*L,int b);LUA_API void -lua_pushlightuserdata(lua_State*L,void*p);LUA_API void lua_gettable(lua_State* -L,int idx);LUA_API void lua_rawget(lua_State*L,int idx);LUA_API void -lua_rawgeti(lua_State*L,int idx,int n);LUA_API void lua_newtable(lua_State*L); -LUA_API void*lua_newuserdata(lua_State*L,size_t sz);LUA_API int -lua_getmetatable(lua_State*L,int objindex);LUA_API void lua_getfenv(lua_State* -L,int idx);LUA_API void lua_settable(lua_State*L,int idx);LUA_API void -lua_rawset(lua_State*L,int idx);LUA_API void lua_rawseti(lua_State*L,int idx, -int n);LUA_API int lua_setmetatable(lua_State*L,int objindex);LUA_API int -lua_setfenv(lua_State*L,int idx);LUA_API void lua_call(lua_State*L,int nargs, -int nresults);LUA_API int lua_pcall(lua_State*L,int nargs,int nresults,int -errfunc);LUA_API int lua_cpcall(lua_State*L,lua_CFunction func,void*ud); -LUA_API int lua_load(lua_State*L,lua_Chunkreader reader,void*dt,const char* -chunkname);LUA_API int lua_dump(lua_State*L,lua_Chunkwriter writer,void*data); -LUA_API int lua_yield(lua_State*L,int nresults);LUA_API int lua_resume( -lua_State*L,int narg);LUA_API int lua_getgcthreshold(lua_State*L);LUA_API int -lua_getgccount(lua_State*L);LUA_API void lua_setgcthreshold(lua_State*L,int -newthreshold);LUA_API const char*lua_version(void);LUA_API int lua_error( -lua_State*L);LUA_API int lua_next(lua_State*L,int idx);LUA_API void lua_concat -(lua_State*L,int n); -#define lua_boxpointer(L,u) (*(void**)(lua_newuserdata(L,sizeof(void*)))=(u)) -#define lua_unboxpointer(L,i) (*(void**)(lua_touserdata(L,i))) -#define lua_pop(L,n) lua_settop(L,-(n)-1) -#define lua_register(L,n,f) (lua_pushstring(L,n),lua_pushcfunction(L,f),\ -lua_settable(L,LUA_GLOBALSINDEX)) -#define lua_pushcfunction(L,f) lua_pushcclosure(L,f,0) -#define lua_isfunction(L,n) (lua_type(L,n)==LUA_TFUNCTION) -#define lua_istable(L,n) (lua_type(L,n)==LUA_TTABLE) -#define lua_islightuserdata(L,n) (lua_type(L,n)==LUA_TLIGHTUSERDATA) -#define lua_isnil(L,n) (lua_type(L,n)==LUA_TNIL) -#define lua_isboolean(L,n) (lua_type(L,n)==LUA_TBOOLEAN) -#define lua_isnone(L,n) (lua_type(L,n)==LUA_TNONE) -#define lua_isnoneornil(L, n)(lua_type(L,n)<=0) -#define lua_pushliteral(L, s)lua_pushlstring(L,""s,(sizeof(s)/sizeof(char))-1) -LUA_API int lua_pushupvalues(lua_State*L); -#define lua_getregistry(L) lua_pushvalue(L,LUA_REGISTRYINDEX) -#define lua_setglobal(L,s) (lua_pushstring(L,s),lua_insert(L,-2),lua_settable(\ -L,LUA_GLOBALSINDEX)) -#define lua_getglobal(L,s) (lua_pushstring(L,s),lua_gettable(L,\ -LUA_GLOBALSINDEX)) -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) -#define lua_ref(L,lock) ((lock)?luaL_ref(L,LUA_REGISTRYINDEX):(lua_pushstring(\ -L,"unlocked references are obsolete"),lua_error(L),0)) -#define lua_unref(L,ref) luaL_unref(L,LUA_REGISTRYINDEX,(ref)) -#define lua_getref(L,ref) lua_rawgeti(L,LUA_REGISTRYINDEX,ref) -#ifndef LUA_NUMBER_SCAN -#define LUA_NUMBER_SCAN "%lf" -#endif -#ifndef LUA_NUMBER_FMT -#define LUA_NUMBER_FMT "%.14g" -#endif -#define LUA_HOOKCALL 0 -#define LUA_HOOKRET 1 -#define LUA_HOOKLINE 2 -#define LUA_HOOKCOUNT 3 -#define LUA_HOOKTAILRET 4 -#define LUA_MASKCALL (1<2147483640L -#define BITS_INT 32 -#else -#error "you must define BITS_INT with number of bits in an integer" -#endif -#endif -#endif -typedef unsigned int lu_hash;typedef int ls_hash;typedef unsigned long lu_mem; -#define MAX_LUMEM ULONG_MAX -typedef long ls_nstr;typedef unsigned char lu_byte; -#define MAX_SIZET ((size_t)(~(size_t)0)-2) -#define MAX_INT (INT_MAX-2) -#define IntPoint(p) ((lu_hash)(p)) -#ifndef LUSER_ALIGNMENT_T -typedef union{double u;void*s;long l;}L_Umaxalign; -#else -typedef LUSER_ALIGNMENT_T L_Umaxalign; -#endif -#ifndef LUA_UACNUMBER -typedef double l_uacNumber; -#else -typedef LUA_UACNUMBER l_uacNumber; -#endif -#ifndef lua_assert -#define lua_assert(c) -#endif -#ifndef check_exp -#define check_exp(c,e) (e) -#endif -#ifndef UNUSED -#define UNUSED(x) ((void)(x)) -#endif -#ifndef cast -#define cast(t, exp)((t)(exp)) -#endif -typedef unsigned long Instruction; -#ifndef LUA_MAXCALLS -#define LUA_MAXCALLS 4096 -#endif -#ifndef LUA_MAXCCALLS -#define LUA_MAXCCALLS 200 -#endif -#ifndef LUA_MAXCSTACK -#define LUA_MAXCSTACK 2048 -#endif -#define MAXSTACK 250 -#ifndef MAXVARS -#define MAXVARS 200 -#endif -#ifndef MAXUPVALUES -#define MAXUPVALUES 32 -#endif -#ifndef MAXPARAMS -#define MAXPARAMS 100 -#endif -#ifndef MINSTRTABSIZE -#define MINSTRTABSIZE 32 -#endif -#ifndef LUA_MINBUFFER -#define LUA_MINBUFFER 32 -#endif -#ifndef LUA_MAXPARSERLEVEL -#define LUA_MAXPARSERLEVEL 200 -#endif -#endif -#line 12 "lobject.h" -#define NUM_TAGS LUA_TTHREAD -#define LUA_TPROTO (NUM_TAGS+1) -#define LUA_TUPVAL (NUM_TAGS+2) -typedef union GCObject GCObject; -#define CommonHeader GCObject*next;lu_byte tt;lu_byte marked -typedef struct GCheader{CommonHeader;}GCheader;typedef union{GCObject*gc;void* -p;lua_Number n;int b;}Value;typedef struct lua_TObject{int tt;Value value;} -TObject; -#define ttisnil(o) (ttype(o)==LUA_TNIL) -#define ttisnumber(o) (ttype(o)==LUA_TNUMBER) -#define ttisstring(o) (ttype(o)==LUA_TSTRING) -#define ttistable(o) (ttype(o)==LUA_TTABLE) -#define ttisfunction(o) (ttype(o)==LUA_TFUNCTION) -#define ttisboolean(o) (ttype(o)==LUA_TBOOLEAN) -#define ttisuserdata(o) (ttype(o)==LUA_TUSERDATA) -#define ttisthread(o) (ttype(o)==LUA_TTHREAD) -#define ttislightuserdata(o) (ttype(o)==LUA_TLIGHTUSERDATA) -#define ttype(o) ((o)->tt) -#define gcvalue(o) check_exp(iscollectable(o),(o)->value.gc) -#define pvalue(o) check_exp(ttislightuserdata(o),(o)->value.p) -#define nvalue(o) check_exp(ttisnumber(o),(o)->value.n) -#define tsvalue(o) check_exp(ttisstring(o),&(o)->value.gc->ts) -#define uvalue(o) check_exp(ttisuserdata(o),&(o)->value.gc->u) -#define clvalue(o) check_exp(ttisfunction(o),&(o)->value.gc->cl) -#define hvalue(o) check_exp(ttistable(o),&(o)->value.gc->h) -#define bvalue(o) check_exp(ttisboolean(o),(o)->value.b) -#define thvalue(o) check_exp(ttisthread(o),&(o)->value.gc->th) -#define l_isfalse(o) (ttisnil(o)||(ttisboolean(o)&&bvalue(o)==0)) -#define setnvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TNUMBER;i_o->value.n=(\ -x);} -#define chgnvalue(obj,x) check_exp(ttype(obj)==LUA_TNUMBER,(obj)->value.n=(x)) -#define setpvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TLIGHTUSERDATA;i_o->\ -value.p=(x);} -#define setbvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TBOOLEAN;i_o->value.b=\ -(x);} -#define setsvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TSTRING;i_o->value.gc=\ -cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TSTRING);} -#define setuvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TUSERDATA;i_o->value.\ -gc=cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TUSERDATA);} -#define setthvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TTHREAD;i_o->value.gc\ -=cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TTHREAD);} -#define setclvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TFUNCTION;i_o->value.\ -gc=cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TFUNCTION);} -#define sethvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TTABLE;i_o->value.gc=\ -cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TTABLE);} -#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) -#define checkconsistency(obj) lua_assert(!iscollectable(obj)||(ttype(obj)==(\ -obj)->value.gc->gch.tt)) -#define setobj(obj1,obj2) {const TObject*o2=(obj2);TObject*o1=(obj1);\ -checkconsistency(o2);o1->tt=o2->tt;o1->value=o2->value;} -#define setobjs2s setobj -#define setobj2s setobj -#define setsvalue2s setsvalue -#define setobjt2t setobj -#define setobj2t setobj -#define setobj2n setobj -#define setsvalue2n setsvalue -#define setttype(obj, tt)(ttype(obj)=(tt)) -#define iscollectable(o) (ttype(o)>=LUA_TSTRING) -typedef TObject*StkId;typedef union TString{L_Umaxalign dummy;struct{ -CommonHeader;lu_byte reserved;lu_hash hash;size_t len;}tsv;}TString; -#define getstr(ts) cast(const char*,(ts)+1) -#define svalue(o) getstr(tsvalue(o)) -typedef union Udata{L_Umaxalign dummy;struct{CommonHeader;struct Table* -metatable;size_t len;}uv;}Udata;typedef struct Proto{CommonHeader;TObject*k; -Instruction*code;struct Proto**p;int*lineinfo;struct LocVar*locvars;TString** -upvalues;TString*source;int sizeupvalues;int sizek;int sizecode;int -sizelineinfo;int sizep;int sizelocvars;int lineDefined;GCObject*gclist;lu_byte - nups;lu_byte numparams;lu_byte is_vararg;lu_byte maxstacksize;}Proto;typedef -struct LocVar{TString*varname;int startpc;int endpc;}LocVar;typedef struct -UpVal{CommonHeader;TObject*v;TObject value;}UpVal; -#define ClosureHeader CommonHeader;lu_byte isC;lu_byte nupvalues;GCObject*\ -gclist -typedef struct CClosure{ClosureHeader;lua_CFunction f;TObject upvalue[1];} -CClosure;typedef struct LClosure{ClosureHeader;struct Proto*p;TObject g;UpVal* -upvals[1];}LClosure;typedef union Closure{CClosure c;LClosure l;}Closure; -#define iscfunction(o) (ttype(o)==LUA_TFUNCTION&&clvalue(o)->c.isC) -#define isLfunction(o) (ttype(o)==LUA_TFUNCTION&&!clvalue(o)->c.isC) -typedef struct Node{TObject i_key;TObject i_val;struct Node*next;}Node;typedef - struct Table{CommonHeader;lu_byte flags;lu_byte lsizenode;struct Table* -metatable;TObject*array;Node*node;Node*firstfree;GCObject*gclist;int sizearray -;}Table; -#define lmod(s,size) check_exp((size&(size-1))==0,(cast(int,(s)&((size)-1)))) -#define twoto(x) (1<<(x)) -#define sizenode(t) (twoto((t)->lsizenode)) -extern const TObject luaO_nilobject;int luaO_log2(unsigned int x);int -luaO_int2fb(unsigned int x); -#define fb2int(x) (((x)&7)<<((x)>>3)) -int luaO_rawequalObj(const TObject*t1,const TObject*t2);int luaO_str2d(const -char*s,lua_Number*result);const char*luaO_pushvfstring(lua_State*L,const char* -fmt,va_list argp);const char*luaO_pushfstring(lua_State*L,const char*fmt,...); -void luaO_chunkid(char*out,const char*source,int len); -#endif -#line 12 "lapi.h" -void luaA_pushobject(lua_State*L,const TObject*o); -#endif -#line 16 "lapi.c" -#line 1 "ldebug.h" -#ifndef ldebug_h -#define ldebug_h -#line 1 "lstate.h" -#ifndef lstate_h -#define lstate_h -#line 1 "ltm.h" -#ifndef ltm_h -#define ltm_h -typedef enum{TM_INDEX,TM_NEWINDEX,TM_GC,TM_MODE,TM_EQ,TM_ADD,TM_SUB,TM_MUL, -TM_DIV,TM_POW,TM_UNM,TM_LT,TM_LE,TM_CONCAT,TM_CALL,TM_N}TMS; -#define gfasttm(g,et,e) (((et)->flags&(1u<<(e)))?NULL:luaT_gettm(et,e,(g)->\ -tmname[e])) -#define fasttm(l,et,e) gfasttm(G(l),et,e) -const TObject*luaT_gettm(Table*events,TMS event,TString*ename);const TObject* -luaT_gettmbyobj(lua_State*L,const TObject*o,TMS event);void luaT_init( -lua_State*L);extern const char*const luaT_typenames[]; -#endif -#line 14 "lstate.h" -#line 1 "lzio.h" -#ifndef lzio_h -#define lzio_h -#define EOZ (-1) -typedef struct Zio ZIO; -#define char2int(c) cast(int,cast(unsigned char,(c))) -#define zgetc(z) (((z)->n--)>0?char2int(*(z)->p++):luaZ_fill(z)) -#define zname(z) ((z)->name) -void luaZ_init(ZIO*z,lua_Chunkreader reader,void*data,const char*name);size_t -luaZ_read(ZIO*z,void*b,size_t n);int luaZ_lookahead(ZIO*z);typedef struct -Mbuffer{char*buffer;size_t buffsize;}Mbuffer;char*luaZ_openspace(lua_State*L, -Mbuffer*buff,size_t n); -#define luaZ_initbuffer(L, buff)((buff)->buffer=NULL,(buff)->buffsize=0) -#define luaZ_sizebuffer(buff) ((buff)->buffsize) -#define luaZ_buffer(buff) ((buff)->buffer) -#define luaZ_resizebuffer(L, buff,size)(luaM_reallocvector(L,(buff)->buffer,(\ -buff)->buffsize,size,char),(buff)->buffsize=size) -#define luaZ_freebuffer(L, buff)luaZ_resizebuffer(L,buff,0) -struct Zio{size_t n;const char*p;lua_Chunkreader reader;void*data;const char* -name;};int luaZ_fill(ZIO*z); -#endif -#line 15 "lstate.h" -#ifndef lua_lock -#define lua_lock(L) ((void)0) -#endif -#ifndef lua_unlock -#define lua_unlock(L) ((void)0) -#endif -#ifndef lua_userstateopen -#define lua_userstateopen(l) -#endif -struct lua_longjmp; -#define defaultmeta(L) (&G(L)->_defaultmeta) -#define gt(L) (&L->_gt) -#define registry(L) (&G(L)->_registry) -#define EXTRA_STACK 5 -#define BASIC_CI_SIZE 8 -#define BASIC_STACK_SIZE (2*LUA_MINSTACK) -typedef struct stringtable{GCObject**hash;ls_nstr nuse;int size;}stringtable; -typedef struct CallInfo{StkId base;StkId top;int state;union{struct{const -Instruction*savedpc;const Instruction**pc;int tailcalls;}l;struct{int dummy;}c -;}u;}CallInfo; -#define CI_C (1<<0) -#define CI_HASFRAME (1<<1) -#define CI_CALLING (1<<2) -#define CI_SAVEDPC (1<<3) -#define CI_YIELD (1<<4) -#define ci_func(ci) (clvalue((ci)->base-1)) -typedef struct global_State{stringtable strt;GCObject*rootgc;GCObject* -rootudata;GCObject*tmudata;Mbuffer buff;lu_mem GCthreshold;lu_mem nblocks; -lua_CFunction panic;TObject _registry;TObject _defaultmeta;struct lua_State* -mainthread;Node dummynode[1];TString*tmname[TM_N];}global_State;struct -lua_State{CommonHeader;StkId top;StkId base;global_State*l_G;CallInfo*ci;StkId - stack_last;StkId stack;int stacksize;CallInfo*end_ci;CallInfo*base_ci; -unsigned short size_ci;unsigned short nCcalls;lu_byte hookmask;lu_byte -allowhook;lu_byte hookinit;int basehookcount;int hookcount;lua_Hook hook; -TObject _gt;GCObject*openupval;GCObject*gclist;struct lua_longjmp*errorJmp; -ptrdiff_t errfunc;}; -#define G(L) (L->l_G) -union GCObject{GCheader gch;union TString ts;union Udata u;union Closure cl; -struct Table h;struct Proto p;struct UpVal uv;struct lua_State th;}; -#define gcotots(o) check_exp((o)->gch.tt==LUA_TSTRING,&((o)->ts)) -#define gcotou(o) check_exp((o)->gch.tt==LUA_TUSERDATA,&((o)->u)) -#define gcotocl(o) check_exp((o)->gch.tt==LUA_TFUNCTION,&((o)->cl)) -#define gcotoh(o) check_exp((o)->gch.tt==LUA_TTABLE,&((o)->h)) -#define gcotop(o) check_exp((o)->gch.tt==LUA_TPROTO,&((o)->p)) -#define gcotouv(o) check_exp((o)->gch.tt==LUA_TUPVAL,&((o)->uv)) -#define ngcotouv(o) check_exp((o)==NULL||(o)->gch.tt==LUA_TUPVAL,&((o)->uv)) -#define gcototh(o) check_exp((o)->gch.tt==LUA_TTHREAD,&((o)->th)) -#define valtogco(v) (cast(GCObject*,(v))) -lua_State*luaE_newthread(lua_State*L);void luaE_freethread(lua_State*L, -lua_State*L1); -#endif -#line 12 "ldebug.h" -#define pcRel(pc, p)(cast(int,(pc)-(p)->code)-1) -#define getline(f,pc) (((f)->lineinfo)?(f)->lineinfo[pc]:0) -#define resethookcount(L) (L->hookcount=L->basehookcount) -void luaG_inithooks(lua_State*L);void luaG_typeerror(lua_State*L,const TObject -*o,const char*opname);void luaG_concaterror(lua_State*L,StkId p1,StkId p2); -void luaG_aritherror(lua_State*L,const TObject*p1,const TObject*p2);int -luaG_ordererror(lua_State*L,const TObject*p1,const TObject*p2);void -luaG_runerror(lua_State*L,const char*fmt,...);void luaG_errormsg(lua_State*L); -int luaG_checkcode(const Proto*pt); -#endif -#line 17 "lapi.c" -#line 1 "ldo.h" -#ifndef ldo_h -#define ldo_h -#ifndef HARDSTACKTESTS -#define condhardstacktests(x) {} -#else -#define condhardstacktests(x) x -#endif -#define luaD_checkstack(L,n) if((char*)L->stack_last-(char*)L->top<=(n)*(int)\ -sizeof(TObject))luaD_growstack(L,n);else condhardstacktests(luaD_reallocstack(\ -L,L->stacksize)); -#define incr_top(L) {luaD_checkstack(L,1);L->top++;} -#define savestack(L,p) ((char*)(p)-(char*)L->stack) -#define restorestack(L,n) ((TObject*)((char*)L->stack+(n))) -#define saveci(L,p) ((char*)(p)-(char*)L->base_ci) -#define restoreci(L,n) ((CallInfo*)((char*)L->base_ci+(n))) -typedef void(*Pfunc)(lua_State*L,void*ud);void luaD_resetprotection(lua_State* -L);int luaD_protectedparser(lua_State*L,ZIO*z,int bin);void luaD_callhook( -lua_State*L,int event,int line);StkId luaD_precall(lua_State*L,StkId func); -void luaD_call(lua_State*L,StkId func,int nResults);int luaD_pcall(lua_State*L -,Pfunc func,void*u,ptrdiff_t oldtop,ptrdiff_t ef);void luaD_poscall(lua_State* -L,int wanted,StkId firstResult);void luaD_reallocCI(lua_State*L,int newsize); -void luaD_reallocstack(lua_State*L,int newsize);void luaD_growstack(lua_State* -L,int n);void luaD_throw(lua_State*L,int errcode);int luaD_rawrunprotected( -lua_State*L,Pfunc f,void*ud); -#endif -#line 18 "lapi.c" -#line 1 "lfunc.h" -#ifndef lfunc_h -#define lfunc_h -Proto*luaF_newproto(lua_State*L);Closure*luaF_newCclosure(lua_State*L,int -nelems);Closure*luaF_newLclosure(lua_State*L,int nelems,TObject*e);UpVal* -luaF_findupval(lua_State*L,StkId level);void luaF_close(lua_State*L,StkId -level);void luaF_freeproto(lua_State*L,Proto*f);void luaF_freeclosure( -lua_State*L,Closure*c);const char*luaF_getlocalname(const Proto*func,int -local_number,int pc); -#endif -#line 19 "lapi.c" -#line 1 "lgc.h" -#ifndef lgc_h -#define lgc_h -#define luaC_checkGC(L) {lua_assert(!(L->ci->state&CI_CALLING));if(G(L)->\ -nblocks>=G(L)->GCthreshold)luaC_collectgarbage(L);} -size_t luaC_separateudata(lua_State*L);void luaC_callGCTM(lua_State*L);void -luaC_sweep(lua_State*L,int all);void luaC_collectgarbage(lua_State*L);void -luaC_link(lua_State*L,GCObject*o,lu_byte tt); -#endif -#line 20 "lapi.c" -#line 1 "lmem.h" -#ifndef lmem_h -#define lmem_h -#define MEMERRMSG "not enough memory" -void*luaM_realloc(lua_State*L,void*oldblock,lu_mem oldsize,lu_mem size);void* -luaM_growaux(lua_State*L,void*block,int*size,int size_elem,int limit,const -char*errormsg); -#define luaM_free(L, b,s)luaM_realloc(L,(b),(s),0) -#define luaM_freelem(L, b)luaM_realloc(L,(b),sizeof(*(b)),0) -#define luaM_freearray(L, b,n,t)luaM_realloc(L,(b),cast(lu_mem,n)*cast(lu_mem,\ -sizeof(t)),0) -#define luaM_malloc(L, t)luaM_realloc(L,NULL,0,(t)) -#define luaM_new(L, t)cast(t*,luaM_malloc(L,sizeof(t))) -#define luaM_newvector(L, n,t)cast(t*,luaM_malloc(L,cast(lu_mem,n)*cast(lu_mem\ -,sizeof(t)))) -#define luaM_growvector(L,v,nelems,size,t,limit,e) if(((nelems)+1)>(size))((v)\ -=cast(t*,luaM_growaux(L,v,&(size),sizeof(t),limit,e))) -#define luaM_reallocvector(L, v,oldn,n,t)((v)=cast(t*,luaM_realloc(L,v,cast(\ -lu_mem,oldn)*cast(lu_mem,sizeof(t)),cast(lu_mem,n)*cast(lu_mem,sizeof(t))))) -#endif -#line 21 "lapi.c" -#line 1 "lstring.h" -#ifndef lstring_h -#define lstring_h -#define sizestring(l) (cast(lu_mem,sizeof(union TString))+(cast(lu_mem,l)+1)*\ -sizeof(char)) -#define sizeudata(l) (cast(lu_mem,sizeof(union Udata))+(l)) -#define luaS_new(L, s)(luaS_newlstr(L,s,strlen(s))) -#define luaS_newliteral(L, s)(luaS_newlstr(L,""s,(sizeof(s)/sizeof(char))-1)) -#define luaS_fix(s) ((s)->tsv.marked|=(1<<4)) -void luaS_resize(lua_State*L,int newsize);Udata*luaS_newudata(lua_State*L, -size_t s);void luaS_freeall(lua_State*L);TString*luaS_newlstr(lua_State*L, -const char*str,size_t l); -#endif -#line 24 "lapi.c" -#line 1 "ltable.h" -#ifndef ltable_h -#define ltable_h -#define gnode(t,i) (&(t)->node[i]) -#define gkey(n) (&(n)->i_key) -#define gval(n) (&(n)->i_val) -const TObject*luaH_getnum(Table*t,int key);TObject*luaH_setnum(lua_State*L, -Table*t,int key);const TObject*luaH_getstr(Table*t,TString*key);const TObject* -luaH_get(Table*t,const TObject*key);TObject*luaH_set(lua_State*L,Table*t,const - TObject*key);Table*luaH_new(lua_State*L,int narray,int lnhash);void luaH_free -(lua_State*L,Table*t);int luaH_next(lua_State*L,Table*t,StkId key);Node* -luaH_mainposition(const Table*t,const TObject*key); -#endif -#line 25 "lapi.c" -#line 1 "lundump.h" -#ifndef lundump_h -#define lundump_h -Proto*luaU_undump(lua_State*L,ZIO*Z,Mbuffer*buff);int luaU_endianness(void); -void luaU_dump(lua_State*L,const Proto*Main,lua_Chunkwriter w,void*data);void -luaU_print(const Proto*Main); -#define LUA_SIGNATURE "\033Lua" -#define VERSION 0x50 -#define VERSION0 0x50 -#define TEST_NUMBER ((lua_Number)3.14159265358979323846E7) -#endif -#line 27 "lapi.c" -#line 1 "lvm.h" -#ifndef lvm_h -#define lvm_h -#define tostring(L,o) ((ttype(o)==LUA_TSTRING)||(luaV_tostring(L,o))) -#define tonumber(o,n) (ttype(o)==LUA_TNUMBER||(((o)=luaV_tonumber(o,n))!=NULL)\ -) -#define equalobj(L,o1,o2) (ttype(o1)==ttype(o2)&&luaV_equalval(L,o1,o2)) -int luaV_lessthan(lua_State*L,const TObject*l,const TObject*r);int -luaV_equalval(lua_State*L,const TObject*t1,const TObject*t2);const TObject* -luaV_tonumber(const TObject*obj,TObject*n);int luaV_tostring(lua_State*L,StkId - obj);const TObject*luaV_gettable(lua_State*L,const TObject*t,TObject*key,int -loop);void luaV_settable(lua_State*L,const TObject*t,TObject*key,StkId val); -StkId luaV_execute(lua_State*L);void luaV_concat(lua_State*L,int total,int -last); -#endif -#line 28 "lapi.c" -const char lua_ident[]="$Lua: "LUA_VERSION" "LUA_COPYRIGHT" $\n""$Authors: " -LUA_AUTHORS" $\n""$URL: www.lua.org $\n"; -#ifndef api_check -#define api_check(L, o) -#endif -#define api_checknelems(L, n)api_check(L,(n)<=(L->top-L->base)) -#define api_incr_top(L) {api_check(L,L->topci->top);L->top++;} -static TObject*negindex(lua_State*L,int idx){if(idx>LUA_REGISTRYINDEX){ -api_check(L,idx!=0&&-idx<=L->top-L->base);return L->top+idx;}else switch(idx){ -case LUA_REGISTRYINDEX:return registry(L);case LUA_GLOBALSINDEX:return gt(L); -default:{TObject*func=(L->base-1);idx=LUA_GLOBALSINDEX-idx;lua_assert( -iscfunction(func));return(idx<=clvalue(func)->c.nupvalues)?&clvalue(func)->c. -upvalue[idx-1]:NULL;}}}static TObject*luaA_index(lua_State*L,int idx){if(idx>0 -){api_check(L,idx<=L->top-L->base);return L->base+idx-1;}else{TObject*o= -negindex(L,idx);api_check(L,o!=NULL);return o;}}static TObject* -luaA_indexAcceptable(lua_State*L,int idx){if(idx>0){TObject*o=L->base+(idx-1); -api_check(L,idx<=L->stack_last-L->base);if(o>=L->top)return NULL;else return o -;}else return negindex(L,idx);}void luaA_pushobject(lua_State*L,const TObject* -o){setobj2s(L->top,o);incr_top(L);}LUA_API int lua_checkstack(lua_State*L,int -size){int res;lua_lock(L);if((L->top-L->base+size)>LUA_MAXCSTACK)res=0;else{ -luaD_checkstack(L,size);if(L->ci->toptop+size)L->ci->top=L->top+size;res=1 -;}lua_unlock(L);return res;}LUA_API void lua_xmove(lua_State*from,lua_State*to -,int n){int i;lua_lock(to);api_checknelems(from,n);from->top-=n;for(i=0;itop,from->top+i);api_incr_top(to);}lua_unlock(to);}LUA_API -lua_CFunction lua_atpanic(lua_State*L,lua_CFunction panicf){lua_CFunction old; -lua_lock(L);old=G(L)->panic;G(L)->panic=panicf;lua_unlock(L);return old;} -LUA_API lua_State*lua_newthread(lua_State*L){lua_State*L1;lua_lock(L); -luaC_checkGC(L);L1=luaE_newthread(L);setthvalue(L->top,L1);api_incr_top(L); -lua_unlock(L);lua_userstateopen(L1);return L1;}LUA_API int lua_gettop( -lua_State*L){return(L->top-L->base);}LUA_API void lua_settop(lua_State*L,int -idx){lua_lock(L);if(idx>=0){api_check(L,idx<=L->stack_last-L->base);while(L-> -topbase+idx)setnilvalue(L->top++);L->top=L->base+idx;}else{api_check(L,-( -idx+1)<=(L->top-L->base));L->top+=idx+1;}lua_unlock(L);}LUA_API void -lua_remove(lua_State*L,int idx){StkId p;lua_lock(L);p=luaA_index(L,idx);while( -++ptop)setobjs2s(p-1,p);L->top--;lua_unlock(L);}LUA_API void lua_insert( -lua_State*L,int idx){StkId p;StkId q;lua_lock(L);p=luaA_index(L,idx);for(q=L-> -top;q>p;q--)setobjs2s(q,q-1);setobjs2s(p,L->top);lua_unlock(L);}LUA_API void -lua_replace(lua_State*L,int idx){lua_lock(L);api_checknelems(L,1);setobj( -luaA_index(L,idx),L->top-1);L->top--;lua_unlock(L);}LUA_API void lua_pushvalue -(lua_State*L,int idx){lua_lock(L);setobj2s(L->top,luaA_index(L,idx)); -api_incr_top(L);lua_unlock(L);}LUA_API int lua_type(lua_State*L,int idx){StkId - o=luaA_indexAcceptable(L,idx);return(o==NULL)?LUA_TNONE:ttype(o);}LUA_API -const char*lua_typename(lua_State*L,int t){UNUSED(L);return(t==LUA_TNONE)? -"no value":luaT_typenames[t];}LUA_API int lua_iscfunction(lua_State*L,int idx) -{StkId o=luaA_indexAcceptable(L,idx);return(o==NULL)?0:iscfunction(o);}LUA_API - int lua_isnumber(lua_State*L,int idx){TObject n;const TObject*o= -luaA_indexAcceptable(L,idx);return(o!=NULL&&tonumber(o,&n));}LUA_API int -lua_isstring(lua_State*L,int idx){int t=lua_type(L,idx);return(t==LUA_TSTRING -||t==LUA_TNUMBER);}LUA_API int lua_isuserdata(lua_State*L,int idx){const -TObject*o=luaA_indexAcceptable(L,idx);return(o!=NULL&&(ttisuserdata(o)|| -ttislightuserdata(o)));}LUA_API int lua_rawequal(lua_State*L,int index1,int -index2){StkId o1=luaA_indexAcceptable(L,index1);StkId o2=luaA_indexAcceptable( -L,index2);return(o1==NULL||o2==NULL)?0:luaO_rawequalObj(o1,o2);}LUA_API int -lua_equal(lua_State*L,int index1,int index2){StkId o1,o2;int i;lua_lock(L);o1= -luaA_indexAcceptable(L,index1);o2=luaA_indexAcceptable(L,index2);i=(o1==NULL|| -o2==NULL)?0:equalobj(L,o1,o2);lua_unlock(L);return i;}LUA_API int lua_lessthan -(lua_State*L,int index1,int index2){StkId o1,o2;int i;lua_lock(L);o1= -luaA_indexAcceptable(L,index1);o2=luaA_indexAcceptable(L,index2);i=(o1==NULL|| -o2==NULL)?0:luaV_lessthan(L,o1,o2);lua_unlock(L);return i;}LUA_API lua_Number -lua_tonumber(lua_State*L,int idx){TObject n;const TObject*o= -luaA_indexAcceptable(L,idx);if(o!=NULL&&tonumber(o,&n))return nvalue(o);else -return 0;}LUA_API int lua_toboolean(lua_State*L,int idx){const TObject*o= -luaA_indexAcceptable(L,idx);return(o!=NULL)&&!l_isfalse(o);}LUA_API const char -*lua_tostring(lua_State*L,int idx){StkId o=luaA_indexAcceptable(L,idx);if(o== -NULL)return NULL;else if(ttisstring(o))return svalue(o);else{const char*s; -lua_lock(L);s=(luaV_tostring(L,o)?svalue(o):NULL);luaC_checkGC(L);lua_unlock(L -);return s;}}LUA_API size_t lua_strlen(lua_State*L,int idx){StkId o= -luaA_indexAcceptable(L,idx);if(o==NULL)return 0;else if(ttisstring(o))return -tsvalue(o)->tsv.len;else{size_t l;lua_lock(L);l=(luaV_tostring(L,o)?tsvalue(o) -->tsv.len:0);lua_unlock(L);return l;}}LUA_API lua_CFunction lua_tocfunction( -lua_State*L,int idx){StkId o=luaA_indexAcceptable(L,idx);return(o==NULL||! -iscfunction(o))?NULL:clvalue(o)->c.f;}LUA_API void*lua_touserdata(lua_State*L, -int idx){StkId o=luaA_indexAcceptable(L,idx);if(o==NULL)return NULL;switch( -ttype(o)){case LUA_TUSERDATA:return(uvalue(o)+1);case LUA_TLIGHTUSERDATA: -return pvalue(o);default:return NULL;}}LUA_API lua_State*lua_tothread( -lua_State*L,int idx){StkId o=luaA_indexAcceptable(L,idx);return(o==NULL||! -ttisthread(o))?NULL:thvalue(o);}LUA_API const void*lua_topointer(lua_State*L, -int idx){StkId o=luaA_indexAcceptable(L,idx);if(o==NULL)return NULL;else{ -switch(ttype(o)){case LUA_TTABLE:return hvalue(o);case LUA_TFUNCTION:return -clvalue(o);case LUA_TTHREAD:return thvalue(o);case LUA_TUSERDATA:case -LUA_TLIGHTUSERDATA:return lua_touserdata(L,idx);default:return NULL;}}}LUA_API - void lua_pushnil(lua_State*L){lua_lock(L);setnilvalue(L->top);api_incr_top(L) -;lua_unlock(L);}LUA_API void lua_pushnumber(lua_State*L,lua_Number n){lua_lock -(L);setnvalue(L->top,n);api_incr_top(L);lua_unlock(L);}LUA_API void -lua_pushlstring(lua_State*L,const char*s,size_t len){lua_lock(L);luaC_checkGC( -L);setsvalue2s(L->top,luaS_newlstr(L,s,len));api_incr_top(L);lua_unlock(L);} -LUA_API void lua_pushstring(lua_State*L,const char*s){if(s==NULL)lua_pushnil(L -);else lua_pushlstring(L,s,strlen(s));}LUA_API const char*lua_pushvfstring( -lua_State*L,const char*fmt,va_list argp){const char*ret;lua_lock(L); -luaC_checkGC(L);ret=luaO_pushvfstring(L,fmt,argp);lua_unlock(L);return ret;} -LUA_API const char*lua_pushfstring(lua_State*L,const char*fmt,...){const char* -ret;va_list argp;lua_lock(L);luaC_checkGC(L);va_start(argp,fmt);ret= -luaO_pushvfstring(L,fmt,argp);va_end(argp);lua_unlock(L);return ret;}LUA_API -void lua_pushcclosure(lua_State*L,lua_CFunction fn,int n){Closure*cl;lua_lock( -L);luaC_checkGC(L);api_checknelems(L,n);cl=luaF_newCclosure(L,n);cl->c.f=fn;L -->top-=n;while(n--)setobj2n(&cl->c.upvalue[n],L->top+n);setclvalue(L->top,cl); -api_incr_top(L);lua_unlock(L);}LUA_API void lua_pushboolean(lua_State*L,int b) -{lua_lock(L);setbvalue(L->top,(b!=0));api_incr_top(L);lua_unlock(L);}LUA_API -void lua_pushlightuserdata(lua_State*L,void*p){lua_lock(L);setpvalue(L->top,p) -;api_incr_top(L);lua_unlock(L);}LUA_API void lua_gettable(lua_State*L,int idx) -{StkId t;lua_lock(L);t=luaA_index(L,idx);setobj2s(L->top-1,luaV_gettable(L,t,L -->top-1,0));lua_unlock(L);}LUA_API void lua_rawget(lua_State*L,int idx){StkId -t;lua_lock(L);t=luaA_index(L,idx);api_check(L,ttistable(t));setobj2s(L->top-1, -luaH_get(hvalue(t),L->top-1));lua_unlock(L);}LUA_API void lua_rawgeti( -lua_State*L,int idx,int n){StkId o;lua_lock(L);o=luaA_index(L,idx);api_check(L -,ttistable(o));setobj2s(L->top,luaH_getnum(hvalue(o),n));api_incr_top(L); -lua_unlock(L);}LUA_API void lua_newtable(lua_State*L){lua_lock(L);luaC_checkGC -(L);sethvalue(L->top,luaH_new(L,0,0));api_incr_top(L);lua_unlock(L);}LUA_API -int lua_getmetatable(lua_State*L,int objindex){const TObject*obj;Table*mt=NULL -;int res;lua_lock(L);obj=luaA_indexAcceptable(L,objindex);if(obj!=NULL){switch -(ttype(obj)){case LUA_TTABLE:mt=hvalue(obj)->metatable;break;case -LUA_TUSERDATA:mt=uvalue(obj)->uv.metatable;break;}}if(mt==NULL||mt==hvalue( -defaultmeta(L)))res=0;else{sethvalue(L->top,mt);api_incr_top(L);res=1;} -lua_unlock(L);return res;}LUA_API void lua_getfenv(lua_State*L,int idx){StkId -o;lua_lock(L);o=luaA_index(L,idx);setobj2s(L->top,isLfunction(o)?&clvalue(o)-> -l.g:gt(L));api_incr_top(L);lua_unlock(L);}LUA_API void lua_settable(lua_State* -L,int idx){StkId t;lua_lock(L);api_checknelems(L,2);t=luaA_index(L,idx); -luaV_settable(L,t,L->top-2,L->top-1);L->top-=2;lua_unlock(L);}LUA_API void -lua_rawset(lua_State*L,int idx){StkId t;lua_lock(L);api_checknelems(L,2);t= -luaA_index(L,idx);api_check(L,ttistable(t));setobj2t(luaH_set(L,hvalue(t),L-> -top-2),L->top-1);L->top-=2;lua_unlock(L);}LUA_API void lua_rawseti(lua_State*L -,int idx,int n){StkId o;lua_lock(L);api_checknelems(L,1);o=luaA_index(L,idx); -api_check(L,ttistable(o));setobj2t(luaH_setnum(L,hvalue(o),n),L->top-1);L->top ---;lua_unlock(L);}LUA_API int lua_setmetatable(lua_State*L,int objindex){ -TObject*obj,*mt;int res=1;lua_lock(L);api_checknelems(L,1);obj=luaA_index(L, -objindex);mt=(!ttisnil(L->top-1))?L->top-1:defaultmeta(L);api_check(L, -ttistable(mt));switch(ttype(obj)){case LUA_TTABLE:{hvalue(obj)->metatable= -hvalue(mt);break;}case LUA_TUSERDATA:{uvalue(obj)->uv.metatable=hvalue(mt); -break;}default:{res=0;break;}}L->top--;lua_unlock(L);return res;}LUA_API int -lua_setfenv(lua_State*L,int idx){StkId o;int res=0;lua_lock(L);api_checknelems -(L,1);o=luaA_index(L,idx);L->top--;api_check(L,ttistable(L->top));if( -isLfunction(o)){res=1;clvalue(o)->l.g=*(L->top);}lua_unlock(L);return res;} -LUA_API void lua_call(lua_State*L,int nargs,int nresults){StkId func;lua_lock( -L);api_checknelems(L,nargs+1);func=L->top-(nargs+1);luaD_call(L,func,nresults) -;lua_unlock(L);}struct CallS{StkId func;int nresults;};static void f_call( -lua_State*L,void*ud){struct CallS*c=cast(struct CallS*,ud);luaD_call(L,c->func -,c->nresults);}LUA_API int lua_pcall(lua_State*L,int nargs,int nresults,int -errfunc){struct CallS c;int status;ptrdiff_t func;lua_lock(L);func=(errfunc==0 -)?0:savestack(L,luaA_index(L,errfunc));c.func=L->top-(nargs+1);c.nresults= -nresults;status=luaD_pcall(L,f_call,&c,savestack(L,c.func),func);lua_unlock(L) -;return status;}struct CCallS{lua_CFunction func;void*ud;};static void f_Ccall -(lua_State*L,void*ud){struct CCallS*c=cast(struct CCallS*,ud);Closure*cl;cl= -luaF_newCclosure(L,0);cl->c.f=c->func;setclvalue(L->top,cl);incr_top(L); -setpvalue(L->top,c->ud);incr_top(L);luaD_call(L,L->top-2,0);}LUA_API int -lua_cpcall(lua_State*L,lua_CFunction func,void*ud){struct CCallS c;int status; -lua_lock(L);c.func=func;c.ud=ud;status=luaD_pcall(L,f_Ccall,&c,savestack(L,L-> -top),0);lua_unlock(L);return status;}LUA_API int lua_load(lua_State*L, -lua_Chunkreader reader,void*data,const char*chunkname){ZIO z;int status;int c; -lua_lock(L);if(!chunkname)chunkname="?";luaZ_init(&z,reader,data,chunkname);c= -luaZ_lookahead(&z);status=luaD_protectedparser(L,&z,(c==LUA_SIGNATURE[0])); -lua_unlock(L);return status;}LUA_API int lua_dump(lua_State*L,lua_Chunkwriter -writer,void*data){int status;TObject*o;lua_lock(L);api_checknelems(L,1);o=L-> -top-1;if(isLfunction(o)&&clvalue(o)->l.nupvalues==0){luaU_dump(L,clvalue(o)->l -.p,writer,data);status=1;}else status=0;lua_unlock(L);return status;} -#define GCscalel(x) ((x)>>10) -#define GCscale(x) (cast(int,GCscalel(x))) -#define GCunscale(x) (cast(lu_mem,x)<<10) -LUA_API int lua_getgcthreshold(lua_State*L){int threshold;lua_lock(L); -threshold=GCscale(G(L)->GCthreshold);lua_unlock(L);return threshold;}LUA_API -int lua_getgccount(lua_State*L){int count;lua_lock(L);count=GCscale(G(L)-> -nblocks);lua_unlock(L);return count;}LUA_API void lua_setgcthreshold(lua_State -*L,int newthreshold){lua_lock(L);if(cast(lu_mem,newthreshold)>GCscalel( -MAX_LUMEM))G(L)->GCthreshold=MAX_LUMEM;else G(L)->GCthreshold=GCunscale( -newthreshold);luaC_checkGC(L);lua_unlock(L);}LUA_API const char*lua_version( -void){return LUA_VERSION;}LUA_API int lua_error(lua_State*L){lua_lock(L); -api_checknelems(L,1);luaG_errormsg(L);lua_unlock(L);return 0;}LUA_API int -lua_next(lua_State*L,int idx){StkId t;int more;lua_lock(L);t=luaA_index(L,idx) -;api_check(L,ttistable(t));more=luaH_next(L,hvalue(t),L->top-1);if(more){ -api_incr_top(L);}else L->top-=1;lua_unlock(L);return more;}LUA_API void -lua_concat(lua_State*L,int n){lua_lock(L);luaC_checkGC(L);api_checknelems(L,n) -;if(n>=2){luaV_concat(L,n,L->top-L->base-1);L->top-=(n-1);}else if(n==0){ -setsvalue2s(L->top,luaS_newlstr(L,NULL,0));api_incr_top(L);}lua_unlock(L);} -LUA_API void*lua_newuserdata(lua_State*L,size_t size){Udata*u;lua_lock(L); -luaC_checkGC(L);u=luaS_newudata(L,size);setuvalue(L->top,u);api_incr_top(L); -lua_unlock(L);return u+1;}LUA_API int lua_pushupvalues(lua_State*L){Closure* -func;int n,i;lua_lock(L);api_check(L,iscfunction(L->base-1));func=clvalue(L-> -base-1);n=func->c.nupvalues;luaD_checkstack(L,n+LUA_MINSTACK);for(i=0;itop,&func->c.upvalue[i]);L->top++;}lua_unlock(L);return n;}static - const char*aux_upvalue(lua_State*L,int funcindex,int n,TObject**val){Closure* -f;StkId fi=luaA_index(L,funcindex);if(!ttisfunction(fi))return NULL;f=clvalue( -fi);if(f->c.isC){if(n>f->c.nupvalues)return NULL;*val=&f->c.upvalue[n-1]; -return"";}else{Proto*p=f->l.p;if(n>p->sizeupvalues)return NULL;*val=f->l. -upvals[n-1]->v;return getstr(p->upvalues[n-1]);}}LUA_API const char* -lua_getupvalue(lua_State*L,int funcindex,int n){const char*name;TObject*val; -lua_lock(L);name=aux_upvalue(L,funcindex,n,&val);if(name){setobj2s(L->top,val) -;api_incr_top(L);}lua_unlock(L);return name;}LUA_API const char*lua_setupvalue -(lua_State*L,int funcindex,int n){const char*name;TObject*val;lua_lock(L); -api_checknelems(L,1);name=aux_upvalue(L,funcindex,n,&val);if(name){L->top--; -setobj(val,L->top);}lua_unlock(L);return name;} -#line 1 "lauxlib.c" -#define lauxlib_c -#line 1 "lauxlib.h" -#ifndef lauxlib_h -#define lauxlib_h -#ifndef LUALIB_API -#define LUALIB_API LUA_API -#endif -typedef struct luaL_reg{const char*name;lua_CFunction func;}luaL_reg; -LUALIB_API void luaL_openlib(lua_State*L,const char*libname,const luaL_reg*l, -int nup);LUALIB_API int luaL_getmetafield(lua_State*L,int obj,const char*e); -LUALIB_API int luaL_callmeta(lua_State*L,int obj,const char*e);LUALIB_API int -luaL_typerror(lua_State*L,int narg,const char*tname);LUALIB_API int -luaL_argerror(lua_State*L,int numarg,const char*extramsg);LUALIB_API const -char*luaL_checklstring(lua_State*L,int numArg,size_t*l);LUALIB_API const char* -luaL_optlstring(lua_State*L,int numArg,const char*def,size_t*l);LUALIB_API -lua_Number luaL_checknumber(lua_State*L,int numArg);LUALIB_API lua_Number -luaL_optnumber(lua_State*L,int nArg,lua_Number def);LUALIB_API void -luaL_checkstack(lua_State*L,int sz,const char*msg);LUALIB_API void -luaL_checktype(lua_State*L,int narg,int t);LUALIB_API void luaL_checkany( -lua_State*L,int narg);LUALIB_API int luaL_newmetatable(lua_State*L,const char* -tname);LUALIB_API void luaL_getmetatable(lua_State*L,const char*tname); -LUALIB_API void*luaL_checkudata(lua_State*L,int ud,const char*tname); -LUALIB_API void luaL_where(lua_State*L,int lvl);LUALIB_API int luaL_error( -lua_State*L,const char*fmt,...);LUALIB_API int luaL_findstring(const char*st, -const char*const lst[]);LUALIB_API int luaL_ref(lua_State*L,int t);LUALIB_API -void luaL_unref(lua_State*L,int t,int ref);LUALIB_API int luaL_getn(lua_State* -L,int t);LUALIB_API void luaL_setn(lua_State*L,int t,int n);LUALIB_API int -luaL_loadfile(lua_State*L,const char*filename);LUALIB_API int luaL_loadbuffer( -lua_State*L,const char*buff,size_t sz,const char*name); -#define luaL_argcheck(L, cond,numarg,extramsg)if(!(cond))luaL_argerror(L,\ -numarg,extramsg) -#define luaL_checkstring(L,n) (luaL_checklstring(L,(n),NULL)) -#define luaL_optstring(L,n,d) (luaL_optlstring(L,(n),(d),NULL)) -#define luaL_checkint(L,n) ((int)luaL_checknumber(L,n)) -#define luaL_checklong(L,n) ((long)luaL_checknumber(L,n)) -#define luaL_optint(L,n,d) ((int)luaL_optnumber(L,n,(lua_Number)(d))) -#define luaL_optlong(L,n,d) ((long)luaL_optnumber(L,n,(lua_Number)(d))) -#ifndef LUAL_BUFFERSIZE -#define LUAL_BUFFERSIZE BUFSIZ -#endif -typedef struct luaL_Buffer{char*p;int lvl;lua_State*L;char buffer[ -LUAL_BUFFERSIZE];}luaL_Buffer; -#define luaL_putchar(B,c) ((void)((B)->p<((B)->buffer+LUAL_BUFFERSIZE)||\ -luaL_prepbuffer(B)),(*(B)->p++=(char)(c))) -#define luaL_addsize(B,n) ((B)->p+=(n)) -LUALIB_API void luaL_buffinit(lua_State*L,luaL_Buffer*B);LUALIB_API char* -luaL_prepbuffer(luaL_Buffer*B);LUALIB_API void luaL_addlstring(luaL_Buffer*B, -const char*s,size_t l);LUALIB_API void luaL_addstring(luaL_Buffer*B,const char -*s);LUALIB_API void luaL_addvalue(luaL_Buffer*B);LUALIB_API void -luaL_pushresult(luaL_Buffer*B);LUALIB_API int lua_dofile(lua_State*L,const -char*filename);LUALIB_API int lua_dostring(lua_State*L,const char*str); -LUALIB_API int lua_dobuffer(lua_State*L,const char*buff,size_t sz,const char*n -); -#define luaL_check_lstr luaL_checklstring -#define luaL_opt_lstr luaL_optlstring -#define luaL_check_number luaL_checknumber -#define luaL_opt_number luaL_optnumber -#define luaL_arg_check luaL_argcheck -#define luaL_check_string luaL_checkstring -#define luaL_opt_string luaL_optstring -#define luaL_check_int luaL_checkint -#define luaL_check_long luaL_checklong -#define luaL_opt_int luaL_optint -#define luaL_opt_long luaL_optlong -#endif -#line 24 "lauxlib.c" -#define RESERVED_REFS 2 -#define FREELIST_REF 1 -#define ARRAYSIZE_REF 2 -#define abs_index(L, i)((i)>0||(i)<=LUA_REGISTRYINDEX?(i):lua_gettop(L)+(i)+1) -LUALIB_API int luaL_argerror(lua_State*L,int narg,const char*extramsg){ -lua_Debug ar;lua_getstack(L,0,&ar);lua_getinfo(L,"n",&ar);if(strcmp(ar. -namewhat,"method")==0){narg--;if(narg==0)return luaL_error(L, -"calling `%s' on bad self (%s)",ar.name,extramsg);}if(ar.name==NULL)ar.name= -"?";return luaL_error(L,"bad argument #%d to `%s' (%s)",narg,ar.name,extramsg) -;}LUALIB_API int luaL_typerror(lua_State*L,int narg,const char*tname){const -char*msg=lua_pushfstring(L,"%s expected, got %s",tname,lua_typename(L,lua_type -(L,narg)));return luaL_argerror(L,narg,msg);}static void tag_error(lua_State*L -,int narg,int tag){luaL_typerror(L,narg,lua_typename(L,tag));}LUALIB_API void -luaL_where(lua_State*L,int level){lua_Debug ar;if(lua_getstack(L,level,&ar)){ -lua_getinfo(L,"Snl",&ar);if(ar.currentline>0){lua_pushfstring(L,"%s:%d: ",ar. -short_src,ar.currentline);return;}}lua_pushliteral(L,"");}LUALIB_API int -luaL_error(lua_State*L,const char*fmt,...){va_list argp;va_start(argp,fmt); -luaL_where(L,1);lua_pushvfstring(L,fmt,argp);va_end(argp);lua_concat(L,2); -return lua_error(L);}LUALIB_API int luaL_findstring(const char*name,const char -*const list[]){int i;for(i=0;list[i];i++)if(strcmp(list[i],name)==0)return i; -return-1;}LUALIB_API int luaL_newmetatable(lua_State*L,const char*tname){ -lua_pushstring(L,tname);lua_rawget(L,LUA_REGISTRYINDEX);if(!lua_isnil(L,-1)) -return 0;lua_pop(L,1);lua_newtable(L);lua_pushstring(L,tname);lua_pushvalue(L, --2);lua_rawset(L,LUA_REGISTRYINDEX);lua_pushvalue(L,-1);lua_pushstring(L,tname -);lua_rawset(L,LUA_REGISTRYINDEX);return 1;}LUALIB_API void luaL_getmetatable( -lua_State*L,const char*tname){lua_pushstring(L,tname);lua_rawget(L, -LUA_REGISTRYINDEX);}LUALIB_API void*luaL_checkudata(lua_State*L,int ud,const -char*tname){const char*tn;if(!lua_getmetatable(L,ud))return NULL;lua_rawget(L, -LUA_REGISTRYINDEX);tn=lua_tostring(L,-1);if(tn&&(strcmp(tn,tname)==0)){lua_pop -(L,1);return lua_touserdata(L,ud);}else{lua_pop(L,1);return NULL;}}LUALIB_API -void luaL_checkstack(lua_State*L,int space,const char*mes){if(!lua_checkstack( -L,space))luaL_error(L,"stack overflow (%s)",mes);}LUALIB_API void -luaL_checktype(lua_State*L,int narg,int t){if(lua_type(L,narg)!=t)tag_error(L, -narg,t);}LUALIB_API void luaL_checkany(lua_State*L,int narg){if(lua_type(L, -narg)==LUA_TNONE)luaL_argerror(L,narg,"value expected");}LUALIB_API const char -*luaL_checklstring(lua_State*L,int narg,size_t*len){const char*s=lua_tostring( -L,narg);if(!s)tag_error(L,narg,LUA_TSTRING);if(len)*len=lua_strlen(L,narg); -return s;}LUALIB_API const char*luaL_optlstring(lua_State*L,int narg,const -char*def,size_t*len){if(lua_isnoneornil(L,narg)){if(len)*len=(def?strlen(def): -0);return def;}else return luaL_checklstring(L,narg,len);}LUALIB_API -lua_Number luaL_checknumber(lua_State*L,int narg){lua_Number d=lua_tonumber(L, -narg);if(d==0&&!lua_isnumber(L,narg))tag_error(L,narg,LUA_TNUMBER);return d;} -LUALIB_API lua_Number luaL_optnumber(lua_State*L,int narg,lua_Number def){if( -lua_isnoneornil(L,narg))return def;else return luaL_checknumber(L,narg);} -LUALIB_API int luaL_getmetafield(lua_State*L,int obj,const char*event){if(! -lua_getmetatable(L,obj))return 0;lua_pushstring(L,event);lua_rawget(L,-2);if( -lua_isnil(L,-1)){lua_pop(L,2);return 0;}else{lua_remove(L,-2);return 1;}} -LUALIB_API int luaL_callmeta(lua_State*L,int obj,const char*event){obj= -abs_index(L,obj);if(!luaL_getmetafield(L,obj,event))return 0;lua_pushvalue(L, -obj);lua_call(L,1,1);return 1;}LUALIB_API void luaL_openlib(lua_State*L,const -char*libname,const luaL_reg*l,int nup){if(libname){lua_pushstring(L,libname); -lua_gettable(L,LUA_GLOBALSINDEX);if(lua_isnil(L,-1)){lua_pop(L,1);lua_newtable -(L);lua_pushstring(L,libname);lua_pushvalue(L,-2);lua_settable(L, -LUA_GLOBALSINDEX);}lua_insert(L,-(nup+1));}for(;l->name;l++){int i; -lua_pushstring(L,l->name);for(i=0;ifunc,nup);lua_settable(L,-(nup+3));}lua_pop(L,nup);} -static int checkint(lua_State*L,int topop){int n=(int)lua_tonumber(L,-1);if(n -==0&&!lua_isnumber(L,-1))n=-1;lua_pop(L,topop);return n;}static void getsizes( -lua_State*L){lua_rawgeti(L,LUA_REGISTRYINDEX,ARRAYSIZE_REF);if(lua_isnil(L,-1) -){lua_pop(L,1);lua_newtable(L);lua_pushvalue(L,-1);lua_setmetatable(L,-2); -lua_pushliteral(L,"__mode");lua_pushliteral(L,"k");lua_rawset(L,-3); -lua_pushvalue(L,-1);lua_rawseti(L,LUA_REGISTRYINDEX,ARRAYSIZE_REF);}}void -luaL_setn(lua_State*L,int t,int n){t=abs_index(L,t);lua_pushliteral(L,"n"); -lua_rawget(L,t);if(checkint(L,1)>=0){lua_pushliteral(L,"n");lua_pushnumber(L,( -lua_Number)n);lua_rawset(L,t);}else{getsizes(L);lua_pushvalue(L,t); -lua_pushnumber(L,(lua_Number)n);lua_rawset(L,-3);lua_pop(L,1);}}int luaL_getn( -lua_State*L,int t){int n;t=abs_index(L,t);lua_pushliteral(L,"n");lua_rawget(L, -t);if((n=checkint(L,1))>=0)return n;getsizes(L);lua_pushvalue(L,t);lua_rawget( -L,-2);if((n=checkint(L,2))>=0)return n;for(n=1;;n++){lua_rawgeti(L,t,n);if( -lua_isnil(L,-1))break;lua_pop(L,1);}lua_pop(L,1);return n-1;} -#define bufflen(B) ((B)->p-(B)->buffer) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE-bufflen(B))) -#define LIMIT (LUA_MINSTACK/2) -static int emptybuffer(luaL_Buffer*B){size_t l=bufflen(B);if(l==0)return 0; -else{lua_pushlstring(B->L,B->buffer,l);B->p=B->buffer;B->lvl++;return 1;}} -static void adjuststack(luaL_Buffer*B){if(B->lvl>1){lua_State*L=B->L;int toget -=1;size_t toplen=lua_strlen(L,-1);do{size_t l=lua_strlen(L,-(toget+1));if(B-> -lvl-toget+1>=LIMIT||toplen>l){toplen+=l;toget++;}else break;}while(toget -lvl);lua_concat(L,toget);B->lvl=B->lvl-toget+1;}}LUALIB_API char* -luaL_prepbuffer(luaL_Buffer*B){if(emptybuffer(B))adjuststack(B);return B-> -buffer;}LUALIB_API void luaL_addlstring(luaL_Buffer*B,const char*s,size_t l){ -while(l--)luaL_putchar(B,*s++);}LUALIB_API void luaL_addstring(luaL_Buffer*B, -const char*s){luaL_addlstring(B,s,strlen(s));}LUALIB_API void luaL_pushresult( -luaL_Buffer*B){emptybuffer(B);lua_concat(B->L,B->lvl);B->lvl=1;}LUALIB_API -void luaL_addvalue(luaL_Buffer*B){lua_State*L=B->L;size_t vl=lua_strlen(L,-1); -if(vl<=bufffree(B)){memcpy(B->p,lua_tostring(L,-1),vl);B->p+=vl;lua_pop(L,1);} -else{if(emptybuffer(B))lua_insert(L,-2);B->lvl++;adjuststack(B);}}LUALIB_API -void luaL_buffinit(lua_State*L,luaL_Buffer*B){B->L=L;B->p=B->buffer;B->lvl=0;} -LUALIB_API int luaL_ref(lua_State*L,int t){int ref;t=abs_index(L,t);if( -lua_isnil(L,-1)){lua_pop(L,1);return LUA_REFNIL;}lua_rawgeti(L,t,FREELIST_REF) -;ref=(int)lua_tonumber(L,-1);lua_pop(L,1);if(ref!=0){lua_rawgeti(L,t,ref); -lua_rawseti(L,t,FREELIST_REF);}else{ref=luaL_getn(L,t);if(ref=0){t=abs_index(L -,t);lua_rawgeti(L,t,FREELIST_REF);lua_rawseti(L,t,ref);lua_pushnumber(L,( -lua_Number)ref);lua_rawseti(L,t,FREELIST_REF);}}typedef struct LoadF{FILE*f; -char buff[LUAL_BUFFERSIZE];}LoadF;static const char*getF(lua_State*L,void*ud, -size_t*size){LoadF*lf=(LoadF*)ud;(void)L;if(feof(lf->f))return NULL;*size= -fread(lf->buff,1,LUAL_BUFFERSIZE,lf->f);return(*size>0)?lf->buff:NULL;}static -int errfile(lua_State*L,int fnameindex){const char*filename=lua_tostring(L, -fnameindex)+1;lua_pushfstring(L,"cannot read %s: %s",filename,strerror(errno)) -;lua_remove(L,fnameindex);return LUA_ERRFILE;}LUALIB_API int luaL_loadfile( -lua_State*L,const char*filename){LoadF lf;int status,readstatus;int c;int -fnameindex=lua_gettop(L)+1;if(filename==NULL){lua_pushliteral(L,"=stdin");lf.f -=stdin;}else{lua_pushfstring(L,"@%s",filename);lf.f=fopen(filename,"r");}if(lf -.f==NULL)return errfile(L,fnameindex);c=ungetc(getc(lf.f),lf.f);if(!(isspace(c -)||isprint(c))&&lf.f!=stdin){fclose(lf.f);lf.f=fopen(filename,"rb");if(lf.f== -NULL)return errfile(L,fnameindex);}status=lua_load(L,getF,&lf,lua_tostring(L,- -1));readstatus=ferror(lf.f);if(lf.f!=stdin)fclose(lf.f);if(readstatus){ -lua_settop(L,fnameindex);return errfile(L,fnameindex);}lua_remove(L,fnameindex -);return status;}typedef struct LoadS{const char*s;size_t size;}LoadS;static -const char*getS(lua_State*L,void*ud,size_t*size){LoadS*ls=(LoadS*)ud;(void)L; -if(ls->size==0)return NULL;*size=ls->size;ls->size=0;return ls->s;}LUALIB_API -int luaL_loadbuffer(lua_State*L,const char*buff,size_t size,const char*name){ -LoadS ls;ls.s=buff;ls.size=size;return lua_load(L,getS,&ls,name);}static void -callalert(lua_State*L,int status){if(status!=0){lua_getglobal(L,"_ALERT");if( -lua_isfunction(L,-1)){lua_insert(L,-2);lua_call(L,1,0);}else{fprintf(stderr, -"%s\n",lua_tostring(L,-2));lua_pop(L,2);}}}static int aux_do(lua_State*L,int -status){if(status==0){status=lua_pcall(L,0,LUA_MULTRET,0);}callalert(L,status) -;return status;}LUALIB_API int lua_dofile(lua_State*L,const char*filename){ -return aux_do(L,luaL_loadfile(L,filename));}LUALIB_API int lua_dobuffer( -lua_State*L,const char*buff,size_t size,const char*name){return aux_do(L, -luaL_loadbuffer(L,buff,size,name));}LUALIB_API int lua_dostring(lua_State*L, -const char*str){return lua_dobuffer(L,str,strlen(str),str);} -#line 1 "lbaselib.c" -#define lbaselib_c -#line 1 "lualib.h" -#ifndef lualib_h -#define lualib_h -#ifndef LUALIB_API -#define LUALIB_API LUA_API -#endif -#define LUA_COLIBNAME "coroutine" -LUALIB_API int luaopen_base(lua_State*L); -#define LUA_TABLIBNAME "table" -LUALIB_API int luaopen_table(lua_State*L); -#define LUA_IOLIBNAME "io" -#define LUA_OSLIBNAME "os" -LUALIB_API int luaopen_io(lua_State*L); -#define LUA_STRLIBNAME "string" -LUALIB_API int luaopen_string(lua_State*L); -#define LUA_MATHLIBNAME "math" -LUALIB_API int luaopen_math(lua_State*L); -#define LUA_DBLIBNAME "debug" -LUALIB_API int luaopen_debug(lua_State*L);LUALIB_API int luaopen_loadlib( -lua_State*L); -#ifndef lua_assert -#define lua_assert(c) -#endif -#define lua_baselibopen luaopen_base -#define lua_tablibopen luaopen_table -#define lua_iolibopen luaopen_io -#define lua_strlibopen luaopen_string -#define lua_mathlibopen luaopen_math -#define lua_dblibopen luaopen_debug -#endif -#line 20 "lbaselib.c" -static int luaB_print(lua_State*L){int n=lua_gettop(L);int i;lua_getglobal(L, -"tostring");for(i=1;i<=n;i++){const char*s;lua_pushvalue(L,-1);lua_pushvalue(L -,i);lua_call(L,1,1);s=lua_tostring(L,-1);if(s==NULL)return luaL_error(L, -"`tostring' must return a string to `print'");if(i>1)fputs("\t",stdout);fputs( -s,stdout);lua_pop(L,1);}fputs("\n",stdout);return 0;}static int luaB_tonumber( -lua_State*L){int base=luaL_optint(L,2,10);if(base==10){luaL_checkany(L,1);if( -lua_isnumber(L,1)){lua_pushnumber(L,lua_tonumber(L,1));return 1;}}else{const -char*s1=luaL_checkstring(L,1);char*s2;unsigned long n;luaL_argcheck(L,2<=base -&&base<=36,2,"base out of range");n=strtoul(s1,&s2,base);if(s1!=s2){while( -isspace((unsigned char)(*s2)))s2++;if(*s2=='\0'){lua_pushnumber(L,(lua_Number) -n);return 1;}}}lua_pushnil(L);return 1;}static int luaB_error(lua_State*L){int - level=luaL_optint(L,2,1);luaL_checkany(L,1);if(!lua_isstring(L,1)||level==0) -lua_pushvalue(L,1);else{luaL_where(L,level);lua_pushvalue(L,1);lua_concat(L,2) -;}return lua_error(L);}static int luaB_getmetatable(lua_State*L){luaL_checkany -(L,1);if(!lua_getmetatable(L,1)){lua_pushnil(L);return 1;}luaL_getmetafield(L, -1,"__metatable");return 1;}static int luaB_setmetatable(lua_State*L){int t= -lua_type(L,2);luaL_checktype(L,1,LUA_TTABLE);luaL_argcheck(L,t==LUA_TNIL||t== -LUA_TTABLE,2,"nil or table expected");if(luaL_getmetafield(L,1,"__metatable")) -luaL_error(L,"cannot change a protected metatable");lua_settop(L,2); -lua_setmetatable(L,1);return 1;}static void getfunc(lua_State*L){if( -lua_isfunction(L,1))lua_pushvalue(L,1);else{lua_Debug ar;int level=luaL_optint -(L,1,1);luaL_argcheck(L,level>=0,1,"level must be non-negative");if( -lua_getstack(L,level,&ar)==0)luaL_argerror(L,1,"invalid level");lua_getinfo(L, -"f",&ar);if(lua_isnil(L,-1))luaL_error(L, -"no function environment for tail call at level %d",level);}}static int -aux_getfenv(lua_State*L){lua_getfenv(L,-1);lua_pushliteral(L,"__fenv"); -lua_rawget(L,-2);return!lua_isnil(L,-1);}static int luaB_getfenv(lua_State*L){ -getfunc(L);if(!aux_getfenv(L))lua_pop(L,1);return 1;}static int luaB_setfenv( -lua_State*L){luaL_checktype(L,2,LUA_TTABLE);getfunc(L);if(aux_getfenv(L)) -luaL_error(L,"`setfenv' cannot change a protected environment");else lua_pop(L -,2);lua_pushvalue(L,2);if(lua_isnumber(L,1)&&lua_tonumber(L,1)==0)lua_replace( -L,LUA_GLOBALSINDEX);else if(lua_setfenv(L,-2)==0)luaL_error(L, -"`setfenv' cannot change environment of given function");return 0;}static int -luaB_rawequal(lua_State*L){luaL_checkany(L,1);luaL_checkany(L,2); -lua_pushboolean(L,lua_rawequal(L,1,2));return 1;}static int luaB_rawget( -lua_State*L){luaL_checktype(L,1,LUA_TTABLE);luaL_checkany(L,2);lua_rawget(L,1) -;return 1;}static int luaB_rawset(lua_State*L){luaL_checktype(L,1,LUA_TTABLE); -luaL_checkany(L,2);luaL_checkany(L,3);lua_rawset(L,1);return 1;}static int -luaB_gcinfo(lua_State*L){lua_pushnumber(L,(lua_Number)lua_getgccount(L)); -lua_pushnumber(L,(lua_Number)lua_getgcthreshold(L));return 2;}static int -luaB_collectgarbage(lua_State*L){lua_setgcthreshold(L,luaL_optint(L,1,0)); -return 0;}static int luaB_type(lua_State*L){luaL_checkany(L,1);lua_pushstring( -L,lua_typename(L,lua_type(L,1)));return 1;}static int luaB_next(lua_State*L){ -luaL_checktype(L,1,LUA_TTABLE);lua_settop(L,2);if(lua_next(L,1))return 2;else{ -lua_pushnil(L);return 1;}}static int luaB_pairs(lua_State*L){luaL_checktype(L, -1,LUA_TTABLE);lua_pushliteral(L,"next");lua_rawget(L,LUA_GLOBALSINDEX); -lua_pushvalue(L,1);lua_pushnil(L);return 3;}static int luaB_ipairs(lua_State*L -){lua_Number i=lua_tonumber(L,2);luaL_checktype(L,1,LUA_TTABLE);if(i==0&& -lua_isnone(L,2)){lua_pushliteral(L,"ipairs");lua_rawget(L,LUA_GLOBALSINDEX); -lua_pushvalue(L,1);lua_pushnumber(L,0);return 3;}else{i++;lua_pushnumber(L,i); -lua_rawgeti(L,1,(int)i);return(lua_isnil(L,-1))?0:2;}}static int load_aux( -lua_State*L,int status){if(status==0)return 1;else{lua_pushnil(L);lua_insert(L -,-2);return 2;}}static int luaB_loadstring(lua_State*L){size_t l;const char*s= -luaL_checklstring(L,1,&l);const char*chunkname=luaL_optstring(L,2,s);return -load_aux(L,luaL_loadbuffer(L,s,l,chunkname));}static int luaB_loadfile( -lua_State*L){const char*fname=luaL_optstring(L,1,NULL);return load_aux(L, -luaL_loadfile(L,fname));}static int luaB_dofile(lua_State*L){const char*fname= -luaL_optstring(L,1,NULL);int n=lua_gettop(L);int status=luaL_loadfile(L,fname) -;if(status!=0)lua_error(L);lua_call(L,0,LUA_MULTRET);return lua_gettop(L)-n;} -static int luaB_assert(lua_State*L){luaL_checkany(L,1);if(!lua_toboolean(L,1)) -return luaL_error(L,"%s",luaL_optstring(L,2,"assertion failed!"));lua_settop(L -,1);return 1;}static int luaB_unpack(lua_State*L){int n,i;luaL_checktype(L,1, -LUA_TTABLE);n=luaL_getn(L,1);luaL_checkstack(L,n,"table too big to unpack"); -for(i=1;i<=n;i++)lua_rawgeti(L,1,i);return n;}static int luaB_pcall(lua_State* -L){int status;luaL_checkany(L,1);status=lua_pcall(L,lua_gettop(L)-1, -LUA_MULTRET,0);lua_pushboolean(L,(status==0));lua_insert(L,1);return -lua_gettop(L);}static int luaB_xpcall(lua_State*L){int status;luaL_checkany(L, -2);lua_settop(L,2);lua_insert(L,1);status=lua_pcall(L,0,LUA_MULTRET,1); -lua_pushboolean(L,(status==0));lua_replace(L,1);return lua_gettop(L);}static -int luaB_tostring(lua_State*L){char buff[128];luaL_checkany(L,1);if( -luaL_callmeta(L,1,"__tostring"))return 1;switch(lua_type(L,1)){case -LUA_TNUMBER:lua_pushstring(L,lua_tostring(L,1));return 1;case LUA_TSTRING: -lua_pushvalue(L,1);return 1;case LUA_TBOOLEAN:lua_pushstring(L,(lua_toboolean( -L,1)?"true":"false"));return 1;case LUA_TTABLE:sprintf(buff,"table: %p", -lua_topointer(L,1));break;case LUA_TFUNCTION:sprintf(buff,"function: %p", -lua_topointer(L,1));break;case LUA_TUSERDATA:case LUA_TLIGHTUSERDATA:sprintf( -buff,"userdata: %p",lua_touserdata(L,1));break;case LUA_TTHREAD:sprintf(buff, -"thread: %p",(void*)lua_tothread(L,1));break;case LUA_TNIL:lua_pushliteral(L, -"nil");return 1;}lua_pushstring(L,buff);return 1;}static int luaB_newproxy( -lua_State*L){lua_settop(L,1);lua_newuserdata(L,0);if(lua_toboolean(L,1)==0) -return 1;else if(lua_isboolean(L,1)){lua_newtable(L);lua_pushvalue(L,-1); -lua_pushboolean(L,1);lua_rawset(L,lua_upvalueindex(1));}else{int validproxy=0; -if(lua_getmetatable(L,1)){lua_rawget(L,lua_upvalueindex(1));validproxy= -lua_toboolean(L,-1);lua_pop(L,1);}luaL_argcheck(L,validproxy,1, -"boolean or proxy expected");lua_getmetatable(L,1);}lua_setmetatable(L,2); -return 1;} -#define REQTAB "_LOADED" -#define LUA_PATH "LUA_PATH" -#ifndef LUA_PATH_SEP -#define LUA_PATH_SEP ';' -#endif -#ifndef LUA_PATH_MARK -#define LUA_PATH_MARK '?' -#endif -#ifndef LUA_PATH_DEFAULT -#define LUA_PATH_DEFAULT "?;?.lua" -#endif -static const char*getpath(lua_State*L){const char*path;lua_getglobal(L, -LUA_PATH);path=lua_tostring(L,-1);lua_pop(L,1);if(path)return path;path=getenv -(LUA_PATH);if(path)return path;return LUA_PATH_DEFAULT;}static const char* -pushnextpath(lua_State*L,const char*path){const char*l;if(*path=='\0')return -NULL;if(*path==LUA_PATH_SEP)path++;l=strchr(path,LUA_PATH_SEP);if(l==NULL)l= -path+strlen(path);lua_pushlstring(L,path,l-path);return l;}static void -pushcomposename(lua_State*L){const char*path=lua_tostring(L,-1);const char* -wild;int n=1;while((wild=strchr(path,LUA_PATH_MARK))!=NULL){luaL_checkstack(L, -3,"too many marks in a path component");lua_pushlstring(L,path,wild-path); -lua_pushvalue(L,1);path=wild+1;n+=2;}lua_pushstring(L,path);lua_concat(L,n);} -static int luaB_require(lua_State*L){const char*path;int status=LUA_ERRFILE; -luaL_checkstring(L,1);lua_settop(L,1);lua_getglobal(L,REQTAB);if(!lua_istable( -L,2))return luaL_error(L,"`"REQTAB"' is not a table");path=getpath(L); -lua_pushvalue(L,1);lua_rawget(L,2);if(lua_toboolean(L,-1))return 1;else{while( -status==LUA_ERRFILE){lua_settop(L,3);if((path=pushnextpath(L,path))==NULL) -break;pushcomposename(L);status=luaL_loadfile(L,lua_tostring(L,-1));}}switch( -status){case 0:{lua_getglobal(L,"_REQUIREDNAME");lua_insert(L,-2); -lua_pushvalue(L,1);lua_setglobal(L,"_REQUIREDNAME");lua_call(L,0,1);lua_insert -(L,-2);lua_setglobal(L,"_REQUIREDNAME");if(lua_isnil(L,-1)){lua_pushboolean(L, -1);lua_replace(L,-2);}lua_pushvalue(L,1);lua_pushvalue(L,-2);lua_rawset(L,2); -return 1;}case LUA_ERRFILE:{return luaL_error(L, -"could not load package `%s' from path `%s'",lua_tostring(L,1),getpath(L));} -default:{return luaL_error(L,"error loading package `%s' (%s)",lua_tostring(L, -1),lua_tostring(L,-1));}}}static const luaL_reg base_funcs[]={{"error", -luaB_error},{"getmetatable",luaB_getmetatable},{"setmetatable", -luaB_setmetatable},{"getfenv",luaB_getfenv},{"setfenv",luaB_setfenv},{"next", -luaB_next},{"ipairs",luaB_ipairs},{"pairs",luaB_pairs},{"print",luaB_print},{ -"tonumber",luaB_tonumber},{"tostring",luaB_tostring},{"type",luaB_type},{ -"assert",luaB_assert},{"unpack",luaB_unpack},{"rawequal",luaB_rawequal},{ -"rawget",luaB_rawget},{"rawset",luaB_rawset},{"pcall",luaB_pcall},{"xpcall", -luaB_xpcall},{"collectgarbage",luaB_collectgarbage},{"gcinfo",luaB_gcinfo},{ -"loadfile",luaB_loadfile},{"dofile",luaB_dofile},{"loadstring",luaB_loadstring -},{"require",luaB_require},{NULL,NULL}};static int auxresume(lua_State*L, -lua_State*co,int narg){int status;if(!lua_checkstack(co,narg))luaL_error(L, -"too many arguments to resume");lua_xmove(L,co,narg);status=lua_resume(co,narg -);if(status==0){int nres=lua_gettop(co);if(!lua_checkstack(L,nres))luaL_error( -L,"too many results to resume");lua_xmove(co,L,nres);return nres;}else{ -lua_xmove(co,L,1);return-1;}}static int luaB_coresume(lua_State*L){lua_State* -co=lua_tothread(L,1);int r;luaL_argcheck(L,co,1,"coroutine expected");r= -auxresume(L,co,lua_gettop(L)-1);if(r<0){lua_pushboolean(L,0);lua_insert(L,-2); -return 2;}else{lua_pushboolean(L,1);lua_insert(L,-(r+1));return r+1;}}static -int luaB_auxwrap(lua_State*L){lua_State*co=lua_tothread(L,lua_upvalueindex(1)) -;int r=auxresume(L,co,lua_gettop(L));if(r<0){if(lua_isstring(L,-1)){luaL_where -(L,1);lua_insert(L,-2);lua_concat(L,2);}lua_error(L);}return r;}static int -luaB_cocreate(lua_State*L){lua_State*NL=lua_newthread(L);luaL_argcheck(L, -lua_isfunction(L,1)&&!lua_iscfunction(L,1),1,"Lua function expected"); -lua_pushvalue(L,1);lua_xmove(L,NL,1);return 1;}static int luaB_cowrap( -lua_State*L){luaB_cocreate(L);lua_pushcclosure(L,luaB_auxwrap,1);return 1;} -static int luaB_yield(lua_State*L){return lua_yield(L,lua_gettop(L));}static -int luaB_costatus(lua_State*L){lua_State*co=lua_tothread(L,1);luaL_argcheck(L, -co,1,"coroutine expected");if(L==co)lua_pushliteral(L,"running");else{ -lua_Debug ar;if(lua_getstack(co,0,&ar)==0&&lua_gettop(co)==0)lua_pushliteral(L -,"dead");else lua_pushliteral(L,"suspended");}return 1;}static const luaL_reg -co_funcs[]={{"create",luaB_cocreate},{"wrap",luaB_cowrap},{"resume", -luaB_coresume},{"yield",luaB_yield},{"status",luaB_costatus},{NULL,NULL}}; -static void base_open(lua_State*L){lua_pushliteral(L,"_G");lua_pushvalue(L, -LUA_GLOBALSINDEX);luaL_openlib(L,NULL,base_funcs,0);lua_pushliteral(L, -"_VERSION");lua_pushliteral(L,LUA_VERSION);lua_rawset(L,-3);lua_pushliteral(L, -"newproxy");lua_newtable(L);lua_pushvalue(L,-1);lua_setmetatable(L,-2); -lua_pushliteral(L,"__mode");lua_pushliteral(L,"k");lua_rawset(L,-3); -lua_pushcclosure(L,luaB_newproxy,1);lua_rawset(L,-3);lua_rawset(L,-1);} -LUALIB_API int luaopen_base(lua_State*L){base_open(L);luaL_openlib(L, -LUA_COLIBNAME,co_funcs,0);lua_newtable(L);lua_setglobal(L,REQTAB);return 0;} -#line 1 "lcode.c" -#define lcode_c -#line 1 "lcode.h" -#ifndef lcode_h -#define lcode_h -#line 1 "llex.h" -#ifndef llex_h -#define llex_h -#define FIRST_RESERVED 257 -#define TOKEN_LEN (sizeof("function")/sizeof(char)) -enum RESERVED{TK_AND=FIRST_RESERVED,TK_BREAK,TK_DO,TK_ELSE,TK_ELSEIF,TK_END, -TK_FALSE,TK_FOR,TK_FUNCTION,TK_IF,TK_IN,TK_LOCAL,TK_NIL,TK_NOT,TK_OR,TK_REPEAT -,TK_RETURN,TK_THEN,TK_TRUE,TK_UNTIL,TK_WHILE,TK_NAME,TK_CONCAT,TK_DOTS,TK_EQ, -TK_GE,TK_LE,TK_NE,TK_NUMBER,TK_STRING,TK_EOS}; -#define NUM_RESERVED (cast(int,TK_WHILE-FIRST_RESERVED+1)) -typedef union{lua_Number r;TString*ts;}SemInfo;typedef struct Token{int token; -SemInfo seminfo;}Token;typedef struct LexState{int current;int linenumber;int -lastline;Token t;Token lookahead;struct FuncState*fs;struct lua_State*L;ZIO*z; -Mbuffer*buff;TString*source;int nestlevel;}LexState;void luaX_init(lua_State*L -);void luaX_setinput(lua_State*L,LexState*LS,ZIO*z,TString*source);int -luaX_lex(LexState*LS,SemInfo*seminfo);void luaX_checklimit(LexState*ls,int val -,int limit,const char*msg);void luaX_syntaxerror(LexState*ls,const char*s); -void luaX_errorline(LexState*ls,const char*s,const char*token,int line);const -char*luaX_token2str(LexState*ls,int token); -#endif -#line 11 "lcode.h" -#line 1 "lopcodes.h" -#ifndef lopcodes_h -#define lopcodes_h -enum OpMode{iABC,iABx,iAsBx}; -#define SIZE_C 9 -#define SIZE_B 9 -#define SIZE_Bx (SIZE_C+SIZE_B) -#define SIZE_A 8 -#define SIZE_OP 6 -#define POS_C SIZE_OP -#define POS_B (POS_C+SIZE_C) -#define POS_Bx POS_C -#define POS_A (POS_B+SIZE_B) -#if SIZE_Bx >1) -#else -#define MAXARG_Bx MAX_INT -#define MAXARG_sBx MAX_INT -#endif -#define MAXARG_A ((1<>POS_A)) -#define SETARG_A(i,u) ((i)=(((i)&MASK0(SIZE_A,POS_A))|((cast(Instruction,u)<<\ -POS_A)&MASK1(SIZE_A,POS_A)))) -#define GETARG_B(i) (cast(int,((i)>>POS_B)&MASK1(SIZE_B,0))) -#define SETARG_B(i,b) ((i)=(((i)&MASK0(SIZE_B,POS_B))|((cast(Instruction,b)<<\ -POS_B)&MASK1(SIZE_B,POS_B)))) -#define GETARG_C(i) (cast(int,((i)>>POS_C)&MASK1(SIZE_C,0))) -#define SETARG_C(i,b) ((i)=(((i)&MASK0(SIZE_C,POS_C))|((cast(Instruction,b)<<\ -POS_C)&MASK1(SIZE_C,POS_C)))) -#define GETARG_Bx(i) (cast(int,((i)>>POS_Bx)&MASK1(SIZE_Bx,0))) -#define SETARG_Bx(i,b) ((i)=(((i)&MASK0(SIZE_Bx,POS_Bx))|((cast(Instruction,b)\ -<=OPR_NE) -typedef enum UnOpr{OPR_MINUS,OPR_NOT,OPR_NOUNOPR}UnOpr; -#define getcode(fs,e) ((fs)->f->code[(e)->info]) -#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) -int luaK_code(FuncState*fs,Instruction i,int line);int luaK_codeABx(FuncState* -fs,OpCode o,int A,unsigned int Bx);int luaK_codeABC(FuncState*fs,OpCode o,int -A,int B,int C);void luaK_fixline(FuncState*fs,int line);void luaK_nil( -FuncState*fs,int from,int n);void luaK_reserveregs(FuncState*fs,int n);void -luaK_checkstack(FuncState*fs,int n);int luaK_stringK(FuncState*fs,TString*s); -int luaK_numberK(FuncState*fs,lua_Number r);void luaK_dischargevars(FuncState* -fs,expdesc*e);int luaK_exp2anyreg(FuncState*fs,expdesc*e);void -luaK_exp2nextreg(FuncState*fs,expdesc*e);void luaK_exp2val(FuncState*fs, -expdesc*e);int luaK_exp2RK(FuncState*fs,expdesc*e);void luaK_self(FuncState*fs -,expdesc*e,expdesc*key);void luaK_indexed(FuncState*fs,expdesc*t,expdesc*k); -void luaK_goiftrue(FuncState*fs,expdesc*e);void luaK_goiffalse(FuncState*fs, -expdesc*e);void luaK_storevar(FuncState*fs,expdesc*var,expdesc*e);void -luaK_setcallreturns(FuncState*fs,expdesc*var,int nresults);int luaK_jump( -FuncState*fs);void luaK_patchlist(FuncState*fs,int list,int target);void -luaK_patchtohere(FuncState*fs,int list);void luaK_concat(FuncState*fs,int*l1, -int l2);int luaK_getlabel(FuncState*fs);void luaK_prefix(FuncState*fs,UnOpr op -,expdesc*v);void luaK_infix(FuncState*fs,BinOpr op,expdesc*v);void luaK_posfix -(FuncState*fs,BinOpr op,expdesc*v1,expdesc*v2); -#endif -#line 15 "lcode.c" -#define hasjumps(e) ((e)->t!=(e)->f) -void luaK_nil(FuncState*fs,int from,int n){Instruction*previous;if(fs->pc>fs-> -lasttarget&&GET_OPCODE(*(previous=&fs->f->code[fs->pc-1]))==OP_LOADNIL){int -pfrom=GETARG_A(*previous);int pto=GETARG_B(*previous);if(pfrom<=from&&from<= -pto+1){if(from+n-1>pto)SETARG_B(*previous,from+n-1);return;}}luaK_codeABC(fs, -OP_LOADNIL,from,from+n-1,0);}int luaK_jump(FuncState*fs){int jpc=fs->jpc;int j -;fs->jpc=NO_JUMP;j=luaK_codeAsBx(fs,OP_JMP,0,NO_JUMP);luaK_concat(fs,&j,jpc); -return j;}static int luaK_condjump(FuncState*fs,OpCode op,int A,int B,int C){ -luaK_codeABC(fs,op,A,B,C);return luaK_jump(fs);}static void luaK_fixjump( -FuncState*fs,int pc,int dest){Instruction*jmp=&fs->f->code[pc];int offset=dest --(pc+1);lua_assert(dest!=NO_JUMP);if(abs(offset)>MAXARG_sBx)luaX_syntaxerror( -fs->ls,"control structure too long");SETARG_sBx(*jmp,offset);}int -luaK_getlabel(FuncState*fs){fs->lasttarget=fs->pc;return fs->pc;}static int -luaK_getjump(FuncState*fs,int pc){int offset=GETARG_sBx(fs->f->code[pc]);if( -offset==NO_JUMP)return NO_JUMP;else return(pc+1)+offset;}static Instruction* -getjumpcontrol(FuncState*fs,int pc){Instruction*pi=&fs->f->code[pc];if(pc>=1&& -testOpMode(GET_OPCODE(*(pi-1)),OpModeT))return pi-1;else return pi;}static int - need_value(FuncState*fs,int list,int cond){for(;list!=NO_JUMP;list= -luaK_getjump(fs,list)){Instruction i=*getjumpcontrol(fs,list);if(GET_OPCODE(i) -!=OP_TEST||GETARG_C(i)!=cond)return 1;}return 0;}static void patchtestreg( -Instruction*i,int reg){if(reg==NO_REG)reg=GETARG_B(*i);SETARG_A(*i,reg);} -static void luaK_patchlistaux(FuncState*fs,int list,int ttarget,int treg,int -ftarget,int freg,int dtarget){while(list!=NO_JUMP){int next=luaK_getjump(fs, -list);Instruction*i=getjumpcontrol(fs,list);if(GET_OPCODE(*i)!=OP_TEST){ -lua_assert(dtarget!=NO_JUMP);luaK_fixjump(fs,list,dtarget);}else{if(GETARG_C(* -i)){lua_assert(ttarget!=NO_JUMP);patchtestreg(i,treg);luaK_fixjump(fs,list, -ttarget);}else{lua_assert(ftarget!=NO_JUMP);patchtestreg(i,freg);luaK_fixjump( -fs,list,ftarget);}}list=next;}}static void luaK_dischargejpc(FuncState*fs){ -luaK_patchlistaux(fs,fs->jpc,fs->pc,NO_REG,fs->pc,NO_REG,fs->pc);fs->jpc= -NO_JUMP;}void luaK_patchlist(FuncState*fs,int list,int target){if(target==fs-> -pc)luaK_patchtohere(fs,list);else{lua_assert(targetpc);luaK_patchlistaux( -fs,list,target,NO_REG,target,NO_REG,target);}}void luaK_patchtohere(FuncState* -fs,int list){luaK_getlabel(fs);luaK_concat(fs,&fs->jpc,list);}void luaK_concat -(FuncState*fs,int*l1,int l2){if(l2==NO_JUMP)return;else if(*l1==NO_JUMP)*l1=l2 -;else{int list=*l1;int next;while((next=luaK_getjump(fs,list))!=NO_JUMP)list= -next;luaK_fixjump(fs,list,l2);}}void luaK_checkstack(FuncState*fs,int n){int -newstack=fs->freereg+n;if(newstack>fs->f->maxstacksize){if(newstack>=MAXSTACK) -luaX_syntaxerror(fs->ls,"function or expression too complex");fs->f-> -maxstacksize=cast(lu_byte,newstack);}}void luaK_reserveregs(FuncState*fs,int n -){luaK_checkstack(fs,n);fs->freereg+=n;}static void freereg(FuncState*fs,int -reg){if(reg>=fs->nactvar&®freereg--;lua_assert(reg==fs-> -freereg);}}static void freeexp(FuncState*fs,expdesc*e){if(e->k==VNONRELOC) -freereg(fs,e->info);}static int addk(FuncState*fs,TObject*k,TObject*v){const -TObject*idx=luaH_get(fs->h,k);if(ttisnumber(idx)){lua_assert(luaO_rawequalObj( -&fs->f->k[cast(int,nvalue(idx))],v));return cast(int,nvalue(idx));}else{Proto* -f=fs->f;luaM_growvector(fs->L,f->k,fs->nk,f->sizek,TObject,MAXARG_Bx, -"constant table overflow");setobj2n(&f->k[fs->nk],v);setnvalue(luaH_set(fs->L, -fs->h,k),cast(lua_Number,fs->nk));return fs->nk++;}}int luaK_stringK(FuncState -*fs,TString*s){TObject o;setsvalue(&o,s);return addk(fs,&o,&o);}int -luaK_numberK(FuncState*fs,lua_Number r){TObject o;setnvalue(&o,r);return addk( -fs,&o,&o);}static int nil_constant(FuncState*fs){TObject k,v;setnilvalue(&v); -sethvalue(&k,fs->h);return addk(fs,&k,&v);}void luaK_setcallreturns(FuncState* -fs,expdesc*e,int nresults){if(e->k==VCALL){SETARG_C(getcode(fs,e),nresults+1); -if(nresults==1){e->k=VNONRELOC;e->info=GETARG_A(getcode(fs,e));}}}void -luaK_dischargevars(FuncState*fs,expdesc*e){switch(e->k){case VLOCAL:{e->k= -VNONRELOC;break;}case VUPVAL:{e->info=luaK_codeABC(fs,OP_GETUPVAL,0,e->info,0) -;e->k=VRELOCABLE;break;}case VGLOBAL:{e->info=luaK_codeABx(fs,OP_GETGLOBAL,0,e -->info);e->k=VRELOCABLE;break;}case VINDEXED:{freereg(fs,e->aux);freereg(fs,e -->info);e->info=luaK_codeABC(fs,OP_GETTABLE,0,e->info,e->aux);e->k=VRELOCABLE; -break;}case VCALL:{luaK_setcallreturns(fs,e,1);break;}default:break;}}static -int code_label(FuncState*fs,int A,int b,int jump){luaK_getlabel(fs);return -luaK_codeABC(fs,OP_LOADBOOL,A,b,jump);}static void discharge2reg(FuncState*fs, -expdesc*e,int reg){luaK_dischargevars(fs,e);switch(e->k){case VNIL:{luaK_nil( -fs,reg,1);break;}case VFALSE:case VTRUE:{luaK_codeABC(fs,OP_LOADBOOL,reg,e->k -==VTRUE,0);break;}case VK:{luaK_codeABx(fs,OP_LOADK,reg,e->info);break;}case -VRELOCABLE:{Instruction*pc=&getcode(fs,e);SETARG_A(*pc,reg);break;}case -VNONRELOC:{if(reg!=e->info)luaK_codeABC(fs,OP_MOVE,reg,e->info,0);break;} -default:{lua_assert(e->k==VVOID||e->k==VJMP);return;}}e->info=reg;e->k= -VNONRELOC;}static void discharge2anyreg(FuncState*fs,expdesc*e){if(e->k!= -VNONRELOC){luaK_reserveregs(fs,1);discharge2reg(fs,e,fs->freereg-1);}}static -void luaK_exp2reg(FuncState*fs,expdesc*e,int reg){discharge2reg(fs,e,reg);if(e -->k==VJMP)luaK_concat(fs,&e->t,e->info);if(hasjumps(e)){int final;int p_f= -NO_JUMP;int p_t=NO_JUMP;if(need_value(fs,e->t,1)||need_value(fs,e->f,0)){int -fj=NO_JUMP;if(e->k!=VJMP)fj=luaK_jump(fs);p_f=code_label(fs,reg,0,1);p_t= -code_label(fs,reg,1,0);luaK_patchtohere(fs,fj);}final=luaK_getlabel(fs); -luaK_patchlistaux(fs,e->f,p_f,NO_REG,final,reg,p_f);luaK_patchlistaux(fs,e->t, -final,reg,p_t,NO_REG,p_t);}e->f=e->t=NO_JUMP;e->info=reg;e->k=VNONRELOC;}void -luaK_exp2nextreg(FuncState*fs,expdesc*e){luaK_dischargevars(fs,e);freeexp(fs,e -);luaK_reserveregs(fs,1);luaK_exp2reg(fs,e,fs->freereg-1);}int luaK_exp2anyreg -(FuncState*fs,expdesc*e){luaK_dischargevars(fs,e);if(e->k==VNONRELOC){if(! -hasjumps(e))return e->info;if(e->info>=fs->nactvar){luaK_exp2reg(fs,e,e->info) -;return e->info;}}luaK_exp2nextreg(fs,e);return e->info;}void luaK_exp2val( -FuncState*fs,expdesc*e){if(hasjumps(e))luaK_exp2anyreg(fs,e);else -luaK_dischargevars(fs,e);}int luaK_exp2RK(FuncState*fs,expdesc*e){luaK_exp2val -(fs,e);switch(e->k){case VNIL:{if(fs->nk+MAXSTACK<=MAXARG_C){e->info= -nil_constant(fs);e->k=VK;return e->info+MAXSTACK;}else break;}case VK:{if(e-> -info+MAXSTACK<=MAXARG_C)return e->info+MAXSTACK;else break;}default:break;} -return luaK_exp2anyreg(fs,e);}void luaK_storevar(FuncState*fs,expdesc*var, -expdesc*exp){switch(var->k){case VLOCAL:{freeexp(fs,exp);luaK_exp2reg(fs,exp, -var->info);return;}case VUPVAL:{int e=luaK_exp2anyreg(fs,exp);luaK_codeABC(fs, -OP_SETUPVAL,e,var->info,0);break;}case VGLOBAL:{int e=luaK_exp2anyreg(fs,exp); -luaK_codeABx(fs,OP_SETGLOBAL,e,var->info);break;}case VINDEXED:{int e= -luaK_exp2RK(fs,exp);luaK_codeABC(fs,OP_SETTABLE,var->info,var->aux,e);break;} -default:{lua_assert(0);break;}}freeexp(fs,exp);}void luaK_self(FuncState*fs, -expdesc*e,expdesc*key){int func;luaK_exp2anyreg(fs,e);freeexp(fs,e);func=fs-> -freereg;luaK_reserveregs(fs,2);luaK_codeABC(fs,OP_SELF,func,e->info, -luaK_exp2RK(fs,key));freeexp(fs,key);e->info=func;e->k=VNONRELOC;}static void -invertjump(FuncState*fs,expdesc*e){Instruction*pc=getjumpcontrol(fs,e->info); -lua_assert(testOpMode(GET_OPCODE(*pc),OpModeT)&&GET_OPCODE(*pc)!=OP_TEST); -SETARG_A(*pc,!(GETARG_A(*pc)));}static int jumponcond(FuncState*fs,expdesc*e, -int cond){if(e->k==VRELOCABLE){Instruction ie=getcode(fs,e);if(GET_OPCODE(ie) -==OP_NOT){fs->pc--;return luaK_condjump(fs,OP_TEST,NO_REG,GETARG_B(ie),!cond); -}}discharge2anyreg(fs,e);freeexp(fs,e);return luaK_condjump(fs,OP_TEST,NO_REG, -e->info,cond);}void luaK_goiftrue(FuncState*fs,expdesc*e){int pc; -luaK_dischargevars(fs,e);switch(e->k){case VK:case VTRUE:{pc=NO_JUMP;break;} -case VFALSE:{pc=luaK_jump(fs);break;}case VJMP:{invertjump(fs,e);pc=e->info; -break;}default:{pc=jumponcond(fs,e,0);break;}}luaK_concat(fs,&e->f,pc);}void -luaK_goiffalse(FuncState*fs,expdesc*e){int pc;luaK_dischargevars(fs,e);switch( -e->k){case VNIL:case VFALSE:{pc=NO_JUMP;break;}case VTRUE:{pc=luaK_jump(fs); -break;}case VJMP:{pc=e->info;break;}default:{pc=jumponcond(fs,e,1);break;}} -luaK_concat(fs,&e->t,pc);}static void codenot(FuncState*fs,expdesc*e){ -luaK_dischargevars(fs,e);switch(e->k){case VNIL:case VFALSE:{e->k=VTRUE;break; -}case VK:case VTRUE:{e->k=VFALSE;break;}case VJMP:{invertjump(fs,e);break;} -case VRELOCABLE:case VNONRELOC:{discharge2anyreg(fs,e);freeexp(fs,e);e->info= -luaK_codeABC(fs,OP_NOT,0,e->info,0);e->k=VRELOCABLE;break;}default:{lua_assert -(0);break;}}{int temp=e->f;e->f=e->t;e->t=temp;}}void luaK_indexed(FuncState* -fs,expdesc*t,expdesc*k){t->aux=luaK_exp2RK(fs,k);t->k=VINDEXED;}void -luaK_prefix(FuncState*fs,UnOpr op,expdesc*e){if(op==OPR_MINUS){luaK_exp2val(fs -,e);if(e->k==VK&&ttisnumber(&fs->f->k[e->info]))e->info=luaK_numberK(fs,- -nvalue(&fs->f->k[e->info]));else{luaK_exp2anyreg(fs,e);freeexp(fs,e);e->info= -luaK_codeABC(fs,OP_UNM,0,e->info,0);e->k=VRELOCABLE;}}else codenot(fs,e);}void - luaK_infix(FuncState*fs,BinOpr op,expdesc*v){switch(op){case OPR_AND:{ -luaK_goiftrue(fs,v);luaK_patchtohere(fs,v->t);v->t=NO_JUMP;break;}case OPR_OR: -{luaK_goiffalse(fs,v);luaK_patchtohere(fs,v->f);v->f=NO_JUMP;break;}case -OPR_CONCAT:{luaK_exp2nextreg(fs,v);break;}default:{luaK_exp2RK(fs,v);break;}}} -static void codebinop(FuncState*fs,expdesc*res,BinOpr op,int o1,int o2){if(op -<=OPR_POW){OpCode opc=cast(OpCode,(op-OPR_ADD)+OP_ADD);res->info=luaK_codeABC( -fs,opc,0,o1,o2);res->k=VRELOCABLE;}else{static const OpCode ops[]={OP_EQ,OP_EQ -,OP_LT,OP_LE,OP_LT,OP_LE};int cond=1;if(op>=OPR_GT){int temp;temp=o1;o1=o2;o2= -temp;}else if(op==OPR_NE)cond=0;res->info=luaK_condjump(fs,ops[op-OPR_NE],cond -,o1,o2);res->k=VJMP;}}void luaK_posfix(FuncState*fs,BinOpr op,expdesc*e1, -expdesc*e2){switch(op){case OPR_AND:{lua_assert(e1->t==NO_JUMP); -luaK_dischargevars(fs,e2);luaK_concat(fs,&e1->f,e2->f);e1->k=e2->k;e1->info=e2 -->info;e1->aux=e2->aux;e1->t=e2->t;break;}case OPR_OR:{lua_assert(e1->f== -NO_JUMP);luaK_dischargevars(fs,e2);luaK_concat(fs,&e1->t,e2->t);e1->k=e2->k;e1 -->info=e2->info;e1->aux=e2->aux;e1->f=e2->f;break;}case OPR_CONCAT:{ -luaK_exp2val(fs,e2);if(e2->k==VRELOCABLE&&GET_OPCODE(getcode(fs,e2))== -OP_CONCAT){lua_assert(e1->info==GETARG_B(getcode(fs,e2))-1);freeexp(fs,e1); -SETARG_B(getcode(fs,e2),e1->info);e1->k=e2->k;e1->info=e2->info;}else{ -luaK_exp2nextreg(fs,e2);freeexp(fs,e2);freeexp(fs,e1);e1->info=luaK_codeABC(fs -,OP_CONCAT,0,e1->info,e2->info);e1->k=VRELOCABLE;}break;}default:{int o1= -luaK_exp2RK(fs,e1);int o2=luaK_exp2RK(fs,e2);freeexp(fs,e2);freeexp(fs,e1); -codebinop(fs,e1,op,o1,o2);}}}void luaK_fixline(FuncState*fs,int line){fs->f-> -lineinfo[fs->pc-1]=line;}int luaK_code(FuncState*fs,Instruction i,int line){ -Proto*f=fs->f;luaK_dischargejpc(fs);luaM_growvector(fs->L,f->code,fs->pc,f-> -sizecode,Instruction,MAX_INT,"code size overflow");f->code[fs->pc]=i; -luaM_growvector(fs->L,f->lineinfo,fs->pc,f->sizelineinfo,int,MAX_INT, -"code size overflow");f->lineinfo[fs->pc]=line;return fs->pc++;}int -luaK_codeABC(FuncState*fs,OpCode o,int a,int b,int c){lua_assert(getOpMode(o) -==iABC);return luaK_code(fs,CREATE_ABC(o,a,b,c),fs->ls->lastline);}int -luaK_codeABx(FuncState*fs,OpCode o,int a,unsigned int bc){lua_assert(getOpMode -(o)==iABx||getOpMode(o)==iAsBx);return luaK_code(fs,CREATE_ABx(o,a,bc),fs->ls -->lastline);} -#line 1 "ldblib.c" -#define ldblib_c -static void settabss(lua_State*L,const char*i,const char*v){lua_pushstring(L,i -);lua_pushstring(L,v);lua_rawset(L,-3);}static void settabsi(lua_State*L,const - char*i,int v){lua_pushstring(L,i);lua_pushnumber(L,(lua_Number)v);lua_rawset( -L,-3);}static int getinfo(lua_State*L){lua_Debug ar;const char*options= -luaL_optstring(L,2,"flnSu");if(lua_isnumber(L,1)){if(!lua_getstack(L,(int)( -lua_tonumber(L,1)),&ar)){lua_pushnil(L);return 1;}}else if(lua_isfunction(L,1) -){lua_pushfstring(L,">%s",options);options=lua_tostring(L,-1);lua_pushvalue(L, -1);}else return luaL_argerror(L,1,"function or level expected");if(! -lua_getinfo(L,options,&ar))return luaL_argerror(L,2,"invalid option"); -lua_newtable(L);for(;*options;options++){switch(*options){case'S':settabss(L, -"source",ar.source);settabss(L,"short_src",ar.short_src);settabsi(L, -"linedefined",ar.linedefined);settabss(L,"what",ar.what);break;case'l': -settabsi(L,"currentline",ar.currentline);break;case'u':settabsi(L,"nups",ar. -nups);break;case'n':settabss(L,"name",ar.name);settabss(L,"namewhat",ar. -namewhat);break;case'f':lua_pushliteral(L,"func");lua_pushvalue(L,-3); -lua_rawset(L,-3);break;}}return 1;}static int getlocal(lua_State*L){lua_Debug -ar;const char*name;if(!lua_getstack(L,luaL_checkint(L,1),&ar))return -luaL_argerror(L,1,"level out of range");name=lua_getlocal(L,&ar,luaL_checkint( -L,2));if(name){lua_pushstring(L,name);lua_pushvalue(L,-2);return 2;}else{ -lua_pushnil(L);return 1;}}static int setlocal(lua_State*L){lua_Debug ar;if(! -lua_getstack(L,luaL_checkint(L,1),&ar))return luaL_argerror(L,1, -"level out of range");luaL_checkany(L,3);lua_pushstring(L,lua_setlocal(L,&ar, -luaL_checkint(L,2)));return 1;}static int auxupvalue(lua_State*L,int get){ -const char*name;int n=luaL_checkint(L,2);luaL_checktype(L,1,LUA_TFUNCTION);if( -lua_iscfunction(L,1))return 0;name=get?lua_getupvalue(L,1,n):lua_setupvalue(L, -1,n);if(name==NULL)return 0;lua_pushstring(L,name);lua_insert(L,-(get+1)); -return get+1;}static int getupvalue(lua_State*L){return auxupvalue(L,1);} -static int setupvalue(lua_State*L){luaL_checkany(L,3);return auxupvalue(L,0);} -static const char KEY_HOOK='h';static void hookf(lua_State*L,lua_Debug*ar){ -static const char*const hooknames[]={"call","return","line","count", -"tail return"};lua_pushlightuserdata(L,(void*)&KEY_HOOK);lua_rawget(L, -LUA_REGISTRYINDEX);if(lua_isfunction(L,-1)){lua_pushstring(L,hooknames[(int)ar -->event]);if(ar->currentline>=0)lua_pushnumber(L,(lua_Number)ar->currentline); -else lua_pushnil(L);lua_assert(lua_getinfo(L,"lS",ar));lua_call(L,2,0);}else -lua_pop(L,1);}static int makemask(const char*smask,int count){int mask=0;if( -strchr(smask,'c'))mask|=LUA_MASKCALL;if(strchr(smask,'r'))mask|=LUA_MASKRET;if -(strchr(smask,'l'))mask|=LUA_MASKLINE;if(count>0)mask|=LUA_MASKCOUNT;return -mask;}static char*unmakemask(int mask,char*smask){int i=0;if(mask&LUA_MASKCALL -)smask[i++]='c';if(mask&LUA_MASKRET)smask[i++]='r';if(mask&LUA_MASKLINE)smask[ -i++]='l';smask[i]='\0';return smask;}static int sethook(lua_State*L){if( -lua_isnoneornil(L,1)){lua_settop(L,1);lua_sethook(L,NULL,0,0);}else{const char -*smask=luaL_checkstring(L,2);int count=luaL_optint(L,3,0);luaL_checktype(L,1, -LUA_TFUNCTION);lua_sethook(L,hookf,makemask(smask,count),count);} -lua_pushlightuserdata(L,(void*)&KEY_HOOK);lua_pushvalue(L,1);lua_rawset(L, -LUA_REGISTRYINDEX);return 0;}static int gethook(lua_State*L){char buff[5];int -mask=lua_gethookmask(L);lua_Hook hook=lua_gethook(L);if(hook!=NULL&&hook!= -hookf)lua_pushliteral(L,"external hook");else{lua_pushlightuserdata(L,(void*)& -KEY_HOOK);lua_rawget(L,LUA_REGISTRYINDEX);}lua_pushstring(L,unmakemask(mask, -buff));lua_pushnumber(L,(lua_Number)lua_gethookcount(L));return 3;}static int -debug(lua_State*L){for(;;){char buffer[250];fputs("lua_debug> ",stderr);if( -fgets(buffer,sizeof(buffer),stdin)==0||strcmp(buffer,"cont\n")==0)return 0; -lua_dostring(L,buffer);lua_settop(L,0);}} -#define LEVELS1 12 -#define LEVELS2 10 -static int errorfb(lua_State*L){int level=1;int firstpart=1;lua_Debug ar;if( -lua_gettop(L)==0)lua_pushliteral(L,"");else if(!lua_isstring(L,1))return 1; -else lua_pushliteral(L,"\n");lua_pushliteral(L,"stack traceback:");while( -lua_getstack(L,level++,&ar)){if(level>LEVELS1&&firstpart){if(!lua_getstack(L, -level+LEVELS2,&ar))level--;else{lua_pushliteral(L,"\n\t...");while( -lua_getstack(L,level+LEVELS2,&ar))level++;}firstpart=0;continue;} -lua_pushliteral(L,"\n\t");lua_getinfo(L,"Snl",&ar);lua_pushfstring(L,"%s:",ar. -short_src);if(ar.currentline>0)lua_pushfstring(L,"%d:",ar.currentline);switch( -*ar.namewhat){case'g':case'l':case'f':case'm':lua_pushfstring(L, -" in function `%s'",ar.name);break;default:{if(*ar.what=='m')lua_pushfstring(L -," in main chunk");else if(*ar.what=='C'||*ar.what=='t')lua_pushliteral(L," ?" -);else lua_pushfstring(L," in function <%s:%d>",ar.short_src,ar.linedefined);} -}lua_concat(L,lua_gettop(L));}lua_concat(L,lua_gettop(L));return 1;}static -const luaL_reg dblib[]={{"getlocal",getlocal},{"getinfo",getinfo},{"gethook", -gethook},{"getupvalue",getupvalue},{"sethook",sethook},{"setlocal",setlocal},{ -"setupvalue",setupvalue},{"debug",debug},{"traceback",errorfb},{NULL,NULL}}; -LUALIB_API int luaopen_debug(lua_State*L){luaL_openlib(L,LUA_DBLIBNAME,dblib,0 -);lua_pushliteral(L,"_TRACEBACK");lua_pushcfunction(L,errorfb);lua_settable(L, -LUA_GLOBALSINDEX);return 1;} -#line 1 "ldebug.c" -#define ldebug_c -static const char*getfuncname(CallInfo*ci,const char**name); -#define isLua(ci) (!((ci)->state&CI_C)) -static int currentpc(CallInfo*ci){if(!isLua(ci))return-1;if(ci->state& -CI_HASFRAME)ci->u.l.savedpc=*ci->u.l.pc;return pcRel(ci->u.l.savedpc,ci_func( -ci)->l.p);}static int currentline(CallInfo*ci){int pc=currentpc(ci);if(pc<0) -return-1;else return getline(ci_func(ci)->l.p,pc);}void luaG_inithooks( -lua_State*L){CallInfo*ci;for(ci=L->ci;ci!=L->base_ci;ci--)currentpc(ci);L-> -hookinit=1;}LUA_API int lua_sethook(lua_State*L,lua_Hook func,int mask,int -count){if(func==NULL||mask==0){mask=0;func=NULL;}L->hook=func;L->basehookcount -=count;resethookcount(L);L->hookmask=cast(lu_byte,mask);L->hookinit=0;return 1 -;}LUA_API lua_Hook lua_gethook(lua_State*L){return L->hook;}LUA_API int -lua_gethookmask(lua_State*L){return L->hookmask;}LUA_API int lua_gethookcount( -lua_State*L){return L->basehookcount;}LUA_API int lua_getstack(lua_State*L,int - level,lua_Debug*ar){int status;CallInfo*ci;lua_lock(L);for(ci=L->ci;level>0&& -ci>L->base_ci;ci--){level--;if(!(ci->state&CI_C))level-=ci->u.l.tailcalls;}if( -level>0||ci==L->base_ci)status=0;else if(level<0){status=1;ar->i_ci=0;}else{ -status=1;ar->i_ci=ci-L->base_ci;}lua_unlock(L);return status;}static Proto* -getluaproto(CallInfo*ci){return(isLua(ci)?ci_func(ci)->l.p:NULL);}LUA_API -const char*lua_getlocal(lua_State*L,const lua_Debug*ar,int n){const char*name; -CallInfo*ci;Proto*fp;lua_lock(L);name=NULL;ci=L->base_ci+ar->i_ci;fp= -getluaproto(ci);if(fp){name=luaF_getlocalname(fp,n,currentpc(ci));if(name) -luaA_pushobject(L,ci->base+(n-1));}lua_unlock(L);return name;}LUA_API const -char*lua_setlocal(lua_State*L,const lua_Debug*ar,int n){const char*name; -CallInfo*ci;Proto*fp;lua_lock(L);name=NULL;ci=L->base_ci+ar->i_ci;fp= -getluaproto(ci);L->top--;if(fp){name=luaF_getlocalname(fp,n,currentpc(ci));if( -!name||name[0]=='(')name=NULL;else setobjs2s(ci->base+(n-1),L->top);} -lua_unlock(L);return name;}static void funcinfo(lua_Debug*ar,StkId func){ -Closure*cl=clvalue(func);if(cl->c.isC){ar->source="=[C]";ar->linedefined=-1;ar -->what="C";}else{ar->source=getstr(cl->l.p->source);ar->linedefined=cl->l.p-> -lineDefined;ar->what=(ar->linedefined==0)?"main":"Lua";}luaO_chunkid(ar-> -short_src,ar->source,LUA_IDSIZE);}static const char*travglobals(lua_State*L, -const TObject*o){Table*g=hvalue(gt(L));int i=sizenode(g);while(i--){Node*n= -gnode(g,i);if(luaO_rawequalObj(o,gval(n))&&ttisstring(gkey(n)))return getstr( -tsvalue(gkey(n)));}return NULL;}static void info_tailcall(lua_State*L, -lua_Debug*ar){ar->name=ar->namewhat="";ar->what="tail";ar->linedefined=ar-> -currentline=-1;ar->source="=(tail call)";luaO_chunkid(ar->short_src,ar->source -,LUA_IDSIZE);ar->nups=0;setnilvalue(L->top);}static int auxgetinfo(lua_State*L -,const char*what,lua_Debug*ar,StkId f,CallInfo*ci){int status=1;for(;*what; -what++){switch(*what){case'S':{funcinfo(ar,f);break;}case'l':{ar->currentline= -(ci)?currentline(ci):-1;break;}case'u':{ar->nups=clvalue(f)->c.nupvalues;break -;}case'n':{ar->namewhat=(ci)?getfuncname(ci,&ar->name):NULL;if(ar->namewhat== -NULL){if((ar->name=travglobals(L,f))!=NULL)ar->namewhat="global";else ar-> -namewhat="";}break;}case'f':{setobj2s(L->top,f);break;}default:status=0;}} -return status;}LUA_API int lua_getinfo(lua_State*L,const char*what,lua_Debug* -ar){int status=1;lua_lock(L);if(*what=='>'){StkId f=L->top-1;if(!ttisfunction( -f))luaG_runerror(L,"value for `lua_getinfo' is not a function");status= -auxgetinfo(L,what+1,ar,f,NULL);L->top--;}else if(ar->i_ci!=0){CallInfo*ci=L-> -base_ci+ar->i_ci;lua_assert(ttisfunction(ci->base-1));status=auxgetinfo(L,what -,ar,ci->base-1,ci);}else info_tailcall(L,ar);if(strchr(what,'f'))incr_top(L); -lua_unlock(L);return status;} -#define check(x) if(!(x))return 0; -#define checkjump(pt,pc) check(0<=pc&&pcsizecode) -#define checkreg(pt,reg) check((reg)<(pt)->maxstacksize) -static int precheck(const Proto*pt){check(pt->maxstacksize<=MAXSTACK);check(pt -->sizelineinfo==pt->sizecode||pt->sizelineinfo==0);lua_assert(pt->numparams+pt -->is_vararg<=pt->maxstacksize);check(GET_OPCODE(pt->code[pt->sizecode-1])== -OP_RETURN);return 1;}static int checkopenop(const Proto*pt,int pc){Instruction - i=pt->code[pc+1];switch(GET_OPCODE(i)){case OP_CALL:case OP_TAILCALL:case -OP_RETURN:{check(GETARG_B(i)==0);return 1;}case OP_SETLISTO:return 1;default: -return 0;}}static int checkRK(const Proto*pt,int r){return(rmaxstacksize -||(r>=MAXSTACK&&r-MAXSTACKsizek));}static Instruction luaG_symbexec(const - Proto*pt,int lastpc,int reg){int pc;int last;last=pt->sizecode-1;check( -precheck(pt));for(pc=0;pccode[pc];OpCode - op=GET_OPCODE(i);int a=GETARG_A(i);int b=0;int c=0;checkreg(pt,a);switch( -getOpMode(op)){case iABC:{b=GETARG_B(i);c=GETARG_C(i);if(testOpMode(op, -OpModeBreg)){checkreg(pt,b);}else if(testOpMode(op,OpModeBrk))check(checkRK(pt -,b));if(testOpMode(op,OpModeCrk))check(checkRK(pt,c));break;}case iABx:{b= -GETARG_Bx(i);if(testOpMode(op,OpModeK))check(bsizek);break;}case iAsBx:{b -=GETARG_sBx(i);break;}}if(testOpMode(op,OpModesetA)){if(a==reg)last=pc;}if( -testOpMode(op,OpModeT)){check(pc+2sizecode);check(GET_OPCODE(pt->code[pc+ -1])==OP_JMP);}switch(op){case OP_LOADBOOL:{check(c==0||pc+2sizecode); -break;}case OP_LOADNIL:{if(a<=reg&®<=b)last=pc;break;}case OP_GETUPVAL:case - OP_SETUPVAL:{check(bnups);break;}case OP_GETGLOBAL:case OP_SETGLOBAL:{ -check(ttisstring(&pt->k[b]));break;}case OP_SELF:{checkreg(pt,a+1);if(reg==a+1 -)last=pc;break;}case OP_CONCAT:{check(c=a)last=pc;case OP_FORLOOP:checkreg(pt,a+2);case -OP_JMP:{int dest=pc+1+b;check(0<=dest&&destsizecode);if(reg!=NO_REG&&pc< -dest&&dest<=lastpc)pc+=b;break;}case OP_CALL:case OP_TAILCALL:{if(b!=0){ -checkreg(pt,a+b-1);}c--;if(c==LUA_MULTRET){check(checkopenop(pt,pc));}else if( -c!=0)checkreg(pt,a+c-1);if(reg>=a)last=pc;break;}case OP_RETURN:{b--;if(b>0) -checkreg(pt,a+b-1);break;}case OP_SETLIST:{checkreg(pt,a+(b&(LFIELDS_PER_FLUSH --1))+1);break;}case OP_CLOSURE:{int nup;check(bsizep);nup=pt->p[b]->nups; -check(pc+nupsizecode);for(;nup>0;nup--){OpCode op1=GET_OPCODE(pt->code[pc -+nup]);check(op1==OP_GETUPVAL||op1==OP_MOVE);}break;}default:break;}}return pt -->code[last];} -#undef check -#undef checkjump -#undef checkreg -int luaG_checkcode(const Proto*pt){return luaG_symbexec(pt,pt->sizecode,NO_REG -);}static const char*kname(Proto*p,int c){c=c-MAXSTACK;if(c>=0&&ttisstring(&p -->k[c]))return svalue(&p->k[c]);else return"?";}static const char*getobjname( -CallInfo*ci,int stackpos,const char**name){if(isLua(ci)){Proto*p=ci_func(ci)-> -l.p;int pc=currentpc(ci);Instruction i;*name=luaF_getlocalname(p,stackpos+1,pc -);if(*name)return"local";i=luaG_symbexec(p,pc,stackpos);lua_assert(pc!=-1); -switch(GET_OPCODE(i)){case OP_GETGLOBAL:{int g=GETARG_Bx(i);lua_assert( -ttisstring(&p->k[g]));*name=svalue(&p->k[g]);return"global";}case OP_MOVE:{int - a=GETARG_A(i);int b=GETARG_B(i);if(bu.l.tailcalls>0)||!isLua(ci-1))return NULL;ci ---;i=ci_func(ci)->l.p->code[currentpc(ci)];if(GET_OPCODE(i)==OP_CALL|| -GET_OPCODE(i)==OP_TAILCALL)return getobjname(ci,GETARG_A(i),name);else return -NULL;}static int isinstack(CallInfo*ci,const TObject*o){StkId p;for(p=ci->base -;ptop;p++)if(o==p)return 1;return 0;}void luaG_typeerror(lua_State*L, -const TObject*o,const char*op){const char*name=NULL;const char*t= -luaT_typenames[ttype(o)];const char*kind=(isinstack(L->ci,o))?getobjname(L->ci -,o-L->base,&name):NULL;if(kind)luaG_runerror(L, -"attempt to %s %s `%s' (a %s value)",op,kind,name,t);else luaG_runerror(L, -"attempt to %s a %s value",op,t);}void luaG_concaterror(lua_State*L,StkId p1, -StkId p2){if(ttisstring(p1))p1=p2;lua_assert(!ttisstring(p1));luaG_typeerror(L -,p1,"concatenate");}void luaG_aritherror(lua_State*L,const TObject*p1,const -TObject*p2){TObject temp;if(luaV_tonumber(p1,&temp)==NULL)p2=p1;luaG_typeerror -(L,p2,"perform arithmetic on");}int luaG_ordererror(lua_State*L,const TObject* -p1,const TObject*p2){const char*t1=luaT_typenames[ttype(p1)];const char*t2= -luaT_typenames[ttype(p2)];if(t1[2]==t2[2])luaG_runerror(L, -"attempt to compare two %s values",t1);else luaG_runerror(L, -"attempt to compare %s with %s",t1,t2);return 0;}static void addinfo(lua_State -*L,const char*msg){CallInfo*ci=L->ci;if(isLua(ci)){char buff[LUA_IDSIZE];int -line=currentline(ci);luaO_chunkid(buff,getstr(getluaproto(ci)->source), -LUA_IDSIZE);luaO_pushfstring(L,"%s:%d: %s",buff,line,msg);}}void luaG_errormsg -(lua_State*L){if(L->errfunc!=0){StkId errfunc=restorestack(L,L->errfunc);if(! -ttisfunction(errfunc))luaD_throw(L,LUA_ERRERR);setobjs2s(L->top,L->top-1); -setobjs2s(L->top-1,errfunc);incr_top(L);luaD_call(L,L->top-2,1);}luaD_throw(L, -LUA_ERRRUN);}void luaG_runerror(lua_State*L,const char*fmt,...){va_list argp; -va_start(argp,fmt);addinfo(L,luaO_pushvfstring(L,fmt,argp));va_end(argp); -luaG_errormsg(L);} -#line 1 "ldo.c" -#define ldo_c -struct lua_longjmp{struct lua_longjmp*previous;jmp_buf b;volatile int status;} -;static void seterrorobj(lua_State*L,int errcode,StkId oldtop){switch(errcode) -{case LUA_ERRMEM:{setsvalue2s(oldtop,luaS_new(L,MEMERRMSG));break;}case -LUA_ERRERR:{setsvalue2s(oldtop,luaS_new(L,"error in error handling"));break;} -case LUA_ERRSYNTAX:case LUA_ERRRUN:{setobjs2s(oldtop,L->top-1);break;}}L->top= -oldtop+1;}void luaD_throw(lua_State*L,int errcode){if(L->errorJmp){L->errorJmp -->status=errcode;longjmp(L->errorJmp->b,1);}else{G(L)->panic(L);exit( -EXIT_FAILURE);}}int luaD_rawrunprotected(lua_State*L,Pfunc f,void*ud){struct -lua_longjmp lj;lj.status=0;lj.previous=L->errorJmp;L->errorJmp=&lj;if(setjmp( -lj.b)==0)(*f)(L,ud);L->errorJmp=lj.previous;return lj.status;}static void -restore_stack_limit(lua_State*L){L->stack_last=L->stack+L->stacksize-1;if(L-> -size_ci>LUA_MAXCALLS){int inuse=(L->ci-L->base_ci);if(inuse+1top=(L->top-oldstack)+L->stack;for(up=L-> -openupval;up!=NULL;up=up->gch.next)gcotouv(up)->v=(gcotouv(up)->v-oldstack)+L -->stack;for(ci=L->base_ci;ci<=L->ci;ci++){ci->top=(ci->top-oldstack)+L->stack; -ci->base=(ci->base-oldstack)+L->stack;}L->base=L->ci->base;}void -luaD_reallocstack(lua_State*L,int newsize){TObject*oldstack=L->stack; -luaM_reallocvector(L,L->stack,L->stacksize,newsize,TObject);L->stacksize= -newsize;L->stack_last=L->stack+newsize-1-EXTRA_STACK;correctstack(L,oldstack); -}void luaD_reallocCI(lua_State*L,int newsize){CallInfo*oldci=L->base_ci; -luaM_reallocvector(L,L->base_ci,L->size_ci,newsize,CallInfo);L->size_ci=cast( -unsigned short,newsize);L->ci=(L->ci-oldci)+L->base_ci;L->end_ci=L->base_ci+L -->size_ci;}void luaD_growstack(lua_State*L,int n){if(n<=L->stacksize) -luaD_reallocstack(L,2*L->stacksize);else luaD_reallocstack(L,L->stacksize+n+ -EXTRA_STACK);}static void luaD_growCI(lua_State*L){if(L->size_ci>LUA_MAXCALLS) -luaD_throw(L,LUA_ERRERR);else{luaD_reallocCI(L,2*L->size_ci);if(L->size_ci> -LUA_MAXCALLS)luaG_runerror(L,"stack overflow");}}void luaD_callhook(lua_State* -L,int event,int line){lua_Hook hook=L->hook;if(hook&&L->allowhook){ptrdiff_t -top=savestack(L,L->top);ptrdiff_t ci_top=savestack(L,L->ci->top);lua_Debug ar; -ar.event=event;ar.currentline=line;if(event==LUA_HOOKTAILRET)ar.i_ci=0;else ar -.i_ci=L->ci-L->base_ci;luaD_checkstack(L,LUA_MINSTACK);L->ci->top=L->top+ -LUA_MINSTACK;L->allowhook=0;lua_unlock(L);(*hook)(L,&ar);lua_lock(L); -lua_assert(!L->allowhook);L->allowhook=1;L->ci->top=restorestack(L,ci_top);L-> -top=restorestack(L,top);}}static void adjust_varargs(lua_State*L,int nfixargs, -StkId base){int i;Table*htab;TObject nname;int actual=L->top-base;if(actual< -nfixargs){luaD_checkstack(L,nfixargs-actual);for(;actualtop++);}actual-=nfixargs;htab=luaH_new(L,actual,1);for(i=0;i< -actual;i++)setobj2n(luaH_setnum(L,htab,i+1),L->top-actual+i);setsvalue(&nname, -luaS_newliteral(L,"n"));setnvalue(luaH_set(L,htab,&nname),cast(lua_Number, -actual));L->top-=actual;sethvalue(L->top,htab);incr_top(L);}static StkId -tryfuncTM(lua_State*L,StkId func){const TObject*tm=luaT_gettmbyobj(L,func, -TM_CALL);StkId p;ptrdiff_t funcr=savestack(L,func);if(!ttisfunction(tm)) -luaG_typeerror(L,func,"call");for(p=L->top;p>func;p--)setobjs2s(p,p-1); -incr_top(L);func=restorestack(L,funcr);setobj2s(func,tm);return func;}StkId -luaD_precall(lua_State*L,StkId func){LClosure*cl;ptrdiff_t funcr=savestack(L, -func);if(!ttisfunction(func))func=tryfuncTM(L,func);if(L->ci+1==L->end_ci) -luaD_growCI(L);else condhardstacktests(luaD_reallocCI(L,L->size_ci));cl=& -clvalue(func)->l;if(!cl->isC){CallInfo*ci;Proto*p=cl->p;if(p->is_vararg) -adjust_varargs(L,p->numparams,func+1);luaD_checkstack(L,p->maxstacksize);ci=++ -L->ci;L->base=L->ci->base=restorestack(L,funcr)+1;ci->top=L->base+p-> -maxstacksize;ci->u.l.savedpc=p->code;ci->u.l.tailcalls=0;ci->state=CI_SAVEDPC; -while(L->toptop)setnilvalue(L->top++);L->top=ci->top;return NULL;}else{ -CallInfo*ci;int n;luaD_checkstack(L,LUA_MINSTACK);ci=++L->ci;L->base=L->ci-> -base=restorestack(L,funcr)+1;ci->top=L->top+LUA_MINSTACK;ci->state=CI_C;if(L-> -hookmask&LUA_MASKCALL)luaD_callhook(L,LUA_HOOKCALL,-1);lua_unlock(L); -#ifdef LUA_COMPATUPVALUES -lua_pushupvalues(L); -#endif -n=(*clvalue(L->base-1)->c.f)(L);lua_lock(L);return L->top-n;}}static StkId -callrethooks(lua_State*L,StkId firstResult){ptrdiff_t fr=savestack(L, -firstResult);luaD_callhook(L,LUA_HOOKRET,-1);if(!(L->ci->state&CI_C)){while(L -->ci->u.l.tailcalls--)luaD_callhook(L,LUA_HOOKTAILRET,-1);}return restorestack -(L,fr);}void luaD_poscall(lua_State*L,int wanted,StkId firstResult){StkId res; -if(L->hookmask&LUA_MASKRET)firstResult=callrethooks(L,firstResult);res=L->base --1;L->ci--;L->base=L->ci->base;while(wanted!=0&&firstResulttop){setobjs2s( -res++,firstResult++);wanted--;}while(wanted-->0)setnilvalue(res++);L->top=res; -}void luaD_call(lua_State*L,StkId func,int nResults){StkId firstResult; -lua_assert(!(L->ci->state&CI_CALLING));if(++L->nCcalls>=LUA_MAXCCALLS){if(L-> -nCcalls==LUA_MAXCCALLS)luaG_runerror(L,"C stack overflow");else if(L->nCcalls ->=(LUA_MAXCCALLS+(LUA_MAXCCALLS>>3)))luaD_throw(L,LUA_ERRERR);}firstResult= -luaD_precall(L,func);if(firstResult==NULL)firstResult=luaV_execute(L); -luaD_poscall(L,nResults,firstResult);L->nCcalls--;luaC_checkGC(L);}static void - resume(lua_State*L,void*ud){StkId firstResult;int nargs=*cast(int*,ud); -CallInfo*ci=L->ci;if(ci==L->base_ci){lua_assert(nargstop-L->base); -luaD_precall(L,L->top-(nargs+1));}else{lua_assert(ci->state&CI_YIELD);if(ci-> -state&CI_C){int nresults;lua_assert((ci-1)->state&CI_SAVEDPC);lua_assert( -GET_OPCODE(*((ci-1)->u.l.savedpc-1))==OP_CALL||GET_OPCODE(*((ci-1)->u.l. -savedpc-1))==OP_TAILCALL);nresults=GETARG_C(*((ci-1)->u.l.savedpc-1))-1; -luaD_poscall(L,nresults,L->top-nargs);if(nresults>=0)L->top=L->ci->top;}else{ -ci->state&=~CI_YIELD;}}firstResult=luaV_execute(L);if(firstResult!=NULL) -luaD_poscall(L,LUA_MULTRET,firstResult);}static int resume_error(lua_State*L, -const char*msg){L->top=L->ci->base;setsvalue2s(L->top,luaS_new(L,msg)); -incr_top(L);lua_unlock(L);return LUA_ERRRUN;}LUA_API int lua_resume(lua_State* -L,int nargs){int status;lu_byte old_allowhooks;lua_lock(L);if(L->ci==L-> -base_ci){if(nargs>=L->top-L->base)return resume_error(L, -"cannot resume dead coroutine");}else if(!(L->ci->state&CI_YIELD))return -resume_error(L,"cannot resume non-suspended coroutine");old_allowhooks=L-> -allowhook;lua_assert(L->errfunc==0&&L->nCcalls==0);status=luaD_rawrunprotected -(L,resume,&nargs);if(status!=0){L->ci=L->base_ci;L->base=L->ci->base;L-> -nCcalls=0;luaF_close(L,L->base);seterrorobj(L,status,L->base);L->allowhook= -old_allowhooks;restore_stack_limit(L);}lua_unlock(L);return status;}LUA_API -int lua_yield(lua_State*L,int nresults){CallInfo*ci;lua_lock(L);ci=L->ci;if(L -->nCcalls>0)luaG_runerror(L, -"attempt to yield across metamethod/C-call boundary");if(ci->state&CI_C){if(( -ci-1)->state&CI_C)luaG_runerror(L,"cannot yield a C function");if(L->top- -nresults>L->base){int i;for(i=0;ibase+i,L->top- -nresults+i);L->top=L->base+nresults;}}ci->state|=CI_YIELD;lua_unlock(L);return --1;}int luaD_pcall(lua_State*L,Pfunc func,void*u,ptrdiff_t old_top,ptrdiff_t -ef){int status;unsigned short oldnCcalls=L->nCcalls;ptrdiff_t old_ci=saveci(L, -L->ci);lu_byte old_allowhooks=L->allowhook;ptrdiff_t old_errfunc=L->errfunc;L -->errfunc=ef;status=luaD_rawrunprotected(L,func,u);if(status!=0){StkId oldtop= -restorestack(L,old_top);luaF_close(L,oldtop);seterrorobj(L,status,oldtop);L-> -nCcalls=oldnCcalls;L->ci=restoreci(L,old_ci);L->base=L->ci->base;L->allowhook= -old_allowhooks;restore_stack_limit(L);}L->errfunc=old_errfunc;return status;} -struct SParser{ZIO*z;Mbuffer buff;int bin;};static void f_parser(lua_State*L, -void*ud){struct SParser*p;Proto*tf;Closure*cl;luaC_checkGC(L);p=cast(struct -SParser*,ud);tf=p->bin?luaU_undump(L,p->z,&p->buff):luaY_parser(L,p->z,&p-> -buff);cl=luaF_newLclosure(L,0,gt(L));cl->l.p=tf;setclvalue(L->top,cl);incr_top -(L);}int luaD_protectedparser(lua_State*L,ZIO*z,int bin){struct SParser p;int -status;ptrdiff_t oldtopr=savestack(L,L->top);p.z=z;p.bin=bin;luaZ_initbuffer(L -,&p.buff);status=luaD_rawrunprotected(L,f_parser,&p);luaZ_freebuffer(L,&p.buff -);if(status!=0){StkId oldtop=restorestack(L,oldtopr);seterrorobj(L,status, -oldtop);}return status;} -#line 1 "ldump.c" -#define ldump_c -#define DumpVector(b,n,size,D) DumpBlock(b,(n)*(size),D) -#define DumpLiteral(s,D) DumpBlock(""s,(sizeof(s))-1,D) -typedef struct{lua_State*L;lua_Chunkwriter write;void*data;}DumpState;static -void DumpBlock(const void*b,size_t size,DumpState*D){lua_unlock(D->L);(*D-> -write)(D->L,b,size,D->data);lua_lock(D->L);}static void DumpByte(int y, -DumpState*D){char x=(char)y;DumpBlock(&x,sizeof(x),D);}static void DumpInt(int - x,DumpState*D){DumpBlock(&x,sizeof(x),D);}static void DumpSize(size_t x, -DumpState*D){DumpBlock(&x,sizeof(x),D);}static void DumpNumber(lua_Number x, -DumpState*D){DumpBlock(&x,sizeof(x),D);}static void DumpString(TString*s, -DumpState*D){if(s==NULL||getstr(s)==NULL)DumpSize(0,D);else{size_t size=s->tsv -.len+1;DumpSize(size,D);DumpBlock(getstr(s),size,D);}}static void DumpCode( -const Proto*f,DumpState*D){DumpInt(f->sizecode,D);DumpVector(f->code,f-> -sizecode,sizeof(*f->code),D);}static void DumpLocals(const Proto*f,DumpState*D -){int i,n=f->sizelocvars;DumpInt(n,D);for(i=0;ilocvars[i -].varname,D);DumpInt(f->locvars[i].startpc,D);DumpInt(f->locvars[i].endpc,D);} -}static void DumpLines(const Proto*f,DumpState*D){DumpInt(f->sizelineinfo,D); -DumpVector(f->lineinfo,f->sizelineinfo,sizeof(*f->lineinfo),D);}static void -DumpUpvalues(const Proto*f,DumpState*D){int i,n=f->sizeupvalues;DumpInt(n,D); -for(i=0;iupvalues[i],D);}static void DumpFunction(const -Proto*f,const TString*p,DumpState*D);static void DumpConstants(const Proto*f, -DumpState*D){int i,n;DumpInt(n=f->sizek,D);for(i=0;ik[i];DumpByte(ttype(o),D);switch(ttype(o)){case LUA_TNUMBER:DumpNumber( -nvalue(o),D);break;case LUA_TSTRING:DumpString(tsvalue(o),D);break;case -LUA_TNIL:break;default:lua_assert(0);break;}}DumpInt(n=f->sizep,D);for(i=0;ip[i],f->source,D);}static void DumpFunction(const Proto*f -,const TString*p,DumpState*D){DumpString((f->source==p)?NULL:f->source,D); -DumpInt(f->lineDefined,D);DumpByte(f->nups,D);DumpByte(f->numparams,D); -DumpByte(f->is_vararg,D);DumpByte(f->maxstacksize,D);DumpLines(f,D);DumpLocals -(f,D);DumpUpvalues(f,D);DumpConstants(f,D);DumpCode(f,D);}static void -DumpHeader(DumpState*D){DumpLiteral(LUA_SIGNATURE,D);DumpByte(VERSION,D); -DumpByte(luaU_endianness(),D);DumpByte(sizeof(int),D);DumpByte(sizeof(size_t), -D);DumpByte(sizeof(Instruction),D);DumpByte(SIZE_OP,D);DumpByte(SIZE_A,D); -DumpByte(SIZE_B,D);DumpByte(SIZE_C,D);DumpByte(sizeof(lua_Number),D); -DumpNumber(TEST_NUMBER,D);}void luaU_dump(lua_State*L,const Proto*Main, -lua_Chunkwriter w,void*data){DumpState D;D.L=L;D.write=w;D.data=data; -DumpHeader(&D);DumpFunction(Main,NULL,&D);} -#line 1 "lfunc.c" -#define lfunc_c -#define sizeCclosure(n) (cast(int,sizeof(CClosure))+cast(int,sizeof(TObject)*(\ -(n)-1))) -#define sizeLclosure(n) (cast(int,sizeof(LClosure))+cast(int,sizeof(TObject*)*\ -((n)-1))) -Closure*luaF_newCclosure(lua_State*L,int nelems){Closure*c=cast(Closure*, -luaM_malloc(L,sizeCclosure(nelems)));luaC_link(L,valtogco(c),LUA_TFUNCTION);c -->c.isC=1;c->c.nupvalues=cast(lu_byte,nelems);return c;}Closure* -luaF_newLclosure(lua_State*L,int nelems,TObject*e){Closure*c=cast(Closure*, -luaM_malloc(L,sizeLclosure(nelems)));luaC_link(L,valtogco(c),LUA_TFUNCTION);c -->l.isC=0;c->l.g=*e;c->l.nupvalues=cast(lu_byte,nelems);return c;}UpVal* -luaF_findupval(lua_State*L,StkId level){GCObject**pp=&L->openupval;UpVal*p; -UpVal*v;while((p=ngcotouv(*pp))!=NULL&&p->v>=level){if(p->v==level)return p;pp -=&p->next;}v=luaM_new(L,UpVal);v->tt=LUA_TUPVAL;v->marked=1;v->v=level;v->next -=*pp;*pp=valtogco(v);return v;}void luaF_close(lua_State*L,StkId level){UpVal* -p;while((p=ngcotouv(L->openupval))!=NULL&&p->v>=level){setobj(&p->value,p->v); -p->v=&p->value;L->openupval=p->next;luaC_link(L,valtogco(p),LUA_TUPVAL);}} -Proto*luaF_newproto(lua_State*L){Proto*f=luaM_new(L,Proto);luaC_link(L, -valtogco(f),LUA_TPROTO);f->k=NULL;f->sizek=0;f->p=NULL;f->sizep=0;f->code=NULL -;f->sizecode=0;f->sizelineinfo=0;f->sizeupvalues=0;f->nups=0;f->upvalues=NULL; -f->numparams=0;f->is_vararg=0;f->maxstacksize=0;f->lineinfo=NULL;f-> -sizelocvars=0;f->locvars=NULL;f->lineDefined=0;f->source=NULL;return f;}void -luaF_freeproto(lua_State*L,Proto*f){luaM_freearray(L,f->code,f->sizecode, -Instruction);luaM_freearray(L,f->p,f->sizep,Proto*);luaM_freearray(L,f->k,f-> -sizek,TObject);luaM_freearray(L,f->lineinfo,f->sizelineinfo,int); -luaM_freearray(L,f->locvars,f->sizelocvars,struct LocVar);luaM_freearray(L,f-> -upvalues,f->sizeupvalues,TString*);luaM_freelem(L,f);}void luaF_freeclosure( -lua_State*L,Closure*c){int size=(c->c.isC)?sizeCclosure(c->c.nupvalues): -sizeLclosure(c->l.nupvalues);luaM_free(L,c,size);}const char*luaF_getlocalname -(const Proto*f,int local_number,int pc){int i;for(i=0;isizelocvars&&f-> -locvars[i].startpc<=pc;i++){if(pclocvars[i].endpc){local_number--;if( -local_number==0)return getstr(f->locvars[i].varname);}}return NULL;} -#line 1 "lgc.c" -#define lgc_c -typedef struct GCState{GCObject*tmark;GCObject*wk;GCObject*wv;GCObject*wkv; -global_State*g;}GCState; -#define setbit(x,b) ((x)|=(1<<(b))) -#define resetbit(x,b) ((x)&=cast(lu_byte,~(1<<(b)))) -#define testbit(x,b) ((x)&(1<<(b))) -#define unmark(x) resetbit((x)->gch.marked,0) -#define ismarked(x) ((x)->gch.marked&((1<<4)|1)) -#define stringmark(s) setbit((s)->tsv.marked,0) -#define isfinalized(u) (!testbit((u)->uv.marked,1)) -#define markfinalized(u) resetbit((u)->uv.marked,1) -#define KEYWEAKBIT 1 -#define VALUEWEAKBIT 2 -#define KEYWEAK (1<gch.marked,0);switch(o->gch.tt){case LUA_TUSERDATA:{markvalue(st, -gcotou(o)->uv.metatable);break;}case LUA_TFUNCTION:{gcotocl(o)->c.gclist=st-> -tmark;st->tmark=o;break;}case LUA_TTABLE:{gcotoh(o)->gclist=st->tmark;st-> -tmark=o;break;}case LUA_TTHREAD:{gcototh(o)->gclist=st->tmark;st->tmark=o; -break;}case LUA_TPROTO:{gcotop(o)->gclist=st->tmark;st->tmark=o;break;}default -:lua_assert(o->gch.tt==LUA_TSTRING);}}static void marktmu(GCState*st){GCObject -*u;for(u=st->g->tmudata;u;u=u->gch.next){unmark(u);reallymarkobject(st,u);}} -size_t luaC_separateudata(lua_State*L){size_t deadmem=0;GCObject**p=&G(L)-> -rootudata;GCObject*curr;GCObject*collected=NULL;GCObject**lastcollected=& -collected;while((curr=*p)!=NULL){lua_assert(curr->gch.tt==LUA_TUSERDATA);if( -ismarked(curr)||isfinalized(gcotou(curr)))p=&curr->gch.next;else if(fasttm(L, -gcotou(curr)->uv.metatable,TM_GC)==NULL){markfinalized(gcotou(curr));p=&curr-> -gch.next;}else{deadmem+=sizeudata(gcotou(curr)->uv.len);*p=curr->gch.next;curr -->gch.next=NULL;*lastcollected=curr;lastcollected=&curr->gch.next;}}* -lastcollected=G(L)->tmudata;G(L)->tmudata=collected;return deadmem;}static -void removekey(Node*n){setnilvalue(gval(n));if(iscollectable(gkey(n)))setttype -(gkey(n),LUA_TNONE);}static void traversetable(GCState*st,Table*h){int i;int -weakkey=0;int weakvalue=0;const TObject*mode;markvalue(st,h->metatable); -lua_assert(h->lsizenode||h->node==st->g->dummynode);mode=gfasttm(st->g,h-> -metatable,TM_MODE);if(mode&&ttisstring(mode)){weakkey=(strchr(svalue(mode),'k' -)!=NULL);weakvalue=(strchr(svalue(mode),'v')!=NULL);if(weakkey||weakvalue){ -GCObject**weaklist;h->marked&=~(KEYWEAK|VALUEWEAK);h->marked|=cast(lu_byte,( -weakkey<wkv:(weakkey)?&st->wk:&st->wv;h->gclist=*weaklist;*weaklist=valtogco(h);} -}if(!weakvalue){i=h->sizearray;while(i--)markobject(st,&h->array[i]);}i= -sizenode(h);while(i--){Node*n=gnode(h,i);if(!ttisnil(gval(n))){lua_assert(! -ttisnil(gkey(n)));condmarkobject(st,gkey(n),!weakkey);condmarkobject(st,gval(n -),!weakvalue);}}}static void traverseproto(GCState*st,Proto*f){int i; -stringmark(f->source);for(i=0;isizek;i++){if(ttisstring(f->k+i))stringmark -(tsvalue(f->k+i));}for(i=0;isizeupvalues;i++)stringmark(f->upvalues[i]); -for(i=0;isizep;i++)markvalue(st,f->p[i]);for(i=0;isizelocvars;i++) -stringmark(f->locvars[i].varname);lua_assert(luaG_checkcode(f));}static void -traverseclosure(GCState*st,Closure*cl){if(cl->c.isC){int i;for(i=0;ic. -nupvalues;i++)markobject(st,&cl->c.upvalue[i]);}else{int i;lua_assert(cl->l. -nupvalues==cl->l.p->nups);markvalue(st,hvalue(&cl->l.g));markvalue(st,cl->l.p) -;for(i=0;il.nupvalues;i++){UpVal*u=cl->l.upvals[i];if(!u->marked){ -markobject(st,&u->value);u->marked=1;}}}}static void checkstacksizes(lua_State -*L,StkId max){int used=L->ci-L->base_ci;if(4*usedsize_ci&&2*BASIC_CI_SIZE< -L->size_ci)luaD_reallocCI(L,L->size_ci/2);else condhardstacktests( -luaD_reallocCI(L,L->size_ci));used=max-L->stack;if(4*usedstacksize&&2*( -BASIC_STACK_SIZE+EXTRA_STACK)stacksize)luaD_reallocstack(L,L->stacksize/2) -;else condhardstacktests(luaD_reallocstack(L,L->stacksize));}static void -traversestack(GCState*st,lua_State*L1){StkId o,lim;CallInfo*ci;markobject(st, -gt(L1));lim=L1->top;for(ci=L1->base_ci;ci<=L1->ci;ci++){lua_assert(ci->top<=L1 -->stack_last);lua_assert(ci->state&(CI_C|CI_HASFRAME|CI_SAVEDPC));if(lim -top)lim=ci->top;}for(o=L1->stack;otop;o++)markobject(st,o);for(;o<=lim;o -++)setnilvalue(o);checkstacksizes(L1,lim);}static void propagatemarks(GCState* -st){while(st->tmark){switch(st->tmark->gch.tt){case LUA_TTABLE:{Table*h=gcotoh -(st->tmark);st->tmark=h->gclist;traversetable(st,h);break;}case LUA_TFUNCTION: -{Closure*cl=gcotocl(st->tmark);st->tmark=cl->c.gclist;traverseclosure(st,cl); -break;}case LUA_TTHREAD:{lua_State*th=gcototh(st->tmark);st->tmark=th->gclist; -traversestack(st,th);break;}case LUA_TPROTO:{Proto*p=gcotop(st->tmark);st-> -tmark=p->gclist;traverseproto(st,p);break;}default:lua_assert(0);}}}static int - valismarked(const TObject*o){if(ttisstring(o))stringmark(tsvalue(o));return! -iscollectable(o)||testbit(o->value.gc->gch.marked,0);}static void -cleartablekeys(GCObject*l){while(l){Table*h=gcotoh(l);int i=sizenode(h); -lua_assert(h->marked&KEYWEAK);while(i--){Node*n=gnode(h,i);if(!valismarked( -gkey(n)))removekey(n);}l=h->gclist;}}static void cleartablevalues(GCObject*l){ -while(l){Table*h=gcotoh(l);int i=h->sizearray;lua_assert(h->marked&VALUEWEAK); -while(i--){TObject*o=&h->array[i];if(!valismarked(o))setnilvalue(o);}i= -sizenode(h);while(i--){Node*n=gnode(h,i);if(!valismarked(gval(n)))removekey(n) -;}l=h->gclist;}}static void freeobj(lua_State*L,GCObject*o){switch(o->gch.tt){ -case LUA_TPROTO:luaF_freeproto(L,gcotop(o));break;case LUA_TFUNCTION: -luaF_freeclosure(L,gcotocl(o));break;case LUA_TUPVAL:luaM_freelem(L,gcotouv(o) -);break;case LUA_TTABLE:luaH_free(L,gcotoh(o));break;case LUA_TTHREAD:{ -lua_assert(gcototh(o)!=L&&gcototh(o)!=G(L)->mainthread);luaE_freethread(L, -gcototh(o));break;}case LUA_TSTRING:{luaM_free(L,o,sizestring(gcotots(o)->tsv. -len));break;}case LUA_TUSERDATA:{luaM_free(L,o,sizeudata(gcotou(o)->uv.len)); -break;}default:lua_assert(0);}}static int sweeplist(lua_State*L,GCObject**p, -int limit){GCObject*curr;int count=0;while((curr=*p)!=NULL){if(curr->gch. -marked>limit){unmark(curr);p=&curr->gch.next;}else{count++;*p=curr->gch.next; -freeobj(L,curr);}}return count;}static void sweepstrings(lua_State*L,int all){ -int i;for(i=0;istrt.size;i++){G(L)->strt.nuse-=sweeplist(L,&G(L)->strt. -hash[i],all);}}static void checkSizes(lua_State*L,size_t deadmem){if(G(L)-> -strt.nusestrt.size/4)&&G(L)->strt.size>MINSTRTABSIZE*2) -luaS_resize(L,G(L)->strt.size/2);if(luaZ_sizebuffer(&G(L)->buff)>LUA_MINBUFFER -*2){size_t newsize=luaZ_sizebuffer(&G(L)->buff)/2;luaZ_resizebuffer(L,&G(L)-> -buff,newsize);}G(L)->GCthreshold=2*G(L)->nblocks-deadmem;}static void do1gcTM( -lua_State*L,Udata*udata){const TObject*tm=fasttm(L,udata->uv.metatable,TM_GC); -if(tm!=NULL){setobj2s(L->top,tm);setuvalue(L->top+1,udata);L->top+=2;luaD_call -(L,L->top-2,0);}}void luaC_callGCTM(lua_State*L){lu_byte oldah=L->allowhook;L -->allowhook=0;L->top++;while(G(L)->tmudata!=NULL){GCObject*o=G(L)->tmudata; -Udata*udata=gcotou(o);G(L)->tmudata=udata->uv.next;udata->uv.next=G(L)-> -rootudata;G(L)->rootudata=o;setuvalue(L->top-1,udata);unmark(o);markfinalized( -udata);do1gcTM(L,udata);}L->top--;L->allowhook=oldah;}void luaC_sweep( -lua_State*L,int all){if(all)all=256;sweeplist(L,&G(L)->rootudata,all); -sweepstrings(L,all);sweeplist(L,&G(L)->rootgc,all);}static void markroot( -GCState*st,lua_State*L){global_State*g=st->g;markobject(st,defaultmeta(L)); -markobject(st,registry(L));traversestack(st,g->mainthread);if(L!=g->mainthread -)markvalue(st,L);}static size_t mark(lua_State*L){size_t deadmem;GCState st; -GCObject*wkv;st.g=G(L);st.tmark=NULL;st.wkv=st.wk=st.wv=NULL;markroot(&st,L); -propagatemarks(&st);cleartablevalues(st.wkv);cleartablevalues(st.wv);wkv=st. -wkv;st.wkv=NULL;st.wv=NULL;deadmem=luaC_separateudata(L);marktmu(&st); -propagatemarks(&st);cleartablekeys(wkv);cleartablekeys(st.wk);cleartablevalues -(st.wv);cleartablekeys(st.wkv);cleartablevalues(st.wkv);return deadmem;}void -luaC_collectgarbage(lua_State*L){size_t deadmem=mark(L);luaC_sweep(L,0); -checkSizes(L,deadmem);luaC_callGCTM(L);}void luaC_link(lua_State*L,GCObject*o, -lu_byte tt){o->gch.next=G(L)->rootgc;G(L)->rootgc=o;o->gch.marked=0;o->gch.tt= -tt;} -#line 1 "liolib.c" -#define liolib_c -#ifndef USE_TMPNAME -#ifdef __GNUC__ -#define USE_TMPNAME 0 -#else -#define USE_TMPNAME 1 -#endif -#endif -#ifndef USE_POPEN -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >=2 -#define USE_POPEN 1 -#endif -#endif -#endif -#ifndef USE_POPEN -#define USE_POPEN 0 -#endif -#if !USE_POPEN -#define pclose(f) (-1) -#endif -#define FILEHANDLE "FILE*" -#define IO_INPUT "_input" -#define IO_OUTPUT "_output" -static int pushresult(lua_State*L,int i,const char*filename){if(i){ -lua_pushboolean(L,1);return 1;}else{lua_pushnil(L);if(filename)lua_pushfstring -(L,"%s: %s",filename,strerror(errno));else lua_pushfstring(L,"%s",strerror( -errno));lua_pushnumber(L,errno);return 3;}}static FILE**topfile(lua_State*L, -int findex){FILE**f=(FILE**)luaL_checkudata(L,findex,FILEHANDLE);if(f==NULL) -luaL_argerror(L,findex,"bad file");return f;}static int io_type(lua_State*L){ -FILE**f=(FILE**)luaL_checkudata(L,1,FILEHANDLE);if(f==NULL)lua_pushnil(L);else - if(*f==NULL)lua_pushliteral(L,"closed file");else lua_pushliteral(L,"file"); -return 1;}static FILE*tofile(lua_State*L,int findex){FILE**f=topfile(L,findex) -;if(*f==NULL)luaL_error(L,"attempt to use a closed file");return*f;}static -FILE**newfile(lua_State*L){FILE**pf=(FILE**)lua_newuserdata(L,sizeof(FILE*));* -pf=NULL;luaL_getmetatable(L,FILEHANDLE);lua_setmetatable(L,-2);return pf;} -static void registerfile(lua_State*L,FILE*f,const char*name,const char*impname -){lua_pushstring(L,name);*newfile(L)=f;if(impname){lua_pushstring(L,impname); -lua_pushvalue(L,-2);lua_settable(L,-6);}lua_settable(L,-3);}static int -aux_close(lua_State*L){FILE*f=tofile(L,1);if(f==stdin||f==stdout||f==stderr) -return 0;else{int ok=(pclose(f)!=-1)||(fclose(f)==0);if(ok)*(FILE**) -lua_touserdata(L,1)=NULL;return ok;}}static int io_close(lua_State*L){if( -lua_isnone(L,1)&&lua_type(L,lua_upvalueindex(1))==LUA_TTABLE){lua_pushstring(L -,IO_OUTPUT);lua_rawget(L,lua_upvalueindex(1));}return pushresult(L,aux_close(L -),NULL);}static int io_gc(lua_State*L){FILE**f=topfile(L,1);if(*f!=NULL) -aux_close(L);return 0;}static int io_tostring(lua_State*L){char buff[128];FILE -**f=topfile(L,1);if(*f==NULL)strcpy(buff,"closed");else sprintf(buff,"%p", -lua_touserdata(L,1));lua_pushfstring(L,"file (%s)",buff);return 1;}static int -io_open(lua_State*L){const char*filename=luaL_checkstring(L,1);const char*mode -=luaL_optstring(L,2,"r");FILE**pf=newfile(L);*pf=fopen(filename,mode);return(* -pf==NULL)?pushresult(L,0,filename):1;}static int io_popen(lua_State*L){ -#if !USE_POPEN -luaL_error(L,"`popen' not supported");return 0; -#else -const char*filename=luaL_checkstring(L,1);const char*mode=luaL_optstring(L,2, -"r");FILE**pf=newfile(L);*pf=popen(filename,mode);return(*pf==NULL)?pushresult -(L,0,filename):1; -#endif -}static int io_tmpfile(lua_State*L){FILE**pf=newfile(L);*pf=tmpfile();return(* -pf==NULL)?pushresult(L,0,NULL):1;}static FILE*getiofile(lua_State*L,const char -*name){lua_pushstring(L,name);lua_rawget(L,lua_upvalueindex(1));return tofile( -L,-1);}static int g_iofile(lua_State*L,const char*name,const char*mode){if(! -lua_isnoneornil(L,1)){const char*filename=lua_tostring(L,1);lua_pushstring(L, -name);if(filename){FILE**pf=newfile(L);*pf=fopen(filename,mode);if(*pf==NULL){ -lua_pushfstring(L,"%s: %s",filename,strerror(errno));luaL_argerror(L,1, -lua_tostring(L,-1));}}else{tofile(L,1);lua_pushvalue(L,1);}lua_rawset(L, -lua_upvalueindex(1));}lua_pushstring(L,name);lua_rawget(L,lua_upvalueindex(1)) -;return 1;}static int io_input(lua_State*L){return g_iofile(L,IO_INPUT,"r");} -static int io_output(lua_State*L){return g_iofile(L,IO_OUTPUT,"w");}static int - io_readline(lua_State*L);static void aux_lines(lua_State*L,int idx,int close) -{lua_pushliteral(L,FILEHANDLE);lua_rawget(L,LUA_REGISTRYINDEX);lua_pushvalue(L -,idx);lua_pushboolean(L,close);lua_pushcclosure(L,io_readline,3);}static int -f_lines(lua_State*L){tofile(L,1);aux_lines(L,1,0);return 1;}static int -io_lines(lua_State*L){if(lua_isnoneornil(L,1)){lua_pushstring(L,IO_INPUT); -lua_rawget(L,lua_upvalueindex(1));return f_lines(L);}else{const char*filename= -luaL_checkstring(L,1);FILE**pf=newfile(L);*pf=fopen(filename,"r"); -luaL_argcheck(L,*pf,1,strerror(errno));aux_lines(L,lua_gettop(L),1);return 1;} -}static int read_number(lua_State*L,FILE*f){lua_Number d;if(fscanf(f, -LUA_NUMBER_SCAN,&d)==1){lua_pushnumber(L,d);return 1;}else return 0;}static -int test_eof(lua_State*L,FILE*f){int c=getc(f);ungetc(c,f);lua_pushlstring(L, -NULL,0);return(c!=EOF);}static int read_line(lua_State*L,FILE*f){luaL_Buffer b -;luaL_buffinit(L,&b);for(;;){size_t l;char*p=luaL_prepbuffer(&b);if(fgets(p, -LUAL_BUFFERSIZE,f)==NULL){luaL_pushresult(&b);return(lua_strlen(L,-1)>0);}l= -strlen(p);if(p[l-1]!='\n')luaL_addsize(&b,l);else{luaL_addsize(&b,l-1); -luaL_pushresult(&b);return 1;}}}static int read_chars(lua_State*L,FILE*f, -size_t n){size_t rlen;size_t nr;luaL_Buffer b;luaL_buffinit(L,&b);rlen= -LUAL_BUFFERSIZE;do{char*p=luaL_prepbuffer(&b);if(rlen>n)rlen=n;nr=fread(p, -sizeof(char),rlen,f);luaL_addsize(&b,nr);n-=nr;}while(n>0&&nr==rlen); -luaL_pushresult(&b);return(n==0||lua_strlen(L,-1)>0);}static int g_read( -lua_State*L,FILE*f,int first){int nargs=lua_gettop(L)-1;int success;int n;if( -nargs==0){success=read_line(L,f);n=first+1;}else{luaL_checkstack(L,nargs+ -LUA_MINSTACK,"too many arguments");success=1;for(n=first;nargs--&&success;n++) -{if(lua_type(L,n)==LUA_TNUMBER){size_t l=(size_t)lua_tonumber(L,n);success=(l -==0)?test_eof(L,f):read_chars(L,f,l);}else{const char*p=lua_tostring(L,n); -luaL_argcheck(L,p&&p[0]=='*',n,"invalid option");switch(p[1]){case'n':success= -read_number(L,f);break;case'l':success=read_line(L,f);break;case'a':read_chars -(L,f,~((size_t)0));success=1;break;case'w':return luaL_error(L, -"obsolete option `*w' to `read'");default:return luaL_argerror(L,n, -"invalid format");}}}}if(!success){lua_pop(L,1);lua_pushnil(L);}return n-first -;}static int io_read(lua_State*L){return g_read(L,getiofile(L,IO_INPUT),1);} -static int f_read(lua_State*L){return g_read(L,tofile(L,1),2);}static int -io_readline(lua_State*L){FILE*f=*(FILE**)lua_touserdata(L,lua_upvalueindex(2)) -;if(f==NULL)luaL_error(L,"file is already closed");if(read_line(L,f))return 1; -else{if(lua_toboolean(L,lua_upvalueindex(3))){lua_settop(L,0);lua_pushvalue(L, -lua_upvalueindex(2));aux_close(L);}return 0;}}static int g_write(lua_State*L, -FILE*f,int arg){int nargs=lua_gettop(L)-1;int status=1;for(;nargs--;arg++){if( -lua_type(L,arg)==LUA_TNUMBER){status=status&&fprintf(f,LUA_NUMBER_FMT, -lua_tonumber(L,arg))>0;}else{size_t l;const char*s=luaL_checklstring(L,arg,&l) -;status=status&&(fwrite(s,sizeof(char),l,f)==l);}}return pushresult(L,status, -NULL);}static int io_write(lua_State*L){return g_write(L,getiofile(L,IO_OUTPUT -),1);}static int f_write(lua_State*L){return g_write(L,tofile(L,1),2);}static -int f_seek(lua_State*L){static const int mode[]={SEEK_SET,SEEK_CUR,SEEK_END}; -static const char*const modenames[]={"set","cur","end",NULL};FILE*f=tofile(L,1 -);int op=luaL_findstring(luaL_optstring(L,2,"cur"),modenames);long offset= -luaL_optlong(L,3,0);luaL_argcheck(L,op!=-1,2,"invalid mode");op=fseek(f,offset -,mode[op]);if(op)return pushresult(L,0,NULL);else{lua_pushnumber(L,ftell(f)); -return 1;}}static int io_flush(lua_State*L){return pushresult(L,fflush( -getiofile(L,IO_OUTPUT))==0,NULL);}static int f_flush(lua_State*L){return -pushresult(L,fflush(tofile(L,1))==0,NULL);}static const luaL_reg iolib[]={{ -"input",io_input},{"output",io_output},{"lines",io_lines},{"close",io_close},{ -"flush",io_flush},{"open",io_open},{"popen",io_popen},{"read",io_read},{ -"tmpfile",io_tmpfile},{"type",io_type},{"write",io_write},{NULL,NULL}};static -const luaL_reg flib[]={{"flush",f_flush},{"read",f_read},{"lines",f_lines},{ -"seek",f_seek},{"write",f_write},{"close",io_close},{"__gc",io_gc},{ -"__tostring",io_tostring},{NULL,NULL}};static void createmeta(lua_State*L){ -luaL_newmetatable(L,FILEHANDLE);lua_pushliteral(L,"__index");lua_pushvalue(L,- -2);lua_rawset(L,-3);luaL_openlib(L,NULL,flib,0);}static int io_execute( -lua_State*L){lua_pushnumber(L,system(luaL_checkstring(L,1)));return 1;}static -int io_remove(lua_State*L){const char*filename=luaL_checkstring(L,1);return -pushresult(L,remove(filename)==0,filename);}static int io_rename(lua_State*L){ -const char*fromname=luaL_checkstring(L,1);const char*toname=luaL_checkstring(L -,2);return pushresult(L,rename(fromname,toname)==0,fromname);}static int -io_tmpname(lua_State*L){ -#if !USE_TMPNAME -luaL_error(L,"`tmpname' not supported");return 0; -#else -char buff[L_tmpnam];if(tmpnam(buff)!=buff)return luaL_error(L, -"unable to generate a unique filename in `tmpname'");lua_pushstring(L,buff); -return 1; -#endif -}static int io_getenv(lua_State*L){lua_pushstring(L,getenv(luaL_checkstring(L, -1)));return 1;}static int io_clock(lua_State*L){lua_pushnumber(L,((lua_Number) -clock())/(lua_Number)CLOCKS_PER_SEC);return 1;}static void setfield(lua_State* -L,const char*key,int value){lua_pushstring(L,key);lua_pushnumber(L,value); -lua_rawset(L,-3);}static void setboolfield(lua_State*L,const char*key,int -value){lua_pushstring(L,key);lua_pushboolean(L,value);lua_rawset(L,-3);}static - int getboolfield(lua_State*L,const char*key){int res;lua_pushstring(L,key); -lua_gettable(L,-2);res=lua_toboolean(L,-1);lua_pop(L,1);return res;}static int - getfield(lua_State*L,const char*key,int d){int res;lua_pushstring(L,key); -lua_gettable(L,-2);if(lua_isnumber(L,-1))res=(int)(lua_tonumber(L,-1));else{if -(d==-2)return luaL_error(L,"field `%s' missing in date table",key);res=d;} -lua_pop(L,1);return res;}static int io_date(lua_State*L){const char*s= -luaL_optstring(L,1,"%c");time_t t=(time_t)(luaL_optnumber(L,2,-1));struct tm* -stm;if(t==(time_t)(-1))t=time(NULL);if(*s=='!'){stm=gmtime(&t);s++;}else stm= -localtime(&t);if(stm==NULL)lua_pushnil(L);else if(strcmp(s,"*t")==0){ -lua_newtable(L);setfield(L,"sec",stm->tm_sec);setfield(L,"min",stm->tm_min); -setfield(L,"hour",stm->tm_hour);setfield(L,"day",stm->tm_mday);setfield(L, -"month",stm->tm_mon+1);setfield(L,"year",stm->tm_year+1900);setfield(L,"wday", -stm->tm_wday+1);setfield(L,"yday",stm->tm_yday+1);setboolfield(L,"isdst",stm-> -tm_isdst);}else{char b[256];if(strftime(b,sizeof(b),s,stm))lua_pushstring(L,b) -;else return luaL_error(L,"`date' format too long");}return 1;}static int -io_time(lua_State*L){if(lua_isnoneornil(L,1))lua_pushnumber(L,time(NULL));else -{time_t t;struct tm ts;luaL_checktype(L,1,LUA_TTABLE);lua_settop(L,1);ts. -tm_sec=getfield(L,"sec",0);ts.tm_min=getfield(L,"min",0);ts.tm_hour=getfield(L -,"hour",12);ts.tm_mday=getfield(L,"day",-2);ts.tm_mon=getfield(L,"month",-2)-1 -;ts.tm_year=getfield(L,"year",-2)-1900;ts.tm_isdst=getboolfield(L,"isdst");t= -mktime(&ts);if(t==(time_t)(-1))lua_pushnil(L);else lua_pushnumber(L,t);}return - 1;}static int io_difftime(lua_State*L){lua_pushnumber(L,difftime((time_t)( -luaL_checknumber(L,1)),(time_t)(luaL_optnumber(L,2,0))));return 1;}static int -io_setloc(lua_State*L){static const int cat[]={LC_ALL,LC_COLLATE,LC_CTYPE, -LC_MONETARY,LC_NUMERIC,LC_TIME};static const char*const catnames[]={"all", -"collate","ctype","monetary","numeric","time",NULL};const char*l=lua_tostring( -L,1);int op=luaL_findstring(luaL_optstring(L,2,"all"),catnames);luaL_argcheck( -L,l||lua_isnoneornil(L,1),1,"string expected");luaL_argcheck(L,op!=-1,2, -"invalid option");lua_pushstring(L,setlocale(cat[op],l));return 1;}static int -io_exit(lua_State*L){exit(luaL_optint(L,1,EXIT_SUCCESS));return 0;}static -const luaL_reg syslib[]={{"clock",io_clock},{"date",io_date},{"difftime", -io_difftime},{"execute",io_execute},{"exit",io_exit},{"getenv",io_getenv},{ -"remove",io_remove},{"rename",io_rename},{"setlocale",io_setloc},{"time", -io_time},{"tmpname",io_tmpname},{NULL,NULL}};LUALIB_API int luaopen_io( -lua_State*L){luaL_openlib(L,LUA_OSLIBNAME,syslib,0);createmeta(L); -lua_pushvalue(L,-1);luaL_openlib(L,LUA_IOLIBNAME,iolib,1);registerfile(L,stdin -,"stdin",IO_INPUT);registerfile(L,stdout,"stdout",IO_OUTPUT);registerfile(L, -stderr,"stderr",NULL);return 1;} -#line 1 "llex.c" -#define llex_c -#define next(LS) (LS->current=zgetc(LS->z)) -static const char*const token2string[]={"and","break","do","else","elseif", -"end","false","for","function","if","in","local","nil","not","or","repeat", -"return","then","true","until","while","*name","..","...","==",">=","<=","~=", -"*number","*string",""};void luaX_init(lua_State*L){int i;for(i=0;i< -NUM_RESERVED;i++){TString*ts=luaS_new(L,token2string[i]);luaS_fix(ts); -lua_assert(strlen(token2string[i])+1<=TOKEN_LEN);ts->tsv.reserved=cast(lu_byte -,i+1);}} -#define MAXSRC 80 -void luaX_checklimit(LexState*ls,int val,int limit,const char*msg){if(val> -limit){msg=luaO_pushfstring(ls->L,"too many %s (limit=%d)",msg,limit); -luaX_syntaxerror(ls,msg);}}void luaX_errorline(LexState*ls,const char*s,const -char*token,int line){lua_State*L=ls->L;char buff[MAXSRC];luaO_chunkid(buff, -getstr(ls->source),MAXSRC);luaO_pushfstring(L,"%s:%d: %s near `%s'",buff,line, -s,token);luaD_throw(L,LUA_ERRSYNTAX);}static void luaX_error(LexState*ls,const - char*s,const char*token){luaX_errorline(ls,s,token,ls->linenumber);}void -luaX_syntaxerror(LexState*ls,const char*msg){const char*lasttoken;switch(ls->t -.token){case TK_NAME:lasttoken=getstr(ls->t.seminfo.ts);break;case TK_STRING: -case TK_NUMBER:lasttoken=luaZ_buffer(ls->buff);break;default:lasttoken= -luaX_token2str(ls,ls->t.token);break;}luaX_error(ls,msg,lasttoken);}const char -*luaX_token2str(LexState*ls,int token){if(tokenL,"%c",token);}else -return token2string[token-FIRST_RESERVED];}static void luaX_lexerror(LexState* -ls,const char*s,int token){if(token==TK_EOS)luaX_error(ls,s,luaX_token2str(ls, -token));else luaX_error(ls,s,luaZ_buffer(ls->buff));}static void inclinenumber -(LexState*LS){next(LS);++LS->linenumber;luaX_checklimit(LS,LS->linenumber, -MAX_INT,"lines in a chunk");}void luaX_setinput(lua_State*L,LexState*LS,ZIO*z, -TString*source){LS->L=L;LS->lookahead.token=TK_EOS;LS->z=z;LS->fs=NULL;LS-> -linenumber=1;LS->lastline=1;LS->source=source;next(LS);if(LS->current=='#'){do -{next(LS);}while(LS->current!='\n'&&LS->current!=EOZ);}} -#define EXTRABUFF 32 -#define MAXNOCHECK 5 -#define checkbuffer(LS, len)if(((len)+MAXNOCHECK)*sizeof(char)>luaZ_sizebuffer\ -((LS)->buff))luaZ_openspace((LS)->L,(LS)->buff,(len)+EXTRABUFF) -#define save(LS, c,l)(luaZ_buffer((LS)->buff)[l++]=cast(char,c)) -#define save_and_next(LS, l)(save(LS,LS->current,l),next(LS)) -static size_t readname(LexState*LS){size_t l=0;checkbuffer(LS,l);do{ -checkbuffer(LS,l);save_and_next(LS,l);}while(isalnum(LS->current)||LS->current -=='_');save(LS,'\0',l);return l-1;}static void read_numeral(LexState*LS,int -comma,SemInfo*seminfo){size_t l=0;checkbuffer(LS,l);if(comma)save(LS,'.',l); -while(isdigit(LS->current)){checkbuffer(LS,l);save_and_next(LS,l);}if(LS-> -current=='.'){save_and_next(LS,l);if(LS->current=='.'){save_and_next(LS,l); -save(LS,'\0',l);luaX_lexerror(LS, -"ambiguous syntax (decimal point x string concatenation)",TK_NUMBER);}}while( -isdigit(LS->current)){checkbuffer(LS,l);save_and_next(LS,l);}if(LS->current== -'e'||LS->current=='E'){save_and_next(LS,l);if(LS->current=='+'||LS->current== -'-')save_and_next(LS,l);while(isdigit(LS->current)){checkbuffer(LS,l); -save_and_next(LS,l);}}save(LS,'\0',l);if(!luaO_str2d(luaZ_buffer(LS->buff),& -seminfo->r))luaX_lexerror(LS,"malformed number",TK_NUMBER);}static void -read_long_string(LexState*LS,SemInfo*seminfo){int cont=0;size_t l=0; -checkbuffer(LS,l);save(LS,'[',l);save_and_next(LS,l);if(LS->current=='\n') -inclinenumber(LS);for(;;){checkbuffer(LS,l);switch(LS->current){case EOZ:save( -LS,'\0',l);luaX_lexerror(LS,(seminfo)?"unfinished long string": -"unfinished long comment",TK_EOS);break;case'[':save_and_next(LS,l);if(LS-> -current=='['){cont++;save_and_next(LS,l);}continue;case']':save_and_next(LS,l) -;if(LS->current==']'){if(cont==0)goto endloop;cont--;save_and_next(LS,l);} -continue;case'\n':save(LS,'\n',l);inclinenumber(LS);if(!seminfo)l=0;continue; -default:save_and_next(LS,l);}}endloop:save_and_next(LS,l);save(LS,'\0',l);if( -seminfo)seminfo->ts=luaS_newlstr(LS->L,luaZ_buffer(LS->buff)+2,l-5);}static -void read_string(LexState*LS,int del,SemInfo*seminfo){size_t l=0;checkbuffer( -LS,l);save_and_next(LS,l);while(LS->current!=del){checkbuffer(LS,l);switch(LS -->current){case EOZ:save(LS,'\0',l);luaX_lexerror(LS,"unfinished string", -TK_EOS);break;case'\n':save(LS,'\0',l);luaX_lexerror(LS,"unfinished string", -TK_STRING);break;case'\\':next(LS);switch(LS->current){case'a':save(LS,'\a',l) -;next(LS);break;case'b':save(LS,'\b',l);next(LS);break;case'f':save(LS,'\f',l) -;next(LS);break;case'n':save(LS,'\n',l);next(LS);break;case'r':save(LS,'\r',l) -;next(LS);break;case't':save(LS,'\t',l);next(LS);break;case'v':save(LS,'\v',l) -;next(LS);break;case'\n':save(LS,'\n',l);inclinenumber(LS);break;case EOZ: -break;default:{if(!isdigit(LS->current))save_and_next(LS,l);else{int c=0;int i -=0;do{c=10*c+(LS->current-'0');next(LS);}while(++i<3&&isdigit(LS->current));if -(c>UCHAR_MAX){save(LS,'\0',l);luaX_lexerror(LS,"escape sequence too large", -TK_STRING);}save(LS,c,l);}}}break;default:save_and_next(LS,l);}}save_and_next( -LS,l);save(LS,'\0',l);seminfo->ts=luaS_newlstr(LS->L,luaZ_buffer(LS->buff)+1,l --3);}int luaX_lex(LexState*LS,SemInfo*seminfo){for(;;){switch(LS->current){ -case'\n':{inclinenumber(LS);continue;}case'-':{next(LS);if(LS->current!='-') -return'-';next(LS);if(LS->current=='['&&(next(LS),LS->current=='[')) -read_long_string(LS,NULL);else while(LS->current!='\n'&&LS->current!=EOZ)next( -LS);continue;}case'[':{next(LS);if(LS->current!='[')return'[';else{ -read_long_string(LS,seminfo);return TK_STRING;}}case'=':{next(LS);if(LS-> -current!='=')return'=';else{next(LS);return TK_EQ;}}case'<':{next(LS);if(LS-> -current!='=')return'<';else{next(LS);return TK_LE;}}case'>':{next(LS);if(LS-> -current!='=')return'>';else{next(LS);return TK_GE;}}case'~':{next(LS);if(LS-> -current!='=')return'~';else{next(LS);return TK_NE;}}case'"':case'\'':{ -read_string(LS,LS->current,seminfo);return TK_STRING;}case'.':{next(LS);if(LS -->current=='.'){next(LS);if(LS->current=='.'){next(LS);return TK_DOTS;}else -return TK_CONCAT;}else if(!isdigit(LS->current))return'.';else{read_numeral(LS -,1,seminfo);return TK_NUMBER;}}case EOZ:{return TK_EOS;}default:{if(isspace(LS -->current)){next(LS);continue;}else if(isdigit(LS->current)){read_numeral(LS,0 -,seminfo);return TK_NUMBER;}else if(isalpha(LS->current)||LS->current=='_'){ -size_t l=readname(LS);TString*ts=luaS_newlstr(LS->L,luaZ_buffer(LS->buff),l); -if(ts->tsv.reserved>0)return ts->tsv.reserved-1+FIRST_RESERVED;seminfo->ts=ts; -return TK_NAME;}else{int c=LS->current;if(iscntrl(c))luaX_error(LS, -"invalid control char",luaO_pushfstring(LS->L,"char(%d)",c));next(LS);return c -;}}}}} -#undef next -#line 1 "lmem.c" -#define lmem_c -#ifndef l_realloc -#define l_realloc(b,os,s) realloc(b,s) -#endif -#ifndef l_free -#define l_free(b,os) free(b) -#endif -#define MINSIZEARRAY 4 -void*luaM_growaux(lua_State*L,void*block,int*size,int size_elems,int limit, -const char*errormsg){void*newblock;int newsize=(*size)*2;if(newsize< -MINSIZEARRAY)newsize=MINSIZEARRAY;else if(*size>=limit/2){if(*size=MAX_SIZET)luaG_runerror(L, -"memory allocation error: block too big");else{block=l_realloc(block,oldsize, -size);if(block==NULL){if(L)luaD_throw(L,LUA_ERRMEM);else return NULL;}}if(L){ -lua_assert(G(L)!=NULL&&G(L)->nblocks>0);G(L)->nblocks-=oldsize;G(L)->nblocks+= -size;}return block;} -#line 1 "loadlib.c" -#undef LOADLIB -#ifdef USE_DLOPEN -#define LOADLIB -#include /* dg: magic anchor comment */ -static int loadlib(lua_State*L){const char*path=luaL_checkstring(L,1);const -char*init=luaL_checkstring(L,2);void*lib=dlopen(path,RTLD_NOW);if(lib!=NULL){ -lua_CFunction f=(lua_CFunction)dlsym(lib,init);if(f!=NULL){ -lua_pushlightuserdata(L,lib);lua_pushcclosure(L,f,1);return 1;}}lua_pushnil(L) -;lua_pushstring(L,dlerror());lua_pushstring(L,(lib!=NULL)?"init":"open");if( -lib!=NULL)dlclose(lib);return 3;} -#endif -#ifndef USE_DLL -#ifdef _WIN32 -#define USE_DLL 1 -#else -#define USE_DLL 0 -#endif -#endif -#if USE_DLL -#define LOADLIB -#include /* dg: magic anchor comment */ -static void pusherror(lua_State*L){int error=GetLastError();char buffer[128]; -if(FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,0, -error,0,buffer,sizeof(buffer),0))lua_pushstring(L,buffer);else lua_pushfstring -(L,"system error %d\n",error);}static int loadlib(lua_State*L){const char*path -=luaL_checkstring(L,1);const char*init=luaL_checkstring(L,2);HINSTANCE lib= -LoadLibrary(path);if(lib!=NULL){lua_CFunction f=(lua_CFunction)GetProcAddress( -lib,init);if(f!=NULL){lua_pushlightuserdata(L,lib);lua_pushcclosure(L,f,1); -return 1;}}lua_pushnil(L);pusherror(L);lua_pushstring(L,(lib!=NULL)?"init": -"open");if(lib!=NULL)FreeLibrary(lib);return 3;} -#endif -#ifndef LOADLIB -#ifdef linux -#define LOADLIB -#endif -#ifdef sun -#define LOADLIB -#endif -#ifdef sgi -#define LOADLIB -#endif -#ifdef BSD -#define LOADLIB -#endif -#ifdef _WIN32 -#define LOADLIB -#endif -#ifdef LOADLIB -#undef LOADLIB -#define LOADLIB "`loadlib' not installed (check your Lua configuration)" -#else -#define LOADLIB "`loadlib' not supported" -#endif -static int loadlib(lua_State*L){lua_pushnil(L);lua_pushliteral(L,LOADLIB); -lua_pushliteral(L,"absent");return 3;} -#endif -LUALIB_API int luaopen_loadlib(lua_State*L){lua_register(L,"loadlib",loadlib); -return 0;} -#line 1 "lobject.c" -#define lobject_c -#ifndef lua_str2number -#define lua_str2number(s,p) strtod((s),(p)) -#endif -const TObject luaO_nilobject={LUA_TNIL,{NULL}};int luaO_int2fb(unsigned int x) -{int m=0;while(x>=(1<<3)){x=(x+1)>>1;m++;}return(m<<3)|cast(int,x);}int -luaO_log2(unsigned int x){static const lu_byte log_8[255]={0,1,1,2,2,2,2,3,3,3 -,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 -,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 -,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 -,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -,7,7,7,7,7,7,7,7,7,7,7};if(x>=0x00010000){if(x>=0x01000000)return log_8[((x>> -24)&0xff)-1]+24;else return log_8[((x>>16)&0xff)-1]+16;}else{if(x>=0x00000100) -return log_8[((x>>8)&0xff)-1]+8;else if(x)return log_8[(x&0xff)-1];return-1;}} -int luaO_rawequalObj(const TObject*t1,const TObject*t2){if(ttype(t1)!=ttype(t2 -))return 0;else switch(ttype(t1)){case LUA_TNIL:return 1;case LUA_TNUMBER: -return nvalue(t1)==nvalue(t2);case LUA_TBOOLEAN:return bvalue(t1)==bvalue(t2); -case LUA_TLIGHTUSERDATA:return pvalue(t1)==pvalue(t2);default:lua_assert( -iscollectable(t1));return gcvalue(t1)==gcvalue(t2);}}int luaO_str2d(const char -*s,lua_Number*result){char*endptr;lua_Number res=lua_str2number(s,&endptr);if( -endptr==s)return 0;while(isspace((unsigned char)(*endptr)))endptr++;if(*endptr -!='\0')return 0;*result=res;return 1;}static void pushstr(lua_State*L,const -char*str){setsvalue2s(L->top,luaS_new(L,str));incr_top(L);}const char* -luaO_pushvfstring(lua_State*L,const char*fmt,va_list argp){int n=1;pushstr(L, -"");for(;;){const char*e=strchr(fmt,'%');if(e==NULL)break;setsvalue2s(L->top, -luaS_newlstr(L,fmt,e-fmt));incr_top(L);switch(*(e+1)){case's':pushstr(L,va_arg -(argp,char*));break;case'c':{char buff[2];buff[0]=cast(char,va_arg(argp,int)); -buff[1]='\0';pushstr(L,buff);break;}case'd':setnvalue(L->top,cast(lua_Number, -va_arg(argp,int)));incr_top(L);break;case'f':setnvalue(L->top,cast(lua_Number, -va_arg(argp,l_uacNumber)));incr_top(L);break;case'%':pushstr(L,"%");break; -default:lua_assert(0);}n+=2;fmt=e+2;}pushstr(L,fmt);luaV_concat(L,n+1,L->top-L -->base-1);L->top-=n;return svalue(L->top-1);}const char*luaO_pushfstring( -lua_State*L,const char*fmt,...){const char*msg;va_list argp;va_start(argp,fmt) -;msg=luaO_pushvfstring(L,fmt,argp);va_end(argp);return msg;}void luaO_chunkid( -char*out,const char*source,int bufflen){if(*source=='='){strncpy(out,source+1, -bufflen);out[bufflen-1]='\0';}else{if(*source=='@'){int l;source++;bufflen-= -sizeof(" `...' ");l=strlen(source);strcpy(out,"");if(l>bufflen){source+=(l- -bufflen);strcat(out,"...");}strcat(out,source);}else{int len=strcspn(source, -"\n");bufflen-=sizeof(" [string \"...\"] ");if(len>bufflen)len=bufflen;strcpy( -out,"[string \"");if(source[len]!='\0'){strncat(out,source,len);strcat(out, -"...");}else strcat(out,source);strcat(out,"\"]");}}} -#line 1 "lopcodes.c" -#define lopcodes_c -#ifdef LUA_OPNAMES -const char*const luaP_opnames[]={"MOVE","LOADK","LOADBOOL","LOADNIL", -"GETUPVAL","GETGLOBAL","GETTABLE","SETGLOBAL","SETUPVAL","SETTABLE","NEWTABLE" -,"SELF","ADD","SUB","MUL","DIV","POW","UNM","NOT","CONCAT","JMP","EQ","LT", -"LE","TEST","CALL","TAILCALL","RETURN","FORLOOP","TFORLOOP","TFORPREP", -"SETLIST","SETLISTO","CLOSE","CLOSURE"}; -#endif -#define opmode(t,b,bk,ck,sa,k,m) (((t)<f->locvars[(fs)->actvar[i]]) -#define enterlevel(ls) if(++(ls)->nestlevel>LUA_MAXPARSERLEVEL)\ -luaX_syntaxerror(ls,"too many syntax levels"); -#define leavelevel(ls) ((ls)->nestlevel--) -typedef struct BlockCnt{struct BlockCnt*previous;int breaklist;int nactvar;int - upval;int isbreakable;}BlockCnt;static void chunk(LexState*ls);static void -expr(LexState*ls,expdesc*v);static void next(LexState*ls){ls->lastline=ls-> -linenumber;if(ls->lookahead.token!=TK_EOS){ls->t=ls->lookahead;ls->lookahead. -token=TK_EOS;}else ls->t.token=luaX_lex(ls,&ls->t.seminfo);}static void -lookahead(LexState*ls){lua_assert(ls->lookahead.token==TK_EOS);ls->lookahead. -token=luaX_lex(ls,&ls->lookahead.seminfo);}static void error_expected(LexState -*ls,int token){luaX_syntaxerror(ls,luaO_pushfstring(ls->L,"`%s' expected", -luaX_token2str(ls,token)));}static int testnext(LexState*ls,int c){if(ls->t. -token==c){next(ls);return 1;}else return 0;}static void check(LexState*ls,int -c){if(!testnext(ls,c))error_expected(ls,c);} -#define check_condition(ls,c,msg) {if(!(c))luaX_syntaxerror(ls,msg);} -static void check_match(LexState*ls,int what,int who,int where){if(!testnext( -ls,what)){if(where==ls->linenumber)error_expected(ls,what);else{ -luaX_syntaxerror(ls,luaO_pushfstring(ls->L, -"`%s' expected (to close `%s' at line %d)",luaX_token2str(ls,what), -luaX_token2str(ls,who),where));}}}static TString*str_checkname(LexState*ls){ -TString*ts;check_condition(ls,(ls->t.token==TK_NAME)," expected");ts=ls -->t.seminfo.ts;next(ls);return ts;}static void init_exp(expdesc*e,expkind k, -int i){e->f=e->t=NO_JUMP;e->k=k;e->info=i;}static void codestring(LexState*ls, -expdesc*e,TString*s){init_exp(e,VK,luaK_stringK(ls->fs,s));}static void -checkname(LexState*ls,expdesc*e){codestring(ls,e,str_checkname(ls));}static -int luaI_registerlocalvar(LexState*ls,TString*varname){FuncState*fs=ls->fs; -Proto*f=fs->f;luaM_growvector(ls->L,f->locvars,fs->nlocvars,f->sizelocvars, -LocVar,MAX_INT,"");f->locvars[fs->nlocvars].varname=varname;return fs-> -nlocvars++;}static void new_localvar(LexState*ls,TString*name,int n){FuncState -*fs=ls->fs;luaX_checklimit(ls,fs->nactvar+n+1,MAXVARS,"local variables");fs-> -actvar[fs->nactvar+n]=luaI_registerlocalvar(ls,name);}static void -adjustlocalvars(LexState*ls,int nvars){FuncState*fs=ls->fs;fs->nactvar+=nvars; -for(;nvars;nvars--){getlocvar(fs,fs->nactvar-nvars).startpc=fs->pc;}}static -void removevars(LexState*ls,int tolevel){FuncState*fs=ls->fs;while(fs->nactvar ->tolevel)getlocvar(fs,--fs->nactvar).endpc=fs->pc;}static void new_localvarstr -(LexState*ls,const char*name,int n){new_localvar(ls,luaS_new(ls->L,name),n);} -static void create_local(LexState*ls,const char*name){new_localvarstr(ls,name, -0);adjustlocalvars(ls,1);}static int indexupvalue(FuncState*fs,TString*name, -expdesc*v){int i;Proto*f=fs->f;for(i=0;inups;i++){if(fs->upvalues[i].k==v -->k&&fs->upvalues[i].info==v->info){lua_assert(fs->f->upvalues[i]==name); -return i;}}luaX_checklimit(fs->ls,f->nups+1,MAXUPVALUES,"upvalues"); -luaM_growvector(fs->L,fs->f->upvalues,f->nups,fs->f->sizeupvalues,TString*, -MAX_INT,"");fs->f->upvalues[f->nups]=name;fs->upvalues[f->nups]=*v;return f-> -nups++;}static int searchvar(FuncState*fs,TString*n){int i;for(i=fs->nactvar-1 -;i>=0;i--){if(n==getlocvar(fs,i).varname)return i;}return-1;}static void -markupval(FuncState*fs,int level){BlockCnt*bl=fs->bl;while(bl&&bl->nactvar> -level)bl=bl->previous;if(bl)bl->upval=1;}static void singlevaraux(FuncState*fs -,TString*n,expdesc*var,int base){if(fs==NULL)init_exp(var,VGLOBAL,NO_REG);else -{int v=searchvar(fs,n);if(v>=0){init_exp(var,VLOCAL,v);if(!base)markupval(fs,v -);}else{singlevaraux(fs->prev,n,var,0);if(var->k==VGLOBAL){if(base)var->info= -luaK_stringK(fs,n);}else{var->info=indexupvalue(fs,n,var);var->k=VUPVAL;}}}} -static TString*singlevar(LexState*ls,expdesc*var,int base){TString*varname= -str_checkname(ls);singlevaraux(ls->fs,varname,var,base);return varname;}static - void adjust_assign(LexState*ls,int nvars,int nexps,expdesc*e){FuncState*fs=ls -->fs;int extra=nvars-nexps;if(e->k==VCALL){extra++;if(extra<=0)extra=0;else -luaK_reserveregs(fs,extra-1);luaK_setcallreturns(fs,e,extra);}else{if(e->k!= -VVOID)luaK_exp2nextreg(fs,e);if(extra>0){int reg=fs->freereg;luaK_reserveregs( -fs,extra);luaK_nil(fs,reg,extra);}}}static void code_params(LexState*ls,int -nparams,int dots){FuncState*fs=ls->fs;adjustlocalvars(ls,nparams); -luaX_checklimit(ls,fs->nactvar,MAXPARAMS,"parameters");fs->f->numparams=cast( -lu_byte,fs->nactvar);fs->f->is_vararg=cast(lu_byte,dots);if(dots)create_local( -ls,"arg");luaK_reserveregs(fs,fs->nactvar);}static void enterblock(FuncState* -fs,BlockCnt*bl,int isbreakable){bl->breaklist=NO_JUMP;bl->isbreakable= -isbreakable;bl->nactvar=fs->nactvar;bl->upval=0;bl->previous=fs->bl;fs->bl=bl; -lua_assert(fs->freereg==fs->nactvar);}static void leaveblock(FuncState*fs){ -BlockCnt*bl=fs->bl;fs->bl=bl->previous;removevars(fs->ls,bl->nactvar);if(bl-> -upval)luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0);lua_assert(bl->nactvar==fs-> -nactvar);fs->freereg=fs->nactvar;luaK_patchtohere(fs,bl->breaklist);}static -void pushclosure(LexState*ls,FuncState*func,expdesc*v){FuncState*fs=ls->fs; -Proto*f=fs->f;int i;luaM_growvector(ls->L,f->p,fs->np,f->sizep,Proto*, -MAXARG_Bx,"constant table overflow");f->p[fs->np++]=func->f;init_exp(v, -VRELOCABLE,luaK_codeABx(fs,OP_CLOSURE,0,fs->np-1));for(i=0;if->nups;i++ -){OpCode o=(func->upvalues[i].k==VLOCAL)?OP_MOVE:OP_GETUPVAL;luaK_codeABC(fs,o -,0,func->upvalues[i].info,0);}}static void open_func(LexState*ls,FuncState*fs) -{Proto*f=luaF_newproto(ls->L);fs->f=f;fs->prev=ls->fs;fs->ls=ls;fs->L=ls->L;ls -->fs=fs;fs->pc=0;fs->lasttarget=0;fs->jpc=NO_JUMP;fs->freereg=0;fs->nk=0;fs->h -=luaH_new(ls->L,0,0);fs->np=0;fs->nlocvars=0;fs->nactvar=0;fs->bl=NULL;f-> -source=ls->source;f->maxstacksize=2;}static void close_func(LexState*ls){ -lua_State*L=ls->L;FuncState*fs=ls->fs;Proto*f=fs->f;removevars(ls,0); -luaK_codeABC(fs,OP_RETURN,0,1,0);luaM_reallocvector(L,f->code,f->sizecode,fs-> -pc,Instruction);f->sizecode=fs->pc;luaM_reallocvector(L,f->lineinfo,f-> -sizelineinfo,fs->pc,int);f->sizelineinfo=fs->pc;luaM_reallocvector(L,f->k,f-> -sizek,fs->nk,TObject);f->sizek=fs->nk;luaM_reallocvector(L,f->p,f->sizep,fs-> -np,Proto*);f->sizep=fs->np;luaM_reallocvector(L,f->locvars,f->sizelocvars,fs-> -nlocvars,LocVar);f->sizelocvars=fs->nlocvars;luaM_reallocvector(L,f->upvalues, -f->sizeupvalues,f->nups,TString*);f->sizeupvalues=f->nups;lua_assert( -luaG_checkcode(f));lua_assert(fs->bl==NULL);ls->fs=fs->prev;}Proto*luaY_parser -(lua_State*L,ZIO*z,Mbuffer*buff){struct LexState lexstate;struct FuncState -funcstate;lexstate.buff=buff;lexstate.nestlevel=0;luaX_setinput(L,&lexstate,z, -luaS_new(L,zname(z)));open_func(&lexstate,&funcstate);next(&lexstate);chunk(& -lexstate);check_condition(&lexstate,(lexstate.t.token==TK_EOS), -" expected");close_func(&lexstate);lua_assert(funcstate.prev==NULL); -lua_assert(funcstate.f->nups==0);lua_assert(lexstate.nestlevel==0);return -funcstate.f;}static void luaY_field(LexState*ls,expdesc*v){FuncState*fs=ls->fs -;expdesc key;luaK_exp2anyreg(fs,v);next(ls);checkname(ls,&key);luaK_indexed(fs -,v,&key);}static void luaY_index(LexState*ls,expdesc*v){next(ls);expr(ls,v); -luaK_exp2val(ls->fs,v);check(ls,']');}struct ConsControl{expdesc v;expdesc*t; -int nh;int na;int tostore;};static void recfield(LexState*ls,struct -ConsControl*cc){FuncState*fs=ls->fs;int reg=ls->fs->freereg;expdesc key,val;if -(ls->t.token==TK_NAME){luaX_checklimit(ls,cc->nh,MAX_INT, -"items in a constructor");cc->nh++;checkname(ls,&key);}else luaY_index(ls,&key -);check(ls,'=');luaK_exp2RK(fs,&key);expr(ls,&val);luaK_codeABC(fs,OP_SETTABLE -,cc->t->info,luaK_exp2RK(fs,&key),luaK_exp2RK(fs,&val));fs->freereg=reg;} -static void closelistfield(FuncState*fs,struct ConsControl*cc){if(cc->v.k== -VVOID)return;luaK_exp2nextreg(fs,&cc->v);cc->v.k=VVOID;if(cc->tostore== -LFIELDS_PER_FLUSH){luaK_codeABx(fs,OP_SETLIST,cc->t->info,cc->na-1);cc-> -tostore=0;fs->freereg=cc->t->info+1;}}static void lastlistfield(FuncState*fs, -struct ConsControl*cc){if(cc->tostore==0)return;if(cc->v.k==VCALL){ -luaK_setcallreturns(fs,&cc->v,LUA_MULTRET);luaK_codeABx(fs,OP_SETLISTO,cc->t-> -info,cc->na-1);}else{if(cc->v.k!=VVOID)luaK_exp2nextreg(fs,&cc->v); -luaK_codeABx(fs,OP_SETLIST,cc->t->info,cc->na-1);}fs->freereg=cc->t->info+1;} -static void listfield(LexState*ls,struct ConsControl*cc){expr(ls,&cc->v); -luaX_checklimit(ls,cc->na,MAXARG_Bx,"items in a constructor");cc->na++;cc-> -tostore++;}static void constructor(LexState*ls,expdesc*t){FuncState*fs=ls->fs; -int line=ls->linenumber;int pc=luaK_codeABC(fs,OP_NEWTABLE,0,0,0);struct -ConsControl cc;cc.na=cc.nh=cc.tostore=0;cc.t=t;init_exp(t,VRELOCABLE,pc); -init_exp(&cc.v,VVOID,0);luaK_exp2nextreg(ls->fs,t);check(ls,'{');do{lua_assert -(cc.v.k==VVOID||cc.tostore>0);testnext(ls,';');if(ls->t.token=='}')break; -closelistfield(fs,&cc);switch(ls->t.token){case TK_NAME:{lookahead(ls);if(ls-> -lookahead.token!='=')listfield(ls,&cc);else recfield(ls,&cc);break;}case'[':{ -recfield(ls,&cc);break;}default:{listfield(ls,&cc);break;}}}while(testnext(ls, -',')||testnext(ls,';'));check_match(ls,'}','{',line);lastlistfield(fs,&cc); -SETARG_B(fs->f->code[pc],luaO_int2fb(cc.na));SETARG_C(fs->f->code[pc], -luaO_log2(cc.nh)+1);}static void parlist(LexState*ls){int nparams=0;int dots=0 -;if(ls->t.token!=')'){do{switch(ls->t.token){case TK_DOTS:dots=1;next(ls); -break;case TK_NAME:new_localvar(ls,str_checkname(ls),nparams++);break;default: -luaX_syntaxerror(ls," or `...' expected");}}while(!dots&&testnext(ls,',' -));}code_params(ls,nparams,dots);}static void body(LexState*ls,expdesc*e,int -needself,int line){FuncState new_fs;open_func(ls,&new_fs);new_fs.f-> -lineDefined=line;check(ls,'(');if(needself)create_local(ls,"self");parlist(ls) -;check(ls,')');chunk(ls);check_match(ls,TK_END,TK_FUNCTION,line);close_func(ls -);pushclosure(ls,&new_fs,e);}static int explist1(LexState*ls,expdesc*v){int n= -1;expr(ls,v);while(testnext(ls,',')){luaK_exp2nextreg(ls->fs,v);expr(ls,v);n++ -;}return n;}static void funcargs(LexState*ls,expdesc*f){FuncState*fs=ls->fs; -expdesc args;int base,nparams;int line=ls->linenumber;switch(ls->t.token){case -'(':{if(line!=ls->lastline)luaX_syntaxerror(ls, -"ambiguous syntax (function call x new statement)");next(ls);if(ls->t.token== -')')args.k=VVOID;else{explist1(ls,&args);luaK_setcallreturns(fs,&args, -LUA_MULTRET);}check_match(ls,')','(',line);break;}case'{':{constructor(ls,& -args);break;}case TK_STRING:{codestring(ls,&args,ls->t.seminfo.ts);next(ls); -break;}default:{luaX_syntaxerror(ls,"function arguments expected");return;}} -lua_assert(f->k==VNONRELOC);base=f->info;if(args.k==VCALL)nparams=LUA_MULTRET; -else{if(args.k!=VVOID)luaK_exp2nextreg(fs,&args);nparams=fs->freereg-(base+1); -}init_exp(f,VCALL,luaK_codeABC(fs,OP_CALL,base,nparams+1,2));luaK_fixline(fs, -line);fs->freereg=base+1;}static void prefixexp(LexState*ls,expdesc*v){switch( -ls->t.token){case'(':{int line=ls->linenumber;next(ls);expr(ls,v);check_match( -ls,')','(',line);luaK_dischargevars(ls->fs,v);return;}case TK_NAME:{singlevar( -ls,v,1);return;} -#ifdef LUA_COMPATUPSYNTAX -case'%':{TString*varname;int line=ls->linenumber;next(ls);varname=singlevar(ls -,v,1);if(v->k!=VUPVAL)luaX_errorline(ls,"global upvalues are obsolete",getstr( -varname),line);return;} -#endif -default:{luaX_syntaxerror(ls,"unexpected symbol");return;}}}static void -primaryexp(LexState*ls,expdesc*v){FuncState*fs=ls->fs;prefixexp(ls,v);for(;;){ -switch(ls->t.token){case'.':{luaY_field(ls,v);break;}case'[':{expdesc key; -luaK_exp2anyreg(fs,v);luaY_index(ls,&key);luaK_indexed(fs,v,&key);break;}case -':':{expdesc key;next(ls);checkname(ls,&key);luaK_self(fs,v,&key);funcargs(ls, -v);break;}case'(':case TK_STRING:case'{':{luaK_exp2nextreg(fs,v);funcargs(ls,v -);break;}default:return;}}}static void simpleexp(LexState*ls,expdesc*v){switch -(ls->t.token){case TK_NUMBER:{init_exp(v,VK,luaK_numberK(ls->fs,ls->t.seminfo. -r));next(ls);break;}case TK_STRING:{codestring(ls,v,ls->t.seminfo.ts);next(ls) -;break;}case TK_NIL:{init_exp(v,VNIL,0);next(ls);break;}case TK_TRUE:{init_exp -(v,VTRUE,0);next(ls);break;}case TK_FALSE:{init_exp(v,VFALSE,0);next(ls);break -;}case'{':{constructor(ls,v);break;}case TK_FUNCTION:{next(ls);body(ls,v,0,ls -->linenumber);break;}default:{primaryexp(ls,v);break;}}}static UnOpr getunopr( -int op){switch(op){case TK_NOT:return OPR_NOT;case'-':return OPR_MINUS;default -:return OPR_NOUNOPR;}}static BinOpr getbinopr(int op){switch(op){case'+': -return OPR_ADD;case'-':return OPR_SUB;case'*':return OPR_MULT;case'/':return -OPR_DIV;case'^':return OPR_POW;case TK_CONCAT:return OPR_CONCAT;case TK_NE: -return OPR_NE;case TK_EQ:return OPR_EQ;case'<':return OPR_LT;case TK_LE:return - OPR_LE;case'>':return OPR_GT;case TK_GE:return OPR_GE;case TK_AND:return -OPR_AND;case TK_OR:return OPR_OR;default:return OPR_NOBINOPR;}}static const -struct{lu_byte left;lu_byte right;}priority[]={{6,6},{6,6},{7,7},{7,7},{10,9}, -{5,4},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{2,2},{1,1}}; -#define UNARY_PRIORITY 8 -static BinOpr subexpr(LexState*ls,expdesc*v,int limit){BinOpr op;UnOpr uop; -enterlevel(ls);uop=getunopr(ls->t.token);if(uop!=OPR_NOUNOPR){next(ls);subexpr -(ls,v,UNARY_PRIORITY);luaK_prefix(ls->fs,uop,v);}else simpleexp(ls,v);op= -getbinopr(ls->t.token);while(op!=OPR_NOBINOPR&&cast(int,priority[op].left)> -limit){expdesc v2;BinOpr nextop;next(ls);luaK_infix(ls->fs,op,v);nextop= -subexpr(ls,&v2,cast(int,priority[op].right));luaK_posfix(ls->fs,op,v,&v2);op= -nextop;}leavelevel(ls);return op;}static void expr(LexState*ls,expdesc*v){ -subexpr(ls,v,-1);}static int block_follow(int token){switch(token){case -TK_ELSE:case TK_ELSEIF:case TK_END:case TK_UNTIL:case TK_EOS:return 1;default: -return 0;}}static void block(LexState*ls){FuncState*fs=ls->fs;BlockCnt bl; -enterblock(fs,&bl,0);chunk(ls);lua_assert(bl.breaklist==NO_JUMP);leaveblock(fs -);}struct LHS_assign{struct LHS_assign*prev;expdesc v;};static void -check_conflict(LexState*ls,struct LHS_assign*lh,expdesc*v){FuncState*fs=ls->fs -;int extra=fs->freereg;int conflict=0;for(;lh;lh=lh->prev){if(lh->v.k== -VINDEXED){if(lh->v.info==v->info){conflict=1;lh->v.info=extra;}if(lh->v.aux==v -->info){conflict=1;lh->v.aux=extra;}}}if(conflict){luaK_codeABC(fs,OP_MOVE,fs -->freereg,v->info,0);luaK_reserveregs(fs,1);}}static void assignment(LexState* -ls,struct LHS_assign*lh,int nvars){expdesc e;check_condition(ls,VLOCAL<=lh->v. -k&&lh->v.k<=VINDEXED,"syntax error");if(testnext(ls,',')){struct LHS_assign nv -;nv.prev=lh;primaryexp(ls,&nv.v);if(nv.v.k==VLOCAL)check_conflict(ls,lh,&nv.v) -;assignment(ls,&nv,nvars+1);}else{int nexps;check(ls,'=');nexps=explist1(ls,&e -);if(nexps!=nvars){adjust_assign(ls,nvars,nexps,&e);if(nexps>nvars)ls->fs-> -freereg-=nexps-nvars;}else{luaK_setcallreturns(ls->fs,&e,1);luaK_storevar(ls-> -fs,&lh->v,&e);return;}}init_exp(&e,VNONRELOC,ls->fs->freereg-1);luaK_storevar( -ls->fs,&lh->v,&e);}static void cond(LexState*ls,expdesc*v){expr(ls,v);if(v->k -==VNIL)v->k=VFALSE;luaK_goiftrue(ls->fs,v);luaK_patchtohere(ls->fs,v->t);} -#ifndef MAXEXPWHILE -#define MAXEXPWHILE 100 -#endif -#define EXTRAEXP 5 -static void whilestat(LexState*ls,int line){Instruction codeexp[MAXEXPWHILE+ -EXTRAEXP];int lineexp;int i;int sizeexp;FuncState*fs=ls->fs;int whileinit, -blockinit,expinit;expdesc v;BlockCnt bl;next(ls);whileinit=luaK_jump(fs); -expinit=luaK_getlabel(fs);expr(ls,&v);if(v.k==VK)v.k=VTRUE;lineexp=ls-> -linenumber;luaK_goiffalse(fs,&v);luaK_concat(fs,&v.f,fs->jpc);fs->jpc=NO_JUMP; -sizeexp=fs->pc-expinit;if(sizeexp>MAXEXPWHILE)luaX_syntaxerror(ls, -"`while' condition too complex");for(i=0;if->code[ -expinit+i];fs->pc=expinit;enterblock(fs,&bl,1);check(ls,TK_DO);blockinit= -luaK_getlabel(fs);block(ls);luaK_patchtohere(fs,whileinit);if(v.t!=NO_JUMP)v.t -+=fs->pc-expinit;if(v.f!=NO_JUMP)v.f+=fs->pc-expinit;for(i=0;ifs;int -repeat_init=luaK_getlabel(fs);expdesc v;BlockCnt bl;enterblock(fs,&bl,1);next( -ls);block(ls);check_match(ls,TK_UNTIL,TK_REPEAT,line);cond(ls,&v); -luaK_patchlist(fs,v.f,repeat_init);leaveblock(fs);}static int exp1(LexState*ls -){expdesc e;int k;expr(ls,&e);k=e.k;luaK_exp2nextreg(ls->fs,&e);return k;} -static void forbody(LexState*ls,int base,int line,int nvars,int isnum){ -BlockCnt bl;FuncState*fs=ls->fs;int prep,endfor;adjustlocalvars(ls,nvars); -check(ls,TK_DO);enterblock(fs,&bl,1);prep=luaK_getlabel(fs);block(ls); -luaK_patchtohere(fs,prep-1);endfor=(isnum)?luaK_codeAsBx(fs,OP_FORLOOP,base, -NO_JUMP):luaK_codeABC(fs,OP_TFORLOOP,base,0,nvars-3);luaK_fixline(fs,line); -luaK_patchlist(fs,(isnum)?endfor:luaK_jump(fs),prep);leaveblock(fs);}static -void fornum(LexState*ls,TString*varname,int line){FuncState*fs=ls->fs;int base -=fs->freereg;new_localvar(ls,varname,0);new_localvarstr(ls,"(for limit)",1); -new_localvarstr(ls,"(for step)",2);check(ls,'=');exp1(ls);check(ls,',');exp1( -ls);if(testnext(ls,','))exp1(ls);else{luaK_codeABx(fs,OP_LOADK,fs->freereg, -luaK_numberK(fs,1));luaK_reserveregs(fs,1);}luaK_codeABC(fs,OP_SUB,fs->freereg --3,fs->freereg-3,fs->freereg-1);luaK_jump(fs);forbody(ls,base,line,3,1);} -static void forlist(LexState*ls,TString*indexname){FuncState*fs=ls->fs;expdesc - e;int nvars=0;int line;int base=fs->freereg;new_localvarstr(ls, -"(for generator)",nvars++);new_localvarstr(ls,"(for state)",nvars++); -new_localvar(ls,indexname,nvars++);while(testnext(ls,','))new_localvar(ls, -str_checkname(ls),nvars++);check(ls,TK_IN);line=ls->linenumber;adjust_assign( -ls,nvars,explist1(ls,&e),&e);luaK_checkstack(fs,3);luaK_codeAsBx(fs, -OP_TFORPREP,base,NO_JUMP);forbody(ls,base,line,nvars,0);}static void forstat( -LexState*ls,int line){FuncState*fs=ls->fs;TString*varname;BlockCnt bl; -enterblock(fs,&bl,0);next(ls);varname=str_checkname(ls);switch(ls->t.token){ -case'=':fornum(ls,varname,line);break;case',':case TK_IN:forlist(ls,varname); -break;default:luaX_syntaxerror(ls,"`=' or `in' expected");}check_match(ls, -TK_END,TK_FOR,line);leaveblock(fs);}static void test_then_block(LexState*ls, -expdesc*v){next(ls);cond(ls,v);check(ls,TK_THEN);block(ls);}static void ifstat -(LexState*ls,int line){FuncState*fs=ls->fs;expdesc v;int escapelist=NO_JUMP; -test_then_block(ls,&v);while(ls->t.token==TK_ELSEIF){luaK_concat(fs,& -escapelist,luaK_jump(fs));luaK_patchtohere(fs,v.f);test_then_block(ls,&v);}if( -ls->t.token==TK_ELSE){luaK_concat(fs,&escapelist,luaK_jump(fs)); -luaK_patchtohere(fs,v.f);next(ls);block(ls);}else luaK_concat(fs,&escapelist,v -.f);luaK_patchtohere(fs,escapelist);check_match(ls,TK_END,TK_IF,line);}static -void localfunc(LexState*ls){expdesc v,b;FuncState*fs=ls->fs;new_localvar(ls, -str_checkname(ls),0);init_exp(&v,VLOCAL,fs->freereg);luaK_reserveregs(fs,1); -adjustlocalvars(ls,1);body(ls,&b,0,ls->linenumber);luaK_storevar(fs,&v,&b); -getlocvar(fs,fs->nactvar-1).startpc=fs->pc;}static void localstat(LexState*ls) -{int nvars=0;int nexps;expdesc e;do{new_localvar(ls,str_checkname(ls),nvars++) -;}while(testnext(ls,','));if(testnext(ls,'='))nexps=explist1(ls,&e);else{e.k= -VVOID;nexps=0;}adjust_assign(ls,nvars,nexps,&e);adjustlocalvars(ls,nvars);} -static int funcname(LexState*ls,expdesc*v){int needself=0;singlevar(ls,v,1); -while(ls->t.token=='.')luaY_field(ls,v);if(ls->t.token==':'){needself=1; -luaY_field(ls,v);}return needself;}static void funcstat(LexState*ls,int line){ -int needself;expdesc v,b;next(ls);needself=funcname(ls,&v);body(ls,&b,needself -,line);luaK_storevar(ls->fs,&v,&b);luaK_fixline(ls->fs,line);}static void -exprstat(LexState*ls){FuncState*fs=ls->fs;struct LHS_assign v;primaryexp(ls,&v -.v);if(v.v.k==VCALL){luaK_setcallreturns(fs,&v.v,0);}else{v.prev=NULL; -assignment(ls,&v,1);}}static void retstat(LexState*ls){FuncState*fs=ls->fs; -expdesc e;int first,nret;next(ls);if(block_follow(ls->t.token)||ls->t.token== -';')first=nret=0;else{nret=explist1(ls,&e);if(e.k==VCALL){luaK_setcallreturns( -fs,&e,LUA_MULTRET);if(nret==1){SET_OPCODE(getcode(fs,&e),OP_TAILCALL); -lua_assert(GETARG_A(getcode(fs,&e))==fs->nactvar);}first=fs->nactvar;nret= -LUA_MULTRET;}else{if(nret==1)first=luaK_exp2anyreg(fs,&e);else{ -luaK_exp2nextreg(fs,&e);first=fs->nactvar;lua_assert(nret==fs->freereg-first); -}}}luaK_codeABC(fs,OP_RETURN,first,nret+1,0);}static void breakstat(LexState* -ls){FuncState*fs=ls->fs;BlockCnt*bl=fs->bl;int upval=0;next(ls);while(bl&&!bl -->isbreakable){upval|=bl->upval;bl=bl->previous;}if(!bl)luaX_syntaxerror(ls, -"no loop to break");if(upval)luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0); -luaK_concat(fs,&bl->breaklist,luaK_jump(fs));}static int statement(LexState*ls -){int line=ls->linenumber;switch(ls->t.token){case TK_IF:{ifstat(ls,line); -return 0;}case TK_WHILE:{whilestat(ls,line);return 0;}case TK_DO:{next(ls); -block(ls);check_match(ls,TK_END,TK_DO,line);return 0;}case TK_FOR:{forstat(ls, -line);return 0;}case TK_REPEAT:{repeatstat(ls,line);return 0;}case TK_FUNCTION -:{funcstat(ls,line);return 0;}case TK_LOCAL:{next(ls);if(testnext(ls, -TK_FUNCTION))localfunc(ls);else localstat(ls);return 0;}case TK_RETURN:{ -retstat(ls);return 1;}case TK_BREAK:{breakstat(ls);return 1;}default:{exprstat -(ls);return 0;}}}static void chunk(LexState*ls){int islast=0;enterlevel(ls); -while(!islast&&!block_follow(ls->t.token)){islast=statement(ls);testnext(ls, -';');lua_assert(ls->fs->freereg>=ls->fs->nactvar);ls->fs->freereg=ls->fs-> -nactvar;}leavelevel(ls);} -#line 1 "lposix.c" -#define MYNAME "posix" -#define MYVERSION MYNAME" library for "LUA_VERSION" / Nov 2003" -#ifndef MYBUFSIZ -#define MYBUFSIZ 512 -#endif -#line 1 "modemuncher.h" -struct modeLookup{char rwx;mode_t bits;};typedef struct modeLookup modeLookup; -static modeLookup modesel[]={{'r',S_IRUSR},{'w',S_IWUSR},{'x',S_IXUSR},{'r', -S_IRGRP},{'w',S_IWGRP},{'x',S_IXGRP},{'r',S_IROTH},{'w',S_IWOTH},{'x',S_IXOTH} -,{(char)NULL,(mode_t)-1}};static int rwxrwxrwx(mode_t*mode,const char*p){int -count;mode_t tmp_mode=*mode;tmp_mode&=~(S_ISUID|S_ISGID);for(count=0;count<9; -count++){if(*p==modesel[count].rwx)tmp_mode|=modesel[count].bits;else if(*p== -'-')tmp_mode&=~modesel[count].bits;else if(*p=='s')switch(count){case 2: -tmp_mode|=S_ISUID|S_IXUSR;break;case 5:tmp_mode|=S_ISGID|S_IXGRP;break;default -:return-4;break;}p++;}*mode=tmp_mode;return 0;}static void modechopper(mode_t -mode,char*p){int count;char*pp;pp=p;for(count=0;count<9;count++){if(mode& -modesel[count].bits)*p=modesel[count].rwx;else*p='-';p++;}*p=0;if(mode&S_ISUID -)pp[2]=(mode&S_IXUSR)?'s':'S';if(mode&S_ISGID)pp[5]=(mode&S_IXGRP)?'s':'S';} -static int mode_munch(mode_t*mode,const char*p){char op=0;mode_t affected_bits -,ch_mode;int doneFlag=0; -#ifdef DEBUG -char tmp[10]; -#endif -#ifdef DEBUG -modechopper(*mode,tmp);printf("modemuncher: got base mode = %s\n",tmp); -#endif -while(!doneFlag){affected_bits=0;ch_mode=0; -#ifdef DEBUG -printf("modemuncher step 1\n"); -#endif -if(*p=='r'||*p=='-')return rwxrwxrwx(mode,p);for(;;p++)switch(*p){case'u': -affected_bits|=04700;break;case'g':affected_bits|=02070;break;case'o': -affected_bits|=01007;break;case'a':affected_bits|=07777;break;case' ':break; -default:goto no_more_affected;}no_more_affected:if(affected_bits==0) -affected_bits=07777; -#ifdef DEBUG -printf("modemuncher step 2 (*p='%c')\n",*p); -#endif -switch(*p){case'+':case'-':case'=':op=*p;break;case' ':break;default:return-1; -} -#ifdef DEBUG -printf("modemuncher step 3\n"); -#endif -for(p++;*p!=0;p++)switch(*p){case'r':ch_mode|=00444;break;case'w':ch_mode|= -00222;break;case'x':ch_mode|=00111;break;case's':ch_mode|=06000;break;case' ': -break;default:goto specs_done;}specs_done: -#ifdef DEBUG -printf("modemuncher step 4\n"); -#endif -if(*p!=',')doneFlag=1;if(*p!=0&&*p!=' '&&*p!=','){ -#ifdef DEBUG -printf("modemuncher: comma error!\n");printf("modemuncher: doneflag = %u\n", -doneFlag); -#endif -return-2;}p++;if(ch_mode)switch(op){case'+':*mode=*mode|=ch_mode&affected_bits -;break;case'-':*mode=*mode&=~(ch_mode&affected_bits);break;case'=':*mode= -ch_mode&affected_bits;break;default:return-3;}} -#ifdef DEBUG -modechopper(*mode,tmp);printf("modemuncher: returning mode = %s\n",tmp); -#endif -return 0;} -#line 38 "lposix.c" -static const char*filetype(mode_t m){if(S_ISREG(m))return"regular";else if( -S_ISLNK(m))return"link";else if(S_ISDIR(m))return"directory";else if(S_ISCHR(m -))return"character device";else if(S_ISBLK(m))return"block device";else if( -S_ISFIFO(m))return"fifo"; -#ifdef S_ISSOCK -else if(S_ISSOCK(m))return"socket"; -#endif -else return"?";}typedef int(*Selector)(lua_State*L,int i,const void*data); -static int doselection(lua_State*L,int i,const char*const S[],Selector F,const - void*data){if(lua_isnone(L,i)){lua_newtable(L);for(i=0;S[i]!=NULL;i++){ -lua_pushstring(L,S[i]);F(L,i,data);lua_settable(L,-3);}return 1;}else{int j= -luaL_findstring(luaL_checkstring(L,i),S);if(j==-1)luaL_argerror(L,i, -"unknown selector");return F(L,j,data);}}static void storeindex(lua_State*L, -int i,const char*value){lua_pushstring(L,value);lua_rawseti(L,-2,i);}static -void storestring(lua_State*L,const char*name,const char*value){lua_pushstring( -L,name);lua_pushstring(L,value);lua_settable(L,-3);}static void storenumber( -lua_State*L,const char*name,lua_Number value){lua_pushstring(L,name); -lua_pushnumber(L,value);lua_settable(L,-3);}static int pusherror(lua_State*L, -const char*info){lua_pushnil(L);if(info==NULL)lua_pushstring(L,strerror(errno) -);else lua_pushfstring(L,"%s: %s",info,strerror(errno));lua_pushnumber(L,errno -);return 3;}static int lposix_pushresult(lua_State*L,int i,const char*info){if -(i!=-1){lua_pushnumber(L,i);return 1;}else return pusherror(L,info);}static -void badoption(lua_State*L,int i,const char*what,int option){luaL_argerror(L,2 -,lua_pushfstring(L,"unknown %s option `%c'",what,option));}static uid_t -mygetuid(lua_State*L,int i){if(lua_isnone(L,i))return-1;else if(lua_isnumber(L -,i))return(uid_t)lua_tonumber(L,i);else if(lua_isstring(L,i)){struct passwd*p= -getpwnam(lua_tostring(L,i));return(p==NULL)?-1:p->pw_uid;}else return -luaL_typerror(L,i,"string or number");}static gid_t mygetgid(lua_State*L,int i -){if(lua_isnone(L,i))return-1;else if(lua_isnumber(L,i))return(gid_t) -lua_tonumber(L,i);else if(lua_isstring(L,i)){struct group*g=getgrnam( -lua_tostring(L,i));return(g==NULL)?-1:g->gr_gid;}else return luaL_typerror(L,i -,"string or number");}static int Perrno(lua_State*L){lua_pushstring(L,strerror -(errno));lua_pushnumber(L,errno);return 2;}static int Pdir(lua_State*L){const -char*path=luaL_optstring(L,1,".");DIR*d=opendir(path);if(d==NULL)return -pusherror(L,path);else{int i;struct dirent*entry;lua_newtable(L);for(i=1;( -entry=readdir(d))!=NULL;i++)storeindex(L,i,entry->d_name);closedir(d);return 1 -;}}static int aux_files(lua_State*L){DIR*d=lua_touserdata(L,lua_upvalueindex(1 -));struct dirent*entry;if(d==NULL)luaL_error(L,"attempt to use closed dir"); -entry=readdir(d);if(entry==NULL){closedir(d);lua_pushnil(L);lua_replace(L, -lua_upvalueindex(1));lua_pushnil(L);}else{lua_pushstring(L,entry->d_name); -#if 0 -#ifdef _DIRENT_HAVE_D_TYPE -lua_pushstring(L,filetype(DTTOIF(entry->d_type)));return 2; -#endif -#endif -}return 1;}static int Pfiles(lua_State*L){const char*path=luaL_optstring(L,1, -".");DIR*d=opendir(path);if(d==NULL)return pusherror(L,path);else{ -lua_pushlightuserdata(L,d);lua_pushcclosure(L,aux_files,1);return 1;}}static -int Pgetcwd(lua_State*L){char buf[MYBUFSIZ];if(getcwd(buf,sizeof(buf))==NULL) -return pusherror(L,".");else{lua_pushstring(L,buf);return 1;}}static int -Pmkdir(lua_State*L){const char*path=luaL_checkstring(L,1);return -lposix_pushresult(L,mkdir(path,0777),path);}static int Pchdir(lua_State*L){ -const char*path=luaL_checkstring(L,1);return lposix_pushresult(L,chdir(path), -path);}static int Prmdir(lua_State*L){const char*path=luaL_checkstring(L,1); -return lposix_pushresult(L,rmdir(path),path);}static int Punlink(lua_State*L){ -const char*path=luaL_checkstring(L,1);return lposix_pushresult(L,unlink(path), -path);}static int Plink(lua_State*L){const char*oldpath=luaL_checkstring(L,1); -const char*newpath=luaL_checkstring(L,2);return lposix_pushresult(L,link( -oldpath,newpath),NULL);}static int Psymlink(lua_State*L){const char*oldpath= -luaL_checkstring(L,1);const char*newpath=luaL_checkstring(L,2);return -lposix_pushresult(L,symlink(oldpath,newpath),NULL);}static int Preadlink( -lua_State*L){char buf[MYBUFSIZ];const char*path=luaL_checkstring(L,1);int n= -readlink(path,buf,sizeof(buf));if(n==-1)return pusherror(L,path); -lua_pushlstring(L,buf,n);return 1;}static int Paccess(lua_State*L){int mode= -F_OK;const char*path=luaL_checkstring(L,1);const char*s;for(s=luaL_optstring(L -,2,"f");*s!=0;s++)switch(*s){case' ':break;case'r':mode|=R_OK;break;case'w': -mode|=W_OK;break;case'x':mode|=X_OK;break;case'f':mode|=F_OK;break;default: -badoption(L,2,"mode",*s);break;}return lposix_pushresult(L,access(path,mode), -path);}static int Pmkfifo(lua_State*L){const char*path=luaL_checkstring(L,1); -return lposix_pushresult(L,mkfifo(path,0777),path);}static int Pexec(lua_State -*L){const char*path=luaL_checkstring(L,1);int i,n=lua_gettop(L);char**argv= -malloc((n+1)*sizeof(char*));if(argv==NULL)luaL_error(L,"not enough memory"); -argv[0]=(char*)path;for(i=1;ipw_name);break;case 1:lua_pushnumber(L,p->pw_uid);break; -case 2:lua_pushnumber(L,p->pw_gid);break;case 3:lua_pushstring(L,p->pw_dir); -break;case 4:lua_pushstring(L,p->pw_shell);break;case 5:lua_pushstring(L,p-> -pw_gecos);break;case 6:lua_pushstring(L,p->pw_passwd);break;}return 1;}static -const char*const Sgetpasswd[]={"name","uid","gid","dir","shell","gecos", -"passwd",NULL};static int Pgetpasswd(lua_State*L){struct passwd*p=NULL;if( -lua_isnoneornil(L,1))p=getpwuid(geteuid());else if(lua_isnumber(L,1))p= -getpwuid((uid_t)lua_tonumber(L,1));else if(lua_isstring(L,1))p=getpwnam( -lua_tostring(L,1));else luaL_typerror(L,1,"string or number");if(p==NULL) -lua_pushnil(L);else doselection(L,2,Sgetpasswd,Fgetpasswd,p);return 1;}static -int Pgetgroup(lua_State*L){struct group*g=NULL;if(lua_isnumber(L,1))g=getgrgid -((gid_t)lua_tonumber(L,1));else if(lua_isstring(L,1))g=getgrnam(lua_tostring(L -,1));else luaL_typerror(L,1,"string or number");if(g==NULL)lua_pushnil(L);else -{int i;lua_newtable(L);storestring(L,"name",g->gr_name);storenumber(L,"gid",g -->gr_gid);for(i=0;g->gr_mem[i]!=NULL;i++)storeindex(L,i+1,g->gr_mem[i]);} -return 1;}static int Psetuid(lua_State*L){return lposix_pushresult(L,setuid( -mygetuid(L,1)),NULL);}static int Psetgid(lua_State*L){return lposix_pushresult -(L,setgid(mygetgid(L,1)),NULL);}struct mytimes{struct tms t;clock_t elapsed;}; -#define pushtime(L,x) lua_pushnumber(L,((lua_Number)x)/CLOCKS_PER_SEC) -static int Ftimes(lua_State*L,int i,const void*data){const struct mytimes*t= -data;switch(i){case 0:pushtime(L,t->t.tms_utime);break;case 1:pushtime(L,t->t. -tms_stime);break;case 2:pushtime(L,t->t.tms_cutime);break;case 3:pushtime(L,t -->t.tms_cstime);break;case 4:pushtime(L,t->elapsed);break;}return 1;}static -const char*const Stimes[]={"utime","stime","cutime","cstime","elapsed",NULL}; -#define storetime(L,name,x) storenumber(L,name,(lua_Number)x/CLK_TCK) -static int Ptimes(lua_State*L){struct mytimes t;t.elapsed=times(&t.t);return -doselection(L,1,Stimes,Ftimes,&t);}struct mystat{struct stat s;char mode[10]; -const char*type;};static int Fstat(lua_State*L,int i,const void*data){const -struct mystat*s=data;switch(i){case 0:lua_pushstring(L,s->mode);break;case 1: -lua_pushnumber(L,s->s.st_ino);break;case 2:lua_pushnumber(L,s->s.st_dev);break -;case 3:lua_pushnumber(L,s->s.st_nlink);break;case 4:lua_pushnumber(L,s->s. -st_uid);break;case 5:lua_pushnumber(L,s->s.st_gid);break;case 6:lua_pushnumber -(L,s->s.st_size);break;case 7:lua_pushnumber(L,s->s.st_atime);break;case 8: -lua_pushnumber(L,s->s.st_mtime);break;case 9:lua_pushnumber(L,s->s.st_ctime); -break;case 10:lua_pushstring(L,s->type);break;case 11:lua_pushnumber(L,s->s. -st_mode);break;}return 1;}static const char*const Sstat[]={"mode","ino","dev", -"nlink","uid","gid","size","atime","mtime","ctime","type","_mode",NULL};static - int Pstat(lua_State*L){struct mystat s;const char*path=luaL_checkstring(L,1); -if(stat(path,&s.s)==-1)return pusherror(L,path);s.type=filetype(s.s.st_mode); -modechopper(s.s.st_mode,s.mode);return doselection(L,2,Sstat,Fstat,&s);}static - int Puname(lua_State*L){struct utsname u;luaL_Buffer b;const char*s;if(uname( -&u)==-1)return pusherror(L,NULL);luaL_buffinit(L,&b);for(s=luaL_optstring(L,1, -"%s %n %r %v %m");*s;s++)if(*s!='%')luaL_putchar(&b,*s);else switch(*++s){case -'%':luaL_putchar(&b,*s);break;case'm':luaL_addstring(&b,u.machine);break;case -'n':luaL_addstring(&b,u.nodename);break;case'r':luaL_addstring(&b,u.release); -break;case's':luaL_addstring(&b,u.sysname);break;case'v':luaL_addstring(&b,u. -version);break;default:badoption(L,2,"format",*s);break;}luaL_pushresult(&b); -return 1;}static const int Kpathconf[]={_PC_LINK_MAX,_PC_MAX_CANON, -_PC_MAX_INPUT,_PC_NAME_MAX,_PC_PATH_MAX,_PC_PIPE_BUF,_PC_CHOWN_RESTRICTED, -_PC_NO_TRUNC,_PC_VDISABLE,-1};static int Fpathconf(lua_State*L,int i,const -void*data){const char*path=data;lua_pushnumber(L,pathconf(path,Kpathconf[i])); -return 1;}static const char*const Spathconf[]={"link_max","max_canon", -"max_input","name_max","path_max","pipe_buf","chown_restricted","no_trunc", -"vdisable",NULL};static int Ppathconf(lua_State*L){const char*path= -luaL_checkstring(L,1);return doselection(L,2,Spathconf,Fpathconf,path);}static - const int Ksysconf[]={_SC_ARG_MAX,_SC_CHILD_MAX,_SC_CLK_TCK,_SC_NGROUPS_MAX, -_SC_STREAM_MAX,_SC_TZNAME_MAX,_SC_OPEN_MAX,_SC_JOB_CONTROL,_SC_SAVED_IDS, -_SC_VERSION,-1};static int Fsysconf(lua_State*L,int i,const void*data){ -lua_pushnumber(L,sysconf(Ksysconf[i]));return 1;}static const char*const -Ssysconf[]={"arg_max","child_max","clk_tck","ngroups_max","stream_max", -"tzname_max","open_max","job_control","saved_ids","version",NULL};static int -Psysconf(lua_State*L){return doselection(L,1,Ssysconf,Fsysconf,NULL);}static -const luaL_reg R[]={{"access",Paccess},{"chdir",Pchdir},{"chmod",Pchmod},{ -"chown",Pchown},{"ctermid",Pctermid},{"dir",Pdir},{"errno",Perrno},{"exec", -Pexec},{"files",Pfiles},{"fork",Pfork},{"getcwd",Pgetcwd},{"getenv",Pgetenv},{ -"getgroup",Pgetgroup},{"getlogin",Pgetlogin},{"getpasswd",Pgetpasswd},{ -"getprocessid",Pgetprocessid},{"kill",Pkill},{"link",Plink},{"mkdir",Pmkdir},{ -"mkfifo",Pmkfifo},{"pathconf",Ppathconf},{"putenv",Pputenv},{"readlink", -Preadlink},{"rmdir",Prmdir},{"setgid",Psetgid},{"setuid",Psetuid},{"sleep", -Psleep},{"stat",Pstat},{"symlink",Psymlink},{"sysconf",Psysconf},{"times", -Ptimes},{"ttyname",Pttyname},{"umask",Pumask},{"uname",Puname},{"unlink", -Punlink},{"utime",Putime},{"wait",Pwait}, -#ifdef linux -{"setenv",Psetenv},{"unsetenv",Punsetenv}, -#endif -{NULL,NULL}};LUALIB_API int luaopen_posix(lua_State*L){luaL_openlib(L,MYNAME,R -,0);lua_pushliteral(L,"version");lua_pushliteral(L,MYVERSION);lua_settable(L,- -3);return 1;} -#line 1 "lstate.c" -#define lstate_c -#ifndef LUA_USERSTATE -#define EXTRASPACE 0 -#else -union UEXTRASPACE{L_Umaxalign a;LUA_USERSTATE b;}; -#define EXTRASPACE (sizeof(union UEXTRASPACE)) -#endif -static int default_panic(lua_State*L){UNUSED(L);return 0;}static lua_State* -mallocstate(lua_State*L){lu_byte*block=(lu_byte*)luaM_malloc(L,sizeof( -lua_State)+EXTRASPACE);if(block==NULL)return NULL;else{block+=EXTRASPACE; -return cast(lua_State*,block);}}static void freestate(lua_State*L,lua_State*L1 -){luaM_free(L,cast(lu_byte*,L1)-EXTRASPACE,sizeof(lua_State)+EXTRASPACE);} -static void stack_init(lua_State*L1,lua_State*L){L1->stack=luaM_newvector(L, -BASIC_STACK_SIZE+EXTRA_STACK,TObject);L1->stacksize=BASIC_STACK_SIZE+ -EXTRA_STACK;L1->top=L1->stack;L1->stack_last=L1->stack+(L1->stacksize- -EXTRA_STACK)-1;L1->base_ci=luaM_newvector(L,BASIC_CI_SIZE,CallInfo);L1->ci=L1 -->base_ci;L1->ci->state=CI_C;setnilvalue(L1->top++);L1->base=L1->ci->base=L1-> -top;L1->ci->top=L1->top+LUA_MINSTACK;L1->size_ci=BASIC_CI_SIZE;L1->end_ci=L1-> -base_ci+L1->size_ci;}static void freestack(lua_State*L,lua_State*L1){ -luaM_freearray(L,L1->base_ci,L1->size_ci,CallInfo);luaM_freearray(L,L1->stack, -L1->stacksize,TObject);}static void f_luaopen(lua_State*L,void*ud){ -global_State*g=luaM_new(NULL,global_State);UNUSED(ud);if(g==NULL)luaD_throw(L, -LUA_ERRMEM);L->l_G=g;g->mainthread=L;g->GCthreshold=0;g->strt.size=0;g->strt. -nuse=0;g->strt.hash=NULL;setnilvalue(defaultmeta(L));setnilvalue(registry(L)); -luaZ_initbuffer(L,&g->buff);g->panic=default_panic;g->rootgc=NULL;g->rootudata -=NULL;g->tmudata=NULL;setnilvalue(gkey(g->dummynode));setnilvalue(gval(g-> -dummynode));g->dummynode->next=NULL;g->nblocks=sizeof(lua_State)+sizeof( -global_State);stack_init(L,L);defaultmeta(L)->tt=LUA_TTABLE;sethvalue( -defaultmeta(L),luaH_new(L,0,0));hvalue(defaultmeta(L))->metatable=hvalue( -defaultmeta(L));sethvalue(gt(L),luaH_new(L,0,4));sethvalue(registry(L), -luaH_new(L,4,4));luaS_resize(L,MINSTRTABSIZE);luaT_init(L);luaX_init(L); -luaS_fix(luaS_newliteral(L,MEMERRMSG));g->GCthreshold=4*G(L)->nblocks;}static -void preinit_state(lua_State*L){L->stack=NULL;L->stacksize=0;L->errorJmp=NULL; -L->hook=NULL;L->hookmask=L->hookinit=0;L->basehookcount=0;L->allowhook=1; -resethookcount(L);L->openupval=NULL;L->size_ci=0;L->nCcalls=0;L->base_ci=L->ci -=NULL;L->errfunc=0;setnilvalue(gt(L));}static void close_state(lua_State*L){ -luaF_close(L,L->stack);if(G(L)){luaC_sweep(L,1);lua_assert(G(L)->rootgc==NULL) -;lua_assert(G(L)->rootudata==NULL);luaS_freeall(L);luaZ_freebuffer(L,&G(L)-> -buff);}freestack(L,L);if(G(L)){lua_assert(G(L)->nblocks==sizeof(lua_State)+ -sizeof(global_State));luaM_freelem(NULL,G(L));}freestate(NULL,L);}lua_State* -luaE_newthread(lua_State*L){lua_State*L1=mallocstate(L);luaC_link(L,valtogco( -L1),LUA_TTHREAD);preinit_state(L1);L1->l_G=L->l_G;stack_init(L1,L);setobj2n(gt -(L1),gt(L));return L1;}void luaE_freethread(lua_State*L,lua_State*L1){ -luaF_close(L1,L1->stack);lua_assert(L1->openupval==NULL);freestack(L,L1); -freestate(L,L1);}LUA_API lua_State*lua_open(void){lua_State*L=mallocstate(NULL -);if(L){L->tt=LUA_TTHREAD;L->marked=0;L->next=L->gclist=NULL;preinit_state(L); -L->l_G=NULL;if(luaD_rawrunprotected(L,f_luaopen,NULL)!=0){close_state(L);L= -NULL;}}lua_userstateopen(L);return L;}static void callallgcTM(lua_State*L,void -*ud){UNUSED(ud);luaC_callGCTM(L);}LUA_API void lua_close(lua_State*L){lua_lock -(L);L=G(L)->mainthread;luaF_close(L,L->stack);luaC_separateudata(L);L->errfunc -=0;do{L->ci=L->base_ci;L->base=L->top=L->ci->base;L->nCcalls=0;}while( -luaD_rawrunprotected(L,callallgcTM,NULL)!=0);lua_assert(G(L)->tmudata==NULL); -close_state(L);} -#line 1 "lstring.c" -#define lstring_c -void luaS_freeall(lua_State*L){lua_assert(G(L)->strt.nuse==0);luaM_freearray(L -,G(L)->strt.hash,G(L)->strt.size,TString*);}void luaS_resize(lua_State*L,int -newsize){GCObject**newhash=luaM_newvector(L,newsize,GCObject*);stringtable*tb= -&G(L)->strt;int i;for(i=0;isize;i++ -){GCObject*p=tb->hash[i];while(p){GCObject*next=p->gch.next;lu_hash h=gcotots( -p)->tsv.hash;int h1=lmod(h,newsize);lua_assert(cast(int,h%newsize)==lmod(h, -newsize));p->gch.next=newhash[h1];newhash[h1]=p;p=next;}}luaM_freearray(L,tb-> -hash,tb->size,TString*);tb->size=newsize;tb->hash=newhash;}static TString* -newlstr(lua_State*L,const char*str,size_t l,lu_hash h){TString*ts=cast(TString -*,luaM_malloc(L,sizestring(l)));stringtable*tb;ts->tsv.len=l;ts->tsv.hash=h;ts -->tsv.marked=0;ts->tsv.tt=LUA_TSTRING;ts->tsv.reserved=0;memcpy(ts+1,str,l* -sizeof(char));((char*)(ts+1))[l]='\0';tb=&G(L)->strt;h=lmod(h,tb->size);ts-> -tsv.next=tb->hash[h];tb->hash[h]=valtogco(ts);tb->nuse++;if(tb->nuse>cast( -ls_nstr,tb->size)&&tb->size<=MAX_INT/2)luaS_resize(L,tb->size*2);return ts;} -TString*luaS_newlstr(lua_State*L,const char*str,size_t l){GCObject*o;lu_hash h -=(lu_hash)l;size_t step=(l>>5)+1;size_t l1;for(l1=l;l1>=step;l1-=step)h=h^((h -<<5)+(h>>2)+(unsigned char)(str[l1-1]));for(o=G(L)->strt.hash[lmod(h,G(L)-> -strt.size)];o!=NULL;o=o->gch.next){TString*ts=gcotots(o);if(ts->tsv.len==l&&( -memcmp(str,getstr(ts),l)==0))return ts;}return newlstr(L,str,l,h);}Udata* -luaS_newudata(lua_State*L,size_t s){Udata*u;u=cast(Udata*,luaM_malloc(L, -sizeudata(s)));u->uv.marked=(1<<1);u->uv.tt=LUA_TUSERDATA;u->uv.len=s;u->uv. -metatable=hvalue(defaultmeta(L));u->uv.next=G(L)->rootudata;G(L)->rootudata= -valtogco(u);return u;} -#line 1 "lstrlib.c" -#define lstrlib_c -#ifndef uchar -#define uchar(c) ((unsigned char)(c)) -#endif -typedef long sint32;static int str_len(lua_State*L){size_t l;luaL_checklstring -(L,1,&l);lua_pushnumber(L,(lua_Number)l);return 1;}static sint32 posrelat( -sint32 pos,size_t len){return(pos>=0)?pos:(sint32)len+pos+1;}static int -str_sub(lua_State*L){size_t l;const char*s=luaL_checklstring(L,1,&l);sint32 -start=posrelat(luaL_checklong(L,2),l);sint32 end=posrelat(luaL_optlong(L,3,-1) -,l);if(start<1)start=1;if(end>(sint32)l)end=(sint32)l;if(start<=end) -lua_pushlstring(L,s+start-1,end-start+1);else lua_pushliteral(L,"");return 1;} -static int str_lower(lua_State*L){size_t l;size_t i;luaL_Buffer b;const char*s -=luaL_checklstring(L,1,&l);luaL_buffinit(L,&b);for(i=0;i0)luaL_addlstring(&b,s,l);luaL_pushresult(&b); -return 1;}static int str_byte(lua_State*L){size_t l;const char*s= -luaL_checklstring(L,1,&l);sint32 pos=posrelat(luaL_optlong(L,2,1),l);if(pos<=0 -||(size_t)(pos)>l)return 0;lua_pushnumber(L,uchar(s[pos-1]));return 1;}static -int str_char(lua_State*L){int n=lua_gettop(L);int i;luaL_Buffer b; -luaL_buffinit(L,&b);for(i=1;i<=n;i++){int c=luaL_checkint(L,i);luaL_argcheck(L -,uchar(c)==c,i,"invalid value");luaL_putchar(&b,uchar(c));}luaL_pushresult(&b) -;return 1;}static int writer(lua_State*L,const void*b,size_t size,void*B){( -void)L;luaL_addlstring((luaL_Buffer*)B,(const char*)b,size);return 1;}static -int str_dump(lua_State*L){luaL_Buffer b;luaL_checktype(L,1,LUA_TFUNCTION); -luaL_buffinit(L,&b);if(!lua_dump(L,writer,&b))luaL_error(L, -"unable to dump given function");luaL_pushresult(&b);return 1;} -#ifndef MAX_CAPTURES -#define MAX_CAPTURES 32 -#endif -#define CAP_UNFINISHED (-1) -#define CAP_POSITION (-2) -typedef struct MatchState{const char*src_init;const char*src_end;lua_State*L; -int level;struct{const char*init;sint32 len;}capture[MAX_CAPTURES];}MatchState -; -#define ESC '%' -#define SPECIALS "^$*+?.([%-" -static int check_capture(MatchState*ms,int l){l-='1';if(l<0||l>=ms->level||ms -->capture[l].len==CAP_UNFINISHED)return luaL_error(ms->L, -"invalid capture index");return l;}static int capture_to_close(MatchState*ms){ -int level=ms->level;for(level--;level>=0;level--)if(ms->capture[level].len== -CAP_UNFINISHED)return level;return luaL_error(ms->L,"invalid pattern capture") -;}static const char*luaI_classend(MatchState*ms,const char*p){switch(*p++){ -case ESC:{if(*p=='\0')luaL_error(ms->L,"malformed pattern (ends with `%')"); -return p+1;}case'[':{if(*p=='^')p++;do{if(*p=='\0')luaL_error(ms->L, -"malformed pattern (missing `]')");if(*(p++)==ESC&&*p!='\0')p++;}while(*p!=']' -);return p+1;}default:{return p;}}}static int match_class(int c,int cl){int -res;switch(tolower(cl)){case'a':res=isalpha(c);break;case'c':res=iscntrl(c); -break;case'd':res=isdigit(c);break;case'l':res=islower(c);break;case'p':res= -ispunct(c);break;case's':res=isspace(c);break;case'u':res=isupper(c);break; -case'w':res=isalnum(c);break;case'x':res=isxdigit(c);break;case'z':res=(c==0); -break;default:return(cl==c);}return(islower(cl)?res:!res);}static int -matchbracketclass(int c,const char*p,const char*ec){int sig=1;if(*(p+1)=='^'){ -sig=0;p++;}while(++pL,"unbalanced pattern");if(*s!=*p) -return NULL;else{int b=*p;int e=*(p+1);int cont=1;while(++ssrc_end){if(*s -==e){if(--cont==0)return s+1;}else if(*s==b)cont++;}}return NULL;}static const - char*max_expand(MatchState*ms,const char*s,const char*p,const char*ep){sint32 - i=0;while((s+i)src_end&&luaI_singlematch(uchar(*(s+i)),p,ep))i++;while(i ->=0){const char*res=match(ms,(s+i),ep+1);if(res)return res;i--;}return NULL;} -static const char*min_expand(MatchState*ms,const char*s,const char*p,const -char*ep){for(;;){const char*res=match(ms,s,ep+1);if(res!=NULL)return res;else -if(ssrc_end&&luaI_singlematch(uchar(*s),p,ep))s++;else return NULL;}} -static const char*start_capture(MatchState*ms,const char*s,const char*p,int -what){const char*res;int level=ms->level;if(level>=MAX_CAPTURES)luaL_error(ms -->L,"too many captures");ms->capture[level].init=s;ms->capture[level].len=what -;ms->level=level+1;if((res=match(ms,s,p))==NULL)ms->level--;return res;}static - const char*end_capture(MatchState*ms,const char*s,const char*p){int l= -capture_to_close(ms);const char*res;ms->capture[l].len=s-ms->capture[l].init; -if((res=match(ms,s,p))==NULL)ms->capture[l].len=CAP_UNFINISHED;return res;} -static const char*match_capture(MatchState*ms,const char*s,int l){size_t len;l -=check_capture(ms,l);len=ms->capture[l].len;if((size_t)(ms->src_end-s)>=len&& -memcmp(ms->capture[l].init,s,len)==0)return s+len;else return NULL;}static -const char*match(MatchState*ms,const char*s,const char*p){init:switch(*p){case -'(':{if(*(p+1)==')')return start_capture(ms,s,p+2,CAP_POSITION);else return -start_capture(ms,s,p+1,CAP_UNFINISHED);}case')':{return end_capture(ms,s,p+1); -}case ESC:{switch(*(p+1)){case'b':{s=matchbalance(ms,s,p+2);if(s==NULL)return -NULL;p+=4;goto init;}case'f':{const char*ep;char previous;p+=2;if(*p!='[') -luaL_error(ms->L,"missing `[' after `%%f' in pattern");ep=luaI_classend(ms,p); -previous=(s==ms->src_init)?'\0':*(s-1);if(matchbracketclass(uchar(previous),p, -ep-1)||!matchbracketclass(uchar(*s),p,ep-1))return NULL;p=ep;goto init;} -default:{if(isdigit(uchar(*(p+1)))){s=match_capture(ms,s,*(p+1));if(s==NULL) -return NULL;p+=2;goto init;}goto dflt;}}}case'\0':{return s;}case'$':{if(*(p+1 -)=='\0')return(s==ms->src_end)?s:NULL;else goto dflt;}default:dflt:{const char -*ep=luaI_classend(ms,p);int m=ssrc_end&&luaI_singlematch(uchar(*s),p,ep); -switch(*ep){case'?':{const char*res;if(m&&((res=match(ms,s+1,ep+1))!=NULL)) -return res;p=ep+1;goto init;}case'*':{return max_expand(ms,s,p,ep);}case'+':{ -return(m?max_expand(ms,s+1,p,ep):NULL);}case'-':{return min_expand(ms,s,p,ep); -}default:{if(!m)return NULL;s++;p=ep;goto init;}}}}}static const char*lmemfind -(const char*s1,size_t l1,const char*s2,size_t l2){if(l2==0)return s1;else if( -l2>l1)return NULL;else{const char*init;l2--;l1=l1-l2;while(l1>0&&(init=(const -char*)memchr(s1,*s2,l1))!=NULL){init++;if(memcmp(init,s2+1,l2)==0)return init- -1;else{l1-=init-s1;s1=init;}}return NULL;}}static void push_onecapture( -MatchState*ms,int i){int l=ms->capture[i].len;if(l==CAP_UNFINISHED)luaL_error( -ms->L,"unfinished capture");if(l==CAP_POSITION)lua_pushnumber(ms->L,( -lua_Number)(ms->capture[i].init-ms->src_init+1));else lua_pushlstring(ms->L,ms -->capture[i].init,l);}static int push_captures(MatchState*ms,const char*s, -const char*e){int i;luaL_checkstack(ms->L,ms->level,"too many captures");if(ms -->level==0&&s){lua_pushlstring(ms->L,s,e-s);return 1;}else{for(i=0;ilevel -;i++)push_onecapture(ms,i);return ms->level;}}static int str_find(lua_State*L) -{size_t l1,l2;const char*s=luaL_checklstring(L,1,&l1);const char*p= -luaL_checklstring(L,2,&l2);sint32 init=posrelat(luaL_optlong(L,3,1),l1)-1;if( -init<0)init=0;else if((size_t)(init)>l1)init=(sint32)l1;if(lua_toboolean(L,4) -||strpbrk(p,SPECIALS)==NULL){const char*s2=lmemfind(s+init,l1-init,p,l2);if(s2 -){lua_pushnumber(L,(lua_Number)(s2-s+1));lua_pushnumber(L,(lua_Number)(s2-s+l2 -));return 2;}}else{MatchState ms;int anchor=(*p=='^')?(p++,1):0;const char*s1= -s+init;ms.L=L;ms.src_init=s;ms.src_end=s+l1;do{const char*res;ms.level=0;if(( -res=match(&ms,s1,p))!=NULL){lua_pushnumber(L,(lua_Number)(s1-s+1)); -lua_pushnumber(L,(lua_Number)(res-s));return push_captures(&ms,NULL,0)+2;}} -while(s1++L -;if(lua_isstring(L,3)){const char*news=lua_tostring(L,3);size_t l=lua_strlen(L -,3);size_t i;for(i=0;i=3&&(lua_isstring(L,3)||lua_isfunction(L,3)),3, -"string or function expected");luaL_buffinit(L,&b);ms.L=L;ms.src_init=src;ms. -src_end=src+srcl;while(nsrc)src=e;else if(srcMAX_FORMAT)luaL_error(L,"invalid format (too long)");form[0]='%'; -strncpy(form+1,strfrmt,p-strfrmt+1);form[p-strfrmt+2]=0;return p;}static int -str_format(lua_State*L){int arg=1;size_t sfl;const char*strfrmt= -luaL_checklstring(L,arg,&sfl);const char*strfrmt_end=strfrmt+sfl;luaL_Buffer b -;luaL_buffinit(L,&b);while(strfrmt=100){lua_pushvalue(L,arg); -luaL_addvalue(&b);continue;}else{sprintf(buff,form,s);break;}}default:{return -luaL_error(L,"invalid option to `format'");}}luaL_addlstring(&b,buff,strlen( -buff));}}luaL_pushresult(&b);return 1;}static const luaL_reg strlib[]={{"len", -str_len},{"sub",str_sub},{"lower",str_lower},{"upper",str_upper},{"char", -str_char},{"rep",str_rep},{"byte",str_byte},{"format",str_format},{"dump", -str_dump},{"find",str_find},{"gfind",gfind},{"gsub",str_gsub},{NULL,NULL}}; -LUALIB_API int luaopen_string(lua_State*L){luaL_openlib(L,LUA_STRLIBNAME, -strlib,0);return 1;} -#line 1 "ltable.c" -#define ltable_c -#if BITS_INT >26 -#define MAXBITS 24 -#else -#define MAXBITS (BITS_INT-2) -#endif -#define toobig(x) ((((x)-1)>>MAXBITS)!=0) -#ifndef lua_number2int -#define lua_number2int(i,n) ((i)=(int)(n)) -#endif -#define hashpow2(t,n) (gnode(t,lmod((n),sizenode(t)))) -#define hashstr(t,str) hashpow2(t,(str)->tsv.hash) -#define hashboolean(t,p) hashpow2(t,p) -#define hashmod(t,n) (gnode(t,((n)%((sizenode(t)-1)|1)))) -#define hashpointer(t,p) hashmod(t,IntPoint(p)) -#define numints cast(int,sizeof(lua_Number)/sizeof(int)) -static Node*hashnum(const Table*t,lua_Number n){unsigned int a[numints];int i; -n+=1;lua_assert(sizeof(a)<=sizeof(n));memcpy(a,&n,sizeof(a));for(i=1;i=1&&!toobig(k))return k;} -return-1;}static int luaH_index(lua_State*L,Table*t,StkId key){int i;if( -ttisnil(key))return-1;i=arrayindex(key);if(0<=i&&i<=t->sizearray){return i-1;} -else{const TObject*v=luaH_get(t,key);if(v==&luaO_nilobject)luaG_runerror(L, -"invalid key for `next'");i=cast(int,(cast(const lu_byte*,v)-cast(const -lu_byte*,gval(gnode(t,0))))/sizeof(Node));return i+t->sizearray;}}int -luaH_next(lua_State*L,Table*t,StkId key){int i=luaH_index(L,t,key);for(i++;isizearray;i++){if(!ttisnil(&t->array[i])){setnvalue(key,cast(lua_Number,i+1) -);setobj2s(key+1,&t->array[i]);return 1;}}for(i-=t->sizearray;i=twoto(i-1);i++){if(nums[i]>0){a+=nums[i];if(a>= -twoto(i-1)){n=i;na=a;}}}lua_assert(na<=*narray&&*narray<=ntotal);*nhash=ntotal --na;*narray=(n==-1)?0:twoto(n);lua_assert(na<=*narray&&na>=*narray/2);}static -void numuse(const Table*t,int*narray,int*nhash){int nums[MAXBITS+1];int i,lg; -int totaluse=0;for(i=0,lg=0;lg<=MAXBITS;lg++){int ttlg=twoto(lg);if(ttlg>t-> -sizearray){ttlg=t->sizearray;if(i>=ttlg)break;}nums[lg]=0;for(;iarray[i])){nums[lg]++;totaluse++;}}}for(;lg<=MAXBITS;lg++)nums[lg -]=0;*narray=totaluse;i=sizenode(t);while(i--){Node*n=&t->node[i];if(!ttisnil( -gval(n))){int k=arrayindex(gkey(n));if(k>=0){nums[luaO_log2(k-1)+1]++;(*narray -)++;}totaluse++;}}computesizes(nums,totaluse,narray,nhash);}static void -setarrayvector(lua_State*L,Table*t,int size){int i;luaM_reallocvector(L,t-> -array,t->sizearray,size,TObject);for(i=t->sizearray;iarray[i]);t->sizearray=size;}static void setnodevector(lua_State*L,Table*t, -int lsize){int i;int size=twoto(lsize);if(lsize>MAXBITS)luaG_runerror(L, -"table overflow");if(lsize==0){t->node=G(L)->dummynode;lua_assert(ttisnil(gkey -(t->node)));lua_assert(ttisnil(gval(t->node)));lua_assert(t->node->next==NULL) -;}else{t->node=luaM_newvector(L,size,Node);for(i=0;inode[i].next -=NULL;setnilvalue(gkey(gnode(t,i)));setnilvalue(gval(gnode(t,i)));}}t-> -lsizenode=cast(lu_byte,lsize);t->firstfree=gnode(t,size-1);}static void resize -(lua_State*L,Table*t,int nasize,int nhsize){int i;int oldasize=t->sizearray; -int oldhsize=t->lsizenode;Node*nold;Node temp[1];if(oldhsize)nold=t->node;else -{lua_assert(t->node==G(L)->dummynode);temp[0]=t->node[0];nold=temp;setnilvalue -(gkey(G(L)->dummynode));setnilvalue(gval(G(L)->dummynode));lua_assert(G(L)-> -dummynode->next==NULL);}if(nasize>oldasize)setarrayvector(L,t,nasize); -setnodevector(L,t,nhsize);if(nasizesizearray=nasize;for(i=nasize -;iarray[i]))setobjt2t(luaH_setnum(L,t,i+1),&t-> -array[i]);}luaM_reallocvector(L,t->array,oldasize,nasize,TObject);}for(i=twoto -(oldhsize)-1;i>=0;i--){Node*old=nold+i;if(!ttisnil(gval(old)))setobjt2t( -luaH_set(L,t,gkey(old)),gval(old));}if(oldhsize)luaM_freearray(L,nold,twoto( -oldhsize),Node);}static void rehash(lua_State*L,Table*t){int nasize,nhsize; -numuse(t,&nasize,&nhsize);resize(L,t,nasize,luaO_log2(nhsize)+1);}Table* -luaH_new(lua_State*L,int narray,int lnhash){Table*t=luaM_new(L,Table); -luaC_link(L,valtogco(t),LUA_TTABLE);t->metatable=hvalue(defaultmeta(L));t-> -flags=cast(lu_byte,~0);t->array=NULL;t->sizearray=0;t->lsizenode=0;t->node= -NULL;setarrayvector(L,t,narray);setnodevector(L,t,lnhash);return t;}void -luaH_free(lua_State*L,Table*t){if(t->lsizenode)luaM_freearray(L,t->node, -sizenode(t),Node);luaM_freearray(L,t->array,t->sizearray,TObject);luaM_freelem -(L,t);} -#if 0 -void luaH_remove(Table*t,Node*e){Node*mp=luaH_mainposition(t,gkey(e));if(e!=mp -){while(mp->next!=e)mp=mp->next;mp->next=e->next;}else{if(e->next!=NULL)??} -lua_assert(ttisnil(gval(node)));setnilvalue(gkey(e));e->next=NULL;} -#endif -static TObject*newkey(lua_State*L,Table*t,const TObject*key){TObject*val;Node* -mp=luaH_mainposition(t,key);if(!ttisnil(gval(mp))){Node*othern= -luaH_mainposition(t,gkey(mp));Node*n=t->firstfree;if(othern!=mp){while(othern -->next!=mp)othern=othern->next;othern->next=n;*n=*mp;mp->next=NULL;setnilvalue -(gval(mp));}else{n->next=mp->next;mp->next=n;mp=n;}}setobj2t(gkey(mp),key); -lua_assert(ttisnil(gval(mp)));for(;;){if(ttisnil(gkey(t->firstfree)))return -gval(mp);else if(t->firstfree==t->node)break;else(t->firstfree)--;}setbvalue( -gval(mp),0);rehash(L,t);val=cast(TObject*,luaH_get(t,key));lua_assert( -ttisboolean(val));setnilvalue(val);return val;}static const TObject* -luaH_getany(Table*t,const TObject*key){if(ttisnil(key))return&luaO_nilobject; -else{Node*n=luaH_mainposition(t,key);do{if(luaO_rawequalObj(gkey(n),key)) -return gval(n);else n=n->next;}while(n);return&luaO_nilobject;}}const TObject* -luaH_getnum(Table*t,int key){if(1<=key&&key<=t->sizearray)return&t->array[key- -1];else{lua_Number nk=cast(lua_Number,key);Node*n=hashnum(t,nk);do{if( -ttisnumber(gkey(n))&&nvalue(gkey(n))==nk)return gval(n);else n=n->next;}while( -n);return&luaO_nilobject;}}const TObject*luaH_getstr(Table*t,TString*key){Node -*n=hashstr(t,key);do{if(ttisstring(gkey(n))&&tsvalue(gkey(n))==key)return gval -(n);else n=n->next;}while(n);return&luaO_nilobject;}const TObject*luaH_get( -Table*t,const TObject*key){switch(ttype(key)){case LUA_TSTRING:return -luaH_getstr(t,tsvalue(key));case LUA_TNUMBER:{int k;lua_number2int(k,(nvalue( -key)));if(cast(lua_Number,k)==nvalue(key))return luaH_getnum(t,k);}default: -return luaH_getany(t,key);}}TObject*luaH_set(lua_State*L,Table*t,const TObject -*key){const TObject*p=luaH_get(t,key);t->flags=0;if(p!=&luaO_nilobject)return -cast(TObject*,p);else{if(ttisnil(key))luaG_runerror(L,"table index is nil"); -else if(ttisnumber(key)&&nvalue(key)!=nvalue(key))luaG_runerror(L, -"table index is NaN");return newkey(L,t,key);}}TObject*luaH_setnum(lua_State*L -,Table*t,int key){const TObject*p=luaH_getnum(t,key);if(p!=&luaO_nilobject) -return cast(TObject*,p);else{TObject k;setnvalue(&k,cast(lua_Number,key)); -return newkey(L,t,&k);}} -#line 1 "ltablib.c" -#define ltablib_c -#define aux_getn(L,n) (luaL_checktype(L,n,LUA_TTABLE),luaL_getn(L,n)) -static int luaB_foreachi(lua_State*L){int i;int n=aux_getn(L,1);luaL_checktype -(L,2,LUA_TFUNCTION);for(i=1;i<=n;i++){lua_pushvalue(L,2);lua_pushnumber(L,( -lua_Number)i);lua_rawgeti(L,1,i);lua_call(L,2,1);if(!lua_isnil(L,-1))return 1; -lua_pop(L,1);}return 0;}static int luaB_foreach(lua_State*L){luaL_checktype(L, -1,LUA_TTABLE);luaL_checktype(L,2,LUA_TFUNCTION);lua_pushnil(L);for(;;){if( -lua_next(L,1)==0)return 0;lua_pushvalue(L,2);lua_pushvalue(L,-3);lua_pushvalue -(L,-3);lua_call(L,2,1);if(!lua_isnil(L,-1))return 1;lua_pop(L,2);}}static int -luaB_getn(lua_State*L){lua_pushnumber(L,(lua_Number)aux_getn(L,1));return 1;} -static int luaB_setn(lua_State*L){luaL_checktype(L,1,LUA_TTABLE);luaL_setn(L,1 -,luaL_checkint(L,2));return 0;}static int luaB_tinsert(lua_State*L){int v= -lua_gettop(L);int n=aux_getn(L,1)+1;int pos;if(v==2)pos=n;else{pos= -luaL_checkint(L,2);if(pos>n)n=pos;v=3;}luaL_setn(L,1,n);while(--n>=pos){ -lua_rawgeti(L,1,n);lua_rawseti(L,1,n+1);}lua_pushvalue(L,v);lua_rawseti(L,1, -pos);return 0;}static int luaB_tremove(lua_State*L){int n=aux_getn(L,1);int -pos=luaL_optint(L,2,n);if(n<=0)return 0;luaL_setn(L,1,n-1);lua_rawgeti(L,1,pos -);for(;posu) -luaL_error(L,"invalid order function for sorting");lua_pop(L,1);}while( -lua_rawgeti(L,1,--j),sort_comp(L,-3,-1)){if(jci->base+(k)-1) -static void setnameval(lua_State*L,const char*name,int val){lua_pushstring(L, -name);lua_pushintegral(L,val);lua_settable(L,-3);} -#define MARK 0x55 -#ifndef EXTERNMEMCHECK -#define HEADER (sizeof(L_Umaxalign)) -#define MARKSIZE 16 -#define blockhead(b) (cast(char*,b)-HEADER) -#define setsize(newblock, size)(*cast(size_t*,newblock)=size) -#define checkblocksize(b, size)(size==(*cast(size_t*,blockhead(b)))) -#define fillmem(mem,size) memset(mem,-MARK,size) -#else -#define HEADER 0 -#define MARKSIZE 0 -#define blockhead(b) (b) -#define setsize(newblock, size) -#define checkblocksize(b,size) (1) -#define fillmem(mem,size) -#endif -unsigned long memdebug_numblocks=0;unsigned long memdebug_total=0;unsigned -long memdebug_maxmem=0;unsigned long memdebug_memlimit=ULONG_MAX;static void* -checkblock(void*block,size_t size){void*b=blockhead(block);int i;for(i=0;i< -MARKSIZE;i++)lua_assert(*(cast(char*,b)+HEADER+size+i)==MARK+i);return b;} -static void freeblock(void*block,size_t size){if(block){lua_assert( -checkblocksize(block,size));block=checkblock(block,size);fillmem(block,size+ -HEADER+MARKSIZE);free(block);memdebug_numblocks--;memdebug_total-=size;}}void* -debug_realloc(void*block,size_t oldsize,size_t size){lua_assert(oldsize==0|| -checkblocksize(block,oldsize));lua_assert(block!=NULL||size>0);if(size==0){ -freeblock(block,oldsize);return NULL;}else if(size>oldsize&&memdebug_total+ -size-oldsize>memdebug_memlimit)return NULL;else{void*newblock;int i;size_t -realsize=HEADER+size+MARKSIZE;size_t commonsize=(oldsizememdebug_maxmem)memdebug_maxmem= -memdebug_total;memdebug_numblocks++;setsize(newblock,size);for(i=0;icode[pc];OpCode o=GET_OPCODE(i);const char*name=luaP_opnames[o];int line= -getline(p,pc);sprintf(buff,"(%4d) %4d - ",line,pc);switch(getOpMode(o)){case -iABC:sprintf(buff+strlen(buff),"%-12s%4d %4d %4d",name,GETARG_A(i),GETARG_B(i) -,GETARG_C(i));break;case iABx:sprintf(buff+strlen(buff),"%-12s%4d %4d",name, -GETARG_A(i),GETARG_Bx(i));break;case iAsBx:sprintf(buff+strlen(buff), -"%-12s%4d %4d",name,GETARG_A(i),GETARG_sBx(i));break;}return buff;} -#if 0 -void luaI_printcode(Proto*pt,int size){int pc;for(pc=0;pcl.p;lua_newtable(L);setnameval(L,"maxstack",p->maxstacksize);setnameval(L, -"numparams",p->numparams);for(pc=0;pcsizecode;pc++){char buff[100]; -lua_pushintegral(L,pc+1);lua_pushstring(L,buildop(p,pc,buff));lua_settable(L,- -3);}return 1;}static int listk(lua_State*L){Proto*p;int i;luaL_argcheck(L, -lua_isfunction(L,1)&&!lua_iscfunction(L,1),1,"Lua function expected");p= -clvalue(func_at(L,1))->l.p;lua_newtable(L);for(i=0;isizek;i++){ -lua_pushintegral(L,i+1);luaA_pushobject(L,p->k+i);lua_settable(L,-3);}return 1 -;}static int listlocals(lua_State*L){Proto*p;int pc=luaL_checkint(L,2)-1;int i -=0;const char*name;luaL_argcheck(L,lua_isfunction(L,1)&&!lua_iscfunction(L,1), -1,"Lua function expected");p=clvalue(func_at(L,1))->l.p;while((name= -luaF_getlocalname(p,++i,pc))!=NULL)lua_pushstring(L,name);return i-1;}static -int get_limits(lua_State*L){lua_newtable(L);setnameval(L,"BITS_INT",BITS_INT); -setnameval(L,"LFPF",LFIELDS_PER_FLUSH);setnameval(L,"MAXVARS",MAXVARS); -setnameval(L,"MAXPARAMS",MAXPARAMS);setnameval(L,"MAXSTACK",MAXSTACK); -setnameval(L,"MAXUPVALUES",MAXUPVALUES);return 1;}static int mem_query( -lua_State*L){if(lua_isnone(L,1)){lua_pushintegral(L,memdebug_total); -lua_pushintegral(L,memdebug_numblocks);lua_pushintegral(L,memdebug_maxmem); -return 3;}else{memdebug_memlimit=luaL_checkint(L,1);return 0;}}static int -hash_query(lua_State*L){if(lua_isnone(L,2)){luaL_argcheck(L,lua_type(L,1)== -LUA_TSTRING,1,"string expected");lua_pushintegral(L,tsvalue(func_at(L,1))->tsv -.hash);}else{TObject*o=func_at(L,1);Table*t;luaL_checktype(L,2,LUA_TTABLE);t= -hvalue(func_at(L,2));lua_pushintegral(L,luaH_mainposition(t,o)-t->node);} -return 1;}static int stacklevel(lua_State*L){unsigned long a=0; -lua_pushintegral(L,(int)(L->top-L->stack));lua_pushintegral(L,(int)(L-> -stack_last-L->stack));lua_pushintegral(L,(int)(L->ci-L->base_ci)); -lua_pushintegral(L,(int)(L->end_ci-L->base_ci));lua_pushintegral(L,(unsigned -long)&a);return 5;}static int table_query(lua_State*L){const Table*t;int i= -luaL_optint(L,2,-1);luaL_checktype(L,1,LUA_TTABLE);t=hvalue(func_at(L,1));if(i -==-1){lua_pushintegral(L,t->sizearray);lua_pushintegral(L,sizenode(t)); -lua_pushintegral(L,t->firstfree-t->node);}else if(isizearray){ -lua_pushintegral(L,i);luaA_pushobject(L,&t->array[i]);lua_pushnil(L);}else if( -(i-=t->sizearray)");luaA_pushobject(L,gval(gnode(t,i)));if(t-> -node[i].next)lua_pushintegral(L,t->node[i].next-t->node);else lua_pushnil(L);} -return 3;}static int string_query(lua_State*L){stringtable*tb=&G(L)->strt;int -s=luaL_optint(L,2,0)-1;if(s==-1){lua_pushintegral(L,tb->nuse);lua_pushintegral -(L,tb->size);return 2;}else if(ssize){GCObject*ts;int n=0;for(ts=tb->hash -[s];ts;ts=ts->gch.next){setsvalue2s(L->top,gcotots(ts));incr_top(L);n++;} -return n;}return 0;}static int tref(lua_State*L){int level=lua_gettop(L);int -lock=luaL_optint(L,2,1);luaL_checkany(L,1);lua_pushvalue(L,1);lua_pushintegral -(L,lua_ref(L,lock));assert(lua_gettop(L)==level+1);return 1;}static int getref -(lua_State*L){int level=lua_gettop(L);lua_getref(L,luaL_checkint(L,1));assert( -lua_gettop(L)==level+1);return 1;}static int unref(lua_State*L){int level= -lua_gettop(L);lua_unref(L,luaL_checkint(L,1));assert(lua_gettop(L)==level); -return 0;}static int metatable(lua_State*L){luaL_checkany(L,1);if(lua_isnone(L -,2)){if(lua_getmetatable(L,1)==0)lua_pushnil(L);}else{lua_settop(L,2); -luaL_checktype(L,2,LUA_TTABLE);lua_setmetatable(L,1);}return 1;}static int -upvalue(lua_State*L){int n=luaL_checkint(L,2);luaL_checktype(L,1,LUA_TFUNCTION -);if(lua_isnone(L,3)){const char*name=lua_getupvalue(L,1,n);if(name==NULL) -return 0;lua_pushstring(L,name);return 2;}else{const char*name=lua_setupvalue( -L,1,n);lua_pushstring(L,name);return 1;}}static int newuserdata(lua_State*L){ -size_t size=luaL_checkint(L,1);char*p=cast(char*,lua_newuserdata(L,size)); -while(size--)*p++='\0';return 1;}static int pushuserdata(lua_State*L){ -lua_pushlightuserdata(L,cast(void*,luaL_checkint(L,1)));return 1;}static int -udataval(lua_State*L){lua_pushintegral(L,cast(int,lua_touserdata(L,1)));return - 1;}static int doonnewstack(lua_State*L){lua_State*L1=lua_newthread(L);size_t -l;const char*s=luaL_checklstring(L,1,&l);int status=luaL_loadbuffer(L1,s,l,s); -if(status==0)status=lua_pcall(L1,0,0,0);lua_pushintegral(L,status);return 1;} -static int s2d(lua_State*L){lua_pushnumber(L,*cast(const double*, -luaL_checkstring(L,1)));return 1;}static int d2s(lua_State*L){double d= -luaL_checknumber(L,1);lua_pushlstring(L,cast(char*,&d),sizeof(d));return 1;} -static int newstate(lua_State*L){lua_State*L1=lua_open();if(L1){ -lua_userstateopen(L1);lua_pushintegral(L,(unsigned long)L1);}else lua_pushnil( -L);return 1;}static int loadlib(lua_State*L){static const luaL_reg libs[]={{ -"mathlibopen",luaopen_math},{"strlibopen",luaopen_string},{"iolibopen", -luaopen_io},{"tablibopen",luaopen_table},{"dblibopen",luaopen_debug},{ -"baselibopen",luaopen_base},{NULL,NULL}};lua_State*L1=cast(lua_State*,cast( -unsigned long,luaL_checknumber(L,1)));lua_pushvalue(L1,LUA_GLOBALSINDEX); -luaL_openlib(L1,NULL,libs,0);return 0;}static int closestate(lua_State*L){ -lua_State*L1=cast(lua_State*,cast(unsigned long,luaL_checknumber(L,1))); -lua_close(L1);lua_unlock(L);return 0;}static int doremote(lua_State*L){ -lua_State*L1=cast(lua_State*,cast(unsigned long,luaL_checknumber(L,1)));size_t - lcode;const char*code=luaL_checklstring(L,2,&lcode);int status;lua_settop(L1, -0);status=luaL_loadbuffer(L1,code,lcode,code);if(status==0)status=lua_pcall(L1 -,0,LUA_MULTRET,0);if(status!=0){lua_pushnil(L);lua_pushintegral(L,status); -lua_pushstring(L,lua_tostring(L1,-1));return 3;}else{int i=0;while(!lua_isnone -(L1,++i))lua_pushstring(L,lua_tostring(L1,i));lua_pop(L1,i-1);return i-1;}} -static int log2_aux(lua_State*L){lua_pushintegral(L,luaO_log2(luaL_checkint(L, -1)));return 1;}static int int2fb_aux(lua_State*L){int b=luaO_int2fb( -luaL_checkint(L,1));lua_pushintegral(L,b);lua_pushintegral(L,fb2int(b));return - 2;}static int test_do(lua_State*L){const char*p=luaL_checkstring(L,1);if(*p== -'@')lua_dofile(L,p+1);else lua_dostring(L,p);return lua_gettop(L);}static -const char*const delimits=" \t\n,;";static void skip(const char**pc){while(** -pc!='\0'&&strchr(delimits,**pc))(*pc)++;}static int getnum_aux(lua_State*L, -const char**pc){int res=0;int sig=1;skip(pc);if(**pc=='.'){res=cast(int, -lua_tonumber(L,-1));lua_pop(L,1);(*pc)++;return res;}else if(**pc=='-'){sig=-1 -;(*pc)++;}while(isdigit(cast(int,**pc)))res=res*10+(*(*pc)++)-'0';return sig* -res;}static const char*getname_aux(char*buff,const char**pc){int i=0;skip(pc); -while(**pc!='\0'&&!strchr(delimits,**pc))buff[i++]=*(*pc)++;buff[i]='\0'; -return buff;} -#define EQ(s1) (strcmp(s1,inst)==0) -#define getnum (getnum_aux(L,&pc)) -#define getname (getname_aux(buff,&pc)) -static int testC(lua_State*L){char buff[30];const char*pc=luaL_checkstring(L,1 -);for(;;){const char*inst=getname;if EQ("")return 0;else if EQ("isnumber"){ -lua_pushintegral(L,lua_isnumber(L,getnum));}else if EQ("isstring"){ -lua_pushintegral(L,lua_isstring(L,getnum));}else if EQ("istable"){ -lua_pushintegral(L,lua_istable(L,getnum));}else if EQ("iscfunction"){ -lua_pushintegral(L,lua_iscfunction(L,getnum));}else if EQ("isfunction"){ -lua_pushintegral(L,lua_isfunction(L,getnum));}else if EQ("isuserdata"){ -lua_pushintegral(L,lua_isuserdata(L,getnum));}else if EQ("isudataval"){ -lua_pushintegral(L,lua_islightuserdata(L,getnum));}else if EQ("isnil"){ -lua_pushintegral(L,lua_isnil(L,getnum));}else if EQ("isnull"){lua_pushintegral -(L,lua_isnone(L,getnum));}else if EQ("tonumber"){lua_pushnumber(L,lua_tonumber -(L,getnum));}else if EQ("tostring"){const char*s=lua_tostring(L,getnum); -lua_pushstring(L,s);}else if EQ("strlen"){lua_pushintegral(L,lua_strlen(L, -getnum));}else if EQ("tocfunction"){lua_pushcfunction(L,lua_tocfunction(L, -getnum));}else if EQ("return"){return getnum;}else if EQ("gettop"){ -lua_pushintegral(L,lua_gettop(L));}else if EQ("settop"){lua_settop(L,getnum);} -else if EQ("pop"){lua_pop(L,getnum);}else if EQ("pushnum"){lua_pushintegral(L, -getnum);}else if EQ("pushnil"){lua_pushnil(L);}else if EQ("pushbool"){ -lua_pushboolean(L,getnum);}else if EQ("tobool"){lua_pushintegral(L, -lua_toboolean(L,getnum));}else if EQ("pushvalue"){lua_pushvalue(L,getnum);} -else if EQ("pushcclosure"){lua_pushcclosure(L,testC,getnum);}else if EQ( -"pushupvalues"){lua_pushupvalues(L);}else if EQ("remove"){lua_remove(L,getnum) -;}else if EQ("insert"){lua_insert(L,getnum);}else if EQ("replace"){lua_replace -(L,getnum);}else if EQ("gettable"){lua_gettable(L,getnum);}else if EQ( -"settable"){lua_settable(L,getnum);}else if EQ("next"){lua_next(L,-2);}else if - EQ("concat"){lua_concat(L,getnum);}else if EQ("lessthan"){int a=getnum; -lua_pushboolean(L,lua_lessthan(L,a,getnum));}else if EQ("equal"){int a=getnum; -lua_pushboolean(L,lua_equal(L,a,getnum));}else if EQ("rawcall"){int narg= -getnum;int nres=getnum;lua_call(L,narg,nres);}else if EQ("call"){int narg= -getnum;int nres=getnum;lua_pcall(L,narg,nres,0);}else if EQ("loadstring"){ -size_t sl;const char*s=luaL_checklstring(L,getnum,&sl);luaL_loadbuffer(L,s,sl, -s);}else if EQ("loadfile"){luaL_loadfile(L,luaL_checkstring(L,getnum));}else -if EQ("setmetatable"){lua_setmetatable(L,getnum);}else if EQ("getmetatable"){ -if(lua_getmetatable(L,getnum)==0)lua_pushnil(L);}else if EQ("type"){ -lua_pushstring(L,lua_typename(L,lua_type(L,getnum)));}else if EQ("getn"){int i -=getnum;lua_pushintegral(L,luaL_getn(L,i));}else if EQ("setn"){int i=getnum; -int n=cast(int,lua_tonumber(L,-1));luaL_setn(L,i,n);lua_pop(L,1);}else -luaL_error(L,"unknown instruction %s",buff);}return 0;}static void yieldf( -lua_State*L,lua_Debug*ar){lua_yield(L,0);}static int setyhook(lua_State*L){if( -lua_isnoneornil(L,1))lua_sethook(L,NULL,0,0);else{const char*smask= -luaL_checkstring(L,1);int count=luaL_optint(L,2,0);int mask=0;if(strchr(smask, -'l'))mask|=LUA_MASKLINE;if(count>0)mask|=LUA_MASKCOUNT;lua_sethook(L,yieldf, -mask,count);}return 0;}static int coresume(lua_State*L){int status;lua_State* -co=lua_tothread(L,1);luaL_argcheck(L,co,1,"coroutine expected");status= -lua_resume(co,0);if(status!=0){lua_pushboolean(L,0);lua_insert(L,-2);return 2; -}else{lua_pushboolean(L,1);return 1;}}static const struct luaL_reg tests_funcs -[]={{"hash",hash_query},{"limits",get_limits},{"listcode",listcode},{"listk", -listk},{"listlocals",listlocals},{"loadlib",loadlib},{"stacklevel",stacklevel} -,{"querystr",string_query},{"querytab",table_query},{"doit",test_do},{"testC", -testC},{"ref",tref},{"getref",getref},{"unref",unref},{"d2s",d2s},{"s2d",s2d}, -{"metatable",metatable},{"upvalue",upvalue},{"newuserdata",newuserdata},{ -"pushuserdata",pushuserdata},{"udataval",udataval},{"doonnewstack", -doonnewstack},{"newstate",newstate},{"closestate",closestate},{"doremote", -doremote},{"log2",log2_aux},{"int2fb",int2fb_aux},{"totalmem",mem_query},{ -"resume",coresume},{"setyhook",setyhook},{NULL,NULL}};static void fim(void){if -(!islocked)lua_close(lua_state);lua_assert(memdebug_numblocks==0);lua_assert( -memdebug_total==0);}static int l_panic(lua_State*L){UNUSED(L);fprintf(stderr, -"unable to recover; exiting\n");return 0;}int luaB_opentests(lua_State*L){ -lua_atpanic(L,l_panic);lua_userstateopen(L);lua_state=L;luaL_openlib(L,"T", -tests_funcs,0);atexit(fim);return 0;} -#undef main -int main(int argc,char*argv[]){char*limit=getenv("MEMLIMIT");if(limit) -memdebug_memlimit=strtoul(limit,NULL,10);l_main(argc,argv);return 0;} -#endif -#line 1 "ltm.c" -#define ltm_c -const char*const luaT_typenames[]={"nil","boolean","userdata","number", -"string","table","function","userdata","thread"};void luaT_init(lua_State*L){ -static const char*const luaT_eventname[]={"__index","__newindex","__gc", -"__mode","__eq","__add","__sub","__mul","__div","__pow","__unm","__lt","__le", -"__concat","__call"};int i;for(i=0;itmname[i]=luaS_new(L, -luaT_eventname[i]);luaS_fix(G(L)->tmname[i]);}}const TObject*luaT_gettm(Table* -events,TMS event,TString*ename){const TObject*tm=luaH_getstr(events,ename); -lua_assert(event<=TM_EQ);if(ttisnil(tm)){events->flags|=cast(lu_byte,1u<tmname[event];switch(ttype(o)){case -LUA_TTABLE:return luaH_getstr(hvalue(o)->metatable,ename);case LUA_TUSERDATA: -return luaH_getstr(uvalue(o)->uv.metatable,ename);default:return& -luaO_nilobject;}} -#line 1 "lua.c" -#define lua_c -#ifdef LUA_USERCONFIG -#include LUA_USERCONFIG -#endif -#ifdef _POSIX_C_SOURCE -#define stdin_is_tty() isatty(0) -#else -#define stdin_is_tty() 1 -#endif -#ifndef PROMPT -#define PROMPT "> " -#endif -#ifndef PROMPT2 -#define PROMPT2 ">> " -#endif -#ifndef PROGNAME -#define PROGNAME "lua" -#endif -#ifndef lua_userinit -#define lua_userinit(L) openstdlibs(L) -#endif -#ifndef LUA_EXTRALIBS -#define LUA_EXTRALIBS -#endif -static lua_State*L=NULL;static const char*progname=PROGNAME;LUALIB_API int -luaopen_posix(lua_State*L);static const luaL_reg lualibs[]={{"base", -luaopen_base},{"table",luaopen_table},{"io",luaopen_io},{"string", -luaopen_string},{"debug",luaopen_debug},{"loadlib",luaopen_loadlib},{"posix", -luaopen_posix},LUA_EXTRALIBS{NULL,NULL}};static void lstop(lua_State*l, -lua_Debug*ar){(void)ar;lua_sethook(l,NULL,0,0);luaL_error(l,"interrupted!");} -static void laction(int i){signal(i,SIG_DFL);lua_sethook(L,lstop,LUA_MASKCALL| -LUA_MASKRET|LUA_MASKCOUNT,1);}static void print_usage(void){fprintf(stderr, -"usage: %s [options] [script [args]].\n""Available options are:\n" -" - execute stdin as a file\n"" -e stat execute string `stat'\n" -" -i enter interactive mode after executing `script'\n" -" -l name load and run library `name'\n" -" -v show version information\n"" -- stop handling options\n", -progname);}static void l_message(const char*pname,const char*msg){if(pname) -fprintf(stderr,"%s: ",pname);fprintf(stderr,"%s\n",msg);}static int report(int - status){const char*msg;if(status){msg=lua_tostring(L,-1);if(msg==NULL)msg= -"(error with no message)";l_message(progname,msg);lua_pop(L,1);}return status; -}static int lcall(int narg,int clear){int status;int base=lua_gettop(L)-narg; -lua_pushliteral(L,"_TRACEBACK");lua_rawget(L,LUA_GLOBALSINDEX);lua_insert(L, -base);signal(SIGINT,laction);status=lua_pcall(L,narg,(clear?0:LUA_MULTRET), -base);signal(SIGINT,SIG_DFL);lua_remove(L,base);return status;}static void -print_version(void){l_message(NULL,LUA_VERSION" "LUA_COPYRIGHT);}static void -getargs(char*argv[],int n){int i;lua_newtable(L);for(i=0;argv[i];i++){ -lua_pushnumber(L,i-n);lua_pushstring(L,argv[i]);lua_rawset(L,-3);} -lua_pushliteral(L,"n");lua_pushnumber(L,i-n-1);lua_rawset(L,-3);}static int -docall(int status){if(status==0)status=lcall(0,1);return report(status);} -static int file_input(const char*name){return docall(luaL_loadfile(L,name));} -static int dostring(const char*s,const char*name){return docall( -luaL_loadbuffer(L,s,strlen(s),name));}static int load_file(const char*name){ -lua_pushliteral(L,"require");lua_rawget(L,LUA_GLOBALSINDEX);if(!lua_isfunction -(L,-1)){lua_pop(L,1);return file_input(name);}else{lua_pushstring(L,name); -return report(lcall(1,1));}} -#ifndef lua_saveline -#define lua_saveline(L,line) -#endif -#ifndef lua_readline -#define lua_readline(L,prompt) readline(L,prompt) -#ifndef MAXINPUT -#define MAXINPUT 512 -#endif -static int readline(lua_State*l,const char*prompt){static char buffer[MAXINPUT -];if(prompt){fputs(prompt,stdout);fflush(stdout);}if(fgets(buffer,sizeof( -buffer),stdin)==NULL)return 0;else{lua_pushstring(l,buffer);return 1;}} -#endif -static const char*get_prompt(int firstline){const char*p=NULL;lua_pushstring(L -,firstline?"_PROMPT":"_PROMPT2");lua_rawget(L,LUA_GLOBALSINDEX);p=lua_tostring -(L,-1);if(p==NULL)p=(firstline?PROMPT:PROMPT2);lua_pop(L,1);return p;}static -int incomplete(int status){if(status==LUA_ERRSYNTAX&&strstr(lua_tostring(L,-1) -,"near `'")!=NULL){lua_pop(L,1);return 1;}else return 0;}static int -load_string(void){int status;lua_settop(L,0);if(lua_readline(L,get_prompt(1)) -==0)return-1;if(lua_tostring(L,-1)[0]=='='){lua_pushfstring(L,"return %s", -lua_tostring(L,-1)+1);lua_remove(L,-2);}for(;;){status=luaL_loadbuffer(L, -lua_tostring(L,1),lua_strlen(L,1),"=stdin");if(!incomplete(status))break;if( -lua_readline(L,get_prompt(0))==0)return-1;lua_concat(L,lua_gettop(L));} -lua_saveline(L,lua_tostring(L,1));lua_remove(L,1);return status;}static void -manual_input(void){int status;const char*oldprogname=progname;progname=NULL; -while((status=load_string())!=-1){if(status==0)status=lcall(0,0);report(status -);if(status==0&&lua_gettop(L)>0){lua_getglobal(L,"print");lua_insert(L,1);if( -lua_pcall(L,lua_gettop(L)-1,0,0)!=0)l_message(progname,lua_pushfstring(L, -"error calling `print' (%s)",lua_tostring(L,-1)));}}lua_settop(L,0);fputs("\n" -,stdout);progname=oldprogname;}static int handle_argv(char*argv[],int* -interactive){if(argv[1]==NULL){if(stdin_is_tty()){print_version();manual_input -();}else file_input(NULL);}else{int i;for(i=1;argv[i]!=NULL;i++){if(argv[i][0] -!='-')break;switch(argv[i][1]){case'-':{if(argv[i][2]!='\0'){print_usage(); -return 1;}i++;goto endloop;}case'\0':{file_input(NULL);break;}case'i':{* -interactive=1;break;}case'v':{print_version();break;}case'e':{const char*chunk -=argv[i]+2;if(*chunk=='\0')chunk=argv[++i];if(chunk==NULL){print_usage(); -return 1;}if(dostring(chunk,"=")!=0)return 1;break;}case'l':{ -const char*filename=argv[i]+2;if(*filename=='\0')filename=argv[++i];if( -filename==NULL){print_usage();return 1;}if(load_file(filename))return 1;break; -}case'c':{l_message(progname,"option `-c' is deprecated");break;}case's':{ -l_message(progname,"option `-s' is deprecated");break;}default:{print_usage(); -return 1;}}}endloop:if(argv[i]!=NULL){const char*filename=argv[i];getargs(argv -,i);lua_setglobal(L,"arg");if(strcmp(filename,"/dev/stdin")==0)filename=NULL; -return file_input(filename);}}return 0;}static void openstdlibs(lua_State*l){ -const luaL_reg*lib=lualibs;for(;lib->func;lib++){lib->func(l);lua_settop(l,0); -}}static int handle_luainit(void){const char*init=getenv("LUA_INIT");if(init== -NULL)return 0;else if(init[0]=='@')return file_input(init+1);else return -dostring(init,"=LUA_INIT");}struct Smain{int argc;char**argv;int status;}; -static int pmain(lua_State*l){struct Smain*s=(struct Smain*)lua_touserdata(l,1 -);int status;int interactive=0;if(s->argv[0]&&s->argv[0][0])progname=s->argv[0 -];L=l;lua_userinit(l);status=handle_luainit();if(status==0){status=handle_argv -(s->argv,&interactive);if(status==0&&interactive)manual_input();}s->status= -status;return 0;}int main(int argc,char*argv[]){int status;struct Smain s; -lua_State*l=lua_open();if(l==NULL){l_message(argv[0], -"cannot create state: not enough memory");return EXIT_FAILURE;}s.argc=argc;s. -argv=argv;status=lua_cpcall(l,&pmain,&s);report(status);lua_close(l);return( -status||s.status)?EXIT_FAILURE:EXIT_SUCCESS;} -#line 1 "lundump.c" -#define lundump_c -#define LoadByte (lu_byte)ezgetc -typedef struct{lua_State*L;ZIO*Z;Mbuffer*b;int swap;const char*name;}LoadState -;static void unexpectedEOZ(LoadState*S){luaG_runerror(S->L, -"unexpected end of file in %s",S->name);}static int ezgetc(LoadState*S){int c= -zgetc(S->Z);if(c==EOZ)unexpectedEOZ(S);return c;}static void ezread(LoadState* -S,void*b,int n){int r=luaZ_read(S->Z,b,n);if(r!=0)unexpectedEOZ(S);}static -void LoadBlock(LoadState*S,void*b,size_t size){if(S->swap){char*p=(char*)b+ -size-1;int n=size;while(n--)*p--=(char)ezgetc(S);}else ezread(S,b,size);} -static void LoadVector(LoadState*S,void*b,int m,size_t size){if(S->swap){char* -q=(char*)b;while(m--){char*p=q+size-1;int n=size;while(n--)*p--=(char)ezgetc(S -);q+=size;}}else ezread(S,b,m*size);}static int LoadInt(LoadState*S){int x; -LoadBlock(S,&x,sizeof(x));if(x<0)luaG_runerror(S->L,"bad integer in %s",S-> -name);return x;}static size_t LoadSize(LoadState*S){size_t x;LoadBlock(S,&x, -sizeof(x));return x;}static lua_Number LoadNumber(LoadState*S){lua_Number x; -LoadBlock(S,&x,sizeof(x));return x;}static TString*LoadString(LoadState*S){ -size_t size=LoadSize(S);if(size==0)return NULL;else{char*s=luaZ_openspace(S->L -,S->b,size);ezread(S,s,size);return luaS_newlstr(S->L,s,size-1);}}static void -LoadCode(LoadState*S,Proto*f){int size=LoadInt(S);f->code=luaM_newvector(S->L, -size,Instruction);f->sizecode=size;LoadVector(S,f->code,size,sizeof(*f->code)) -;}static void LoadLocals(LoadState*S,Proto*f){int i,n;n=LoadInt(S);f->locvars= -luaM_newvector(S->L,n,LocVar);f->sizelocvars=n;for(i=0;ilocvars[i]. -varname=LoadString(S);f->locvars[i].startpc=LoadInt(S);f->locvars[i].endpc= -LoadInt(S);}}static void LoadLines(LoadState*S,Proto*f){int size=LoadInt(S);f -->lineinfo=luaM_newvector(S->L,size,int);f->sizelineinfo=size;LoadVector(S,f-> -lineinfo,size,sizeof(*f->lineinfo));}static void LoadUpvalues(LoadState*S, -Proto*f){int i,n;n=LoadInt(S);if(n!=0&&n!=f->nups)luaG_runerror(S->L, -"bad nupvalues in %s: read %d; expected %d",S->name,n,f->nups);f->upvalues= -luaM_newvector(S->L,n,TString*);f->sizeupvalues=n;for(i=0;iupvalues[ -i]=LoadString(S);}static Proto*LoadFunction(LoadState*S,TString*p);static void - LoadConstants(LoadState*S,Proto*f){int i,n;n=LoadInt(S);f->k=luaM_newvector(S -->L,n,TObject);f->sizek=n;for(i=0;ik[i];int t=LoadByte(S -);switch(t){case LUA_TNUMBER:setnvalue(o,LoadNumber(S));break;case LUA_TSTRING -:setsvalue2n(o,LoadString(S));break;case LUA_TNIL:setnilvalue(o);break;default -:luaG_runerror(S->L,"bad constant type (%d) in %s",t,S->name);break;}}n= -LoadInt(S);f->p=luaM_newvector(S->L,n,Proto*);f->sizep=n;for(i=0;ip[ -i]=LoadFunction(S,f->source);}static Proto*LoadFunction(LoadState*S,TString*p) -{Proto*f=luaF_newproto(S->L);f->source=LoadString(S);if(f->source==NULL)f-> -source=p;f->lineDefined=LoadInt(S);f->nups=LoadByte(S);f->numparams=LoadByte(S -);f->is_vararg=LoadByte(S);f->maxstacksize=LoadByte(S);LoadLines(S,f); -LoadLocals(S,f);LoadUpvalues(S,f);LoadConstants(S,f);LoadCode(S,f); -#ifndef TRUST_BINARIES -if(!luaG_checkcode(f))luaG_runerror(S->L,"bad code in %s",S->name); -#endif -return f;}static void LoadSignature(LoadState*S){const char*s=LUA_SIGNATURE; -while(*s!=0&&ezgetc(S)==*s)++s;if(*s!=0)luaG_runerror(S->L, -"bad signature in %s",S->name);}static void TestSize(LoadState*S,int s,const -char*what){int r=LoadByte(S);if(r!=s)luaG_runerror(S->L, -"virtual machine mismatch in %s: ""size of %s is %d but read %d",S->name,what, -s,r);} -#define TESTSIZE(s,w) TestSize(S,s,w) -#define V(v) v/16,v%16 -static void LoadHeader(LoadState*S){int version;lua_Number x,tx=TEST_NUMBER; -LoadSignature(S);version=LoadByte(S);if(version>VERSION)luaG_runerror(S->L, -"%s too new: ""read version %d.%d; expected at most %d.%d",S->name,V(version), -V(VERSION));if(versionL,"%s too old: " -"read version %d.%d; expected at least %d.%d",S->name,V(version),V(VERSION0)); -S->swap=(luaU_endianness()!=LoadByte(S));TESTSIZE(sizeof(int),"int");TESTSIZE( -sizeof(size_t),"size_t");TESTSIZE(sizeof(Instruction),"Instruction");TESTSIZE( -SIZE_OP,"OP");TESTSIZE(SIZE_A,"A");TESTSIZE(SIZE_B,"B");TESTSIZE(SIZE_C,"C"); -TESTSIZE(sizeof(lua_Number),"number");x=LoadNumber(S);if((long)x!=(long)tx) -luaG_runerror(S->L,"unknown number format in %s",S->name);}static Proto* -LoadChunk(LoadState*S){LoadHeader(S);return LoadFunction(S,NULL);}Proto* -luaU_undump(lua_State*L,ZIO*Z,Mbuffer*buff){LoadState S;const char*s=zname(Z); -if(*s=='@'||*s=='=')S.name=s+1;else if(*s==LUA_SIGNATURE[0])S.name= -"binary string";else S.name=s;S.L=L;S.Z=Z;S.b=buff;return LoadChunk(&S);}int -luaU_endianness(void){int x=1;return*(char*)&x;} -#line 1 "lvm.c" -#define lvm_c -#ifndef lua_number2str -#define lua_number2str(s,n) sprintf((s),LUA_NUMBER_FMT,(n)) -#endif -#define MAXTAGLOOP 100 -const TObject*luaV_tonumber(const TObject*obj,TObject*n){lua_Number num;if( -ttisnumber(obj))return obj;if(ttisstring(obj)&&luaO_str2d(svalue(obj),&num)){ -setnvalue(n,num);return n;}else return NULL;}int luaV_tostring(lua_State*L, -StkId obj){if(!ttisnumber(obj))return 0;else{char s[32];lua_number2str(s, -nvalue(obj));setsvalue2s(obj,luaS_new(L,s));return 1;}}static void traceexec( -lua_State*L){lu_byte mask=L->hookmask;if(mask&LUA_MASKCOUNT){if(L->hookcount== -0){resethookcount(L);luaD_callhook(L,LUA_HOOKCOUNT,-1);return;}}if(mask& -LUA_MASKLINE){CallInfo*ci=L->ci;Proto*p=ci_func(ci)->l.p;int newline=getline(p -,pcRel(*ci->u.l.pc,p));if(!L->hookinit){luaG_inithooks(L);return;}lua_assert( -ci->state&CI_HASFRAME);if(pcRel(*ci->u.l.pc,p)==0)ci->u.l.savedpc=*ci->u.l.pc; -if(*ci->u.l.pc<=ci->u.l.savedpc||newline!=getline(p,pcRel(ci->u.l.savedpc,p))) -{luaD_callhook(L,LUA_HOOKLINE,newline);ci=L->ci;}ci->u.l.savedpc=*ci->u.l.pc;} -}static void callTMres(lua_State*L,const TObject*f,const TObject*p1,const -TObject*p2){setobj2s(L->top,f);setobj2s(L->top+1,p1);setobj2s(L->top+2,p2); -luaD_checkstack(L,3);L->top+=3;luaD_call(L,L->top-3,1);L->top--;}static void -callTM(lua_State*L,const TObject*f,const TObject*p1,const TObject*p2,const -TObject*p3){setobj2s(L->top,f);setobj2s(L->top+1,p1);setobj2s(L->top+2,p2); -setobj2s(L->top+3,p3);luaD_checkstack(L,4);L->top+=4;luaD_call(L,L->top-4,0);} -static const TObject*luaV_index(lua_State*L,const TObject*t,TObject*key,int -loop){const TObject*tm=fasttm(L,hvalue(t)->metatable,TM_INDEX);if(tm==NULL) -return&luaO_nilobject;if(ttisfunction(tm)){callTMres(L,tm,t,key);return L->top -;}else return luaV_gettable(L,tm,key,loop);}static const TObject* -luaV_getnotable(lua_State*L,const TObject*t,TObject*key,int loop){const -TObject*tm=luaT_gettmbyobj(L,t,TM_INDEX);if(ttisnil(tm))luaG_typeerror(L,t, -"index");if(ttisfunction(tm)){callTMres(L,tm,t,key);return L->top;}else return - luaV_gettable(L,tm,key,loop);}const TObject*luaV_gettable(lua_State*L,const -TObject*t,TObject*key,int loop){if(loop>MAXTAGLOOP)luaG_runerror(L, -"loop in gettable");if(ttistable(t)){Table*h=hvalue(t);const TObject*v= -luaH_get(h,key);if(!ttisnil(v))return v;else return luaV_index(L,t,key,loop+1) -;}else return luaV_getnotable(L,t,key,loop+1);}void luaV_settable(lua_State*L, -const TObject*t,TObject*key,StkId val){const TObject*tm;int loop=0;do{if( -ttistable(t)){Table*h=hvalue(t);TObject*oldval=luaH_set(L,h,key);if(!ttisnil( -oldval)||(tm=fasttm(L,h->metatable,TM_NEWINDEX))==NULL){setobj2t(oldval,val); -return;}}else if(ttisnil(tm=luaT_gettmbyobj(L,t,TM_NEWINDEX)))luaG_typeerror(L -,t,"index");if(ttisfunction(tm)){callTM(L,tm,t,key,val);return;}t=tm;}while(++ -loop<=MAXTAGLOOP);luaG_runerror(L,"loop in settable");}static int call_binTM( -lua_State*L,const TObject*p1,const TObject*p2,StkId res,TMS event){ptrdiff_t -result=savestack(L,res);const TObject*tm=luaT_gettmbyobj(L,p1,event);if( -ttisnil(tm))tm=luaT_gettmbyobj(L,p2,event);if(!ttisfunction(tm))return 0; -callTMres(L,tm,p1,p2);res=restorestack(L,result);setobjs2s(res,L->top);return -1;}static const TObject*get_compTM(lua_State*L,Table*mt1,Table*mt2,TMS event){ -const TObject*tm1=fasttm(L,mt1,event);const TObject*tm2;if(tm1==NULL)return -NULL;if(mt1==mt2)return tm1;tm2=fasttm(L,mt2,event);if(tm2==NULL)return NULL; -if(luaO_rawequalObj(tm1,tm2))return tm1;return NULL;}static int call_orderTM( -lua_State*L,const TObject*p1,const TObject*p2,TMS event){const TObject*tm1= -luaT_gettmbyobj(L,p1,event);const TObject*tm2;if(ttisnil(tm1))return-1;tm2= -luaT_gettmbyobj(L,p2,event);if(!luaO_rawequalObj(tm1,tm2))return-1;callTMres(L -,tm1,p1,p2);return!l_isfalse(L->top);}static int luaV_strcmp(const TString*ls, -const TString*rs){const char*l=getstr(ls);size_t ll=ls->tsv.len;const char*r= -getstr(rs);size_t lr=rs->tsv.len;for(;;){int temp=strcoll(l,r);if(temp!=0) -return temp;else{size_t len=strlen(l);if(len==lr)return(len==ll)?0:1;else if( -len==ll)return-1;len++;l+=len;ll-=len;r+=len;lr-=len;}}}int luaV_lessthan( -lua_State*L,const TObject*l,const TObject*r){int res;if(ttype(l)!=ttype(r)) -return luaG_ordererror(L,l,r);else if(ttisnumber(l))return nvalue(l)uv.metatable,uvalue(t2)->uv.metatable,TM_EQ);break;} -case LUA_TTABLE:{if(hvalue(t1)==hvalue(t2))return 1;tm=get_compTM(L,hvalue(t1) -->metatable,hvalue(t2)->metatable,TM_EQ);break;}default:return gcvalue(t1)== -gcvalue(t2);}if(tm==NULL)return 0;callTMres(L,tm,t1,t2);return!l_isfalse(L-> -top);}void luaV_concat(lua_State*L,int total,int last){do{StkId top=L->base+ -last+1;int n=2;if(!tostring(L,top-2)||!tostring(L,top-1)){if(!call_binTM(L,top --2,top-1,top-2,TM_CONCAT))luaG_concaterror(L,top-2,top-1);}else if(tsvalue(top --1)->tsv.len>0){lu_mem tl=cast(lu_mem,tsvalue(top-1)->tsv.len)+cast(lu_mem, -tsvalue(top-2)->tsv.len);char*buffer;int i;while(ntsv.len;n++;}if(tl>MAX_SIZET)luaG_runerror(L, -"string size overflow");buffer=luaZ_openspace(L,&G(L)->buff,tl);tl=0;for(i=n;i ->0;i--){size_t l=tsvalue(top-i)->tsv.len;memcpy(buffer+tl,svalue(top-i),l);tl -+=l;}setsvalue2s(top-n,luaS_newlstr(L,buffer,tl));}total-=n-1;last-=n-1;}while -(total>1);}static void Arith(lua_State*L,StkId ra,const TObject*rb,const -TObject*rc,TMS op){TObject tempb,tempc;const TObject*b,*c;if((b=luaV_tonumber( -rb,&tempb))!=NULL&&(c=luaV_tonumber(rc,&tempc))!=NULL){switch(op){case TM_ADD: -setnvalue(ra,nvalue(b)+nvalue(c));break;case TM_SUB:setnvalue(ra,nvalue(b)- -nvalue(c));break;case TM_MUL:setnvalue(ra,nvalue(b)*nvalue(c));break;case -TM_DIV:setnvalue(ra,nvalue(b)/nvalue(c));break;case TM_POW:{const TObject*f= -luaH_getstr(hvalue(gt(L)),G(L)->tmname[TM_POW]);ptrdiff_t res=savestack(L,ra); -if(!ttisfunction(f))luaG_runerror(L,"`__pow' (`^' operator) is not a function" -);callTMres(L,f,b,c);ra=restorestack(L,res);setobjs2s(ra,L->top);break;} -default:lua_assert(0);break;}}else if(!call_binTM(L,rb,rc,ra,op)) -luaG_aritherror(L,rb,rc);} -#define runtime_check(L, c){if(!(c))return 0;} -#define RA(i) (base+GETARG_A(i)) -#define XRA(i) (L->base+GETARG_A(i)) -#define RB(i) (base+GETARG_B(i)) -#define RKB(i) ((GETARG_B(i)hookmask&LUA_MASKCALL){L->ci->u.l.pc=&pc;luaD_callhook(L, -LUA_HOOKCALL,-1);}retentry:L->ci->u.l.pc=&pc;lua_assert(L->ci->state== -CI_SAVEDPC||L->ci->state==(CI_SAVEDPC|CI_CALLING));L->ci->state=CI_HASFRAME;pc -=L->ci->u.l.savedpc;cl=&clvalue(L->base-1)->l;k=cl->p->k;for(;;){const -Instruction i=*pc++;StkId base,ra;if((L->hookmask&(LUA_MASKLINE|LUA_MASKCOUNT) -)&&(--L->hookcount==0||L->hookmask&LUA_MASKLINE)){traceexec(L);if(L->ci->state -&CI_YIELD){L->ci->u.l.savedpc=pc-1;L->ci->state=CI_YIELD|CI_SAVEDPC;return -NULL;}}base=L->base;ra=RA(i);lua_assert(L->ci->state&CI_HASFRAME);lua_assert( -base==L->ci->base);lua_assert(L->top<=L->stack+L->stacksize&&L->top>=base); -lua_assert(L->top==L->ci->top||GET_OPCODE(i)==OP_CALL||GET_OPCODE(i)== -OP_TAILCALL||GET_OPCODE(i)==OP_RETURN||GET_OPCODE(i)==OP_SETLISTO);switch( -GET_OPCODE(i)){case OP_MOVE:{setobjs2s(ra,RB(i));break;}case OP_LOADK:{ -setobj2s(ra,KBx(i));break;}case OP_LOADBOOL:{setbvalue(ra,GETARG_B(i));if( -GETARG_C(i))pc++;break;}case OP_LOADNIL:{TObject*rb=RB(i);do{setnilvalue(rb--) -;}while(rb>=ra);break;}case OP_GETUPVAL:{int b=GETARG_B(i);setobj2s(ra,cl-> -upvals[b]->v);break;}case OP_GETGLOBAL:{TObject*rb=KBx(i);const TObject*v; -lua_assert(ttisstring(rb)&&ttistable(&cl->g));v=luaH_getstr(hvalue(&cl->g), -tsvalue(rb));if(!ttisnil(v)){setobj2s(ra,v);}else setobj2s(XRA(i),luaV_index(L -,&cl->g,rb,0));break;}case OP_GETTABLE:{StkId rb=RB(i);TObject*rc=RKC(i);if( -ttistable(rb)){const TObject*v=luaH_get(hvalue(rb),rc);if(!ttisnil(v)){ -setobj2s(ra,v);}else setobj2s(XRA(i),luaV_index(L,rb,rc,0));}else setobj2s(XRA -(i),luaV_getnotable(L,rb,rc,0));break;}case OP_SETGLOBAL:{lua_assert( -ttisstring(KBx(i))&&ttistable(&cl->g));luaV_settable(L,&cl->g,KBx(i),ra);break -;}case OP_SETUPVAL:{int b=GETARG_B(i);setobj(cl->upvals[b]->v,ra);break;}case -OP_SETTABLE:{luaV_settable(L,ra,RKB(i),RKC(i));break;}case OP_NEWTABLE:{int b= -GETARG_B(i);b=fb2int(b);sethvalue(ra,luaH_new(L,b,GETARG_C(i)));luaC_checkGC(L -);break;}case OP_SELF:{StkId rb=RB(i);TObject*rc=RKC(i);runtime_check(L, -ttisstring(rc));setobjs2s(ra+1,rb);if(ttistable(rb)){const TObject*v= -luaH_getstr(hvalue(rb),tsvalue(rc));if(!ttisnil(v)){setobj2s(ra,v);}else -setobj2s(XRA(i),luaV_index(L,rb,rc,0));}else setobj2s(XRA(i),luaV_getnotable(L -,rb,rc,0));break;}case OP_ADD:{TObject*rb=RKB(i);TObject*rc=RKC(i);if( -ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)+nvalue(rc));}else -Arith(L,ra,rb,rc,TM_ADD);break;}case OP_SUB:{TObject*rb=RKB(i);TObject*rc=RKC( -i);if(ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)-nvalue(rc));} -else Arith(L,ra,rb,rc,TM_SUB);break;}case OP_MUL:{TObject*rb=RKB(i);TObject*rc -=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)*nvalue(rc)) -;}else Arith(L,ra,rb,rc,TM_MUL);break;}case OP_DIV:{TObject*rb=RKB(i);TObject* -rc=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)/nvalue(rc -));}else Arith(L,ra,rb,rc,TM_DIV);break;}case OP_POW:{Arith(L,ra,RKB(i),RKC(i) -,TM_POW);break;}case OP_UNM:{const TObject*rb=RB(i);TObject temp;if(tonumber( -rb,&temp)){setnvalue(ra,-nvalue(rb));}else{setnilvalue(&temp);if(!call_binTM(L -,RB(i),&temp,ra,TM_UNM))luaG_aritherror(L,RB(i),&temp);}break;}case OP_NOT:{ -int res=l_isfalse(RB(i));setbvalue(ra,res);break;}case OP_CONCAT:{int b= -GETARG_B(i);int c=GETARG_C(i);luaV_concat(L,c-b+1,c);base=L->base;setobjs2s(RA -(i),base+b);luaC_checkGC(L);break;}case OP_JMP:{dojump(pc,GETARG_sBx(i));break -;}case OP_EQ:{if(equalobj(L,RKB(i),RKC(i))!=GETARG_A(i))pc++;else dojump(pc, -GETARG_sBx(*pc)+1);break;}case OP_LT:{if(luaV_lessthan(L,RKB(i),RKC(i))!= -GETARG_A(i))pc++;else dojump(pc,GETARG_sBx(*pc)+1);break;}case OP_LE:{if( -luaV_lessequal(L,RKB(i),RKC(i))!=GETARG_A(i))pc++;else dojump(pc,GETARG_sBx(* -pc)+1);break;}case OP_TEST:{TObject*rb=RB(i);if(l_isfalse(rb)==GETARG_C(i))pc -++;else{setobjs2s(ra,rb);dojump(pc,GETARG_sBx(*pc)+1);}break;}case OP_CALL: -case OP_TAILCALL:{StkId firstResult;int b=GETARG_B(i);int nresults;if(b!=0)L-> -top=ra+b;nresults=GETARG_C(i)-1;firstResult=luaD_precall(L,ra);if(firstResult) -{if(firstResult>L->top){lua_assert(L->ci->state==(CI_C|CI_YIELD));(L->ci-1)->u -.l.savedpc=pc;(L->ci-1)->state=CI_SAVEDPC;return NULL;}luaD_poscall(L,nresults -,firstResult);if(nresults>=0)L->top=L->ci->top;}else{if(GET_OPCODE(i)==OP_CALL -){(L->ci-1)->u.l.savedpc=pc;(L->ci-1)->state=(CI_SAVEDPC|CI_CALLING);}else{int - aux;base=(L->ci-1)->base;ra=RA(i);if(L->openupval)luaF_close(L,base);for(aux= -0;ra+auxtop;aux++)setobjs2s(base+aux-1,ra+aux);(L->ci-1)->top=L->top=base+ -aux;lua_assert(L->ci->state&CI_SAVEDPC);(L->ci-1)->u.l.savedpc=L->ci->u.l. -savedpc;(L->ci-1)->u.l.tailcalls++;(L->ci-1)->state=CI_SAVEDPC;L->ci--;L->base -=L->ci->base;}goto callentry;}break;}case OP_RETURN:{CallInfo*ci=L->ci-1;int b -=GETARG_B(i);if(b!=0)L->top=ra+b-1;lua_assert(L->ci->state&CI_HASFRAME);if(L-> -openupval)luaF_close(L,base);L->ci->state=CI_SAVEDPC;L->ci->u.l.savedpc=pc;if( -!(ci->state&CI_CALLING)){lua_assert((ci->state&CI_C)||ci->u.l.pc!=&pc);return -ra;}else{int nresults;lua_assert(ttisfunction(ci->base-1)&&(ci->state& -CI_SAVEDPC));lua_assert(GET_OPCODE(*(ci->u.l.savedpc-1))==OP_CALL);nresults= -GETARG_C(*(ci->u.l.savedpc-1))-1;luaD_poscall(L,nresults,ra);if(nresults>=0)L -->top=L->ci->top;goto retentry;}}case OP_FORLOOP:{lua_Number step,idx,limit; -const TObject*plimit=ra+1;const TObject*pstep=ra+2;if(!ttisnumber(ra)) -luaG_runerror(L,"`for' initial value must be a number");if(!tonumber(plimit,ra -+1))luaG_runerror(L,"`for' limit must be a number");if(!tonumber(pstep,ra+2)) -luaG_runerror(L,"`for' step must be a number");step=nvalue(pstep);idx=nvalue( -ra)+step;limit=nvalue(plimit);if(step>0?idx<=limit:idx>=limit){dojump(pc, -GETARG_sBx(i));chgnvalue(ra,idx);}break;}case OP_TFORLOOP:{int nvar=GETARG_C(i -)+1;StkId cb=ra+nvar+2;setobjs2s(cb,ra);setobjs2s(cb+1,ra+1);setobjs2s(cb+2,ra -+2);L->top=cb+3;luaD_call(L,cb,nvar);L->top=L->ci->top;ra=XRA(i)+2;cb=ra+nvar; -do{nvar--;setobjs2s(ra+nvar,cb+nvar);}while(nvar>0);if(ttisnil(ra))pc++;else -dojump(pc,GETARG_sBx(*pc)+1);break;}case OP_TFORPREP:{if(ttistable(ra)){ -setobjs2s(ra+1,ra);setobj2s(ra,luaH_getstr(hvalue(gt(L)),luaS_new(L,"next"))); -}dojump(pc,GETARG_sBx(i));break;}case OP_SETLIST:case OP_SETLISTO:{int bc;int -n;Table*h;runtime_check(L,ttistable(ra));h=hvalue(ra);bc=GETARG_Bx(i);if( -GET_OPCODE(i)==OP_SETLIST)n=(bc&(LFIELDS_PER_FLUSH-1))+1;else{n=L->top-ra-1;L -->top=L->ci->top;}bc&=~(LFIELDS_PER_FLUSH-1);for(;n>0;n--)setobj2t(luaH_setnum -(L,h,bc+n),ra+n);break;}case OP_CLOSE:{luaF_close(L,ra);break;}case OP_CLOSURE -:{Proto*p;Closure*ncl;int nup,j;p=cl->p->p[GETARG_Bx(i)];nup=p->nups;ncl= -luaF_newLclosure(L,nup,&cl->g);ncl->l.p=p;for(j=0;jl.upvals[j]=cl->upvals[GETARG_B(*pc)];else{ -lua_assert(GET_OPCODE(*pc)==OP_MOVE);ncl->l.upvals[j]=luaF_findupval(L,base+ -GETARG_B(*pc));}}setclvalue(ra,ncl);luaC_checkGC(L);break;}}}} -#line 1 "lzio.c" -#define lzio_c -int luaZ_fill(ZIO*z){size_t size;const char*buff=z->reader(NULL,z->data,&size) -;if(buff==NULL||size==0)return EOZ;z->n=size-1;z->p=buff;return char2int(*(z-> -p++));}int luaZ_lookahead(ZIO*z){if(z->n==0){int c=luaZ_fill(z);if(c==EOZ) -return c;z->n++;z->p--;}return char2int(*z->p);}void luaZ_init(ZIO*z, -lua_Chunkreader reader,void*data,const char*name){z->reader=reader;z->data= -data;z->name=name;z->n=0;z->p=NULL;}size_t luaZ_read(ZIO*z,void*b,size_t n){ -while(n){size_t m;if(z->n==0){if(luaZ_fill(z)==EOZ)return n;else{++z->n;--z->p -;}}m=(n<=z->n)?n:z->n;memcpy(b,z->p,m);z->n-=m;z->p+=m;b=(char*)b+m;n-=m;} -return 0;}char*luaZ_openspace(lua_State*L,Mbuffer*buff,size_t n){if(n>buff-> -buffsize){if(nbuffer -,buff->buffsize,n,char);buff->buffsize=n;}return buff->buffer;} - From 11377070fda2f3b3d8b5b28561993c33c5c46ab1 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 15 May 2013 23:46:15 +0100 Subject: [PATCH 015/231] Update distribution files. --HG-- branch : dtrg-buildsystem --- .distr | 14 ++++++++------ distr/mkdist | 2 +- first/.distr | 7 +------ lang/basic/.distr | 2 +- lang/basic/lib/.distr | 2 +- lang/basic/src/.distr | 2 +- lang/cem/.distr | 2 +- lang/cem/cemcom.ansi/.distr | 2 +- lang/cem/cemcom/.distr | 2 +- lang/cem/cpp.ansi/.distr | 5 ++--- lang/cem/libcc.ansi/.distr | 2 +- lang/cem/libcc/.distr | 2 +- lang/cem/libcc/gen/.distr | 2 +- lang/cem/libcc/math/.distr | 2 +- lang/cem/libcc/mon/.distr | 2 +- lang/cem/libcc/stdio/.distr | 2 +- lang/m2/.distr | 2 +- lang/m2/comp/.distr | 2 +- lang/m2/libm2/.distr | 2 +- lang/occam/.distr | 2 +- lang/occam/comp/.distr | 2 +- lang/occam/lib/.distr | 2 +- lang/pc/.distr | 2 +- lang/pc/comp/.distr | 2 +- lang/pc/libpc/.distr | 2 +- mach/i386/.distr | 2 +- mach/i386/libem/.distr | 1 - mach/i386/libend/.distr | 1 - mach/i80/.distr | 2 +- mach/i80/libem/.distr | 1 - mach/i80/libend/.distr | 1 - mach/i86/.distr | 2 +- mach/i86/libem/.distr | 1 - mach/i86/libend/.distr | 1 - mach/m68020/.distr | 11 ++--------- mach/m68020/libem/.distr | 31 ++++++++++++++++++++++++++++++- mach/m68020/libend/.distr | 6 ++++-- mach/powerpc/libend/.distr | 2 +- mach/proto/.distr | 1 - mach/proto/as/.distr | 2 +- mach/proto/cg/.distr | 1 - mach/proto/ncg/.distr | 2 +- mach/proto/top/.distr | 2 +- modules/src/alloc/.distr | 2 +- modules/src/assert/.distr | 1 - modules/src/em_code/.distr | 2 +- modules/src/em_mes/.distr | 2 +- modules/src/flt_arith/.distr | 2 +- modules/src/idf/.distr | 2 +- modules/src/input/.distr | 2 +- modules/src/object/.distr | 2 +- modules/src/print/.distr | 2 +- modules/src/read_em/.distr | 2 +- modules/src/string/.distr | 2 +- modules/src/system/.distr | 2 +- plat/.distr | 2 ++ plat/cpm/.distr | 3 +-- plat/linux/.distr | 2 ++ plat/linux/liblinux/.distr | 20 ++++++++++++++++++++ plat/linux386/.distr | 22 ++-------------------- plat/linux68k/.distr | 22 ++-------------------- plat/linuxppc/.distr | 4 ++-- plat/pc86/.distr | 3 +-- util/LLgen/.distr | 2 +- util/ack/.distr | 2 +- util/amisc/.distr | 2 +- util/arch/.distr | 2 +- util/cgg/.distr | 1 - util/cmisc/.distr | 2 +- util/cpp/.distr | 2 +- util/data/.distr | 2 +- util/ego/.distr | 2 +- util/led/.distr | 2 +- util/misc/.distr | 2 +- util/ncgg/.distr | 2 +- util/opt/.distr | 2 +- util/topgen/.distr | 2 +- 77 files changed, 132 insertions(+), 136 deletions(-) create mode 100644 plat/.distr create mode 100644 plat/linux/.distr create mode 100644 plat/linux/liblinux/.distr diff --git a/.distr b/.distr index 971a46554..dbe964f93 100644 --- a/.distr +++ b/.distr @@ -1,9 +1,7 @@ README CHANGES Copyright -pm -pmfile -config.pm +Makefile h modules/h @@ -13,7 +11,7 @@ util/data util/LLgen modules/src/alloc -modules/src/assert +#modules/src/assert modules/src/system modules/src/string modules/src/read_em @@ -31,7 +29,7 @@ util/ack lib/descr/fe util/arch #util/cpp -util/cgg +#util/cgg util/ncgg util/misc util/opt @@ -43,15 +41,19 @@ lang/cem lang/pc lang/m2 #lang/occam -#lang/basic +lang/basic mach/proto mach/i80 mach/i86 mach/i386 +mach/m68020 +plat plat/cpm plat/pc86 +plat/linux plat/linux386 +plat/linux68k examples diff --git a/distr/mkdist b/distr/mkdist index 2e2653430..8366d69fb 100755 --- a/distr/mkdist +++ b/distr/mkdist @@ -143,7 +143,7 @@ echo "" if [ -e $destdir ]; then if [ "$delete" = "yes" ]; then echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort." - read + read _ _ echo "Erasing..." rm -rf "$destdir" else diff --git a/first/.distr b/first/.distr index 8bff7f59c..e8f7adb1e 100644 --- a/first/.distr +++ b/first/.distr @@ -1,9 +1,4 @@ -ack.pm -ack-custom.pm -c.pm -llgen.pm -yacc.pm - +core.mk #create_dir #cp_dir #em_path.h.src diff --git a/lang/basic/.distr b/lang/basic/.distr index 8b025617a..c01dd4ce8 100644 --- a/lang/basic/.distr +++ b/lang/basic/.distr @@ -1,3 +1,3 @@ -pmfile +build.mk src lib diff --git a/lang/basic/lib/.distr b/lang/basic/lib/.distr index 4e51a9787..958e508d9 100644 --- a/lang/basic/lib/.distr +++ b/lang/basic/lib/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk abs.c asc.c asrt.c diff --git a/lang/basic/src/.distr b/lang/basic/src/.distr index 053feca94..0056c149f 100644 --- a/lang/basic/src/.distr +++ b/lang/basic/src/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk basic.g basic.lex bem.c diff --git a/lang/cem/.distr b/lang/cem/.distr index b4ca36155..21f8f8d1b 100644 --- a/lang/cem/.distr +++ b/lang/cem/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk cemcom.ansi cpp.ansi libcc.ansi diff --git a/lang/cem/cemcom.ansi/.distr b/lang/cem/cemcom.ansi/.distr index 2ea332861..13a214f16 100644 --- a/lang/cem/cemcom.ansi/.distr +++ b/lang/cem/cemcom.ansi/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk LLlex.c LLlex.h LLmessage.c diff --git a/lang/cem/cemcom/.distr b/lang/cem/cemcom/.distr index eee6d8f13..cde313abc 100644 --- a/lang/cem/cemcom/.distr +++ b/lang/cem/cemcom/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk LLlex.c LLlex.h LLmessage.c diff --git a/lang/cem/cpp.ansi/.distr b/lang/cem/cpp.ansi/.distr index 28ed84cb2..e858a9344 100644 --- a/lang/cem/cpp.ansi/.distr +++ b/lang/cem/cpp.ansi/.distr @@ -1,8 +1,8 @@ -pmfile +build.mk LLlex.c LLlex.h LLmessage.c -Parameters +parameters.h arith.h bits.h ch3bin.c @@ -22,7 +22,6 @@ input.h macro.str main.c make.allocd -make.hfiles make.next make.tokcase make.tokfile diff --git a/lang/cem/libcc.ansi/.distr b/lang/cem/libcc.ansi/.distr index 65f515e93..cc07e6720 100644 --- a/lang/cem/libcc.ansi/.distr +++ b/lang/cem/libcc.ansi/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk head_ac.e assert ctype diff --git a/lang/cem/libcc/.distr b/lang/cem/libcc/.distr index 9412e8f87..dea372b8f 100644 --- a/lang/cem/libcc/.distr +++ b/lang/cem/libcc/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk gen headers math diff --git a/lang/cem/libcc/gen/.distr b/lang/cem/libcc/gen/.distr index a4b83bb42..b834f7890 100644 --- a/lang/cem/libcc/gen/.distr +++ b/lang/cem/libcc/gen/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk head_cc.e abs.c atof.c diff --git a/lang/cem/libcc/math/.distr b/lang/cem/libcc/math/.distr index a6b3b1220..e9ee68785 100644 --- a/lang/cem/libcc/math/.distr +++ b/lang/cem/libcc/math/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk asin.c atan2.c atan.c diff --git a/lang/cem/libcc/mon/.distr b/lang/cem/libcc/mon/.distr index 0ec396a35..7312104df 100644 --- a/lang/cem/libcc/mon/.distr +++ b/lang/cem/libcc/mon/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk exit.c gtty.c signal.c diff --git a/lang/cem/libcc/stdio/.distr b/lang/cem/libcc/stdio/.distr index 728de5ee2..fceca8663 100644 --- a/lang/cem/libcc/stdio/.distr +++ b/lang/cem/libcc/stdio/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk vsprintf.c vfprintf.c vprintf.c diff --git a/lang/m2/.distr b/lang/m2/.distr index 9ed8b06d4..ef717ff3c 100644 --- a/lang/m2/.distr +++ b/lang/m2/.distr @@ -1,3 +1,3 @@ -pmfile +build.mk comp libm2 diff --git a/lang/m2/comp/.distr b/lang/m2/comp/.distr index 1ea799dbd..bae10e61a 100644 --- a/lang/m2/comp/.distr +++ b/lang/m2/comp/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk LLlex.c LLlex.h LLmessage.c diff --git a/lang/m2/libm2/.distr b/lang/m2/libm2/.distr index 2cbf40d17..f7df21a12 100644 --- a/lang/m2/libm2/.distr +++ b/lang/m2/libm2/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk Termcap.mod CSP.mod PascalIO.mod diff --git a/lang/occam/.distr b/lang/occam/.distr index 475b9ed71..216c0a94d 100644 --- a/lang/occam/.distr +++ b/lang/occam/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk comp lib test diff --git a/lang/occam/comp/.distr b/lang/occam/comp/.distr index d220a92fb..d5cc91854 100644 --- a/lang/occam/comp/.distr +++ b/lang/occam/comp/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk builtin.c code.c code.h diff --git a/lang/occam/lib/.distr b/lang/occam/lib/.distr index 1f306717f..b5d4c6d50 100644 --- a/lang/occam/lib/.distr +++ b/lang/occam/lib/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk builtin.c chan_strct.c channel.c diff --git a/lang/pc/.distr b/lang/pc/.distr index cbd3fb167..8de02b7d5 100644 --- a/lang/pc/.distr +++ b/lang/pc/.distr @@ -1,3 +1,3 @@ -pmfile +build.mk libpc comp diff --git a/lang/pc/comp/.distr b/lang/pc/comp/.distr index 3e7d26961..827326d8c 100644 --- a/lang/pc/comp/.distr +++ b/lang/pc/comp/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk LLlex.c LLlex.h LLmessage.c diff --git a/lang/pc/libpc/.distr b/lang/pc/libpc/.distr index 0a10ca561..7cbba6326 100644 --- a/lang/pc/libpc/.distr +++ b/lang/pc/libpc/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk abi.c abl.c abr.c diff --git a/mach/i386/.distr b/mach/i386/.distr index 86584ff3c..38864464f 100644 --- a/mach/i386/.distr +++ b/mach/i386/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk as ncg libem diff --git a/mach/i386/libem/.distr b/mach/i386/libem/.distr index 670d9e145..c5bb0fc80 100644 --- a/mach/i386/libem/.distr +++ b/mach/i386/libem/.distr @@ -1,4 +1,3 @@ -pmfile adi.s and.s blm.s diff --git a/mach/i386/libend/.distr b/mach/i386/libend/.distr index 1508ebdc7..afa027b6e 100644 --- a/mach/i386/libend/.distr +++ b/mach/i386/libend/.distr @@ -1,4 +1,3 @@ -pmfile edata.s em_end.s end.s diff --git a/mach/i80/.distr b/mach/i80/.distr index c4ce2f711..fb68ed554 100644 --- a/mach/i80/.distr +++ b/mach/i80/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk as top ncg diff --git a/mach/i80/libem/.distr b/mach/i80/libem/.distr index b6454fbc7..8856d843f 100644 --- a/mach/i80/libem/.distr +++ b/mach/i80/libem/.distr @@ -1,4 +1,3 @@ -pmfile aar2.s adi4.s and.s diff --git a/mach/i80/libend/.distr b/mach/i80/libend/.distr index 1508ebdc7..afa027b6e 100644 --- a/mach/i80/libend/.distr +++ b/mach/i80/libend/.distr @@ -1,4 +1,3 @@ -pmfile edata.s em_end.s end.s diff --git a/mach/i86/.distr b/mach/i86/.distr index 86584ff3c..38864464f 100644 --- a/mach/i86/.distr +++ b/mach/i86/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk as ncg libem diff --git a/mach/i86/libem/.distr b/mach/i86/libem/.distr index a580bcb0c..0d2cf9e4b 100644 --- a/mach/i86/libem/.distr +++ b/mach/i86/libem/.distr @@ -1,4 +1,3 @@ -pmfile adi.s and.s cii.s diff --git a/mach/i86/libend/.distr b/mach/i86/libend/.distr index 1508ebdc7..afa027b6e 100644 --- a/mach/i86/libend/.distr +++ b/mach/i86/libend/.distr @@ -1,4 +1,3 @@ -pmfile edata.s em_end.s end.s diff --git a/mach/m68020/.distr b/mach/m68020/.distr index 096a7b2f4..38864464f 100644 --- a/mach/m68020/.distr +++ b/mach/m68020/.distr @@ -1,12 +1,5 @@ -Action +build.mk as -cv +ncg libem libend -libsys -ncg -libfp -libdb -top -ce -mach_params diff --git a/mach/m68020/libem/.distr b/mach/m68020/libem/.distr index d2b4f2884..73355eedc 100644 --- a/mach/m68020/libem/.distr +++ b/mach/m68020/libem/.distr @@ -1,2 +1,31 @@ +aar.s +cii.s +cmi.s +cms.s +cmu.s +csa.s +csb.s +cuu.s +cvf.s +dia.s +edata.s +em_end.s +end.s +etext.s +exg.s +fakfp.s +fat.s +fp68881.s +inn.s +lar.s LIST -libem_s.a +los.s +mon.s +nop.s +printf.s +sar.s +set.s +shp.s +sts.s +trp.s +trpstr.c diff --git a/mach/m68020/libend/.distr b/mach/m68020/libend/.distr index b48ec8483..afa027b6e 100644 --- a/mach/m68020/libend/.distr +++ b/mach/m68020/libend/.distr @@ -1,2 +1,4 @@ -LIST -end_s.a +edata.s +em_end.s +end.s +etext.s diff --git a/mach/powerpc/libend/.distr b/mach/powerpc/libend/.distr index 1508ebdc7..38509e6aa 100644 --- a/mach/powerpc/libend/.distr +++ b/mach/powerpc/libend/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk edata.s em_end.s end.s diff --git a/mach/proto/.distr b/mach/proto/.distr index e34b0c9d7..78c561b64 100644 --- a/mach/proto/.distr +++ b/mach/proto/.distr @@ -1,4 +1,3 @@ -pmfile as cg ncg diff --git a/mach/proto/as/.distr b/mach/proto/as/.distr index 4c6af5c3e..49642a8e8 100644 --- a/mach/proto/as/.distr +++ b/mach/proto/as/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk comm0.h comm1.h comm2.y diff --git a/mach/proto/cg/.distr b/mach/proto/cg/.distr index dc488f32f..cf85682ac 100644 --- a/mach/proto/cg/.distr +++ b/mach/proto/cg/.distr @@ -1,4 +1,3 @@ -pmfile assert.h codegen.c compute.c diff --git a/mach/proto/ncg/.distr b/mach/proto/ncg/.distr index d8d384103..59ffc4a45 100644 --- a/mach/proto/ncg/.distr +++ b/mach/proto/ncg/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk assert.h codegen.c compute.c diff --git a/mach/proto/top/.distr b/mach/proto/top/.distr index bb14a80cf..6563cbe48 100644 --- a/mach/proto/top/.distr +++ b/mach/proto/top/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk queue.c queue.h top.c diff --git a/modules/src/alloc/.distr b/modules/src/alloc/.distr index fa07cf5d1..5e32a9ab6 100644 --- a/modules/src/alloc/.distr +++ b/modules/src/alloc/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk Malloc.c Srealloc.c Realloc.c diff --git a/modules/src/assert/.distr b/modules/src/assert/.distr index 34e11b290..8d1e1d31f 100644 --- a/modules/src/assert/.distr +++ b/modules/src/assert/.distr @@ -1,4 +1,3 @@ -pmfile BadAssert.c assert.3 assert.h diff --git a/modules/src/em_code/.distr b/modules/src/em_code/.distr index 45a94e8d3..fa1a4b160 100644 --- a/modules/src/em_code/.distr +++ b/modules/src/em_code/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk C_out.c bhcst.c bhdlb.c diff --git a/modules/src/em_mes/.distr b/modules/src/em_mes/.distr index 14eca8bbf..ca0b69dd8 100644 --- a/modules/src/em_mes/.distr +++ b/modules/src/em_mes/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk C_ms_com.c C_ms_ego.c C_ms_emx.c diff --git a/modules/src/flt_arith/.distr b/modules/src/flt_arith/.distr index c5c0292b5..c4a1363d4 100644 --- a/modules/src/flt_arith/.distr +++ b/modules/src/flt_arith/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk b64_add.c b64_sft.c flt_add.c diff --git a/modules/src/idf/.distr b/modules/src/idf/.distr index 4402cca9f..39d43902d 100644 --- a/modules/src/idf/.distr +++ b/modules/src/idf/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk idf.3 idf_pkg.body idf_pkg.spec diff --git a/modules/src/input/.distr b/modules/src/input/.distr index fc3c9413f..282567634 100644 --- a/modules/src/input/.distr +++ b/modules/src/input/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk AtEoIF.c AtEoIT.c inp_pkg.body diff --git a/modules/src/object/.distr b/modules/src/object/.distr index 1ad72d93d..27bc19a3e 100644 --- a/modules/src/object/.distr +++ b/modules/src/object/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk object.3 object.h obj.h diff --git a/modules/src/print/.distr b/modules/src/print/.distr index b23ff8f37..ae84adbeb 100644 --- a/modules/src/print/.distr +++ b/modules/src/print/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk doprnt.c format.c fprint.c diff --git a/modules/src/read_em/.distr b/modules/src/read_em/.distr index 100499ee0..10e7531e0 100644 --- a/modules/src/read_em/.distr +++ b/modules/src/read_em/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk EM_vars.c argtype em_comp.h diff --git a/modules/src/string/.distr b/modules/src/string/.distr index 77bb9697d..73292d23b 100644 --- a/modules/src/string/.distr +++ b/modules/src/string/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk bts2str.c btscat.c btscmp.c diff --git a/modules/src/system/.distr b/modules/src/system/.distr index 2bfeb1de9..53683d833 100644 --- a/modules/src/system/.distr +++ b/modules/src/system/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk access.c break.c chmode.c diff --git a/plat/.distr b/plat/.distr new file mode 100644 index 000000000..69538e79a --- /dev/null +++ b/plat/.distr @@ -0,0 +1,2 @@ +build.mk + diff --git a/plat/cpm/.distr b/plat/cpm/.distr index 04a32eaa3..23343f43f 100644 --- a/plat/cpm/.distr +++ b/plat/cpm/.distr @@ -1,11 +1,10 @@ descr boot.s -pmfile +build.mk README include/ack/config.h include/unistd.h include/cpm.h -libsys/pmfile libsys/_bdos.s libsys/brk.c libsys/close.c diff --git a/plat/linux/.distr b/plat/linux/.distr new file mode 100644 index 000000000..cd8d6878b --- /dev/null +++ b/plat/linux/.distr @@ -0,0 +1,2 @@ +liblinux + diff --git a/plat/linux/liblinux/.distr b/plat/linux/liblinux/.distr new file mode 100644 index 000000000..d5667c361 --- /dev/null +++ b/plat/linux/liblinux/.distr @@ -0,0 +1,20 @@ +brk.c +build.mk +close.c +creat.c +errno.s +_exit.c +getpid.c +gettimeofday.c +_hol0.s +isatty.c +kill.c +libsys.h +lseek.c +open.c +pmfile +read.c +sbrk.c +signal.c +syscalls.h +write.c diff --git a/plat/linux386/.distr b/plat/linux386/.distr index da4420e2f..ec0a7f252 100644 --- a/plat/linux386/.distr +++ b/plat/linux386/.distr @@ -1,26 +1,8 @@ descr boot.s -pmfile +build.mk README +include/sys/ioctl.h include/ack/config.h include/unistd.h -libsys/pmfile -libsys/_exit.c -libsys/_hol0.s libsys/_syscall.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/gettimeofday.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/sbrk.c -libsys/signal.c -libsys/syscalls.h -libsys/write.c diff --git a/plat/linux68k/.distr b/plat/linux68k/.distr index da4420e2f..ec0a7f252 100644 --- a/plat/linux68k/.distr +++ b/plat/linux68k/.distr @@ -1,26 +1,8 @@ descr boot.s -pmfile +build.mk README +include/sys/ioctl.h include/ack/config.h include/unistd.h -libsys/pmfile -libsys/_exit.c -libsys/_hol0.s libsys/_syscall.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/gettimeofday.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/sbrk.c -libsys/signal.c -libsys/syscalls.h -libsys/write.c diff --git a/plat/linuxppc/.distr b/plat/linuxppc/.distr index da4420e2f..7bf2c073b 100644 --- a/plat/linuxppc/.distr +++ b/plat/linuxppc/.distr @@ -1,10 +1,10 @@ descr boot.s -pmfile +build.mk README include/ack/config.h include/unistd.h -libsys/pmfile +libsys/build.mk libsys/_exit.c libsys/_hol0.s libsys/_syscall.s diff --git a/plat/pc86/.distr b/plat/pc86/.distr index 9bcdd612a..bc4921680 100644 --- a/plat/pc86/.distr +++ b/plat/pc86/.distr @@ -1,10 +1,9 @@ descr boot.s -pmfile +build.mk README include/ack/config.h include/unistd.h -libsys/pmfile libsys/_hol0.s libsys/brk.c libsys/close.c diff --git a/util/LLgen/.distr b/util/LLgen/.distr index c8dcea78f..d9b7bfec4 100644 --- a/util/LLgen/.distr +++ b/util/LLgen/.distr @@ -1,4 +1,4 @@ -pmfile-ack +build.mk src/main.c src/gencode.c src/compute.c diff --git a/util/ack/.distr b/util/ack/.distr index 47ebd56d7..17fe19346 100644 --- a/util/ack/.distr +++ b/util/ack/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk ack.h data.c data.h diff --git a/util/amisc/.distr b/util/amisc/.distr index 3cbc22a7d..7711636ff 100644 --- a/util/amisc/.distr +++ b/util/amisc/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk ashow.c ashow.1 anm.c diff --git a/util/arch/.distr b/util/arch/.distr index 7a52ea34b..e6dbd9e4e 100644 --- a/util/arch/.distr +++ b/util/arch/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk aal.1 arch.1 arch.5 diff --git a/util/cgg/.distr b/util/cgg/.distr index 2a2ff68aa..60379f236 100644 --- a/util/cgg/.distr +++ b/util/cgg/.distr @@ -1,4 +1,3 @@ -pmfile bootgram.y bootlex.l main.c diff --git a/util/cmisc/.distr b/util/cmisc/.distr index fea42afee..a0012ed5d 100644 --- a/util/cmisc/.distr +++ b/util/cmisc/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk GCIPM.c cclash.1 cclash.c diff --git a/util/cpp/.distr b/util/cpp/.distr index 7b896c676..cd790f208 100644 --- a/util/cpp/.distr +++ b/util/cpp/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk LLlex.c LLlex.h LLmessage.c diff --git a/util/data/.distr b/util/data/.distr index 238202998..aaddd8677 100644 --- a/util/data/.distr +++ b/util/data/.distr @@ -1,3 +1,3 @@ -pmfile +build.mk em_ptyp.c new_table diff --git a/util/ego/.distr b/util/ego/.distr index 49f46d9aa..c2b981405 100644 --- a/util/ego/.distr +++ b/util/ego/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk bo ca cf diff --git a/util/led/.distr b/util/led/.distr index 6d4ff4c24..d505d7858 100644 --- a/util/led/.distr +++ b/util/led/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk WRONG ack.out.5 archive.c diff --git a/util/misc/.distr b/util/misc/.distr index 85e58eff3..5f41acd1d 100644 --- a/util/misc/.distr +++ b/util/misc/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk convert.c em_decode.6 esize.1 diff --git a/util/ncgg/.distr b/util/ncgg/.distr index f90b6e519..19d084a70 100644 --- a/util/ncgg/.distr +++ b/util/ncgg/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk assert.h cgg.y coerc.c diff --git a/util/opt/.distr b/util/opt/.distr index de2d23cf5..8ac4a7749 100644 --- a/util/opt/.distr +++ b/util/opt/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk alloc.c alloc.h assert.h diff --git a/util/topgen/.distr b/util/topgen/.distr index 52cb94313..b26dfa968 100644 --- a/util/topgen/.distr +++ b/util/topgen/.distr @@ -1,4 +1,4 @@ -pmfile +build.mk LLlex.c hash.c main.c From 24ef1627ec41ad35921ac72c385bcfe464300942 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 16 May 2013 14:20:58 +0100 Subject: [PATCH 016/231] A few last build tweaks. --HG-- branch : dtrg-buildsystem --- Makefile | 2 ++ mach/m68020/libem/.distr | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index c50e79b10..e203d3243 100644 --- a/Makefile +++ b/Makefile @@ -111,6 +111,8 @@ include plat/linux68k/build.mk .PHONY: installables installables: $(INSTALLABLES) + @echo "" + @echo "Build completed successfully." .PHONY: install install: installables diff --git a/mach/m68020/libem/.distr b/mach/m68020/libem/.distr index 73355eedc..43a4003c4 100644 --- a/mach/m68020/libem/.distr +++ b/mach/m68020/libem/.distr @@ -8,21 +8,15 @@ csb.s cuu.s cvf.s dia.s -edata.s -em_end.s -end.s -etext.s exg.s -fakfp.s fat.s fp68881.s inn.s lar.s -LIST los.s mon.s nop.s -printf.s +pmfile sar.s set.s shp.s From f70f78b6e439dff6233c5f82ef5f27874c8ceb0c Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 16 May 2013 22:02:00 +0100 Subject: [PATCH 017/231] Correctly generate dependency information. --- first/core.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/first/core.mk b/first/core.mk index f1530d4d9..1dc82c5b9 100644 --- a/first/core.mk +++ b/first/core.mk @@ -13,7 +13,7 @@ define cfile-rule $o: $s @echo CC $o @mkdir -p $(dir $o) - @$(CC) $(CFLAGS) $(cflags) -MM -MQ $d -o $d $s + @$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d $s $(hide) $(CC) $(CFLAGS) $(cflags) -c -o $o $s endef From e5f6d5acfa1c2ea733f46a248f3127ed0abd41e4 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 16 May 2013 22:02:59 +0100 Subject: [PATCH 018/231] Fix buffer overrun looking up type information for op_lab pseudoops (as they're not EM opcodes, we shouldn't look them up in em_flags!). --- mach/proto/ncg/nextem.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mach/proto/ncg/nextem.c b/mach/proto/ncg/nextem.c index 9023f8a22..75f0d0fec 100644 --- a/mach/proto/ncg/nextem.c +++ b/mach/proto/ncg/nextem.c @@ -87,6 +87,13 @@ extern char em_flag[]; argtyp(mn) { + /* op_lab is a special opcode which represents a label definition. It's + * not actually a real EM instruction. Therefore if we try to look it + * up in em_flag, we'll get a buffer overrun... */ + + if (mn == op_lab) + return EV_UNDEF; + switch(em_flag[mn-sp_fmnem]&EM_PAR) { case PAR_W: case PAR_S: From 32ebc502c86047797d72122a98e329f2ca03a05e Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 17 May 2013 00:03:38 +0100 Subject: [PATCH 019/231] Skeleton of VideoCore IV support for the Raspberry Pi. --HG-- branch : dtrg-videocore rename : mach/powerpc/as/.distr => mach/vc4/as/.distr rename : mach/powerpc/as/mach0.c => mach/vc4/as/mach0.c rename : mach/powerpc/as/mach1.c => mach/vc4/as/mach1.c rename : mach/powerpc/as/mach2.c => mach/vc4/as/mach2.c rename : mach/powerpc/as/mach3.c => mach/vc4/as/mach3.c rename : mach/powerpc/as/mach4.c => mach/vc4/as/mach4.c rename : mach/powerpc/as/mach5.c => mach/vc4/as/mach5.c rename : mach/i86/build.mk => mach/vc4/build.mk rename : mach/powerpc/libem/powerpc.h => mach/vc4/libem/videocore.h rename : mach/i86/libend/.distr => mach/vc4/libend/.distr rename : mach/i86/libend/edata.s => mach/vc4/libend/edata.s rename : mach/i86/libend/em_end.s => mach/vc4/libend/em_end.s rename : mach/i86/libend/end.s => mach/vc4/libend/end.s rename : mach/i86/libend/etext.s => mach/vc4/libend/etext.s rename : mach/powerpc/ncg/.distr => mach/vc4/ncg/.distr rename : mach/powerpc/ncg/mach.c => mach/vc4/ncg/mach.c rename : mach/powerpc/ncg/mach.h => mach/vc4/ncg/mach.h rename : mach/powerpc/ncg/table => mach/vc4/ncg/table rename : plat/pc86/descr => plat/rpi/descr --- mach/vc4/as/.distr | 6 + mach/vc4/as/binary.h | 34 + mach/vc4/as/mach0.c | 31 + mach/vc4/as/mach1.c | 6 + mach/vc4/as/mach2.c | 22 + mach/vc4/as/mach3.c | 95 ++ mach/vc4/as/mach4.c | 110 ++ mach/vc4/as/mach5.c | 7 + mach/vc4/build.mk | 10 + mach/vc4/libem/dummy.s | 9 + mach/vc4/libem/videocore.h | 15 + mach/vc4/libend/.distr | 4 + mach/vc4/libend/edata.s | 15 + mach/vc4/libend/em_end.s | 24 + mach/vc4/libend/end.s | 15 + mach/vc4/libend/etext.s | 15 + mach/vc4/ncg/.distr | 3 + mach/vc4/ncg/mach.c | 210 ++++ mach/vc4/ncg/mach.h | 32 + mach/vc4/ncg/table | 1999 +++++++++++++++++++++++++++++++ mach/vc4/test/opcodes.s | 77 ++ plat/rpi/build.mk | 47 + plat/rpi/descr | 69 ++ plat/rpi/include/ack/config.h | 11 + plat/rpi/include/unistd.h | 73 ++ plat/rpi/libsys/_hol0.s | 22 + plat/rpi/libsys/_sys_rawread.s | 26 + plat/rpi/libsys/_sys_rawwrite.s | 32 + plat/rpi/libsys/brk.c | 45 + plat/rpi/libsys/close.c | 16 + plat/rpi/libsys/creat.c | 17 + plat/rpi/libsys/errno.s | 31 + plat/rpi/libsys/getpid.c | 15 + plat/rpi/libsys/isatty.c | 15 + plat/rpi/libsys/kill.c | 16 + plat/rpi/libsys/libsys.h | 18 + plat/rpi/libsys/lseek.c | 16 + plat/rpi/libsys/open.c | 16 + plat/rpi/libsys/read.c | 45 + plat/rpi/libsys/signal.c | 17 + plat/rpi/libsys/time.c | 19 + plat/rpi/libsys/write.c | 50 + 42 files changed, 3355 insertions(+) create mode 100644 mach/vc4/as/.distr create mode 100644 mach/vc4/as/binary.h create mode 100644 mach/vc4/as/mach0.c create mode 100644 mach/vc4/as/mach1.c create mode 100644 mach/vc4/as/mach2.c create mode 100644 mach/vc4/as/mach3.c create mode 100644 mach/vc4/as/mach4.c create mode 100644 mach/vc4/as/mach5.c create mode 100644 mach/vc4/build.mk create mode 100644 mach/vc4/libem/dummy.s create mode 100644 mach/vc4/libem/videocore.h create mode 100644 mach/vc4/libend/.distr create mode 100644 mach/vc4/libend/edata.s create mode 100644 mach/vc4/libend/em_end.s create mode 100644 mach/vc4/libend/end.s create mode 100644 mach/vc4/libend/etext.s create mode 100644 mach/vc4/ncg/.distr create mode 100644 mach/vc4/ncg/mach.c create mode 100644 mach/vc4/ncg/mach.h create mode 100644 mach/vc4/ncg/table create mode 100644 mach/vc4/test/opcodes.s create mode 100644 plat/rpi/build.mk create mode 100644 plat/rpi/descr create mode 100644 plat/rpi/include/ack/config.h create mode 100644 plat/rpi/include/unistd.h create mode 100644 plat/rpi/libsys/_hol0.s create mode 100644 plat/rpi/libsys/_sys_rawread.s create mode 100644 plat/rpi/libsys/_sys_rawwrite.s create mode 100644 plat/rpi/libsys/brk.c create mode 100644 plat/rpi/libsys/close.c create mode 100644 plat/rpi/libsys/creat.c create mode 100644 plat/rpi/libsys/errno.s create mode 100644 plat/rpi/libsys/getpid.c create mode 100644 plat/rpi/libsys/isatty.c create mode 100644 plat/rpi/libsys/kill.c create mode 100644 plat/rpi/libsys/libsys.h create mode 100644 plat/rpi/libsys/lseek.c create mode 100644 plat/rpi/libsys/open.c create mode 100644 plat/rpi/libsys/read.c create mode 100644 plat/rpi/libsys/signal.c create mode 100644 plat/rpi/libsys/time.c create mode 100644 plat/rpi/libsys/write.c diff --git a/mach/vc4/as/.distr b/mach/vc4/as/.distr new file mode 100644 index 000000000..8ebe3797c --- /dev/null +++ b/mach/vc4/as/.distr @@ -0,0 +1,6 @@ +mach0.c +mach1.c +mach2.c +mach3.c +mach4.c +mach5.c diff --git a/mach/vc4/as/binary.h b/mach/vc4/as/binary.h new file mode 100644 index 000000000..c00e73550 --- /dev/null +++ b/mach/vc4/as/binary.h @@ -0,0 +1,34 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef BINARY_H +#define BINARY_H + +/* This grotesque nonsense allows us to use binary constants from C. */ + +#define HEX__(n) 0x##n##LU +#define B8__(x) \ + ((x&0x0000000FLU)?1:0) \ + +((x&0x000000F0LU)?2:0) \ + +((x&0x00000F00LU)?4:0) \ + +((x&0x0000F000LU)?8:0) \ + +((x&0x000F0000LU)?16:0) \ + +((x&0x00F00000LU)?32:0) \ + +((x&0x0F000000LU)?64:0) \ + +((x&0xF0000000LU)?128:0) + +#define B8(d) \ + ((unsigned char)B8__(HEX__(d))) +#define B16(dmsb,dlsb) \ + (((unsigned short)B8(dmsb)<<8) + B8(dlsb)) +#define B32(dmsb,db2,db3,dlsb) \ + (((unsigned long)B8(dmsb)<<24) \ + + ((unsigned long)B8(db2)<<16) \ + + ((unsigned long)B8(db3)<<8) \ + + B8(dlsb)) + +#endif diff --git a/mach/vc4/as/mach0.c b/mach/vc4/as/mach0.c new file mode 100644 index 000000000..b6294ecfc --- /dev/null +++ b/mach/vc4/as/mach0.c @@ -0,0 +1,31 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#define THREE_PASS /* branch and offset optimization */ +#define LISTING /* enable listing facilities */ +#define RELOCATION /* generate relocatable code */ +#define DEBUG 0 + +#undef valu_t +#define valu_t long + +#undef ADDR_T +#define ADDR_T long + +#undef word_t +#define word_t long + +#undef ALIGNWORD +#define ALIGNWORD 4 + +#undef ALIGNSECT +#define ALIGNSECT 4 + +#undef VALWIDTH +#define VALWIDTH 8 + +#define FIXUPFLAGS (RELBR | RELWR) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c new file mode 100644 index 000000000..96a8a07fa --- /dev/null +++ b/mach/vc4/as/mach1.c @@ -0,0 +1,6 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c new file mode 100644 index 000000000..c69007de0 --- /dev/null +++ b/mach/vc4/as/mach2.c @@ -0,0 +1,22 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +%token GPR + +%token OP +%token OP_ONEREG +%token OP_ONELREG +%token OP_ALU +%token OP_MEM +%token OP_BREG +%token OP_STACK + +/* Other token types */ + +/* %type c */ +%type e16 u8 u7 u6 u5 u4 u2 u1 +/* %type nb ds bda bdl lia lil */ diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c new file mode 100644 index 000000000..b36652db7 --- /dev/null +++ b/mach/vc4/as/mach3.c @@ -0,0 +1,95 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "binary.h" + +/* Integer registers */ + +0, GPR, 0, "r0", +0, GPR, 1, "r1", +0, GPR, 2, "r2", +0, GPR, 3, "r3", +0, GPR, 4, "r4", +0, GPR, 5, "r5", + +0, GPR, 6, "r6", +0, GPR, 6, "fp", +0, GPR, 7, "r7", +0, GPR, 8, "r8", +0, GPR, 9, "r9", +0, GPR, 10, "r10", +0, GPR, 11, "r11", +0, GPR, 12, "r12", +0, GPR, 13, "r13", +0, GPR, 14, "r14", +0, GPR, 15, "r15", +0, GPR, 16, "r16", +0, GPR, 17, "r17", +0, GPR, 18, "r18", +0, GPR, 19, "r19", +0, GPR, 20, "r20", +0, GPR, 21, "r21", +0, GPR, 22, "r22", +0, GPR, 23, "r23", +0, GPR, 24, "r24", + +0, GPR, 25, "r25", +0, GPR, 25, "sp", +0, GPR, 26, "r26", +0, GPR, 26, "lr", +0, GPR, 27, "r27", +0, GPR, 28, "r28", +0, GPR, 29, "r29", +0, GPR, 30, "r30", +0, GPR, 30, "sr", +0, GPR, 31, "r31", +0, GPR, 31, "pc", + +/* Special instructions */ + +0, OP, B16(00000000,00000001), "nop", +0, OP, B16(00000000,00001010), "rti", + +0, OP_ONEREG, B16(00000000,01000000), "b", +0, OP_ONEREG, B16(00000000,01100000), "bl", +0, OP_ONELREG, B16(00000000,10000000), "tbb", +0, OP_ONELREG, B16(00000000,10100000), "tbs", + +0, OP_ALU, B8(00000000), "mov", +0, OP_ALU, B8(00000001), "cmn", +0, OP_ALU, B8(00000010), "add", +0, OP_ALU, B8(00000011), "bic", +0, OP_ALU, B8(00000100), "mul", +0, OP_ALU, B8(00000101), "eor", +0, OP_ALU, B8(00000110), "sub", +0, OP_ALU, B8(00000111), "and", +0, OP_ALU, B8(00001000), "mvn", +0, OP_ALU, B8(00001001), "ror", +0, OP_ALU, B8(00001010), "cmp", +0, OP_ALU, B8(00001011), "rsb", +0, OP_ALU, B8(00001100), "btst", +0, OP_ALU, B8(00001101), "or", +0, OP_ALU, B8(00001110), "extu", +0, OP_ALU, B8(00001111), "max", +0, OP_ALU, B8(00010000), "bset", +0, OP_ALU, B8(00010001), "min", +0, OP_ALU, B8(00010010), "bclr", +0, OP_ALU, B8(00010011), "adds2", +0, OP_ALU, B8(00010100), "bchg", +0, OP_ALU, B8(00010101), "adds4", +0, OP_ALU, B8(00010110), "adds8", +0, OP_ALU, B8(00010111), "adds16", +0, OP_ALU, B8(00011000), "exts", +0, OP_ALU, B8(00011001), "neg", +0, OP_ALU, B8(00011010), "lsr", +0, OP_ALU, B8(00011011), "clz", +0, OP_ALU, B8(00011100), "lsl", +0, OP_ALU, B8(00011101), "brev", +0, OP_ALU, B8(00011110), "asr", +0, OP_ALU, B8(00011111), "abs", + + diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c new file mode 100644 index 000000000..d1320dae1 --- /dev/null +++ b/mach/vc4/as/mach4.c @@ -0,0 +1,110 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "binary.h" + +operation + : OP { emit2($1); } + + | OP_ONEREG GPR + { + emit2($1 | ($2<<0)); + } + + | OP_ONELREG GPR + { + if ($2 >= 0x10) + serror("cannot use r16+ here"); + emit2($1 | ($2<<0)); + } + + | OP_ALU GPR ',' GPR + { + emit2(B16(01000000, 00000000) | ($1<<8) | ($2<<0) | ($4<<4)); + } + + | OP_ALU GPR ',' '#' u5 + { + if ($1 >= 0x10) + serror("cannot use this ALU operation in 2op form"); + emit2(B16(01100000, 00000000) | ($1<<9) | ($2<<0) | ($5<<4)); + } + ; + +e16 + : expr + { + DOTVAL += 2; + newrelo($1.typ, RELO2 | FIXUPFLAGS); + DOTVAL -= 2; + $$ = $1.val & 0xFFFF; + } + ; + +u8 + : absexp + { + if (($1 < 0) || ($1 > 0xFF)) + serror("8-bit unsigned value out of range"); + $$ = $1; + } + ; + +u7 + : absexp + { + if (($1 < 0) || ($1 > 0x7F)) + serror("7-bit unsigned value out of range"); + $$ = $1; + } + ; + +u6 + : absexp + { + if (($1 < 0) || ($1 > 0x3F)) + serror("6-bit unsigned value out of range"); + $$ = $1; + } + ; + +u5 + : absexp + { + if (($1 < 0) || ($1 > 0x1F)) + serror("5-bit unsigned value out of range"); + $$ = $1; + } + ; + +u4 + : absexp + { + if (($1 < 0) || ($1 > 0xF)) + serror("4-bit unsigned value out of range"); + $$ = $1; + } + ; + +u1 + : absexp + { + if (($1 < 0) || ($1 > 1)) + serror("1-bit unsigned value out of range"); + $$ = $1; + } + ; + +u2 + : absexp + { + if (($1 < 0) || ($1 > 0x3)) + serror("2-bit unsigned value out of range"); + $$ = $1; + } + ; + diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c new file mode 100644 index 000000000..668f4b748 --- /dev/null +++ b/mach/vc4/as/mach5.c @@ -0,0 +1,7 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + diff --git a/mach/vc4/build.mk b/mach/vc4/build.mk new file mode 100644 index 000000000..06ea3edd4 --- /dev/null +++ b/mach/vc4/build.mk @@ -0,0 +1,10 @@ +arch-libem-vc4 := \ + dummy.s + +arch-libend-vc4 = \ + edata.s \ + em_end.s \ + end.s \ + etext.s + + diff --git a/mach/vc4/libem/dummy.s b/mach/vc4/libem/dummy.s new file mode 100644 index 000000000..4edaa030f --- /dev/null +++ b/mach/vc4/libem/dummy.s @@ -0,0 +1,9 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "videocore.h" diff --git a/mach/vc4/libem/videocore.h b/mach/vc4/libem/videocore.h new file mode 100644 index 000000000..3e27a7e7b --- /dev/null +++ b/mach/vc4/libem/videocore.h @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + diff --git a/mach/vc4/libend/.distr b/mach/vc4/libend/.distr new file mode 100644 index 000000000..afa027b6e --- /dev/null +++ b/mach/vc4/libend/.distr @@ -0,0 +1,4 @@ +edata.s +em_end.s +end.s +etext.s diff --git a/mach/vc4/libend/edata.s b/mach/vc4/libend/edata.s new file mode 100644 index 000000000..e706877db --- /dev/null +++ b/mach/vc4/libend/edata.s @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _edata +.sect .data +_edata: diff --git a/mach/vc4/libend/em_end.s b/mach/vc4/libend/em_end.s new file mode 100644 index 000000000..bae5aaa0c --- /dev/null +++ b/mach/vc4/libend/em_end.s @@ -0,0 +1,24 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .end ! only for declaration of _end, __end and endbss. +.define endtext, endrom, enddata, endbss, __end + + .sect .text +endtext: + .sect .rom +endrom: + .sect .data +enddata: + .sect .end +__end: +endbss: diff --git a/mach/vc4/libend/end.s b/mach/vc4/libend/end.s new file mode 100644 index 000000000..5ce2882b6 --- /dev/null +++ b/mach/vc4/libend/end.s @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _end +.sect .end ! only for declaration of _end, __end and endbss. +_end: diff --git a/mach/vc4/libend/etext.s b/mach/vc4/libend/etext.s new file mode 100644 index 000000000..973ab1814 --- /dev/null +++ b/mach/vc4/libend/etext.s @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _etext +.sect .text +_etext: diff --git a/mach/vc4/ncg/.distr b/mach/vc4/ncg/.distr new file mode 100644 index 000000000..ccdf9bf7e --- /dev/null +++ b/mach/vc4/ncg/.distr @@ -0,0 +1,3 @@ +mach.c +mach.h +table diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c new file mode 100644 index 000000000..f57a2a08f --- /dev/null +++ b/mach/vc4/ncg/mach.c @@ -0,0 +1,210 @@ +/* + * VideoCore IV code generator for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include + +#ifndef NORCSID +static char rcsid[]= "$Id$" ; +#endif + +int framesize; + +/* + * machine dependent back end routines for the Zilog Z80. + */ + +con_part(int sz, word w) +{ + while (part_size % sz) + part_size++; + if (part_size == TEM_WSIZE) + part_flush(); + if (sz == 1) { + w &= 0xFF; + w <<= 8*(3-part_size); + part_word |= w; + } else if (sz == 2) { + w &= 0xFFFF; + if (part_size == 0) { + /* Shift 8 for m68k2, 16 otherwise */ + w <<= 4 * TEM_WSIZE; + } + part_word |= w; + } else { + assert(sz == TEM_WSIZE); + part_word = w; + } + part_size += sz; +} + +con_mult(word sz) +{ + + if (argval != 4) + fatal("bad icon/ucon size"); + fprintf(codefile,".data4 %s\n", str); +} + +#define CODE_GENERATOR +#define IEEEFLOAT +#define FL_MSL_AT_LOW_ADDRESS 1 +#define FL_MSW_AT_LOW_ADDRESS 1 +#define FL_MSB_AT_LOW_ADDRESS 1 +#include + +prolog(full nlocals) +{ + int ss = nlocals + 8; + fprintf(codefile, "addi sp, sp, %d\n", -ss); + fprintf(codefile, "stw fp, %d(sp)\n", nlocals); + fprintf(codefile, "mfspr r0, lr\n" + "stw r0, %d(sp)\n", nlocals+4); + fprintf(codefile, "addi fp, sp, %d\n", nlocals); + + framesize = nlocals; +} + +mes(word type) +{ + int argt ; + + switch ( (int)type ) { + case ms_ext : + for (;;) { + switch ( argt=getarg( + ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) { + case sp_cend : + return ; + default: + strarg(argt) ; + fprintf(codefile,".define %s\n",argstr) ; + break ; + } + } + default : + while ( getarg(any_ptyp) != sp_cend ) ; + break ; + } +} + +char *segname[] = { + ".sect .text", + ".sect .data", + ".sect .rom", + ".sect .bss" +}; + +#ifdef REGVARS + +static int savedregsi[32]; +static int numsaved; + +/* Initialise regvar system for one function. */ + +i_regsave() +{ + int i; + + fprintf(codefile, "! i_regsave()\n"); + for (i=0; i<32; i++) + savedregsi[i] = INT_MAX; + numsaved = 0; +} + +/* Mark a register as being saved. */ + +regsave(const char* regname, full offset, int size) +{ + int regnum = atoi(regname+1); + savedregsi[regnum] = offset; + numsaved++; + + fprintf(codefile, "! %d is saved in %s\n", offset, regname); +#if 0 + fprintf(codefile, "stwu %s, -4(sp)\n", regname); + if (offset >= 0) + fprintf(codefile, "lwz %s, %d(fp)\n", regname, offset); +#endif +} + +/* Finish saving ragisters. */ + +void saveloadregs(const char* ops, const char* opm) +{ + int offset = -(framesize + numsaved*4); + int reg = 32; + + /* Check for the possibility of a multiple. */ + + do + { + reg--; + } + while ((reg > 0) && (savedregsi[reg] != INT_MAX)); + if (reg < 31) + { + fprintf(codefile, "%s r%d, %d(fp)\n", opm, reg+1, offset); + offset += (31-reg)*4; + } + + /* Saved everything else singly. */ + + while (reg > 0) + { + if (savedregsi[reg] != INT_MAX) + { + fprintf(codefile, "%s r%d, %d(fp)\n", ops, reg, offset); + offset += 4; + } + reg--; + } +} + +f_regsave() +{ + int i; + fprintf(codefile, "! f_regsave()\n"); + fprintf(codefile, "addi sp, sp, %d\n", -numsaved*4); + + saveloadregs("stw", "stmw"); + + for (i=0; i<32; i++) + if ((savedregsi[i] != INT_MAX) && (savedregsi[i] > 0)) + fprintf(codefile, "lwz r%d, %d(fp)\n", i, savedregsi[i]); +} + +/* Restore all saved registers. */ + +regreturn() +{ + fprintf(codefile, "! regreturn()\n"); + saveloadregs("lwz", "lmw"); +} + +/* Calculate the score of a given register. */ + +int regscore(full offset, int size, int type, int frequency, int totype) +{ + int score; + + fprintf(codefile, "! regscore(%ld, %d, %d, %d, %d)\n", offset, size, type, frequency, totype); + + if (size != 4) + return -1; + + /* Per use: 6 bytes (on average) + * Overhead in prologue: 4 bytes, plus 4 if a parameter + * Overhead in epilogue: 0 bytes + */ + + score = frequency*6 - 4 - ((offset>=0) ? 4 : 0); + fprintf(codefile, "! local at offset %d has regvar score %d\n", offset, score); + return score; +} + +#endif diff --git a/mach/vc4/ncg/mach.h b/mach/vc4/ncg/mach.h new file mode 100644 index 000000000..89d2b8a97 --- /dev/null +++ b/mach/vc4/ncg/mach.h @@ -0,0 +1,32 @@ +/* + * VideoCore IV code generator for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#define ex_ap(y) fprintf(codefile,".extern %s\n",y) +#define in_ap(y) /* nothing */ + +#define newilb(x) fprintf(codefile,"%s:\n",x) +#define newdlb(x) fprintf(codefile,"%s:\n",x) +#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y) +#define newlbss(l,x) fprintf(codefile,".comm %s,%u\n",l,x); + +#define cst_fmt "%d" +#define off_fmt "%d" +#define ilb_fmt "I%x_%x" +#define dlb_fmt "_%d" +#define hol_fmt "hol%d" + +#define hol_off "%ld+hol%d" + +#define con_cst(x) fprintf(codefile,".data4\t%ld\n",x) +#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x) +#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x) + +#define fmt_id(sf, st) sprintf(st,"_%s",sf) + +#define modhead ".sect .text; .sect .rom; .sect .data; .sect .bss\n" + +#define BSS_INIT 0 diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table new file mode 100644 index 000000000..f08ec3500 --- /dev/null +++ b/mach/vc4/ncg/table @@ -0,0 +1,1999 @@ +/* + * VideoCore IV code generator for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +EM_WSIZE = 4 +EM_PSIZE = 4 +EM_BSIZE = 8 /* two words saved in call frame */ + +INT8 = 1 /* Size of values */ +INT16 = 2 +INT32 = 4 +INT64 = 8 + +FP_OFFSET = 0 /* Offset of saved FP relative to our FP */ +PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ + +#define COMMENT(n) /* noop */ + + +#define nicesize(x) ((x)==INT8 || (x)==INT16 || (x)==INT32 || (x)==INT64) + +#define smalls(n) sfit(n, 16) +#define smallu(n) ufit(n, 16) + +#define lo(n) (n & 0xFFFF) +#define hi(n) ((n>>16) & 0xFFFF) + +/* Use these for instructions that treat the low half as signed --- his() + * includes a modifier to produce the correct value when the low half gets + * sign extended. Er, do make sure you load the low half second. */ +#define los(n) (n & 0xFFFF) +#define his(n) ((hi(n) - (lo(n)>>15)) & 0xFFFF) + +#define IFFALSE {CONST, 4} +#define IFTRUE {CONST, 12} +#define ALWAYS {CONST, 20} +#define DCTRZ {CONST, 34} + +#define LT {CONST, 0} +#define GT {CONST, 1} +#define EQ {CONST, 2} + + + +PROPERTIES + + GPR /* any GPR */ + REG /* any allocatable GPR */ + FPR /* any FPR */ + FREG /* any allocatable FPR */ + SPR /* any SPR */ + CR /* any CR */ + + GPR0 GPRSP GPRFP GPR3 GPR4 GPR5 GPR6 GPR7 + GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15 + GPR16 GPR17 GPR18 GPR19 GPR20 GPR21 GPR22 GPR23 + GPR24 GPR25 GPR26 GPR27 GPR28 GPR29 GPR30 GPR31 + + CR0 CR1 + + FPR0 FPR1 FPR2 FPR3 FPR4 FPR5 FPR6 FPR7 + FPR8 FPR9 FPR10 FPR11 FPR12 FPR13 FPR14 FPR15 + FPR16 FPR17 FPR18 FPR19 FPR20 FPR21 FPR22 FPR23 + FPR24 FPR25 FPR26 FPR27 FPR28 FPR29 FPR30 FPR31 + +REGISTERS + + /* Reverse order to encourage ncg to allocate them from r31 down */ + + R31("r31") : GPR, REG, GPR31 regvar. + R30("r30") : GPR, REG, GPR30 regvar. + R29("r29") : GPR, REG, GPR29 regvar. + R28("r28") : GPR, REG, GPR28 regvar. + R27("r27") : GPR, REG, GPR27 regvar. + R26("r26") : GPR, REG, GPR26 regvar. + R25("r25") : GPR, REG, GPR25 regvar. + R24("r24") : GPR, REG, GPR24 regvar. + R23("r23") : GPR, REG, GPR23 regvar. + R22("r22") : GPR, REG, GPR22 regvar. + R21("r21") : GPR, REG, GPR21 regvar. + R20("r20") : GPR, REG, GPR20 regvar. + R19("r19") : GPR, REG, GPR19 regvar. + R18("r18") : GPR, REG, GPR18 regvar. + R17("r17") : GPR, REG, GPR17 regvar. + R16("r16") : GPR, REG, GPR16 regvar. + R15("r15") : GPR, REG, GPR15 regvar. + R14("r14") : GPR, REG, GPR14 regvar. + R13("r13") : GPR, REG, GPR13 regvar. + R12("r12") : GPR, REG, GPR12. + R11("r11") : GPR, GPR11. + R10("r10") : GPR, REG, GPR10. + R9("r9") : GPR, REG, GPR9. + R8("r8") : GPR, REG, GPR8. + R7("r7") : GPR, REG, GPR7. + R6("r6") : GPR, REG, GPR6. + R5("r5") : GPR, REG, GPR5. + R4("r4") : GPR, REG, GPR4. + R3("r3") : GPR, REG, GPR3. + FP("fp") : GPR, GPRFP. + SP("sp") : GPR, GPRSP. + R0("r0") : GPR, GPR0. + + F31("f31") : FPR, FREG, FPR31. + F30("f30") : FPR, FREG, FPR30. + F29("f29") : FPR, FREG, FPR29. + F28("f28") : FPR, FREG, FPR28. + F27("f27") : FPR, FREG, FPR27. + F26("f26") : FPR, FREG, FPR26. + F25("f25") : FPR, FREG, FPR25. + F24("f24") : FPR, FREG, FPR24. + F23("f23") : FPR, FREG, FPR23. + F22("f22") : FPR, FREG, FPR22. + F21("f21") : FPR, FREG, FPR21. + F20("f20") : FPR, FREG, FPR20. + F19("f19") : FPR, FREG, FPR19. + F18("f18") : FPR, FREG, FPR18. + F17("f17") : FPR, FREG, FPR17. + F16("f16") : FPR, FREG, FPR16. + F15("f15") : FPR, FREG, FPR15. + F14("f14") : FPR, FREG, FPR14. + F13("f13") : FPR, FREG, FPR13. + F12("f12") : FPR, FREG, FPR12. + F11("f11") : FPR, FREG, FPR11. + F10("f10") : FPR, FREG, FPR10. + F9("f9") : FPR, FREG, FPR9. + F8("f8") : FPR, FREG, FPR8. + F7("f7") : FPR, FREG, FPR7. + F6("f6") : FPR, FREG, FPR6. + F5("f5") : FPR, FREG, FPR5. + F4("f4") : FPR, FREG, FPR4. + F3("f3") : FPR, FREG, FPR3. + F2("f2") : FPR, FREG, FPR2. + F1("f1") : FPR, FREG, FPR1. + F0("f0") : FPR, FREG, FPR0. + + LR("lr") : SPR. + CTR("ctr") : SPR. + C0("cr0") : CR, CR0. + +#define SCRATCH R11 +#define FSCRATCH F0 + + +TOKENS + +/* Used only in instruction descriptions (to generate the correct syntax). */ + + GPRINDIRECT = { GPR reg; INT off; } 4 off "(" reg ")". + GPRINDIRECTLO = { GPR reg; ADDR adr; } 4 ">" adr "(" reg ")". /* Warning! Do not use on labels. */ + HILABEL = { ADDR adr; } 4 "<" adr. + LOLABEL = { ADDR adr; } 4 ">" adr. + +/* Primitives */ + + LABEL = { ADDR adr; } 4 adr. + CONST = { INT val; } 4 val. + LOCAL = { INT off; } 4. + +/* Allows us to use regvar() to refer to registers */ + + GPRE = { GPR reg; } 4 reg. + +/* Expression partial results */ + + SUM_RC = { GPR reg; INT off; } 4. + SUM_RR = { GPR reg1; GPR reg2; } 4. + + TRISTATE_RC_S = { GPR reg; INT val; } 4. + TRISTATE_RC_U = { GPR reg; INT val; } 4. + TRISTATE_RR_S = { GPR reg1; GPR reg2; } 4. + TRISTATE_RR_U = { GPR reg1; GPR reg2; } 4. + + TRISTATE_FF = { FPR reg1; FPR reg2; } 4. + + SEX_B = { GPR reg; } 4. + SEX_H = { GPR reg; } 4. + + IND_RC_B = { GPR reg; INT off; } 4. + IND_RC_H = { GPR reg; INT off; } 4. + IND_RC_H_S = { GPR reg; INT off; } 4. + IND_RC_W = { GPR reg; INT off; } 4. + IND_RR_W = { GPR reg1; GPR reg2; } 4. + IND_LABEL_W = { ADDR adr; } 4. + IND_RC_D = { GPR reg; INT off; } 8. + IND_RR_D = { GPR reg1; GPR reg2; } 8. + IND_LABEL_D = { ADDR adr; } 8. + + NOT_R = { GPR reg; } 4. + + AND_RR = { GPR reg1; GPR reg2; } 4. + AND_RC = { GPR reg; INT val; } 4. + OR_RR = { GPR reg1; GPR reg2; } 4. + OR_RC = { GPR reg; INT val; } 4. + XOR_RR = { GPR reg1; GPR reg2; } 4. + XOR_RC = { GPR reg; INT val; } 4. + +/* Floats */ + + FD = { FPR reg; } 8 reg. + FS = { FPR reg; } 4 reg. + +/* Comments */ + + LABELI = { ADDR msg; INT num; } 4 msg " " num. + + + + +SETS + + TOKEN = LABEL + CONST + LOCAL. + GPRI = GPR + GPRE. + + SUM_ALL = SUM_RC + SUM_RR. + + TRISTATE_ALL = TRISTATE_RC_S + TRISTATE_RC_U + TRISTATE_RR_S + + TRISTATE_RR_U + TRISTATE_FF. + + SEX_ALL = SEX_B + SEX_H. + + LOGICAL_ALL = NOT_R + AND_RR + AND_RC + OR_RR + OR_RC + XOR_RR + + XOR_RC. + + IND_ALL_W = IND_RC_W + IND_RR_W + IND_LABEL_W. + + IND_ALL_D = IND_RC_D + IND_RR_D + IND_LABEL_D. + + OP_ALL_W = SUM_ALL + TRISTATE_ALL + SEX_ALL + LOGICAL_ALL + + IND_ALL_W. + + +INSTRUCTIONS + + add GPRI:wo, GPRI:ro, GPRI:ro. + addX "add." GPRI:wo, GPRI:ro, GPRI:ro. + addi GPRI:wo, GPRI:ro, CONST:ro. + addis GPRI:wo, GPRI:ro, CONST+HILABEL:ro. + and GPRI:wo, GPRI:ro, GPRI:ro. + andc GPRI:wo, GPRI:ro, GPRI:ro. + andiX "andi." GPRI:wo, GPRI:ro, CONST:ro kills :cc. + andisX "andis." GPRI:wo, GPRI:ro, CONST:ro kills :cc. + b LABEL:ro. + bc CONST:ro, CONST:ro, LABEL:ro. + bcctr CONST:ro, CONST:ro, CONST:ro. + bcctrl CONST:ro, CONST:ro, CONST:ro. + bclr CONST:ro, CONST:ro, CONST:ro. + bl LABEL:ro. + cmp CR:ro, CONST:ro, GPRI:ro, GPR:ro kills :cc. + cmpi CR:ro, CONST:ro, GPRI:ro, CONST:ro kills :cc. + cmpl CR:ro, CONST:ro, GPRI:ro, GPR:ro kills :cc. + cmpli CR:ro, CONST:ro, GPRI:ro, CONST:ro kills :cc. + divw GPRI:wo, GPRI:ro, GPRI:ro. + divwu GPRI:wo, GPRI:ro, GPRI:ro. + eqv GPRI:wo, GPRI:ro, GPRI:ro. + extsb GPRI:wo, GPRI:ro. + extsh GPRI:wo, GPRI:ro. + fadd FD:wo, FD:ro, FD:ro. + fadds FS:wo, FS:ro, FS:ro. + fcmpo CR:wo, FD:ro, FD:ro. + fdiv FD:wo, FD:ro, FD:ro. + fdivs FS:wo, FS:ro, FS:ro. + fneg FS+FD:wo, FS+FD:ro. + fmul FD:wo, FD:ro, FD:ro. + fmuls FS:wo, FS:ro, FS:ro. + frsp FS:wo, FD:ro. + fsub FD:wo, FD:ro, FD:ro. + fsubs FS:wo, FS:ro, FS:ro. + fmr FS+FD:wo, FS+FD:ro. + lbzx GPRI:wo, GPR:ro, GPR:ro. + lbz GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lfd FD:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lfdu FD:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lfdx FD:wo, GPR:ro, GPR:ro. + lfs FS:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lfsu FS:wo, GPRINDIRECT+GPRINDIRECTLO:rw. + lfsx FS:wo, GPR:ro, GPR:ro. + lhzx GPRI:wo, GPR:ro, GPR:ro. + lhax GPRI:wo, GPR:ro, GPR:ro. + lha GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lhz GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lwzu GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + lwzx GPRI:wo, GPR:ro, GPR:ro. + lwz GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. + nand GPRI:wo, GPRI:ro, GPRI:ro. + neg GPRI:wo, GPRI:ro. + nor GPRI:wo, GPRI:ro, GPRI:ro. + mfcr GPRI:wo. + mullw GPRI:wo, GPRI:ro, GPRI:ro. + mfspr GPRI:wo, SPR:ro. + mtspr SPR:wo, GPRI:ro. + or GPRI:wo, GPRI:ro, GPRI:ro. + orc GPRI:wo, GPRI:ro, GPRI:ro. + ori GPRI:wo, GPRI:ro, CONST+LOLABEL:ro. + orX "or." GPRI:wo, GPRI:ro, GPRI:ro kills :cc. + rlwinm GPRI:wo, GPRI:ro, CONST:ro, CONST:ro, CONST:ro. + slw GPRI:wo, GPRI:ro, GPRI:ro. + subf GPRI:wo, GPRI:ro, GPRI:ro. + sraw GPRI:wo, GPRI:ro, GPRI:ro. + srawi GPRI:wo, GPRI:ro, CONST:ro. + srw GPRI:wo, GPRI:ro, GPRI:ro. + stb GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + stbx GPRI:ro, GPR:ro, GPR:ro. + stfd FD:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + stfdu FD:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + stfdx FD:ro, GPR:ro, GPR:ro. + stfs FS:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + stfsu FS:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + stfsx FS:ro, GPR:ro, GPR:ro. + sth GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + sthx GPRI:ro, GPR:ro, GPR:ro. + stw GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + stwx GPRI:ro, GPR:ro, GPR:ro. + stwu GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. + xor GPRI:wo, GPRI:ro, GPRI:ro. + xori GPRI:wo, GPRI:ro, CONST:ro. + + gpr_gpr_gpr GPRI:wo, GPRI:ro, GPRI:ro. + gpr_gpr_si GPRI:wo, GPRI:ro, CONST:ro. + gpr_ro_gprindirect GPRI:ro, GPRINDIRECT:rw. + gpr_ro_gpr_gpr GPRI:ro, GPRI:ro, GPRI:ro. + gpr_wo_gprindirect GPRI:wo, GPRINDIRECT:ro. + gpr_wo_gpr_gpr GPRI:wo, GPRI:ro, GPRI:ro. + + invalid "invalid". + comment "!" LABEL+LABELI:ro. + + + +MOVES + + from GPR to GPR + gen + COMMENT("move GPR->GPR") + or %2, %1, %1 + +/* GPRE exists solely to allow us to use regvar() (which can only be used in + an expression) as a register constant. */ + + from GPR to GPRE + gen + COMMENT("move GPR->GPRE") + or %2, %1, %1 + +/* Constants */ + + from CONST smalls(%val) to GPR + gen + COMMENT("move CONST->GPRE") + addi %2, R0, {CONST, lo(%1.val)} + + from CONST to GPR + gen + COMMENT("move CONST->GPRE") + addis %2, R0, {CONST, hi(%1.val)} + ori %2, %2, {CONST, lo(%1.val)} + + from LABEL to GPR + gen + COMMENT("move LABEL->GPR") + addis %2, R0, {HILABEL, %1.adr} + ori %2, %2, {LOLABEL, %1.adr} + +/* Sign extension */ + + from SEX_B to GPR + gen + COMMENT("move SEX_B->GPR") + extsb %2, %1.reg + + from SEX_H to GPR + gen + COMMENT("move SEX_H->GPR") + extsh %2, %1.reg + +/* Register + something */ + + from SUM_RC smalls(%off) to GPR + gen + COMMENT("move SUM_RC->GPR smalls") + addi %2, %1.reg, {CONST, lo(%1.off)} + + from SUM_RC to GPR + gen + COMMENT("move SUM_RC->GPR large") + addi %2, %1.reg, {CONST, los(%1.off)} + addis %2, %2, {CONST, his(%1.off)} + + from SUM_RR to GPR + gen + COMMENT("move SUM_RR->GPR") + add %2, %1.reg1, %1.reg2 + + from SUM_RR to GPR + gen + COMMENT("move SUM_RR->GPRE") + add %2, %1.reg1, %1.reg2 + +/* Read/write byte */ + + from IND_RC_B smalls(%off) to GPR + gen + COMMENT("move IND_RC_B->GPR small") + lbz %2, {GPRINDIRECT, %1.reg, %1.off} + + from IND_RC_B to GPR + gen + COMMENT("move IND_RC_B->GPR large") + addis SCRATCH, %1.reg, {CONST, his(%1.off)} + lbz %2, {GPRINDIRECT, SCRATCH, los(%1.off)} + + from GPR to IND_RC_B smalls(%off) + gen + COMMENT("move GPR->IND_RC_B small") + stb %1, {GPRINDIRECT, %2.reg, %2.off} + + from GPR to IND_RC_B + gen + COMMENT("move GPR->IND_RC_B large") + addis SCRATCH, %2.reg, {CONST, his(%2.off)} + stb %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + +/* Read/write short */ + + from IND_RC_H smalls(%off) to GPR + gen + COMMENT("move IND_RC_H->GPR small") + lhz %2, {GPRINDIRECT, %1.reg, %1.off} + + from IND_RC_H to GPR + gen + COMMENT("move IND_RC_H->GPR large") + addis SCRATCH, %1.reg, {CONST, his(%1.off)} + lhz %2, {GPRINDIRECT, SCRATCH, los(%1.off)} + + from IND_RC_H_S smalls(%off) to GPR + gen + COMMENT("move IND_RC_H_S->GPR small") + lha %2, {GPRINDIRECT, %1.reg, %1.off} + + from IND_RC_H_S to GPR + gen + COMMENT("move IND_RC_H_S->GPR large") + addis SCRATCH, %1.reg, {CONST, his(%1.off)} + lha %2, {GPRINDIRECT, SCRATCH, los(%1.off)} + + from GPR to IND_RC_H smalls(%off) + gen + COMMENT("move GPR->IND_RC_H small") + sth %1, {GPRINDIRECT, %2.reg, %2.off} + + from GPR to IND_RC_H + gen + COMMENT("move GPR->IND_RC_H large") + addis SCRATCH, %2.reg, {CONST, his(%2.off)} + sth %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + +/* Read word */ + + from IND_RC_W smalls(%off) to GPR + gen + COMMENT("move IND_RC_W->GPR small") + lwz %2, {GPRINDIRECT, %1.reg, %1.off} + + from IND_RC_W to GPR + gen + COMMENT("move IND_RC_W->GPR large") + addis %2, %1.reg, {CONST, his(%1.off)} + lwz %2, {GPRINDIRECT, %2, los(%1.off)} + + from IND_RR_W to GPR + gen + COMMENT("move IND_RR_W->GPR") + lwzx %2, %1.reg1, %1.reg2 + + from IND_LABEL_W to GPR + gen + COMMENT("move IND_LABEL_W->GPR") + move {LABEL, %1.adr}, SCRATCH + lwz %2, {GPRINDIRECT, SCRATCH, 0} + + from IND_RC_W smalls(%off) to FS + gen + COMMENT("move IND_RC_W->FS small") + lfs %2, {GPRINDIRECT, %1.reg, %1.off} + + from IND_RC_W to FS + gen + COMMENT("move IND_RC_W->FS large") + addis SCRATCH, %1.reg, {CONST, his(%1.off)} + lfs %2, {GPRINDIRECT, SCRATCH, los(%1.off)} + + from IND_RR_W to FS + gen + COMMENT("move IND_RR_W->FS") + lfsx %2, %1.reg1, %1.reg2 + + from IND_LABEL_W to FS + gen + COMMENT("move IND_LABEL_W->FS") + move {LABEL, %1.adr}, SCRATCH + lfs %2, {GPRINDIRECT, SCRATCH, 0} + +/* Write word */ + + from GPR to IND_RC_W smalls(%off) + gen + COMMENT("move GPR->IND_RC_W small") + stw %1, {GPRINDIRECT, %2.reg, %2.off} + + from GPR to IND_RC_W + gen + COMMENT("move GPR->IND_RC_W large") + addis SCRATCH, %2.reg, {CONST, his(%2.off)} + stw %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + + from GPR to IND_RR_W + gen + COMMENT("move GPR->IND_RR_W") + stwx %1, %2.reg1, %2.reg2 + + from GPR to IND_LABEL_W + gen + COMMENT("move GPR->IND_LABEL_D") + move {LABEL, %2.adr}, SCRATCH + stw %1, {GPRINDIRECT, SCRATCH, 0} + + from FS to IND_RC_W smalls(%off) + gen + COMMENT("move FS->IND_RC_W small") + stfs %1, {GPRINDIRECT, %2.reg, %2.off} + + from FS to IND_RC_W + gen + COMMENT("move FS->IND_RC_W large") + addis SCRATCH, %2.reg, {CONST, his(%2.off)} + stfs %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + + from FS to IND_RR_W + gen + COMMENT("move FS->IND_RR_W") + stfsx %1, %2.reg1, %2.reg2 + + from FS to IND_LABEL_W + gen + COMMENT("move FS->IND_LABEL_D") + move {LABEL, %2.adr}, SCRATCH + stfs %1, {GPRINDIRECT, SCRATCH, 0} + +/* Read double */ + + from IND_RC_D smalls(%off) to FD + gen + COMMENT("move IND_RC_D->FD small") + lfd %2, {GPRINDIRECT, %1.reg, %1.off} + + from IND_RC_D to FD + gen + COMMENT("move IND_RC_D->FD large") + addis SCRATCH, %1.reg, {CONST, his(%1.off)} + lfd %2, {GPRINDIRECT, SCRATCH, los(%1.off)} + + from IND_RR_D to FD + gen + COMMENT("move IND_RR_D->FD") + lfdx %2, %1.reg1, %1.reg2 + + from IND_LABEL_D to FD + gen + COMMENT("move IND_LABEL_D->FD") + move {LABEL, %1.adr}, SCRATCH + lfd %2, {GPRINDIRECT, SCRATCH, 0} + +/* Write double */ + + from FD to IND_RC_D smalls(%off) + gen + COMMENT("move FD->IND_RC_D small") + stfd %1, {GPRINDIRECT, %2.reg, %2.off} + + from FD to IND_RC_D + gen + COMMENT("move FD->IND_RC_D large") + addis SCRATCH, %2.reg, {CONST, his(%2.off)} + stfd %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + + from FD to IND_RR_D + gen + COMMENT("move FD->IND_RR_W") + stfdx %1, %2.reg1, %2.reg2 + + from FD to IND_LABEL_D + gen + COMMENT("move FD->IND_LABEL_D") + move {LABEL, %2.adr}, SCRATCH + stfd %1, {GPRINDIRECT, SCRATCH, 0} + +/* Extract condition code field (actually produces (CC&3)<<2) */ + + from CR0 to GPR + gen + COMMENT("move CR0->GPR") + mfcr %2 + rlwinm %2, %2, {CONST, 4}, {CONST, 32-4}, {CONST, 31-2} + +/* Comparisons */ + + from TRISTATE_RR_S to CR0 + gen + cmp %2, {CONST, 0}, %1.reg1, %1.reg2 + + from TRISTATE_RR_U to CR0 + gen + cmpl %2, {CONST, 0}, %1.reg1, %1.reg2 + + from TRISTATE_RC_S to CR0 + gen + COMMENT("move TRISTATE_RC_S->CR0 large") + move {CONST, %1.val}, SCRATCH + cmp %2, {CONST, 0}, %1.reg, SCRATCH + + from TRISTATE_RC_U smallu(%val) to CR0 + gen + COMMENT("move TRISTATE_RC_U->CR0 small") + cmpli %2, {CONST, 0}, %1.reg, {CONST, %1.val} + + from TRISTATE_RC_U to CR0 + gen + COMMENT("move TRISTATE_RC_U->CR0") + move {CONST, %1.val}, SCRATCH + cmpl %2, {CONST, 0}, %1.reg, SCRATCH + + from TRISTATE_FF to CR0 + gen + COMMENT("move TRISTATE_FF->CR0") + fcmpo %2, {FD, %1.reg1}, {FD, %1.reg2} + + from GPR to CR0 + gen + COMMENT("move GPR->CR0") + orX SCRATCH, %1, %1 /* alas, can't call test */ + + from TRISTATE_RR_S + TRISTATE_RC_S + TRISTATE_FF to GPR + gen + COMMENT("move TRISTATE_R*_S->GPR") + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tristate_s_table"}, %2 + lwzx %2, %2, SCRATCH + + from TRISTATE_RR_U + TRISTATE_RC_U to GPR + gen + COMMENT("move TRISTATE_R*_U->GPR") + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tristate_u_table"}, %2 + lwzx %2, %2, SCRATCH + +/* Logicals */ + + from NOT_R to GPR + gen + COMMENT("move NOT_R->GPR") + nor %2, %1.reg, %1.reg + + from AND_RR to GPR + gen + COMMENT("move AND_RR->GPR") + and %2, %1.reg1, %1.reg2 + + from AND_RC smallu(%val) to GPR + gen + COMMENT("move AND_RC->GPR small") + andiX %2, %1.reg, {CONST, %1.val} + + from AND_RC to GPR + gen + COMMENT("move AND_RC->GPR") + move {CONST, %1.val}, SCRATCH + and %2, %1.reg, SCRATCH + + from OR_RR to GPR + gen + COMMENT("move OR_RR->GPR") + or %2, %1.reg1, %1.reg2 + + from OR_RC smallu(%val) to GPR + gen + COMMENT("move OR_RC->GPR small") + ori %2, %1.reg, {CONST, %1.val} + + from OR_RC to GPR + gen + COMMENT("move OR_RC->GPR") + move {CONST, %1.val}, SCRATCH + or %2, %1.reg, SCRATCH + + from XOR_RR to GPR + gen + COMMENT("move XOR_RR->GPR") + xor %2, %1.reg1, %1.reg2 + + from XOR_RC smallu(%val) to GPR + gen + COMMENT("move XOR_RC->GPR small") + xori %2, %1.reg, {CONST, %1.val} + + from XOR_RC to GPR + gen + COMMENT("move XOR_RC->GPR") + move {CONST, %1.val}, SCRATCH + xor %2, %1.reg, SCRATCH + +/* Miscellaneous */ + + from OP_ALL_W + LABEL + CONST to GPRE + gen + move %1, %2.reg + + +TESTS + + to test GPR + gen + orX SCRATCH, %1, %1 + + + +STACKINGRULES + + from GPR to STACK + gen + COMMENT("stack GPR") + stwu %1, {GPRINDIRECT, SP, 0-4} + + from CONST to STACK + uses REG + gen + COMMENT("stack CONST") + move %1, %a + stwu %a, {GPRINDIRECT, SP, 0-4} + + from LABEL to STACK + uses REG + gen + COMMENT("stack LABEL") + move %1, {GPRE, %a} + stwu %a, {GPRINDIRECT, SP, 0-4} + + from SEX_B to STACK + gen + COMMENT("stack SEX_B") + extsb SCRATCH, %1.reg + stwu SCRATCH, {GPRINDIRECT, SP, 0-4} + + from SEX_H to STACK + gen + COMMENT("stack SEX_H") + extsh SCRATCH, %1.reg + stwu SCRATCH, {GPRINDIRECT, SP, 0-4} + + from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL to STACK + gen + move %1, {GPRE, SCRATCH} + stwu SCRATCH, {GPRINDIRECT, SP, 0-4} + + from IND_ALL_W to STACK + gen + move %1, SCRATCH + stwu SCRATCH, {GPRINDIRECT, SP, 0-4} + + from IND_ALL_D to STACK + gen + move %1, {FD, FSCRATCH} + stfdu {FD, FSCRATCH}, {GPRINDIRECT, SP, 0-8} + + from FD to STACK + gen + COMMENT("stack FD") + stfdu %1, {GPRINDIRECT, SP, 0-8} + + from FS to STACK + gen + COMMENT("stack FS") + stfsu %1, {GPRINDIRECT, SP, 0-4} + + from TOKEN to STACK + gen + invalid. + + + +COERCIONS + + from REG + uses REG + gen + COMMENT("coerce REG->REG") + move %1, %a + yields %a + + from CONST + uses REG + gen + COMMENT("coerce CONST->REG") + move %1, %a + yields %a + + from LABEL + uses REG + gen + COMMENT("coerce LABEL->REG") + move %1, {GPRE, %a} + yields %a + + from STACK + uses REG + gen + COMMENT("coerce STACK->REG") + lwz %a, {GPRINDIRECT, SP, 0} + addi SP, SP, {CONST, 4} + yields %a + + from SEX_B + uses REG + gen + COMMENT("coerce SEX_B->REG") + extsb %a, %1.reg + yields %a + + from SEX_H + uses REG + gen + COMMENT("coerce SEX_H->REG") + extsh %a, %1.reg + yields %a + + from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL + uses REG + gen + move %1, {GPRE, %a} + yields %a + + from FS + uses FREG + gen + fmr {FS, %a}, %1 + yields {FS, %a} + + from FD + uses FREG + gen + fmr {FD, %a}, %1 + yields {FD, %a} + + from STACK + uses FREG + gen + COMMENT("coerce STACK->FD") + lfd {FD, %a}, {GPRINDIRECT, SP, 0} + addi SP, SP, {CONST, 8} + yields {FD, %a} + + from STACK + uses FREG + gen + COMMENT("coerce STACK->FS") + lfs {FS, %a}, {GPRINDIRECT, SP, 0} + addi SP, SP, {CONST, 4} + yields {FS, %a} + + from IND_ALL_W + uses REG + gen + move %1, %a + yields %a + + from IND_ALL_W + uses FREG + gen + move %1, {FS, %a} + yields {FS, %a} + + from IND_ALL_D + uses FREG + gen + move %1, {FD, %a} + yields {FD, %a} + + + + +PATTERNS + +/* Intrinsics */ + + pat loc /* Load constant */ + yields {CONST, $1} + + pat dup $1==INT32 /* Duplicate word on top of stack */ + with GPR + yields %1 %1 + + pat dup $1==INT64 /* Duplicate double-word on top of stack */ + with GPR GPR + yields %2 %1 %2 %1 + + pat exg $1==INT32 /* Exchange top two words on stack */ + with GPR GPR + yields %1 %2 + + pat stl lol $1==$2 /* Store then load local */ + leaving + dup 4 + stl $1 + + pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */ + leaving + dup INT32 + lal $1 + sti $2 + + pat ste loe $1==$2 /* Store then load external */ + leaving + dup 4 + ste $1 + + +/* Type conversions */ + + pat loc loc cii loc loc cii $1==$4 && $2==$5 /* madness, generated by the C compiler */ + leaving + loc $1 + loc $2 + cii + + pat loc loc cii loc loc cii $2==INT32 && $5==INT32 && $4<$2 /* madness, generated by the C compiler */ + leaving + loc $4 + loc $5 + cii + + pat loc loc ciu /* signed X -> unsigned X */ + leaving + loc $1 + loc $2 + cuu + + pat loc loc cuu $1==$2 /* unsigned X -> unsigned X */ + /* nop */ + + pat loc loc cii $1==$2 /* signed X -> signed X */ + /* nop */ + + pat loc loc cui $1==$2 /* unsigned X -> signed X */ + /* nop */ + + pat loc loc cui $1==INT8 && $2==INT32 /* unsigned char -> signed int */ + /* nop */ + + pat loc loc cui $1==INT16 && $2==INT32 /* unsigned short -> signed int */ + /* nop */ + + pat loc loc cii $1==INT8 && $2==INT32 /* signed char -> signed int */ + with GPR + yields {SEX_B, %1} + + pat loc loc cii $1==2 && $2==4 /* signed char -> signed short */ + with GPR + yields {SEX_H, %1} + + + + + +/* Local variables */ + + pat lal /* Load address of local */ + yields {SUM_RC, FP, $1} + + pat lol inreg($1)>0 /* Load from local */ + yields {LOCAL, $1} + + pat lol /* Load from local */ + leaving + lal $1 + loi INT32 + + pat ldl /* Load double-word from local */ + leaving + lal $1 + loi INT32*2 + + pat stl inreg($1)>0 /* Store to local */ + with CONST + LABEL + GPR + OP_ALL_W + kills regvar($1), LOCAL %off==$1 + gen + move %1, {GPRE, regvar($1)} + + pat stl /* Store to local */ + leaving + lal $1 + sti INT32 + + pat sdl /* Store double-word to local */ + leaving + lal $1 + sti INT32*2 + + pat lil inreg($1)>0 /* Load from indirected local */ + uses REG + gen + lwz %a, {GPRINDIRECT, regvar($1), 0} + yields %a + + pat lil /* Load from indirected local */ + leaving + lol $1 + loi INT32 + + pat sil /* Save to indirected local */ + leaving + lol $1 + sti INT32 + + pat stl lol $1==$2 /* Save then load (generated by C compiler) */ + leaving + dup 4 + stl $1 + + pat zrl /* Zero local */ + leaving + loc 0 + stl $1 + + pat inl /* Increment local */ + leaving + lol $1 + loc 1 + adi 4 + stl $1 + + pat del /* Decrement local */ + leaving + lol $1 + loc 1 + sbi 4 + stl $1 + + +/* Global variables */ + + pat lpi /* Load address of external function */ + leaving + lae $1 + + pat lae /* Load address of external */ + yields {LABEL, $1} + + pat loe /* Load word external */ + leaving + lae $1 + loi INT32 + + pat ste /* Store word external */ + leaving + lae $1 + sti INT32 + + pat lde /* Load double-word external */ + leaving + lae $1 + loi INT64 + + pat sde /* Store double-word external */ + leaving + lae $1 + sti INT64 + + pat zre /* Zero external */ + leaving + loc 0 + ste $1 + + pat ine /* Increment external */ + uses REG={LABEL, $1}, REG + gen + lwz %b, {GPRINDIRECT, %a, 0} + addi %b, %b, {CONST, 1} + stw %b, {GPRINDIRECT, %a, 0} + + pat dee /* Decrement external */ + uses REG={LABEL, $1}, REG + gen + lwz %b, {GPRINDIRECT, %a, 0} + addi %b, %b, {CONST, 0-1} + stw %b, {GPRINDIRECT, %a, 0} + + + +/* Structures */ + + pat lof /* Load word offsetted */ + leaving + adp $1 + loi INT32 + + pat ldf /* Load double-word offsetted */ + leaving + adp $1 + loi INT64 + + pat stf /* Store word offsetted */ + leaving + adp $1 + sti INT32 + + pat sdf /* Store double-word offsetted */ + leaving + adp $1 + sti INT64 + + + +/* Loads and stores */ + + pat loi $1==INT8 /* Load byte indirect */ + with GPR + uses REG + gen + lbz %a, {GPRINDIRECT, %1, 0} + yields %a + with SUM_RR + uses reusing %1, REG + gen + lbzx %a, %1.reg1, %1.reg2 + yields %a + with SUM_RC + uses REG + gen + move {IND_RC_B, %1.reg, %1.off}, %a + yields %a + + pat loi loc loc cii $1==INT16 && $2==INT16 && $3==INT32 /* Load half-word indirect and sign extend */ + with GPR + uses REG + gen + lha %a, {GPRINDIRECT, %1, 0} + yields %a + with SUM_RR + uses reusing %1, REG + gen + lhax %a, %1.reg1, %1.reg2 + yields %a + with SUM_RC + uses REG + gen + move {IND_RC_H_S, %1.reg, %1.off}, %a + yields %a + + pat loi $1==INT16 /* Load half-word indirect */ + with GPR + uses REG + gen + lhz %a, {GPRINDIRECT, %1, 0} + yields %a + with SUM_RR + uses reusing %1, REG + gen + lhzx %a, %1.reg1, %1.reg2 + yields %a + with SUM_RC + uses REG + gen + move {IND_RC_H, %1.reg, %1.off}, %a + yields %a + + pat loi $1==INT32 /* Load word indirect */ + with GPR + yields {IND_RC_W, %1, 0} + with SUM_RC + yields {IND_RC_W, %1.reg, %1.off} + with SUM_RR + yields {IND_RR_W, %1.reg1, %1.reg2} + with LABEL + yields {IND_LABEL_W, %1.adr} + + pat loi $1==INT64 /* Load double-word indirect */ + with GPR + yields {IND_RC_D, %1, 0} + with SUM_RC + yields {IND_RC_D, %1.reg, %1.off} + with SUM_RR + yields {IND_RR_D, %1.reg1, %1.reg2} + with LABEL + yields {IND_LABEL_D, %1.adr} + + pat loi /* Load arbitrary size */ + leaving + loc $1 + los INT32 + + pat los /* Load arbitrary size */ + with GPR3 GPR4 STACK + kills ALL + gen + bl {LABEL, ".los"} + + pat sti $1==INT8 /* Store byte indirect */ + with GPR GPR + gen + stb %2, {GPRINDIRECT, %1, 0} + with SUM_RR GPR + gen + stbx %2, %1.reg1, %1.reg2 + with SUM_RC GPR + gen + move %2, {IND_RC_B, %1.reg, %1.off} + with GPR SEX_B + gen + stb %2.reg, {GPRINDIRECT, %1, 0} + with SUM_RR SEX_B + gen + stbx %2.reg, %1.reg1, %1.reg2 + with SUM_RC SEX_B + gen + move %2.reg, {IND_RC_B, %1.reg, %1.off} + + pat sti $1==INT16 /* Store half-word indirect */ + with GPR GPR + gen + sth %2, {GPRINDIRECT, %1, 0} + with SUM_RR GPR + gen + sthx %2, %1.reg1, %1.reg2 + with SUM_RC GPR + gen + move %2, {IND_RC_H, %1.reg, %1.off} + with GPR SEX_H + gen + sth %2.reg, {GPRINDIRECT, %1, 0} + with SUM_RR SEX_H + gen + sthx %2.reg, %1.reg1, %1.reg2 + with SUM_RC SEX_H + gen + move %2.reg, {IND_RC_H, %1.reg, %1.off} + + pat sti $1==INT32 /* Store word indirect */ + with GPR GPR+FS + gen + move %2, {IND_RC_W, %1, 0} + with SUM_RR GPR+FS + gen + move %2, {IND_RR_W, %1.reg1, %1.reg2} + with SUM_RC GPR+FS + gen + move %2, {IND_RC_W, %1.reg, %1.off} + with LABEL GPR+FS + gen + move %2, {IND_LABEL_W, %1.adr} + + pat sti $1==INT64 /* Store double-word indirect */ + with GPR FD + gen + move %2, {IND_RC_D, %1, 0} + with SUM_RR FD + gen + move %2, {IND_RR_D, %1.reg1, %1.reg2} + with SUM_RC FD + gen + move %2, {IND_RC_D, %1.reg, %1.off} + with GPR GPR GPR + gen + stw %2, {GPRINDIRECT, %1, 0} + stw %3, {GPRINDIRECT, %1, 4} + with SUM_RC GPR GPR + gen + move %2, {IND_RC_W, %1.reg, %1.off} + move %3, {IND_RC_W, %1.reg, %1.off+4} + with LABEL FD + gen + move %2, {IND_LABEL_D, %1.adr} + + + pat sti /* Store arbitrary size */ + leaving + loc $1 + sts INT32 + + pat sts /* Load arbitrary size */ + with GPR3 GPR4 STACK + kills ALL + gen + bl {LABEL, ".sts"} + + + +/* Arithmetic wrappers */ + + pat ads $1==4 /* Add var to pointer */ + leaving adi $1 + + pat sbs $1==4 /* Subtract var from pointer */ + leaving sbi $1 + + pat adp /* Add constant to pointer */ + leaving + loc $1 + adi 4 + + pat adu /* Add unsigned */ + leaving + adi $1 + + pat sbu /* Subtract unsigned */ + leaving + sbi $1 + + pat inc /* Add 1 */ + leaving + loc 1 + adi 4 + + pat dec /* Subtract 1 */ + leaving + loc 1 + sbi 4 + + pat loc mlu $2==2 /* Unsigned multiply by constant */ + leaving + loc $1 + mli 4 + + pat mlu /* Unsigned multiply by var */ + leaving + mli $1 + + pat loc slu /* Shift left unsigned by constant amount */ + leaving + loc $1 + sli $2 + + pat slu /* Shift left unsigned by variable amount */ + leaving + sli $1 + + + +/* Word arithmetic */ + + pat adi $1==4 /* Add word (second + top) */ + with REG REG + yields {SUM_RR, %1, %2} + with CONST REG + yields {SUM_RC, %2, %1.val} + with REG CONST + yields {SUM_RC, %1, %2.val} + with CONST SUM_RC + yields {SUM_RC, %2.reg, %2.off+%1.val} + with CONST LABEL + yields {LABEL, %2.adr+%1.val} + + pat sbi $1==4 /* Subtract word (second - top) */ + with REG REG + uses reusing %2, REG + gen + subf %a, %1, %2 + yields %a + with CONST REG + yields {SUM_RC, %2, 0-%1.val} + with CONST SUM_RC + yields {SUM_RC, %2.reg, %2.off-%1.val} + with CONST LABEL + yields {LABEL, %2.adr+(0-%1.val)} + + pat ngi $1==4 /* Negate word */ + with REG + uses reusing %1, REG + gen + neg %a, %1 + yields %a + + pat mli $1==4 /* Multiply word (second * top) */ + with REG REG + uses reusing %2, REG + gen + mullw %a, %2, %1 + yields %a + + pat dvi $1==4 /* Divide word (second / top) */ + with REG REG + uses reusing %2, REG + gen + divw %a, %2, %1 + yields %a + + pat dvu $1==4 /* Divide unsigned word (second / top) */ + with REG REG + uses reusing %2, REG + gen + divwu %a, %2, %1 + yields %a + + pat rmi $1==4 /* Remainder word (second % top) */ + with REG REG + uses REG + gen + divw %a, %2, %1 + mullw %a, %a, %1 + subf %a, %a, %2 + yields %a + + pat rmu $1==4 /* Remainder unsigned word (second % top) */ + with REG REG + uses REG + gen + divwu %a, %2, %1 + mullw %a, %a, %1 + subf %a, %a, %2 + yields %a + + pat and $1==4 /* AND word */ + with GPR NOT_R + uses reusing %1, REG + gen + andc %a, %1, %2.reg + yields %a + with NOT_R GPR + uses reusing %1, REG + gen + andc %a, %2, %1.reg + yields %a + with GPR GPR + yields {AND_RR, %1, %2} + with GPR CONST + yields {AND_RC, %1, %2.val} + with CONST GPR + yields {AND_RC, %2, %1.val} + + pat and !defined($1) /* AND set */ + with STACK + gen + bl {LABEL, ".and"} + + pat ior $1==4 /* OR word */ + with GPR NOT_R + uses reusing %1, REG + gen + orc %a, %1, %2.reg + yields %a + with NOT_R GPR + uses reusing %2, REG + gen + orc %a, %2, %1.reg + yields %a + with GPR GPR + yields {OR_RR, %1, %2} + with GPR CONST + yields {OR_RC, %1, %2.val} + with CONST GPR + yields {OR_RC, %2, %1.val} + + pat ior !defined($1) /* OR set */ + with STACK + gen + bl {LABEL, ".ior"} + + pat xor $1==4 /* XOR word */ + with GPR GPR + yields {XOR_RR, %1, %2} + with GPR CONST + yields {XOR_RC, %1, %2.val} + with CONST GPR + yields {XOR_RC, %2, %1.val} + + pat xor !defined($1) /* XOR set */ + with STACK + gen + bl {LABEL, ".xor"} + + pat com $1==INT32 /* NOT word */ + with AND_RR + uses REG + gen + nand %a, %1.reg1, %1.reg2 + yields %a + with OR_RR + uses REG + gen + nor %a, %1.reg1, %1.reg2 + yields %a + with XOR_RR + uses REG + gen + eqv %a, %1.reg1, %1.reg2 + yields %a + with GPR + yields {NOT_R, %1} + + pat com !defined($1) /* NOT set */ + with STACK + gen + bl {LABEL, ".com"} + + pat sli $1==4 /* Shift left (second << top) */ + with CONST GPR + uses reusing %2, REG + gen + rlwinm %a, %2, {CONST, (%1.val & 0x1F)}, {CONST, 0}, {CONST, 31-(%1.val & 0x1F)} + yields %a + with GPR GPR + uses reusing %2, REG + gen + slw %a, %2, %1 + yields %a + + pat sri $1==4 /* Shift right signed (second >> top) */ + with CONST GPR + uses reusing %2, REG + gen + srawi %a, %2, {CONST, %1.val & 0x1F} + yields %a + with GPR GPR + uses reusing %2, REG + gen + sraw %a, %2, %1 + yields %a + + pat sru $1==4 /* Shift right unsigned (second >> top) */ + with CONST GPR + uses reusing %2, REG + gen + rlwinm %a, %2, {CONST, 32-(%1.val & 0x1F)}, {CONST, (%1.val & 0x1F)}, {CONST, 31} + yields %a + with GPR GPR + uses reusing %2, REG + gen + srw %a, %2, %1 + yields %a + + + +/* Arrays */ + + pat aar $1==INT32 /* Index array */ + with GPR3 GPR4 GPR5 + gen + bl {LABEL, ".aar4"} + yields R3 + + pat lae lar $2==INT32 && nicesize(rom($1, 3)) /* Load array */ + leaving + lae $1 + aar INT32 + loi rom($1, 3) + + pat lar $1==INT32 /* Load array */ + with GPR3 GPR4 GPR5 STACK + kills ALL + gen + bl {LABEL, ".lar4"} + + pat lae sar $2==INT32 && nicesize(rom($1, 3)) /* Store array */ + leaving + lae $1 + aar INT32 + sti rom($1, 3) + + pat sar $1==INT32 /* Store array */ + with GPR3 GPR4 GPR5 STACK + kills ALL + gen + bl {LABEL, ".sar4"} + + + + +/* Sets */ + + pat set defined($1) /* Create word with set bit */ + leaving + loc 1 + exg INT32 + sli INT32 + + pat set !defined($1) /* Create structure with set bit (variable) */ + with GPR3 GPR4 STACK + gen + bl {LABEL, ".set"} + + pat inn defined($1) /* Test for set bit */ + leaving + set INT32 + and INT32 + + pat inn !defined($1) /* Test for set bit (variable) */ + with GPR3 STACK + gen + bl {LABEL, ".inn"} + + + +/* Boolean resolutions */ + + pat teq /* top = (top == 0) */ + with TRISTATE_ALL + GPR + uses reusing %1, REG + gen + move %1, C0 + move C0, SCRATCH + move {LABEL, ".teq_table"}, %a + lwzx %a, %a, SCRATCH + yields %a + + pat tne /* top = (top != 0) */ + with TRISTATE_ALL + GPR + uses reusing %1, REG + gen + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tne_table"}, %a + lwzx %a, %a, SCRATCH + yields %a + + pat tlt /* top = (top < 0) */ + with TRISTATE_ALL + GPR + uses reusing %1, REG + gen + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tlt_table"}, %a + lwzx %a, %a, SCRATCH + yields %a + + pat tle /* top = (top <= 0) */ + with TRISTATE_ALL + GPR + uses reusing %1, REG + gen + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tle_table"}, %a + lwzx %a, %a, SCRATCH + yields %a + + pat tgt /* top = (top > 0) */ + with TRISTATE_ALL + GPR + uses reusing %1, REG + gen + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tgt_table"}, %a + lwzx %a, %a, SCRATCH + yields %a + + pat tge /* top = (top >= 0) */ + with TRISTATE_ALL + GPR + uses reusing %1, REG + gen + move %1, C0 + move C0, SCRATCH + move {LABEL, ".tge_table"}, %a + lwzx %a, %a, SCRATCH + yields %a + + + + +/* Simple branches */ + + pat zeq /* Branch if signed top == 0 */ + with TRISTATE_ALL+GPR STACK + gen + move %1, C0 + bc IFTRUE, EQ, {LABEL, $1} + + pat beq + leaving + cmi INT32 + zeq $1 + + pat zne /* Branch if signed top != 0 */ + with TRISTATE_ALL+GPR STACK + gen + move %1, C0 + bc IFFALSE, EQ, {LABEL, $1} + + pat bne + leaving + cmi INT32 + zne $1 + + pat zgt /* Branch if signed top > 0 */ + with TRISTATE_ALL+GPR STACK + gen + move %1, C0 + bc IFTRUE, GT, {LABEL, $1} + + pat bgt + leaving + cmi INT32 + zgt $1 + + pat zge /* Branch if signed top >= 0 */ + with TRISTATE_ALL+GPR STACK + gen + move %1, C0 + bc IFFALSE, LT, {LABEL, $1} + + pat bge + leaving + cmi INT32 + zge $1 + + pat zlt /* Branch if signed top < 0 */ + with TRISTATE_ALL+GPR STACK + gen + move %1, C0 + bc IFTRUE, LT, {LABEL, $1} + + pat blt + leaving + cmi INT32 + zlt $1 + + pat zle /* Branch if signed top >= 0 */ + with TRISTATE_ALL+GPR STACK + gen + move %1, C0 + bc IFFALSE, GT, {LABEL, $1} + + pat ble + leaving + cmi INT32 + zle $1 + + +/* Compare and jump */ + + pat cmi /* Signed tristate compare */ + with CONST GPR + yields {TRISTATE_RC_S, %2, %1.val} + with GPR GPR + yields {TRISTATE_RR_S, %2, %1} + + pat cmu /* Unsigned tristate compare */ + with CONST GPR + yields {TRISTATE_RC_U, %2, %1.val} + with GPR GPR + yields {TRISTATE_RR_U, %2, %1} + + pat cmp /* Compare pointers */ + leaving + cmu INT32 + + pat cms $1==INT32 /* Compare blocks (word sized) */ + leaving + cmi INT32 + + + + +/* Other branching and labelling */ + + pat lab topeltsize($1)==4 && !fallthrough($1) + gen + labeldef $1 + yields R3 + + pat lab topeltsize($1)==4 && fallthrough($1) + with GPR3 + gen + labeldef $1 + yields %1 + + pat lab topeltsize($1)!=4 + with STACK + kills ALL + gen + labeldef $1 + + pat bra topeltsize($1)==4 /* Unconditional jump with TOS GPRister */ + with GPR3 STACK + gen + b {LABEL, $1} + + pat bra topeltsize($1)!=4 /* Unconditional jump without TOS GPRister */ + with STACK + gen + b {LABEL, $1} + + + +/* Miscellaneous */ + + pat cal /* Call procedure */ + with STACK + kills ALL + gen + bl {LABEL, $1} + + pat cai /* Call procedure indirect */ + with GPR STACK + kills ALL + gen + mtspr CTR, %1 + bcctrl ALWAYS, {CONST, 0}, {CONST, 0} + + pat lfr $1==INT32 /* Load function result, word */ + yields R3 + + pat lfr $1==INT64 /* Load function result, double-word */ + yields R4 R3 + + pat ret $1==0 /* Return from procedure */ + gen + return + b {LABEL, ".ret"} + + pat ret $1==INT32 /* Return from procedure, word */ + with GPR3 + gen + return + b {LABEL, ".ret"} + + pat ret $1==INT64 /* Return from procedure, double-word */ + with GPR3 GPR4 + gen + return + b {LABEL, ".ret"} + + pat blm /* Block move constant length */ + with GPR GPR STACK + uses REG + gen + move {CONST, $1}, %a + stwu %a, {GPRINDIRECT, SP, 0-4} + stwu %2, {GPRINDIRECT, SP, 0-4} + stwu %1, {GPRINDIRECT, SP, 0-4} + bl {LABEL, "_memmove"} + addi SP, SP, {CONST, 12} + + pat bls /* Block move variable length */ + with GPR GPR GPR STACK + gen + stwu %1, {GPRINDIRECT, SP, 0-4} + stwu %3, {GPRINDIRECT, SP, 0-4} + stwu %2, {GPRINDIRECT, SP, 0-4} + bl {LABEL, "_memmove"} + addi SP, SP, {CONST, 12} + + pat csa /* Array-lookup switch */ + with GPR3 GPR4 STACK + gen + b {LABEL, ".csa"} + + pat csb /* Table-lookup switch */ + with GPR3 GPR4 STACK + gen + b {LABEL, ".csb"} + + + +/* EM specials */ + + pat fil /* Set current filename */ + leaving + lae $1 + ste ".filename" + + pat lin /* Set current line number */ + leaving + loc $1 + ste ".linenumber" + + pat lni /* Increment line number */ + leaving + ine ".linenumber" + + pat lim /* Load EM trap ignore mask */ + leaving + lde ".ignmask" + + pat sim /* Store EM trap ignore mask */ + leaving + ste ".ignmask" + + pat trp /* Raise EM trap */ + with GPR3 + gen + bl {LABEL, ".trap"} + + pat sig /* Set trap handler */ + leaving + ste ".trppc" + + pat rtt /* Return from trap */ + leaving + ret 0 + + pat lxl $1==0 /* Load FP */ + leaving + lor 0 + + pat lxl $1==1 /* Load caller's FP */ + leaving + lxl 0 + dch + + pat dch /* FP -> caller FP */ + with GPR + uses reusing %1, REG + gen + lwz %a, {GPRINDIRECT, %1, FP_OFFSET} + yields %a + + pat lpb /* Convert FP to argument address */ + leaving + adp EM_BSIZE + + pat lxa /* Load caller's SP */ + leaving + lxl $1 + lpb + + pat gto /* longjmp */ + uses REG + gen + move {LABEL, $1}, %a + move {IND_RC_W, %a, 8}, FP + move {IND_RC_W, %a, 4}, SP + move {IND_RC_W, %a, 0}, %a + mtspr CTR, %a + bcctr ALWAYS, {CONST, 0}, {CONST, 0} + +#if 0 + + pat gto /* longjmp */ + with STACK + gen + ld {LABEL, $1+2} + wspec {CONST, 1} + ld {LABEL, $1+4} + wspec {CONST, 0} + ld {LABEL, $1+0} + wspec {CONST, 2} + + pat str $1==1 /* Store special GPRister */ + with GPR0 + gen + wspec {CONST, $1} + +#endif + + pat lor $1==0 /* Load FP */ + uses REG + gen + move FP, %a + yields %a + + pat lor $1==1 /* Load SP */ + uses REG + gen + move SP, %a + yields %a + + pat lor $1==2 /* Load HP */ + leaving + loe ".reghp" + + pat str $1==0 /* Store FP */ + with GPR + gen + move %1, FP + + pat str $1==1 /* Store SP */ + with GPR + gen + move %1, SP + + pat str $1==2 /* Store HP */ + leaving + ste ".reghp" + + pat ass /* Adjust stack by variable amount */ + with CONST + gen + move {SUM_RC, SP, %1.val}, {GPRE, SP} + with GPR + gen + move {SUM_RR, SP, %1}, {GPRE, SP} + + pat asp /* Adjust stack by constant amount */ + leaving + loc $1 + ass + diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s new file mode 100644 index 000000000..894a7540e --- /dev/null +++ b/mach/vc4/test/opcodes.s @@ -0,0 +1,77 @@ +# +/* + * VideoCore IV assembler test file + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +main: + nop + rti + + b r0 + b r31 + bl r0 + bl r31 + tbb r0 + tbb r15 + tbs r0 + tbs r15 + + mov r0, r1 + cmn r0, r1 + add r0, r1 + bic r0, r1 + mul r0, r1 + eor r0, r1 + sub r0, r1 + and r0, r1 + mvn r0, r1 + ror r0, r1 + cmp r0, r1 + rsb r0, r1 + btst r0, r1 + or r0, r1 + extu r0, r1 + max r0, r1 + bset r0, r1 + min r0, r1 + bclr r0, r1 + adds2 r0, r1 + bchg r0, r1 + adds4 r0, r1 + adds8 r0, r1 + adds16 r0, r1 + exts r0, r1 + neg r0, r1 + lsr r0, r1 + clz r0, r1 + lsl r0, r1 + brev r0, r1 + asr r0, r1 + abs r0, r1 + + mov r0, #31 + cmn r0, #31 + add r0, #31 + bic r0, #31 + mul r0, #31 + eor r0, #31 + sub r0, #31 + and r0, #31 + mvn r0, #31 + ror r0, #31 + cmp r0, #31 + rsb r0, #31 + btst r0, #31 + or r0, #31 + extu r0, #31 + max r0, #31 + diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk new file mode 100644 index 000000000..20aed87f7 --- /dev/null +++ b/plat/rpi/build.mk @@ -0,0 +1,47 @@ +# Build script for Raspberry Pi bare-metal executables (using the +# VideoCore IV processor, not the ARM). +# +# © 2013 David Given +# This file is redistributable under the terms of the 3-clause BSD license. +# See the file 'Copying' in the root of the distribution for the full text. + +ARCH := vc4 +PLATFORM := rpi +OPTIMISATION := -O + +D := plat/rpi/ + +platform-headers := \ + ack/config.h + +platform-libsys := \ + _hol0.s \ + +ifeq (x,y) + errno.s \ + _sys_rawread.s \ + _sys_rawwrite.s \ + open.c \ + creat.c \ + close.c \ + read.c \ + write.c \ + brk.c \ + getpid.c \ + kill.c \ + isatty.c \ + lseek.c \ + time.c \ + signal.c +endif + +$(eval $(call build-platform)) + +define build-rpi-boot-impl + $(call reset) + $(call ackfile, $D/boot.s) + $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) +endef + +#(eval $(build-rpi-boot-impl)) + diff --git a/plat/rpi/descr b/plat/rpi/descr new file mode 100644 index 000000000..41dfc400f --- /dev/null +++ b/plat/rpi/descr @@ -0,0 +1,69 @@ +# $Source$ +# $State$ +# $Revision$ + +var w=2 +var p=2 +var s=2 +var l=4 +var f=4 +var d=8 +var ARCH=vc4 +var PLATFORM=rpi +var PLATFORMDIR={EM}/share/ack/{PLATFORM} +var CPP_F=-D__unix +var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 +var MACHOPT_F=-m8 + +# 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 be + from .m.g + to .s + program {EM}/lib/ack/{PLATFORM}/ncg + args < + stdout + need .e +end +name as + from .s.so + to .o + program {EM}/lib/ack/{PLATFORM}/as + args - -o > < + prep cond +end +name led + from .o.a + to .out + program {EM}/lib/ack/em_led + mapflag -l* LNAME={PLATFORMDIR}/lib* + mapflag -i SEPID=-b1:0 + mapflag -fp FLOATS={EM}/{ILIB}fp + args {ALIGN} {SEPID?} \ + (.e:{HEAD}={PLATFORMDIR}/boot.o) \ + ({RTS}:.ocm.b={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.c={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.mod={PLATFORMDIR}/modula2.o) \ + ({RTS}:.p={PLATFORMDIR}/pascal.o) \ + -o > < \ + (.p:{TAIL}={PLATFORMDIR}/libpascal.a) \ + (.b:{TAIL}={PLATFORMDIR}/libbasic.a) \ + (.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \ + (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ + (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ + {FLOATS?} \ + (.e:{TAIL}={PLATFORMDIR}/libem.a \ + {PLATFORMDIR}/libsys.a \ + {PLATFORMDIR}/libend.a) + linker +end +name cv + from .out + to .img + program {EM}/bin/aslod + args < > + outfile raspberrypi.bin +end diff --git a/plat/rpi/include/ack/config.h b/plat/rpi/include/ack/config.h new file mode 100644 index 000000000..fd2c48cba --- /dev/null +++ b/plat/rpi/include/ack/config.h @@ -0,0 +1,11 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _ACK_CONFIG_H +#define _ACK_CONFIG_H + +#endif diff --git a/plat/rpi/include/unistd.h b/plat/rpi/include/unistd.h new file mode 100644 index 000000000..ddd8739d3 --- /dev/null +++ b/plat/rpi/include/unistd.h @@ -0,0 +1,73 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#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 void* sbrk(intptr_t 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/plat/rpi/libsys/_hol0.s b/plat/rpi/libsys/_hol0.s new file mode 100644 index 000000000..eed00817d --- /dev/null +++ b/plat/rpi/libsys/_hol0.s @@ -0,0 +1,22 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .bss + +! This data block is used to store information about the current line number +! and file. + +.define hol0 +.comm hol0, 8 diff --git a/plat/rpi/libsys/_sys_rawread.s b/plat/rpi/libsys/_sys_rawread.s new file mode 100644 index 000000000..02edba21a --- /dev/null +++ b/plat/rpi/libsys/_sys_rawread.s @@ -0,0 +1,26 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +! Reads a single byte. + +.define __sys_rawread +__sys_rawread: + xorb ah, ah + int 0x16 + xorb ah, ah + ret + \ No newline at end of file diff --git a/plat/rpi/libsys/_sys_rawwrite.s b/plat/rpi/libsys/_sys_rawwrite.s new file mode 100644 index 000000000..a424574d7 --- /dev/null +++ b/plat/rpi/libsys/_sys_rawwrite.s @@ -0,0 +1,32 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +! Writes a single byte to the console. + +.define __sys_rawwrite +.extern __sys_rawwrite + +__sys_rawwrite: + push bp + mov bp, sp + + movb al, 4(bp) + movb ah, 0x0E + mov bx, 0x0007 + int 0x10 + jmp .cret + \ No newline at end of file diff --git a/plat/rpi/libsys/brk.c b/plat/rpi/libsys/brk.c new file mode 100644 index 000000000..cff32b9a9 --- /dev/null +++ b/plat/rpi/libsys/brk.c @@ -0,0 +1,45 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +#define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ +#define STACK_BUFFER 128 /* number of bytes to leave for stack */ + +extern char _end[1]; +static char* current = _end; + +int brk(void* newend) +{ + /* This variable is used to figure out the current stack pointer, + * by taking its address. */ + char dummy; + char* p = newend; + + if ((p > (&dummy - STACK_BUFFER)) || + (p < _end)) + return -1; + + current = p; + return 0; +} + +void* sbrk(intptr_t increment) +{ + char* old; + + if (increment == 0) + return current; + + old = current; + if (brk(old + increment) < 0) + return OUT_OF_MEMORY; + + return old; +} diff --git a/plat/rpi/libsys/close.c b/plat/rpi/libsys/close.c new file mode 100644 index 000000000..60fa0f96b --- /dev/null +++ b/plat/rpi/libsys/close.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +int close(int fd) +{ + errno = EBADF; + return -1; +} diff --git a/plat/rpi/libsys/creat.c b/plat/rpi/libsys/creat.c new file mode 100644 index 000000000..7c009e6a0 --- /dev/null +++ b/plat/rpi/libsys/creat.c @@ -0,0 +1,17 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include "libsys.h" + +int open(const char* path, int access, ...) +{ + errno = EACCES; + return -1; +} diff --git a/plat/rpi/libsys/errno.s b/plat/rpi/libsys/errno.s new file mode 100644 index 000000000..a2e1f8b55 --- /dev/null +++ b/plat/rpi/libsys/errno.s @@ -0,0 +1,31 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +#define D(e) .define e; e + +.sect .data + +! Define various ACK error numbers. Note that these are *not* ANSI C +! errnos, and are used for different purposes. + +D(ERANGE) = 1 +D(ESET) = 2 +D(EIDIVZ) = 6 +D(EHEAP) = 17 +D(EILLINS) = 18 +D(EODDZ) = 19 +D(ECASE) = 20 +D(EBADMON) = 25 + diff --git a/plat/rpi/libsys/getpid.c b/plat/rpi/libsys/getpid.c new file mode 100644 index 000000000..0ae1f6154 --- /dev/null +++ b/plat/rpi/libsys/getpid.c @@ -0,0 +1,15 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +pid_t getpid(void) +{ + return 0; +} diff --git a/plat/rpi/libsys/isatty.c b/plat/rpi/libsys/isatty.c new file mode 100644 index 000000000..83837ba9c --- /dev/null +++ b/plat/rpi/libsys/isatty.c @@ -0,0 +1,15 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +int isatty(int fd) +{ + return 1; +} diff --git a/plat/rpi/libsys/kill.c b/plat/rpi/libsys/kill.c new file mode 100644 index 000000000..bacc405df --- /dev/null +++ b/plat/rpi/libsys/kill.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +int kill(pid_t pid, int sig) +{ + errno = EINVAL; + return -1; +} diff --git a/plat/rpi/libsys/libsys.h b/plat/rpi/libsys/libsys.h new file mode 100644 index 000000000..e9bff7e1a --- /dev/null +++ b/plat/rpi/libsys/libsys.h @@ -0,0 +1,18 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef LIBSYS_H +#define LIBSYS_H + +extern void _sys_rawwrite(unsigned char b); +extern unsigned char _sys_rawread(void); + +extern void _sys_write_tty(char c); + +/* extern int _sys_ttyflags; */ + +#endif diff --git a/plat/rpi/libsys/lseek.c b/plat/rpi/libsys/lseek.c new file mode 100644 index 000000000..9a487d747 --- /dev/null +++ b/plat/rpi/libsys/lseek.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +off_t lseek(int fd, off_t offset, int whence) +{ + errno = EINVAL; + return -1; +} diff --git a/plat/rpi/libsys/open.c b/plat/rpi/libsys/open.c new file mode 100644 index 000000000..cbdc30ec1 --- /dev/null +++ b/plat/rpi/libsys/open.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include "libsys.h" + +int creat(const char* path, int mode) +{ + return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); +} diff --git a/plat/rpi/libsys/read.c b/plat/rpi/libsys/read.c new file mode 100644 index 000000000..476689320 --- /dev/null +++ b/plat/rpi/libsys/read.c @@ -0,0 +1,45 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include "libsys.h" + +int read(int fd, void* buffer, size_t count) +{ + char i; + + /* We're only allowed to read from fd 0, 1 or 2. */ + + if ((fd < 0) || (fd > 2)) + { + errno = EBADF; + return -1; + } + + /* Empty buffer? */ + + if (count == 0) + return 0; + + /* Read one byte. */ + + i = _sys_rawread(); +#if 0 + if ((i == '\r') && !(_sys_ttyflags & RAW)) + i = '\n'; + if (_sys_ttyflags & ECHO) + _sys_write_tty(i); +#endif + if (i == '\r') + i = '\n'; + _sys_write_tty(i); + + *(char*)buffer = i; + return 1; +} diff --git a/plat/rpi/libsys/signal.c b/plat/rpi/libsys/signal.c new file mode 100644 index 000000000..10a2ded29 --- /dev/null +++ b/plat/rpi/libsys/signal.c @@ -0,0 +1,17 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +sighandler_t signal(int signum, sighandler_t handler) +{ + return SIG_DFL; +} diff --git a/plat/rpi/libsys/time.c b/plat/rpi/libsys/time.c new file mode 100644 index 000000000..e448a33d0 --- /dev/null +++ b/plat/rpi/libsys/time.c @@ -0,0 +1,19 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +time_t time(time_t* t) +{ + if (t) + *t = 0; + return 0; +} diff --git a/plat/rpi/libsys/write.c b/plat/rpi/libsys/write.c new file mode 100644 index 000000000..9a765b04c --- /dev/null +++ b/plat/rpi/libsys/write.c @@ -0,0 +1,50 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include "libsys.h" + +void _sys_write_tty(char c) +{ + _sys_rawwrite(c); +#if 0 + if ((c == '\n') && !(_sys_ttyflags & RAW)) + _sys_rawwrite('\r'); +#endif + if (c == '\n') + _sys_rawwrite('\r'); +} + +int write(int fd, void* buffer, size_t count) +{ + int i; + char* p = buffer; + + /* We're only allowed to write to fd 0, 1 or 2. */ + + if ((fd < 0) || (fd > 2)) + { + errno = EBADF; + return -1; + } + + /* Write all data. */ + + i = 0; + while (i < count) + { + _sys_write_tty(*p++); + + i++; + } + + /* No failures. */ + + return count; +} From e7c2029c9c32603cc15c2cb8af1922b9e4543143 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 17 May 2013 00:04:37 +0100 Subject: [PATCH 020/231] Dependency fixes. --- first/core.mk | 2 +- mach/proto/as/build.mk | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/first/core.mk b/first/core.mk index 1dc82c5b9..d2e32fc68 100644 --- a/first/core.mk +++ b/first/core.mk @@ -93,7 +93,7 @@ endef # --- ACK library linking define acklibrary-rule -$o: $s $(ACKAR) +$o: $s $(AAL) @echo ACKLIBRARY $o @mkdir -p $(dir $o) @$(RM) $o diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 039630f75..64eaab1e9 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -25,7 +25,9 @@ define build-as-impl $(call yacc, $(OBJDIR)/$D, $(OBJDIR)/$D/preprocessed-comm2.y) $(eval CLEANABLES += $(OBJDIR)/$D/preprocessed-comm2.y) -$(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) +$(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ + mach/$(ARCH)/as/mach2.c \ + mach/$(ARCH)/as/mach4.c @echo PREPROCESS $$@ @mkdir -p $$(dir $$@) $(hide) $(CPPANSI) -P \ From 9a513e8ef3d390b7fd41a2c7299dad2e6bb4bcb8 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 17 May 2013 00:04:54 +0100 Subject: [PATCH 021/231] Fix warning. --- lang/m2/comp/defmodule.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index fc83d36fd..f26168a28 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -12,6 +12,7 @@ #include "parameters.h" #include "debug.h" +#include #include #include #include From 5378e3fe53d86c5ea55f8f096f959ec95ecfc4aa Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 17 May 2013 22:40:50 +0100 Subject: [PATCH 022/231] Add special relocation type for VC4 jump instructions. --HG-- branch : dtrg-videocore --- h/out.h | 1 + util/amisc/ashow.c | 3 +++ util/led/ack.out.5 | 1 + util/led/relocate.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/h/out.h b/h/out.h index 122296f8e..2c97219e5 100644 --- a/h/out.h +++ b/h/out.h @@ -64,6 +64,7 @@ struct outname { #define RELO4 3 /* 4 bytes */ #define RELOPPC 4 /* PowerPC 26-bit address */ #define RELOH2 5 /* write top 2 bytes of 4 byte word */ +#define RELOVC4 6 /* VideoCore IV address in 32-bit instruction */ #define RELPC 0x08 /* pc relative */ #define RELBR 0x10 /* High order byte lowest address. */ diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index 5f22827ee..67e785ecc 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -143,6 +143,9 @@ showrelo() case RELOH2: printf("\ttop 2 bytes of a 4 byte word\n"); break; + case RELOVC4: + printf("\tVideoCore IV address in 32-bit instruction\n"); + break; default: printf("\tunknown relocation type %d\n", relrec.or_type & RELSZ); break; diff --git a/util/led/ack.out.5 b/util/led/ack.out.5 index 8e85b3f92..d9e24bff6 100644 --- a/util/led/ack.out.5 +++ b/util/led/ack.out.5 @@ -164,6 +164,7 @@ struct outrelo { #define RELO4 0x03 /* 4 bytes */ #define RELOPPC 0x04 /* 26-bit PowerPC address */ #define RELOH2 0x05 /* write top 2 bytes of 4 byte word */ +#define RELOVC4 0x06 /* VideoCore IV address in 32-bit insruction */ #define RELPC 0x08 /* pc relative */ #define RELBR 0x10 /* High order byte lowest address. */ #define RELWR 0x20 /* High order word lowest address. */ diff --git a/util/led/relocate.c b/util/led/relocate.c index 93b1e9c05..f44a34b96 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -8,6 +8,7 @@ static char rcsid[] = "$Id$"; #include #include +#include #include "out.h" #include "const.h" #include "debug.h" @@ -63,6 +64,22 @@ getvalu(addr, type) return read4(addr, type) & 0x03FFFFFD; case RELOH2: return read2(addr, type) << 16; + case RELOVC4: + { + long i = read4(addr, type); + if (i & 0x00800000) + { + /* Branch instruction. */ + return (i<<9)>>9; + } + else + { + /* Branch-link instruction. */ + long hi = (i<<4)>>28; + long lo = (i & 0x007fffff); + return lo | (hi<<23); + } + } default: fatal("bad relocation size"); } @@ -138,6 +155,28 @@ putvalu(valu, addr, type) case RELOH2: write2(valu>>16, addr, type); break; + case RELOVC4: + { + long i = read4(addr, type); + if (i & 0x00800000) + { + /* Branch instruction. */ + unsigned v = (valu/2) & 0x007fffff; + i &= ~0x007fffff; + i |= v; + } + else + { + /* Branch-link instruction. */ + unsigned v = (valu/2) & 0x07ffffff; + unsigned hiv = v >> 23; + unsigned lov = v & 0x007fffff; + i &= ~0x0f7fffff; + i |= (lov>>16) | (hiv<<24); + } + write4(i, addr, type); + break; + } default: fatal("bad relocation size"); } From 26877d3c4f65ca0889c0ce34c7dc277d47c26753 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 17 May 2013 23:30:49 +0100 Subject: [PATCH 023/231] Add a whole bunch of VC4 opcodes. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach1.c | 21 ++++ mach/vc4/as/mach2.c | 6 +- mach/vc4/as/mach3.c | 51 ++++++++- mach/vc4/as/mach4.c | 40 ++++--- mach/vc4/as/mach5.c | 205 ++++++++++++++++++++++++++++++++++ mach/vc4/test/opcodes.s | 239 +++++++++++++++++++++++++++++++++++++--- 6 files changed, 524 insertions(+), 38 deletions(-) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 96a8a07fa..915d1fb51 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -4,3 +4,24 @@ * This file is redistributable under the terms of the 3-clause BSD license. * See the file 'Copying' in the root of the distribution for the full text. */ + +#include "binary.h" + +#define ALWAYS 14 + +extern void alu_instr_reg(unsigned opcode, unsigned cc, unsigned rd, + unsigned ra, unsigned rb); + +extern void alu_instr_lit(unsigned opcode, unsigned cc, unsigned rd, + unsigned ra, unsigned value); + +extern void misc_instr_reg(unsigned opcode, unsigned cc, unsigned rd, + unsigned ra, unsigned rb); + +extern void misc_instr_lit(unsigned opcode, unsigned cc, unsigned rd, + unsigned ra, unsigned value); + +extern void branch_instr(unsigned bl, unsigned cc, struct expr_t* expr); + +extern void stack_instr(unsigned opcode, unsigned loreg, unsigned hireg, + unsigned extrareg); \ No newline at end of file diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c index c69007de0..6fd2b0e45 100644 --- a/mach/vc4/as/mach2.c +++ b/mach/vc4/as/mach2.c @@ -6,13 +6,17 @@ */ %token GPR +%token CC %token OP +%token OP_BRANCH %token OP_ONEREG %token OP_ONELREG %token OP_ALU +%token OP_FPU %token OP_MEM -%token OP_BREG +%token OP_MISC +%token OP_MISCL %token OP_STACK /* Other token types */ diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index b36652db7..b2cd1c2c9 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -5,8 +5,6 @@ * See the file 'Copying' in the root of the distribution for the full text. */ -#include "binary.h" - /* Integer registers */ 0, GPR, 0, "r0", @@ -17,7 +15,6 @@ 0, GPR, 5, "r5", 0, GPR, 6, "r6", -0, GPR, 6, "fp", 0, GPR, 7, "r7", 0, GPR, 8, "r8", 0, GPR, 9, "r9", @@ -42,6 +39,7 @@ 0, GPR, 26, "r26", 0, GPR, 26, "lr", 0, GPR, 27, "r27", +0, GPR, 27, "fp", 0, GPR, 28, "r28", 0, GPR, 29, "r29", 0, GPR, 30, "r30", @@ -49,13 +47,34 @@ 0, GPR, 31, "r31", 0, GPR, 31, "pc", +/* Condition codes */ + +0, CC, 0, ".eq", +0, CC, 1, ".ne", +0, CC, 2, ".cs", +0, CC, 2, ".lo", +0, CC, 3, ".cc", +0, CC, 3, ".hg", +0, CC, 4, ".mi", +0, CC, 5, ".pl", +0, CC, 6, ".vs", +0, CC, 7, ".vc", +0, CC, 8, ".hi", +0, CC, 9, ".ls", +0, CC, 10, ".ge", +0, CC, 11, ".lt", +0, CC, 12, ".gt", +0, CC, 13, ".le", +0, CC, 15, ".f", + /* Special instructions */ 0, OP, B16(00000000,00000001), "nop", 0, OP, B16(00000000,00001010), "rti", -0, OP_ONEREG, B16(00000000,01000000), "b", -0, OP_ONEREG, B16(00000000,01100000), "bl", +0, OP_BRANCH, 0, "b", +0, OP_BRANCH, 1, "bl", + 0, OP_ONELREG, B16(00000000,10000000), "tbb", 0, OP_ONELREG, B16(00000000,10100000), "tbs", @@ -92,4 +111,26 @@ 0, OP_ALU, B8(00011110), "asr", 0, OP_ALU, B8(00011111), "abs", +0, OP_MISC, B16(11001000,00000000), "fadd", +0, OP_MISC, B16(11001000,00100000), "fsub", +0, OP_MISC, B16(11001000,01000000), "fmul", +0, OP_MISC, B16(11001000,01100000), "fdiv", +0, OP_MISC, B16(11001000,10000000), "fcmp", +0, OP_MISC, B16(11001000,10100000), "fabs", +0, OP_MISC, B16(11001000,11000000), "frsb", +0, OP_MISC, B16(11001000,11100000), "fmax", +0, OP_MISC, B16(11001001,00000000), "frcp", +0, OP_MISC, B16(11001001,00100000), "frsqrt", +0, OP_MISC, B16(11001001,01000000), "fnmul", +0, OP_MISC, B16(11001001,01100000), "fmin", +0, OP_MISC, B16(11001001,10000000), "fld1", +0, OP_MISC, B16(11001001,10100000), "fld0", +0, OP_MISC, B16(11001001,11000000), "log2", +0, OP_MISC, B16(11001001,11100000), "exp2", +0, OP_MISC, B16(11000101,11100000), "adds256", +0, OP_MISCL, B16(11000100,10000000), "divs", +0, OP_MISCL, B16(11000100,11100000), "divu", + +0, OP_STACK, B16(00000010,00000000), "push", +0, OP_STACK, B16(00000010,10000000), "pop", diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index d1320dae1..05dba83b8 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -5,15 +5,12 @@ * See the file 'Copying' in the root of the distribution for the full text. */ -#include "binary.h" - operation : OP { emit2($1); } - | OP_ONEREG GPR - { - emit2($1 | ($2<<0)); - } + | OP_BRANCH GPR { emit2($1 | ($2<<0)); } + | OP_BRANCH expr { branch_instr($1, ALWAYS, &$2); } + | OP_BRANCH CC expr { branch_instr($1, $2, &$3); } | OP_ONELREG GPR { @@ -22,17 +19,28 @@ operation emit2($1 | ($2<<0)); } - | OP_ALU GPR ',' GPR - { - emit2(B16(01000000, 00000000) | ($1<<8) | ($2<<0) | ($4<<4)); - } + | OP_ALU GPR ',' GPR { alu_instr_reg($1, ALWAYS, $2, $2, $4); } + | OP_ALU GPR ',' GPR ',' GPR { alu_instr_reg($1, ALWAYS, $2, $4, $6); } + | OP_ALU CC GPR ',' GPR { alu_instr_reg($1, $2, $3, $3, $5); } + | OP_ALU CC GPR ',' GPR ',' GPR { alu_instr_reg($1, $2, $3, $5, $7); } - | OP_ALU GPR ',' '#' u5 - { - if ($1 >= 0x10) - serror("cannot use this ALU operation in 2op form"); - emit2(B16(01100000, 00000000) | ($1<<9) | ($2<<0) | ($5<<4)); - } + | OP_ALU GPR ',' '#' absexp { alu_instr_lit($1, ALWAYS, $2, $2, $5); } + | OP_ALU GPR ',' GPR ',' '#' absexp { alu_instr_lit($1, ALWAYS, $2, $4, $7); } + | OP_ALU CC GPR ',' '#' absexp { alu_instr_lit($1, $2, $3, $3, $6); } + | OP_ALU CC GPR ',' GPR ',' '#' absexp { alu_instr_lit($1, $2, $3, $5, $8); } + + | OP_MISC GPR ',' GPR ',' GPR { misc_instr_reg($1, ALWAYS, $2, $4, $6); } + | OP_MISC CC GPR ',' GPR ',' GPR { misc_instr_reg($1, $2, $3, $5, $7); } + + | OP_MISCL GPR ',' GPR ',' GPR { misc_instr_reg($1, ALWAYS, $2, $4, $6); } + | OP_MISCL CC GPR ',' GPR ',' GPR { misc_instr_reg($1, $2, $3, $5, $7); } + | OP_MISCL GPR ',' GPR ',' '#' absexp { misc_instr_lit($1, ALWAYS, $2, $4, $7); } + | OP_MISCL CC GPR ',' GPR ',' '#' absexp { misc_instr_lit($1, $2, $3, $5, $8); } + + | OP_STACK GPR { stack_instr($1, $2, $2, -1); } + | OP_STACK GPR ',' GPR { stack_instr($1, $2, $2, $4); } + | OP_STACK GPR '-' GPR { stack_instr($1, $2, $4, -1); } + | OP_STACK GPR '-' GPR ',' GPR { stack_instr($1, $2, $4, $6); } ; e16 diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 668f4b748..83d73da2a 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -5,3 +5,208 @@ * See the file 'Copying' in the root of the distribution for the full text. */ +/* Assemble an ALU instruction where rb is a register. */ + +void alu_instr_reg(unsigned op, unsigned cc, + unsigned rd, unsigned ra, unsigned rb) +{ + /* Can we use short form? */ + + if ((cc == ALWAYS) && (ra == rd)) + { + emit2(B16(01000000,00000000) | (op<<8) | (rb<<4) | (rd<<0)); + return; + } + + /* Long form, then. */ + + emit2(B16(11000000,00000000) | (op<<5) | (rd<<0)); + emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); +} + +/* Assemble an ALU instruction where rb is a literal. */ + +void alu_instr_lit(unsigned op, unsigned cc, + unsigned rd, unsigned ra, unsigned value) +{ + /* 16 bit short form? */ + + if ((cc == ALWAYS) && !(op & 1) && (value <= 0x1f) && (ra == rd) && + !(ra & 0x10)) + { + emit2(B16(01100000,00000000) | (op<<8) | (value<<4) | (rd<<0)); + return; + } + + /* 32 bit medium form? */ + + if (value >= 0x1f) + { + emit2(B16(11000000,00000000) | (op<<5) | (rd<<0)); + emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | (value<<0)); + return; + } + + /* Long form, then. */ + + if (cc != ALWAYS) + serror("cannot use condition codes with ALU literals this big"); + + /* add is special. */ + + if (op == B8(00000010)) + emit2(B16(11101100,00000000) | (ra<<5) | (rd<<0)); + else + { + if (ra != rd) + serror("can only use 2op form of ALU instructions with literals this big"); + emit2(B16(11101000,00000000) | (op<<5) | (rd<<0)); + } + + emit4(value); +} + +/* Miscellaneous instructions with three registers and a cc. */ + +void misc_instr_reg(unsigned op, unsigned cc, + unsigned rd, unsigned ra, unsigned rb) +{ + emit2(op | (rd<<0)); + emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); +} + +/* Miscellaneous instructions with two registers, a literal, and a cc. */ + +void misc_instr_lit(unsigned op, unsigned cc, + unsigned rd, unsigned ra, unsigned value) +{ + if (value < 0x1f) + serror("only constants from 0..31 can be used here"); + + emit2(op | (rd<<0)); + emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | (value<<0)); +} + +/* Assemble a branch instruction. This may be a near branch into this + * object file, or a far branch which requires a fixup. */ + +void branch_instr(unsigned bl, unsigned cc, struct expr_t* expr) +{ + unsigned type = expr->typ & S_TYP; + + /* Sanity checking. */ + + if (bl && (cc != ALWAYS)) + serror("can't use condition codes with bl"); + if (type == S_ABS) + serror("can't use absolute addresses here"); + + switch (pass) + { + case 0: + /* Calculate size of instructions only. For now we just assume + * that they're going to be the maximum size, 32 bits. */ + + emit4(0); + break; + + case 1: + case 2: + { + /* The VC4 branch instructions express distance in 2-byte + * words. */ + + int d = (expr->val - DOTVAL) / 2; + + /* We now know the worst case for the instruction layout. At + * this point we can emit the instructions, which may shrink + * the code. */ + + if (!bl && (type == DOTTYP)) + { + /* This is a reference to code within this section. If it's + * close enough to the program counter, we can use a short- + * form instruction. */ + + if ((d >= -128) && (d < 127)) + { + emit2(B16(00011000,00000000) | (cc<<7) | (d&0x7f)); + break; + } + } + + /* Absolute addresses and references to other sections + * need the full 32 bits. */ + + newrelo(expr->typ, RELOVC4 | RELPC); + + if (bl) + { + unsigned v = d & 0x07ffffff; + unsigned hiv = v >> 23; + unsigned lov = v & 0x007fffff; + emit2(B16(10010000,10000000) | (lov>>16) | (hiv<<8)); + emit2(B16(00000000,00000000) | (lov&0xffff)); + } + else + { + unsigned v = d & 0x007fffff; + emit2(B16(10010000,00000000) | (cc<<8) | (v>>16)); + emit2(B16(00000000,00000000) | (v&0xffff)); + } + break; + } + } +} + +void stack_instr(unsigned opcode, unsigned loreg, unsigned hireg, + unsigned extrareg) +{ + unsigned b; + + switch (loreg) + { + case 0: b = 0; break; + case 6: b = 1; break; + case 16: b = 2; break; + case 24: b = 3; break; + + case 26: /* lr */ + extrareg = 26; + hireg = 31; + loreg = 0; + b = 0; + break; + + case 31: /* pc */ + extrareg = 31; + hireg = 31; + loreg = 0; + b = 0; + break; + + default: + serror("base register for push or pop may be only r0, r6, r16, r24, lr or pc"); + } + + if (opcode & 0x0080) + { + /* Pop */ + if (extrareg == 26) + serror("cannot pop lr"); + } + else + { + /* Push */ + if (extrareg == 31) + serror("cannot push pc"); + } + + if (hireg < loreg) + serror("invalid register range"); + + emit2(opcode | (b<<5) | (hireg<<0) | + ((extrareg != -1) ? 0x0100 : 0)); +} + + diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s index 894a7540e..6dedc4168 100644 --- a/mach/vc4/test/opcodes.s +++ b/mach/vc4/test/opcodes.s @@ -25,6 +25,8 @@ main: tbs r0 tbs r15 + nop + mov r0, r1 cmn r0, r1 add r0, r1 @@ -58,20 +60,225 @@ main: asr r0, r1 abs r0, r1 - mov r0, #31 - cmn r0, #31 - add r0, #31 - bic r0, #31 - mul r0, #31 - eor r0, #31 - sub r0, #31 - and r0, #31 - mvn r0, #31 - ror r0, #31 - cmp r0, #31 - rsb r0, #31 - btst r0, #31 - or r0, #31 - extu r0, #31 - max r0, #31 + nop + mov.f r0, r1 + cmn.f r0, r1 + add.f r0, r1 + bic.f r0, r1 + mul.f r0, r1 + eor.f r0, r1 + sub.f r0, r1 + and.f r0, r1 + mvn.f r0, r1 + ror.f r0, r1 + cmp.f r0, r1 + rsb.f r0, r1 + btst.f r0, r1 + or.f r0, r1 + extu.f r0, r1 + max.f r0, r1 + bset.f r0, r1 + min.f r0, r1 + bclr.f r0, r1 + adds2.f r0, r1 + bchg.f r0, r1 + adds4.f r0, r1 + adds8.f r0, r1 + adds16.f r0, r1 + exts.f r0, r1 + neg.f r0, r1 + lsr.f r0, r1 + clz.f r0, r1 + lsl.f r0, r1 + brev.f r0, r1 + asr.f r0, r1 + abs.f r0, r1 + + nop + + mov r0, r1, r2 + cmn r0, r1, r2 + add r0, r1, r2 + bic r0, r1, r2 + mul r0, r1, r2 + eor r0, r1, r2 + sub r0, r1, r2 + and r0, r1, r2 + mvn r0, r1, r2 + ror r0, r1, r2 + cmp r0, r1, r2 + rsb r0, r1, r2 + btst r0, r1, r2 + or r0, r1, r2 + extu r0, r1, r2 + max r0, r1, r2 + bset r0, r1, r2 + min r0, r1, r2 + bclr r0, r1, r2 + adds2 r0, r1, r2 + bchg r0, r1, r2 + adds4 r0, r1, r2 + adds8 r0, r1, r2 + adds16 r0, r1, r2 + exts r0, r1, r2 + neg r0, r1, r2 + lsr r0, r1, r2 + clz r0, r1, r2 + lsl r0, r1, r2 + brev r0, r1, r2 + asr r0, r1, r2 + abs r0, r1, r2 + + nop + + mov r0, #0x1f + cmn r0, #0x1f + add r0, #0x1f + bic r0, #0x1f + mul r0, #0x1f + eor r0, #0x1f + sub r0, #0x1f + and r0, #0x1f + mvn r0, #0x1f + ror r0, #0x1f + cmp r0, #0x1f + rsb r0, #0x1f + btst r0, #0x1f + or r0, #0x1f + extu r0, #0x1f + max r0, #0x1f + bset r0, #0x1f + min r0, #0x1f + bclr r0, #0x1f + adds2 r0, #0x1f + bchg r0, #0x1f + adds4 r0, #0x1f + adds8 r0, #0x1f + adds16 r0, #0x1f + exts r0, #0x1f + neg r0, #0x1f + lsr r0, #0x1f + clz r0, #0x1f + lsl r0, #0x1f + brev r0, #0x1f + asr r0, #0x1f + abs r0, #0x1f + + nop + + mov.f r0, #0x1f + cmn.f r0, #0x1f + add.f r0, #0x1f + bic.f r0, #0x1f + mul.f r0, #0x1f + eor.f r0, #0x1f + sub.f r0, #0x1f + and.f r0, #0x1f + mvn.f r0, #0x1f + ror.f r0, #0x1f + cmp.f r0, #0x1f + rsb.f r0, #0x1f + btst.f r0, #0x1f + or.f r0, #0x1f + extu.f r0, #0x1f + max.f r0, #0x1f + bset.f r0, #0x1f + min.f r0, #0x1f + bclr.f r0, #0x1f + adds2.f r0, #0x1f + bchg.f r0, #0x1f + adds4.f r0, #0x1f + adds8.f r0, #0x1f + adds16.f r0, #0x1f + exts.f r0, #0x1f + neg.f r0, #0x1f + lsr.f r0, #0x1f + clz.f r0, #0x1f + lsl.f r0, #0x1f + brev.f r0, #0x1f + asr.f r0, #0x1f + abs.f r0, #0x1f + + add r0, #0x12345678 + add r0, r1, #0x12345678 + sub r0, #0x12345678 + + nop + + fadd r0, r1, r2 + fsub r0, r1, r2 + fmul r0, r1, r2 + fdiv r0, r1, r2 + fcmp r0, r1, r2 + fabs r0, r1, r2 + frsb r0, r1, r2 + fmax r0, r1, r2 + frcp r0, r1, r2 + frsqrt r0, r1, r2 + fnmul r0, r1, r2 + fmin r0, r1, r2 + fld1 r0, r1, r2 + fld0 r0, r1, r2 + log2 r0, r1, r2 + exp2 r0, r1, r2 + divs r0, r1, r2 + divu r0, r1, r2 + divs r0, r1, #31 + divu r0, r1, #31 + adds256 r0, r1, r2 + + nop + + fadd.f r0, r1, r2 + fsub.f r0, r1, r2 + fmul.f r0, r1, r2 + fdiv.f r0, r1, r2 + fcmp.f r0, r1, r2 + fabs.f r0, r1, r2 + frsb.f r0, r1, r2 + fmax.f r0, r1, r2 + frcp.f r0, r1, r2 + frsqrt.f r0, r1, r2 + fnmul.f r0, r1, r2 + fmin.f r0, r1, r2 + fld1.f r0, r1, r2 + fld0.f r0, r1, r2 + log2.f r0, r1, r2 + exp2.f r0, r1, r2 + divs.f r0, r1, r2 + divu.f r0, r1, r2 + divs.f r0, r1, #31 + divu.f r0, r1, #31 + adds256.f r0, r1, r2 + +label: + b label + b forward + b label + b main + b.f label + b.f forward + b.f main + bl label + bl forward + bl main +forward: + + push r0 + push r0, lr + push r0-r5 + push r0-r5, lr + push r6 + push r16 + push r24 + push lr + + pop r0 + pop r0, pc + pop r0-r5 + pop r0-r5, pc + pop r6 + pop r16 + pop r24 + pop pc From c18a82ec40d42f06278461f0fe436dc6f1a540c7 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 18 May 2013 12:15:53 +0100 Subject: [PATCH 024/231] Apply build system fixes for OpenBSD contributed by George Koehler. --- README | 8 ++++++-- lang/cem/cemcom.ansi/LLmessage.c | 1 + lang/cem/cemcom.ansi/options.c | 1 + util/LLgen/build.mk | 4 ++-- util/ack/build.mk | 4 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README b/README index d6a56b050..3b0d877fa 100644 --- a/README +++ b/README @@ -45,6 +45,10 @@ Requirements: - an ANSI C compiler. This defaults to gcc. You can change this by setting the CC make variable. +- flex and yacc. + +- GNU make. + - about 40MB free in /tmp (or some other temporary directory). - about 6MB in the target directory. @@ -57,14 +61,14 @@ Instructions: - Run: - make + make # or gmake ...from the command line. This will do the build. The make system is fully parallelisable. If you have a multicore system, you probably want to do: - make -j8 + make -j8 # or gmake -j8 ...instead (substituting the right number of cores, of course). You can also shave a few seconds of the build time by using the -r flag. diff --git a/lang/cem/cemcom.ansi/LLmessage.c b/lang/cem/cemcom.ansi/LLmessage.c index 9010ce45d..c88c5eb24 100644 --- a/lang/cem/cemcom.ansi/LLmessage.c +++ b/lang/cem/cemcom.ansi/LLmessage.c @@ -6,6 +6,7 @@ /* PARSER ERROR ADMINISTRATION */ #include +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" diff --git a/lang/cem/cemcom.ansi/options.c b/lang/cem/cemcom.ansi/options.c index a8f382302..a23ff3405 100644 --- a/lang/cem/cemcom.ansi/options.c +++ b/lang/cem/cemcom.ansi/options.c @@ -11,6 +11,7 @@ #include #include "class.h" #include "macro.h" +#include "idf.h" #include "arith.h" #include "sizes.h" #include "align.h" diff --git a/util/LLgen/build.mk b/util/LLgen/build.mk index 3c40d1886..28da2d715 100644 --- a/util/LLgen/build.mk +++ b/util/LLgen/build.mk @@ -45,9 +45,9 @@ $(eval CLEANABLES += $o $1/Lpars.h) $o: $1/Lpars.h $1/Lpars.h: $2 $(LLGEN) @echo LLGEN $1/Lpars.c - @mkdir -p $(dir $o) + @mkdir -p $1 $(hide) $(RM) $o $1/Lpars.h - $(hide) cd $(dir $o) && $(LLGEN) $(abspath $2) + $(hide) cd $1 && $(LLGEN) $(abspath $2) $(foreach f,$o,$(call cfile,$f)) diff --git a/util/ack/build.mk b/util/ack/build.mk index 1b4fc146c..36e505c12 100644 --- a/util/ack/build.mk +++ b/util/ack/build.mk @@ -5,8 +5,8 @@ $(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) $(wordlist 2, $(words $g), $g): $(firstword $g) $(firstword $g): $(util-ack-mktables) @echo MKTABLES - @mkdir -p $(dir $g) - $(hide) cd $(dir $g) && $(util-ack-mktables) $(INSDIR)/share + @mkdir -p $(OBJDIR)/$D + $(hide) cd $(OBJDIR)/$D && $(util-ack-mktables) $(INSDIR)/share $(eval CLEANABLES += $g) endef From fc1b3672a36228bc7e0664d98542650984b049c1 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 18 May 2013 13:00:37 +0100 Subject: [PATCH 025/231] Reapply bugfix to sbrk() which got dropped during the move from linx386/libsys to liblinux. Set errno correctly. --- plat/linux/liblinux/brk.c | 6 +++++- plat/linux/liblinux/sbrk.c | 25 ++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plat/linux/liblinux/brk.c b/plat/linux/liblinux/brk.c index 8bb53d31d..7ce5c5fc8 100644 --- a/plat/linux/liblinux/brk.c +++ b/plat/linux/liblinux/brk.c @@ -5,9 +5,13 @@ #include #include +#include #include "libsys.h" int brk(void* end) { - return _syscall(__NR_brk, (quad) end, 0, 0); + int e = _syscall(__NR_brk, (quad) end, 0, 0); + if (e == -1) + errno = ENOMEM; + return e; } diff --git a/plat/linux/liblinux/sbrk.c b/plat/linux/liblinux/sbrk.c index 17b273f42..35810ef89 100644 --- a/plat/linux/liblinux/sbrk.c +++ b/plat/linux/liblinux/sbrk.c @@ -1,32 +1,39 @@ -/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/sbrk.c,v $ - * $State: Exp $ - * $Revision: 1.1 $ +/* $Source$ + * $State$ + * $Revision$ */ #include -#include #include +#include #include "libsys.h" #define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ -extern char _end[1]; - -static char* current = _end; +static char* current = NULL; void* sbrk(intptr_t increment) { char* old; char* new; + char* actual; + + if (!current) + current = (char*) _syscall(__NR_brk, 0, 0, 0); if (increment == 0) return current; old = current; new = old + increment; - if (brk(new) < 0) + + actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0); + if (actual < new) + { + errno = ENOMEM; return OUT_OF_MEMORY; + } - current = new; + current = actual; return old; } From fc2833d4568f5e474661dec3c3cf93b33cbd2cc5 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 00:56:56 +0100 Subject: [PATCH 026/231] Add most vanilla memory load/store instructions. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach0.c | 2 + mach/vc4/as/mach1.c | 24 +++---- mach/vc4/as/mach2.c | 4 -- mach/vc4/as/mach3.c | 12 +++- mach/vc4/as/mach4.c | 84 ++++--------------------- mach/vc4/as/mach5.c | 134 +++++++++++++++++++++++++++++++++++----- mach/vc4/test/opcodes.s | 51 +++++++++++++++ 7 files changed, 205 insertions(+), 106 deletions(-) diff --git a/mach/vc4/as/mach0.c b/mach/vc4/as/mach0.c index b6294ecfc..d12994de0 100644 --- a/mach/vc4/as/mach0.c +++ b/mach/vc4/as/mach0.c @@ -19,6 +19,8 @@ #undef word_t #define word_t long +typedef unsigned long quad; + #undef ALIGNWORD #define ALIGNWORD 4 diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 915d1fb51..bfb298f68 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -9,19 +9,21 @@ #define ALWAYS 14 -extern void alu_instr_reg(unsigned opcode, unsigned cc, unsigned rd, - unsigned ra, unsigned rb); +extern void alu_instr_reg(quad opcode, quad cc, quad rd, + quad ra, quad rb); -extern void alu_instr_lit(unsigned opcode, unsigned cc, unsigned rd, - unsigned ra, unsigned value); +extern void alu_instr_lit(quad opcode, quad cc, quad rd, + quad ra, quad value); -extern void misc_instr_reg(unsigned opcode, unsigned cc, unsigned rd, - unsigned ra, unsigned rb); +extern void misc_instr_reg(quad opcode, quad cc, quad rd, + quad ra, quad rb); -extern void misc_instr_lit(unsigned opcode, unsigned cc, unsigned rd, - unsigned ra, unsigned value); +extern void misc_instr_lit(quad opcode, quad cc, quad rd, + quad ra, quad value); -extern void branch_instr(unsigned bl, unsigned cc, struct expr_t* expr); +extern void branch_instr(quad bl, quad cc, struct expr_t* expr); -extern void stack_instr(unsigned opcode, unsigned loreg, unsigned hireg, - unsigned extrareg); \ No newline at end of file +extern void stack_instr(quad opcode, quad loreg, quad hireg, + quad extrareg); + +extern void mem_instr(quad opcode, quad cc, quad rd, long offset, quad rs); diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c index 6fd2b0e45..2abde7136 100644 --- a/mach/vc4/as/mach2.c +++ b/mach/vc4/as/mach2.c @@ -19,8 +19,4 @@ %token OP_MISCL %token OP_STACK -/* Other token types */ -/* %type c */ -%type e16 u8 u7 u6 u5 u4 u2 u1 -/* %type nb ds bda bdl lia lil */ diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index b2cd1c2c9..64b503a98 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -33,13 +33,13 @@ 0, GPR, 22, "r22", 0, GPR, 23, "r23", 0, GPR, 24, "r24", +0, GPR, 24, "fp", 0, GPR, 25, "r25", 0, GPR, 25, "sp", 0, GPR, 26, "r26", 0, GPR, 26, "lr", 0, GPR, 27, "r27", -0, GPR, 27, "fp", 0, GPR, 28, "r28", 0, GPR, 29, "r29", 0, GPR, 30, "r30", @@ -134,3 +134,13 @@ 0, OP_STACK, B16(00000010,00000000), "push", 0, OP_STACK, B16(00000010,10000000), "pop", + +0, OP_MEM, B8(00000000), "ld", +0, OP_MEM, B8(00000001), "st", +0, OP_MEM, B8(00000010), "ldh", +0, OP_MEM, B8(00000011), "sth", +0, OP_MEM, B8(00000100), "ldb", +0, OP_MEM, B8(00000101), "stb", +0, OP_MEM, B8(00000110), "ldhs", +0, OP_MEM, B8(00000111), "sths", + diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index 05dba83b8..7bd183829 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -41,78 +41,16 @@ operation | OP_STACK GPR ',' GPR { stack_instr($1, $2, $2, $4); } | OP_STACK GPR '-' GPR { stack_instr($1, $2, $4, -1); } | OP_STACK GPR '-' GPR ',' GPR { stack_instr($1, $2, $4, $6); } - ; - -e16 - : expr - { - DOTVAL += 2; - newrelo($1.typ, RELO2 | FIXUPFLAGS); - DOTVAL -= 2; - $$ = $1.val & 0xFFFF; - } - ; - -u8 - : absexp - { - if (($1 < 0) || ($1 > 0xFF)) - serror("8-bit unsigned value out of range"); - $$ = $1; - } - ; - -u7 - : absexp - { - if (($1 < 0) || ($1 > 0x7F)) - serror("7-bit unsigned value out of range"); - $$ = $1; - } - ; - -u6 - : absexp - { - if (($1 < 0) || ($1 > 0x3F)) - serror("6-bit unsigned value out of range"); - $$ = $1; - } - ; - -u5 - : absexp - { - if (($1 < 0) || ($1 > 0x1F)) - serror("5-bit unsigned value out of range"); - $$ = $1; - } - ; - -u4 - : absexp - { - if (($1 < 0) || ($1 > 0xF)) - serror("4-bit unsigned value out of range"); - $$ = $1; - } - ; - -u1 - : absexp - { - if (($1 < 0) || ($1 > 1)) - serror("1-bit unsigned value out of range"); - $$ = $1; - } - ; - -u2 - : absexp - { - if (($1 < 0) || ($1 > 0x3)) - serror("2-bit unsigned value out of range"); - $$ = $1; - } + + | OP_MEM GPR ',' '(' GPR ')' { mem_instr($1, ALWAYS, $2, 0, $5); } + | OP_MEM CC GPR ',' '(' GPR ')' { mem_instr($1, $2, $3, 0, $6); } + | OP_MEM GPR ',' absexp '(' GPR ')' { mem_instr($1, ALWAYS, $2, $4, $6); } + | OP_MEM CC GPR ',' absexp '(' GPR ')' { mem_instr($1, $2, $3, $5, $7); } + + | OP_MEM GPR ',' '(' GPR ',' GPR ')' + | OP_MEM CC GPR ',' '(' GPR ',' GPR ')' + + | OP_MEM GPR ',' '(' GPR ')' '+' '+' + | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' ; diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 83d73da2a..32d7507f3 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -5,10 +5,11 @@ * See the file 'Copying' in the root of the distribution for the full text. */ +#define maskx(v, x) (v & ((1<<(x))-1)) + /* Assemble an ALU instruction where rb is a register. */ -void alu_instr_reg(unsigned op, unsigned cc, - unsigned rd, unsigned ra, unsigned rb) +void alu_instr_reg(quad op, quad cc, quad rd, quad ra, quad rb) { /* Can we use short form? */ @@ -26,8 +27,7 @@ void alu_instr_reg(unsigned op, unsigned cc, /* Assemble an ALU instruction where rb is a literal. */ -void alu_instr_lit(unsigned op, unsigned cc, - unsigned rd, unsigned ra, unsigned value) +void alu_instr_lit(quad op, quad cc, quad rd, quad ra, quad value) { /* 16 bit short form? */ @@ -68,8 +68,7 @@ void alu_instr_lit(unsigned op, unsigned cc, /* Miscellaneous instructions with three registers and a cc. */ -void misc_instr_reg(unsigned op, unsigned cc, - unsigned rd, unsigned ra, unsigned rb) +void misc_instr_reg(quad op, quad cc, quad rd, quad ra, quad rb) { emit2(op | (rd<<0)); emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); @@ -77,8 +76,7 @@ void misc_instr_reg(unsigned op, unsigned cc, /* Miscellaneous instructions with two registers, a literal, and a cc. */ -void misc_instr_lit(unsigned op, unsigned cc, - unsigned rd, unsigned ra, unsigned value) +void misc_instr_lit(quad op, quad cc, quad rd, quad ra, quad value) { if (value < 0x1f) serror("only constants from 0..31 can be used here"); @@ -90,9 +88,9 @@ void misc_instr_lit(unsigned op, unsigned cc, /* Assemble a branch instruction. This may be a near branch into this * object file, or a far branch which requires a fixup. */ -void branch_instr(unsigned bl, unsigned cc, struct expr_t* expr) +void branch_instr(quad bl, quad cc, struct expr_t* expr) { - unsigned type = expr->typ & S_TYP; + quad type = expr->typ & S_TYP; /* Sanity checking. */ @@ -142,15 +140,15 @@ void branch_instr(unsigned bl, unsigned cc, struct expr_t* expr) if (bl) { - unsigned v = d & 0x07ffffff; - unsigned hiv = v >> 23; - unsigned lov = v & 0x007fffff; + quad v = d & 0x07ffffff; + quad hiv = v >> 23; + quad lov = v & 0x007fffff; emit2(B16(10010000,10000000) | (lov>>16) | (hiv<<8)); emit2(B16(00000000,00000000) | (lov&0xffff)); } else { - unsigned v = d & 0x007fffff; + quad v = d & 0x007fffff; emit2(B16(10010000,00000000) | (cc<<8) | (v>>16)); emit2(B16(00000000,00000000) | (v&0xffff)); } @@ -159,10 +157,11 @@ void branch_instr(unsigned bl, unsigned cc, struct expr_t* expr) } } -void stack_instr(unsigned opcode, unsigned loreg, unsigned hireg, - unsigned extrareg) +/* Push/pop. */ + +void stack_instr(quad opcode, quad loreg, quad hireg, quad extrareg) { - unsigned b; + quad b; switch (loreg) { @@ -209,4 +208,105 @@ void stack_instr(unsigned opcode, unsigned loreg, unsigned hireg, ((extrareg != -1) ? 0x0100 : 0)); } +/* Memory operations where the offset is a fixed value (including zero). */ + +void mem_instr(quad opcode, quad cc, quad rd, long offset, quad rs) +{ + quad uoffset = (quad) offset; + int multiple4 = !(offset & 3); + int intonly = ((opcode & B8(00000110)) == 0); + + /* If no CC, there are some special forms we can use. */ + + if (cc == ALWAYS) + { + /* Very short form, special for stack offsets. */ + + if (intonly && (rs == 25) && multiple4 && fitx(offset, 7) && (rd < 0x10)) + { + quad o = maskx(offset, 7) / 4; + emit2(B16(00000100,00000000) | (opcode<<9) | (o<<4) | (rd<<0)); + return; + } + + /* Slightly longer form for directly dereferencing via a register. */ + + if ((rs < 0x10) && (rd < 0x10) && (offset == 0)) + { + emit2(B16(00001000,00000000) | (opcode<<8) | (rs<<4) | (rd<<4)); + return; + } + + /* Integer only, but a limited offset. */ + + if (intonly && (uoffset <= 0x3f) && (rs < 0x10) && (rd < 0x10)) + { + quad o = uoffset / 4; + emit2(B16(00100000,00000000) | (opcode<<12) | (o<<8) | + (rs<<4) | (rd<<0)); + return; + } + + /* Certain registers support 16-bit offsets. */ + + if (fitx(offset, 16)) + { + switch (rs) + { + case 0: opcode = B16(10101011,00000000) | (opcode<<5); goto specialreg; + case 24: opcode = B16(10101000,00000000) | (opcode<<5); goto specialreg; + case 25: opcode = B16(10101001,00000000) | (opcode<<5); goto specialreg; + case 31: opcode = B16(10101010,00000000) | (opcode<<5); goto specialreg; + default: break; + + specialreg: + { + quad o = maskx(offset, 16); + emit2(opcode | (rd<<0)); + emit2(o); + return; + } + } + } + + /* 12-bit displacements. */ + + if (fitx(offset, 12)) + { + quad looffset = maskx(offset, 11); + quad hioffset = (offset >> 11) & 1; + + emit2(B16(10100010,00000000) | (opcode<<5) | (rd<<0) | (hioffset<<8)); + emit2(B16(00000000,00000000) | (rs<<11) | (looffset<<0)); + return; + } + + /* Everything else uses Very Long Form. */ + + if (!fitx(offset, 27)) + serror("offset will not fit into load/store instruction"); + + if (rs == 31) + opcode = B16(11100111,00000000) | (opcode<<5); + else + opcode = B16(11100110,00000000) | (opcode<<5); + + emit2(opcode | (rd<<0)); + emit4((rs<<27) | maskx(offset, 27)); + return; + } + + /* Now we're on to load/store instructions with ccs. */ + + if (uoffset <= 0x1f) + { + emit2(B16(10100000,00000000) | (opcode<<5) | (rd<<0)); + emit2(B16(00000000,01000000) | (rs<<11) | (cc<<7) | (uoffset<<0)); + return; + } + + /* No encoding for this instruction. */ + + serror("invalid load/store instruction"); +} diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s index 6dedc4168..2f9c1c709 100644 --- a/mach/vc4/test/opcodes.s +++ b/mach/vc4/test/opcodes.s @@ -282,3 +282,54 @@ forward: pop r16 pop r24 pop pc + + nop + + ld r0, (sp) + st r0, (sp) + ld r0, 4(sp) + st r0, 4(sp) + ld r0, -4(sp) + st r0, -4(sp) + ld r0, 5(sp) + st r0, 5(sp) + ld r0, -5(sp) + st r0, -5(sp) + + ld r0, (r1) + st r0, (r1) + ld r16, (r1) + st r16, (r1) + ldh r0, (r1) + sth r0, (r1) + ldb r0, (r1) + stb r0, (r1) + ldhs r0, (r1) + sths r0, (r1) + ldh r16, (r1) + sth r16, (r1) + ldb r16, (r1) + stb r16, (r1) + ldhs r16, (r1) + sths r16, (r1) + ld r0, 0x3c (r1) + st r0, 0x3c (r1) + ld r0, 0xfff (r1) + st r0, 0xfff (r1) + ld r1, 0xffff (r0) + st r1, 0xffff (r0) + ld r0, -1 (r1) + st r0, -1 (r1) + ld r16, 0x3c (r1) + st r16, 0x3c (r1) + ld r16, 0xfff (r1) + st r16, 0xfff (r1) + ld r16, 0xffff (r0) + st r16, 0xffff (r0) + ld r16, -1 (r1) + st r16, -1 (r1) + + ld.f r0, (r1) + st.f r0, (r1) + ld.f r0, 8 (r1) + st.f r0, 8 (r1) From febe8ca937ff80005191155c96e25f37db98c054 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 12:39:35 +0100 Subject: [PATCH 027/231] Add register offset and postincrement memory operations. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach1.c | 27 +++++++++------------------ mach/vc4/as/mach4.c | 10 +++++----- mach/vc4/as/mach5.c | 32 ++++++++++++++++++++++++-------- mach/vc4/test/opcodes.s | 11 +++++++++++ 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index bfb298f68..25d5034b4 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -9,21 +9,12 @@ #define ALWAYS 14 -extern void alu_instr_reg(quad opcode, quad cc, quad rd, - quad ra, quad rb); - -extern void alu_instr_lit(quad opcode, quad cc, quad rd, - quad ra, quad value); - -extern void misc_instr_reg(quad opcode, quad cc, quad rd, - quad ra, quad rb); - -extern void misc_instr_lit(quad opcode, quad cc, quad rd, - quad ra, quad value); - -extern void branch_instr(quad bl, quad cc, struct expr_t* expr); - -extern void stack_instr(quad opcode, quad loreg, quad hireg, - quad extrareg); - -extern void mem_instr(quad opcode, quad cc, quad rd, long offset, quad rs); +extern void alu_instr_reg(quad opcode, int cc, int rd, int ra, int rb); +extern void alu_instr_lit(quad opcode, int cc, int rd, int ra, quad value); +extern void misc_instr_reg(quad opcode, int cc, int rd, int ra, int rb); +extern void misc_instr_lit(quad opcode, int cc, int rd, int ra, quad value); +extern void branch_instr(int bl, int cc, struct expr_t* expr); +extern void stack_instr(quad opcode, int loreg, int hireg, int extrareg); +extern void mem_instr(quad opcode, int cc, int rd, long offset, int rs); +extern void mem_offset_instr(quad opcode, int cc, int rd, int qa, int rb); +extern void mem_postincr_instr(quad opcode, int cc, int rd, int rs); diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index 7bd183829..f614825e9 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -6,7 +6,7 @@ */ operation - : OP { emit2($1); } + : OP { emit2($1); } | OP_BRANCH GPR { emit2($1 | ($2<<0)); } | OP_BRANCH expr { branch_instr($1, ALWAYS, &$2); } @@ -47,10 +47,10 @@ operation | OP_MEM GPR ',' absexp '(' GPR ')' { mem_instr($1, ALWAYS, $2, $4, $6); } | OP_MEM CC GPR ',' absexp '(' GPR ')' { mem_instr($1, $2, $3, $5, $7); } - | OP_MEM GPR ',' '(' GPR ',' GPR ')' - | OP_MEM CC GPR ',' '(' GPR ',' GPR ')' + | OP_MEM GPR ',' '(' GPR ',' GPR ')' { mem_offset_instr($1, ALWAYS, $2, $5, $7); } + | OP_MEM CC GPR ',' '(' GPR ',' GPR ')' { mem_offset_instr($1, $2, $3, $6, $8); } - | OP_MEM GPR ',' '(' GPR ')' '+' '+' - | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' + | OP_MEM GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, ALWAYS, $2, $5); } + | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, $2, $3, $6); } ; diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 32d7507f3..0d68c8ff9 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -9,7 +9,7 @@ /* Assemble an ALU instruction where rb is a register. */ -void alu_instr_reg(quad op, quad cc, quad rd, quad ra, quad rb) +void alu_instr_reg(quad op, int cc, int rd, int ra, int rb) { /* Can we use short form? */ @@ -27,7 +27,7 @@ void alu_instr_reg(quad op, quad cc, quad rd, quad ra, quad rb) /* Assemble an ALU instruction where rb is a literal. */ -void alu_instr_lit(quad op, quad cc, quad rd, quad ra, quad value) +void alu_instr_lit(quad op, int cc, int rd, int ra, quad value) { /* 16 bit short form? */ @@ -68,7 +68,7 @@ void alu_instr_lit(quad op, quad cc, quad rd, quad ra, quad value) /* Miscellaneous instructions with three registers and a cc. */ -void misc_instr_reg(quad op, quad cc, quad rd, quad ra, quad rb) +void misc_instr_reg(quad op, int cc, int rd, int ra, int rb) { emit2(op | (rd<<0)); emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); @@ -76,7 +76,7 @@ void misc_instr_reg(quad op, quad cc, quad rd, quad ra, quad rb) /* Miscellaneous instructions with two registers, a literal, and a cc. */ -void misc_instr_lit(quad op, quad cc, quad rd, quad ra, quad value) +void misc_instr_lit(quad op, int cc, int rd, int ra, quad value) { if (value < 0x1f) serror("only constants from 0..31 can be used here"); @@ -88,7 +88,7 @@ void misc_instr_lit(quad op, quad cc, quad rd, quad ra, quad value) /* Assemble a branch instruction. This may be a near branch into this * object file, or a far branch which requires a fixup. */ -void branch_instr(quad bl, quad cc, struct expr_t* expr) +void branch_instr(int bl, int cc, struct expr_t* expr) { quad type = expr->typ & S_TYP; @@ -159,9 +159,9 @@ void branch_instr(quad bl, quad cc, struct expr_t* expr) /* Push/pop. */ -void stack_instr(quad opcode, quad loreg, quad hireg, quad extrareg) +void stack_instr(quad opcode, int loreg, int hireg, int extrareg) { - quad b; + int b; switch (loreg) { @@ -210,7 +210,7 @@ void stack_instr(quad opcode, quad loreg, quad hireg, quad extrareg) /* Memory operations where the offset is a fixed value (including zero). */ -void mem_instr(quad opcode, quad cc, quad rd, long offset, quad rs) +void mem_instr(quad opcode, int cc, int rd, long offset, int rs) { quad uoffset = (quad) offset; int multiple4 = !(offset & 3); @@ -310,3 +310,19 @@ void mem_instr(quad opcode, quad cc, quad rd, long offset, quad rs) serror("invalid load/store instruction"); } +/* Memory operations where the destination address is a sum of two + * registers. */ + +void mem_offset_instr(quad opcode, int cc, int rd, int ra, int rb) +{ + emit2(B16(10100000,00000000) | (opcode<<5) | (rd<<0)); + emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); +} + +/* Memory operations with postincrement. */ + +void mem_postincr_instr(quad opcode, int cc, int rd, int rs) +{ + emit2(B16(10100101,00000000) | (opcode<<5) | (rd<<0)); + emit2(B16(00000000,00000000) | (rs<<11) | (cc<<7)); +} diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s index 2f9c1c709..ddc6b1706 100644 --- a/mach/vc4/test/opcodes.s +++ b/mach/vc4/test/opcodes.s @@ -333,3 +333,14 @@ forward: st.f r0, (r1) ld.f r0, 8 (r1) st.f r0, 8 (r1) + + ld r0, (r1, r2) + st r0, (r1, r2) + ld.f r0, (pc, pc) + st.f r0, (pc, pc) + + ld r0, (r1)++ + st r0, (r1)++ + ld.f pc, (pc)++ + st.f pc, (pc)++ + From 80afe75c9bfc40a2bc7de4354c7fa4c1416724d4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 13:03:53 +0100 Subject: [PATCH 028/231] Added memory operations that work on fixed up addresses. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach1.c | 1 + mach/vc4/as/mach4.c | 2 ++ mach/vc4/as/mach5.c | 62 +++++++++++++++++++++++++++++++++++++++++ mach/vc4/test/opcodes.s | 9 ++++++ 4 files changed, 74 insertions(+) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 25d5034b4..6e7b6819f 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -18,3 +18,4 @@ extern void stack_instr(quad opcode, int loreg, int hireg, int extrareg); extern void mem_instr(quad opcode, int cc, int rd, long offset, int rs); extern void mem_offset_instr(quad opcode, int cc, int rd, int qa, int rb); extern void mem_postincr_instr(quad opcode, int cc, int rd, int rs); +extern void mem_address_instr(quad opcode, int rd, struct expr_t* expr); diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index f614825e9..78c9337c9 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -52,5 +52,7 @@ operation | OP_MEM GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, ALWAYS, $2, $5); } | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, $2, $3, $6); } + + | OP_MEM GPR ',' expr { mem_address_instr($1, $2, &$4); } ; diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 0d68c8ff9..265e18f52 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -326,3 +326,65 @@ void mem_postincr_instr(quad opcode, int cc, int rd, int rs) emit2(B16(10100101,00000000) | (opcode<<5) | (rd<<0)); emit2(B16(00000000,00000000) | (rs<<11) | (cc<<7)); } + +/* Memory operations where the destination is an address literal. */ + +void mem_address_instr(quad opcode, int rd, struct expr_t* expr) +{ + quad type = expr->typ & S_TYP; + + /* Sanity checking. */ + + if (type == S_ABS) + serror("can't use absolute addresses here"); + + switch (pass) + { + case 0: + /* Calculate size of instructions only. For now we just assume + * that they're going to be the maximum size, 48 bits. */ + + emit2(0); + emit4(0); + break; + + case 1: + case 2: + { + /* The VC4 branch instructions express distance in 2-byte + * words. */ + + int d = (expr->val - DOTVAL) / 2; + + /* We now know the worst case for the instruction layout. At + * this point we can emit the instructions, which may shrink + * the code. */ + + if (type == DOTTYP) + { + /* This is a reference to an address within this section. If + * it's close enough to the program counter, we can use a + * shorter instruction. */ + + if (fitx(d, 16)) + { + emit2(B16(10101010,00000000) | (opcode<<5) | (rd<<0)); + emit2(d); + return; + } + } + + /* Otherwise we need the full 48 bits. */ + + if (!fitx(d, 27)) + serror("offset too big to encode into instruction"); + + newrelo(expr->typ, RELOVC4 | RELPC); + + emit2(B16(11100111,00000000) | (opcode<<5) | (rd<<0)); + emit4((31<<27) | maskx(d, 27)); + break; + } + } +} + diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s index ddc6b1706..a2104fcd7 100644 --- a/mach/vc4/test/opcodes.s +++ b/mach/vc4/test/opcodes.s @@ -339,8 +339,17 @@ forward: ld.f r0, (pc, pc) st.f r0, (pc, pc) +near: ld r0, (r1)++ st r0, (r1)++ ld.f pc, (pc)++ st.f pc, (pc)++ + ld r0, near + ld r0, main + st r0, near + st r0, main + ldb r0, near + ldb r0, main + stb r0, near + stb r0, main From 4f15423d63b7e35336aef1f2ebf2d2dc4bf24401 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 18:40:19 +0100 Subject: [PATCH 029/231] Add compare-and-branch instructions. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach1.c | 4 ++ mach/vc4/as/mach2.c | 2 +- mach/vc4/as/mach3.c | 3 +- mach/vc4/as/mach4.c | 23 +++++++++-- mach/vc4/as/mach5.c | 84 +++++++++++++++++++++++++++++++++++++++++ mach/vc4/test/opcodes.s | 7 ++++ 6 files changed, 118 insertions(+), 5 deletions(-) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 6e7b6819f..440d7de97 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -19,3 +19,7 @@ extern void mem_instr(quad opcode, int cc, int rd, long offset, int rs); extern void mem_offset_instr(quad opcode, int cc, int rd, int qa, int rb); extern void mem_postincr_instr(quad opcode, int cc, int rd, int rs); extern void mem_address_instr(quad opcode, int rd, struct expr_t* expr); +extern void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct expr_t* expr); +extern void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct expr_t* expr); +extern void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr); +extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr); diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c index 2abde7136..8143d080b 100644 --- a/mach/vc4/as/mach2.c +++ b/mach/vc4/as/mach2.c @@ -9,7 +9,7 @@ %token CC %token OP -%token OP_BRANCH +%token OP_BRANCH OP_BRANCHLINK OP_ADDCMPB %token OP_ONEREG %token OP_ONELREG %token OP_ALU diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index 64b503a98..aba49dca2 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -73,7 +73,8 @@ 0, OP, B16(00000000,00001010), "rti", 0, OP_BRANCH, 0, "b", -0, OP_BRANCH, 1, "bl", +0, OP_BRANCHLINK, 0, "bl", +0, OP_ADDCMPB, 0, "addcmpb", 0, OP_ONELREG, B16(00000000,10000000), "tbb", 0, OP_ONELREG, B16(00000000,10100000), "tbs", diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index 78c9337c9..e9593e761 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -8,9 +8,26 @@ operation : OP { emit2($1); } - | OP_BRANCH GPR { emit2($1 | ($2<<0)); } - | OP_BRANCH expr { branch_instr($1, ALWAYS, &$2); } - | OP_BRANCH CC expr { branch_instr($1, $2, &$3); } + | OP_BRANCH GPR { emit2(B16(00000000,01000000) | ($2<<0)); } + | OP_BRANCHLINK GPR { emit2(B16(00000000,01100000) | ($2<<0)); } + + | OP_BRANCH expr { branch_instr(0, ALWAYS, &$2); } + | OP_BRANCHLINK expr { branch_instr(1, ALWAYS, &$2); } + | OP_BRANCH CC expr { branch_instr(0, $2, &$3); } + | OP_BRANCHLINK CC expr { branch_instr(1, $2, &$3); } + + | OP_BRANCH GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, 0, $2, $4, &$6); } + | OP_BRANCH CC GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr($2, 0, $3, $5, &$7); } + | OP_BRANCH GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, 0, $2, $5, &$7); } + | OP_BRANCH CC GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, 0, $3, $6, &$8); } + | OP_ADDCMPB GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr(ALWAYS, $2, $4, $6, &$8); } + | OP_ADDCMPB CC GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr($2, $3, $5, $7, &$9); } + | OP_ADDCMPB GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_reg_reg_instr(ALWAYS, $2, $5, $7, &$9); } + | OP_ADDCMPB CC GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_reg_reg_instr($2, $3, $6, $8, &$10); } + | OP_ADDCMPB GPR ',' GPR ',' '#' absexp ',' expr { branch_addcmp_reg_lit_instr(ALWAYS, $2, $4, $7, &$9); } + | OP_ADDCMPB CC GPR ',' GPR ',' '#' absexp ',' expr { branch_addcmp_reg_lit_instr($2, $3, $5, $8, &$10); } + | OP_ADDCMPB GPR ',' '#' absexp ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, $2, $5, $8, &$10); } + | OP_ADDCMPB CC GPR ',' '#' absexp ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, $3, $6, $9, &$11); } | OP_ONELREG GPR { diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 265e18f52..768d2eaee 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -388,3 +388,87 @@ void mem_address_instr(quad opcode, int rd, struct expr_t* expr) } } +/* Common code for handling addcmp: merge in as much of expr as will fit to + * the second pair of the addcmp opcode. */ + +static void branch_addcmp_common(quad opcode, int bits, struct expr_t* expr) +{ + quad type = expr->typ & S_TYP; + + switch (pass) + { + case 0: + /* Calculate size of instructions only. */ + + emit2(0); + break; + + case 1: + case 2: + { + if (type != DOTTYP) + serror("can't use this type of branch to jump outside the section"); + + /* The VC4 branch instructions express distance in 2-byte + * words. */ + + int d = (expr->val - DOTVAL-2 + 4) / 2; + + if (!fitx(d, bits)) + serror("target of branch is too far away"); + + emit2(opcode | maskx(d, bits)); + break; + } + } +} + +void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct expr_t* expr) +{ + if ((rd >= 0x10) || (ra >= 0x10) || (rs >= 0x10)) + serror("can only use r0-r15 in this instruction"); + + emit2(B16(10000000,00000000) | (cc<<8) | (ra<<4) | (rd<<0)); + branch_addcmp_common(B16(00000000,00000000) | (rs<<10), 10, expr); +} + +void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct expr_t* expr) +{ + if ((rd >= 0x10) || (rs >= 0x10)) + serror("can only use r0-r15 in this instruction"); + + if (!fitx(va, 4)) + serror("value too big to encode into instruction"); + va = maskx(va, 4); + + emit2(B16(10000000,00000000) | (cc<<8) | (va<<4) | (rd<<0)); + branch_addcmp_common(B16(01000000,00000000) | (rs<<10), 10, expr); +} + +void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr) +{ + if ((rd >= 0x10) || (ra >= 0x10)) + serror("can only use r0-r15 in this instruction"); + + if (!fitx(vs, 6)) + serror("value too big to encode into instruction"); + vs = maskx(vs, 6); + + emit2(B16(10000000,00000000) | (cc<<8) | (ra<<4) | (rd<<0)); + branch_addcmp_common(B16(10000000,00000000) | (vs<<8), 8, expr); +} + +void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr) +{ + if (rd >= 0x10) + serror("can only use r0-r15 in this instruction"); + + if (!fitx(va, 4) || !fitx(vs, 6)) + serror("value too big to encode into instruction"); + va = maskx(va, 4); + vs = maskx(vs, 6); + + emit2(B16(10000000,00000000) | (cc<<8) | (va<<4) | (rd<<0)); + branch_addcmp_common(B16(11000000,00000000) | (vs<<8), 8, expr); +} + diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s index a2104fcd7..87a50d070 100644 --- a/mach/vc4/test/opcodes.s +++ b/mach/vc4/test/opcodes.s @@ -353,3 +353,10 @@ near: ldb r0, main stb r0, near stb r0, main + + b.eq r0, r1, near + b r0, r1, near + addcmpb r0, r1, r2, . + addcmpb r0, #1, r2, . + addcmpb r0, r1, #1, . + addcmpb r0, #1, #2, . From a46ee9185912625037c13d89b7758c742127b0cc Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 23:18:36 +0100 Subject: [PATCH 030/231] Fix warning. --HG-- branch : dtrg-videocore --- mach/proto/ncg/fillem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index 8838d8f9c..516239b3d 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -82,6 +82,8 @@ extern char em_flag[]; extern short em_ptyp[]; extern double atof(); +void prolog(full nlocals); + /* Own version of atol that continues computing on overflow. We don't know that about the ANSI C one. */ From 80f85001fa4ec27f529726e5b3ca10ed9c3dfe9f Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 23:19:10 +0100 Subject: [PATCH 031/231] Correctly emit constants in some ALU instructions. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 768d2eaee..056a8b7aa 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -40,7 +40,7 @@ void alu_instr_lit(quad op, int cc, int rd, int ra, quad value) /* 32 bit medium form? */ - if (value >= 0x1f) + if (value <= 0x1f) { emit2(B16(11000000,00000000) | (op<<5) | (rd<<0)); emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | (value<<0)); From 61bff180824b3c4bb9aef2ca18cddd1589f770d4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 23:33:29 +0100 Subject: [PATCH 032/231] Added skeleton bootstrap code. --HG-- branch : dtrg-videocore rename : plat/pc86/boot.s => plat/rpi/boot.s --- plat/rpi/boot.s | 49 +++++++++++++++++++++++++++++++++++++++++++++++ plat/rpi/build.mk | 2 +- plat/rpi/descr | 6 +++--- 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 plat/rpi/boot.s diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s new file mode 100644 index 000000000..3cf4f3fe1 --- /dev/null +++ b/plat/rpi/boot.s @@ -0,0 +1,49 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +begtext: +#if 0 + ! Wipe the bss. (I'm a little suprised that __m_a_i_n doesn't do this.) + + mov di, begbss + mov cx, endbss + sub cx, di + mov ax, 0 + rep stosb + + ! Push standard parameters onto the stack and go. + + push envp ! envp + push argv ! argv + push 1 ! argc +#endif + b __m_a_i_n + +! Define symbols at the beginning of our various segments, so that we can find +! them. (Except .text, which has already been done.) + +.define begtext, begdata, begbss +.sect .data; begdata: +.sect .rom; begrom: +.sect .bss; begbss: + +! Some magic data. All EM systems need these. + +.define .trppc, .ignmask, _errno +.comm .trppc, 4 +.comm .ignmask, 4 +.comm _errno, 4 diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index 20aed87f7..679be61ea 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -43,5 +43,5 @@ define build-rpi-boot-impl $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) endef -#(eval $(build-rpi-boot-impl)) +$(eval $(build-rpi-boot-impl)) diff --git a/plat/rpi/descr b/plat/rpi/descr index 41dfc400f..fd9cc4dca 100644 --- a/plat/rpi/descr +++ b/plat/rpi/descr @@ -2,8 +2,8 @@ # $State$ # $Revision$ -var w=2 -var p=2 +var w=4 +var p=4 var s=2 var l=4 var f=4 @@ -12,7 +12,7 @@ var ARCH=vc4 var PLATFORM=rpi var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix -var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 +var ALIGN=-a0:2 -a1:4 -a2:4 -a3:4 var MACHOPT_F=-m8 # Override the setting in fe so that files compiled for this platform can see From 76ba0bf6b3c856670d173ddc083a9779b78ab5b4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 23:33:42 +0100 Subject: [PATCH 033/231] First steps towards a code generator. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/mach.c | 79 ++- mach/vc4/ncg/table | 1145 ++++++++++++++----------------------------- 2 files changed, 399 insertions(+), 825 deletions(-) diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c index f57a2a08f..375d8a6e7 100644 --- a/mach/vc4/ncg/mach.c +++ b/mach/vc4/ncg/mach.c @@ -8,10 +8,6 @@ #include #include -#ifndef NORCSID -static char rcsid[]= "$Id$" ; -#endif - int framesize; /* @@ -57,15 +53,14 @@ con_mult(word sz) #define FL_MSB_AT_LOW_ADDRESS 1 #include -prolog(full nlocals) +void prolog(full nlocals) { int ss = nlocals + 8; - fprintf(codefile, "addi sp, sp, %d\n", -ss); - fprintf(codefile, "stw fp, %d(sp)\n", nlocals); - fprintf(codefile, "mfspr r0, lr\n" - "stw r0, %d(sp)\n", nlocals+4); - fprintf(codefile, "addi fp, sp, %d\n", nlocals); - + fprintf(codefile, "push fp, lr\n"); + fprintf(codefile, "mov fp, sp\n"); + if (nlocals > 0) + fprintf(codefile, "sub sp, #%d\n", nlocals); + framesize = nlocals; } @@ -106,7 +101,7 @@ static int numsaved; /* Initialise regvar system for one function. */ -i_regsave() +void i_regsave(void) { int i; @@ -118,7 +113,7 @@ i_regsave() /* Mark a register as being saved. */ -regsave(const char* regname, full offset, int size) +void regsave(const char* regname, full offset, int size) { int regnum = atoi(regname+1); savedregsi[regnum] = offset; @@ -134,34 +129,29 @@ regsave(const char* regname, full offset, int size) /* Finish saving ragisters. */ -void saveloadregs(const char* ops, const char* opm) +static void saveloadregs(const char* op) { - int offset = -(framesize + numsaved*4); - int reg = 32; - - /* Check for the possibility of a multiple. */ - - do + int minreg = 32; + int maxreg = -1; + int i; + + for (i=0; i<32; i++) { - reg--; - } - while ((reg > 0) && (savedregsi[reg] != INT_MAX)); - if (reg < 31) - { - fprintf(codefile, "%s r%d, %d(fp)\n", opm, reg+1, offset); - offset += (31-reg)*4; - } - - /* Saved everything else singly. */ - - while (reg > 0) - { - if (savedregsi[reg] != INT_MAX) + if (savedregsi[i] != INT_MAX) { - fprintf(codefile, "%s r%d, %d(fp)\n", ops, reg, offset); - offset += 4; + if (i < minreg) + minreg = i; + if (i > maxreg) + maxreg = i; } - reg--; + } + + if (minreg != 32) + { + fprintf(codefile, "! saving registers %d to %d\n", minreg, maxreg); + assert(minreg == 6); + + fprintf(codefile, "%s r6-r%d\n", op, maxreg); } } @@ -169,13 +159,14 @@ f_regsave() { int i; fprintf(codefile, "! f_regsave()\n"); - fprintf(codefile, "addi sp, sp, %d\n", -numsaved*4); - - saveloadregs("stw", "stmw"); - + saveloadregs("push"); + for (i=0; i<32; i++) - if ((savedregsi[i] != INT_MAX) && (savedregsi[i] > 0)) - fprintf(codefile, "lwz r%d, %d(fp)\n", i, savedregsi[i]); + { + int o = savedregsi[i]; + if ((o != INT_MAX) && (o > 0)) + fprintf(codefile, "ld r%d, %d (fp)\n", i, savedregsi[i]); + } } /* Restore all saved registers. */ @@ -183,7 +174,7 @@ f_regsave() regreturn() { fprintf(codefile, "! regreturn()\n"); - saveloadregs("lwz", "lmw"); + saveloadregs("pop"); } /* Calculate the score of a given register. */ diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index f08ec3500..691d6076b 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -22,141 +22,68 @@ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ #define nicesize(x) ((x)==INT8 || (x)==INT16 || (x)==INT32 || (x)==INT64) -#define smalls(n) sfit(n, 16) -#define smallu(n) ufit(n, 16) - -#define lo(n) (n & 0xFFFF) -#define hi(n) ((n>>16) & 0xFFFF) - -/* Use these for instructions that treat the low half as signed --- his() - * includes a modifier to produce the correct value when the low half gets - * sign extended. Er, do make sure you load the low half second. */ -#define los(n) (n & 0xFFFF) -#define his(n) ((hi(n) - (lo(n)>>15)) & 0xFFFF) - -#define IFFALSE {CONST, 4} -#define IFTRUE {CONST, 12} -#define ALWAYS {CONST, 20} -#define DCTRZ {CONST, 34} - -#define LT {CONST, 0} -#define GT {CONST, 1} -#define EQ {CONST, 2} - PROPERTIES GPR /* any GPR */ REG /* any allocatable GPR */ - FPR /* any FPR */ - FREG /* any allocatable FPR */ - SPR /* any SPR */ - CR /* any CR */ - - GPR0 GPRSP GPRFP GPR3 GPR4 GPR5 GPR6 GPR7 + LREG /* any allocatable low register (r0-r15) */ + HREG /* any allocatable high register (r0-r15) */ + STACKABLE /* a push/popable register (r0, r6, r16, fp) */ + + GPR0 GPR1 GPR2 GPR3 GPR4 GPR5 GPR6 GPR7 GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15 GPR16 GPR17 GPR18 GPR19 GPR20 GPR21 GPR22 GPR23 - GPR24 GPR25 GPR26 GPR27 GPR28 GPR29 GPR30 GPR31 - - CR0 CR1 - FPR0 FPR1 FPR2 FPR3 FPR4 FPR5 FPR6 FPR7 - FPR8 FPR9 FPR10 FPR11 FPR12 FPR13 FPR14 FPR15 - FPR16 FPR17 FPR18 FPR19 FPR20 FPR21 FPR22 FPR23 - FPR24 FPR25 FPR26 FPR27 FPR28 FPR29 FPR30 FPR31 + GPRFP GPRSP GPRLR GPRPC REGISTERS - /* Reverse order to encourage ncg to allocate them from r31 down */ - - R31("r31") : GPR, REG, GPR31 regvar. - R30("r30") : GPR, REG, GPR30 regvar. - R29("r29") : GPR, REG, GPR29 regvar. - R28("r28") : GPR, REG, GPR28 regvar. - R27("r27") : GPR, REG, GPR27 regvar. - R26("r26") : GPR, REG, GPR26 regvar. - R25("r25") : GPR, REG, GPR25 regvar. - R24("r24") : GPR, REG, GPR24 regvar. - R23("r23") : GPR, REG, GPR23 regvar. - R22("r22") : GPR, REG, GPR22 regvar. - R21("r21") : GPR, REG, GPR21 regvar. - R20("r20") : GPR, REG, GPR20 regvar. - R19("r19") : GPR, REG, GPR19 regvar. - R18("r18") : GPR, REG, GPR18 regvar. - R17("r17") : GPR, REG, GPR17 regvar. - R16("r16") : GPR, REG, GPR16 regvar. - R15("r15") : GPR, REG, GPR15 regvar. - R14("r14") : GPR, REG, GPR14 regvar. - R13("r13") : GPR, REG, GPR13 regvar. - R12("r12") : GPR, REG, GPR12. - R11("r11") : GPR, GPR11. - R10("r10") : GPR, REG, GPR10. - R9("r9") : GPR, REG, GPR9. - R8("r8") : GPR, REG, GPR8. - R7("r7") : GPR, REG, GPR7. - R6("r6") : GPR, REG, GPR6. - R5("r5") : GPR, REG, GPR5. - R4("r4") : GPR, REG, GPR4. - R3("r3") : GPR, REG, GPR3. - FP("fp") : GPR, GPRFP. + R0("r0") : GPR, REG, LREG, STACKABLE, GPR0. + R1("r1") : GPR, REG, LREG, GPR1. + R2("r2") : GPR, REG, LREG, GPR2. + R3("r3") : GPR, REG, LREG, GPR3. + R4("r4") : GPR, REG, LREG, GPR4. + R5("r5") : GPR, REG, LREG, GPR5. + R6("r6") : GPR, REG, LREG, STACKABLE, GPR6 regvar. + R7("r7") : GPR, REG, LREG, GPR7 regvar. + R8("r8") : GPR, REG, LREG, GPR8 regvar. + R9("r9") : GPR, REG, LREG, GPR9 regvar. + R10("r10") : GPR, REG, LREG, GPR10 regvar. + R11("r11") : GPR, REG, LREG, GPR11 regvar. + R12("r12") : GPR, REG, LREG, GPR12 regvar. + R13("r13") : GPR, REG, LREG, GPR13 regvar. + R14("r14") : GPR, REG, LREG, GPR14 regvar. + R15("r15") : GPR, REG, LREG, GPR15 regvar. + + R16("r16") : GPR, REG, HREG, STACKABLE, GPR16 regvar. + R17("r17") : GPR, REG, HREG, GPR17 regvar. + R18("r18") : GPR, REG, HREG, GPR18 regvar. + R19("r19") : GPR, REG, HREG, GPR19 regvar. + R20("r20") : GPR, REG, HREG, GPR20 regvar. + R21("r21") : GPR, REG, HREG, GPR21 regvar. + R22("r22") : GPR, REG, HREG, GPR22 regvar. + R23("r23") : GPR, GPR23. + FP("fp") : GPR, GPRFP, STACKABLE. SP("sp") : GPR, GPRSP. - R0("r0") : GPR, GPR0. - - F31("f31") : FPR, FREG, FPR31. - F30("f30") : FPR, FREG, FPR30. - F29("f29") : FPR, FREG, FPR29. - F28("f28") : FPR, FREG, FPR28. - F27("f27") : FPR, FREG, FPR27. - F26("f26") : FPR, FREG, FPR26. - F25("f25") : FPR, FREG, FPR25. - F24("f24") : FPR, FREG, FPR24. - F23("f23") : FPR, FREG, FPR23. - F22("f22") : FPR, FREG, FPR22. - F21("f21") : FPR, FREG, FPR21. - F20("f20") : FPR, FREG, FPR20. - F19("f19") : FPR, FREG, FPR19. - F18("f18") : FPR, FREG, FPR18. - F17("f17") : FPR, FREG, FPR17. - F16("f16") : FPR, FREG, FPR16. - F15("f15") : FPR, FREG, FPR15. - F14("f14") : FPR, FREG, FPR14. - F13("f13") : FPR, FREG, FPR13. - F12("f12") : FPR, FREG, FPR12. - F11("f11") : FPR, FREG, FPR11. - F10("f10") : FPR, FREG, FPR10. - F9("f9") : FPR, FREG, FPR9. - F8("f8") : FPR, FREG, FPR8. - F7("f7") : FPR, FREG, FPR7. - F6("f6") : FPR, FREG, FPR6. - F5("f5") : FPR, FREG, FPR5. - F4("f4") : FPR, FREG, FPR4. - F3("f3") : FPR, FREG, FPR3. - F2("f2") : FPR, FREG, FPR2. - F1("f1") : FPR, FREG, FPR1. - F0("f0") : FPR, FREG, FPR0. - - LR("lr") : SPR. - CTR("ctr") : SPR. - C0("cr0") : CR, CR0. - -#define SCRATCH R11 -#define FSCRATCH F0 + LR("lr") : GPR, GPRLR. + PC("pc") : GPR, GPRPC. + /* r26 to r31 are special and the code generator doesn't touch them. */ +#define SCRATCH R23 TOKENS /* Used only in instruction descriptions (to generate the correct syntax). */ - GPRINDIRECT = { GPR reg; INT off; } 4 off "(" reg ")". - GPRINDIRECTLO = { GPR reg; ADDR adr; } 4 ">" adr "(" reg ")". /* Warning! Do not use on labels. */ - HILABEL = { ADDR adr; } 4 "<" adr. - LOLABEL = { ADDR adr; } 4 ">" adr. + GPROFFSET = { GPR reg; INT off; } 4 off "(" reg ")". + GPRGPR = { GPR reg1; GPR reg2; } 4 "(" reg1 "," reg2 ")". /* Primitives */ LABEL = { ADDR adr; } 4 adr. - CONST = { INT val; } 4 val. + CONST = { INT val; } 4 "#" val. LOCAL = { INT off; } 4. /* Allows us to use regvar() to refer to registers */ @@ -168,40 +95,27 @@ TOKENS SUM_RC = { GPR reg; INT off; } 4. SUM_RR = { GPR reg1; GPR reg2; } 4. - TRISTATE_RC_S = { GPR reg; INT val; } 4. - TRISTATE_RC_U = { GPR reg; INT val; } 4. - TRISTATE_RR_S = { GPR reg1; GPR reg2; } 4. - TRISTATE_RR_U = { GPR reg1; GPR reg2; } 4. - - TRISTATE_FF = { FPR reg1; FPR reg2; } 4. - SEX_B = { GPR reg; } 4. SEX_H = { GPR reg; } 4. IND_RC_B = { GPR reg; INT off; } 4. + IND_RR_B = { GPR reg1; GPR reg2; } 4. + IND_LABEL_B = { ADDR adr; } 4. + IND_RC_H = { GPR reg; INT off; } 4. + IND_RR_H = { GPR reg1; GPR reg2; } 4. + IND_LABEL_H = { ADDR adr; } 4. + IND_RC_H_S = { GPR reg; INT off; } 4. - IND_RC_W = { GPR reg; INT off; } 4. - IND_RR_W = { GPR reg1; GPR reg2; } 4. - IND_LABEL_W = { ADDR adr; } 4. + + IND_RC_Q = { GPR reg; INT off; } 4. + IND_RR_Q = { GPR reg1; GPR reg2; } 4. + IND_LABEL_Q = { ADDR adr; } 4. + IND_RC_D = { GPR reg; INT off; } 8. IND_RR_D = { GPR reg1; GPR reg2; } 8. IND_LABEL_D = { ADDR adr; } 8. - NOT_R = { GPR reg; } 4. - - AND_RR = { GPR reg1; GPR reg2; } 4. - AND_RC = { GPR reg; INT val; } 4. - OR_RR = { GPR reg1; GPR reg2; } 4. - OR_RC = { GPR reg; INT val; } 4. - XOR_RR = { GPR reg1; GPR reg2; } 4. - XOR_RC = { GPR reg; INT val; } 4. - -/* Floats */ - - FD = { FPR reg; } 8 reg. - FS = { FPR reg; } 4 reg. - /* Comments */ LABELI = { ADDR msg; INT num; } 4 msg " " num. @@ -216,116 +130,48 @@ SETS SUM_ALL = SUM_RC + SUM_RR. - TRISTATE_ALL = TRISTATE_RC_S + TRISTATE_RC_U + TRISTATE_RR_S + - TRISTATE_RR_U + TRISTATE_FF. - SEX_ALL = SEX_B + SEX_H. - LOGICAL_ALL = NOT_R + AND_RR + AND_RC + OR_RR + OR_RC + XOR_RR + - XOR_RC. - - IND_ALL_W = IND_RC_W + IND_RR_W + IND_LABEL_W. + IND_ALL_B = IND_RC_B + IND_RR_B + IND_LABEL_B. + IND_ALL_H = IND_RC_H + IND_RR_H + IND_LABEL_H. + IND_ALL_Q = IND_RC_Q + IND_RR_Q + IND_LABEL_Q. IND_ALL_D = IND_RC_D + IND_RR_D + IND_LABEL_D. - - OP_ALL_W = SUM_ALL + TRISTATE_ALL + SEX_ALL + LOGICAL_ALL + - IND_ALL_W. +#if 0 + OP_ALL_Q = SUM_ALL + TRISTATE_ALL + SEX_ALL + LOGICAL_ALL + + IND_ALL_Q. +#endif + + OP_ALL_Q = SUM_ALL + SEX_ALL + IND_ALL_B + IND_ALL_H + IND_ALL_Q. INSTRUCTIONS - add GPRI:wo, GPRI:ro, GPRI:ro. - addX "add." GPRI:wo, GPRI:ro, GPRI:ro. - addi GPRI:wo, GPRI:ro, CONST:ro. - addis GPRI:wo, GPRI:ro, CONST+HILABEL:ro. - and GPRI:wo, GPRI:ro, GPRI:ro. - andc GPRI:wo, GPRI:ro, GPRI:ro. - andiX "andi." GPRI:wo, GPRI:ro, CONST:ro kills :cc. - andisX "andis." GPRI:wo, GPRI:ro, CONST:ro kills :cc. - b LABEL:ro. - bc CONST:ro, CONST:ro, LABEL:ro. - bcctr CONST:ro, CONST:ro, CONST:ro. - bcctrl CONST:ro, CONST:ro, CONST:ro. - bclr CONST:ro, CONST:ro, CONST:ro. - bl LABEL:ro. - cmp CR:ro, CONST:ro, GPRI:ro, GPR:ro kills :cc. - cmpi CR:ro, CONST:ro, GPRI:ro, CONST:ro kills :cc. - cmpl CR:ro, CONST:ro, GPRI:ro, GPR:ro kills :cc. - cmpli CR:ro, CONST:ro, GPRI:ro, CONST:ro kills :cc. - divw GPRI:wo, GPRI:ro, GPRI:ro. - divwu GPRI:wo, GPRI:ro, GPRI:ro. - eqv GPRI:wo, GPRI:ro, GPRI:ro. - extsb GPRI:wo, GPRI:ro. - extsh GPRI:wo, GPRI:ro. - fadd FD:wo, FD:ro, FD:ro. - fadds FS:wo, FS:ro, FS:ro. - fcmpo CR:wo, FD:ro, FD:ro. - fdiv FD:wo, FD:ro, FD:ro. - fdivs FS:wo, FS:ro, FS:ro. - fneg FS+FD:wo, FS+FD:ro. - fmul FD:wo, FD:ro, FD:ro. - fmuls FS:wo, FS:ro, FS:ro. - frsp FS:wo, FD:ro. - fsub FD:wo, FD:ro, FD:ro. - fsubs FS:wo, FS:ro, FS:ro. - fmr FS+FD:wo, FS+FD:ro. - lbzx GPRI:wo, GPR:ro, GPR:ro. - lbz GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lfd FD:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lfdu FD:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lfdx FD:wo, GPR:ro, GPR:ro. - lfs FS:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lfsu FS:wo, GPRINDIRECT+GPRINDIRECTLO:rw. - lfsx FS:wo, GPR:ro, GPR:ro. - lhzx GPRI:wo, GPR:ro, GPR:ro. - lhax GPRI:wo, GPR:ro, GPR:ro. - lha GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lhz GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lwzu GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - lwzx GPRI:wo, GPR:ro, GPR:ro. - lwz GPRI:wo, GPRINDIRECT+GPRINDIRECTLO:ro. - nand GPRI:wo, GPRI:ro, GPRI:ro. - neg GPRI:wo, GPRI:ro. - nor GPRI:wo, GPRI:ro, GPRI:ro. - mfcr GPRI:wo. - mullw GPRI:wo, GPRI:ro, GPRI:ro. - mfspr GPRI:wo, SPR:ro. - mtspr SPR:wo, GPRI:ro. - or GPRI:wo, GPRI:ro, GPRI:ro. - orc GPRI:wo, GPRI:ro, GPRI:ro. - ori GPRI:wo, GPRI:ro, CONST+LOLABEL:ro. - orX "or." GPRI:wo, GPRI:ro, GPRI:ro kills :cc. - rlwinm GPRI:wo, GPRI:ro, CONST:ro, CONST:ro, CONST:ro. - slw GPRI:wo, GPRI:ro, GPRI:ro. - subf GPRI:wo, GPRI:ro, GPRI:ro. - sraw GPRI:wo, GPRI:ro, GPRI:ro. - srawi GPRI:wo, GPRI:ro, CONST:ro. - srw GPRI:wo, GPRI:ro, GPRI:ro. - stb GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - stbx GPRI:ro, GPR:ro, GPR:ro. - stfd FD:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - stfdu FD:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - stfdx FD:ro, GPR:ro, GPR:ro. - stfs FS:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - stfsu FS:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - stfsx FS:ro, GPR:ro, GPR:ro. - sth GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - sthx GPRI:ro, GPR:ro, GPR:ro. - stw GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - stwx GPRI:ro, GPR:ro, GPR:ro. - stwu GPRI:ro, GPRINDIRECT+GPRINDIRECTLO:rw. - xor GPRI:wo, GPRI:ro, GPRI:ro. - xori GPRI:wo, GPRI:ro, CONST:ro. + add GPRI:wo, GPRI:ro, GPRI+CONST:ro. + beq "b.eq" LABEL:ro. + bne "b.ne" LABEL:ro. + b GPRI+LABEL:ro. + bl GPRI+LABEL:ro. + cmp GPRI:ro, GPRI+CONST:ro. + exts GPRI:wo, GPRI:ro, GPRI+CONST:ro. + ld GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldb GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldh GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldhs GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. + lea GPRI:wo, LABEL:ro. + lsl GPRI:wo, GPRI:ro, GPRI+CONST:ro. + mov GPRI:wo, GPRI+CONST:ro. + pop STACKABLE:wo. + pop STACKABLE:wo, GPRLR+GPRPC:wo. + push STACKABLE:ro. + sub GPRI:wo, GPRI:ro, CONST+GPRI:ro. + st GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. + stb GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. + sth GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. + sths GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. - gpr_gpr_gpr GPRI:wo, GPRI:ro, GPRI:ro. - gpr_gpr_si GPRI:wo, GPRI:ro, CONST:ro. - gpr_ro_gprindirect GPRI:ro, GPRINDIRECT:rw. - gpr_ro_gpr_gpr GPRI:ro, GPRI:ro, GPRI:ro. - gpr_wo_gprindirect GPRI:wo, GPRINDIRECT:ro. - gpr_wo_gpr_gpr GPRI:wo, GPRI:ro, GPRI:ro. - - invalid "invalid". - comment "!" LABEL+LABELI:ro. + invalid "invalid". + comment "!" LABEL+LABELI:ro. @@ -333,8 +179,8 @@ MOVES from GPR to GPR gen - COMMENT("move GPR->GPR") - or %2, %1, %1 + COMMENT("mov GPR->GPR") + mov %2, %1 /* GPRE exists solely to allow us to use regvar() (which can only be used in an expression) as a register constant. */ @@ -342,455 +188,210 @@ MOVES from GPR to GPRE gen COMMENT("move GPR->GPRE") - or %2, %1, %1 - + mov %2, %1 + + from GPRE to GPR + gen + COMMENT("move GPRE->GPR") + mov %2, %1 + /* Constants */ - from CONST smalls(%val) to GPR - gen - COMMENT("move CONST->GPRE") - addi %2, R0, {CONST, lo(%1.val)} - from CONST to GPR gen - COMMENT("move CONST->GPRE") - addis %2, R0, {CONST, hi(%1.val)} - ori %2, %2, {CONST, lo(%1.val)} - + COMMENT("move CONST->GPR") + mov %2, %1 + from LABEL to GPR gen COMMENT("move LABEL->GPR") - addis %2, R0, {HILABEL, %1.adr} - ori %2, %2, {LOLABEL, %1.adr} - + lea %2, {LABEL, %1.adr} + /* Sign extension */ from SEX_B to GPR gen COMMENT("move SEX_B->GPR") - extsb %2, %1.reg - + exts %2, %1.reg, {CONST, 8} + from SEX_H to GPR gen COMMENT("move SEX_H->GPR") - extsh %2, %1.reg - + exts %2, %1.reg, {CONST, 16} + /* Register + something */ - from SUM_RC smalls(%off) to GPR - gen - COMMENT("move SUM_RC->GPR smalls") - addi %2, %1.reg, {CONST, lo(%1.off)} - from SUM_RC to GPR gen - COMMENT("move SUM_RC->GPR large") - addi %2, %1.reg, {CONST, los(%1.off)} - addis %2, %2, {CONST, his(%1.off)} - + COMMENT("move SUM_RC->GPR") + add %2, %1.reg, {CONST, %1.off} + from SUM_RR to GPR gen COMMENT("move SUM_RR->GPR") add %2, %1.reg1, %1.reg2 - + from SUM_RR to GPR gen COMMENT("move SUM_RR->GPRE") add %2, %1.reg1, %1.reg2 - -/* Read/write byte */ - from IND_RC_B smalls(%off) to GPR - gen - COMMENT("move IND_RC_B->GPR small") - lbz %2, {GPRINDIRECT, %1.reg, %1.off} - +/* Read byte */ + from IND_RC_B to GPR gen - COMMENT("move IND_RC_B->GPR large") - addis SCRATCH, %1.reg, {CONST, his(%1.off)} - lbz %2, {GPRINDIRECT, SCRATCH, los(%1.off)} - - from GPR to IND_RC_B smalls(%off) + COMMENT("move IND_RC_B->GPR") + ldb %2, {GPROFFSET, %1.reg, %1.off} + + from IND_RR_B to GPR gen - COMMENT("move GPR->IND_RC_B small") - stb %1, {GPRINDIRECT, %2.reg, %2.off} - + COMMENT("move IND_RR_B->GPR") + ldb %2, {GPRGPR, %1.reg1, %1.reg2} + + from IND_LABEL_B to GPR + gen + COMMENT("move IND_LABEL_B->GPR") + ldb %2, {LABEL, %1.adr} + +/* Write byte */ + from GPR to IND_RC_B gen - COMMENT("move GPR->IND_RC_B large") - addis SCRATCH, %2.reg, {CONST, his(%2.off)} - stb %1, {GPRINDIRECT, SCRATCH, los(%2.off)} - -/* Read/write short */ + COMMENT("move GPR->IND_RC_B") + stb %1, {GPROFFSET, %2.reg, %2.off} - from IND_RC_H smalls(%off) to GPR + from GPR to IND_RR_B gen - COMMENT("move IND_RC_H->GPR small") - lhz %2, {GPRINDIRECT, %1.reg, %1.off} - + COMMENT("move GPR->IND_RR_B") + stb %1, {GPRGPR, %2.reg1, %2.reg2} + + from GPR to IND_LABEL_B + gen + COMMENT("move GPR->IND_LABEL_B") + stb %1, {LABEL, %2.adr} + +/* Read short */ + from IND_RC_H to GPR gen - COMMENT("move IND_RC_H->GPR large") - addis SCRATCH, %1.reg, {CONST, his(%1.off)} - lhz %2, {GPRINDIRECT, SCRATCH, los(%1.off)} - - from IND_RC_H_S smalls(%off) to GPR + COMMENT("move IND_RC_H->GPR") + ldh %2, {GPROFFSET, %1.reg, %1.off} + + from IND_RR_H to GPR gen - COMMENT("move IND_RC_H_S->GPR small") - lha %2, {GPRINDIRECT, %1.reg, %1.off} - - from IND_RC_H_S to GPR + COMMENT("move IND_RR_H->GPR") + ldh %2, {GPRGPR, %1.reg1, %1.reg2} + + from IND_LABEL_H to GPR gen - COMMENT("move IND_RC_H_S->GPR large") - addis SCRATCH, %1.reg, {CONST, his(%1.off)} - lha %2, {GPRINDIRECT, SCRATCH, los(%1.off)} - - from GPR to IND_RC_H smalls(%off) - gen - COMMENT("move GPR->IND_RC_H small") - sth %1, {GPRINDIRECT, %2.reg, %2.off} - + COMMENT("move IND_LABEL_H->GPR") + ldh %2, {LABEL, %1.adr} + +/* Write short */ + from GPR to IND_RC_H gen - COMMENT("move GPR->IND_RC_H large") - addis SCRATCH, %2.reg, {CONST, his(%2.off)} - sth %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + COMMENT("move GPR->IND_RC_H") + sth %1, {GPROFFSET, %2.reg, %2.off} + + from GPR to IND_RR_H + gen + COMMENT("move GPR->IND_RR_H") + sth %1, {GPRGPR, %2.reg1, %2.reg2} + + from GPR to IND_LABEL_H + gen + COMMENT("move GPR->IND_LABEL_H") + sth %1, {LABEL, %2.adr} + +/* Read quad */ + + from IND_RC_Q to GPR + gen + COMMENT("move IND_RC_Q->GPR") + ld %2, {GPROFFSET, %1.reg, %1.off} -/* Read word */ - - from IND_RC_W smalls(%off) to GPR + from IND_RR_Q to GPR gen - COMMENT("move IND_RC_W->GPR small") - lwz %2, {GPRINDIRECT, %1.reg, %1.off} - - from IND_RC_W to GPR - gen - COMMENT("move IND_RC_W->GPR large") - addis %2, %1.reg, {CONST, his(%1.off)} - lwz %2, {GPRINDIRECT, %2, los(%1.off)} - - from IND_RR_W to GPR - gen - COMMENT("move IND_RR_W->GPR") - lwzx %2, %1.reg1, %1.reg2 + COMMENT("move IND_RR_Q->GPR") + ld %2, {GPRGPR, %1.reg1, %1.reg2} - from IND_LABEL_W to GPR + from IND_LABEL_Q to GPR gen - COMMENT("move IND_LABEL_W->GPR") - move {LABEL, %1.adr}, SCRATCH - lwz %2, {GPRINDIRECT, SCRATCH, 0} - - from IND_RC_W smalls(%off) to FS - gen - COMMENT("move IND_RC_W->FS small") - lfs %2, {GPRINDIRECT, %1.reg, %1.off} - - from IND_RC_W to FS - gen - COMMENT("move IND_RC_W->FS large") - addis SCRATCH, %1.reg, {CONST, his(%1.off)} - lfs %2, {GPRINDIRECT, SCRATCH, los(%1.off)} + COMMENT("move IND_LABEL_Q->GPR") + ld %2, {LABEL, %1.adr} - from IND_RR_W to FS - gen - COMMENT("move IND_RR_W->FS") - lfsx %2, %1.reg1, %1.reg2 - - from IND_LABEL_W to FS - gen - COMMENT("move IND_LABEL_W->FS") - move {LABEL, %1.adr}, SCRATCH - lfs %2, {GPRINDIRECT, SCRATCH, 0} - -/* Write word */ +/* Write quad */ - from GPR to IND_RC_W smalls(%off) + from GPR to IND_RC_Q gen - COMMENT("move GPR->IND_RC_W small") - stw %1, {GPRINDIRECT, %2.reg, %2.off} - - from GPR to IND_RC_W - gen - COMMENT("move GPR->IND_RC_W large") - addis SCRATCH, %2.reg, {CONST, his(%2.off)} - stw %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + COMMENT("move GPR->IND_RC_Q") + st %1, {GPROFFSET, %2.reg, %2.off} - from GPR to IND_RR_W + from GPR to IND_RR_Q gen - COMMENT("move GPR->IND_RR_W") - stwx %1, %2.reg1, %2.reg2 - - from GPR to IND_LABEL_W - gen - COMMENT("move GPR->IND_LABEL_D") - move {LABEL, %2.adr}, SCRATCH - stw %1, {GPRINDIRECT, SCRATCH, 0} - - from FS to IND_RC_W smalls(%off) - gen - COMMENT("move FS->IND_RC_W small") - stfs %1, {GPRINDIRECT, %2.reg, %2.off} - - from FS to IND_RC_W - gen - COMMENT("move FS->IND_RC_W large") - addis SCRATCH, %2.reg, {CONST, his(%2.off)} - stfs %1, {GPRINDIRECT, SCRATCH, los(%2.off)} + COMMENT("move GPR->IND_RR_Q") + st %1, {GPRGPR, %2.reg1, %2.reg2} - from FS to IND_RR_W + from GPR to IND_LABEL_Q gen - COMMENT("move FS->IND_RR_W") - stfsx %1, %2.reg1, %2.reg2 - - from FS to IND_LABEL_W - gen - COMMENT("move FS->IND_LABEL_D") - move {LABEL, %2.adr}, SCRATCH - stfs %1, {GPRINDIRECT, SCRATCH, 0} - -/* Read double */ - - from IND_RC_D smalls(%off) to FD - gen - COMMENT("move IND_RC_D->FD small") - lfd %2, {GPRINDIRECT, %1.reg, %1.off} - - from IND_RC_D to FD - gen - COMMENT("move IND_RC_D->FD large") - addis SCRATCH, %1.reg, {CONST, his(%1.off)} - lfd %2, {GPRINDIRECT, SCRATCH, los(%1.off)} - - from IND_RR_D to FD - gen - COMMENT("move IND_RR_D->FD") - lfdx %2, %1.reg1, %1.reg2 - - from IND_LABEL_D to FD - gen - COMMENT("move IND_LABEL_D->FD") - move {LABEL, %1.adr}, SCRATCH - lfd %2, {GPRINDIRECT, SCRATCH, 0} - -/* Write double */ - - from FD to IND_RC_D smalls(%off) - gen - COMMENT("move FD->IND_RC_D small") - stfd %1, {GPRINDIRECT, %2.reg, %2.off} - - from FD to IND_RC_D - gen - COMMENT("move FD->IND_RC_D large") - addis SCRATCH, %2.reg, {CONST, his(%2.off)} - stfd %1, {GPRINDIRECT, SCRATCH, los(%2.off)} - - from FD to IND_RR_D - gen - COMMENT("move FD->IND_RR_W") - stfdx %1, %2.reg1, %2.reg2 - - from FD to IND_LABEL_D - gen - COMMENT("move FD->IND_LABEL_D") - move {LABEL, %2.adr}, SCRATCH - stfd %1, {GPRINDIRECT, SCRATCH, 0} - -/* Extract condition code field (actually produces (CC&3)<<2) */ - - from CR0 to GPR - gen - COMMENT("move CR0->GPR") - mfcr %2 - rlwinm %2, %2, {CONST, 4}, {CONST, 32-4}, {CONST, 31-2} - -/* Comparisons */ - - from TRISTATE_RR_S to CR0 - gen - cmp %2, {CONST, 0}, %1.reg1, %1.reg2 - - from TRISTATE_RR_U to CR0 - gen - cmpl %2, {CONST, 0}, %1.reg1, %1.reg2 - - from TRISTATE_RC_S to CR0 - gen - COMMENT("move TRISTATE_RC_S->CR0 large") - move {CONST, %1.val}, SCRATCH - cmp %2, {CONST, 0}, %1.reg, SCRATCH - - from TRISTATE_RC_U smallu(%val) to CR0 - gen - COMMENT("move TRISTATE_RC_U->CR0 small") - cmpli %2, {CONST, 0}, %1.reg, {CONST, %1.val} - - from TRISTATE_RC_U to CR0 - gen - COMMENT("move TRISTATE_RC_U->CR0") - move {CONST, %1.val}, SCRATCH - cmpl %2, {CONST, 0}, %1.reg, SCRATCH - - from TRISTATE_FF to CR0 - gen - COMMENT("move TRISTATE_FF->CR0") - fcmpo %2, {FD, %1.reg1}, {FD, %1.reg2} - - from GPR to CR0 - gen - COMMENT("move GPR->CR0") - orX SCRATCH, %1, %1 /* alas, can't call test */ - - from TRISTATE_RR_S + TRISTATE_RC_S + TRISTATE_FF to GPR - gen - COMMENT("move TRISTATE_R*_S->GPR") - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tristate_s_table"}, %2 - lwzx %2, %2, SCRATCH - - from TRISTATE_RR_U + TRISTATE_RC_U to GPR - gen - COMMENT("move TRISTATE_R*_U->GPR") - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tristate_u_table"}, %2 - lwzx %2, %2, SCRATCH - -/* Logicals */ - - from NOT_R to GPR - gen - COMMENT("move NOT_R->GPR") - nor %2, %1.reg, %1.reg - - from AND_RR to GPR - gen - COMMENT("move AND_RR->GPR") - and %2, %1.reg1, %1.reg2 - - from AND_RC smallu(%val) to GPR - gen - COMMENT("move AND_RC->GPR small") - andiX %2, %1.reg, {CONST, %1.val} - - from AND_RC to GPR - gen - COMMENT("move AND_RC->GPR") - move {CONST, %1.val}, SCRATCH - and %2, %1.reg, SCRATCH - - from OR_RR to GPR - gen - COMMENT("move OR_RR->GPR") - or %2, %1.reg1, %1.reg2 - - from OR_RC smallu(%val) to GPR - gen - COMMENT("move OR_RC->GPR small") - ori %2, %1.reg, {CONST, %1.val} - - from OR_RC to GPR - gen - COMMENT("move OR_RC->GPR") - move {CONST, %1.val}, SCRATCH - or %2, %1.reg, SCRATCH - - from XOR_RR to GPR - gen - COMMENT("move XOR_RR->GPR") - xor %2, %1.reg1, %1.reg2 - - from XOR_RC smallu(%val) to GPR - gen - COMMENT("move XOR_RC->GPR small") - xori %2, %1.reg, {CONST, %1.val} - - from XOR_RC to GPR - gen - COMMENT("move XOR_RC->GPR") - move {CONST, %1.val}, SCRATCH - xor %2, %1.reg, SCRATCH + COMMENT("move GPR->IND_LABEL_Q") + st %1, {LABEL, %2.adr} /* Miscellaneous */ - from OP_ALL_W + LABEL + CONST to GPRE + from CONST + LABEL + GPR + OP_ALL_Q to GPRE gen move %1, %2.reg - + +#if 0 TESTS - + to test GPR gen - orX SCRATCH, %1, %1 + invalid +#endif STACKINGRULES - - from GPR to STACK + + from STACKABLE to STACK gen - COMMENT("stack GPR") - stwu %1, {GPRINDIRECT, SP, 0-4} - - from CONST to STACK - uses REG + COMMENT("stack STACKABLE") + push %1 + + from REG to STACK + uses STACKABLE + gen + COMMENT("stack non-STACKABLE") + move %1, %a + push %a + + from REG to STACK + gen + COMMENT("stack non-STACKABLE, fallback") + sub SP, SP, {CONST, 4} + st %1, {GPROFFSET, SP, 0} + + from CONST + OP_ALL_Q to STACK + uses STACKABLE gen - COMMENT("stack CONST") move %1, %a - stwu %a, {GPRINDIRECT, SP, 0-4} - - from LABEL to STACK - uses REG - gen - COMMENT("stack LABEL") - move %1, {GPRE, %a} - stwu %a, {GPRINDIRECT, SP, 0-4} - - from SEX_B to STACK - gen - COMMENT("stack SEX_B") - extsb SCRATCH, %1.reg - stwu SCRATCH, {GPRINDIRECT, SP, 0-4} - - from SEX_H to STACK - gen - COMMENT("stack SEX_H") - extsh SCRATCH, %1.reg - stwu SCRATCH, {GPRINDIRECT, SP, 0-4} - - from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL to STACK - gen - move %1, {GPRE, SCRATCH} - stwu SCRATCH, {GPRINDIRECT, SP, 0-4} - - from IND_ALL_W to STACK + push %a + + from CONST + OP_ALL_Q to STACK gen + COMMENT("fallback stack") move %1, SCRATCH - stwu SCRATCH, {GPRINDIRECT, SP, 0-4} - - from IND_ALL_D to STACK - gen - move %1, {FD, FSCRATCH} - stfdu {FD, FSCRATCH}, {GPRINDIRECT, SP, 0-8} - - from FD to STACK - gen - COMMENT("stack FD") - stfdu %1, {GPRINDIRECT, SP, 0-8} - - from FS to STACK - gen - COMMENT("stack FS") - stfsu %1, {GPRINDIRECT, SP, 0-4} + sub SP, SP, {CONST, 4} + st SCRATCH, {GPROFFSET, SP, 0} from TOKEN to STACK gen invalid. - - + COERCIONS @@ -800,7 +401,14 @@ COERCIONS COMMENT("coerce REG->REG") move %1, %a yields %a - + + from GPRE + uses REG + gen + COMMENT("coerce GPRE->REG") + move %1, %a + yields %a + from CONST uses REG gen @@ -812,83 +420,49 @@ COERCIONS uses REG gen COMMENT("coerce LABEL->REG") - move %1, {GPRE, %a} + move %1, %a yields %a - + from STACK - uses REG + uses STACKABLE gen COMMENT("coerce STACK->REG") - lwz %a, {GPRINDIRECT, SP, 0} - addi SP, SP, {CONST, 4} + pop %a yields %a - + from SEX_B uses REG gen COMMENT("coerce SEX_B->REG") - extsb %a, %1.reg + exts %a, %1.reg, {CONST, 8} yields %a from SEX_H uses REG gen COMMENT("coerce SEX_H->REG") - extsh %a, %1.reg + exts %a, %1.reg, {CONST, 16} yields %a - + +#if 0 from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL uses REG gen move %1, {GPRE, %a} yields %a - from FS - uses FREG - gen - fmr {FS, %a}, %1 - yields {FS, %a} - - from FD - uses FREG - gen - fmr {FD, %a}, %1 - yields {FD, %a} - - from STACK - uses FREG - gen - COMMENT("coerce STACK->FD") - lfd {FD, %a}, {GPRINDIRECT, SP, 0} - addi SP, SP, {CONST, 8} - yields {FD, %a} - - from STACK - uses FREG - gen - COMMENT("coerce STACK->FS") - lfs {FS, %a}, {GPRINDIRECT, SP, 0} - addi SP, SP, {CONST, 4} - yields {FS, %a} - - from IND_ALL_W + from IND_ALL_Q uses REG gen move %1, %a yields %a - - from IND_ALL_W - uses FREG +#endif + from OP_ALL_Q + uses REG gen - move %1, {FS, %a} - yields {FS, %a} - - from IND_ALL_D - uses FREG - gen - move %1, {FD, %a} - yields {FD, %a} - + move %1, %a + yields %a + @@ -900,15 +474,15 @@ PATTERNS yields {CONST, $1} pat dup $1==INT32 /* Duplicate word on top of stack */ - with GPR + with REG yields %1 %1 pat dup $1==INT64 /* Duplicate double-word on top of stack */ - with GPR GPR + with REG REG yields %2 %1 %2 %1 pat exg $1==INT32 /* Exchange top two words on stack */ - with GPR GPR + with REG REG yields %1 %2 pat stl lol $1==$2 /* Store then load local */ @@ -964,11 +538,11 @@ PATTERNS /* nop */ pat loc loc cii $1==INT8 && $2==INT32 /* signed char -> signed int */ - with GPR + with REG yields {SEX_B, %1} pat loc loc cii $1==2 && $2==4 /* signed char -> signed short */ - with GPR + with REG yields {SEX_H, %1} @@ -992,13 +566,13 @@ PATTERNS leaving lal $1 loi INT32*2 - + pat stl inreg($1)>0 /* Store to local */ - with CONST + LABEL + GPR + OP_ALL_W + with CONST + LABEL + GPR + OP_ALL_Q kills regvar($1), LOCAL %off==$1 gen move %1, {GPRE, regvar($1)} - + pat stl /* Store to local */ leaving lal $1 @@ -1012,7 +586,7 @@ PATTERNS pat lil inreg($1)>0 /* Load from indirected local */ uses REG gen - lwz %a, {GPRINDIRECT, regvar($1), 0} + ld %a, {GPROFFSET, regvar($1), 0} yields %a pat lil /* Load from indirected local */ @@ -1084,19 +658,21 @@ PATTERNS loc 0 ste $1 +#if 0 pat ine /* Increment external */ uses REG={LABEL, $1}, REG gen - lwz %b, {GPRINDIRECT, %a, 0} + lwz %b, {GPROFFSET, %a, 0} addi %b, %b, {CONST, 1} - stw %b, {GPRINDIRECT, %a, 0} + stw %b, {GPROFFSET, %a, 0} pat dee /* Decrement external */ uses REG={LABEL, $1}, REG gen - lwz %b, {GPRINDIRECT, %a, 0} + lwz %b, {GPROFFSET, %a, 0} addi %b, %b, {CONST, 0-1} - stw %b, {GPRINDIRECT, %a, 0} + stw %b, {GPROFFSET, %a, 0} +#endif @@ -1128,26 +704,18 @@ PATTERNS pat loi $1==INT8 /* Load byte indirect */ with GPR - uses REG - gen - lbz %a, {GPRINDIRECT, %1, 0} - yields %a + yields {IND_RC_B, %1, 0} with SUM_RR - uses reusing %1, REG - gen - lbzx %a, %1.reg1, %1.reg2 - yields %a + yields {IND_RR_B, %1.reg1, %1.reg2} with SUM_RC - uses REG - gen - move {IND_RC_B, %1.reg, %1.off}, %a - yields %a - + yields {IND_RC_B, %1.reg, %1.off} + +#if 0 pat loi loc loc cii $1==INT16 && $2==INT16 && $3==INT32 /* Load half-word indirect and sign extend */ with GPR uses REG gen - lha %a, {GPRINDIRECT, %1, 0} + lha %a, {GPROFFSET, %1, 0} yields %a with SUM_RR uses reusing %1, REG @@ -1164,7 +732,7 @@ PATTERNS with GPR uses REG gen - lhz %a, {GPRINDIRECT, %1, 0} + lhz %a, {GPROFFSET, %1, 0} yields %a with SUM_RR uses reusing %1, REG @@ -1176,18 +744,20 @@ PATTERNS gen move {IND_RC_H, %1.reg, %1.off}, %a yields %a +#endif - pat loi $1==INT32 /* Load word indirect */ + pat loi $1==INT32 /* Load quad indirect */ with GPR - yields {IND_RC_W, %1, 0} + yields {IND_RC_Q, %1, 0} with SUM_RC - yields {IND_RC_W, %1.reg, %1.off} + yields {IND_RC_Q, %1.reg, %1.off} with SUM_RR - yields {IND_RR_W, %1.reg1, %1.reg2} + yields {IND_RR_Q, %1.reg1, %1.reg2} with LABEL - yields {IND_LABEL_W, %1.adr} + yields {IND_LABEL_Q, %1.adr} - pat loi $1==INT64 /* Load double-word indirect */ +#if 0 + pat loi $1==INT64 /* Load double-quad indirect */ with GPR yields {IND_RC_D, %1, 0} with SUM_RC @@ -1196,6 +766,7 @@ PATTERNS yields {IND_RR_D, %1.reg1, %1.reg2} with LABEL yields {IND_LABEL_D, %1.adr} +#endif pat loi /* Load arbitrary size */ leaving @@ -1203,7 +774,7 @@ PATTERNS los INT32 pat los /* Load arbitrary size */ - with GPR3 GPR4 STACK + with GPR0 GPR1 STACK kills ALL gen bl {LABEL, ".los"} @@ -1211,57 +782,64 @@ PATTERNS pat sti $1==INT8 /* Store byte indirect */ with GPR GPR gen - stb %2, {GPRINDIRECT, %1, 0} + move %2, {IND_RC_B, %1, 0} with SUM_RR GPR gen - stbx %2, %1.reg1, %1.reg2 + move %2, {IND_RR_B, %1.reg1, %1.reg2} with SUM_RC GPR gen move %2, {IND_RC_B, %1.reg, %1.off} with GPR SEX_B gen - stb %2.reg, {GPRINDIRECT, %1, 0} + move %2.reg, {IND_RC_B, %1, 0} with SUM_RR SEX_B gen - stbx %2.reg, %1.reg1, %1.reg2 + move %2.reg, {IND_RR_B, %1.reg1, %1.reg2} with SUM_RC SEX_B gen move %2.reg, {IND_RC_B, %1.reg, %1.off} + with LABEL GPR + gen + move %2, {IND_LABEL_B, %1.adr} pat sti $1==INT16 /* Store half-word indirect */ with GPR GPR gen - sth %2, {GPRINDIRECT, %1, 0} + move %2, {IND_RC_H, %1, 0} with SUM_RR GPR gen - sthx %2, %1.reg1, %1.reg2 + move %2, {IND_RR_H, %1.reg1, %1.reg2} with SUM_RC GPR gen move %2, {IND_RC_H, %1.reg, %1.off} with GPR SEX_H gen - sth %2.reg, {GPRINDIRECT, %1, 0} + move %2.reg, {IND_RC_H, %1, 0} with SUM_RR SEX_H gen - sthx %2.reg, %1.reg1, %1.reg2 + move %2.reg, {IND_RR_H, %1.reg1, %1.reg2} with SUM_RC SEX_H gen move %2.reg, {IND_RC_H, %1.reg, %1.off} + with LABEL GPR + gen + move %2, {IND_LABEL_H, %1.adr} - pat sti $1==INT32 /* Store word indirect */ - with GPR GPR+FS + pat sti $1==INT32 /* Store quad indirect */ + with GPR GPR gen - move %2, {IND_RC_W, %1, 0} - with SUM_RR GPR+FS + move %2, {IND_RC_Q, %1, 0} + with SUM_RR GPR gen - move %2, {IND_RR_W, %1.reg1, %1.reg2} - with SUM_RC GPR+FS + move %2, {IND_RR_Q, %1.reg1, %1.reg2} + with SUM_RC GPR gen - move %2, {IND_RC_W, %1.reg, %1.off} - with LABEL GPR+FS + move %2, {IND_RC_Q, %1.reg, %1.off} + with LABEL GPR gen - move %2, {IND_LABEL_W, %1.adr} + move %2, {IND_LABEL_Q, %1.adr} +#if 0 pat sti $1==INT64 /* Store double-word indirect */ with GPR FD gen @@ -1274,12 +852,12 @@ PATTERNS move %2, {IND_RC_D, %1.reg, %1.off} with GPR GPR GPR gen - stw %2, {GPRINDIRECT, %1, 0} - stw %3, {GPRINDIRECT, %1, 4} + stw %2, {GPROFFSET, %1, 0} + stw %3, {GPROFFSET, %1, 4} with SUM_RC GPR GPR gen - move %2, {IND_RC_W, %1.reg, %1.off} - move %3, {IND_RC_W, %1.reg, %1.off+4} + move %2, {IND_RC_Q, %1.reg, %1.off} + move %3, {IND_RC_Q, %1.reg, %1.off+4} with LABEL FD gen move %2, {IND_LABEL_D, %1.adr} @@ -1295,6 +873,7 @@ PATTERNS kills ALL gen bl {LABEL, ".sts"} +#endif @@ -1351,7 +930,7 @@ PATTERNS /* Word arithmetic */ - pat adi $1==4 /* Add word (second + top) */ + pat adi $1==INT32 /* Add word (second + top) */ with REG REG yields {SUM_RR, %1, %2} with CONST REG @@ -1362,7 +941,8 @@ PATTERNS yields {SUM_RC, %2.reg, %2.off+%1.val} with CONST LABEL yields {LABEL, %2.adr+%1.val} - + +#if 0 pat sbi $1==4 /* Subtract word (second - top) */ with REG REG uses reusing %2, REG @@ -1504,19 +1084,16 @@ PATTERNS with STACK gen bl {LABEL, ".com"} +#endif pat sli $1==4 /* Shift left (second << top) */ - with CONST GPR + with CONST+GPR GPR uses reusing %2, REG gen - rlwinm %a, %2, {CONST, (%1.val & 0x1F)}, {CONST, 0}, {CONST, 31-(%1.val & 0x1F)} + lsl %a, %2, %1 yields %a - with GPR GPR - uses reusing %2, REG - gen - slw %a, %2, %1 - yields %a - + +#if 0 pat sri $1==4 /* Shift right signed (second >> top) */ with CONST GPR uses reusing %2, REG @@ -1664,34 +1241,38 @@ PATTERNS move {LABEL, ".tge_table"}, %a lwzx %a, %a, SCRATCH yields %a - + +#endif /* Simple branches */ pat zeq /* Branch if signed top == 0 */ - with TRISTATE_ALL+GPR STACK + with GPR STACK gen - move %1, C0 - bc IFTRUE, EQ, {LABEL, $1} + cmp %1, {CONST, 0} + beq {LABEL, $1} pat beq - leaving - cmi INT32 - zeq $1 - - pat zne /* Branch if signed top != 0 */ - with TRISTATE_ALL+GPR STACK + with GPR GPR STACK gen - move %1, C0 - bc IFFALSE, EQ, {LABEL, $1} + cmp %1, %2 + beq {LABEL, $1} + + pat zne /* Branch if signed top != 0 */ + with GPR STACK + gen + cmp %1, {CONST, 0} + bne {LABEL, $1} pat bne - leaving - cmi INT32 - zne $1 - + with GPR GPR STACK + gen + cmp %1, %2 + bne {LABEL, $1} + +#if 0 pat zgt /* Branch if signed top > 0 */ with TRISTATE_ALL+GPR STACK gen @@ -1735,8 +1316,10 @@ PATTERNS leaving cmi INT32 zle $1 +#endif +#if 0 /* Compare and jump */ pat cmi /* Signed tristate compare */ @@ -1780,17 +1363,13 @@ PATTERNS kills ALL gen labeldef $1 - - pat bra topeltsize($1)==4 /* Unconditional jump with TOS GPRister */ - with GPR3 STACK - gen - b {LABEL, $1} - - pat bra topeltsize($1)!=4 /* Unconditional jump without TOS GPRister */ +#endif + + pat bra /* Unconditional jump */ with STACK gen b {LABEL, $1} - + /* Miscellaneous */ @@ -1805,49 +1384,52 @@ PATTERNS with GPR STACK kills ALL gen - mtspr CTR, %1 - bcctrl ALWAYS, {CONST, 0}, {CONST, 0} - + bl %1 + pat lfr $1==INT32 /* Load function result, word */ - yields R3 + yields R0 pat lfr $1==INT64 /* Load function result, double-word */ - yields R4 R3 - + yields R0 R1 + pat ret $1==0 /* Return from procedure */ gen return - b {LABEL, ".ret"} - + mov SP, FP + pop FP, PC + pat ret $1==INT32 /* Return from procedure, word */ - with GPR3 + with GPR0 gen return - b {LABEL, ".ret"} + mov SP, FP + pop FP, PC pat ret $1==INT64 /* Return from procedure, double-word */ - with GPR3 GPR4 + with GPR0 GPR1 gen return - b {LABEL, ".ret"} + mov SP, FP + pop FP, PC +#if 0 pat blm /* Block move constant length */ with GPR GPR STACK uses REG gen move {CONST, $1}, %a - stwu %a, {GPRINDIRECT, SP, 0-4} - stwu %2, {GPRINDIRECT, SP, 0-4} - stwu %1, {GPRINDIRECT, SP, 0-4} + stwu %a, {GPROFFSET, SP, 0-4} + stwu %2, {GPROFFSET, SP, 0-4} + stwu %1, {GPROFFSET, SP, 0-4} bl {LABEL, "_memmove"} addi SP, SP, {CONST, 12} pat bls /* Block move variable length */ with GPR GPR GPR STACK gen - stwu %1, {GPRINDIRECT, SP, 0-4} - stwu %3, {GPRINDIRECT, SP, 0-4} - stwu %2, {GPRINDIRECT, SP, 0-4} + stwu %1, {GPROFFSET, SP, 0-4} + stwu %3, {GPROFFSET, SP, 0-4} + stwu %2, {GPROFFSET, SP, 0-4} bl {LABEL, "_memmove"} addi SP, SP, {CONST, 12} @@ -1913,7 +1495,7 @@ PATTERNS with GPR uses reusing %1, REG gen - lwz %a, {GPRINDIRECT, %1, FP_OFFSET} + lwz %a, {GPROFFSET, %1, FP_OFFSET} yields %a pat lpb /* Convert FP to argument address */ @@ -1929,9 +1511,9 @@ PATTERNS uses REG gen move {LABEL, $1}, %a - move {IND_RC_W, %a, 8}, FP - move {IND_RC_W, %a, 4}, SP - move {IND_RC_W, %a, 0}, %a + move {IND_RC_Q, %a, 8}, FP + move {IND_RC_Q, %a, 4}, SP + move {IND_RC_Q, %a, 0}, %a mtspr CTR, %a bcctr ALWAYS, {CONST, 0}, {CONST, 0} @@ -1952,6 +1534,7 @@ PATTERNS gen wspec {CONST, $1} +#endif #endif pat lor $1==0 /* Load FP */ @@ -1983,17 +1566,17 @@ PATTERNS pat str $1==2 /* Store HP */ leaving ste ".reghp" - + pat ass /* Adjust stack by variable amount */ with CONST gen - move {SUM_RC, SP, %1.val}, {GPRE, SP} + move {SUM_RC, SP, %1.val}, SP with GPR gen - move {SUM_RR, SP, %1}, {GPRE, SP} + move {SUM_RR, SP, %1}, SP pat asp /* Adjust stack by constant amount */ leaving loc $1 ass - + From 11890026db9f4a2b3978284fa493d383020015a9 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 May 2013 23:34:42 +0100 Subject: [PATCH 034/231] Push/pop are the right way round. Don't corrup short-form ALU instructions. Correct encoding of push/pop register ranges. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach3.c | 4 ++-- mach/vc4/as/mach5.c | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index aba49dca2..f47c024dd 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -133,8 +133,8 @@ 0, OP_MISCL, B16(11000100,10000000), "divs", 0, OP_MISCL, B16(11000100,11100000), "divu", -0, OP_STACK, B16(00000010,00000000), "push", -0, OP_STACK, B16(00000010,10000000), "pop", +0, OP_STACK, B16(00000010,10000000), "push", +0, OP_STACK, B16(00000010,00000000), "pop", 0, OP_MEM, B8(00000000), "ld", 0, OP_MEM, B8(00000001), "st", diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 056a8b7aa..6314ed1f3 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -13,7 +13,7 @@ void alu_instr_reg(quad op, int cc, int rd, int ra, int rb) { /* Can we use short form? */ - if ((cc == ALWAYS) && (ra == rd)) + if ((cc == ALWAYS) && (ra == rd) && (ra < 0x10) && (rb < 0x10)) { emit2(B16(01000000,00000000) | (op<<8) | (rb<<4) | (rd<<0)); return; @@ -32,7 +32,7 @@ void alu_instr_lit(quad op, int cc, int rd, int ra, quad value) /* 16 bit short form? */ if ((cc == ALWAYS) && !(op & 1) && (value <= 0x1f) && (ra == rd) && - !(ra & 0x10)) + (ra < 0x10)) { emit2(B16(01100000,00000000) | (op<<8) | (value<<4) | (rd<<0)); return; @@ -162,6 +162,7 @@ void branch_instr(int bl, int cc, struct expr_t* expr) void stack_instr(quad opcode, int loreg, int hireg, int extrareg) { int b; + int m; switch (loreg) { @@ -172,15 +173,13 @@ void stack_instr(quad opcode, int loreg, int hireg, int extrareg) case 26: /* lr */ extrareg = 26; - hireg = 31; - loreg = 0; + hireg = loreg = -1; b = 0; break; case 31: /* pc */ extrareg = 31; - hireg = 31; - loreg = 0; + hireg = loreg = -1; b = 0; break; @@ -189,23 +188,27 @@ void stack_instr(quad opcode, int loreg, int hireg, int extrareg) } if (opcode & 0x0080) - { - /* Pop */ - if (extrareg == 26) - serror("cannot pop lr"); - } - else { /* Push */ if (extrareg == 31) serror("cannot push pc"); } + else + { + /* Pop */ + if (extrareg == 26) + serror("cannot pop lr"); + } if (hireg < loreg) serror("invalid register range"); - emit2(opcode | (b<<5) | (hireg<<0) | - ((extrareg != -1) ? 0x0100 : 0)); + if (hireg == -1) + m = 31; + else + m = hireg - loreg; + + emit2(opcode | (b<<5) | (m<<0) | ((extrareg != -1) ? 0x0100 : 0)); } /* Memory operations where the offset is a fixed value (including zero). */ From 5082b2a5d71832284679a91607b53309d5e17642 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 20 May 2013 19:56:33 +0100 Subject: [PATCH 035/231] Add lea instruction. Fix dependency issues. --HG-- branch : dtrg-videocore --- mach/proto/as/build.mk | 2 ++ mach/vc4/as/mach1.c | 2 ++ mach/vc4/as/mach2.c | 1 + mach/vc4/as/mach3.c | 1 + mach/vc4/as/mach4.c | 3 +++ mach/vc4/as/mach5.c | 23 +++++++++++++++++++++++ 6 files changed, 32 insertions(+) diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 64eaab1e9..791611f3d 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -26,7 +26,9 @@ define build-as-impl $(eval CLEANABLES += $(OBJDIR)/$D/preprocessed-comm2.y) $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ + mach/$(ARCH)/as/mach1.c \ mach/$(ARCH)/as/mach2.c \ + mach/$(ARCH)/as/mach3.c \ mach/$(ARCH)/as/mach4.c @echo PREPROCESS $$@ @mkdir -p $$(dir $$@) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 440d7de97..de164610e 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -23,3 +23,5 @@ extern void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct e extern void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct expr_t* expr); extern void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr); extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr); +extern void lea_stack_instr(int rd, long va, int rs); +extern void lea_address_instr(int rd, struct expr_t* expr); \ No newline at end of file diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c index 8143d080b..4c02efb39 100644 --- a/mach/vc4/as/mach2.c +++ b/mach/vc4/as/mach2.c @@ -18,5 +18,6 @@ %token OP_MISC %token OP_MISCL %token OP_STACK +%token OP_LEA diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index f47c024dd..72c0c2a88 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -145,3 +145,4 @@ 0, OP_MEM, B8(00000110), "ldhs", 0, OP_MEM, B8(00000111), "sths", +0, OP_LEA, 0, "lea", \ No newline at end of file diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index e9593e761..73cbea8e4 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -71,5 +71,8 @@ operation | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, $2, $3, $6); } | OP_MEM GPR ',' expr { mem_address_instr($1, $2, &$4); } + + | OP_LEA GPR ',' absexp '(' GPR ')' { lea_stack_instr($2, $4, $6); } + | OP_LEA GPR ',' expr { lea_address_instr($2, &$4); } ; diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 6314ed1f3..d6f71e7fb 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -475,3 +475,26 @@ void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t branch_addcmp_common(B16(11000000,00000000) | (vs<<8), 8, expr); } +/* lea, where the source is relative to the stack. */ + +void lea_stack_instr(int rd, long va, int rs) +{ + if (rs != 25) + serror("source register must be sp"); + + if (!fitx(va, 6)) + serror("offset too big to encode in instruction"); + va = maskx(va, 6); + + emit2(B16(00010000,00000000) | (rd<<0) | (va<<5)); +} + +/* lea, where the source is an address. */ + +void lea_address_instr(int rd, struct expr_t* expr) +{ + newrelo(expr->typ, RELOVC4); + emit2(B16(11100101,00000000) | (rd<<0)); + emit4(expr->val); +} + From 970f2bae6222b98d825af151f2d467f5893a8590 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 20 May 2013 22:35:12 +0100 Subject: [PATCH 036/231] Major revamp to simplify and use 2op instructions. Better code. Now looks like it may work one day. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 656 +++++++++++++-------------------------------- 1 file changed, 181 insertions(+), 475 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 691d6076b..3dc18a678 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -28,43 +28,34 @@ PROPERTIES GPR /* any GPR */ REG /* any allocatable GPR */ - LREG /* any allocatable low register (r0-r15) */ - HREG /* any allocatable high register (r0-r15) */ STACKABLE /* a push/popable register (r0, r6, r16, fp) */ GPR0 GPR1 GPR2 GPR3 GPR4 GPR5 GPR6 GPR7 GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15 GPR16 GPR17 GPR18 GPR19 GPR20 GPR21 GPR22 GPR23 - GPRFP GPRSP GPRLR GPRPC + GPRGP GPRFP GPRSP GPRLR GPRPC REGISTERS - R0("r0") : GPR, REG, LREG, STACKABLE, GPR0. - R1("r1") : GPR, REG, LREG, GPR1. - R2("r2") : GPR, REG, LREG, GPR2. - R3("r3") : GPR, REG, LREG, GPR3. - R4("r4") : GPR, REG, LREG, GPR4. - R5("r5") : GPR, REG, LREG, GPR5. - R6("r6") : GPR, REG, LREG, STACKABLE, GPR6 regvar. - R7("r7") : GPR, REG, LREG, GPR7 regvar. - R8("r8") : GPR, REG, LREG, GPR8 regvar. - R9("r9") : GPR, REG, LREG, GPR9 regvar. - R10("r10") : GPR, REG, LREG, GPR10 regvar. - R11("r11") : GPR, REG, LREG, GPR11 regvar. - R12("r12") : GPR, REG, LREG, GPR12 regvar. - R13("r13") : GPR, REG, LREG, GPR13 regvar. - R14("r14") : GPR, REG, LREG, GPR14 regvar. - R15("r15") : GPR, REG, LREG, GPR15 regvar. + R0("r0") : GPR, REG, STACKABLE, GPR0. + R1("r1") : GPR, REG, GPR1. + R2("r2") : GPR, REG, GPR2. + R3("r3") : GPR, REG, GPR3. + R4("r4") : GPR, REG, GPR4. + R5("r5") : GPR, REG, GPR5. + R6("r6") : GPR, REG, STACKABLE, GPR6 regvar. + R7("r7") : GPR, REG, GPR7 regvar. + R8("r8") : GPR, REG, GPR8 regvar. + R9("r9") : GPR, REG, GPR9 regvar. + R10("r10") : GPR, REG, GPR10 regvar. + R11("r11") : GPR, REG, GPR11 regvar. + R12("r12") : GPR, REG, GPR12 regvar. + R13("r13") : GPR, REG, GPR13 regvar. + R14("r14") : GPR, REG, GPR14 regvar. + GP("r15") : GPR, GPRGP. - R16("r16") : GPR, REG, HREG, STACKABLE, GPR16 regvar. - R17("r17") : GPR, REG, HREG, GPR17 regvar. - R18("r18") : GPR, REG, HREG, GPR18 regvar. - R19("r19") : GPR, REG, HREG, GPR19 regvar. - R20("r20") : GPR, REG, HREG, GPR20 regvar. - R21("r21") : GPR, REG, HREG, GPR21 regvar. - R22("r22") : GPR, REG, HREG, GPR22 regvar. - R23("r23") : GPR, GPR23. + R23("r23") : GPR. FP("fp") : GPR, GPRFP, STACKABLE. SP("sp") : GPR, GPRSP. LR("lr") : GPR, GPRLR. @@ -84,94 +75,61 @@ TOKENS LABEL = { ADDR adr; } 4 adr. CONST = { INT val; } 4 "#" val. - LOCAL = { INT off; } 4. /* Allows us to use regvar() to refer to registers */ GPRE = { GPR reg; } 4 reg. -/* Expression partial results */ - - SUM_RC = { GPR reg; INT off; } 4. - SUM_RR = { GPR reg1; GPR reg2; } 4. - - SEX_B = { GPR reg; } 4. - SEX_H = { GPR reg; } 4. - - IND_RC_B = { GPR reg; INT off; } 4. - IND_RR_B = { GPR reg1; GPR reg2; } 4. - IND_LABEL_B = { ADDR adr; } 4. - - IND_RC_H = { GPR reg; INT off; } 4. - IND_RR_H = { GPR reg1; GPR reg2; } 4. - IND_LABEL_H = { ADDR adr; } 4. - - IND_RC_H_S = { GPR reg; INT off; } 4. - - IND_RC_Q = { GPR reg; INT off; } 4. - IND_RR_Q = { GPR reg1; GPR reg2; } 4. - IND_LABEL_Q = { ADDR adr; } 4. - - IND_RC_D = { GPR reg; INT off; } 8. - IND_RR_D = { GPR reg1; GPR reg2; } 8. - IND_LABEL_D = { ADDR adr; } 8. - -/* Comments */ - - LABELI = { ADDR msg; INT num; } 4 msg " " num. +/* The results of comparisons. */ + TRISTATE_RC_S = { GPR reg; INT val; } 4. + TRISTATE_RC_U = { GPR reg; INT val; } 4. + TRISTATE_RR_S = { GPR reg1; GPR reg2; } 4. + TRISTATE_RR_U = { GPR reg1; GPR reg2; } 4. SETS - TOKEN = LABEL + CONST + LOCAL. + TOKEN = LABEL + CONST. GPRI = GPR + GPRE. - - SUM_ALL = SUM_RC + SUM_RR. - - SEX_ALL = SEX_B + SEX_H. - - IND_ALL_B = IND_RC_B + IND_RR_B + IND_LABEL_B. - IND_ALL_H = IND_RC_H + IND_RR_H + IND_LABEL_H. - IND_ALL_Q = IND_RC_Q + IND_RR_Q + IND_LABEL_Q. - IND_ALL_D = IND_RC_D + IND_RR_D + IND_LABEL_D. -#if 0 - OP_ALL_Q = SUM_ALL + TRISTATE_ALL + SEX_ALL + LOGICAL_ALL + - IND_ALL_Q. -#endif - - OP_ALL_Q = SUM_ALL + SEX_ALL + IND_ALL_B + IND_ALL_H + IND_ALL_Q. INSTRUCTIONS add GPRI:wo, GPRI:ro, GPRI+CONST:ro. + add GPRI:rw, GPRI+CONST:ro. beq "b.eq" LABEL:ro. bne "b.ne" LABEL:ro. + bgt "b.gt" LABEL:ro. + bgt "b.gt" LABEL:ro. + bhi "b.hi" LABEL:ro. b GPRI+LABEL:ro. bl GPRI+LABEL:ro. - cmp GPRI:ro, GPRI+CONST:ro. + cmp GPRI:ro, GPRI+CONST:ro kills :cc. exts GPRI:wo, GPRI:ro, GPRI+CONST:ro. + exts GPRI:rw, GPRI+CONST:ro. ld GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. ldb GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. ldh GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. ldhs GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. lea GPRI:wo, LABEL:ro. + lsl GPRI:rw, GPRI+CONST:ro. lsl GPRI:wo, GPRI:ro, GPRI+CONST:ro. mov GPRI:wo, GPRI+CONST:ro. + neg GPRI:rw, GPRI+CONST:ro. pop STACKABLE:wo. pop STACKABLE:wo, GPRLR+GPRPC:wo. push STACKABLE:ro. sub GPRI:wo, GPRI:ro, CONST+GPRI:ro. + sub GPRI:rw, GPRI+CONST:ro. st GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. stb GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. sth GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. sths GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. invalid "invalid". - comment "!" LABEL+LABELI:ro. @@ -185,173 +143,33 @@ MOVES /* GPRE exists solely to allow us to use regvar() (which can only be used in an expression) as a register constant. */ - from GPR to GPRE - gen - COMMENT("move GPR->GPRE") - mov %2, %1 - from GPRE to GPR gen - COMMENT("move GPRE->GPR") mov %2, %1 /* Constants */ from CONST to GPR gen - COMMENT("move CONST->GPR") mov %2, %1 from LABEL to GPR gen - COMMENT("move LABEL->GPR") lea %2, {LABEL, %1.adr} - -/* Sign extension */ - - from SEX_B to GPR - gen - COMMENT("move SEX_B->GPR") - exts %2, %1.reg, {CONST, 8} - - from SEX_H to GPR - gen - COMMENT("move SEX_H->GPR") - exts %2, %1.reg, {CONST, 16} - -/* Register + something */ - - from SUM_RC to GPR - gen - COMMENT("move SUM_RC->GPR") - add %2, %1.reg, {CONST, %1.off} - - from SUM_RR to GPR - gen - COMMENT("move SUM_RR->GPR") - add %2, %1.reg1, %1.reg2 - - from SUM_RR to GPR - gen - COMMENT("move SUM_RR->GPRE") - add %2, %1.reg1, %1.reg2 - -/* Read byte */ - - from IND_RC_B to GPR - gen - COMMENT("move IND_RC_B->GPR") - ldb %2, {GPROFFSET, %1.reg, %1.off} - - from IND_RR_B to GPR - gen - COMMENT("move IND_RR_B->GPR") - ldb %2, {GPRGPR, %1.reg1, %1.reg2} - - from IND_LABEL_B to GPR - gen - COMMENT("move IND_LABEL_B->GPR") - ldb %2, {LABEL, %1.adr} - -/* Write byte */ - - from GPR to IND_RC_B - gen - COMMENT("move GPR->IND_RC_B") - stb %1, {GPROFFSET, %2.reg, %2.off} - - from GPR to IND_RR_B - gen - COMMENT("move GPR->IND_RR_B") - stb %1, {GPRGPR, %2.reg1, %2.reg2} - - from GPR to IND_LABEL_B - gen - COMMENT("move GPR->IND_LABEL_B") - stb %1, {LABEL, %2.adr} - -/* Read short */ - - from IND_RC_H to GPR - gen - COMMENT("move IND_RC_H->GPR") - ldh %2, {GPROFFSET, %1.reg, %1.off} - - from IND_RR_H to GPR - gen - COMMENT("move IND_RR_H->GPR") - ldh %2, {GPRGPR, %1.reg1, %1.reg2} - - from IND_LABEL_H to GPR - gen - COMMENT("move IND_LABEL_H->GPR") - ldh %2, {LABEL, %1.adr} - -/* Write short */ - - from GPR to IND_RC_H - gen - COMMENT("move GPR->IND_RC_H") - sth %1, {GPROFFSET, %2.reg, %2.off} - - from GPR to IND_RR_H - gen - COMMENT("move GPR->IND_RR_H") - sth %1, {GPRGPR, %2.reg1, %2.reg2} - - from GPR to IND_LABEL_H - gen - COMMENT("move GPR->IND_LABEL_H") - sth %1, {LABEL, %2.adr} - -/* Read quad */ - - from IND_RC_Q to GPR - gen - COMMENT("move IND_RC_Q->GPR") - ld %2, {GPROFFSET, %1.reg, %1.off} - - from IND_RR_Q to GPR - gen - COMMENT("move IND_RR_Q->GPR") - ld %2, {GPRGPR, %1.reg1, %1.reg2} - - from IND_LABEL_Q to GPR - gen - COMMENT("move IND_LABEL_Q->GPR") - ld %2, {LABEL, %1.adr} - -/* Write quad */ - - from GPR to IND_RC_Q - gen - COMMENT("move GPR->IND_RC_Q") - st %1, {GPROFFSET, %2.reg, %2.off} - - from GPR to IND_RR_Q - gen - COMMENT("move GPR->IND_RR_Q") - st %1, {GPRGPR, %2.reg1, %2.reg2} - - from GPR to IND_LABEL_Q - gen - COMMENT("move GPR->IND_LABEL_Q") - st %1, {LABEL, %2.adr} + sub %2, GP /* Miscellaneous */ - from CONST + LABEL + GPR + OP_ALL_Q to GPRE + from CONST+LABEL+GPR+GPRE to GPRE gen move %1, %2.reg -#if 0 TESTS to test GPR gen - invalid -#endif + cmp %1, {CONST, 0} @@ -359,54 +177,48 @@ STACKINGRULES from STACKABLE to STACK gen - COMMENT("stack STACKABLE") push %1 - from REG to STACK + from GPR to STACK uses STACKABLE gen - COMMENT("stack non-STACKABLE") move %1, %a push %a - from REG to STACK + from GPR to STACK gen - COMMENT("stack non-STACKABLE, fallback") sub SP, SP, {CONST, 4} st %1, {GPROFFSET, SP, 0} - from CONST + OP_ALL_Q to STACK + from GPRE to STACK + uses STACKABLE + gen + move %1, %a + push %a + + from GPRE to STACK + gen + sub SP, {CONST, 4} + st %1, {GPROFFSET, SP, 0} + + from TOKEN to STACK uses STACKABLE gen move %1, %a push %a - from CONST + OP_ALL_Q to STACK + from TOKEN to STACK gen COMMENT("fallback stack") move %1, SCRATCH sub SP, SP, {CONST, 4} st SCRATCH, {GPROFFSET, SP, 0} - - from TOKEN to STACK - gen - invalid. COERCIONS - from REG - uses REG - gen - COMMENT("coerce REG->REG") - move %1, %a - yields %a - from GPRE - uses REG - gen - COMMENT("coerce GPRE->REG") - move %1, %a + uses reusing %1, REG=%1 yields %a from CONST @@ -430,40 +242,6 @@ COERCIONS pop %a yields %a - from SEX_B - uses REG - gen - COMMENT("coerce SEX_B->REG") - exts %a, %1.reg, {CONST, 8} - yields %a - - from SEX_H - uses REG - gen - COMMENT("coerce SEX_H->REG") - exts %a, %1.reg, {CONST, 16} - yields %a - -#if 0 - from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL - uses REG - gen - move %1, {GPRE, %a} - yields %a - - from IND_ALL_Q - uses REG - gen - move %1, %a - yields %a -#endif - from OP_ALL_Q - uses REG - gen - move %1, %a - yields %a - - PATTERNS @@ -473,26 +251,28 @@ PATTERNS pat loc /* Load constant */ yields {CONST, $1} - pat dup $1==INT32 /* Duplicate word on top of stack */ - with REG + pat dup $1<=INT32 /* Duplicate word on top of stack */ + with GPR yields %1 %1 - + pat dup $1==INT64 /* Duplicate double-word on top of stack */ - with REG REG + with GPR GPR yields %2 %1 %2 %1 pat exg $1==INT32 /* Exchange top two words on stack */ - with REG REG + with GPR GPR yields %1 %2 - + +#if 0 pat stl lol $1==$2 /* Store then load local */ leaving - dup 4 + dup INT32 stl $1 +#endif pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */ leaving - dup INT32 + dup $2 lal $1 sti $2 @@ -537,30 +317,39 @@ PATTERNS pat loc loc cui $1==INT16 && $2==INT32 /* unsigned short -> signed int */ /* nop */ - pat loc loc cii $1==INT8 && $2==INT32 /* signed char -> signed int */ + pat loc loc cii $1==INT8 && $2>INT8 /* signed char -> anything */ with REG - yields {SEX_B, %1} + uses reusing %1, REG=%1 + gen + exts %a, {CONST, 8} + yields %a - pat loc loc cii $1==2 && $2==4 /* signed char -> signed short */ + pat loc loc cii $1==INT16 && $2>INT16 /* signed short -> anything */ with REG - yields {SEX_H, %1} - + uses reusing %1, REG=%1 + gen + exts %a, {CONST, 16} + yields %a - /* Local variables */ pat lal /* Load address of local */ - yields {SUM_RC, FP, $1} + uses REG + gen + add %a, FP, {CONST, $1} + sub %a, GP + yields %a pat lol inreg($1)>0 /* Load from local */ - yields {LOCAL, $1} - - pat lol /* Load from local */ - leaving - lal $1 - loi INT32 + yields {GPRE, regvar($1)} + + pat lol /* Load quad from local */ + uses REG + gen + ld %a, {GPROFFSET, FP, $1} + yields %a pat ldl /* Load double-word from local */ leaving @@ -568,16 +357,16 @@ PATTERNS loi INT32*2 pat stl inreg($1)>0 /* Store to local */ - with CONST + LABEL + GPR + OP_ALL_Q - kills regvar($1), LOCAL %off==$1 + with CONST+GPRI + kills regvar($1) gen move %1, {GPRE, regvar($1)} pat stl /* Store to local */ - leaving - lal $1 - sti INT32 - + with GPRI + gen + st %1, {GPROFFSET, FP, $1} + pat sdl /* Store double-word to local */ leaving lal $1 @@ -704,11 +493,15 @@ PATTERNS pat loi $1==INT8 /* Load byte indirect */ with GPR - yields {IND_RC_B, %1, 0} - with SUM_RR - yields {IND_RR_B, %1.reg1, %1.reg2} - with SUM_RC - yields {IND_RC_B, %1.reg, %1.off} + uses reusing %1, REG + gen + ldb %a, {GPRGPR, %1, GP} + yields %a + with GPRE + uses reusing %1.reg, REG + gen + ldb %a, {GPRGPR, %1.reg, GP} + yields %a #if 0 pat loi loc loc cii $1==INT16 && $2==INT16 && $3==INT32 /* Load half-word indirect and sign extend */ @@ -748,13 +541,11 @@ PATTERNS pat loi $1==INT32 /* Load quad indirect */ with GPR - yields {IND_RC_Q, %1, 0} - with SUM_RC - yields {IND_RC_Q, %1.reg, %1.off} - with SUM_RR - yields {IND_RR_Q, %1.reg1, %1.reg2} - with LABEL - yields {IND_LABEL_Q, %1.adr} + uses reusing %1, REG + gen + add %a, %1, GP + ld %a, {GPROFFSET, %a, 0} + yields %a #if 0 pat loi $1==INT64 /* Load double-quad indirect */ @@ -780,64 +571,26 @@ PATTERNS bl {LABEL, ".los"} pat sti $1==INT8 /* Store byte indirect */ - with GPR GPR + with GPR GPRI gen - move %2, {IND_RC_B, %1, 0} - with SUM_RR GPR + stb %2, {GPRGPR, %1, GP} + with GPRE GPRI gen - move %2, {IND_RR_B, %1.reg1, %1.reg2} - with SUM_RC GPR - gen - move %2, {IND_RC_B, %1.reg, %1.off} - with GPR SEX_B - gen - move %2.reg, {IND_RC_B, %1, 0} - with SUM_RR SEX_B - gen - move %2.reg, {IND_RR_B, %1.reg1, %1.reg2} - with SUM_RC SEX_B - gen - move %2.reg, {IND_RC_B, %1.reg, %1.off} - with LABEL GPR - gen - move %2, {IND_LABEL_B, %1.adr} + stb %2, {GPRGPR, %1.reg, GP} pat sti $1==INT16 /* Store half-word indirect */ with GPR GPR + uses REG gen - move %2, {IND_RC_H, %1, 0} - with SUM_RR GPR - gen - move %2, {IND_RR_H, %1.reg1, %1.reg2} - with SUM_RC GPR - gen - move %2, {IND_RC_H, %1.reg, %1.off} - with GPR SEX_H - gen - move %2.reg, {IND_RC_H, %1, 0} - with SUM_RR SEX_H - gen - move %2.reg, {IND_RR_H, %1.reg1, %1.reg2} - with SUM_RC SEX_H - gen - move %2.reg, {IND_RC_H, %1.reg, %1.off} - with LABEL GPR - gen - move %2, {IND_LABEL_H, %1.adr} + add %a, %1, GP + sth %2, {GPROFFSET, %a, 0} pat sti $1==INT32 /* Store quad indirect */ with GPR GPR + uses REG gen - move %2, {IND_RC_Q, %1, 0} - with SUM_RR GPR - gen - move %2, {IND_RR_Q, %1.reg1, %1.reg2} - with SUM_RC GPR - gen - move %2, {IND_RC_Q, %1.reg, %1.off} - with LABEL GPR - gen - move %2, {IND_LABEL_Q, %1.adr} + add %a, %1, GP + st %2, {GPROFFSET, %a, 0} #if 0 pat sti $1==INT64 /* Store double-word indirect */ @@ -931,38 +684,32 @@ PATTERNS /* Word arithmetic */ pat adi $1==INT32 /* Add word (second + top) */ - with REG REG - yields {SUM_RR, %1, %2} - with CONST REG - yields {SUM_RC, %2, %1.val} - with REG CONST - yields {SUM_RC, %1, %2.val} - with CONST SUM_RC - yields {SUM_RC, %2.reg, %2.off+%1.val} - with CONST LABEL - yields {LABEL, %2.adr+%1.val} + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + add %a, %1 + yields %a + with GPRI GPRI+CONST + uses reusing %1, REG=%1 + gen + add %a, %2 + yields %a + + pat sbi $1==INT32 /* Subtract word (second - top) */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + sub %a, %1 + yields %a + + pat ngi $1==INT32 /* Negate word */ + with GPRI + uses reusing %1, REG=%1 + gen + neg %a, %a + yields %a #if 0 - pat sbi $1==4 /* Subtract word (second - top) */ - with REG REG - uses reusing %2, REG - gen - subf %a, %1, %2 - yields %a - with CONST REG - yields {SUM_RC, %2, 0-%1.val} - with CONST SUM_RC - yields {SUM_RC, %2.reg, %2.off-%1.val} - with CONST LABEL - yields {LABEL, %2.adr+(0-%1.val)} - - pat ngi $1==4 /* Negate word */ - with REG - uses reusing %1, REG - gen - neg %a, %1 - yields %a - pat mli $1==4 /* Multiply word (second * top) */ with REG REG uses reusing %2, REG @@ -1087,10 +834,10 @@ PATTERNS #endif pat sli $1==4 /* Shift left (second << top) */ - with CONST+GPR GPR - uses reusing %2, REG + with CONST+GPRI GPRI + uses reusing %2, REG=%2 gen - lsl %a, %2, %1 + lsl %a, %1 yields %a #if 0 @@ -1248,79 +995,40 @@ PATTERNS /* Simple branches */ - pat zeq /* Branch if signed top == 0 */ - with GPR STACK - gen - cmp %1, {CONST, 0} - beq {LABEL, $1} - - pat beq - with GPR GPR STACK - gen - cmp %1, %2 - beq {LABEL, $1} - - pat zne /* Branch if signed top != 0 */ - with GPR STACK + proc anyz example zeq + with GPRI STACK gen cmp %1, {CONST, 0} - bne {LABEL, $1} + beq[1] {LABEL, $1} - pat bne - with GPR GPR STACK + pat zeq call anyz("b.eq") /* Branch if signed top == 0 */ + pat zne call anyz("b.ne") /* Branch if signed top != 0 */ + pat zgt call anyz("b.gt") /* Branch if signed top > 0 */ + pat zlt call anyz("b.lt") /* Branch if signed top > 0 */ + + proc anyb example beq + with GPR+CONST GPRI STACK gen - cmp %1, %2 - bne {LABEL, $1} + cmp %2, %1 + beq[1] {LABEL, $1} + + pat beq call anyz("b.eq") /* Branch if signed second == top */ + pat bne call anyz("b.ne") /* Branch if signed second != top */ + pat bgt call anyz("b.gt") /* Branch if signed second > top */ + + proc anycmpb example cmu zeq + with GPR+CONST GPRI STACK + gen + cmp %2, %1 + beq[1] {LABEL, $2} + + pat cmu zgt call anycmpb("b.hi") /* Branch if unsigned second > top */ + pat cmu zlt call anycmpb("b.lo") /* Branch if unsigned second < top */ + pat cmu zge call anycmpb("b.hs") /* Branch if unsigned second >= top */ + pat cmu zle call anycmpb("b.ls") /* Branch if unsigned second <= top */ + #if 0 - pat zgt /* Branch if signed top > 0 */ - with TRISTATE_ALL+GPR STACK - gen - move %1, C0 - bc IFTRUE, GT, {LABEL, $1} - - pat bgt - leaving - cmi INT32 - zgt $1 - - pat zge /* Branch if signed top >= 0 */ - with TRISTATE_ALL+GPR STACK - gen - move %1, C0 - bc IFFALSE, LT, {LABEL, $1} - - pat bge - leaving - cmi INT32 - zge $1 - - pat zlt /* Branch if signed top < 0 */ - with TRISTATE_ALL+GPR STACK - gen - move %1, C0 - bc IFTRUE, LT, {LABEL, $1} - - pat blt - leaving - cmi INT32 - zlt $1 - - pat zle /* Branch if signed top >= 0 */ - with TRISTATE_ALL+GPR STACK - gen - move %1, C0 - bc IFFALSE, GT, {LABEL, $1} - - pat ble - leaving - cmi INT32 - zle $1 -#endif - - -#if 0 -/* Compare and jump */ pat cmi /* Signed tristate compare */ with CONST GPR @@ -1333,6 +1041,7 @@ PATTERNS yields {TRISTATE_RC_U, %2, %1.val} with GPR GPR yields {TRISTATE_RR_U, %2, %1} +#endif pat cmp /* Compare pointers */ leaving @@ -1342,7 +1051,7 @@ PATTERNS leaving cmi INT32 - +#if 0 /* Other branching and labelling */ @@ -1554,27 +1263,24 @@ PATTERNS loe ".reghp" pat str $1==0 /* Store FP */ - with GPR + with GPRI gen - move %1, FP - + sub FP, %1, GP + pat str $1==1 /* Store SP */ - with GPR + with GPRI gen - move %1, SP - + sub SP, %1, GP + pat str $1==2 /* Store HP */ leaving ste ".reghp" pat ass /* Adjust stack by variable amount */ - with CONST - gen - move {SUM_RC, SP, %1.val}, SP - with GPR - gen - move {SUM_RR, SP, %1}, SP - + with CONST+GPRI + gen + add SP, %1 + pat asp /* Adjust stack by constant amount */ leaving loc $1 From e5341e41674fc43b820200980a535f551adcfc9e Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 20 May 2013 22:41:27 +0100 Subject: [PATCH 037/231] Remember to clear ackflags on reset. --HG-- branch : dtrg-videocore --- first/core.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/first/core.mk b/first/core.mk index d2e32fc68..b50549da3 100644 --- a/first/core.mk +++ b/first/core.mk @@ -3,6 +3,7 @@ define reset $(eval o :=) $(eval s :=) $(eval cflags :=) + $(eval ackflags :=) $(eval ldflags :=) $(eval objdir :=) endef From d6565f4d5b2317f37b9aa671986ce1ce944547a0 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 20 May 2013 23:27:31 +0100 Subject: [PATCH 038/231] Fix typo. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index 72c0c2a88..0ae247226 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -54,7 +54,7 @@ 0, CC, 2, ".cs", 0, CC, 2, ".lo", 0, CC, 3, ".cc", -0, CC, 3, ".hg", +0, CC, 3, ".hs", 0, CC, 4, ".mi", 0, CC, 5, ".pl", 0, CC, 6, ".vs", From 6cdea73e849242e913a5c9599385088169e680ac Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 20 May 2013 23:27:45 +0100 Subject: [PATCH 039/231] Add a lot more opcodes. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 319 ++++++++++++++++++++------------------------- 1 file changed, 143 insertions(+), 176 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 3dc18a678..2168afb9b 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -13,6 +13,8 @@ INT8 = 1 /* Size of values */ INT16 = 2 INT32 = 4 INT64 = 8 +FLOAT32 = 4 +FLOAT64 = 8 FP_OFFSET = 0 /* Offset of saved FP relative to our FP */ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ @@ -100,6 +102,7 @@ INSTRUCTIONS add GPRI:wo, GPRI:ro, GPRI+CONST:ro. add GPRI:rw, GPRI+CONST:ro. + and GPRI:rw, GPRI+CONST:ro. beq "b.eq" LABEL:ro. bne "b.ne" LABEL:ro. bgt "b.gt" LABEL:ro. @@ -108,6 +111,9 @@ INSTRUCTIONS b GPRI+LABEL:ro. bl GPRI+LABEL:ro. cmp GPRI:ro, GPRI+CONST:ro kills :cc. + divs GPRI:wo, GPRI:ro, GPRI+CONST:ro. + divu GPRI:wo, GPRI:ro, GPRI+CONST:ro. + eor GPRI:rw, GPRI+CONST:ro. exts GPRI:wo, GPRI:ro, GPRI+CONST:ro. exts GPRI:rw, GPRI+CONST:ro. ld GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. @@ -118,7 +124,9 @@ INSTRUCTIONS lsl GPRI:rw, GPRI+CONST:ro. lsl GPRI:wo, GPRI:ro, GPRI+CONST:ro. mov GPRI:wo, GPRI+CONST:ro. + mul GPRI:rw, GPRI+CONST:ro. neg GPRI:rw, GPRI+CONST:ro. + or GPRI:rw, GPRI+CONST:ro. pop STACKABLE:wo. pop STACKABLE:wo, GPRLR+GPRPC:wo. push STACKABLE:ro. @@ -547,17 +555,14 @@ PATTERNS ld %a, {GPROFFSET, %a, 0} yields %a -#if 0 pat loi $1==INT64 /* Load double-quad indirect */ - with GPR - yields {IND_RC_D, %1, 0} - with SUM_RC - yields {IND_RC_D, %1.reg, %1.off} - with SUM_RR - yields {IND_RR_D, %1.reg1, %1.reg2} - with LABEL - yields {IND_LABEL_D, %1.adr} -#endif + with GPRI + uses reusing %1, REG, REG + gen + add %a, %1, GP + ld %b, {GPROFFSET, %a, 4} + ld %a, {GPROFFSET, %a, 0} + yields %a %b pat loi /* Load arbitrary size */ leaving @@ -565,7 +570,7 @@ PATTERNS los INT32 pat los /* Load arbitrary size */ - with GPR0 GPR1 STACK + with STACK kills ALL gen bl {LABEL, ".los"} @@ -592,29 +597,13 @@ PATTERNS add %a, %1, GP st %2, {GPROFFSET, %a, 0} -#if 0 - pat sti $1==INT64 /* Store double-word indirect */ - with GPR FD + pat sti $1==INT64 /* Store double-quad indirect */ + with GPR GPR + uses REG gen - move %2, {IND_RC_D, %1, 0} - with SUM_RR FD - gen - move %2, {IND_RR_D, %1.reg1, %1.reg2} - with SUM_RC FD - gen - move %2, {IND_RC_D, %1.reg, %1.off} - with GPR GPR GPR - gen - stw %2, {GPROFFSET, %1, 0} - stw %3, {GPROFFSET, %1, 4} - with SUM_RC GPR GPR - gen - move %2, {IND_RC_Q, %1.reg, %1.off} - move %3, {IND_RC_Q, %1.reg, %1.off+4} - with LABEL FD - gen - move %2, {IND_LABEL_D, %1.adr} - + add %a, %1, GP + st %1, {GPROFFSET, %a, 0} + st %2, {GPROFFSET, %a, 4} pat sti /* Store arbitrary size */ leaving @@ -622,12 +611,11 @@ PATTERNS sts INT32 pat sts /* Load arbitrary size */ - with GPR3 GPR4 STACK + with STACK kills ALL gen bl {LABEL, ".sts"} -#endif - + /* Arithmetic wrappers */ @@ -709,6 +697,65 @@ PATTERNS neg %a, %a yields %a + pat and $1==INT32 /* AND word */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + and %a, %1 + yields %a + with GPRI GPRI+CONST + uses reusing %1, REG=%1 + gen + and %a, %2 + yields %a + + pat ior $1==INT32 /* OR word */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + or %a, %1 + yields %a + with GPRI GPRI+CONST + uses reusing %1, REG=%1 + gen + or %a, %2 + yields %a + + pat xor $1==INT32 /* XOR word */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + eor %a, %1 + yields %a + with GPRI GPRI+CONST + uses reusing %1, REG=%1 + gen + eor %a, %2 + yields %a + + pat dvi $1==INT32 /* Divide word (second / top) */ + with GPRI GPRI + uses reusing %2, REG + gen + divs %a, %2, %1 + yields %a + + pat dvu $1==INT32 /* Divide unsigned word (second / top) */ + with GPRI GPRI + uses reusing %2, REG + gen + divu %a, %2, %1 + yields %a + + pat rmu $1==INT32 /* Remainder unsigned word (second % top) */ + with GPRI GPRI + uses REG + gen + divu %a, %2, %1 + mul %a, %1 + sub %a, %2 + yields %a + #if 0 pat mli $1==4 /* Multiply word (second * top) */ with REG REG @@ -717,20 +764,6 @@ PATTERNS mullw %a, %2, %1 yields %a - pat dvi $1==4 /* Divide word (second / top) */ - with REG REG - uses reusing %2, REG - gen - divw %a, %2, %1 - yields %a - - pat dvu $1==4 /* Divide unsigned word (second / top) */ - with REG REG - uses reusing %2, REG - gen - divwu %a, %2, %1 - yields %a - pat rmi $1==4 /* Remainder word (second % top) */ with REG REG uses REG @@ -740,56 +773,11 @@ PATTERNS subf %a, %a, %2 yields %a - pat rmu $1==4 /* Remainder unsigned word (second % top) */ - with REG REG - uses REG - gen - divwu %a, %2, %1 - mullw %a, %a, %1 - subf %a, %a, %2 - yields %a - - pat and $1==4 /* AND word */ - with GPR NOT_R - uses reusing %1, REG - gen - andc %a, %1, %2.reg - yields %a - with NOT_R GPR - uses reusing %1, REG - gen - andc %a, %2, %1.reg - yields %a - with GPR GPR - yields {AND_RR, %1, %2} - with GPR CONST - yields {AND_RC, %1, %2.val} - with CONST GPR - yields {AND_RC, %2, %1.val} - pat and !defined($1) /* AND set */ with STACK gen bl {LABEL, ".and"} - pat ior $1==4 /* OR word */ - with GPR NOT_R - uses reusing %1, REG - gen - orc %a, %1, %2.reg - yields %a - with NOT_R GPR - uses reusing %2, REG - gen - orc %a, %2, %1.reg - yields %a - with GPR GPR - yields {OR_RR, %1, %2} - with GPR CONST - yields {OR_RC, %1, %2.val} - with CONST GPR - yields {OR_RC, %2, %1.val} - pat ior !defined($1) /* OR set */ with STACK gen @@ -924,72 +912,27 @@ PATTERNS with GPR3 STACK gen bl {LABEL, ".inn"} +#endif /* Boolean resolutions */ - pat teq /* top = (top == 0) */ - with TRISTATE_ALL + GPR - uses reusing %1, REG + proc anyt example teq + with GPRI + uses reusing %1, REG=%1 gen - move %1, C0 - move C0, SCRATCH - move {LABEL, ".teq_table"}, %a - lwzx %a, %a, SCRATCH - yields %a - - pat tne /* top = (top != 0) */ - with TRISTATE_ALL + GPR - uses reusing %1, REG - gen - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tne_table"}, %a - lwzx %a, %a, SCRATCH - yields %a - - pat tlt /* top = (top < 0) */ - with TRISTATE_ALL + GPR - uses reusing %1, REG - gen - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tlt_table"}, %a - lwzx %a, %a, SCRATCH - yields %a - - pat tle /* top = (top <= 0) */ - with TRISTATE_ALL + GPR - uses reusing %1, REG - gen - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tle_table"}, %a - lwzx %a, %a, SCRATCH - yields %a - - pat tgt /* top = (top > 0) */ - with TRISTATE_ALL + GPR - uses reusing %1, REG - gen - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tgt_table"}, %a - lwzx %a, %a, SCRATCH + cmp %1, {CONST, 0} + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} yields %a - pat tge /* top = (top >= 0) */ - with TRISTATE_ALL + GPR - uses reusing %1, REG - gen - move %1, C0 - move C0, SCRATCH - move {LABEL, ".tge_table"}, %a - lwzx %a, %a, SCRATCH - yields %a - -#endif + pat cmu teq call anyt("add.eq") /* top = (top == 0) */ + pat cmu tne call anyt("add.ne") /* top = (top != 0) */ + pat cmu tlt call anyt("add.lo") /* top = unsigned (top < 0) */ + pat cmu tle call anyt("add.ls") /* top = unsigned (top <= 0) */ + pat cmu tgt call anyt("add.hi") /* top = unsigned (top > 0) */ + pat cmu tge call anyt("add.hs") /* top = unsigned (top >= 0) */ @@ -1004,7 +947,9 @@ PATTERNS pat zeq call anyz("b.eq") /* Branch if signed top == 0 */ pat zne call anyz("b.ne") /* Branch if signed top != 0 */ pat zgt call anyz("b.gt") /* Branch if signed top > 0 */ - pat zlt call anyz("b.lt") /* Branch if signed top > 0 */ + pat zlt call anyz("b.lt") /* Branch if signed top < 0 */ + pat zge call anyz("b.ge") /* Branch if signed top >= 0 */ + pat zle call anyz("b.le") /* Branch if signed top <= 0 */ proc anyb example beq with GPR+CONST GPRI STACK @@ -1015,6 +960,9 @@ PATTERNS pat beq call anyz("b.eq") /* Branch if signed second == top */ pat bne call anyz("b.ne") /* Branch if signed second != top */ pat bgt call anyz("b.gt") /* Branch if signed second > top */ + pat bge call anyz("b.ge") /* Branch if signed second >= top */ + pat blt call anyz("b.lt") /* Branch if signed second < top */ + pat ble call anyz("b.le") /* Branch if signed second <= top */ proc anycmpb example cmu zeq with GPR+CONST GPRI STACK @@ -1050,7 +998,22 @@ PATTERNS pat cms $1==INT32 /* Compare blocks (word sized) */ leaving cmi INT32 - + + proc anycmf64 example teq + with STACK + uses REG + gen + bl {LABEL, ".cmf8"} + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} + yields %a + + pat cmf tlt $1==FLOAT64 call anyt("add.lo") /* top = unsigned (top < 0) */ + pat cmf tle $1==FLOAT64 call anyt("add.ls") /* top = unsigned (top <= 0) */ + pat cmf tgt $1==FLOAT64 call anyt("add.hi") /* top = unsigned (top > 0) */ + pat cmf tge $1==FLOAT64 call anyt("add.hs") /* top = unsigned (top >= 0) */ + + #if 0 @@ -1121,18 +1084,19 @@ PATTERNS mov SP, FP pop FP, PC -#if 0 pat blm /* Block move constant length */ - with GPR GPR STACK + with GPRI GPRI STACK uses REG gen - move {CONST, $1}, %a - stwu %a, {GPROFFSET, SP, 0-4} - stwu %2, {GPROFFSET, SP, 0-4} - stwu %1, {GPROFFSET, SP, 0-4} + sub SP, {CONST, 12} + mov %a, {CONST, $1} + st %1, {GPROFFSET, SP, 0} + st %2, {GPROFFSET, SP, 4} + st %a, {GPROFFSET, SP, 8} bl {LABEL, "_memmove"} - addi SP, SP, {CONST, 12} + add SP, {CONST, 12} +#if 0 pat bls /* Block move variable length */ with GPR GPR GPR STACK gen @@ -1141,16 +1105,17 @@ PATTERNS stwu %2, {GPROFFSET, SP, 0-4} bl {LABEL, "_memmove"} addi SP, SP, {CONST, 12} +#endif pat csa /* Array-lookup switch */ - with GPR3 GPR4 STACK + with STACK gen - b {LABEL, ".csa"} + bl {LABEL, ".csa"} pat csb /* Table-lookup switch */ - with GPR3 GPR4 STACK + with STACK gen - b {LABEL, ".csb"} + bl {LABEL, ".csb"} @@ -1179,7 +1144,7 @@ PATTERNS ste ".ignmask" pat trp /* Raise EM trap */ - with GPR3 + with GPR0 gen bl {LABEL, ".trap"} @@ -1204,7 +1169,8 @@ PATTERNS with GPR uses reusing %1, REG gen - lwz %a, {GPROFFSET, %1, FP_OFFSET} + ld %a, {GPROFFSET, %1, FP_OFFSET} + sub %a, GP yields %a pat lpb /* Convert FP to argument address */ @@ -1217,15 +1183,17 @@ PATTERNS lpb pat gto /* longjmp */ - uses REG + uses REG, REG gen move {LABEL, $1}, %a - move {IND_RC_Q, %a, 8}, FP - move {IND_RC_Q, %a, 4}, SP - move {IND_RC_Q, %a, 0}, %a - mtspr CTR, %a - bcctr ALWAYS, {CONST, 0}, {CONST, 0} - + ld %b, {GPROFFSET, %a, 8} + add FP, %b, GP + ld %b, {GPROFFSET, %a, 4} + add SP, %b, GP + ld %b, {GPROFFSET, %a, 0} + add %b, GP + b %b + #if 0 pat gto /* longjmp */ @@ -1243,7 +1211,6 @@ PATTERNS gen wspec {CONST, $1} -#endif #endif pat lor $1==0 /* Load FP */ From 877e06ed890a9d17146079c09ef34beb2f4ebd7d Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 21 May 2013 18:16:30 +0100 Subject: [PATCH 040/231] Lots more opcodes including float support. Define float and double to be the same thing (as the VC4 seems not to have double-precision float support). --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 445 ++++++++++++++++++++++++++------------------- plat/rpi/build.mk | 1 + plat/rpi/descr | 2 +- 3 files changed, 262 insertions(+), 186 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 2168afb9b..368c6177e 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -9,12 +9,9 @@ EM_WSIZE = 4 EM_PSIZE = 4 EM_BSIZE = 8 /* two words saved in call frame */ -INT8 = 1 /* Size of values */ -INT16 = 2 -INT32 = 4 -INT64 = 8 -FLOAT32 = 4 -FLOAT64 = 8 +BYTE = 1 /* Size of values */ +WORD = 2 +QUAD = 4 FP_OFFSET = 0 /* Offset of saved FP relative to our FP */ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ @@ -22,7 +19,7 @@ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ #define COMMENT(n) /* noop */ -#define nicesize(x) ((x)==INT8 || (x)==INT16 || (x)==INT32 || (x)==INT64) +#define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD) @@ -103,6 +100,7 @@ INSTRUCTIONS add GPRI:wo, GPRI:ro, GPRI+CONST:ro. add GPRI:rw, GPRI+CONST:ro. and GPRI:rw, GPRI+CONST:ro. + asr GPRI:rw, GPRI+CONST:ro. beq "b.eq" LABEL:ro. bne "b.ne" LABEL:ro. bgt "b.gt" LABEL:ro. @@ -116,6 +114,11 @@ INSTRUCTIONS eor GPRI:rw, GPRI+CONST:ro. exts GPRI:wo, GPRI:ro, GPRI+CONST:ro. exts GPRI:rw, GPRI+CONST:ro. + fadd GPRI:wo, GPRI:ro, GPRI:ro. + fcmp GPRI:wo, GPRI:ro, GPRI:ro. + fdiv GPRI:wo, GPRI:ro, GPRI:ro. + fmul GPRI:wo, GPRI:ro, GPRI:ro. + fsub GPRI:wo, GPRI:ro, GPRI:ro. ld GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. ldb GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. ldh GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. @@ -123,6 +126,7 @@ INSTRUCTIONS lea GPRI:wo, LABEL:ro. lsl GPRI:rw, GPRI+CONST:ro. lsl GPRI:wo, GPRI:ro, GPRI+CONST:ro. + lsr GPRI:rw, GPRI+CONST:ro. mov GPRI:wo, GPRI+CONST:ro. mul GPRI:rw, GPRI+CONST:ro. neg GPRI:rw, GPRI+CONST:ro. @@ -189,9 +193,9 @@ STACKINGRULES from GPR to STACK uses STACKABLE - gen - move %1, %a - push %a + gen + move %1, %a + push %a from GPR to STACK gen @@ -200,9 +204,9 @@ STACKINGRULES from GPRE to STACK uses STACKABLE - gen - move %1, %a - push %a + gen + move %1, %a + push %a from GPRE to STACK gen @@ -222,6 +226,7 @@ STACKINGRULES sub SP, SP, {CONST, 4} st SCRATCH, {GPROFFSET, SP, 0} + COERCIONS @@ -259,22 +264,22 @@ PATTERNS pat loc /* Load constant */ yields {CONST, $1} - pat dup $1<=INT32 /* Duplicate word on top of stack */ - with GPR + pat dup $1<=QUAD /* Duplicate word on top of stack */ + with GPRI yields %1 %1 - pat dup $1==INT64 /* Duplicate double-word on top of stack */ - with GPR GPR - yields %2 %1 %2 %1 - - pat exg $1==INT32 /* Exchange top two words on stack */ - with GPR GPR + pat dup $1<=(2*QUAD) /* Duplicate word pair on top of stack */ + with GPRI GPRI + yields %1 %2 %1 %2 + + pat exg $1==QUAD /* Exchange top two words on stack */ + with GPRI GPRI yields %1 %2 #if 0 pat stl lol $1==$2 /* Store then load local */ leaving - dup INT32 + dup QUAD stl $1 #endif @@ -298,7 +303,7 @@ PATTERNS loc $2 cii - pat loc loc cii loc loc cii $2==INT32 && $5==INT32 && $4<$2 /* madness, generated by the C compiler */ + pat loc loc cii loc loc cii $2==QUAD && $5==QUAD && $4<$2 /* madness, generated by the C compiler */ leaving loc $4 loc $5 @@ -319,20 +324,20 @@ PATTERNS pat loc loc cui $1==$2 /* unsigned X -> signed X */ /* nop */ - pat loc loc cui $1==INT8 && $2==INT32 /* unsigned char -> signed int */ + pat loc loc cui $1==BYTE && $2==QUAD /* unsigned char -> signed int */ /* nop */ - pat loc loc cui $1==INT16 && $2==INT32 /* unsigned short -> signed int */ + pat loc loc cui $1==WORD && $2==QUAD /* unsigned short -> signed int */ /* nop */ - pat loc loc cii $1==INT8 && $2>INT8 /* signed char -> anything */ + pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */ with REG uses reusing %1, REG=%1 gen exts %a, {CONST, 8} yields %a - pat loc loc cii $1==INT16 && $2>INT16 /* signed short -> anything */ + pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */ with REG uses reusing %1, REG=%1 gen @@ -362,7 +367,7 @@ PATTERNS pat ldl /* Load double-word from local */ leaving lal $1 - loi INT32*2 + loi QUAD*2 pat stl inreg($1)>0 /* Store to local */ with CONST+GPRI @@ -378,7 +383,7 @@ PATTERNS pat sdl /* Store double-word to local */ leaving lal $1 - sti INT32*2 + sti QUAD*2 pat lil inreg($1)>0 /* Load from indirected local */ uses REG @@ -389,12 +394,12 @@ PATTERNS pat lil /* Load from indirected local */ leaving lol $1 - loi INT32 + loi QUAD pat sil /* Save to indirected local */ leaving lol $1 - sti INT32 + sti QUAD pat stl lol $1==$2 /* Save then load (generated by C compiler) */ leaving @@ -433,22 +438,12 @@ PATTERNS pat loe /* Load word external */ leaving lae $1 - loi INT32 + loi QUAD pat ste /* Store word external */ leaving lae $1 - sti INT32 - - pat lde /* Load double-word external */ - leaving - lae $1 - loi INT64 - - pat sde /* Store double-word external */ - leaving - lae $1 - sti INT64 + sti QUAD pat zre /* Zero external */ leaving @@ -478,28 +473,19 @@ PATTERNS pat lof /* Load word offsetted */ leaving adp $1 - loi INT32 + loi QUAD - pat ldf /* Load double-word offsetted */ - leaving - adp $1 - loi INT64 pat stf /* Store word offsetted */ leaving adp $1 - sti INT32 + sti QUAD - pat sdf /* Store double-word offsetted */ - leaving - adp $1 - sti INT64 - /* Loads and stores */ - pat loi $1==INT8 /* Load byte indirect */ + pat loi $1==BYTE /* Load byte indirect */ with GPR uses reusing %1, REG gen @@ -512,7 +498,7 @@ PATTERNS yields %a #if 0 - pat loi loc loc cii $1==INT16 && $2==INT16 && $3==INT32 /* Load half-word indirect and sign extend */ + pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load half-word indirect and sign extend */ with GPR uses REG gen @@ -529,7 +515,7 @@ PATTERNS move {IND_RC_H_S, %1.reg, %1.off}, %a yields %a - pat loi $1==INT16 /* Load half-word indirect */ + pat loi $1==WORD /* Load half-word indirect */ with GPR uses REG gen @@ -547,7 +533,7 @@ PATTERNS yields %a #endif - pat loi $1==INT32 /* Load quad indirect */ + pat loi $1==QUAD /* Load quad indirect */ with GPR uses reusing %1, REG gen @@ -555,19 +541,10 @@ PATTERNS ld %a, {GPROFFSET, %a, 0} yields %a - pat loi $1==INT64 /* Load double-quad indirect */ - with GPRI - uses reusing %1, REG, REG - gen - add %a, %1, GP - ld %b, {GPROFFSET, %a, 4} - ld %a, {GPROFFSET, %a, 0} - yields %a %b - pat loi /* Load arbitrary size */ leaving loc $1 - los INT32 + los QUAD pat los /* Load arbitrary size */ with STACK @@ -575,7 +552,7 @@ PATTERNS gen bl {LABEL, ".los"} - pat sti $1==INT8 /* Store byte indirect */ + pat sti $1==BYTE /* Store byte indirect */ with GPR GPRI gen stb %2, {GPRGPR, %1, GP} @@ -583,32 +560,24 @@ PATTERNS gen stb %2, {GPRGPR, %1.reg, GP} - pat sti $1==INT16 /* Store half-word indirect */ + pat sti $1==WORD /* Store half-word indirect */ with GPR GPR uses REG gen add %a, %1, GP sth %2, {GPROFFSET, %a, 0} - pat sti $1==INT32 /* Store quad indirect */ + pat sti $1==QUAD /* Store quad indirect */ with GPR GPR uses REG gen add %a, %1, GP st %2, {GPROFFSET, %a, 0} - pat sti $1==INT64 /* Store double-quad indirect */ - with GPR GPR - uses REG - gen - add %a, %1, GP - st %1, {GPROFFSET, %a, 0} - st %2, {GPROFFSET, %a, 4} - pat sti /* Store arbitrary size */ leaving loc $1 - sts INT32 + sts QUAD pat sts /* Load arbitrary size */ with STACK @@ -671,7 +640,7 @@ PATTERNS /* Word arithmetic */ - pat adi $1==INT32 /* Add word (second + top) */ + pat adi $1==QUAD /* Add word (second + top) */ with GPRI+CONST GPRI uses reusing %2, REG=%2 gen @@ -683,21 +652,21 @@ PATTERNS add %a, %2 yields %a - pat sbi $1==INT32 /* Subtract word (second - top) */ + pat sbi $1==QUAD /* Subtract word (second - top) */ with GPRI+CONST GPRI uses reusing %2, REG=%2 gen sub %a, %1 yields %a - pat ngi $1==INT32 /* Negate word */ + pat ngi $1==QUAD /* Negate word */ with GPRI uses reusing %1, REG=%1 gen neg %a, %a yields %a - pat and $1==INT32 /* AND word */ + pat and $1==QUAD /* AND word */ with GPRI+CONST GPRI uses reusing %2, REG=%2 gen @@ -709,7 +678,7 @@ PATTERNS and %a, %2 yields %a - pat ior $1==INT32 /* OR word */ + pat ior $1==QUAD /* OR word */ with GPRI+CONST GPRI uses reusing %2, REG=%2 gen @@ -721,7 +690,7 @@ PATTERNS or %a, %2 yields %a - pat xor $1==INT32 /* XOR word */ + pat xor $1==QUAD /* XOR word */ with GPRI+CONST GPRI uses reusing %2, REG=%2 gen @@ -733,21 +702,21 @@ PATTERNS eor %a, %2 yields %a - pat dvi $1==INT32 /* Divide word (second / top) */ + pat dvi $1==QUAD /* Divide word (second / top) */ with GPRI GPRI uses reusing %2, REG gen divs %a, %2, %1 yields %a - pat dvu $1==INT32 /* Divide unsigned word (second / top) */ + pat dvu $1==QUAD /* Divide unsigned word (second / top) */ with GPRI GPRI uses reusing %2, REG gen divu %a, %2, %1 yields %a - pat rmu $1==INT32 /* Remainder unsigned word (second % top) */ + pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ with GPRI GPRI uses REG gen @@ -796,7 +765,7 @@ PATTERNS gen bl {LABEL, ".xor"} - pat com $1==INT32 /* NOT word */ + pat com $1==QUAD /* NOT word */ with AND_RR uses REG gen @@ -828,60 +797,50 @@ PATTERNS lsl %a, %1 yields %a -#if 0 pat sri $1==4 /* Shift right signed (second >> top) */ - with CONST GPR - uses reusing %2, REG + with CONST+GPRI GPRI + uses reusing %2, REG=%2 gen - srawi %a, %2, {CONST, %1.val & 0x1F} - yields %a - with GPR GPR - uses reusing %2, REG - gen - sraw %a, %2, %1 + asr %2, %1 yields %a pat sru $1==4 /* Shift right unsigned (second >> top) */ - with CONST GPR - uses reusing %2, REG + with CONST+GPRI GPRI + uses reusing %2, REG=%2 gen - rlwinm %a, %2, {CONST, 32-(%1.val & 0x1F)}, {CONST, (%1.val & 0x1F)}, {CONST, 31} - yields %a - with GPR GPR - uses reusing %2, REG - gen - srw %a, %2, %1 + lsr %2, %1 yields %a +#if 0 /* Arrays */ - pat aar $1==INT32 /* Index array */ + pat aar $1==QUAD /* Index array */ with GPR3 GPR4 GPR5 gen bl {LABEL, ".aar4"} yields R3 - pat lae lar $2==INT32 && nicesize(rom($1, 3)) /* Load array */ + pat lae lar $2==QUAD && nicesize(rom($1, 3)) /* Load array */ leaving lae $1 - aar INT32 + aar QUAD loi rom($1, 3) - pat lar $1==INT32 /* Load array */ + pat lar $1==QUAD /* Load array */ with GPR3 GPR4 GPR5 STACK kills ALL gen bl {LABEL, ".lar4"} - pat lae sar $2==INT32 && nicesize(rom($1, 3)) /* Store array */ + pat lae sar $2==QUAD && nicesize(rom($1, 3)) /* Store array */ leaving lae $1 - aar INT32 + aar QUAD sti rom($1, 3) - pat sar $1==INT32 /* Store array */ + pat sar $1==QUAD /* Store array */ with GPR3 GPR4 GPR5 STACK kills ALL gen @@ -895,8 +854,8 @@ PATTERNS pat set defined($1) /* Create word with set bit */ leaving loc 1 - exg INT32 - sli INT32 + exg QUAD + sli QUAD pat set !defined($1) /* Create structure with set bit (variable) */ with GPR3 GPR4 STACK @@ -905,8 +864,8 @@ PATTERNS pat inn defined($1) /* Test for set bit */ leaving - set INT32 - and INT32 + set QUAD + and QUAD pat inn !defined($1) /* Test for set bit (variable) */ with GPR3 STACK @@ -918,21 +877,59 @@ PATTERNS /* Boolean resolutions */ - proc anyt example teq - with GPRI - uses reusing %1, REG=%1 + proc cm_t example teq + with GPRI GPRI + uses reusing %1, REG gen - cmp %1, {CONST, 0} - mov %a, {CONST, 0} - add[1] %a, {CONST, 1} + cmp %1, %2 + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} yields %a - pat cmu teq call anyt("add.eq") /* top = (top == 0) */ - pat cmu tne call anyt("add.ne") /* top = (top != 0) */ - pat cmu tlt call anyt("add.lo") /* top = unsigned (top < 0) */ - pat cmu tle call anyt("add.ls") /* top = unsigned (top <= 0) */ - pat cmu tgt call anyt("add.hi") /* top = unsigned (top > 0) */ - pat cmu tge call anyt("add.hs") /* top = unsigned (top >= 0) */ + pat cmu teq call cm_t("add.eq") /* top = (second == top) */ + pat cmu tne call cm_t("add.ne") /* top = (second != top) */ + pat cmu tlt call cm_t("add.lo") /* top = unsigned (second < top) */ + pat cmu tle call cm_t("add.ls") /* top = unsigned (second <= top) */ + pat cmu tgt call cm_t("add.hi") /* top = unsigned (second < top) */ + pat cmu tge call cm_t("add.hs") /* top = unsigned (second >= top) */ + pat cmi teq call cm_t("add.eq") /* top = (second == top) */ + pat cmi tne call cm_t("add.ne") /* top = (second != top) */ + pat cmi tlt call cm_t("add.lt") /* top = signed (second < top) */ + pat cmi tle call cm_t("add.le") /* top = signed (second <= top) */ + pat cmi tgt call cm_t("add.gt") /* top = signed (second < top) */ + pat cmi tge call cm_t("add.ge") /* top = signed (second >= top) */ + + proc cmf_t example teq + with GPRI GPRI + uses reusing %1, REG + gen + fcmp %a, %1, %2 + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} + yields %a + + pat cmf teq call cmf_t("add.eq") /* top = float (second == top) */ + pat cmf tne call cmf_t("add.ne") /* top = float (second != top) */ + pat cmf tlt call cmf_t("add.lo") /* top = float (second < top) */ + pat cmf tle call cmf_t("add.ls") /* top = float (second <= top) */ + pat cmf tgt call cmf_t("add.hi") /* top = float (second < top) */ + pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */ + + proc fallback_t example teq + with GPRI + uses reusing %1, REG + gen + cmp %1, {CONST, 0} + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} + yields %a + + pat teq call fallback_t("add.eq") /* top = float (top == 0) */ + pat tne call fallback_t("add.ne") /* top = float (top != 0) */ + pat tlt call fallback_t("add.lo") /* top = float (top < 0) */ + pat tle call fallback_t("add.ls") /* top = float (top <= 0) */ + pat tgt call fallback_t("add.hi") /* top = float (top < 0) */ + pat tge call fallback_t("add.hs") /* top = float (top >= 0) */ @@ -964,16 +961,29 @@ PATTERNS pat blt call anyz("b.lt") /* Branch if signed second < top */ pat ble call anyz("b.le") /* Branch if signed second <= top */ - proc anycmpb example cmu zeq + proc cmu_z example cmu zeq with GPR+CONST GPRI STACK gen cmp %2, %1 beq[1] {LABEL, $2} - pat cmu zgt call anycmpb("b.hi") /* Branch if unsigned second > top */ - pat cmu zlt call anycmpb("b.lo") /* Branch if unsigned second < top */ - pat cmu zge call anycmpb("b.hs") /* Branch if unsigned second >= top */ - pat cmu zle call anycmpb("b.ls") /* Branch if unsigned second <= top */ + pat cmu zgt call cmu_z("b.hi") /* Branch if unsigned second > top */ + pat cmu zlt call cmu_z("b.lo") /* Branch if unsigned second < top */ + pat cmu zge call cmu_z("b.hs") /* Branch if unsigned second >= top */ + pat cmu zle call cmu_z("b.ls") /* Branch if unsigned second <= top */ + + proc cmf_z example cmu zeq + with GPRI GPRI STACK + gen + fcmp %2, %2, %1 + beq[1] {LABEL, $2} + + pat cmf zeq call cmf_z("b.eq") /* Branch if float second == top */ + pat cmf zne call cmf_z("b.ne") /* Branch if float second != top */ + pat cmf zgt call cmf_z("b.gt") /* Branch if float second > top */ + pat cmf zlt call cmf_z("b.lt") /* Branch if float second < top */ + pat cmf zge call cmf_z("b.ge") /* Branch if float second >= top */ + pat cmf zle call cmf_z("b.le") /* Branch if float second <= top */ #if 0 @@ -993,54 +1003,58 @@ PATTERNS pat cmp /* Compare pointers */ leaving - cmu INT32 + cmu QUAD - pat cms $1==INT32 /* Compare blocks (word sized) */ + pat cms $1==QUAD /* Compare blocks (word sized) */ leaving - cmi INT32 - - proc anycmf64 example teq - with STACK - uses REG - gen - bl {LABEL, ".cmf8"} - mov %a, {CONST, 0} - add[1] %a, {CONST, 1} - yields %a - - pat cmf tlt $1==FLOAT64 call anyt("add.lo") /* top = unsigned (top < 0) */ - pat cmf tle $1==FLOAT64 call anyt("add.ls") /* top = unsigned (top <= 0) */ - pat cmf tgt $1==FLOAT64 call anyt("add.hi") /* top = unsigned (top > 0) */ - pat cmf tge $1==FLOAT64 call anyt("add.hs") /* top = unsigned (top >= 0) */ + cmi QUAD + -#if 0 /* Other branching and labelling */ - pat lab topeltsize($1)==4 && !fallthrough($1) +#if 0 + pat lab topeltsize($1)<=4 && !fallthrough($1) gen labeldef $1 - yields R3 + yields R0 - pat lab topeltsize($1)==4 && fallthrough($1) - with GPR3 - gen - labeldef $1 - yields %1 + pat lab topeltsize($1)<=4 && fallthrough($1) + with GPR0 + gen + labeldef $1 + yields %1 - pat lab topeltsize($1)!=4 + pat lab topeltsize($1)>4 with STACK - kills ALL - gen - labeldef $1 + kills ALL + gen + labeldef $1 + + pat bra topeltsize($1)<=4 /* Unconditional jump with TOS register */ + with GPR0 STACK + gen + b {LABEL, $1} + + pat bra topeltsize($1)>4 /* Unconditional jump without TOS register */ + with STACK + gen + b {LABEL, $1} #endif - pat bra /* Unconditional jump */ + pat lab with STACK - gen - b {LABEL, $1} + kills ALL + gen + labeldef $1 + + pat bra + with STACK + gen + b {LABEL, $1} + @@ -1058,31 +1072,27 @@ PATTERNS gen bl %1 - pat lfr $1==INT32 /* Load function result, word */ + pat lfr $1==QUAD /* Load function result, word */ yields R0 - pat lfr $1==INT64 /* Load function result, double-word */ - yields R0 R1 - pat ret $1==0 /* Return from procedure */ gen return - mov SP, FP - pop FP, PC + mov SP, FP + pop FP, PC - pat ret $1==INT32 /* Return from procedure, word */ + pat ret $1<=QUAD /* Return from procedure, word */ with GPR0 - gen - return - mov SP, FP - pop FP, PC - - pat ret $1==INT64 /* Return from procedure, double-word */ - with GPR0 GPR1 - gen - return - mov SP, FP - pop FP, PC + gen + return + mov SP, FP + pop FP, PC + with STACK + gen + pop R0 + return + mov SP, FP + pop FP, PC pat blm /* Block move constant length */ with GPRI GPRI STACK @@ -1253,3 +1263,68 @@ PATTERNS loc $1 ass + + +/* Floating point */ + + pat ngf /* Negate float */ + leaving + loc 0 + exg QUAD + sbf QUAD + + proc simple_f example adf + with GPRI GPRI + uses reusing %1, REG + gen + fadd[1] %a, %2, %1 + yields %a + + pat adf call simple_f("fadd") /* Float subtract (second + top) */ + pat sbf call simple_f("fsub") /* Float subtract (second - top) */ + pat mlf call simple_f("fmul") /* Float multiply (second * top) */ + pat dvf call simple_f("fdiv") /* Float divide (second / top) */ + + pat loc loc cff $1==$2 && $1==QUAD /* Convert float to float */ + leaving + nop + + pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */ + with GPR0 + gen + bl {LABEL, ".cfi"} + yields R0 + + pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */ + with GPR0 + gen + bl {LABEL, ".cfu"} + yields R0 + + pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */ + with GPR0 + gen + bl {LABEL, ".cif"} + yields R0 + + pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */ + with GPR0 + gen + bl {LABEL, ".cuf"} + yields R0 + + pat fef /* Split float */ + with GPR0 + kills GPR1 + gen + bl {LABEL, ".fef"} + yields R0 R1 + + pat fif /* Multiply float and split (?) */ + with GPRI GPRI + kills GPR0, GPR1 + gen + fmul R0, %2, %1 + bl {LABEL, ".fef"} + yields R0 R1 + diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index 679be61ea..9716eb058 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -12,6 +12,7 @@ OPTIMISATION := -O D := plat/rpi/ platform-headers := \ + unistd.h \ ack/config.h platform-libsys := \ diff --git a/plat/rpi/descr b/plat/rpi/descr index fd9cc4dca..23862840d 100644 --- a/plat/rpi/descr +++ b/plat/rpi/descr @@ -7,7 +7,7 @@ var p=4 var s=2 var l=4 var f=4 -var d=8 +var d=4 var ARCH=vc4 var PLATFORM=rpi var PLATFORMDIR={EM}/share/ack/{PLATFORM} From 92817a6ad7beb7c4565a8c6d51fde04f47f47dd3 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 21 May 2013 19:18:11 +0100 Subject: [PATCH 041/231] Allow platforms to specify size of long double; seperate alignment from size. --HG-- branch : dtrg-videocore --- lib/descr/fe | 2 +- plat/cpm/descr | 8 ++++++++ plat/linux386/descr | 14 +++++++++++--- plat/linux68k/descr | 14 +++++++++++--- plat/linuxppc/descr | 14 +++++++++++--- plat/pc86/descr | 8 ++++++++ plat/rpi/descr | 16 ++++++++++++---- 7 files changed, 62 insertions(+), 14 deletions(-) diff --git a/lib/descr/fe b/lib/descr/fe index a8d610362..4e85c64b3 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -84,7 +84,7 @@ name cem -DEM_SSIZE={s} -DEM_LSIZE={l} -DEM_FSIZE={f} -DEM_DSIZE={d}) \ -D_EM_WSIZE={w} -D_EM_PSIZE={p} \ -D_EM_SSIZE={s} -D_EM_LSIZE={l} -D_EM_FSIZE={f} -D_EM_DSIZE={d} \ - -Vw{w}.{w}i{w}.{w}p{p}.{w}f{f}.{w}s{s}.{s}l{l}.{w}d{d}.{w} \ + -Vw{w}.{wa}i{w}.{wa}p{p}.{pa}f{f}.{fa}s{s}.{sa}l{l}.{la}d{d}.{da}x{x}.{xa} \ {CC_ALIGN?} \ {CEM_F?} {LFLAG?} < > callname acc diff --git a/plat/cpm/descr b/plat/cpm/descr index a72f50276..2d626295a 100644 --- a/plat/cpm/descr +++ b/plat/cpm/descr @@ -3,11 +3,19 @@ # $Revision$ 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=i80 var PLATFORM=cpm var PLATFORMDIR={EM}/share/ack/{PLATFORM} diff --git a/plat/linux386/descr b/plat/linux386/descr index ff2b26dfb..3bdd9d768 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -3,11 +3,19 @@ # $Revision$ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} var d=8 +var da={d} +var x=8 +var xa={x} var ARCH=i386 var PLATFORM=linux386 var PLATFORMDIR={EM}/share/ack/{PLATFORM} diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 14f973d52..997ec7154 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -3,11 +3,19 @@ # $Revision: 1.1 $ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} var d=8 +var da={d} +var x=8 +var xa={x} var ARCH=m68020 var PLATFORM=linux68k var PLATFORMDIR={EM}/share/ack/{PLATFORM} diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr index 3311f24c6..69b00fbc5 100644 --- a/plat/linuxppc/descr +++ b/plat/linuxppc/descr @@ -3,11 +3,19 @@ # $Revision: 1.1 $ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} var d=8 +var da={d} +var x=8 +var xa={x} var ARCH=powerpc var PLATFORM=linuxppc var PLATFORMDIR={EM}/share/ack/{PLATFORM} diff --git a/plat/pc86/descr b/plat/pc86/descr index a3f11fc4f..c282e9cc7 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -3,11 +3,19 @@ # $Revision$ 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=i86 var PLATFORM=pc86 var PLATFORMDIR={EM}/share/ack/{PLATFORM} diff --git a/plat/rpi/descr b/plat/rpi/descr index 23862840d..6daff9606 100644 --- a/plat/rpi/descr +++ b/plat/rpi/descr @@ -3,11 +3,19 @@ # $Revision$ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 -var d=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} +var d={w} +var da={w} +var x={w} +var xa={w} var ARCH=vc4 var PLATFORM=rpi var PLATFORMDIR={EM}/share/ack/{PLATFORM} From 1312fe298b0df5f5a8860c6acdb6020f8f74d024 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 21 May 2013 20:05:26 +0100 Subject: [PATCH 042/231] Now compiles (incorrectly) the entire libc, libpc, libm2 and libbasic! --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 220 ++++++++++++++++++++++++++------------ plat/rpi/include/unistd.h | 20 ++++ 2 files changed, 173 insertions(+), 67 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 368c6177e..fd9a106e8 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -293,7 +293,8 @@ PATTERNS leaving dup 4 ste $1 - + + /* Type conversions */ @@ -450,22 +451,30 @@ PATTERNS loc 0 ste $1 -#if 0 pat ine /* Increment external */ - uses REG={LABEL, $1}, REG - gen - lwz %b, {GPROFFSET, %a, 0} - addi %b, %b, {CONST, 1} - stw %b, {GPROFFSET, %a, 0} - + leaving + lae $1 + dup QUAD + loi QUAD + inc + sti QUAD + pat dee /* Decrement external */ - uses REG={LABEL, $1}, REG - gen - lwz %b, {GPROFFSET, %a, 0} - addi %b, %b, {CONST, 0-1} - stw %b, {GPROFFSET, %a, 0} -#endif - + leaving + lae $1 + dup QUAD + loi QUAD + dec + sti QUAD + + pat lde /* Load external */ + uses REG, REG + gen + lea %a, {LABEL, $1} + ld %b, {GPROFFSET, %a, 4} + ld %a, {GPROFFSET, %a, 0} + yields %b %a + /* Structures */ @@ -474,13 +483,30 @@ PATTERNS leaving adp $1 loi QUAD - - + + pat ldf /* Load double offsetted */ + with GPRI + uses reusing %1, REG=%1, REG + gen + add %a, GP + ld %b, {GPROFFSET, %a, $1+4} + ld %a, {GPROFFSET, %a, $1+0} + yields %a %b + pat stf /* Store word offsetted */ leaving adp $1 sti QUAD - + + pat sdf /* Store double offsetted */ + with GPRI GPRI GPRI + uses reusing %3, REG=%3 + gen + add %a, GP + st %1, {GPROFFSET, %a, $1+0} + st %2, {GPROFFSET, %a, $1+4} + + /* Loads and stores */ @@ -659,6 +685,54 @@ PATTERNS sub %a, %1 yields %a + pat mli $1==QUAD /* Multiply word (second * top) */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + mul %a, %1 + yields %a + with GPRI GPRI+CONST + uses reusing %1, REG=%1 + gen + mul %a, %2 + yields %a + + pat mlu + leaving + mli $1 + + pat dvi $1==QUAD /* Divide word (second / top) */ + with GPRI GPRI + uses reusing %2, REG + gen + divs %a, %2, %1 + yields %a + + pat dvu $1==QUAD /* Divide unsigned word (second / top) */ + with GPRI GPRI + uses reusing %2, REG + gen + divu %a, %2, %1 + yields %a + + pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ + with GPRI GPRI + uses REG + gen + divu %a, %2, %1 + mul %a, %1 + sub %a, %2 + yields %a + + pat rmi $1==QUAD /* Remainder signed word (second % top) */ + with GPRI GPRI + uses REG + gen + divs %a, %2, %1 + mul %a, %1 + sub %a, %2 + yields %a + pat ngi $1==QUAD /* Negate word */ with GPRI uses reusing %1, REG=%1 @@ -725,6 +799,15 @@ PATTERNS sub %a, %2 yields %a + pat rmi $1==QUAD /* Remainder signed word (second % top) */ + with GPRI GPRI + uses REG + gen + divs %a, %2, %1 + mul %a, %1 + sub %a, %2 + yields %a + #if 0 pat mli $1==4 /* Multiply word (second * top) */ with REG REG @@ -733,15 +816,7 @@ PATTERNS mullw %a, %2, %1 yields %a - pat rmi $1==4 /* Remainder word (second % top) */ - with REG REG - uses REG - gen - divw %a, %2, %1 - mullw %a, %a, %1 - subf %a, %a, %2 - yields %a - + pat and !defined($1) /* AND set */ with STACK gen @@ -810,30 +885,41 @@ PATTERNS gen lsr %2, %1 yields %a -#if 0 - + /* Arrays */ pat aar $1==QUAD /* Index array */ - with GPR3 GPR4 GPR5 + with STACK + uses GPR0 + gen + bl {LABEL, ".aar4stack"} + yields R0 + with GPR0 GPR1 GPR2 + uses GPR0 gen bl {LABEL, ".aar4"} - yields R3 - + yields R0 + pat lae lar $2==QUAD && nicesize(rom($1, 3)) /* Load array */ leaving lae $1 aar QUAD loi rom($1, 3) - + pat lar $1==QUAD /* Load array */ - with GPR3 GPR4 GPR5 STACK - kills ALL + with STACK + uses GPR0 + gen + bl {LABEL, ".lar4stack"} + yields R0 + with GPR0 GPR1 GPR2 + uses GPR0 gen bl {LABEL, ".lar4"} - + yields R0 + pat lae sar $2==QUAD && nicesize(rom($1, 3)) /* Store array */ leaving lae $1 @@ -841,11 +927,15 @@ PATTERNS sti rom($1, 3) pat sar $1==QUAD /* Store array */ - with GPR3 GPR4 GPR5 STACK - kills ALL + with STACK + uses GPR0 + gen + bl {LABEL, ".sar4stack"} + yields R0 + with GPR0 GPR1 GPR2 + uses GPR0 gen bl {LABEL, ".sar4"} - @@ -854,25 +944,30 @@ PATTERNS pat set defined($1) /* Create word with set bit */ leaving loc 1 - exg QUAD - sli QUAD - + exg $1 + sli $1 + pat set !defined($1) /* Create structure with set bit (variable) */ - with GPR3 GPR4 STACK + with STACK gen bl {LABEL, ".set"} - + pat inn defined($1) /* Test for set bit */ leaving set QUAD and QUAD - + pat inn !defined($1) /* Test for set bit (variable) */ - with GPR3 STACK + with GPR0 STACK gen bl {LABEL, ".inn"} -#endif - + yields R0 + + pat ior !defined($1) /* Or two sets */ + with STACK + gen + bl {LABEL, ".ior"} + /* Boolean resolutions */ @@ -1095,28 +1190,16 @@ PATTERNS pop FP, PC pat blm /* Block move constant length */ - with GPRI GPRI STACK - uses REG - gen - sub SP, {CONST, 12} - mov %a, {CONST, $1} - st %1, {GPROFFSET, SP, 0} - st %2, {GPROFFSET, SP, 4} - st %a, {GPROFFSET, SP, 8} - bl {LABEL, "_memmove"} - add SP, {CONST, 12} - -#if 0 + leaving + loc $1 + bls + pat bls /* Block move variable length */ - with GPR GPR GPR STACK + with STACK + kills ALL gen - stwu %1, {GPROFFSET, SP, 0-4} - stwu %3, {GPROFFSET, SP, 0-4} - stwu %2, {GPROFFSET, SP, 0-4} bl {LABEL, "_memmove"} - addi SP, SP, {CONST, 12} -#endif - + pat csa /* Array-lookup switch */ with STACK gen @@ -1328,3 +1411,6 @@ PATTERNS bl {LABEL, ".fef"} yields R0 R1 + pat zrf /* Load a floating zero */ + leaving + loc 0 diff --git a/plat/rpi/include/unistd.h b/plat/rpi/include/unistd.h index ddd8739d3..4cbf43c58 100644 --- a/plat/rpi/include/unistd.h +++ b/plat/rpi/include/unistd.h @@ -9,12 +9,32 @@ #define _UNISTD_H #include +#include /* Types */ typedef int pid_t; typedef int mode_t; +typedef long suseconds_t; + +/* Time handling. */ + +struct timeval +{ + time_t tv_sec; + suseconds_t tv_usec; +}; + +struct timezone +{ + int tz_minuteswest; + int tz_dsttime; +}; /* obsolete, unused */ + +extern int gettimeofday(struct timeval* tv, struct timezone* tz); +extern int settimeofday(const struct timeval* tv, const struct timezone* tz); + /* Constants for file access (open and friends) */ enum From 5e9102955c72f98b50919db1d85e842bd3a5c756 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 21 May 2013 23:17:30 +0100 Subject: [PATCH 043/231] Reworked VC4 relocations and some of the instruction encoding to be actually correct. Now generating what could be real code! --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 68 ++++++++++++++----- mach/vc4/libem/dummy.s | 5 ++ plat/rpi/boot.s | 16 +++++ util/led/relocate.c | 151 +++++++++++++++++++++++++++++++---------- 4 files changed, 187 insertions(+), 53 deletions(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index d6f71e7fb..b1ce314bc 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -7,6 +7,11 @@ #define maskx(v, x) (v & ((1<<(x))-1)) +static void toobig(void) +{ + serror("offset too big to encode into instruction"); +} + /* Assemble an ALU instruction where rb is a register. */ void alu_instr_reg(quad op, int cc, int rd, int ra, int rb) @@ -90,6 +95,7 @@ void misc_instr_lit(quad op, int cc, int rd, int ra, quad value) void branch_instr(int bl, int cc, struct expr_t* expr) { + quad pc = DOTVAL; quad type = expr->typ & S_TYP; /* Sanity checking. */ @@ -114,7 +120,7 @@ void branch_instr(int bl, int cc, struct expr_t* expr) /* The VC4 branch instructions express distance in 2-byte * words. */ - int d = (expr->val - DOTVAL) / 2; + int d = (expr->val - pc) / 2; /* We now know the worst case for the instruction layout. At * this point we can emit the instructions, which may shrink @@ -126,7 +132,7 @@ void branch_instr(int bl, int cc, struct expr_t* expr) * close enough to the program counter, we can use a short- * form instruction. */ - if ((d >= -128) && (d < 127)) + if (fitx(d, 7)) { emit2(B16(00011000,00000000) | (cc<<7) | (d&0x7f)); break; @@ -136,19 +142,29 @@ void branch_instr(int bl, int cc, struct expr_t* expr) /* Absolute addresses and references to other sections * need the full 32 bits. */ - newrelo(expr->typ, RELOVC4 | RELPC); + newrelo(expr->typ, RELOVC4|RELPC); if (bl) { - quad v = d & 0x07ffffff; - quad hiv = v >> 23; - quad lov = v & 0x007fffff; + quad v, hiv, lov; + + if (!fitx(d, 27)) + toobig(); + + v = maskx(d, 27); + hiv = v >> 23; + lov = v & 0x007fffff; emit2(B16(10010000,10000000) | (lov>>16) | (hiv<<8)); emit2(B16(00000000,00000000) | (lov&0xffff)); } else { - quad v = d & 0x007fffff; + quad v; + + if (!fitx(d, 23)) + toobig(); + + v = maskx(d, 23); emit2(B16(10010000,00000000) | (cc<<8) | (v>>16)); emit2(B16(00000000,00000000) | (v&0xffff)); } @@ -334,6 +350,8 @@ void mem_postincr_instr(quad opcode, int cc, int rd, int rs) void mem_address_instr(quad opcode, int rd, struct expr_t* expr) { + static const char sizes[] = {4, 2, 1, 2}; + int size = sizes[opcode]; quad type = expr->typ & S_TYP; /* Sanity checking. */ @@ -354,10 +372,7 @@ void mem_address_instr(quad opcode, int rd, struct expr_t* expr) case 1: case 2: { - /* The VC4 branch instructions express distance in 2-byte - * words. */ - - int d = (expr->val - DOTVAL) / 2; + int d = expr->val - DOTVAL; /* We now know the worst case for the instruction layout. At * this point we can emit the instructions, which may shrink @@ -365,24 +380,30 @@ void mem_address_instr(quad opcode, int rd, struct expr_t* expr) if (type == DOTTYP) { + int scaledd = d/size; + /* This is a reference to an address within this section. If * it's close enough to the program counter, we can use a * shorter instruction. */ - if (fitx(d, 16)) + if (fitx(scaledd, 16)) { emit2(B16(10101010,00000000) | (opcode<<5) | (rd<<0)); - emit2(d); + emit2(scaledd); return; } } /* Otherwise we need the full 48 bits. */ - if (!fitx(d, 27)) - serror("offset too big to encode into instruction"); + newrelo(expr->typ, RELOVC4|RELPC); - newrelo(expr->typ, RELOVC4 | RELPC); + /* VC4 relocations store the PC-relative delta into the + * destination section in the instruction data. The linker will + * massage this, and scale it appropriately. */ + + if (!fitx(d, 27)) + toobig(); emit2(B16(11100111,00000000) | (opcode<<5) | (rd<<0)); emit4((31<<27) | maskx(d, 27)); @@ -493,8 +514,19 @@ void lea_stack_instr(int rd, long va, int rs) void lea_address_instr(int rd, struct expr_t* expr) { - newrelo(expr->typ, RELOVC4); + quad pc = DOTVAL; + quad type = expr->typ & S_TYP; + + if (type == S_ABS) + serror("can't use absolute addresses here"); + + newrelo(expr->typ, RELOVC4|RELPC); + + /* VC4 relocations store the PC-relative delta into the + * destination section in the instruction data. The linker will + * massage this, and scale it appropriately. */ + emit2(B16(11100101,00000000) | (rd<<0)); - emit4(expr->val); + emit4(expr->val - pc); } diff --git a/mach/vc4/libem/dummy.s b/mach/vc4/libem/dummy.s index 4edaa030f..fdbcc4c38 100644 --- a/mach/vc4/libem/dummy.s +++ b/mach/vc4/libem/dummy.s @@ -7,3 +7,8 @@ */ #include "videocore.h" + +.define __dummy +.sect .data +__dummy: + diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index 3cf4f3fe1..b848e65c4 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -16,6 +16,10 @@ .sect .text begtext: + lea r15, begtext + st sp, .returnsp + st lr, .returnlr + #if 0 ! Wipe the bss. (I'm a little suprised that __m_a_i_n doesn't do this.) @@ -33,6 +37,12 @@ begtext: #endif b __m_a_i_n +.define __exit +__exit: + ld sp, .returnsp + ld lr, .returnlr + b lr + ! Define symbols at the beginning of our various segments, so that we can find ! them. (Except .text, which has already been done.) @@ -47,3 +57,9 @@ begtext: .comm .trppc, 4 .comm .ignmask, 4 .comm _errno, 4 + +! We store the stack pointer and return address on entry so that we can +! cleanly exit. + +.comm .returnsp, 4 +.comm .returnlr, 4 diff --git a/util/led/relocate.c b/util/led/relocate.c index f44a34b96..3cc9ff904 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -8,6 +8,7 @@ static char rcsid[] = "$Id$"; #include #include +#include #include #include "out.h" #include "const.h" @@ -44,6 +45,65 @@ static long read4(char* addr, int type) return ((long)word1 << (2 * WIDTH)) + word0; } +/* VideoCore 4 fixups are complex as we need to patch the instruction in + * one of several different ways (depending on what the instruction is). + */ + +static long get_vc4_valu(char* addr) +{ + uint16_t opcode = read2(addr, 0); + + if ((opcode & 0xff00) == 0xe700) + { + /* ld rd, $+o: [1110 0111 ww 0 d:5] [11111 o:27] + * st rd, $+o: [1110 0111 ww 1 d:5] [11111 o:27] + */ + + int32_t value = read4(addr+2, 0); + value &= 0x07ffffff; + value = value<<5>>5; + return value; + } + + if ((opcode & 0xf080) == 0x9000) + { + /* b $+o*2: [1001 cccc 0ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + */ + + uint32_t value = read4(addr, RELWR); + value &= 0x007fffff; + value = value<<9>>9; + value *= 2; + return value; + } + + if ((opcode & 0xf080) == 0x9080) + { + /* bl $+o*2: [1001 oooo 1ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + * (Note that o is split.) + */ + + int32_t value = read4(addr, RELWR); + int32_t lov = value & 0x007fffff; + int32_t hiv = value & 0x0f000000; + value = lov | (hiv>>1); + value = value<<5>>5; + value *= 2; + return value; + } + + if ((opcode & 0xffe0) == 0xe500) + { + /* lea: [1110 0101 000 d:5] [o:32] */ + + return read4(addr+2, 0); + } + + assert(0 && "unrecognised VC4 instruction"); +} + /* * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. @@ -65,21 +125,7 @@ getvalu(addr, type) case RELOH2: return read2(addr, type) << 16; case RELOVC4: - { - long i = read4(addr, type); - if (i & 0x00800000) - { - /* Branch instruction. */ - return (i<<9)>>9; - } - else - { - /* Branch-link instruction. */ - long hi = (i<<4)>>28; - long lo = (i & 0x007fffff); - return lo | (hi<<23); - } - } + return get_vc4_valu(addr); default: fatal("bad relocation size"); } @@ -123,6 +169,60 @@ static void write4(long valu, char* addr, int type) } } +/* VideoCore 4 fixups are complex as we need to patch the instruction in + * one of several different ways (depending on what the instruction is). + */ + +static void put_vc4_valu(char* addr, long value) +{ + uint16_t opcode = read2(addr, 0); + + if ((opcode & 0xff00) == 0xe700) + { + /* ld rd, o, (pc): [1110 0111 ww 0 d:5] [11111 o:27] + * st rd, o, (pc): [1110 0111 ww 1 d:5] [11111 o:27] + */ + + uint32_t v = read4(addr+2, 0); + v &= 0xf8000000; + v |= value & 0x07ffffff; + write4(v, addr+2, 0); + } + else if ((opcode & 0xf080) == 0x9000) + { + /* b dest: [1001 cccc 0ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + */ + + uint32_t v = read4(addr, RELWR); + v &= 0xff800000; + v |= (value/2) & 0x007fffff; + write4(v, addr, RELWR); + } + else if ((opcode & 0xf080) == 0x9080) + { + /* bl dest: [1001 oooo 1ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + * (Note that o is split.) + */ + + uint32_t v = read4(addr, RELWR); + uint32_t lovalue = (value/2) & 0x007fffff; + uint32_t hivalue = (value/2) & 0x07800000; + v &= 0xf0800000; + v |= lovalue | (hivalue<<1); + write4(v, addr, RELWR); + } + else if ((opcode & 0xffe0) == 0xe500) + { + /* lea: [1110 0101 000 d:5] [o:32] */ + + write4(value, addr+2, 0); + } + else + assert(0 && "unrecognised VC4 instruction"); +} + /* * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. @@ -156,27 +256,8 @@ putvalu(valu, addr, type) write2(valu>>16, addr, type); break; case RELOVC4: - { - long i = read4(addr, type); - if (i & 0x00800000) - { - /* Branch instruction. */ - unsigned v = (valu/2) & 0x007fffff; - i &= ~0x007fffff; - i |= v; - } - else - { - /* Branch-link instruction. */ - unsigned v = (valu/2) & 0x07ffffff; - unsigned hiv = v >> 23; - unsigned lov = v & 0x007fffff; - i &= ~0x0f7fffff; - i |= (lov>>16) | (hiv<<24); - } - write4(i, addr, type); + put_vc4_valu(addr, valu); break; - } default: fatal("bad relocation size"); } From f904465e9c2dbc1cb5aec0e4c0ad5e375d3043ed Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 00:16:16 +0100 Subject: [PATCH 044/231] Fix signedness problem that was showing up on ARM. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index b1ce314bc..f3671bf64 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -5,6 +5,8 @@ * See the file 'Copying' in the root of the distribution for the full text. */ +#include + #define maskx(v, x) (v & ((1<<(x))-1)) static void toobig(void) @@ -120,7 +122,7 @@ void branch_instr(int bl, int cc, struct expr_t* expr) /* The VC4 branch instructions express distance in 2-byte * words. */ - int d = (expr->val - pc) / 2; + int d = ((int32_t)expr->val - (int32_t)pc) / 2; /* We now know the worst case for the instruction layout. At * this point we can emit the instructions, which may shrink From 72542288cd95f93740d88fec17380ef3e0129cd2 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 00:16:59 +0100 Subject: [PATCH 045/231] Adjust bootstrap code to build kernels that work with the mailbox test app. --HG-- branch : dtrg-videocore --- plat/rpi/boot.s | 50 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index b848e65c4..f5c8bafd4 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -15,27 +15,47 @@ .sect .text +#define gp r15 + begtext: - lea r15, begtext + ! Set up system registers. + + lea gp, begtext st sp, .returnsp st lr, .returnlr -#if 0 + ! The GPU kernel code will load parameters into r0-r5. Save them + ! so that the user code can access them. + + sub r0, gp ! pointer + sub r1, gp ! pointer + sub r2, gp ! pointer + sub r3, gp ! pointer + ! r4-r5 are not pointers and don't need adjusting + push r0-r5 + sub r0, sp, gp + st r0, _gpu_parameters + ! Wipe the bss. (I'm a little suprised that __m_a_i_n doesn't do this.) - mov di, begbss - mov cx, endbss - sub cx, di - mov ax, 0 - rep stosb + lea r0, begbss + lea r1, endbss + mov r2, #0 +_1: + stb r2, (r0) + addcmpb.lt r2, #1, r1, _1 ! Push standard parameters onto the stack and go. - push envp ! envp - push argv ! argv - push 1 ! argc -#endif - b __m_a_i_n + mov r0, #0 + push r0 ! envp + push r0 ! argv + push r0 ! argc + + ! Call the language startup code. + + bl __m_a_i_n + ! Fall through to __exit if this returns. .define __exit __exit: @@ -63,3 +83,9 @@ __exit: .comm .returnsp, 4 .comm .returnlr, 4 + +! User pointer to the GPU kernel parameter block. + +.define _gpu_parameters +.comm _gpu_parameters, 4 + From 08c433422449f50a22fa3a82b4d33c062166f045 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 00:44:04 +0100 Subject: [PATCH 046/231] Typo fixes. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach4.c | 4 ++-- mach/vc4/ncg/table | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index 73cbea8e4..4c87209ee 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -22,8 +22,8 @@ operation | OP_BRANCH CC GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, 0, $3, $6, &$8); } | OP_ADDCMPB GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr(ALWAYS, $2, $4, $6, &$8); } | OP_ADDCMPB CC GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr($2, $3, $5, $7, &$9); } - | OP_ADDCMPB GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_reg_reg_instr(ALWAYS, $2, $5, $7, &$9); } - | OP_ADDCMPB CC GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_reg_reg_instr($2, $3, $6, $8, &$10); } + | OP_ADDCMPB GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, $2, $5, $7, &$9); } + | OP_ADDCMPB CC GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_lit_reg_instr($2, $3, $6, $8, &$10); } | OP_ADDCMPB GPR ',' GPR ',' '#' absexp ',' expr { branch_addcmp_reg_lit_instr(ALWAYS, $2, $4, $7, &$9); } | OP_ADDCMPB CC GPR ',' GPR ',' '#' absexp ',' expr { branch_addcmp_reg_lit_instr($2, $3, $5, $8, &$10); } | OP_ADDCMPB GPR ',' '#' absexp ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, $2, $5, $8, &$10); } diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index fd9a106e8..c8dbcb77c 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -1044,17 +1044,17 @@ PATTERNS pat zle call anyz("b.le") /* Branch if signed top <= 0 */ proc anyb example beq - with GPR+CONST GPRI STACK + with GPRI+CONST GPRI STACK gen cmp %2, %1 beq[1] {LABEL, $1} - pat beq call anyz("b.eq") /* Branch if signed second == top */ - pat bne call anyz("b.ne") /* Branch if signed second != top */ - pat bgt call anyz("b.gt") /* Branch if signed second > top */ - pat bge call anyz("b.ge") /* Branch if signed second >= top */ - pat blt call anyz("b.lt") /* Branch if signed second < top */ - pat ble call anyz("b.le") /* Branch if signed second <= top */ + pat beq call anyb("b.eq") /* Branch if signed second == top */ + pat bne call anyb("b.ne") /* Branch if signed second != top */ + pat bgt call anyb("b.gt") /* Branch if signed second > top */ + pat bge call anyb("b.ge") /* Branch if signed second >= top */ + pat blt call anyb("b.lt") /* Branch if signed second < top */ + pat ble call anyb("b.le") /* Branch if signed second <= top */ proc cmu_z example cmu zeq with GPR+CONST GPRI STACK From 6b5316dcfa8e39d589e0a85e2f3e8063111245c8 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 00:52:58 +0100 Subject: [PATCH 047/231] More typo fixes. --HG-- branch : dtrg-videocore --- plat/rpi/boot.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index f5c8bafd4..e190f2ae3 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -43,7 +43,7 @@ begtext: mov r2, #0 _1: stb r2, (r0) - addcmpb.lt r2, #1, r1, _1 + addcmpb.lt r0, #1, r1, _1 ! Push standard parameters onto the stack and go. From 0068952bd1f0230cab4602bae6b863996ba0c872 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 09:47:22 +0100 Subject: [PATCH 048/231] Build the Raspberry Pi code. --HG-- branch : dtrg-videocore --- Makefile | 4 ++++ README | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e203d3243..dbac9cabd 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,8 @@ CFLAGS += \ LDFLAGS += +ACKFLAGS = -Ih + all: installables .DELETE_ON_ERROR: @@ -101,6 +103,7 @@ include mach/i386/build.mk include mach/i86/build.mk include mach/m68020/build.mk # include mach/powerpc/build.mk +include mach/vc4/build.mk include plat/build.mk include plat/pc86/build.mk @@ -108,6 +111,7 @@ include plat/cpm/build.mk include plat/linux386/build.mk include plat/linux68k/build.mk # include plat/linuxppc/build.mk +include plat/rpi/build.mk .PHONY: installables installables: $(INSTALLABLES) diff --git a/README b/README index d6a56b050..52abe73be 100644 --- a/README +++ b/README @@ -32,6 +32,7 @@ pc86 produces bootable floppy disk images for 8086 PCs linux386 produces ELF executables for PC Linux systems linux68k produces ELF executables for m68020 Linux systems cpm produces i80 CP/M .COM files +rpi produces Raspberry Pi GPU binaries INSTALLATION @@ -124,7 +125,7 @@ GOTCHAS There are some things you should be aware of. -- Look at plat//README for information about the two supported +- Look at plat//README for information about the supported platforms. - The library support is fairly limited; for C, it's at roughly the ANSI C From 9e556d8b7ba8f8eb8ff731677935189a0c52af7b Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 10:55:13 +0100 Subject: [PATCH 049/231] Optimise direct access to globals, and incrementing and decrementing locals. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 103 ++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index c8dbcb77c..a82fc49fb 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -276,12 +276,10 @@ PATTERNS with GPRI GPRI yields %1 %2 -#if 0 pat stl lol $1==$2 /* Store then load local */ leaving dup QUAD stl $1 -#endif pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */ leaving @@ -352,8 +350,8 @@ PATTERNS pat lal /* Load address of local */ uses REG gen - add %a, FP, {CONST, $1} - sub %a, GP + sub %a, FP, GP + add %a, {CONST, $1} yields %a pat lol inreg($1)>0 /* Load from local */ @@ -367,8 +365,8 @@ PATTERNS pat ldl /* Load double-word from local */ leaving - lal $1 - loi QUAD*2 + lol $1 + QUAD*0 + lol $1 + QUAD*1 pat stl inreg($1)>0 /* Store to local */ with CONST+GPRI @@ -383,8 +381,8 @@ PATTERNS pat sdl /* Store double-word to local */ leaving - lal $1 - sti QUAD*2 + stl $1 + QUAD*1 + stl $1 + QUAD*0 pat lil inreg($1)>0 /* Load from indirected local */ uses REG @@ -404,26 +402,36 @@ PATTERNS pat stl lol $1==$2 /* Save then load (generated by C compiler) */ leaving - dup 4 + dup QUAD stl $1 - pat zrl /* Zero local */ + pat zrl /* Zero local */ leaving loc 0 stl $1 - pat inl /* Increment local */ + pat inl inreg($1)>0 /* Increment local in register */ + kills regvar($1) + gen + add {GPRE, regvar($1)}, {CONST, 1} + + pat inl inreg($1)<=0 /* Increment local */ leaving lol $1 loc 1 - adi 4 + adi QUAD stl $1 - pat del /* Decrement local */ + pat del inreg($1)>0 /* Decrement local in register */ + kills regvar($1) + gen + sub {GPRE, regvar($1)}, {CONST, 1} + + pat del inreg($1)<=0 /* Decrement local */ leaving lol $1 loc 1 - sbi 4 + sbi QUAD stl $1 @@ -512,6 +520,11 @@ PATTERNS /* Loads and stores */ pat loi $1==BYTE /* Load byte indirect */ + with LABEL + uses REG + gen + ldb %a, %1 + yields %a with GPR uses reusing %1, REG gen @@ -523,51 +536,46 @@ PATTERNS ldb %a, {GPRGPR, %1.reg, GP} yields %a -#if 0 - pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load half-word indirect and sign extend */ - with GPR + pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load short indirect and sign extend */ + with LABEL uses REG gen - lha %a, {GPROFFSET, %1, 0} + ldhs %a, %1 yields %a - with SUM_RR + with GPRI uses reusing %1, REG gen - lhax %a, %1.reg1, %1.reg2 - yields %a - with SUM_RC - uses REG - gen - move {IND_RC_H_S, %1.reg, %1.off}, %a + add %a, %1, GP + ldhs %a, {GPROFFSET, %a, 0} yields %a - pat loi $1==WORD /* Load half-word indirect */ - with GPR + pat loi $1==WORD /* Load short indirect */ + with LABEL uses REG gen - lhz %a, {GPROFFSET, %1, 0} + ldh %a, %1 yields %a - with SUM_RR + with GPRI uses reusing %1, REG gen - lhzx %a, %1.reg1, %1.reg2 + add %a, %1, GP + ldh %a, {GPROFFSET, %a, 0} yields %a - with SUM_RC - uses REG - gen - move {IND_RC_H, %1.reg, %1.off}, %a - yields %a -#endif - + pat loi $1==QUAD /* Load quad indirect */ - with GPR + with LABEL + uses REG + gen + ld %a, %1 + yields %a + with GPRI uses reusing %1, REG gen add %a, %1, GP ld %a, {GPROFFSET, %a, 0} yields %a - pat loi /* Load arbitrary size */ + pat loi !nicesize($1) /* Load arbitrary size */ leaving loc $1 los QUAD @@ -579,6 +587,9 @@ PATTERNS bl {LABEL, ".los"} pat sti $1==BYTE /* Store byte indirect */ + with LABEL GPRI + gen + stb %2, %1 with GPR GPRI gen stb %2, {GPRGPR, %1, GP} @@ -587,15 +598,21 @@ PATTERNS stb %2, {GPRGPR, %1.reg, GP} pat sti $1==WORD /* Store half-word indirect */ - with GPR GPR - uses REG + with LABEL GPRI + gen + sth %2, %1 + with GPRI GPRI + uses reusing %1, REG gen add %a, %1, GP sth %2, {GPROFFSET, %a, 0} pat sti $1==QUAD /* Store quad indirect */ - with GPR GPR - uses REG + with LABEL GPRI + gen + st %2, %1 + with GPRI GPRI + uses reusing %1, REG gen add %a, %1, GP st %2, {GPROFFSET, %a, 0} From cdce394b6c4fd85c53e015cf26f36deecddb4bd3 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 11:02:46 +0100 Subject: [PATCH 050/231] Generate ld rd, (rs) instructions properly. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index f3671bf64..53ec3464c 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -254,7 +254,7 @@ void mem_instr(quad opcode, int cc, int rd, long offset, int rs) if ((rs < 0x10) && (rd < 0x10) && (offset == 0)) { - emit2(B16(00001000,00000000) | (opcode<<8) | (rs<<4) | (rd<<4)); + emit2(B16(00001000,00000000) | (opcode<<8) | (rs<<4) | (rd<<0)); return; } From b5e5df4a63b8e5c8269faa881d4a1d8492aa8c7b Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 18:25:30 +0100 Subject: [PATCH 051/231] Allocate a user stack to run code in. --HG-- branch : dtrg-videocore --- plat/rpi/boot.s | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index e190f2ae3..9e54d3292 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -16,6 +16,12 @@ .sect .text #define gp r15 +#define STACKSIZE 16*1024 + +! MAIN ENTRY POINT +! +! When running as a kernel, our parameters are passed in in r0-r5, so +! the startup sequence mustn't disturb these. begtext: ! Set up system registers. @@ -24,27 +30,28 @@ begtext: st sp, .returnsp st lr, .returnlr - ! The GPU kernel code will load parameters into r0-r5. Save them - ! so that the user code can access them. + ! Wipe the bss. (I'm a little suprised that __m_a_i_n doesn't do this.) + + lea r6, begbss + lea r7, endbss + mov r8, #0 +_1: + stb r8, (r6) + addcmpb.lt r6, #1, r7, _1 + ! Set up the new stack and save the kernel parameters to it. + + lea sp, .stack + STACKSIZE sub r0, gp ! pointer sub r1, gp ! pointer sub r2, gp ! pointer sub r3, gp ! pointer ! r4-r5 are not pointers and don't need adjusting push r0-r5 + sub r0, sp, gp st r0, _gpu_parameters - ! Wipe the bss. (I'm a little suprised that __m_a_i_n doesn't do this.) - - lea r0, begbss - lea r1, endbss - mov r2, #0 -_1: - stb r2, (r0) - addcmpb.lt r0, #1, r1, _1 - ! Push standard parameters onto the stack and go. mov r0, #0 @@ -89,3 +96,7 @@ __exit: .define _gpu_parameters .comm _gpu_parameters, 4 +! User stack. + +.comm .stack, STACKSIZE + From 7537c85e0a09e628b092b808245b2b7e5b7b5e45 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 21:37:48 +0100 Subject: [PATCH 052/231] Generate adds instructions when a shift-and-add is seen (useful for array indexing). --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 82 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index a82fc49fb..65c47e4ed 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -99,6 +99,11 @@ INSTRUCTIONS add GPRI:wo, GPRI:ro, GPRI+CONST:ro. add GPRI:rw, GPRI+CONST:ro. + adds2 GPRI:rw, GPRI+CONST:ro. + adds4 GPRI:rw, GPRI+CONST:ro. + adds8 GPRI:rw, GPRI+CONST:ro. + adds16 GPRI:rw, GPRI+CONST:ro. + adds256 GPRI:rw, GPRI:rw, GPRI:ro. and GPRI:rw, GPRI+CONST:ro. asr GPRI:rw, GPRI+CONST:ro. beq "b.eq" LABEL:ro. @@ -632,16 +637,16 @@ PATTERNS /* Arithmetic wrappers */ - pat ads $1==4 /* Add var to pointer */ + pat ads /* Add var to pointer */ leaving adi $1 - pat sbs $1==4 /* Subtract var from pointer */ + pat sbs /* Subtract var from pointer */ leaving sbi $1 pat adp /* Add constant to pointer */ leaving loc $1 - adi 4 + adi QUAD pat adu /* Add unsigned */ leaving @@ -654,21 +659,21 @@ PATTERNS pat inc /* Add 1 */ leaving loc 1 - adi 4 + adi QUAD pat dec /* Subtract 1 */ leaving loc 1 - sbi 4 + sbi QUAD - pat loc mlu $2==2 /* Unsigned multiply by constant */ + pat loc mlu /* Unsigned multiply by constant */ leaving loc $1 - mli 4 + mli QUAD pat mlu /* Unsigned multiply by var */ leaving - mli $1 + mli QUAD pat loc slu /* Shift left unsigned by constant amount */ leaving @@ -905,6 +910,51 @@ PATTERNS +/* Special arithmetic */ + + pat loc sli adi $1==1 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<1) */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + adds2 %a, %1 + yields %a + + pat loc sli adi $1==2 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<2) */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + adds4 %a, %1 + yields %a + + pat loc sli adi $1==3 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<3) */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + adds8 %a, %1 + yields %a + + pat loc sli adi $1==4 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<4) */ + with GPRI+CONST GPRI + uses reusing %2, REG=%2 + gen + adds16 %a, %1 + yields %a + + pat loc sli adi $1==8 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<8) */ + with GPRI GPRI + uses reusing %2, REG + gen + adds256 %a, %2, %1 + yields %a + + pat loc sli ads + leaving + loc $1 + sli $2 + adi $3 + + + /* Arrays */ pat aar $1==QUAD /* Index array */ @@ -1097,22 +1147,6 @@ PATTERNS pat cmf zge call cmf_z("b.ge") /* Branch if float second >= top */ pat cmf zle call cmf_z("b.le") /* Branch if float second <= top */ - -#if 0 - - pat cmi /* Signed tristate compare */ - with CONST GPR - yields {TRISTATE_RC_S, %2, %1.val} - with GPR GPR - yields {TRISTATE_RR_S, %2, %1} - - pat cmu /* Unsigned tristate compare */ - with CONST GPR - yields {TRISTATE_RC_U, %2, %1.val} - with GPR GPR - yields {TRISTATE_RR_U, %2, %1} -#endif - pat cmp /* Compare pointers */ leaving cmu QUAD From 8f338f9b44af5f4fa24abf70f5fd4ce8861fc256 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 22:46:10 +0100 Subject: [PATCH 053/231] Now actually runs on real hardware. --HG-- branch : dtrg-videocore --- plat/rpi/boot.s | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index 9e54d3292..43811a6ad 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -24,13 +24,8 @@ ! the startup sequence mustn't disturb these. begtext: - ! Set up system registers. - - lea gp, begtext - st sp, .returnsp - st lr, .returnlr - - ! Wipe the bss. (I'm a little suprised that __m_a_i_n doesn't do this.) + ! Wipe the bss. This must happen absolutely first, because we need + ! to store the old system registers into it. lea r6, begbss lea r7, endbss @@ -39,15 +34,32 @@ _1: stb r8, (r6) addcmpb.lt r6, #1, r7, _1 + ! Set up system registers. + + lea gp, begtext + st fp, .returnfp + st sp, .returnsp + st lr, .returnlr + ! Set up the new stack and save the kernel parameters to it. - lea sp, .stack + STACKSIZE + lea sp, .stack + STACKSIZE - 6*4 + sub r0, gp ! pointer + st r0, 0 (sp) + sub r1, gp ! pointer + st r1, 4 (sp) + sub r2, gp ! pointer + st r2, 8 (sp) + sub r3, gp ! pointer + st r3, 12 (sp) + ! r4-r5 are not pointers and don't need adjusting - push r0-r5 + st r4, 16 (sp) + st r5, 20 (sp) sub r0, sp, gp st r0, _gpu_parameters @@ -62,10 +74,12 @@ _1: ! Call the language startup code. bl __m_a_i_n + ! Fall through to __exit if this returns. .define __exit __exit: + ld fp, .returnfp ld sp, .returnsp ld lr, .returnlr b lr @@ -88,6 +102,7 @@ __exit: ! We store the stack pointer and return address on entry so that we can ! cleanly exit. +.comm .returnfp, 4 .comm .returnsp, 4 .comm .returnlr, 4 From 6cbe6e1c4ee590cc8aa33ef3e098a0bd7d3c120f Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 23:12:48 +0100 Subject: [PATCH 054/231] Better treatment of sign extension. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 150 +++++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 67 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 65c47e4ed..3c96d711c 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -79,6 +79,12 @@ TOKENS GPRE = { GPR reg; } 4 reg. +/* Sign extended values. */ + + /* The size refers to the *source*. */ + SIGNEX8 = { GPR reg; } 4 reg. + SIGNEX16 = { GPR reg; } 4 reg. + /* The results of comparisons. */ TRISTATE_RC_S = { GPR reg; INT val; } 4. @@ -92,59 +98,61 @@ SETS TOKEN = LABEL + CONST. GPRI = GPR + GPRE. + OP = TOKEN + SIGNEX8 + SIGNEX16. + XREG = GPRI + SIGNEX8 + SIGNEX16. INSTRUCTIONS - add GPRI:wo, GPRI:ro, GPRI+CONST:ro. - add GPRI:rw, GPRI+CONST:ro. - adds2 GPRI:rw, GPRI+CONST:ro. - adds4 GPRI:rw, GPRI+CONST:ro. - adds8 GPRI:rw, GPRI+CONST:ro. - adds16 GPRI:rw, GPRI+CONST:ro. - adds256 GPRI:rw, GPRI:rw, GPRI:ro. - and GPRI:rw, GPRI+CONST:ro. - asr GPRI:rw, GPRI+CONST:ro. + add XREG:wo, XREG:ro, XREG+CONST:ro. + add XREG:rw, XREG+CONST:ro. + adds2 XREG:rw, XREG+CONST:ro. + adds4 XREG:rw, XREG+CONST:ro. + adds8 XREG:rw, XREG+CONST:ro. + adds16 XREG:rw, XREG+CONST:ro. + adds256 XREG:rw, XREG:rw, XREG:ro. + and XREG:rw, XREG+CONST:ro. + asr XREG:rw, XREG+CONST:ro. beq "b.eq" LABEL:ro. bne "b.ne" LABEL:ro. bgt "b.gt" LABEL:ro. bgt "b.gt" LABEL:ro. bhi "b.hi" LABEL:ro. - b GPRI+LABEL:ro. - bl GPRI+LABEL:ro. - cmp GPRI:ro, GPRI+CONST:ro kills :cc. - divs GPRI:wo, GPRI:ro, GPRI+CONST:ro. - divu GPRI:wo, GPRI:ro, GPRI+CONST:ro. - eor GPRI:rw, GPRI+CONST:ro. - exts GPRI:wo, GPRI:ro, GPRI+CONST:ro. - exts GPRI:rw, GPRI+CONST:ro. - fadd GPRI:wo, GPRI:ro, GPRI:ro. - fcmp GPRI:wo, GPRI:ro, GPRI:ro. - fdiv GPRI:wo, GPRI:ro, GPRI:ro. - fmul GPRI:wo, GPRI:ro, GPRI:ro. - fsub GPRI:wo, GPRI:ro, GPRI:ro. - ld GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. - ldb GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. - ldh GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. - ldhs GPRI:wo, GPROFFSET+GPRGPR+LABEL:ro. - lea GPRI:wo, LABEL:ro. - lsl GPRI:rw, GPRI+CONST:ro. - lsl GPRI:wo, GPRI:ro, GPRI+CONST:ro. - lsr GPRI:rw, GPRI+CONST:ro. - mov GPRI:wo, GPRI+CONST:ro. - mul GPRI:rw, GPRI+CONST:ro. - neg GPRI:rw, GPRI+CONST:ro. - or GPRI:rw, GPRI+CONST:ro. + b XREG+LABEL:ro. + bl XREG+LABEL:ro. + cmp XREG:ro, XREG+CONST:ro kills :cc. + divs XREG:wo, XREG:ro, XREG+CONST:ro. + divu XREG:wo, XREG:ro, XREG+CONST:ro. + eor XREG:rw, XREG+CONST:ro. + exts XREG:wo, XREG:ro, XREG+CONST:ro. + exts XREG:rw, XREG+CONST:ro. + fadd XREG:wo, XREG:ro, XREG:ro. + fcmp XREG:wo, XREG:ro, XREG:ro. + fdiv XREG:wo, XREG:ro, XREG:ro. + fmul XREG:wo, XREG:ro, XREG:ro. + fsub XREG:wo, XREG:ro, XREG:ro. + ld XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldb XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldh XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldhs XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. + lea XREG:wo, LABEL:ro. + lsl XREG:rw, XREG+CONST:ro. + lsl XREG:wo, XREG:ro, XREG+CONST:ro. + lsr XREG:rw, XREG+CONST:ro. + mov XREG:wo, XREG+CONST:ro. + mul XREG:rw, XREG+CONST:ro. + neg XREG:rw, XREG+CONST:ro. + or XREG:rw, XREG+CONST:ro. pop STACKABLE:wo. pop STACKABLE:wo, GPRLR+GPRPC:wo. push STACKABLE:ro. - sub GPRI:wo, GPRI:ro, CONST+GPRI:ro. - sub GPRI:rw, GPRI+CONST:ro. - st GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. - stb GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. - sth GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. - sths GPRI:ro, GPROFFSET+GPRGPR+LABEL:ro. + sub XREG:wo, XREG:ro, CONST+XREG:ro. + sub XREG:rw, XREG+CONST:ro. + st XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. + stb XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. + sth XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. + sths XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. invalid "invalid". @@ -175,6 +183,16 @@ MOVES lea %2, {LABEL, %1.adr} sub %2, GP +/* Sign extension */ + + from SIGNEX8 to GPR + gen + exts %2, %1.reg, {CONST, 8} + + from SIGNEX16 to GPR + gen + exts %2, %1.reg, {CONST, 16} + /* Miscellaneous */ from CONST+LABEL+GPR+GPRE to GPRE @@ -218,13 +236,13 @@ STACKINGRULES sub SP, {CONST, 4} st %1, {GPROFFSET, SP, 0} - from TOKEN to STACK + from OP to STACK uses STACKABLE gen move %1, %a push %a - from TOKEN to STACK + from OP to STACK gen COMMENT("fallback stack") move %1, SCRATCH @@ -239,20 +257,12 @@ COERCIONS uses reusing %1, REG=%1 yields %a - from CONST + from OP uses REG gen - COMMENT("coerce CONST->REG") move %1, %a yields %a - from LABEL - uses REG - gen - COMMENT("coerce LABEL->REG") - move %1, %a - yields %a - from STACK uses STACKABLE gen @@ -335,18 +345,24 @@ PATTERNS /* nop */ pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */ - with REG - uses reusing %1, REG=%1 - gen - exts %a, {CONST, 8} - yields %a - + with GPR + yields {SIGNEX8, %1} + with GPRE + yields {SIGNEX8, %1.reg} + with SIGNEX8 + yields {SIGNEX8, %1.reg} + with SIGNEX16 + yields {SIGNEX8, %1.reg} + pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */ - with REG - uses reusing %1, REG=%1 - gen - exts %a, {CONST, 16} - yields %a + with GPR + yields {SIGNEX16, %1} + with GPRE + yields {SIGNEX16, %1.reg} + with SIGNEX8 + yields {SIGNEX16, %1.reg} + with SIGNEX16 + yields {SIGNEX16, %1.reg} @@ -592,21 +608,21 @@ PATTERNS bl {LABEL, ".los"} pat sti $1==BYTE /* Store byte indirect */ - with LABEL GPRI + with LABEL GPRI+SIGNEX8+SIGNEX16 gen stb %2, %1 - with GPR GPRI + with GPR GPRI+SIGNEX8+SIGNEX16 gen stb %2, {GPRGPR, %1, GP} - with GPRE GPRI + with GPRE GPRI+SIGNEX8+SIGNEX16 gen stb %2, {GPRGPR, %1.reg, GP} pat sti $1==WORD /* Store half-word indirect */ - with LABEL GPRI + with LABEL GPRI+SIGNEX16 gen sth %2, %1 - with GPRI GPRI + with GPRI GPRI+SIGNEX16 uses reusing %1, REG gen add %a, %1, GP From 2c7ee272065d29bb145c5e9c474920b96e6c7918 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 22 May 2013 23:55:23 +0100 Subject: [PATCH 055/231] Double-quads can be loaded and stored (more) correctly. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 53 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 3c96d711c..e5cc0e190 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -386,8 +386,8 @@ PATTERNS pat ldl /* Load double-word from local */ leaving - lol $1 + QUAD*0 lol $1 + QUAD*1 + lol $1 + QUAD*0 pat stl inreg($1)>0 /* Store to local */ with CONST+GPRI @@ -402,8 +402,8 @@ PATTERNS pat sdl /* Store double-word to local */ leaving - stl $1 + QUAD*1 stl $1 + QUAD*0 + stl $1 + QUAD*1 pat lil inreg($1)>0 /* Load from indirected local */ uses REG @@ -496,14 +496,15 @@ PATTERNS dec sti QUAD - pat lde /* Load external */ - uses REG, REG - gen - lea %a, {LABEL, $1} - ld %b, {GPROFFSET, %a, 4} - ld %a, {GPROFFSET, %a, 0} - yields %b %a + pat lde /* Load double external */ + leaving + lae $1 + loi QUAD*2 + pat sde /* Store double external */ + leaving + lae $1 + sti QUAD*2 /* Structures */ @@ -570,7 +571,7 @@ PATTERNS ldhs %a, {GPROFFSET, %a, 0} yields %a - pat loi $1==WORD /* Load short indirect */ + pat loi $1==WORD /* Load short indirect */ with LABEL uses REG gen @@ -583,7 +584,7 @@ PATTERNS ldh %a, {GPROFFSET, %a, 0} yields %a - pat loi $1==QUAD /* Load quad indirect */ + pat loi $1==QUAD /* Load quad indirect */ with LABEL uses REG gen @@ -596,6 +597,22 @@ PATTERNS ld %a, {GPROFFSET, %a, 0} yields %a + pat loi $1==2*QUAD /* Load double-quad indirect */ + with LABEL + uses REG, REG + gen + lea %b, %1 + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + yields %b %a + with GPRI + uses reusing %1, REG, REG + gen + add %b, %1, GP + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + yields %b %a + pat loi !nicesize($1) /* Load arbitrary size */ leaving loc $1 @@ -638,6 +655,20 @@ PATTERNS add %a, %1, GP st %2, {GPROFFSET, %a, 0} + pat sti $1==2*QUAD /* Load double-quad indirect */ + with LABEL GPRI GPRI + uses REG + gen + lea %a, %1 + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + with GPRI GPRI GPRI + uses reusing %1, REG=%1 + gen + add %a, GP + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + pat sti /* Store arbitrary size */ leaving loc $1 From 98a51732abc07a9dcf2748c2b579d0d2e81e4566 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 24 May 2013 17:04:29 +0100 Subject: [PATCH 056/231] Various codegen tweaks. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 223 +++++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 111 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index e5cc0e190..93c787147 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -27,7 +27,6 @@ PROPERTIES GPR /* any GPR */ REG /* any allocatable GPR */ - STACKABLE /* a push/popable register (r0, r6, r16, fp) */ GPR0 GPR1 GPR2 GPR3 GPR4 GPR5 GPR6 GPR7 GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15 @@ -37,13 +36,13 @@ PROPERTIES REGISTERS - R0("r0") : GPR, REG, STACKABLE, GPR0. + R0("r0") : GPR, REG, GPR0. R1("r1") : GPR, REG, GPR1. R2("r2") : GPR, REG, GPR2. R3("r3") : GPR, REG, GPR3. R4("r4") : GPR, REG, GPR4. R5("r5") : GPR, REG, GPR5. - R6("r6") : GPR, REG, STACKABLE, GPR6 regvar. + R6("r6") : GPR, REG, GPR6 regvar. R7("r7") : GPR, REG, GPR7 regvar. R8("r8") : GPR, REG, GPR8 regvar. R9("r9") : GPR, REG, GPR9 regvar. @@ -54,14 +53,16 @@ REGISTERS R14("r14") : GPR, REG, GPR14 regvar. GP("r15") : GPR, GPRGP. + R16("r16") : GPR, GPR16. + R23("r23") : GPR. - FP("fp") : GPR, GPRFP, STACKABLE. + FP("fp") : GPR, GPRFP. SP("sp") : GPR, GPRSP. LR("lr") : GPR, GPRLR. PC("pc") : GPR, GPRPC. /* r26 to r31 are special and the code generator doesn't touch them. */ -#define SCRATCH R23 +#define SCRATCH R16 TOKENS @@ -69,6 +70,7 @@ TOKENS GPROFFSET = { GPR reg; INT off; } 4 off "(" reg ")". GPRGPR = { GPR reg1; GPR reg2; } 4 "(" reg1 "," reg2 ")". + GPRINC = { GPR reg; } 4 "(" reg ")++". /* Primitives */ @@ -119,6 +121,7 @@ INSTRUCTIONS bgt "b.gt" LABEL:ro. bgt "b.gt" LABEL:ro. bhi "b.hi" LABEL:ro. + bset XREG:rw, XREG+CONST:ro. b XREG+LABEL:ro. bl XREG+LABEL:ro. cmp XREG:ro, XREG+CONST:ro kills :cc. @@ -132,6 +135,7 @@ INSTRUCTIONS fdiv XREG:wo, XREG:ro, XREG:ro. fmul XREG:wo, XREG:ro, XREG:ro. fsub XREG:wo, XREG:ro, XREG:ro. + ld XREG:wo, GPRINC:rw. ld XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. ldb XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. ldh XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. @@ -144,9 +148,10 @@ INSTRUCTIONS mul XREG:rw, XREG+CONST:ro. neg XREG:rw, XREG+CONST:ro. or XREG:rw, XREG+CONST:ro. - pop STACKABLE:wo. - pop STACKABLE:wo, GPRLR+GPRPC:wo. - push STACKABLE:ro. + pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo. + pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo. + push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro. + push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro. sub XREG:wo, XREG:ro, CONST+XREG:ro. sub XREG:rw, XREG+CONST:ro. st XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. @@ -155,6 +160,7 @@ INSTRUCTIONS sths XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. invalid "invalid". + comment "!" LABEL:ro. @@ -210,53 +216,35 @@ TESTS STACKINGRULES - from STACKABLE to STACK + from GPR0+GPR6+GPR16 to STACK gen - push %1 + comment {LABEL, "push stackable"} + push %1 - from GPR to STACK - uses STACKABLE + from OP+GPRI to STACK gen - move %1, %a - push %a - - from GPR to STACK - gen - sub SP, SP, {CONST, 4} - st %1, {GPROFFSET, SP, 0} - - from GPRE to STACK - uses STACKABLE - gen - move %1, %a - push %a - - from GPRE to STACK - gen - sub SP, {CONST, 4} - st %1, {GPROFFSET, SP, 0} - - from OP to STACK - uses STACKABLE - gen - move %1, %a - push %a - - from OP to STACK - gen - COMMENT("fallback stack") + comment {LABEL, "push via scratch"} move %1, SCRATCH - sub SP, SP, {CONST, 4} - st SCRATCH, {GPROFFSET, SP, 0} + push SCRATCH + COERCIONS - from GPRE + from GPRI uses reusing %1, REG=%1 yields %a + from GPR + yields {GPRE, %1} + + from OP + uses GPR0 + gen + move %1, %a + yields %a + from OP uses REG gen @@ -264,10 +252,10 @@ COERCIONS yields %a from STACK - uses STACKABLE + uses REG gen - COMMENT("coerce STACK->REG") - pop %a + pop R0 + move R0, %a yields %a @@ -619,10 +607,8 @@ PATTERNS los QUAD pat los /* Load arbitrary size */ - with STACK - kills ALL - gen - bl {LABEL, ".los"} + leaving + cal ".los" pat sti $1==BYTE /* Store byte indirect */ with LABEL GPRI+SIGNEX8+SIGNEX16 @@ -735,6 +721,9 @@ PATTERNS /* Word arithmetic */ + pat loc adi $1==0 /* Add nothing */ + /* nop */ + pat adi $1==QUAD /* Add word (second + top) */ with GPRI+CONST GPRI uses reusing %2, REG=%2 @@ -747,6 +736,9 @@ PATTERNS add %a, %2 yields %a + pat loc sbi $1==0 /* Subtract nothing */ + /* nop */ + pat sbi $1==QUAD /* Subtract word (second - top) */ with GPRI+CONST GPRI uses reusing %2, REG=%2 @@ -886,16 +878,6 @@ PATTERNS yields %a - pat and !defined($1) /* AND set */ - with STACK - gen - bl {LABEL, ".and"} - - pat ior !defined($1) /* OR set */ - with STACK - gen - bl {LABEL, ".ior"} - pat xor $1==4 /* XOR word */ with GPR GPR yields {XOR_RR, %1, %2} @@ -1055,33 +1037,48 @@ PATTERNS /* Sets */ - pat set defined($1) /* Create word with set bit */ + pat set $1==QUAD /* Create quad with one bit set */ + with GPRI + uses reusing %1, REG + gen + bset %a, %1 + yields %a + + pat set defined($1) /* Any other set */ leaving - loc 1 - exg $1 - sli $1 + loc $1 + cal ".set" pat set !defined($1) /* Create structure with set bit (variable) */ - with STACK - gen - bl {LABEL, ".set"} + leaving + cal ".set" pat inn defined($1) /* Test for set bit */ leaving - set QUAD - and QUAD + set $1 + and $1 pat inn !defined($1) /* Test for set bit (variable) */ - with GPR0 STACK - gen - bl {LABEL, ".inn"} - yields R0 + leaving + cal ".inn" - pat ior !defined($1) /* Or two sets */ - with STACK - gen - bl {LABEL, ".ior"} + pat ior !nicesize($1) /* OR set */ + leaving + cal ".ior" + pat ior !defined($1) /* OR set */ + leaving + cal ".ior" + + pat and !nicesize($1) /* AND set */ + leaving + loc $1 + cal ".and" + + pat and !defined($1) /* AND set */ + leaving + cal ".and" + /* Boolean resolutions */ @@ -1171,15 +1168,23 @@ PATTERNS pat ble call anyb("b.le") /* Branch if signed second <= top */ proc cmu_z example cmu zeq - with GPR+CONST GPRI STACK + with GPRI+CONST GPRI STACK gen cmp %2, %1 beq[1] {LABEL, $2} + pat cmu zeq call cmu_z("b.eq") /* Branch if unsigned second == top */ + pat cmu zne call cmu_z("b.ne") /* Branch if unsigned second != top */ pat cmu zgt call cmu_z("b.hi") /* Branch if unsigned second > top */ pat cmu zlt call cmu_z("b.lo") /* Branch if unsigned second < top */ pat cmu zge call cmu_z("b.hs") /* Branch if unsigned second >= top */ pat cmu zle call cmu_z("b.ls") /* Branch if unsigned second <= top */ + pat cmi zeq call cmu_z("b.eq") /* Branch if signed second == top */ + pat cmi zne call cmu_z("b.ne") /* Branch if signed second != top */ + pat cmi zgt call cmu_z("b.gt") /* Branch if signed second > top */ + pat cmi zlt call cmu_z("b.lt") /* Branch if signed second < top */ + pat cmi zge call cmu_z("b.ge") /* Branch if signed second >= top */ + pat cmi zle call cmu_z("b.le") /* Branch if signed second <= top */ proc cmf_z example cmu zeq with GPRI GPRI STACK @@ -1268,6 +1273,9 @@ PATTERNS pat lfr $1==QUAD /* Load function result, word */ yields R0 + pat lfr $1==QUAD*2 /* Load function result, word */ + yields R1 R0 + pat ret $1==0 /* Return from procedure */ gen return @@ -1280,9 +1288,12 @@ PATTERNS return mov SP, FP pop FP, PC - with STACK + + pat ret $1==QUAD*2 /* Return from procedure, word */ + with GPRI GPRI gen - pop R0 + move %1, R0 + move %2, R1 return mov SP, FP pop FP, PC @@ -1335,9 +1346,8 @@ PATTERNS ste ".ignmask" pat trp /* Raise EM trap */ - with GPR0 - gen - bl {LABEL, ".trap"} + leaving + cal ".trap" pat sig /* Set trap handler */ leaving @@ -1467,47 +1477,38 @@ PATTERNS pat dvf call simple_f("fdiv") /* Float divide (second / top) */ pat loc loc cff $1==$2 && $1==QUAD /* Convert float to float */ - leaving + leaving nop pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */ - with GPR0 - gen - bl {LABEL, ".cfi"} - yields R0 + leaving + cal ".cfi" + lfr QUAD pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */ - with GPR0 - gen - bl {LABEL, ".cfu"} - yields R0 + leaving + cal ".cfu" + lfr QUAD pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */ - with GPR0 - gen - bl {LABEL, ".cif"} - yields R0 + leaving + cal ".cif" + lfr QUAD pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */ - with GPR0 - gen - bl {LABEL, ".cuf"} - yields R0 + leaving + cal ".cuf" + lfr QUAD pat fef /* Split float */ - with GPR0 - kills GPR1 - gen - bl {LABEL, ".fef"} - yields R0 R1 + leaving + cal ".cuf" + lfr QUAD*2 pat fif /* Multiply float and split (?) */ - with GPRI GPRI - kills GPR0, GPR1 - gen - fmul R0, %2, %1 - bl {LABEL, ".fef"} - yields R0 R1 + leaving + mlf QUAD + fef pat zrf /* Load a floating zero */ leaving From 98e745d04ce77f7cbdffc860817e6724a049f09f Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 00:33:01 +0100 Subject: [PATCH 057/231] Fix awful bug where uint32_t was sometimes defined as a short. --HG-- branch : dtrg-videocore --- lang/cem/libcc.ansi/headers/stdint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/cem/libcc.ansi/headers/stdint.h b/lang/cem/libcc.ansi/headers/stdint.h index 86fd04815..ce9cf3e38 100644 --- a/lang/cem/libcc.ansi/headers/stdint.h +++ b/lang/cem/libcc.ansi/headers/stdint.h @@ -26,7 +26,7 @@ typedef unsigned short uint16_t; #if _EM_WSIZE == 4 typedef signed int int32_t; -typedef unsigned short uint32_t; +typedef unsigned int uint32_t; #else typedef signed long int32_t; typedef unsigned long uint32_t; From 472f7783422bc372c6f018e5a867b67833f83c44 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 00:33:38 +0100 Subject: [PATCH 058/231] Don't write out constant data as big-endian! Some other cleanups. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach0.c | 1 - mach/vc4/ncg/mach.c | 28 +++++++++------------------- mach/vc4/ncg/table | 6 ++++++ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/mach/vc4/as/mach0.c b/mach/vc4/as/mach0.c index d12994de0..2df70061c 100644 --- a/mach/vc4/as/mach0.c +++ b/mach/vc4/as/mach0.c @@ -30,4 +30,3 @@ typedef unsigned long quad; #undef VALWIDTH #define VALWIDTH 8 -#define FIXUPFLAGS (RELBR | RELWR) diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c index 375d8a6e7..90649b9af 100644 --- a/mach/vc4/ncg/mach.c +++ b/mach/vc4/ncg/mach.c @@ -10,9 +10,7 @@ int framesize; -/* - * machine dependent back end routines for the Zilog Z80. - */ +/* Write out a constant data section. */ con_part(int sz, word w) { @@ -20,19 +18,12 @@ con_part(int sz, word w) part_size++; if (part_size == TEM_WSIZE) part_flush(); - if (sz == 1) { - w &= 0xFF; - w <<= 8*(3-part_size); - part_word |= w; - } else if (sz == 2) { - w &= 0xFFFF; - if (part_size == 0) { - /* Shift 8 for m68k2, 16 otherwise */ - w <<= 4 * TEM_WSIZE; - } + if (sz == 1 || sz == 2) { + w &= (sz == 1 ? 0xFF : 0xFFFF); + w <<= 8 * part_size; part_word |= w; } else { - assert(sz == TEM_WSIZE); + assert(sz == 4); part_word = w; } part_size += sz; @@ -40,7 +31,6 @@ con_part(int sz, word w) con_mult(word sz) { - if (argval != 4) fatal("bad icon/ucon size"); fprintf(codefile,".data4 %s\n", str); @@ -48,9 +38,9 @@ con_mult(word sz) #define CODE_GENERATOR #define IEEEFLOAT -#define FL_MSL_AT_LOW_ADDRESS 1 -#define FL_MSW_AT_LOW_ADDRESS 1 -#define FL_MSB_AT_LOW_ADDRESS 1 +#define FL_MSL_AT_LOW_ADDRESS 0 +#define FL_MSW_AT_LOW_ADDRESS 0 +#define FL_MSB_AT_LOW_ADDRESS 0 #include void prolog(full nlocals) @@ -149,7 +139,7 @@ static void saveloadregs(const char* op) if (minreg != 32) { fprintf(codefile, "! saving registers %d to %d\n", minreg, maxreg); - assert(minreg == 6); + assert((minreg == 6) || (minreg == 16)); fprintf(codefile, "%s r6-r%d\n", op, maxreg); } diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 93c787147..8a23c413e 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -221,6 +221,12 @@ STACKINGRULES comment {LABEL, "push stackable"} push %1 + from OP+GPRI to STACK + uses GPR0 + gen + move %1, %a + push %a + from OP+GPRI to STACK gen comment {LABEL, "push via scratch"} From ec25fec145ab1a0c33e8641af967ed3f8341acfa Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 00:35:29 +0100 Subject: [PATCH 059/231] Build binaries that will run bare metal. Add enough syscall library to init the uart and write text. --HG-- branch : dtrg-videocore rename : plat/rpi/libsys/libsys.h => plat/rpi/libsys/libsysasm.h rename : plat/rpi/libsys/_sys_rawread.s => plat/rpi/libsys/phys_to_user.s rename : plat/rpi/libsys/_sys_rawread.s => plat/rpi/libsys/uart.s rename : plat/rpi/libsys/_sys_rawread.s => plat/rpi/libsys/user_to_phys.s --- plat/rpi/boot.s | 12 ++- plat/rpi/build.mk | 6 +- plat/rpi/include/pi.h | 21 +++++ plat/rpi/libsys/libsysasm.h | 20 +++++ plat/rpi/libsys/phys_to_user.s | 20 +++++ plat/rpi/libsys/uart.s | 135 +++++++++++++++++++++++++++++++++ plat/rpi/libsys/user_to_phys.s | 20 +++++ 7 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 plat/rpi/include/pi.h create mode 100644 plat/rpi/libsys/libsysasm.h create mode 100644 plat/rpi/libsys/phys_to_user.s create mode 100644 plat/rpi/libsys/uart.s create mode 100644 plat/rpi/libsys/user_to_phys.s diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index 43811a6ad..523cf40dc 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -19,14 +19,17 @@ #define STACKSIZE 16*1024 ! MAIN ENTRY POINT -! -! When running as a kernel, our parameters are passed in in r0-r5, so -! the startup sequence mustn't disturb these. begtext: + ! This empty space is required by the boot loader. + + b start + .space 508 ! 512 minus space needed for branch instruction + ! Wipe the bss. This must happen absolutely first, because we need ! to store the old system registers into it. - + +start: lea r6, begbss lea r7, endbss mov r8, #0 @@ -79,6 +82,7 @@ _1: .define __exit __exit: + mov r0, sr ld fp, .returnfp ld sp, .returnsp ld lr, .returnlr diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index 9716eb058..dffe59d9b 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -13,10 +13,15 @@ D := plat/rpi/ platform-headers := \ unistd.h \ + pi.h \ ack/config.h platform-libsys := \ _hol0.s \ + phys_to_user.s \ + user_to_phys.s \ + uart.s \ + write.c \ ifeq (x,y) errno.s \ @@ -26,7 +31,6 @@ ifeq (x,y) creat.c \ close.c \ read.c \ - write.c \ brk.c \ getpid.c \ kill.c \ diff --git a/plat/rpi/include/pi.h b/plat/rpi/include/pi.h new file mode 100644 index 000000000..a69cdd8d9 --- /dev/null +++ b/plat/rpi/include/pi.h @@ -0,0 +1,21 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef PI_H +#define PI_H + +/* Initialise the mini UART (only do this if running on bare metal! */ +extern void init_uart(void); + +/* Converts a pointer from a physical address to a user address. */ +extern void* phys_to_user(void* ptr); + +/* Converts a pointer from a user address to a physical address. */ +extern void* user_to_phys(void* ptr); + +#endif + diff --git a/plat/rpi/libsys/libsysasm.h b/plat/rpi/libsys/libsysasm.h new file mode 100644 index 000000000..16dbbcfba --- /dev/null +++ b/plat/rpi/libsys/libsysasm.h @@ -0,0 +1,20 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef LIBSYSASM_H +#define LIBSYSASM_H + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +#define gp r15 + +#endif diff --git a/plat/rpi/libsys/phys_to_user.s b/plat/rpi/libsys/phys_to_user.s new file mode 100644 index 000000000..649b19b5a --- /dev/null +++ b/plat/rpi/libsys/phys_to_user.s @@ -0,0 +1,20 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +! Transforms a physical address into a user address. + +.define _phys_to_user +_phys_to_user: + ld r0, 0 (sp) + sub r0, gp + b lr + diff --git a/plat/rpi/libsys/uart.s b/plat/rpi/libsys/uart.s new file mode 100644 index 000000000..b12f2efd2 --- /dev/null +++ b/plat/rpi/libsys/uart.s @@ -0,0 +1,135 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +! Because of the low system clock rate, this baud rate might be inaccurate +! So be careful with your serial/terminal, some adjustment may be necessary. +TARGET_BAUD_RATE = 115200 + +! System clock is running directly off the 19.2MHz crystal at initial reset +SYSTEM_CLOCK = 19200000 + +GPFSEL1 = 0x7e200004 +GPSET0 = 0x7e20001C +GPCLR0 = 0x7e200028 +GPPUD = 0x7e200094 +GPPUDCLK0 = 0x7e200098 + +AUX_ENABLES = 0x7e215004 +AUX_MU_IO_REG = 0x7e215040 +AUX_MU_IER_REG = 0x7e215044 +AUX_MU_IIR_REG = 0x7e215048 +AUX_MU_LCR_REG = 0x7e21504C +AUX_MU_MCR_REG = 0x7e215050 +AUX_MU_LSR_REG = 0x7e215054 +AUX_MU_MSR_REG = 0x7e215058 +AUX_MU_SCRATCH = 0x7e21505C +AUX_MU_CNTL_REG = 0x7e215060 +AUX_MU_STAT_REG = 0x7e215064 +AUX_MU_BAUD_REG = 0x7e215068 + +! Sets up the mini UART for use as a console. + +.define _init_uart +_init_uart: + ! Configure TX and RX GPIO pins for Mini Uart function. + mov r1, #GPFSEL1 + ld r0, (r1) + and r0, #~[7<<12] + or r0, #2<<12 + and r0, #~[7<<15] + or r0, #2<<15 + st r0, (r1) + + mov r1, #GPPUD + mov r0, #0 + st r0, (r1) + +delay1: + add r0, #1 + cmp r0, #150 + b.ne delay1 + + mov r1, #GPPUDCLK0 + mov r0, #[1<<14]|[1<<15] + st r0, (r1) + + mov r0, #0 +delay2: + add r0, #1 + cmp r0, #150 + b.ne delay2 + + mov r1, #GPPUDCLK0 + mov r0, #0 + st r0, (r1) + + ! Set up serial port + mov r1, #AUX_ENABLES + mov r0, #1 + st r0, (r1) + + mov r1, #AUX_MU_IER_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_CNTL_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_LCR_REG + mov r0, #3 + st r0, (r1) + + mov r1, #AUX_MU_MCR_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_IER_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_IIR_REG + mov r0, #0xC6 + st r0, (r1) + + mov r1, #AUX_MU_BAUD_REG + mov r0, #[[SYSTEM_CLOCK/[TARGET_BAUD_RATE*8]]-1] + st r0, (r1) + + mov r1, #AUX_MU_LCR_REG + mov r0, #3 + st r0, (r1) + + mov r1, #AUX_MU_CNTL_REG + mov r0, #3 + st r0, (r1) + + b lr + +! Send a single byte. + +.define __sys_rawwrite +__sys_rawwrite: + ld r0, (sp) + mov r1, #AUX_MU_LSR_REG + ! loop until space available in Tx buffer +sendwait: + ld r2, (r1) + and r2, #0x20 + cmp r2, #0x20 + b.ne sendwait + + mov r1, #AUX_MU_IO_REG + stb r0, (r1) + + b lr + diff --git a/plat/rpi/libsys/user_to_phys.s b/plat/rpi/libsys/user_to_phys.s new file mode 100644 index 000000000..7b988fdd6 --- /dev/null +++ b/plat/rpi/libsys/user_to_phys.s @@ -0,0 +1,20 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +! Transforms a user address into a physical address. + +.define _user_to_phys +_user_to_phys: + ld r0, 0 (sp) + add r0, gp + b lr + From 2ee79ab0b251e65f35b9203cc560c37c41bc07fc Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 13:31:01 +0100 Subject: [PATCH 060/231] Encode comparing branch correctly. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach4.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index 4c87209ee..ef0b50082 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -16,10 +16,10 @@ operation | OP_BRANCH CC expr { branch_instr(0, $2, &$3); } | OP_BRANCHLINK CC expr { branch_instr(1, $2, &$3); } - | OP_BRANCH GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, 0, $2, $4, &$6); } - | OP_BRANCH CC GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr($2, 0, $3, $5, &$7); } - | OP_BRANCH GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, 0, $2, $5, &$7); } - | OP_BRANCH CC GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, 0, $3, $6, &$8); } + | OP_BRANCH GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, $2, 0, $4, &$6); } + | OP_BRANCH CC GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr($2, $3, 0, $5, &$7); } + | OP_BRANCH GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, $2, 0, $5, &$7); } + | OP_BRANCH CC GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, $3, 0, $6, &$8); } | OP_ADDCMPB GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr(ALWAYS, $2, $4, $6, &$8); } | OP_ADDCMPB CC GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr($2, $3, $5, $7, &$9); } | OP_ADDCMPB GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, $2, $5, $7, &$9); } From d7efb0a32c17775071bb8f13ac0962353fe22ab8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 13:31:27 +0100 Subject: [PATCH 061/231] Implement .csa. --HG-- branch : dtrg-videocore rename : mach/vc4/libem/dummy.s => mach/vc4/libem/csa.s --- mach/vc4/libem/csa.s | 33 +++++++++++++++++++++++++++++++++ mach/vc4/libem/dummy.s | 14 -------------- mach/vc4/libem/videocore.h | 2 ++ 3 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 mach/vc4/libem/csa.s delete mode 100644 mach/vc4/libem/dummy.s diff --git a/mach/vc4/libem/csa.s b/mach/vc4/libem/csa.s new file mode 100644 index 000000000..1628199a0 --- /dev/null +++ b/mach/vc4/libem/csa.s @@ -0,0 +1,33 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "videocore.h" + +.define .csa +.sect .data +.csa: + ! on entry: + ! r0 = un-fixed-up descriptor + ! r1 = value + add r0, gp + + ld r2, 4 (r0) ! check lower bound + cmp r1, r2 + mov.lo r1, r2 ! r1 = min(r1, r2) + + sub r1, r2 ! adjust value to be 0-based + + ld r2, 8 (r0) ! check upper bound + cmp r1, r2 + mov.hi r1, r2 ! r1 = max(r1, r2) + + add r1, #3 + ld r1, (r0, r1) ! load destination address + add r1, gp + b r1 ! ...and go + diff --git a/mach/vc4/libem/dummy.s b/mach/vc4/libem/dummy.s deleted file mode 100644 index fdbcc4c38..000000000 --- a/mach/vc4/libem/dummy.s +++ /dev/null @@ -1,14 +0,0 @@ -# -/* - * VideoCore IV support library for the ACK - * © 2013 David Given - * This file is redistributable under the terms of the 3-clause BSD license. - * See the file 'Copying' in the root of the distribution for the full text. - */ - -#include "videocore.h" - -.define __dummy -.sect .data -__dummy: - diff --git a/mach/vc4/libem/videocore.h b/mach/vc4/libem/videocore.h index 3e27a7e7b..8ccb981ee 100644 --- a/mach/vc4/libem/videocore.h +++ b/mach/vc4/libem/videocore.h @@ -13,3 +13,5 @@ .sect .data .sect .bss +#define gp r15 + From b6680a48cc6005801cfc0c246a6f1a2f30e43d1a Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 13:31:58 +0100 Subject: [PATCH 062/231] Disable register variables. The code is a bit worse, but having two stackable registers makes things much easier to understand. --HG-- branch : dtrg-videocore --- mach/vc4/build.mk | 2 +- mach/vc4/ncg/table | 69 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/mach/vc4/build.mk b/mach/vc4/build.mk index 06ea3edd4..36b801aff 100644 --- a/mach/vc4/build.mk +++ b/mach/vc4/build.mk @@ -1,5 +1,5 @@ arch-libem-vc4 := \ - dummy.s + csa.s arch-libend-vc4 = \ edata.s \ diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 8a23c413e..bd144a193 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -21,12 +21,19 @@ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ #define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD) +/* #define REGVARS */ + +#ifndef REGVARS +#define regvar +#define return +#endif PROPERTIES GPR /* any GPR */ REG /* any allocatable GPR */ + STACKABLE /* a register than can be used with push/pop */ GPR0 GPR1 GPR2 GPR3 GPR4 GPR5 GPR6 GPR7 GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15 @@ -36,13 +43,17 @@ PROPERTIES REGISTERS - R0("r0") : GPR, REG, GPR0. + R0("r0") : GPR, REG, GPR0, STACKABLE. R1("r1") : GPR, REG, GPR1. R2("r2") : GPR, REG, GPR2. R3("r3") : GPR, REG, GPR3. R4("r4") : GPR, REG, GPR4. R5("r5") : GPR, REG, GPR5. - R6("r6") : GPR, REG, GPR6 regvar. +#if defined REGVARS + R6("r6") : GPR, REG, GPR6, STACKABLE. +#else + R6("r6") : GPR, GPR6. +#endif R7("r7") : GPR, REG, GPR7 regvar. R8("r8") : GPR, REG, GPR8 regvar. R9("r9") : GPR, REG, GPR9 regvar. @@ -62,7 +73,11 @@ REGISTERS PC("pc") : GPR, GPRPC. /* r26 to r31 are special and the code generator doesn't touch them. */ -#define SCRATCH R16 +#if defined REGVARS + #define SCRATCH R16 +#else + #define SCRATCH R6 +#endif TOKENS @@ -227,6 +242,12 @@ STACKINGRULES move %1, %a push %a + from OP to STACK + uses STACKABLE + gen + move %1, %a + push %a + from OP+GPRI to STACK gen comment {LABEL, "push via scratch"} @@ -369,8 +390,10 @@ PATTERNS add %a, {CONST, $1} yields %a +#if defined REGVARS pat lol inreg($1)>0 /* Load from local */ yields {GPRE, regvar($1)} +#endif pat lol /* Load quad from local */ uses REG @@ -383,11 +406,13 @@ PATTERNS lol $1 + QUAD*1 lol $1 + QUAD*0 +#if defined REGVARS pat stl inreg($1)>0 /* Store to local */ with CONST+GPRI kills regvar($1) gen move %1, {GPRE, regvar($1)} +#endif pat stl /* Store to local */ with GPRI @@ -398,12 +423,14 @@ PATTERNS leaving stl $1 + QUAD*0 stl $1 + QUAD*1 - + +#if defined REGVARS pat lil inreg($1)>0 /* Load from indirected local */ uses REG gen ld %a, {GPROFFSET, regvar($1), 0} yields %a +#endif pat lil /* Load from indirected local */ leaving @@ -424,19 +451,20 @@ PATTERNS leaving loc 0 stl $1 - + +#if defined REGVARS pat inl inreg($1)>0 /* Increment local in register */ kills regvar($1) gen add {GPRE, regvar($1)}, {CONST, 1} - + pat inl inreg($1)<=0 /* Increment local */ leaving lol $1 loc 1 adi QUAD stl $1 - + pat del inreg($1)>0 /* Decrement local in register */ kills regvar($1) gen @@ -448,6 +476,21 @@ PATTERNS loc 1 sbi QUAD stl $1 +#else + pat inl /* Increment local in register */ + leaving + lol $1 + loc 1 + adi QUAD + stl $1 + + pat del /* Decrement local in register */ + leaving + lol $1 + loc 1 + sbi QUAD + stl $1 +#endif /* Global variables */ @@ -1288,7 +1331,7 @@ PATTERNS mov SP, FP pop FP, PC - pat ret $1<=QUAD /* Return from procedure, word */ + pat ret $1==QUAD /* Return from procedure, word */ with GPR0 gen return @@ -1316,10 +1359,10 @@ PATTERNS bl {LABEL, "_memmove"} pat csa /* Array-lookup switch */ - with STACK + with GPR0 GPR1 STACK gen - bl {LABEL, ".csa"} - + b {LABEL, ".csa"} + pat csb /* Table-lookup switch */ with STACK gen @@ -1455,6 +1498,10 @@ PATTERNS gen add SP, %1 + pat asp $1==QUAD /* Adjust stack by constant amount */ + gen + pop SCRATCH + pat asp /* Adjust stack by constant amount */ leaving loc $1 From 3b07fee160754546e68c42b0ba69ed41ca91c0e4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 23:26:10 +0100 Subject: [PATCH 063/231] Major bugfix where instructions weren't being shrunk correctly. (Turns out there's built-in support for doing this, which I hadn't found.) --HG-- branch : dtrg-videocore --- mach/vc4/as/mach1.c | 2 +- mach/vc4/as/mach5.c | 219 ++++++++++++++++++-------------------------- 2 files changed, 88 insertions(+), 133 deletions(-) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index de164610e..315468f8e 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -10,7 +10,7 @@ #define ALWAYS 14 extern void alu_instr_reg(quad opcode, int cc, int rd, int ra, int rb); -extern void alu_instr_lit(quad opcode, int cc, int rd, int ra, quad value); +extern void alu_instr_lit(quad opcode, int cc, int rd, int ra, long value); extern void misc_instr_reg(quad opcode, int cc, int rd, int ra, int rb); extern void misc_instr_lit(quad opcode, int cc, int rd, int ra, quad value); extern void branch_instr(int bl, int cc, struct expr_t* expr); diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 53ec3464c..a2227fd5e 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -34,12 +34,12 @@ void alu_instr_reg(quad op, int cc, int rd, int ra, int rb) /* Assemble an ALU instruction where rb is a literal. */ -void alu_instr_lit(quad op, int cc, int rd, int ra, quad value) +void alu_instr_lit(quad op, int cc, int rd, int ra, long value) { /* 16 bit short form? */ - if ((cc == ALWAYS) && !(op & 1) && (value <= 0x1f) && (ra == rd) && - (ra < 0x10)) + if ((cc == ALWAYS) && !(op & 1) && (value >= 0) && (value <= 0x1f) && + (ra == rd) && (ra < 0x10)) { emit2(B16(01100000,00000000) | (op<<8) | (value<<4) | (rd<<0)); return; @@ -47,7 +47,7 @@ void alu_instr_lit(quad op, int cc, int rd, int ra, quad value) /* 32 bit medium form? */ - if (value <= 0x1f) + if ((value >= 0) && (value <= 0x1f)) { emit2(B16(11000000,00000000) | (op<<5) | (rd<<0)); emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | (value<<0)); @@ -99,6 +99,7 @@ void branch_instr(int bl, int cc, struct expr_t* expr) { quad pc = DOTVAL; quad type = expr->typ & S_TYP; + int d; /* Sanity checking. */ @@ -107,71 +108,52 @@ void branch_instr(int bl, int cc, struct expr_t* expr) if (type == S_ABS) serror("can't use absolute addresses here"); - switch (pass) + /* The VC4 branch instructions express distance in 2-byte + * words. */ + + d = (int32_t)expr->val - (int32_t)pc; + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + d /= 2; + + /* If this is a reference to code within this section, and it's + * close enough to the program counter, we can use a short- + * form instruction. */ + + if (small(!bl && (type == DOTTYP) && fitx(d, 7), 2)) + { + emit2(B16(00011000,00000000) | (cc<<7) | (d&0x7f)); + return; + } + + /* Absolute addresses and references to other sections + * need the full 32 bits. */ + + newrelo(expr->typ, RELOVC4|RELPC); + + if (bl) { - case 0: - /* Calculate size of instructions only. For now we just assume - * that they're going to be the maximum size, 32 bits. */ + quad v, hiv, lov; - emit4(0); - break; + if (!fitx(d, 27)) + toobig(); - case 1: - case 2: - { - /* The VC4 branch instructions express distance in 2-byte - * words. */ + v = maskx(d, 27); + hiv = v >> 23; + lov = v & 0x007fffff; + emit2(B16(10010000,10000000) | (lov>>16) | (hiv<<8)); + emit2(B16(00000000,00000000) | (lov&0xffff)); + } + else + { + quad v; - int d = ((int32_t)expr->val - (int32_t)pc) / 2; + if (!fitx(d, 23)) + toobig(); - /* We now know the worst case for the instruction layout. At - * this point we can emit the instructions, which may shrink - * the code. */ - - if (!bl && (type == DOTTYP)) - { - /* This is a reference to code within this section. If it's - * close enough to the program counter, we can use a short- - * form instruction. */ - - if (fitx(d, 7)) - { - emit2(B16(00011000,00000000) | (cc<<7) | (d&0x7f)); - break; - } - } - - /* Absolute addresses and references to other sections - * need the full 32 bits. */ - - newrelo(expr->typ, RELOVC4|RELPC); - - if (bl) - { - quad v, hiv, lov; - - if (!fitx(d, 27)) - toobig(); - - v = maskx(d, 27); - hiv = v >> 23; - lov = v & 0x007fffff; - emit2(B16(10010000,10000000) | (lov>>16) | (hiv<<8)); - emit2(B16(00000000,00000000) | (lov&0xffff)); - } - else - { - quad v; - - if (!fitx(d, 23)) - toobig(); - - v = maskx(d, 23); - emit2(B16(10010000,00000000) | (cc<<8) | (v>>16)); - emit2(B16(00000000,00000000) | (v&0xffff)); - } - break; - } + v = maskx(d, 23); + emit2(B16(10010000,00000000) | (cc<<8) | (v>>16)); + emit2(B16(00000000,00000000) | (v&0xffff)); } } @@ -352,66 +334,45 @@ void mem_postincr_instr(quad opcode, int cc, int rd, int rs) void mem_address_instr(quad opcode, int rd, struct expr_t* expr) { - static const char sizes[] = {4, 2, 1, 2}; + static const char sizes[] = {4, 4, 2, 2, 1, 1, 2, 2}; int size = sizes[opcode]; quad type = expr->typ & S_TYP; + int d, scaledd; /* Sanity checking. */ if (type == S_ABS) serror("can't use absolute addresses here"); - switch (pass) + d = expr->val - DOTVAL; + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + scaledd = d/size; + + /* If this is a reference to an address within this section, and + * it's close enough to the program counter, we can use a + * shorter instruction. */ + + if (small((type==DOTTYP) && fitx(scaledd, 16), 2)) { - case 0: - /* Calculate size of instructions only. For now we just assume - * that they're going to be the maximum size, 48 bits. */ + emit2(B16(10101010,00000000) | (opcode<<5) | (rd<<0)); + emit2(scaledd); + return; + } - emit2(0); - emit4(0); - break; + /* Otherwise we need the full 48 bits. */ - case 1: - case 2: - { - int d = expr->val - DOTVAL; + newrelo(expr->typ, RELOVC4|RELPC); - /* We now know the worst case for the instruction layout. At - * this point we can emit the instructions, which may shrink - * the code. */ + /* VC4 relocations store the PC-relative delta into the + * destination section in the instruction data. The linker will + * massage this, and scale it appropriately. */ - if (type == DOTTYP) - { - int scaledd = d/size; + if (!fitx(d, 27)) + toobig(); - /* This is a reference to an address within this section. If - * it's close enough to the program counter, we can use a - * shorter instruction. */ - - if (fitx(scaledd, 16)) - { - emit2(B16(10101010,00000000) | (opcode<<5) | (rd<<0)); - emit2(scaledd); - return; - } - } - - /* Otherwise we need the full 48 bits. */ - - newrelo(expr->typ, RELOVC4|RELPC); - - /* VC4 relocations store the PC-relative delta into the - * destination section in the instruction data. The linker will - * massage this, and scale it appropriately. */ - - if (!fitx(d, 27)) - toobig(); - - emit2(B16(11100111,00000000) | (opcode<<5) | (rd<<0)); - emit4((31<<27) | maskx(d, 27)); - break; - } - } + emit2(B16(11100111,00000000) | (opcode<<5) | (rd<<0)); + emit4((31<<27) | maskx(d, 27)); } /* Common code for handling addcmp: merge in as much of expr as will fit to @@ -420,33 +381,23 @@ void mem_address_instr(quad opcode, int rd, struct expr_t* expr) static void branch_addcmp_common(quad opcode, int bits, struct expr_t* expr) { quad type = expr->typ & S_TYP; + int d; - switch (pass) - { - case 0: - /* Calculate size of instructions only. */ + if (type != DOTTYP) + serror("can't use this type of branch to jump outside the section"); - emit2(0); - break; + /* The VC4 branch instructions express distance in 2-byte + * words. */ - case 1: - case 2: - { - if (type != DOTTYP) - serror("can't use this type of branch to jump outside the section"); + d = (expr->val - DOTVAL-2 + 4); + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + d /= 2; - /* The VC4 branch instructions express distance in 2-byte - * words. */ + if (!fitx(d, bits)) + serror("target of branch is too far away"); - int d = (expr->val - DOTVAL-2 + 4) / 2; - - if (!fitx(d, bits)) - serror("target of branch is too far away"); - - emit2(opcode | maskx(d, bits)); - break; - } - } + emit2(opcode | maskx(d, bits)); } void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct expr_t* expr) @@ -518,6 +469,10 @@ void lea_address_instr(int rd, struct expr_t* expr) { quad pc = DOTVAL; quad type = expr->typ & S_TYP; + int d = expr->val - pc; + + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; if (type == S_ABS) serror("can't use absolute addresses here"); From 6a672d5e96038863066b5e3fbe7d7889976077b2 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 23:28:47 +0100 Subject: [PATCH 064/231] Heap allocations now works. --HG-- branch : dtrg-videocore --- plat/rpi/build.mk | 16 ++++++++-------- plat/rpi/libsys/brk.c | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index dffe59d9b..a522046f3 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -18,23 +18,23 @@ platform-headers := \ platform-libsys := \ _hol0.s \ + errno.s \ phys_to_user.s \ user_to_phys.s \ uart.s \ - write.c \ - -ifeq (x,y) - errno.s \ - _sys_rawread.s \ - _sys_rawwrite.s \ - open.c \ creat.c \ close.c \ + open.c \ read.c \ + write.c \ + isatty.c \ brk.c \ + +ifeq (x,y) + _sys_rawread.s \ + _sys_rawwrite.s \ getpid.c \ kill.c \ - isatty.c \ lseek.c \ time.c \ signal.c diff --git a/plat/rpi/libsys/brk.c b/plat/rpi/libsys/brk.c index cff32b9a9..2c44347d4 100644 --- a/plat/rpi/libsys/brk.c +++ b/plat/rpi/libsys/brk.c @@ -8,25 +8,25 @@ #include #include #include +#include #define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ -#define STACK_BUFFER 128 /* number of bytes to leave for stack */ +#define STACK_BUFFER 1024 /* number of bytes to leave for stack */ extern char _end[1]; static char* current = _end; +/* Top of heap: we assume that the block of memory the binary is loaded in + * is 256kB long. Because user pointers are always relative to the beginning + * of the block, this makes the end address easy to calculate. */ +static char* max = (char*) (256*1024); + int brk(void* newend) { - /* This variable is used to figure out the current stack pointer, - * by taking its address. */ - char dummy; - char* p = newend; - - if ((p > (&dummy - STACK_BUFFER)) || - (p < _end)) + if ((newend >= (void*)max) || (newend < (void*)_end)) return -1; - - current = p; + + current = newend; return 0; } From 8c21a2ef9b09a040e633bb5e55c97969e1e3dcd7 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 23:58:35 +0100 Subject: [PATCH 065/231] Stop fighting the terrible code and remove the regvar support --- it didn't help much and was a pain. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/mach.c | 105 -------------- mach/vc4/ncg/table | 346 +++++++++++++++++--------------------------- 2 files changed, 130 insertions(+), 321 deletions(-) diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c index 90649b9af..124e8a965 100644 --- a/mach/vc4/ncg/mach.c +++ b/mach/vc4/ncg/mach.c @@ -84,108 +84,3 @@ char *segname[] = { ".sect .bss" }; -#ifdef REGVARS - -static int savedregsi[32]; -static int numsaved; - -/* Initialise regvar system for one function. */ - -void i_regsave(void) -{ - int i; - - fprintf(codefile, "! i_regsave()\n"); - for (i=0; i<32; i++) - savedregsi[i] = INT_MAX; - numsaved = 0; -} - -/* Mark a register as being saved. */ - -void regsave(const char* regname, full offset, int size) -{ - int regnum = atoi(regname+1); - savedregsi[regnum] = offset; - numsaved++; - - fprintf(codefile, "! %d is saved in %s\n", offset, regname); -#if 0 - fprintf(codefile, "stwu %s, -4(sp)\n", regname); - if (offset >= 0) - fprintf(codefile, "lwz %s, %d(fp)\n", regname, offset); -#endif -} - -/* Finish saving ragisters. */ - -static void saveloadregs(const char* op) -{ - int minreg = 32; - int maxreg = -1; - int i; - - for (i=0; i<32; i++) - { - if (savedregsi[i] != INT_MAX) - { - if (i < minreg) - minreg = i; - if (i > maxreg) - maxreg = i; - } - } - - if (minreg != 32) - { - fprintf(codefile, "! saving registers %d to %d\n", minreg, maxreg); - assert((minreg == 6) || (minreg == 16)); - - fprintf(codefile, "%s r6-r%d\n", op, maxreg); - } -} - -f_regsave() -{ - int i; - fprintf(codefile, "! f_regsave()\n"); - saveloadregs("push"); - - for (i=0; i<32; i++) - { - int o = savedregsi[i]; - if ((o != INT_MAX) && (o > 0)) - fprintf(codefile, "ld r%d, %d (fp)\n", i, savedregsi[i]); - } -} - -/* Restore all saved registers. */ - -regreturn() -{ - fprintf(codefile, "! regreturn()\n"); - saveloadregs("pop"); -} - -/* Calculate the score of a given register. */ - -int regscore(full offset, int size, int type, int frequency, int totype) -{ - int score; - - fprintf(codefile, "! regscore(%ld, %d, %d, %d, %d)\n", offset, size, type, frequency, totype); - - if (size != 4) - return -1; - - /* Per use: 6 bytes (on average) - * Overhead in prologue: 4 bytes, plus 4 if a parameter - * Overhead in epilogue: 0 bytes - */ - - score = frequency*6 - 4 - ((offset>=0) ? 4 : 0); - fprintf(codefile, "! local at offset %d has regvar score %d\n", offset, score); - return score; -} - -#endif diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index bd144a193..523879cfe 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -21,12 +21,6 @@ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ #define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD) -/* #define REGVARS */ - -#ifndef REGVARS -#define regvar -#define return -#endif PROPERTIES @@ -49,19 +43,15 @@ REGISTERS R3("r3") : GPR, REG, GPR3. R4("r4") : GPR, REG, GPR4. R5("r5") : GPR, REG, GPR5. -#if defined REGVARS - R6("r6") : GPR, REG, GPR6, STACKABLE. -#else R6("r6") : GPR, GPR6. -#endif - R7("r7") : GPR, REG, GPR7 regvar. - R8("r8") : GPR, REG, GPR8 regvar. - R9("r9") : GPR, REG, GPR9 regvar. - R10("r10") : GPR, REG, GPR10 regvar. - R11("r11") : GPR, REG, GPR11 regvar. - R12("r12") : GPR, REG, GPR12 regvar. - R13("r13") : GPR, REG, GPR13 regvar. - R14("r14") : GPR, REG, GPR14 regvar. + R7("r7") : GPR, REG, GPR7. + R8("r8") : GPR, REG, GPR8. + R9("r9") : GPR, REG, GPR9. + R10("r10") : GPR, REG, GPR10. + R11("r11") : GPR, REG, GPR11. + R12("r12") : GPR, REG, GPR12. + R13("r13") : GPR, REG, GPR13. + R14("r14") : GPR, REG, GPR14. GP("r15") : GPR, GPRGP. R16("r16") : GPR, GPR16. @@ -73,11 +63,7 @@ REGISTERS PC("pc") : GPR, GPRPC. /* r26 to r31 are special and the code generator doesn't touch them. */ -#if defined REGVARS - #define SCRATCH R16 -#else #define SCRATCH R6 -#endif TOKENS @@ -92,10 +78,6 @@ TOKENS LABEL = { ADDR adr; } 4 adr. CONST = { INT val; } 4 "#" val. -/* Allows us to use regvar() to refer to registers */ - - GPRE = { GPR reg; } 4 reg. - /* Sign extended values. */ /* The size refers to the *source*. */ @@ -114,65 +96,64 @@ TOKENS SETS TOKEN = LABEL + CONST. - GPRI = GPR + GPRE. OP = TOKEN + SIGNEX8 + SIGNEX16. - XREG = GPRI + SIGNEX8 + SIGNEX16. + ANY = GPR + OP. INSTRUCTIONS - add XREG:wo, XREG:ro, XREG+CONST:ro. - add XREG:rw, XREG+CONST:ro. - adds2 XREG:rw, XREG+CONST:ro. - adds4 XREG:rw, XREG+CONST:ro. - adds8 XREG:rw, XREG+CONST:ro. - adds16 XREG:rw, XREG+CONST:ro. - adds256 XREG:rw, XREG:rw, XREG:ro. - and XREG:rw, XREG+CONST:ro. - asr XREG:rw, XREG+CONST:ro. + add GPR:wo, GPR:ro, GPR+CONST:ro. + add GPR:rw, GPR+CONST:ro. + adds2 GPR:rw, GPR+CONST:ro. + adds4 GPR:rw, GPR+CONST:ro. + adds8 GPR:rw, GPR+CONST:ro. + adds16 GPR:rw, GPR+CONST:ro. + adds256 GPR:rw, GPR:rw, GPR:ro. + and GPR:rw, GPR+CONST:ro. + asr GPR:rw, GPR+CONST:ro. beq "b.eq" LABEL:ro. bne "b.ne" LABEL:ro. bgt "b.gt" LABEL:ro. bgt "b.gt" LABEL:ro. bhi "b.hi" LABEL:ro. - bset XREG:rw, XREG+CONST:ro. - b XREG+LABEL:ro. - bl XREG+LABEL:ro. - cmp XREG:ro, XREG+CONST:ro kills :cc. - divs XREG:wo, XREG:ro, XREG+CONST:ro. - divu XREG:wo, XREG:ro, XREG+CONST:ro. - eor XREG:rw, XREG+CONST:ro. - exts XREG:wo, XREG:ro, XREG+CONST:ro. - exts XREG:rw, XREG+CONST:ro. - fadd XREG:wo, XREG:ro, XREG:ro. - fcmp XREG:wo, XREG:ro, XREG:ro. - fdiv XREG:wo, XREG:ro, XREG:ro. - fmul XREG:wo, XREG:ro, XREG:ro. - fsub XREG:wo, XREG:ro, XREG:ro. - ld XREG:wo, GPRINC:rw. - ld XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. - ldb XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. - ldh XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. - ldhs XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. - lea XREG:wo, LABEL:ro. - lsl XREG:rw, XREG+CONST:ro. - lsl XREG:wo, XREG:ro, XREG+CONST:ro. - lsr XREG:rw, XREG+CONST:ro. - mov XREG:wo, XREG+CONST:ro. - mul XREG:rw, XREG+CONST:ro. - neg XREG:rw, XREG+CONST:ro. - or XREG:rw, XREG+CONST:ro. + bset GPR:rw, GPR+CONST:ro. + b GPR+LABEL:ro. + bl GPR+LABEL:ro. + cmp GPR:ro, GPR+CONST:ro kills :cc. + divs GPR:wo, GPR:ro, GPR+CONST:ro. + divu GPR:wo, GPR:ro, GPR+CONST:ro. + eor GPR:rw, GPR+CONST:ro. + exts GPR:wo, GPR:ro, GPR+CONST:ro. + exts GPR:rw, GPR+CONST:ro. + fadd GPR:wo, GPR:ro, GPR:ro. + fcmp GPR:wo, GPR:ro, GPR:ro. + fdiv GPR:wo, GPR:ro, GPR:ro. + fmul GPR:wo, GPR:ro, GPR:ro. + fsub GPR:wo, GPR:ro, GPR:ro. + ld GPR:wo, GPRINC:rw. + ld GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldb GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldh GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldhs GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + lea GPR:wo, LABEL:ro. + lsl GPR:rw, GPR+CONST:ro. + lsl GPR:wo, GPR:ro, GPR+CONST:ro. + lsr GPR:rw, GPR+CONST:ro. + mov GPR:wo, GPR+CONST:ro. + mul GPR:rw, GPR+CONST:ro. + neg GPR:rw, GPR+CONST:ro. + or GPR:rw, GPR+CONST:ro. pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo. pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo. push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro. push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro. - sub XREG:wo, XREG:ro, CONST+XREG:ro. - sub XREG:rw, XREG+CONST:ro. - st XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. - stb XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. - sth XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. - sths XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. + sub GPR:wo, GPR:ro, CONST+GPR:ro. + sub GPR:rw, GPR+CONST:ro. + st GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + stb GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + sth GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + sths GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. invalid "invalid". comment "!" LABEL:ro. @@ -186,13 +167,6 @@ MOVES COMMENT("mov GPR->GPR") mov %2, %1 -/* GPRE exists solely to allow us to use regvar() (which can only be used in - an expression) as a register constant. */ - - from GPRE to GPR - gen - mov %2, %1 - /* Constants */ from CONST to GPR @@ -216,9 +190,9 @@ MOVES /* Miscellaneous */ - from CONST+LABEL+GPR+GPRE to GPRE + from CONST+LABEL+GPR to GPR gen - move %1, %2.reg + move %1, %2 TESTS @@ -236,7 +210,7 @@ STACKINGRULES comment {LABEL, "push stackable"} push %1 - from OP+GPRI to STACK + from OP+GPR to STACK uses GPR0 gen move %1, %a @@ -248,7 +222,7 @@ STACKINGRULES move %1, %a push %a - from OP+GPRI to STACK + from OP+GPR to STACK gen comment {LABEL, "push via scratch"} move %1, SCRATCH @@ -259,19 +233,6 @@ STACKINGRULES COERCIONS - from GPRI - uses reusing %1, REG=%1 - yields %a - - from GPR - yields {GPRE, %1} - - from OP - uses GPR0 - gen - move %1, %a - yields %a - from OP uses REG gen @@ -281,8 +242,8 @@ COERCIONS from STACK uses REG gen - pop R0 - move R0, %a + pop SCRATCH + move SCRATCH, %a yields %a @@ -295,15 +256,15 @@ PATTERNS yields {CONST, $1} pat dup $1<=QUAD /* Duplicate word on top of stack */ - with GPRI + with ANY yields %1 %1 pat dup $1<=(2*QUAD) /* Duplicate word pair on top of stack */ - with GPRI GPRI + with ANY ANY yields %1 %2 %1 %2 pat exg $1==QUAD /* Exchange top two words on stack */ - with GPRI GPRI + with ANY ANY yields %1 %2 pat stl lol $1==$2 /* Store then load local */ @@ -362,8 +323,6 @@ PATTERNS pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */ with GPR yields {SIGNEX8, %1} - with GPRE - yields {SIGNEX8, %1.reg} with SIGNEX8 yields {SIGNEX8, %1.reg} with SIGNEX16 @@ -372,8 +331,6 @@ PATTERNS pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */ with GPR yields {SIGNEX16, %1} - with GPRE - yields {SIGNEX16, %1.reg} with SIGNEX8 yields {SIGNEX16, %1.reg} with SIGNEX16 @@ -390,11 +347,6 @@ PATTERNS add %a, {CONST, $1} yields %a -#if defined REGVARS - pat lol inreg($1)>0 /* Load from local */ - yields {GPRE, regvar($1)} -#endif - pat lol /* Load quad from local */ uses REG gen @@ -406,16 +358,8 @@ PATTERNS lol $1 + QUAD*1 lol $1 + QUAD*0 -#if defined REGVARS - pat stl inreg($1)>0 /* Store to local */ - with CONST+GPRI - kills regvar($1) - gen - move %1, {GPRE, regvar($1)} -#endif - pat stl /* Store to local */ - with GPRI + with GPR gen st %1, {GPROFFSET, FP, $1} @@ -424,14 +368,6 @@ PATTERNS stl $1 + QUAD*0 stl $1 + QUAD*1 -#if defined REGVARS - pat lil inreg($1)>0 /* Load from indirected local */ - uses REG - gen - ld %a, {GPROFFSET, regvar($1), 0} - yields %a -#endif - pat lil /* Load from indirected local */ leaving lol $1 @@ -452,31 +388,6 @@ PATTERNS loc 0 stl $1 -#if defined REGVARS - pat inl inreg($1)>0 /* Increment local in register */ - kills regvar($1) - gen - add {GPRE, regvar($1)}, {CONST, 1} - - pat inl inreg($1)<=0 /* Increment local */ - leaving - lol $1 - loc 1 - adi QUAD - stl $1 - - pat del inreg($1)>0 /* Decrement local in register */ - kills regvar($1) - gen - sub {GPRE, regvar($1)}, {CONST, 1} - - pat del inreg($1)<=0 /* Decrement local */ - leaving - lol $1 - loc 1 - sbi QUAD - stl $1 -#else pat inl /* Increment local in register */ leaving lol $1 @@ -490,7 +401,7 @@ PATTERNS loc 1 sbi QUAD stl $1 -#endif + /* Global variables */ @@ -552,7 +463,7 @@ PATTERNS loi QUAD pat ldf /* Load double offsetted */ - with GPRI + with GPR uses reusing %1, REG=%1, REG gen add %a, GP @@ -566,7 +477,7 @@ PATTERNS sti QUAD pat sdf /* Store double offsetted */ - with GPRI GPRI GPRI + with GPR GPR GPR uses reusing %3, REG=%3 gen add %a, GP @@ -589,11 +500,6 @@ PATTERNS gen ldb %a, {GPRGPR, %1, GP} yields %a - with GPRE - uses reusing %1.reg, REG - gen - ldb %a, {GPRGPR, %1.reg, GP} - yields %a pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load short indirect and sign extend */ with LABEL @@ -601,7 +507,7 @@ PATTERNS gen ldhs %a, %1 yields %a - with GPRI + with GPR uses reusing %1, REG gen add %a, %1, GP @@ -614,7 +520,7 @@ PATTERNS gen ldh %a, %1 yields %a - with GPRI + with GPR uses reusing %1, REG gen add %a, %1, GP @@ -627,7 +533,7 @@ PATTERNS gen ld %a, %1 yields %a - with GPRI + with GPR uses reusing %1, REG gen add %a, %1, GP @@ -642,7 +548,7 @@ PATTERNS ld %a, {GPROFFSET, %b, 0} ld %b, {GPROFFSET, %b, 4} yields %b %a - with GPRI + with GPR uses reusing %1, REG, REG gen add %b, %1, GP @@ -660,44 +566,55 @@ PATTERNS cal ".los" pat sti $1==BYTE /* Store byte indirect */ - with LABEL GPRI+SIGNEX8+SIGNEX16 + with LABEL GPR gen stb %2, %1 - with GPR GPRI+SIGNEX8+SIGNEX16 + with LABEL SIGNEX8+SIGNEX16 + gen + stb %2.reg, %1 + with GPR GPR gen stb %2, {GPRGPR, %1, GP} - with GPRE GPRI+SIGNEX8+SIGNEX16 + with GPR SIGNEX8+SIGNEX16 gen - stb %2, {GPRGPR, %1.reg, GP} + stb %2.reg, {GPRGPR, %1, GP} pat sti $1==WORD /* Store half-word indirect */ - with LABEL GPRI+SIGNEX16 + with LABEL GPR gen sth %2, %1 - with GPRI GPRI+SIGNEX16 + with LABEL SIGNEX16 + gen + sth %2.reg, %1 + with GPR GPR uses reusing %1, REG gen add %a, %1, GP sth %2, {GPROFFSET, %a, 0} + with GPR SIGNEX16 + uses reusing %1, REG + gen + add %a, %1, GP + sth %2.reg, {GPROFFSET, %a, 0} pat sti $1==QUAD /* Store quad indirect */ - with LABEL GPRI + with LABEL GPR gen st %2, %1 - with GPRI GPRI + with GPR GPR uses reusing %1, REG gen add %a, %1, GP st %2, {GPROFFSET, %a, 0} pat sti $1==2*QUAD /* Load double-quad indirect */ - with LABEL GPRI GPRI + with LABEL GPR GPR uses REG gen lea %a, %1 st %2, {GPROFFSET, %a, 0} st %3, {GPROFFSET, %a, 4} - with GPRI GPRI GPRI + with GPR GPR GPR uses reusing %1, REG=%1 gen add %a, GP @@ -774,12 +691,12 @@ PATTERNS /* nop */ pat adi $1==QUAD /* Add word (second + top) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen add %a, %1 yields %a - with GPRI GPRI+CONST + with GPR GPR+CONST uses reusing %1, REG=%1 gen add %a, %2 @@ -789,19 +706,19 @@ PATTERNS /* nop */ pat sbi $1==QUAD /* Subtract word (second - top) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen sub %a, %1 yields %a pat mli $1==QUAD /* Multiply word (second * top) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen mul %a, %1 yields %a - with GPRI GPRI+CONST + with GPR GPR+CONST uses reusing %1, REG=%1 gen mul %a, %2 @@ -812,21 +729,21 @@ PATTERNS mli $1 pat dvi $1==QUAD /* Divide word (second / top) */ - with GPRI GPRI + with GPR GPR uses reusing %2, REG gen divs %a, %2, %1 yields %a pat dvu $1==QUAD /* Divide unsigned word (second / top) */ - with GPRI GPRI + with GPR GPR uses reusing %2, REG gen divu %a, %2, %1 yields %a pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ - with GPRI GPRI + with GPR GPR uses REG gen divu %a, %2, %1 @@ -835,7 +752,7 @@ PATTERNS yields %a pat rmi $1==QUAD /* Remainder signed word (second % top) */ - with GPRI GPRI + with GPR GPR uses REG gen divs %a, %2, %1 @@ -844,64 +761,64 @@ PATTERNS yields %a pat ngi $1==QUAD /* Negate word */ - with GPRI + with GPR uses reusing %1, REG=%1 gen neg %a, %a yields %a pat and $1==QUAD /* AND word */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen and %a, %1 yields %a - with GPRI GPRI+CONST + with GPR GPR+CONST uses reusing %1, REG=%1 gen and %a, %2 yields %a pat ior $1==QUAD /* OR word */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen or %a, %1 yields %a - with GPRI GPRI+CONST + with GPR GPR+CONST uses reusing %1, REG=%1 gen or %a, %2 yields %a pat xor $1==QUAD /* XOR word */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen eor %a, %1 yields %a - with GPRI GPRI+CONST + with GPR GPR+CONST uses reusing %1, REG=%1 gen eor %a, %2 yields %a pat dvi $1==QUAD /* Divide word (second / top) */ - with GPRI GPRI + with GPR GPR uses reusing %2, REG gen divs %a, %2, %1 yields %a pat dvu $1==QUAD /* Divide unsigned word (second / top) */ - with GPRI GPRI + with GPR GPR uses reusing %2, REG gen divu %a, %2, %1 yields %a pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ - with GPRI GPRI + with GPR GPR uses REG gen divu %a, %2, %1 @@ -910,7 +827,7 @@ PATTERNS yields %a pat rmi $1==QUAD /* Remainder signed word (second % top) */ - with GPRI GPRI + with GPR GPR uses REG gen divs %a, %2, %1 @@ -966,21 +883,21 @@ PATTERNS #endif pat sli $1==4 /* Shift left (second << top) */ - with CONST+GPRI GPRI + with CONST+GPR GPR uses reusing %2, REG=%2 gen lsl %a, %1 yields %a pat sri $1==4 /* Shift right signed (second >> top) */ - with CONST+GPRI GPRI + with CONST+GPR GPR uses reusing %2, REG=%2 gen asr %2, %1 yields %a pat sru $1==4 /* Shift right unsigned (second >> top) */ - with CONST+GPRI GPRI + with CONST+GPR GPR uses reusing %2, REG=%2 gen lsr %2, %1 @@ -991,35 +908,35 @@ PATTERNS /* Special arithmetic */ pat loc sli adi $1==1 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<1) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen adds2 %a, %1 yields %a pat loc sli adi $1==2 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<2) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen adds4 %a, %1 yields %a pat loc sli adi $1==3 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<3) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen adds8 %a, %1 yields %a pat loc sli adi $1==4 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<4) */ - with GPRI+CONST GPRI + with GPR+CONST GPR uses reusing %2, REG=%2 gen adds16 %a, %1 yields %a pat loc sli adi $1==8 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<8) */ - with GPRI GPRI + with GPR GPR uses reusing %2, REG gen adds256 %a, %2, %1 @@ -1087,7 +1004,7 @@ PATTERNS /* Sets */ pat set $1==QUAD /* Create quad with one bit set */ - with GPRI + with GPR uses reusing %1, REG gen bset %a, %1 @@ -1133,7 +1050,7 @@ PATTERNS /* Boolean resolutions */ proc cm_t example teq - with GPRI GPRI + with GPR GPR uses reusing %1, REG gen cmp %1, %2 @@ -1155,7 +1072,7 @@ PATTERNS pat cmi tge call cm_t("add.ge") /* top = signed (second >= top) */ proc cmf_t example teq - with GPRI GPRI + with GPR GPR uses reusing %1, REG gen fcmp %a, %1, %2 @@ -1171,7 +1088,7 @@ PATTERNS pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */ proc fallback_t example teq - with GPRI + with GPR uses reusing %1, REG gen cmp %1, {CONST, 0} @@ -1191,7 +1108,7 @@ PATTERNS /* Simple branches */ proc anyz example zeq - with GPRI STACK + with GPR STACK gen cmp %1, {CONST, 0} beq[1] {LABEL, $1} @@ -1204,7 +1121,7 @@ PATTERNS pat zle call anyz("b.le") /* Branch if signed top <= 0 */ proc anyb example beq - with GPRI+CONST GPRI STACK + with GPR+CONST GPR STACK gen cmp %2, %1 beq[1] {LABEL, $1} @@ -1217,7 +1134,7 @@ PATTERNS pat ble call anyb("b.le") /* Branch if signed second <= top */ proc cmu_z example cmu zeq - with GPRI+CONST GPRI STACK + with GPR+CONST GPR STACK gen cmp %2, %1 beq[1] {LABEL, $2} @@ -1236,7 +1153,7 @@ PATTERNS pat cmi zle call cmu_z("b.le") /* Branch if signed second <= top */ proc cmf_z example cmu zeq - with GPRI GPRI STACK + with GPR GPR STACK gen fcmp %2, %2, %1 beq[1] {LABEL, $2} @@ -1327,23 +1244,20 @@ PATTERNS pat ret $1==0 /* Return from procedure */ gen - return mov SP, FP pop FP, PC pat ret $1==QUAD /* Return from procedure, word */ with GPR0 gen - return mov SP, FP pop FP, PC pat ret $1==QUAD*2 /* Return from procedure, word */ - with GPRI GPRI + with GPR GPR gen move %1, R0 move %2, R1 - return mov SP, FP pop FP, PC @@ -1480,12 +1394,12 @@ PATTERNS loe ".reghp" pat str $1==0 /* Store FP */ - with GPRI + with GPR gen sub FP, %1, GP pat str $1==1 /* Store SP */ - with GPRI + with GPR gen sub SP, %1, GP @@ -1494,7 +1408,7 @@ PATTERNS ste ".reghp" pat ass /* Adjust stack by variable amount */ - with CONST+GPRI + with CONST+GPR gen add SP, %1 @@ -1518,7 +1432,7 @@ PATTERNS sbf QUAD proc simple_f example adf - with GPRI GPRI + with GPR GPR uses reusing %1, REG gen fadd[1] %a, %2, %1 From e299cc3bcf7710f190b1695c82cde71453323ecc Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 25 May 2013 23:59:31 +0100 Subject: [PATCH 066/231] stdio (output only) now works. --HG-- branch : dtrg-videocore --- plat/rpi/build.mk | 5 ----- plat/rpi/libsys/_sys_rawread.s | 26 -------------------------- plat/rpi/libsys/_sys_rawwrite.s | 32 -------------------------------- 3 files changed, 63 deletions(-) delete mode 100644 plat/rpi/libsys/_sys_rawread.s delete mode 100644 plat/rpi/libsys/_sys_rawwrite.s diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index a522046f3..eb1cd036f 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -29,16 +29,11 @@ platform-libsys := \ write.c \ isatty.c \ brk.c \ - -ifeq (x,y) - _sys_rawread.s \ - _sys_rawwrite.s \ getpid.c \ kill.c \ lseek.c \ time.c \ signal.c -endif $(eval $(call build-platform)) diff --git a/plat/rpi/libsys/_sys_rawread.s b/plat/rpi/libsys/_sys_rawread.s deleted file mode 100644 index 02edba21a..000000000 --- a/plat/rpi/libsys/_sys_rawread.s +++ /dev/null @@ -1,26 +0,0 @@ -# -/* - * Raspberry Pi support library for the ACK - * © 2013 David Given - * This file is redistributable under the terms of the 3-clause BSD license. - * See the file 'Copying' in the root of the distribution for the full text. - */ - -! Declare segments (the order is important). - -.sect .text -.sect .rom -.sect .data -.sect .bss - -.sect .text - -! Reads a single byte. - -.define __sys_rawread -__sys_rawread: - xorb ah, ah - int 0x16 - xorb ah, ah - ret - \ No newline at end of file diff --git a/plat/rpi/libsys/_sys_rawwrite.s b/plat/rpi/libsys/_sys_rawwrite.s deleted file mode 100644 index a424574d7..000000000 --- a/plat/rpi/libsys/_sys_rawwrite.s +++ /dev/null @@ -1,32 +0,0 @@ -# -/* - * Raspberry Pi support library for the ACK - * © 2013 David Given - * This file is redistributable under the terms of the 3-clause BSD license. - * See the file 'Copying' in the root of the distribution for the full text. - */ - -! Declare segments (the order is important). - -.sect .text -.sect .rom -.sect .data -.sect .bss - -.sect .text - -! Writes a single byte to the console. - -.define __sys_rawwrite -.extern __sys_rawwrite - -__sys_rawwrite: - push bp - mov bp, sp - - movb al, 4(bp) - movb ah, 0x0E - mov bx, 0x0007 - int 0x10 - jmp .cret - \ No newline at end of file From 308d41e0834d4caafa57bc2ad8e82499876b84c8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 00:22:08 +0100 Subject: [PATCH 067/231] Added triple-quad load and store (used by the signal stuff). --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 47 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 523879cfe..41a2b2ae2 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -72,6 +72,7 @@ TOKENS GPROFFSET = { GPR reg; INT off; } 4 off "(" reg ")". GPRGPR = { GPR reg1; GPR reg2; } 4 "(" reg1 "," reg2 ")". GPRINC = { GPR reg; } 4 "(" reg ")++". + ADDCMPB_LL = { GPR rd; INT val; INT vs; ADDR dest; } 4 rd ",#" val ",#" vs "," dest. /* Primitives */ @@ -105,6 +106,7 @@ INSTRUCTIONS add GPR:wo, GPR:ro, GPR+CONST:ro. add GPR:rw, GPR+CONST:ro. + addcmpbge "addcmpb.ge" ADDCMPB_LL:rw. adds2 GPR:rw, GPR+CONST:ro. adds4 GPR:rw, GPR+CONST:ro. adds8 GPR:rw, GPR+CONST:ro. @@ -150,6 +152,7 @@ INSTRUCTIONS push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro. sub GPR:wo, GPR:ro, CONST+GPR:ro. sub GPR:rw, GPR+CONST:ro. + st GPR:ro, GPRINC:rw. st GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. stb GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. sth GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. @@ -556,7 +559,25 @@ PATTERNS ld %b, {GPROFFSET, %b, 4} yields %b %a - pat loi !nicesize($1) /* Load arbitrary size */ + pat loi $1==3*QUAD /* Load triple-quad indirect */ + with LABEL + uses REG, REG, REG + gen + lea %b, %1 + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + ld %b, {GPROFFSET, %b, 8} + yields %c %b %a + with GPR + uses reusing %1, REG, REG, REG + gen + add %b, %1, GP + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + ld %c, {GPROFFSET, %b, 8} + yields %c %b %a + + pat loi /* Load arbitrary size */ leaving loc $1 los QUAD @@ -621,16 +642,30 @@ PATTERNS st %2, {GPROFFSET, %a, 0} st %3, {GPROFFSET, %a, 4} + pat sti $1==3*QUAD /* Load triple-quad indirect */ + with LABEL GPR GPR GPR + uses REG + gen + lea %a, %1 + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + st %4, {GPROFFSET, %a, 8} + with GPR GPR GPR GPR + uses reusing %1, REG=%1 + gen + add %a, GP + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + st %4, {GPROFFSET, %a, 8} + pat sti /* Store arbitrary size */ leaving loc $1 sts QUAD - pat sts /* Load arbitrary size */ - with STACK - kills ALL - gen - bl {LABEL, ".sts"} + pat sts /* Store arbitrary size */ + leaving + cal ".sts" From bd9497be77424c6d00054a3f4a74cfb936817252 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 00:22:39 +0100 Subject: [PATCH 068/231] Renamed the pi-specific functions to be a bit cleaner. --HG-- branch : dtrg-videocore rename : plat/rpi/libsys/phys_to_user.s => plat/rpi/libsys/pi_phys_to_user.s rename : plat/rpi/libsys/uart.s => plat/rpi/libsys/pi_uart.s rename : plat/rpi/libsys/user_to_phys.s => plat/rpi/libsys/pi_user_to_phys.s --- plat/rpi/build.mk | 6 +++--- plat/rpi/include/pi.h | 6 +++--- plat/rpi/libsys/{phys_to_user.s => pi_phys_to_user.s} | 4 ++-- plat/rpi/libsys/{uart.s => pi_uart.s} | 4 ++-- plat/rpi/libsys/{user_to_phys.s => pi_user_to_phys.s} | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) rename plat/rpi/libsys/{phys_to_user.s => pi_phys_to_user.s} (89%) rename plat/rpi/libsys/{uart.s => pi_uart.s} (98%) rename plat/rpi/libsys/{user_to_phys.s => pi_user_to_phys.s} (89%) diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index eb1cd036f..7bbf007e4 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -19,9 +19,9 @@ platform-headers := \ platform-libsys := \ _hol0.s \ errno.s \ - phys_to_user.s \ - user_to_phys.s \ - uart.s \ + pi_phys_to_user.s \ + pi_user_to_phys.s \ + pi_uart.s \ creat.c \ close.c \ open.c \ diff --git a/plat/rpi/include/pi.h b/plat/rpi/include/pi.h index a69cdd8d9..b5c54289e 100644 --- a/plat/rpi/include/pi.h +++ b/plat/rpi/include/pi.h @@ -9,13 +9,13 @@ #define PI_H /* Initialise the mini UART (only do this if running on bare metal! */ -extern void init_uart(void); +extern void pi_init_uart(void); /* Converts a pointer from a physical address to a user address. */ -extern void* phys_to_user(void* ptr); +extern void* pi_phys_to_user(void* ptr); /* Converts a pointer from a user address to a physical address. */ -extern void* user_to_phys(void* ptr); +extern void* pi_user_to_phys(void* ptr); #endif diff --git a/plat/rpi/libsys/phys_to_user.s b/plat/rpi/libsys/pi_phys_to_user.s similarity index 89% rename from plat/rpi/libsys/phys_to_user.s rename to plat/rpi/libsys/pi_phys_to_user.s index 649b19b5a..d67cac895 100644 --- a/plat/rpi/libsys/phys_to_user.s +++ b/plat/rpi/libsys/pi_phys_to_user.s @@ -12,8 +12,8 @@ ! Transforms a physical address into a user address. -.define _phys_to_user -_phys_to_user: +.define _pi_phys_to_user +_pi_phys_to_user: ld r0, 0 (sp) sub r0, gp b lr diff --git a/plat/rpi/libsys/uart.s b/plat/rpi/libsys/pi_uart.s similarity index 98% rename from plat/rpi/libsys/uart.s rename to plat/rpi/libsys/pi_uart.s index b12f2efd2..caa9f6f89 100644 --- a/plat/rpi/libsys/uart.s +++ b/plat/rpi/libsys/pi_uart.s @@ -38,8 +38,8 @@ AUX_MU_BAUD_REG = 0x7e215068 ! Sets up the mini UART for use as a console. -.define _init_uart -_init_uart: +.define _pi_init_uart +_pi_init_uart: ! Configure TX and RX GPIO pins for Mini Uart function. mov r1, #GPFSEL1 ld r0, (r1) diff --git a/plat/rpi/libsys/user_to_phys.s b/plat/rpi/libsys/pi_user_to_phys.s similarity index 89% rename from plat/rpi/libsys/user_to_phys.s rename to plat/rpi/libsys/pi_user_to_phys.s index 7b988fdd6..dd62c069a 100644 --- a/plat/rpi/libsys/user_to_phys.s +++ b/plat/rpi/libsys/pi_user_to_phys.s @@ -12,8 +12,8 @@ ! Transforms a user address into a physical address. -.define _user_to_phys -_user_to_phys: +.define _pi_user_to_phys +_pi_user_to_phys: ld r0, 0 (sp) add r0, gp b lr From 6284512b374873bb014dda26006d8aaf3770aa9d Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 00:35:15 +0100 Subject: [PATCH 069/231] Fix erroneous section check (symbols may not have a defined section in pass 1). --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index a2227fd5e..de2bda2ad 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -383,7 +383,7 @@ static void branch_addcmp_common(quad opcode, int bits, struct expr_t* expr) quad type = expr->typ & S_TYP; int d; - if (type != DOTTYP) + if ((pass>0) && (type != DOTTYP)) serror("can't use this type of branch to jump outside the section"); /* The VC4 branch instructions express distance in 2-byte From 510888e6d50e1939017eb374bed16898c2caeb5d Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 13:06:25 +0100 Subject: [PATCH 070/231] .csb now works. --HG-- branch : dtrg-videocore rename : mach/vc4/libem/csa.s => mach/vc4/libem/csb.s --- mach/vc4/build.mk | 3 ++- mach/vc4/libem/csb.s | 33 +++++++++++++++++++++++++++++++++ mach/vc4/ncg/table | 20 +++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 mach/vc4/libem/csb.s diff --git a/mach/vc4/build.mk b/mach/vc4/build.mk index 36b801aff..b7ca860d8 100644 --- a/mach/vc4/build.mk +++ b/mach/vc4/build.mk @@ -1,5 +1,6 @@ arch-libem-vc4 := \ - csa.s + csa.s \ + csb.s arch-libend-vc4 = \ edata.s \ diff --git a/mach/vc4/libem/csb.s b/mach/vc4/libem/csb.s new file mode 100644 index 000000000..7ed74c39f --- /dev/null +++ b/mach/vc4/libem/csb.s @@ -0,0 +1,33 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "videocore.h" + +.define .csb +.sect .data +.csb: + ! on entry: + ! r0 = un-fixed-up descriptor + ! r1 = value + add r0, gp ! r0 = fixed up descriptor + + adds8 r2, r0, #1 ! r2 = moving pointer + ld r3, 4 (r0) ! r3 = count + adds8 r3, r0, r3 ! r3 = end ptr + +loop: + ld r4, (r2)++ + b.eq r4, r1, matched ! r2 points at matching addr + addcmpb.le r2, #4, r3, loop +notmatched: + mov r2, r0 ! r2 points at default jump +matched: + ld r2, (r2) ! load destination address + add r2, gp ! fix up r2 + b r2 ! ...and go + diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 41a2b2ae2..56a3d871a 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -1309,11 +1309,13 @@ PATTERNS pat csa /* Array-lookup switch */ with GPR0 GPR1 STACK + kills ALL gen b {LABEL, ".csa"} pat csb /* Table-lookup switch */ - with STACK + with GPR0 GPR1 STACK + kills ALL gen bl {LABEL, ".csb"} @@ -1484,28 +1486,44 @@ PATTERNS pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */ leaving + loc 0 +#if 0 cal ".cfi" lfr QUAD +#endif pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */ leaving + loc 0 +#if 0 cal ".cfu" lfr QUAD +#endif pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */ leaving + loc 0 +#if 0 cal ".cif" lfr QUAD +#endif pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */ leaving + loc 0 +#if 0 cal ".cuf" lfr QUAD +#endif pat fef /* Split float */ leaving + loc 0 + loc 0 +#if 0 cal ".cuf" lfr QUAD*2 +#endif pat fif /* Multiply float and split (?) */ leaving From 366cd10194f6fd8f4d887723d124de33ecd61818 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 13:13:58 +0100 Subject: [PATCH 071/231] Remainders are calculated correctly. printf now works. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 56a3d871a..18e7bc3f7 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -150,6 +150,7 @@ INSTRUCTIONS pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo. push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro. push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro. + rsb GPR:rw, GPR+CONST:ro. sub GPR:wo, GPR:ro, CONST+GPR:ro. sub GPR:rw, GPR+CONST:ro. st GPR:ro, GPRINC:rw. @@ -783,7 +784,7 @@ PATTERNS gen divu %a, %2, %1 mul %a, %1 - sub %a, %2 + rsb %a, %2 yields %a pat rmi $1==QUAD /* Remainder signed word (second % top) */ @@ -792,7 +793,7 @@ PATTERNS gen divs %a, %2, %1 mul %a, %1 - sub %a, %2 + rsb %a, %2 yields %a pat ngi $1==QUAD /* Negate word */ From e01f00e3205360b767a56aea03bf51b74c0a00d4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 18:58:54 +0100 Subject: [PATCH 072/231] Allow reading from the mini UART. Add a check to not touch the UART unless it's been initialised (in case of accidents when running in kernel mode). --HG-- branch : dtrg-videocore --- plat/rpi/libsys/pi_uart.s | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plat/rpi/libsys/pi_uart.s b/plat/rpi/libsys/pi_uart.s index caa9f6f89..0cfed4a67 100644 --- a/plat/rpi/libsys/pi_uart.s +++ b/plat/rpi/libsys/pi_uart.s @@ -113,12 +113,19 @@ delay2: mov r0, #3 st r0, (r1) + ! Mark the uart as being initialised. + mov r0, #1 + stb r0, __uart_status + b lr ! Send a single byte. .define __sys_rawwrite __sys_rawwrite: + ldb r0, __uart_status + b.eq r0, #0, 1f + ld r0, (sp) mov r1, #AUX_MU_LSR_REG ! loop until space available in Tx buffer @@ -131,5 +138,27 @@ sendwait: mov r1, #AUX_MU_IO_REG stb r0, (r1) +1: b lr +! Receive a single byte. + +.define __sys_rawread +__sys_rawread: + ldb r0, __uart_status + b.eq r0, #0, 1b + + ! receive 1 byte (returned in r0) + mov r1, #AUX_MU_LSR_REG + mov r2, #AUX_MU_IO_REG + ! loop until char available +recvwait: + ld r3, (r1) + and r3, #0x1 + b.ne r3, #0x1, recvwait + + ldb r0, (r2) +1: + b lr + +.comm __uart_status, 1 From ef25c53c9c03528b26b89c588849b1cc22729f6e Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 18:59:19 +0100 Subject: [PATCH 073/231] Fix bug in ine/dee. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 18e7bc3f7..ae44c026b 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -434,19 +434,15 @@ PATTERNS pat ine /* Increment external */ leaving - lae $1 - dup QUAD - loi QUAD + loe $1 inc - sti QUAD + ste $1 pat dee /* Decrement external */ leaving - lae $1 - dup QUAD - loi QUAD + loe $1 dec - sti QUAD + ste $1 pat lde /* Load double external */ leaving From 38e4726f5c63b6b7c41262b0c94ea826d4cdd3ff Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 19:41:37 +0100 Subject: [PATCH 074/231] Boot code now works properly in both kernel and bare-metal mode. --HG-- branch : dtrg-videocore --- plat/rpi/boot.s | 56 +++++++++++++++++++------------------------ plat/rpi/include/pi.h | 15 ++++++++++++ 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index 523cf40dc..71081d2cb 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -23,13 +23,15 @@ begtext: ! This empty space is required by the boot loader. - b start - .space 508 ! 512 minus space needed for branch instruction +kernel_start: + ! When running as a kernel, we need to preserve all registers. We save + ! them onto the default stack. + push r0-r24 + b baremetal_start + .space 506 ! first 512 bytes are ignored by the boot loader +baremetal_start: + ! Wipe the bss (including the new stack). - ! Wipe the bss. This must happen absolutely first, because we need - ! to store the old system registers into it. - -start: lea r6, begbss lea r7, endbss mov r8, #0 @@ -37,35 +39,23 @@ _1: stb r8, (r6) addcmpb.lt r6, #1, r7, _1 - ! Set up system registers. + ! Save system registers. - lea gp, begtext st fp, .returnfp st sp, .returnsp st lr, .returnlr - ! Set up the new stack and save the kernel parameters to it. + lea gp, begtext - lea sp, .stack + STACKSIZE - 6*4 - - sub r0, gp ! pointer - st r0, 0 (sp) - - sub r1, gp ! pointer - st r1, 4 (sp) - - sub r2, gp ! pointer - st r2, 8 (sp) - - sub r3, gp ! pointer - st r3, 12 (sp) - - ! r4-r5 are not pointers and don't need adjusting - st r4, 16 (sp) - st r5, 20 (sp) + ! Save the kernel parameters. + sub r0, gp ! fix up pointer + sub r1, gp ! fix up pointer + sub r2, gp ! fix up pointer + sub r3, gp ! fix up pointer + push r0-r5 sub r0, sp, gp - st r0, _gpu_parameters + st r0, _pi_kernel_parameters ! Push standard parameters onto the stack and go. @@ -82,10 +72,16 @@ _1: .define __exit __exit: + ! It only makes sense to get here if we're in kernel mode. If we're in + ! bare-metal mode, we'll just crash, but that's fine. + + st r0, _pi_kernel_parameters ! save return value mov r0, sr ld fp, .returnfp ld sp, .returnsp ld lr, .returnlr + pop r0-r24 + ld r0, _pi_kernel_parameters ! restore return value b lr ! Define symbols at the beginning of our various segments, so that we can find @@ -110,10 +106,8 @@ __exit: .comm .returnsp, 4 .comm .returnlr, 4 -! User pointer to the GPU kernel parameter block. - -.define _gpu_parameters -.comm _gpu_parameters, 4 +.define _pi_kernel_parameters +.comm _pi_kernel_parameters, 4 ! User stack. diff --git a/plat/rpi/include/pi.h b/plat/rpi/include/pi.h index b5c54289e..656543bde 100644 --- a/plat/rpi/include/pi.h +++ b/plat/rpi/include/pi.h @@ -8,6 +8,21 @@ #ifndef PI_H #define PI_H +/* When running in kernel mode, this structure gets the incoming parameters. + * In bare metal mode, it's gibberish. */ + +struct pi_kernel_parameters +{ + int r5; + int r4; + void* r3; + void* r2; + void* r1; + void* r0; +}; + +extern struct pi_kernel_parameters* pi_kernel_parameters; + /* Initialise the mini UART (only do this if running on bare metal! */ extern void pi_init_uart(void); From ae993b1eb24ca62e102db7c787fb4536bddb47e7 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 19:54:22 +0100 Subject: [PATCH 075/231] Add a crude README. --HG-- branch : dtrg-videocore --- plat/rpi/README | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 plat/rpi/README diff --git a/plat/rpi/README b/plat/rpi/README new file mode 100644 index 000000000..166d2148b --- /dev/null +++ b/plat/rpi/README @@ -0,0 +1,66 @@ +VideoCore IV support in the ACK +=============================== + +This is a fairly crude port of the ACK to produce VideoCore IV machine +code, suitable for use on the Raspberry Pi. It produces terrible but +working code. The resulting binaries can be used either bare metal or +loaded as a GPU kernel and executed using a modified mailbox.c (see below). + +As much of the standard C library as is relevant works; if +you're running in bare-metal mode, you can hook stdin/stdout up to the +mini UART. (Obviously, in kernel mode you can't.) + +Important note! The malloc heap expects your program to be loaded into a +chunk of memory that's 256kB large. You must make sure that this is the case, +or Bad Stuff will happen. + +Output binaries are fully PIC and can be loaded anywhere (this is one of the +things that makes the code so terrible). You must use the pi_user_to_phys() +and pi_phys_to_user() to translate pointers from physical to user and vice +versa. If you don't, Bad Stuff will happen. + + + +Bare metal mode +--------------- + +To run a binary bare metal, compile it: + + ack -mrpi -O program.c -o bootcode.bin + +...and copy the bootcode.bin file to the root of an SD card. Boot the Pi. +Your program will run. + +To use the UART, #include and call pi_init_uart() at the top of your +program. This will set it up and connect it to stdin/stdout. It's 115200 8n1. + + + +Kernel mode +----------- + +This will require some hacking at your end. + +Go here, and follow the instructions. + +https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Kernels-under-Linux + +Now compile your program: + + ack -mrpi -O program.c -o alpha.bin + +MAKE SURE YOU AREN'T USING ANY MEMORY ALLOCATION. Copy the alpha.bin onto +the Pi, and run it with mailbox.c. + +To get data in and out, #include and look at the pi_kernel_parameters +variable. It's a structure that is initialised with the data that's passed in +from mailbox.c (currently four pointers and two integers). + +If you want to use malloc() and friends, you'll need to hack mailbox.c so +that the buffer containing the code is at least 256kB, or you're likely to +corrupt the VideoCore's workspace and crash it. + + +David Given +2013-05-26 + From 1f36370d87ff7aaac15b1a040ad202f2a3a86a4c Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 26 May 2013 22:54:53 +0100 Subject: [PATCH 076/231] Implement nop (the C compiler sometimes generates this!). --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index ae44c026b..3c28651df 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -256,6 +256,8 @@ PATTERNS /* Intrinsics */ + pat nop /* Does nothing */ + pat loc /* Load constant */ yields {CONST, $1} From e0c121d6e6d015806df2a95d53f36dd7b1834766 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 14:11:04 +0100 Subject: [PATCH 077/231] Use relocation enumerations rather than hard-coded values for relocation types (these were causing problems due to the enumeration values having changed). --- mach/proto/as/comm3.c | 6 +++--- mach/proto/as/comm7.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mach/proto/as/comm3.c b/mach/proto/as/comm3.c index a5490e249..f35d1818c 100644 --- a/mach/proto/as/comm3.c +++ b/mach/proto/as/comm3.c @@ -26,9 +26,9 @@ item_t keytab[] = { 0, EXTERN, 0, ".define", 0, EXTERN, 0, ".extern", 0, DOT, 0, ".", - 0, DATA, 1, ".data1", - 0, DATA, 2, ".data2", - 0, DATA, 4, ".data4", + 0, DATA, RELO1, ".data1", + 0, DATA, RELO2, ".data2", + 0, DATA, RELO4, ".data4", 0, ASCII, 0, ".ascii", 0, ASCII, 1, ".asciz", 0, ALIGN, 0, ".align", diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index fbbe42392..d0a147bdb 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -293,16 +293,16 @@ valu_t val; int n; { switch (n) { - case 1: + case RELO1: emit1((int)val); break; - case 2: + case RELO2: #ifdef BYTES_REVERSED emit1(((int)val>>8)); emit1((int)val); #else emit1((int)val); emit1(((int)val>>8)); #endif break; - case 4: + case RELO4: #ifdef WORDS_REVERSED emit2((int)(val>>16)); emit2((int)(val)); #else From 6fff2d45fece78dad2389b443cde3e0d24e44fac Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 14:48:51 +0100 Subject: [PATCH 078/231] Attempt to fix 64-bitness error in ashow. Deprecate the structure format macros in h/out.h because they make no sense on 64-bit platforms. --- h/out.h | 8 +++++++- util/amisc/ashow.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/h/out.h b/h/out.h index 122296f8e..0dffd2908 100644 --- a/h/out.h +++ b/h/out.h @@ -100,13 +100,19 @@ struct outname { /* * structure format strings */ +#if 0 +/* The following strings only make sense on 32-bit platforms, so we're going + * to try and deprecate them. */ #define SF_HEAD "22222244" #define SF_SECT "44444" #define SF_RELO "1124" #define SF_NAME "4224" +#endif /* - * structure sizes (bytes in file; add digits in SF_*) + * structure sizes on disk (bytes in file; add digits in SF_*) + * Note! These are NOT the sizes in memory (64-bit architectures will have + * a different layout). */ #define SZ_HEAD 20 #define SZ_SECT 20 diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index 5f22827ee..809937d71 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -70,7 +70,7 @@ show(headp) /* * We get all struct outname's and the strings in core first. */ - name = (struct outname *) myalloc(headp->oh_nname * SZ_NAME); + name = (struct outname *) myalloc(headp->oh_nname * sizeof(struct outname)); string = myalloc((unsigned) headp->oh_nchar); rd_name(name, headp->oh_nname); for (np = &name[0]; np < &name[headp->oh_nname]; np++) { From 69953d016c2898c166d02db2a6e54cc896633bb0 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 17:10:58 +0100 Subject: [PATCH 079/231] Add support for snprintf and vsnprintf. Try and make the return value a bit more standards-compliant. --HG-- branch : dtrg-videocore --- lang/cem/libcc.ansi/build.mk | 2 ++ lang/cem/libcc.ansi/headers/stdio.h | 2 ++ lang/cem/libcc.ansi/stdio/doprnt.c | 42 +++++++++++++-------------- lang/cem/libcc.ansi/stdio/snprintf.c | 31 ++++++++++++++++++++ lang/cem/libcc.ansi/stdio/vsnprintf.c | 26 +++++++++++++++++ 5 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 lang/cem/libcc.ansi/stdio/snprintf.c create mode 100644 lang/cem/libcc.ansi/stdio/vsnprintf.c diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index a9434ceb4..6140b4b50 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -133,9 +133,11 @@ $(call ackfile, lang/cem/libcc.ansi/stdio/perror.c) $(call ackfile, lang/cem/libcc.ansi/stdio/fprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/printf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/sprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/snprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vfprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vsprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/vsnprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/doprnt.c) $(call ackfile, lang/cem/libcc.ansi/stdio/icompute.c) $(call ackfile, lang/cem/libcc.ansi/stdio/fscanf.c) diff --git a/lang/cem/libcc.ansi/headers/stdio.h b/lang/cem/libcc.ansi/headers/stdio.h index 4c5a42a08..52f286f20 100644 --- a/lang/cem/libcc.ansi/headers/stdio.h +++ b/lang/cem/libcc.ansi/headers/stdio.h @@ -72,10 +72,12 @@ extern int fscanf(FILE *_stream, const char *_format, ...); extern int printf(const char *_format, ...); extern int scanf(const char *_format, ...); extern int sprintf(char *_s, const char *_format, ...); +extern int snprintf(char *_s, size_t _len, const char *_format, ...); extern int sscanf(const char *_s, const char *_format, ...); extern int vfprintf(FILE *_stream, const char *_format, char *_arg); extern int vprintf(const char *_format, char *_arg); extern int vsprintf(char *_s, const char *_format, char *_arg); +extern int vsnprintf(char *_s, size_t _len, const char *_format, char *_arg); extern int fgetc(FILE *_stream); extern char *fgets(char *_s, int _n, FILE *_stream); extern int fputc(int _c, FILE *_stream); diff --git a/lang/cem/libcc.ansi/stdio/doprnt.c b/lang/cem/libcc.ansi/stdio/doprnt.c index 81714de47..395c45704 100644 --- a/lang/cem/libcc.ansi/stdio/doprnt.c +++ b/lang/cem/libcc.ansi/stdio/doprnt.c @@ -38,6 +38,16 @@ gnum(register const char *f, int *ip, va_list *app) #define set_pointer(flags) /* compilation might continue */ #endif +#define PUTC(c) \ + do { \ + int i = putc(c, stream); \ + if (i == EOF) \ + { \ + if (ferror(stream)) \ + return -1; \ + } \ + } while (0) + /* print an ordinal number */ static char * o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed) @@ -125,13 +135,10 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (c != '%') { #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; - nrchars++; + PUTC('\r'); } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; } @@ -181,13 +188,11 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) default: #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC('\r'); nrchars++; } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; case 'n': @@ -280,31 +285,26 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (between_fill) { if (flags & FL_SIGNEDCONV) { j--; nrchars++; - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } else { j -= 2; nrchars += 2; - if ((putc(*s1++, stream) == EOF) - || (putc(*s1++, stream) == EOF)) - return nrchars ? -nrchars : -1; - } + PUTC(*s1++); + PUTC(*s1++); + } } do { - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } while (--i); } nrchars += j; while (--j >= 0) { - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } if (i > 0) nrchars += i; while (--i >= 0) - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } return nrchars; } diff --git a/lang/cem/libcc.ansi/stdio/snprintf.c b/lang/cem/libcc.ansi/stdio/snprintf.c new file mode 100644 index 000000000..7d428118c --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/snprintf.c @@ -0,0 +1,31 @@ +/* + * sprintf - print formatted output on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +snprintf(char * s, size_t len, const char *format, ...) +{ + va_list ap; + int retval; + FILE tmp_stream; + + va_start(ap, format); + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, ap, &tmp_stream); + putc('\0',&tmp_stream); + + va_end(ap); + + return retval; +} diff --git a/lang/cem/libcc.ansi/stdio/vsnprintf.c b/lang/cem/libcc.ansi/stdio/vsnprintf.c new file mode 100644 index 000000000..870e23df2 --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/vsnprintf.c @@ -0,0 +1,26 @@ +/* + * vsprintf - print formatted output without ellipsis on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +vsnprintf(char *s, size_t len, const char *format, va_list arg) +{ + int retval; + FILE tmp_stream; + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, arg, &tmp_stream); + putc('\0',&tmp_stream); + + return retval; +} From f522aba4afdcde0c8a1c8c9e8ee7f5e46f1999c8 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 17:10:58 +0100 Subject: [PATCH 080/231] Add support for snprintf and vsnprintf. Try and make the return value a bit more standards-compliant. --HG-- extra : source : a19eb606871f918e3d9e195b487b5276855edc8e --- lang/cem/libcc.ansi/build.mk | 2 ++ lang/cem/libcc.ansi/headers/stdio.h | 2 ++ lang/cem/libcc.ansi/stdio/doprnt.c | 42 +++++++++++++-------------- lang/cem/libcc.ansi/stdio/snprintf.c | 31 ++++++++++++++++++++ lang/cem/libcc.ansi/stdio/vsnprintf.c | 26 +++++++++++++++++ 5 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 lang/cem/libcc.ansi/stdio/snprintf.c create mode 100644 lang/cem/libcc.ansi/stdio/vsnprintf.c diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index a9434ceb4..6140b4b50 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -133,9 +133,11 @@ $(call ackfile, lang/cem/libcc.ansi/stdio/perror.c) $(call ackfile, lang/cem/libcc.ansi/stdio/fprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/printf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/sprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/snprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vfprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vsprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/vsnprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/doprnt.c) $(call ackfile, lang/cem/libcc.ansi/stdio/icompute.c) $(call ackfile, lang/cem/libcc.ansi/stdio/fscanf.c) diff --git a/lang/cem/libcc.ansi/headers/stdio.h b/lang/cem/libcc.ansi/headers/stdio.h index 4c5a42a08..52f286f20 100644 --- a/lang/cem/libcc.ansi/headers/stdio.h +++ b/lang/cem/libcc.ansi/headers/stdio.h @@ -72,10 +72,12 @@ extern int fscanf(FILE *_stream, const char *_format, ...); extern int printf(const char *_format, ...); extern int scanf(const char *_format, ...); extern int sprintf(char *_s, const char *_format, ...); +extern int snprintf(char *_s, size_t _len, const char *_format, ...); extern int sscanf(const char *_s, const char *_format, ...); extern int vfprintf(FILE *_stream, const char *_format, char *_arg); extern int vprintf(const char *_format, char *_arg); extern int vsprintf(char *_s, const char *_format, char *_arg); +extern int vsnprintf(char *_s, size_t _len, const char *_format, char *_arg); extern int fgetc(FILE *_stream); extern char *fgets(char *_s, int _n, FILE *_stream); extern int fputc(int _c, FILE *_stream); diff --git a/lang/cem/libcc.ansi/stdio/doprnt.c b/lang/cem/libcc.ansi/stdio/doprnt.c index 81714de47..395c45704 100644 --- a/lang/cem/libcc.ansi/stdio/doprnt.c +++ b/lang/cem/libcc.ansi/stdio/doprnt.c @@ -38,6 +38,16 @@ gnum(register const char *f, int *ip, va_list *app) #define set_pointer(flags) /* compilation might continue */ #endif +#define PUTC(c) \ + do { \ + int i = putc(c, stream); \ + if (i == EOF) \ + { \ + if (ferror(stream)) \ + return -1; \ + } \ + } while (0) + /* print an ordinal number */ static char * o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed) @@ -125,13 +135,10 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (c != '%') { #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; - nrchars++; + PUTC('\r'); } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; } @@ -181,13 +188,11 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) default: #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC('\r'); nrchars++; } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; case 'n': @@ -280,31 +285,26 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (between_fill) { if (flags & FL_SIGNEDCONV) { j--; nrchars++; - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } else { j -= 2; nrchars += 2; - if ((putc(*s1++, stream) == EOF) - || (putc(*s1++, stream) == EOF)) - return nrchars ? -nrchars : -1; - } + PUTC(*s1++); + PUTC(*s1++); + } } do { - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } while (--i); } nrchars += j; while (--j >= 0) { - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } if (i > 0) nrchars += i; while (--i >= 0) - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } return nrchars; } diff --git a/lang/cem/libcc.ansi/stdio/snprintf.c b/lang/cem/libcc.ansi/stdio/snprintf.c new file mode 100644 index 000000000..7d428118c --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/snprintf.c @@ -0,0 +1,31 @@ +/* + * sprintf - print formatted output on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +snprintf(char * s, size_t len, const char *format, ...) +{ + va_list ap; + int retval; + FILE tmp_stream; + + va_start(ap, format); + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, ap, &tmp_stream); + putc('\0',&tmp_stream); + + va_end(ap); + + return retval; +} diff --git a/lang/cem/libcc.ansi/stdio/vsnprintf.c b/lang/cem/libcc.ansi/stdio/vsnprintf.c new file mode 100644 index 000000000..870e23df2 --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/vsnprintf.c @@ -0,0 +1,26 @@ +/* + * vsprintf - print formatted output without ellipsis on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +vsnprintf(char *s, size_t len, const char *format, va_list arg) +{ + int retval; + FILE tmp_stream; + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, arg, &tmp_stream); + putc('\0',&tmp_stream); + + return retval; +} From 074b42aa9791f5dd15b32d0b124cb216aac3a555 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 21:41:58 +0100 Subject: [PATCH 081/231] Add some missing libc functions: setenv, unsetenv, strdup. --HG-- branch : dtrg-videocore rename : lang/cem/libcc.ansi/stdlib/getenv.c => lang/cem/libcc.ansi/stdlib/setenv.c rename : lang/cem/libcc.ansi/string/strlen.c => lang/cem/libcc.ansi/string/strdup.c --- lang/cem/libcc.ansi/build.mk | 2 + lang/cem/libcc.ansi/headers/stdlib.h | 3 + lang/cem/libcc.ansi/headers/string.h | 3 + lang/cem/libcc.ansi/misc/putenv.c | 22 ++++--- lang/cem/libcc.ansi/stdlib/getenv.c | 56 +++++++++++++----- lang/cem/libcc.ansi/stdlib/setenv.c | 87 ++++++++++++++++++++++++++++ lang/cem/libcc.ansi/string/strdup.c | 17 ++++++ 7 files changed, 162 insertions(+), 28 deletions(-) create mode 100644 lang/cem/libcc.ansi/stdlib/setenv.c create mode 100644 lang/cem/libcc.ansi/string/strdup.c diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 6140b4b50..5987de9e3 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -186,6 +186,7 @@ $(call ackfile, lang/cem/libcc.ansi/stdlib/div.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/atexit.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/exit.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/getenv.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/setenv.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/labs.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/ldiv.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/mblen.c) @@ -238,6 +239,7 @@ $(call ackfile, lang/cem/libcc.ansi/string/strpbrk.c) $(call ackfile, lang/cem/libcc.ansi/string/strspn.c) $(call ackfile, lang/cem/libcc.ansi/string/strncmp.c) $(call ackfile, lang/cem/libcc.ansi/string/strxfrm.c) +$(call ackfile, lang/cem/libcc.ansi/string/strdup.c) # Time diff --git a/lang/cem/libcc.ansi/headers/stdlib.h b/lang/cem/libcc.ansi/headers/stdlib.h index c14db91a8..64a6de16c 100644 --- a/lang/cem/libcc.ansi/headers/stdlib.h +++ b/lang/cem/libcc.ansi/headers/stdlib.h @@ -36,6 +36,9 @@ extern int atexit(void (*_func)(void)); extern void exit(int _status); extern void _Exit(int _status); extern char* getenv(const char *_name); +extern int setenv(const char *_name, const char *_value, int _overwrite); +extern int unsetenv(const char *_name); +extern int putenv(char *_string); extern int system(const char *_string); extern void* bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, diff --git a/lang/cem/libcc.ansi/headers/string.h b/lang/cem/libcc.ansi/headers/string.h index b9d50617b..eef924f74 100644 --- a/lang/cem/libcc.ansi/headers/string.h +++ b/lang/cem/libcc.ansi/headers/string.h @@ -33,5 +33,8 @@ extern char *strtok(char *_s1, const char *_s2); extern void *memset(void *_s, int _c, size_t _n); extern char *strerror(int _errnum); extern size_t strlen(const char *_s); +extern char *strdup(const char *_s); + +#define bcopy(s, d, z) memmove(d, s, z) #endif diff --git a/lang/cem/libcc.ansi/misc/putenv.c b/lang/cem/libcc.ansi/misc/putenv.c index dc448fef2..a1f94aba4 100644 --- a/lang/cem/libcc.ansi/misc/putenv.c +++ b/lang/cem/libcc.ansi/misc/putenv.c @@ -10,18 +10,17 @@ #define ENTRY_INC 10 #define rounded(x) (((x / ENTRY_INC) + 1) * ENTRY_INC) -extern const char **_penvp; -extern const char **environ; /* environ is a shadow name for _penvp */ +extern char **environ; int putenv(char *name) { - register const char **v = _penvp; + register char **v = environ; register char *r; static int size = 0; /* When size != 0, it contains the number of entries in the * table (including the final NULL pointer). This means that the - * last non-null entry is _penvp[size - 2]. + * last non-null entry is environ[size - 2]. */ if (!name) return 0; @@ -48,11 +47,11 @@ putenv(char *name) } } *r = '='; - v = _penvp; + v = environ; } if (!size) { - register const char **p; + register char **p; register int i = 0; if (v) @@ -62,18 +61,17 @@ putenv(char *name) if (!(v = malloc(rounded(i) * sizeof(char **)))) return 1; size = i; - p = _penvp; - _penvp = v; + p = environ; + environ = v; while (*v++ = *p++); /* copy the environment */ - v = _penvp; + v = environ; } else if (!(size % ENTRY_INC)) { - if (!(v = realloc(_penvp, rounded(size) * sizeof(char **)))) + if (!(v = realloc(environ, rounded(size) * sizeof(char **)))) return 1; - _penvp = v; + environ = v; } v[size - 1] = name; v[size] = NULL; size++; - environ = _penvp; return 0; } diff --git a/lang/cem/libcc.ansi/stdlib/getenv.c b/lang/cem/libcc.ansi/stdlib/getenv.c index 01b887a1d..592e0c05d 100644 --- a/lang/cem/libcc.ansi/stdlib/getenv.c +++ b/lang/cem/libcc.ansi/stdlib/getenv.c @@ -5,23 +5,47 @@ /* $Id$ */ #include -#include +#include -char * -getenv(const char *name) +extern char* _findenv(const char* name, int* offset); + +/* + * getenv(name) -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char* getenv(const char* name) { - register char **v = environ; - register const char *p, *q; + int offset; - if (v == NULL || name == NULL) - return (char *)NULL; - while ((p = *v++) != NULL) { - q = name; - while (*q && (*q == *p++)) - q++; - if (*q || (*p != '=')) - continue; - return (char *)p + 1; - } - return (char *)NULL; + return(_findenv(name,&offset)); } + +/* + * _findenv(name,offset) -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +char* _findenv(register const char* name, int* offset) +{ + extern char **environ; + register int len; + register char **P; + register const char *C; + + if (!environ) + return NULL; + + for (C = name,len = 0;*C && *C != '=';++C,++len); + for (P = environ;*P;++P) + if (!strncmp(*P,name,len)) + if (*(C = *P + len) == '=') { + *offset = P - environ; + return (char*)(++C); + } + return(NULL); +} + diff --git a/lang/cem/libcc.ansi/stdlib/setenv.c b/lang/cem/libcc.ansi/stdlib/setenv.c new file mode 100644 index 000000000..086b2118d --- /dev/null +++ b/lang/cem/libcc.ansi/stdlib/setenv.c @@ -0,0 +1,87 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include +#include + +extern char* _findenv(const char* name, int* offset); +extern char **environ; + +/* + * setenv(name,value,rewrite) + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +int setenv(register const char* name, register const char* value, int rewrite) +{ + static int alloced = 0; /* if allocated space before */ + register char *C; + int l_value, + offset; + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((C = _findenv(name,&offset))) { /* find if already exists */ + if (!rewrite) + return(0); + if (strlen(C) >= l_value) { /* old larger; copy over */ + while (*C++ = *value++); + return(0); + } + } + else { /* create new slot */ + register int cnt = 0; + register char **P; + + if (environ) + for (P = environ;*P;++P,++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (unsigned)(sizeof(char *) * (cnt + 2))); + if (!environ) + return(-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + P = (char **)malloc((unsigned)(sizeof(char *) * + (cnt + 2))); + if (!P) + return(-1); + if (environ) + bcopy(environ,P,cnt * sizeof(char *)); + environ = P; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (C = name;*C && *C != '=';++C); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((unsigned)((int)(C - name) + l_value + 2)))) + return(-1); + for (C = environ[offset];(*C = *name++) && *C != '=';++C); + for (*C++ = '=';*C++ = *value++;); + return(0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +int +unsetenv(const char* name) +{ + register char **P; + int offset; + + while (_findenv(name,&offset)) /* if set multiple times */ + for (P = &environ[offset];;++P) + if (!(*P = *(P + 1))) + break; + + return 0; +} + diff --git a/lang/cem/libcc.ansi/string/strdup.c b/lang/cem/libcc.ansi/string/strdup.c new file mode 100644 index 000000000..730796b5f --- /dev/null +++ b/lang/cem/libcc.ansi/string/strdup.c @@ -0,0 +1,17 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include + +char* +strdup(const char *s) +{ + int len = strlen(s); + char *p = malloc(len+1); + if (p) + memcpy(p, s, len+1); + return p; +} From d273497077b7dda5430ab61fa4b5f39167856fad Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 21:41:58 +0100 Subject: [PATCH 082/231] Add some missing libc functions: setenv, unsetenv, strdup. --HG-- rename : lang/cem/libcc.ansi/stdlib/getenv.c => lang/cem/libcc.ansi/stdlib/setenv.c rename : lang/cem/libcc.ansi/string/strlen.c => lang/cem/libcc.ansi/string/strdup.c extra : source : 64d6e6eec18d76bf8f3947ec5d171db94acdb282 --- lang/cem/libcc.ansi/build.mk | 2 + lang/cem/libcc.ansi/headers/stdlib.h | 3 + lang/cem/libcc.ansi/headers/string.h | 3 + lang/cem/libcc.ansi/misc/putenv.c | 22 ++++--- lang/cem/libcc.ansi/stdlib/getenv.c | 56 +++++++++++++----- lang/cem/libcc.ansi/stdlib/setenv.c | 87 ++++++++++++++++++++++++++++ lang/cem/libcc.ansi/string/strdup.c | 17 ++++++ 7 files changed, 162 insertions(+), 28 deletions(-) create mode 100644 lang/cem/libcc.ansi/stdlib/setenv.c create mode 100644 lang/cem/libcc.ansi/string/strdup.c diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 6140b4b50..5987de9e3 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -186,6 +186,7 @@ $(call ackfile, lang/cem/libcc.ansi/stdlib/div.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/atexit.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/exit.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/getenv.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/setenv.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/labs.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/ldiv.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/mblen.c) @@ -238,6 +239,7 @@ $(call ackfile, lang/cem/libcc.ansi/string/strpbrk.c) $(call ackfile, lang/cem/libcc.ansi/string/strspn.c) $(call ackfile, lang/cem/libcc.ansi/string/strncmp.c) $(call ackfile, lang/cem/libcc.ansi/string/strxfrm.c) +$(call ackfile, lang/cem/libcc.ansi/string/strdup.c) # Time diff --git a/lang/cem/libcc.ansi/headers/stdlib.h b/lang/cem/libcc.ansi/headers/stdlib.h index c14db91a8..64a6de16c 100644 --- a/lang/cem/libcc.ansi/headers/stdlib.h +++ b/lang/cem/libcc.ansi/headers/stdlib.h @@ -36,6 +36,9 @@ extern int atexit(void (*_func)(void)); extern void exit(int _status); extern void _Exit(int _status); extern char* getenv(const char *_name); +extern int setenv(const char *_name, const char *_value, int _overwrite); +extern int unsetenv(const char *_name); +extern int putenv(char *_string); extern int system(const char *_string); extern void* bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, diff --git a/lang/cem/libcc.ansi/headers/string.h b/lang/cem/libcc.ansi/headers/string.h index b9d50617b..eef924f74 100644 --- a/lang/cem/libcc.ansi/headers/string.h +++ b/lang/cem/libcc.ansi/headers/string.h @@ -33,5 +33,8 @@ extern char *strtok(char *_s1, const char *_s2); extern void *memset(void *_s, int _c, size_t _n); extern char *strerror(int _errnum); extern size_t strlen(const char *_s); +extern char *strdup(const char *_s); + +#define bcopy(s, d, z) memmove(d, s, z) #endif diff --git a/lang/cem/libcc.ansi/misc/putenv.c b/lang/cem/libcc.ansi/misc/putenv.c index dc448fef2..a1f94aba4 100644 --- a/lang/cem/libcc.ansi/misc/putenv.c +++ b/lang/cem/libcc.ansi/misc/putenv.c @@ -10,18 +10,17 @@ #define ENTRY_INC 10 #define rounded(x) (((x / ENTRY_INC) + 1) * ENTRY_INC) -extern const char **_penvp; -extern const char **environ; /* environ is a shadow name for _penvp */ +extern char **environ; int putenv(char *name) { - register const char **v = _penvp; + register char **v = environ; register char *r; static int size = 0; /* When size != 0, it contains the number of entries in the * table (including the final NULL pointer). This means that the - * last non-null entry is _penvp[size - 2]. + * last non-null entry is environ[size - 2]. */ if (!name) return 0; @@ -48,11 +47,11 @@ putenv(char *name) } } *r = '='; - v = _penvp; + v = environ; } if (!size) { - register const char **p; + register char **p; register int i = 0; if (v) @@ -62,18 +61,17 @@ putenv(char *name) if (!(v = malloc(rounded(i) * sizeof(char **)))) return 1; size = i; - p = _penvp; - _penvp = v; + p = environ; + environ = v; while (*v++ = *p++); /* copy the environment */ - v = _penvp; + v = environ; } else if (!(size % ENTRY_INC)) { - if (!(v = realloc(_penvp, rounded(size) * sizeof(char **)))) + if (!(v = realloc(environ, rounded(size) * sizeof(char **)))) return 1; - _penvp = v; + environ = v; } v[size - 1] = name; v[size] = NULL; size++; - environ = _penvp; return 0; } diff --git a/lang/cem/libcc.ansi/stdlib/getenv.c b/lang/cem/libcc.ansi/stdlib/getenv.c index 01b887a1d..592e0c05d 100644 --- a/lang/cem/libcc.ansi/stdlib/getenv.c +++ b/lang/cem/libcc.ansi/stdlib/getenv.c @@ -5,23 +5,47 @@ /* $Id$ */ #include -#include +#include -char * -getenv(const char *name) +extern char* _findenv(const char* name, int* offset); + +/* + * getenv(name) -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char* getenv(const char* name) { - register char **v = environ; - register const char *p, *q; + int offset; - if (v == NULL || name == NULL) - return (char *)NULL; - while ((p = *v++) != NULL) { - q = name; - while (*q && (*q == *p++)) - q++; - if (*q || (*p != '=')) - continue; - return (char *)p + 1; - } - return (char *)NULL; + return(_findenv(name,&offset)); } + +/* + * _findenv(name,offset) -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +char* _findenv(register const char* name, int* offset) +{ + extern char **environ; + register int len; + register char **P; + register const char *C; + + if (!environ) + return NULL; + + for (C = name,len = 0;*C && *C != '=';++C,++len); + for (P = environ;*P;++P) + if (!strncmp(*P,name,len)) + if (*(C = *P + len) == '=') { + *offset = P - environ; + return (char*)(++C); + } + return(NULL); +} + diff --git a/lang/cem/libcc.ansi/stdlib/setenv.c b/lang/cem/libcc.ansi/stdlib/setenv.c new file mode 100644 index 000000000..086b2118d --- /dev/null +++ b/lang/cem/libcc.ansi/stdlib/setenv.c @@ -0,0 +1,87 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include +#include + +extern char* _findenv(const char* name, int* offset); +extern char **environ; + +/* + * setenv(name,value,rewrite) + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +int setenv(register const char* name, register const char* value, int rewrite) +{ + static int alloced = 0; /* if allocated space before */ + register char *C; + int l_value, + offset; + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((C = _findenv(name,&offset))) { /* find if already exists */ + if (!rewrite) + return(0); + if (strlen(C) >= l_value) { /* old larger; copy over */ + while (*C++ = *value++); + return(0); + } + } + else { /* create new slot */ + register int cnt = 0; + register char **P; + + if (environ) + for (P = environ;*P;++P,++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (unsigned)(sizeof(char *) * (cnt + 2))); + if (!environ) + return(-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + P = (char **)malloc((unsigned)(sizeof(char *) * + (cnt + 2))); + if (!P) + return(-1); + if (environ) + bcopy(environ,P,cnt * sizeof(char *)); + environ = P; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (C = name;*C && *C != '=';++C); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((unsigned)((int)(C - name) + l_value + 2)))) + return(-1); + for (C = environ[offset];(*C = *name++) && *C != '=';++C); + for (*C++ = '=';*C++ = *value++;); + return(0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +int +unsetenv(const char* name) +{ + register char **P; + int offset; + + while (_findenv(name,&offset)) /* if set multiple times */ + for (P = &environ[offset];;++P) + if (!(*P = *(P + 1))) + break; + + return 0; +} + diff --git a/lang/cem/libcc.ansi/string/strdup.c b/lang/cem/libcc.ansi/string/strdup.c new file mode 100644 index 000000000..730796b5f --- /dev/null +++ b/lang/cem/libcc.ansi/string/strdup.c @@ -0,0 +1,17 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include + +char* +strdup(const char *s) +{ + int len = strlen(s); + char *p = malloc(len+1); + if (p) + memcpy(p, s, len+1); + return p; +} From 2054618e7526eccc11f132d68a00dbc4aaf4657c Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 30 May 2013 23:19:55 +0100 Subject: [PATCH 083/231] Add basic termios to the rpi platform to allow echoing/newline translation to be controlled. --HG-- branch : dtrg-videocore rename : plat/rpi/include/unistd.h => plat/rpi/include/termios.h rename : plat/rpi/libsys/write.c => plat/rpi/libsys/tcgetattr.c rename : plat/rpi/libsys/write.c => plat/rpi/libsys/tcsetattr.c --- plat/rpi/build.mk | 5 ++++- plat/rpi/include/termios.h | 31 +++++++++++++++++++++++++++++++ plat/rpi/libsys/libsys.h | 2 +- plat/rpi/libsys/read.c | 10 +++------- plat/rpi/libsys/tcgetattr.c | 21 +++++++++++++++++++++ plat/rpi/libsys/tcsetattr.c | 19 +++++++++++++++++++ plat/rpi/libsys/write.c | 9 ++++----- 7 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 plat/rpi/include/termios.h create mode 100644 plat/rpi/libsys/tcgetattr.c create mode 100644 plat/rpi/libsys/tcsetattr.c diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index 7bbf007e4..4ddaeb489 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -13,6 +13,7 @@ D := plat/rpi/ platform-headers := \ unistd.h \ + termios.h \ pi.h \ ack/config.h @@ -33,7 +34,9 @@ platform-libsys := \ kill.c \ lseek.c \ time.c \ - signal.c + signal.c \ + tcgetattr.c \ + tcsetattr.c $(eval $(call build-platform)) diff --git a/plat/rpi/include/termios.h b/plat/rpi/include/termios.h new file mode 100644 index 000000000..67bf98a48 --- /dev/null +++ b/plat/rpi/include/termios.h @@ -0,0 +1,31 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _TERMIOS_H +#define _TERMIOS_H + +typedef unsigned char tcflag_t; + +struct termios +{ + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_lflag; +}; + +#define ONLCR 1 +#define ECHO 2 +#define INLCR 4 + +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +extern int tcgetattr(int fd, struct termios* t); +extern int tcsetattr(int fd, int actions, struct termios* t); + +#endif diff --git a/plat/rpi/libsys/libsys.h b/plat/rpi/libsys/libsys.h index e9bff7e1a..bd9d91880 100644 --- a/plat/rpi/libsys/libsys.h +++ b/plat/rpi/libsys/libsys.h @@ -13,6 +13,6 @@ extern unsigned char _sys_rawread(void); extern void _sys_write_tty(char c); -/* extern int _sys_ttyflags; */ +extern int _sys_ttyflags; #endif diff --git a/plat/rpi/libsys/read.c b/plat/rpi/libsys/read.c index 476689320..227c89997 100644 --- a/plat/rpi/libsys/read.c +++ b/plat/rpi/libsys/read.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "libsys.h" int read(int fd, void* buffer, size_t count) @@ -30,16 +31,11 @@ int read(int fd, void* buffer, size_t count) /* Read one byte. */ i = _sys_rawread(); -#if 0 - if ((i == '\r') && !(_sys_ttyflags & RAW)) + if ((i == '\r') && !(_sys_ttyflags & INLCR)) i = '\n'; if (_sys_ttyflags & ECHO) _sys_write_tty(i); -#endif - if (i == '\r') - i = '\n'; - _sys_write_tty(i); - + *(char*)buffer = i; return 1; } diff --git a/plat/rpi/libsys/tcgetattr.c b/plat/rpi/libsys/tcgetattr.c new file mode 100644 index 000000000..08c73f36b --- /dev/null +++ b/plat/rpi/libsys/tcgetattr.c @@ -0,0 +1,21 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +int tcgetattr(int fd, struct termios* t) +{ + t->c_iflag = _sys_ttyflags & INLCR; + t->c_oflag = _sys_ttyflags & ONLCR; + t->c_lflag = _sys_ttyflags & ECHO; + return 0; +} + diff --git a/plat/rpi/libsys/tcsetattr.c b/plat/rpi/libsys/tcsetattr.c new file mode 100644 index 000000000..1943d33e0 --- /dev/null +++ b/plat/rpi/libsys/tcsetattr.c @@ -0,0 +1,19 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +int tcsetattr(int fd, int actions, struct termios* t) +{ + _sys_ttyflags = t->c_iflag | t->c_oflag | t->c_lflag; + return 0; +} + diff --git a/plat/rpi/libsys/write.c b/plat/rpi/libsys/write.c index 9a765b04c..0fba49884 100644 --- a/plat/rpi/libsys/write.c +++ b/plat/rpi/libsys/write.c @@ -8,16 +8,15 @@ #include #include #include +#include #include "libsys.h" +int _sys_ttyflags = ONLCR | INLCR | ECHO; + void _sys_write_tty(char c) { _sys_rawwrite(c); -#if 0 - if ((c == '\n') && !(_sys_ttyflags & RAW)) - _sys_rawwrite('\r'); -#endif - if (c == '\n') + if ((c == '\n') && (_sys_ttyflags & ONLCR)) _sys_rawwrite('\r'); } From d5a112dbfda23a1dfc0e8d5c22e474762da75f44 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 30 May 2013 23:25:22 +0100 Subject: [PATCH 084/231] Some more termios compatibility options. --HG-- branch : dtrg-videocore --- plat/rpi/include/termios.h | 16 ++++++++++++++++ plat/rpi/libsys/tcgetattr.c | 1 + 2 files changed, 17 insertions(+) diff --git a/plat/rpi/include/termios.h b/plat/rpi/include/termios.h index 67bf98a48..8e0dbb8e8 100644 --- a/plat/rpi/include/termios.h +++ b/plat/rpi/include/termios.h @@ -15,12 +15,28 @@ struct termios tcflag_t c_iflag; tcflag_t c_oflag; tcflag_t c_lflag; + tcflag_t c_cflag; }; #define ONLCR 1 #define ECHO 2 #define INLCR 4 +/* Dummied parameters for compatibility --- only the ones above are + * honoured. */ + +#define BRKINT 0 +#define ICRNL 0 +#define INPCK 0 +#define ISTRIP 0 +#define IXON 0 +#define CS8 0 +#define ICANON 0 +#define IEXTEN 0 +#define ISIG 0 + +#define OPOST ONLCR + #define TCSANOW 0 #define TCSADRAIN 1 #define TCSAFLUSH 2 diff --git a/plat/rpi/libsys/tcgetattr.c b/plat/rpi/libsys/tcgetattr.c index 08c73f36b..3b099afb5 100644 --- a/plat/rpi/libsys/tcgetattr.c +++ b/plat/rpi/libsys/tcgetattr.c @@ -16,6 +16,7 @@ int tcgetattr(int fd, struct termios* t) t->c_iflag = _sys_ttyflags & INLCR; t->c_oflag = _sys_ttyflags & ONLCR; t->c_lflag = _sys_ttyflags & ECHO; + t->c_cflag = 0; return 0; } From 86c6fa2f1e339c67c66902e5d3308e3fbd1e1679 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 30 May 2013 23:50:19 +0100 Subject: [PATCH 085/231] Implement NOT... --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 3c28651df..9d1e45874 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -144,6 +144,7 @@ INSTRUCTIONS lsr GPR:rw, GPR+CONST:ro. mov GPR:wo, GPR+CONST:ro. mul GPR:rw, GPR+CONST:ro. + mvn GPR:wo, GPR+CONST:ro. neg GPR:rw, GPR+CONST:ro. or GPR:rw, GPR+CONST:ro. pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo. @@ -837,6 +838,13 @@ PATTERNS eor %a, %2 yields %a + pat com $1==QUAD /* Complement */ + with GPR + uses reusing %1, REG=%1 + gen + mvn %a, %1 + yields %a + pat dvi $1==QUAD /* Divide word (second / top) */ with GPR GPR uses reusing %2, REG From aacabba16584ab2db0b6580d873679c1522c2b05 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 2 Jun 2013 22:02:15 +0100 Subject: [PATCH 086/231] Apply fix contributed by George Koehler: - don't crash if BSS overlaps BDOS - fix stack initialisation bug - fix command line argification --- plat/cpm/boot.s | 86 ++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/plat/cpm/boot.s b/plat/cpm/boot.s index b36d1ce02..960dc400d 100644 --- a/plat/cpm/boot.s +++ b/plat/cpm/boot.s @@ -15,12 +15,21 @@ MAX_ARGV = 8 .sect .bss STACKSIZE = 2*1024 .comm stack, STACKSIZE -.comm oldstack, 2 .sect .text begtext: - ! The absolute first thing we have to do is to clear the bss. (argify - ! requires it.) + ! Check if bss would overlap BDOS. We must not overwrite + ! BDOS and crash CP/M. We cheat by comparing only high bytes + ! of each address. + + lxi b, __end + lda 0x0007 + mov c, a ! c = high byte of BDOS address + mov a, b ! a = high byte of _end + cmp c + jnc __exit ! emergency exit if a >= c + + ! We have to clear the bss. (argify requires it.) lxi h, begbss lxi b, endbss @@ -36,8 +45,8 @@ begtext: jnz 1b ! Set up the stack (now it's been cleared, since it's in the BSS). - - lxi sp, oldstack + STACKSIZE + + lxi sp, stack + STACKSIZE ! C-ify the command line at 0x0080. @@ -54,43 +63,38 @@ begtext: ! Now argify it. lxi b, 0x0081 ! bc = command line pointer - lxi d, argv ! de = argv pointer - - ldax b ! peek for any leading whitespace - ora a - cpi ' ' - jz 3f - -1: xchg ! write out the next argument - mov m, c - inx h - mov m, b - inx h - xchg + lxi h, argv ! hl = argv pointer - lda argc ! exit if this was the last argument +loop_of_argify: + ldax b ! a = next character + ora a ! check for end of string + jz end_of_argify + cpi ' ' ! scan for non-space + jz 2f + + mov m, c ! put next argument in argv + inx h + mov m, b + inx h + + lda argc ! increment argc inr a sta argc - cpi MAX_ARGV - jz end_of_argify - -2: inx b ! scan for whitespace - ldax b - ora a - jz end_of_argify - cpi ' ' - jnz 2b - - xra a ! replace the space with a \0 - stax b - -3: inx b ! scan for non-whitespace - ldax b - ora a - jz end_of_argify - cpi ' ' - jz 3b - jmp 1b + cpi MAX_ARGV ! exit loop if argv is full + jz end_of_argify + +1: inx b ! scan for space + ldax b + ora a + jz end_of_argify + cpi ' ' + jnz 1b + + xra a ! replace the space with a '\0' + stax b + +2: inx b + jmp loop_of_argify end_of_argify: ! Add the fake parameter for the program name. @@ -110,8 +114,8 @@ end_of_argify: mvi h, 0 push h call __m_a_i_n - jmp EXIT - + ! FALLTHROUGH + ! Emergency exit routine. .define EXIT, __exit From 3e0123ca032169ffaa67652da8da633ba92307be Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 5 Jun 2013 23:57:23 +0100 Subject: [PATCH 087/231] Fix treatment of out-of-range values in switch csa. --HG-- branch : dtrg-videocore --- mach/vc4/libem/csa.s | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mach/vc4/libem/csa.s b/mach/vc4/libem/csa.s index 1628199a0..25332f2a7 100644 --- a/mach/vc4/libem/csa.s +++ b/mach/vc4/libem/csa.s @@ -17,17 +17,20 @@ add r0, gp ld r2, 4 (r0) ! check lower bound - cmp r1, r2 - mov.lo r1, r2 ! r1 = min(r1, r2) + + b.lo r1, r2, default ! jump to default if r1 < r2 sub r1, r2 ! adjust value to be 0-based ld r2, 8 (r0) ! check upper bound - cmp r1, r2 - mov.hi r1, r2 ! r1 = max(r1, r2) + b.hi r1, r2, default ! jump to default if r1 > r2 add r1, #3 +go: ld r1, (r0, r1) ! load destination address add r1, gp b r1 ! ...and go +default: + mov r1, #0 ! index of default value + b go From ed6c4a85d16223805969192ef360b360698f2a2a Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 6 Jun 2013 00:05:48 +0100 Subject: [PATCH 088/231] Change the size of the SRAM area to 128kB (to reflect reality). --HG-- branch : dtrg-videocore --- plat/rpi/README | 6 +++--- plat/rpi/libsys/brk.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plat/rpi/README b/plat/rpi/README index 166d2148b..f8836724c 100644 --- a/plat/rpi/README +++ b/plat/rpi/README @@ -11,7 +11,7 @@ you're running in bare-metal mode, you can hook stdin/stdout up to the mini UART. (Obviously, in kernel mode you can't.) Important note! The malloc heap expects your program to be loaded into a -chunk of memory that's 256kB large. You must make sure that this is the case, +chunk of memory that's 128kB large. You must make sure that this is the case, or Bad Stuff will happen. Output binaries are fully PIC and can be loaded anywhere (this is one of the @@ -57,10 +57,10 @@ variable. It's a structure that is initialised with the data that's passed in from mailbox.c (currently four pointers and two integers). If you want to use malloc() and friends, you'll need to hack mailbox.c so -that the buffer containing the code is at least 256kB, or you're likely to +that the buffer containing the code is at least 128kB, or you're likely to corrupt the VideoCore's workspace and crash it. David Given -2013-05-26 +2013-06-06 diff --git a/plat/rpi/libsys/brk.c b/plat/rpi/libsys/brk.c index 2c44347d4..36c7d4a6f 100644 --- a/plat/rpi/libsys/brk.c +++ b/plat/rpi/libsys/brk.c @@ -19,7 +19,7 @@ static char* current = _end; /* Top of heap: we assume that the block of memory the binary is loaded in * is 256kB long. Because user pointers are always relative to the beginning * of the block, this makes the end address easy to calculate. */ -static char* max = (char*) (256*1024); +static char* max = (char*) (128*1024); int brk(void* newend) { From bbd4b4685084e4073c4535567cffc162e9a6980a Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 7 Jun 2013 21:25:38 +0100 Subject: [PATCH 089/231] Fix stack corruption when adjusting SP. Be a bit more rigorous about clearing the pseudostack on branch/labels. --HG-- branch : dtrg-videocore --- mach/vc4/ncg/table | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 9d1e45874..963fb74e1 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -117,7 +117,7 @@ INSTRUCTIONS beq "b.eq" LABEL:ro. bne "b.ne" LABEL:ro. bgt "b.gt" LABEL:ro. - bgt "b.gt" LABEL:ro. + blt "b.lt" LABEL:ro. bhi "b.hi" LABEL:ro. bset GPR:rw, GPR+CONST:ro. b GPR+LABEL:ro. @@ -266,28 +266,32 @@ PATTERNS with ANY yields %1 %1 - pat dup $1<=(2*QUAD) /* Duplicate word pair on top of stack */ + pat dup $1==(2*QUAD) /* Duplicate word pair on top of stack */ with ANY ANY yields %1 %2 %1 %2 - pat exg $1==QUAD /* Exchange top two words on stack */ + pat exg $1<=QUAD /* Exchange top two words on stack */ with ANY ANY yields %1 %2 + pat exg $1==(2*QUAD) /* Exchange top two word pairs on stack */ + with ANY ANY ANY ANY + yields %2 %1 %4 %3 + pat stl lol $1==$2 /* Store then load local */ leaving dup QUAD stl $1 - + pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */ leaving dup $2 lal $1 sti $2 - + pat ste loe $1==$2 /* Store then load external */ leaving - dup 4 + dup QUAD ste $1 @@ -1126,7 +1130,7 @@ PATTERNS pat cmf tne call cmf_t("add.ne") /* top = float (second != top) */ pat cmf tlt call cmf_t("add.lo") /* top = float (second < top) */ pat cmf tle call cmf_t("add.ls") /* top = float (second <= top) */ - pat cmf tgt call cmf_t("add.hi") /* top = float (second < top) */ + pat cmf tgt call cmf_t("add.hi") /* top = float (second > top) */ pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */ proc fallback_t example teq @@ -1142,7 +1146,7 @@ PATTERNS pat tne call fallback_t("add.ne") /* top = float (top != 0) */ pat tlt call fallback_t("add.lo") /* top = float (top < 0) */ pat tle call fallback_t("add.ls") /* top = float (top <= 0) */ - pat tgt call fallback_t("add.hi") /* top = float (top < 0) */ + pat tgt call fallback_t("add.hi") /* top = float (top > 0) */ pat tge call fallback_t("add.hs") /* top = float (top >= 0) */ @@ -1151,6 +1155,7 @@ PATTERNS proc anyz example zeq with GPR STACK + kills ALL gen cmp %1, {CONST, 0} beq[1] {LABEL, $1} @@ -1164,6 +1169,7 @@ PATTERNS proc anyb example beq with GPR+CONST GPR STACK + kills ALL gen cmp %2, %1 beq[1] {LABEL, $1} @@ -1177,6 +1183,7 @@ PATTERNS proc cmu_z example cmu zeq with GPR+CONST GPR STACK + kills ALL gen cmp %2, %1 beq[1] {LABEL, $2} @@ -1196,6 +1203,7 @@ PATTERNS proc cmf_z example cmu zeq with GPR GPR STACK + kills ALL gen fcmp %2, %2, %1 beq[1] {LABEL, $2} @@ -1258,6 +1266,7 @@ PATTERNS pat bra with STACK + kills ALL gen b {LABEL, $1} @@ -1452,13 +1461,23 @@ PATTERNS ste ".reghp" pat ass /* Adjust stack by variable amount */ - with CONST+GPR + with CONST+GPR STACK gen add SP, %1 pat asp $1==QUAD /* Adjust stack by constant amount */ - gen - pop SCRATCH + with GPR + /* silently ignore GPR */ + with STACK + gen + pop SCRATCH + + pat asp $1==(2*QUAD) /* Adjust stack by constant amount */ + with GPR GPR + /* silently ignore GPR */ + with STACK + gen + add SP, {CONST, 2*QUAD} pat asp /* Adjust stack by constant amount */ leaving From eaf4339cd638777d787e34c63397b23ce3b0e6c3 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 9 Jun 2013 22:16:30 +0100 Subject: [PATCH 090/231] Implement a very crude busy-wait based select() mechanism for consol input. --HG-- branch : dtrg-videocore rename : plat/rpi/include/ack/config.h => plat/rpi/include/sys/select.h rename : plat/rpi/libsys/time.c => plat/rpi/libsys/select.c --- plat/rpi/build.mk | 3 +- plat/rpi/include/sys/select.h | 13 +++++++ plat/rpi/include/unistd.h | 12 +++++++ plat/rpi/libsys/libsys.h | 1 + plat/rpi/libsys/pi_uart.s | 14 ++++++++ plat/rpi/libsys/select.c | 65 +++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 plat/rpi/include/sys/select.h create mode 100644 plat/rpi/libsys/select.c diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index 4ddaeb489..4db4a4849 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -36,7 +36,8 @@ platform-libsys := \ time.c \ signal.c \ tcgetattr.c \ - tcsetattr.c + tcsetattr.c \ + select.c $(eval $(call build-platform)) diff --git a/plat/rpi/include/sys/select.h b/plat/rpi/include/sys/select.h new file mode 100644 index 000000000..df7488da4 --- /dev/null +++ b/plat/rpi/include/sys/select.h @@ -0,0 +1,13 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H + +#include + +#endif diff --git a/plat/rpi/include/unistd.h b/plat/rpi/include/unistd.h index 4cbf43c58..a4d0c4507 100644 --- a/plat/rpi/include/unistd.h +++ b/plat/rpi/include/unistd.h @@ -90,4 +90,16 @@ typedef void (*sighandler_t)(int); extern sighandler_t signal(int signum, sighandler_t handler); extern int raise(int signum); +/* Select */ + +typedef uint32_t fd_set; + +extern int select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); + +#define FD_ZERO(set) do { *set = 0; } while (0) +#define FD_SET(fd, set) do { *set |= (1< +#include +#include +#include +#include +#include "libsys.h" + +#define TICKS_PER_SEC 1000000 + +typedef int condition_t(void); + +static int nop_condition(void) +{ + return 0; +} + +int select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout) +{ + int result = 0; + condition_t* condition = nop_condition; + + if (FD_ISSET(0, readfds)) + condition = _sys_rawpoll; + + FD_ZERO(readfds); + FD_ZERO(writefds); + FD_ZERO(exceptfds); + + if (timeout) + { + /* Wait for a specified amount of time. */ + + uint32_t ticks = (timeout->tv_sec * TICKS_PER_SEC) + + (timeout->tv_usec * (TICKS_PER_SEC/1000000)); + uint32_t* timer_clo = pi_phys_to_user((void*) 0x7e003004); + uint32_t ra = *timer_clo; + + while (!condition() && ((*timer_clo - ra) < ticks)) + ; + } + else + { + /* Wait forever. */ + + while (!condition()) + ; + + } + + if ((condition == _sys_rawpoll) && condition()) + { + FD_SET(0, readfds); + result = 1; + } + + return result; +} From 052dd9bfc0aeb6665f07f0fd3bf5a2c9bdc71315 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 20 Jun 2013 00:14:55 +0100 Subject: [PATCH 091/231] Actually remember to set the stack pointer on startup. Reduce to stack from 16kB to a much more reasonable 1kB. --HG-- branch : dtrg-videocore --- plat/rpi/boot.s | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index 71081d2cb..8bee47aba 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -16,7 +16,7 @@ .sect .text #define gp r15 -#define STACKSIZE 16*1024 +#define STACKSIZE 1*1024 ! MAIN ENTRY POINT @@ -46,6 +46,7 @@ _1: st lr, .returnlr lea gp, begtext + lea sp, .stack + STACKSIZE ! Save the kernel parameters. From 55be35a68a9754a4c5c34ae2ff18ff1005b75d84 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 20 Jun 2013 00:15:14 +0100 Subject: [PATCH 092/231] Add a stub malloc.h. --HG-- branch : dtrg-videocore rename : lang/cem/libcc.ansi/headers/stdlib.h => lang/cem/libcc.ansi/headers/malloc.h --- lang/cem/libcc.ansi/build.mk | 1 + lang/cem/libcc.ansi/headers/malloc.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 lang/cem/libcc.ansi/headers/malloc.h diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 5987de9e3..d4300311d 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -16,6 +16,7 @@ define build-libcc-ansi-headers-impl float.h \ limits.h \ math.h \ + malloc.h \ setjmp.h \ signal.h \ stdarg.h \ diff --git a/lang/cem/libcc.ansi/headers/malloc.h b/lang/cem/libcc.ansi/headers/malloc.h new file mode 100644 index 000000000..73cef551e --- /dev/null +++ b/lang/cem/libcc.ansi/headers/malloc.h @@ -0,0 +1,14 @@ +/* + * stdlib.h - standard library + * + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#ifndef _MALLOC_H +#define _MALLOC_H + +#include + +#endif From fd2360be0f9d6fdd91240ed32873f910edf13825 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 21 Jun 2013 23:20:50 +0100 Subject: [PATCH 093/231] Ship assembler man pages. --HG-- branch : dtrg-videocore rename : man/8080_as.6 => man/i80_as.6 rename : man/m68k2_as.6 => man/m68020_as.6 --- mach/proto/as/build.mk | 4 ++++ man/.distr | 5 +++-- man/{8080_as.6 => i80_as.6} | 0 man/{m68k2_as.6 => m68020_as.6} | 0 4 files changed, 7 insertions(+), 2 deletions(-) rename man/{8080_as.6 => i80_as.6} (100%) rename man/{m68k2_as.6 => m68020_as.6} (100%) diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 791611f3d..a67277ac2 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -41,6 +41,10 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ $(call file, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/$(PLATFORM)/as) $(call installto, $(PLATDEP)/$(PLATFORM)/as) + + $(call reset) + $(call file, man/$(ARCH)_as.6) + $(call installto, $(INSDIR)/share/man/man6/$(ARCH)_as.6) endef build-as = $(eval $(build-as-impl)) diff --git a/man/.distr b/man/.distr index d21bfd287..f3262226b 100644 --- a/man/.distr +++ b/man/.distr @@ -2,12 +2,13 @@ 6800_as.6 6805_as.6 6809_as.6 -8080_as.6 +i80_as.6 z8000_as.6 i86_as.6 i386_as.6 -m68k2_as.6 +m68020_as.6 ns_as.6 +vc4_as.6 pdp_as.6 z80_as.6 em_cg.6 diff --git a/man/8080_as.6 b/man/i80_as.6 similarity index 100% rename from man/8080_as.6 rename to man/i80_as.6 diff --git a/man/m68k2_as.6 b/man/m68020_as.6 similarity index 100% rename from man/m68k2_as.6 rename to man/m68020_as.6 From 2be811bac24d6bfb477fbd29df3df6280e145e23 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 21 Jun 2013 23:21:08 +0100 Subject: [PATCH 094/231] Updated VC4 docs. --HG-- branch : dtrg-videocore --- man/vc4_as.6 | 45 +++++++++++++++++++++++++++++++++++++++++++++ plat/rpi/README | 3 +++ 2 files changed, 48 insertions(+) create mode 100644 man/vc4_as.6 diff --git a/man/vc4_as.6 b/man/vc4_as.6 new file mode 100644 index 000000000..81b10813d --- /dev/null +++ b/man/vc4_as.6 @@ -0,0 +1,45 @@ +.\" $Header$ +.TH VC4_AS 1 +.ad +.SH NAME +vc4_as \- assembler for Broadcom VideoCore IV + +.SH SYNOPSIS +/usr/em/lib/vc4_as [options] argument ... + +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). + +.SH SYNTAX +The assembler uses a modified version of the syntax described in +https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Programmers-Manual: +condition codes must be prefixed with a full stop. Vector instructions are not +yet supported. + +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +https://github.com/hermanhermitage/videocoreiv +.SH EXAMPLE +.nf +.ta 8n 16n 24n 32n 40n 48n +An example of VideoCore IV assembly language: + + ldb r0, __uart_status + b.eq r0, #0, 1b + + ! receive 1 byte (returned in r0) + mov r1, #AUX_MU_LSR_REG + mov r2, #AUX_MU_IO_REG + ! loop until char available +recvwait: + ld r3, (r1) + and r3, #0x1 + b.ne r3, #0x1, recvwait + + ldb r0, (r2) +1: + b lr +.fi diff --git a/plat/rpi/README b/plat/rpi/README index f8836724c..7d78433dd 100644 --- a/plat/rpi/README +++ b/plat/rpi/README @@ -5,6 +5,9 @@ This is a fairly crude port of the ACK to produce VideoCore IV machine code, suitable for use on the Raspberry Pi. It produces terrible but working code. The resulting binaries can be used either bare metal or loaded as a GPU kernel and executed using a modified mailbox.c (see below). +Currently floating point support is present but incomplete; and as the +VideoCore IV does not have double-precision float support, the C compiler +treats doubles as single precision. As much of the standard C library as is relevant works; if you're running in bare-metal mode, you can hook stdin/stdout up to the From d94c1c81502771486a92f4543e05abf32d405000 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 21 Jun 2013 23:38:21 +0100 Subject: [PATCH 095/231] Updated distr files. --HG-- branch : dtrg-videocore rename : mach/i80/.distr => mach/vc4/.distr rename : plat/cpm/.distr => plat/rpi/.distr --- .distr | 3 +++ lang/cem/libcc.ansi/headers/.distr | 1 + lang/cem/libcc.ansi/stdio/.distr | 2 ++ lang/cem/libcc.ansi/stdlib/.distr | 1 + lang/cem/libcc.ansi/string/.distr | 1 + mach/.distr | 1 + mach/vc4/.distr | 5 +++++ mach/vc4/as/.distr | 1 + mach/vc4/libem/.distr | 3 +++ man/.distr | 8 -------- plat/rpi/.distr | 31 ++++++++++++++++++++++++++++++ plat/rpi/boot.s | 4 ++++ 12 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 mach/vc4/.distr create mode 100644 mach/vc4/libem/.distr create mode 100644 plat/rpi/.distr diff --git a/.distr b/.distr index dbe964f93..1009a685e 100644 --- a/.distr +++ b/.distr @@ -48,6 +48,7 @@ mach/i80 mach/i86 mach/i386 mach/m68020 +mach/vc4 plat plat/cpm @@ -55,5 +56,7 @@ plat/pc86 plat/linux plat/linux386 plat/linux68k +plat/rpi examples +man diff --git a/lang/cem/libcc.ansi/headers/.distr b/lang/cem/libcc.ansi/headers/.distr index cf35cec17..22ee8d0c4 100644 --- a/lang/cem/libcc.ansi/headers/.distr +++ b/lang/cem/libcc.ansi/headers/.distr @@ -20,3 +20,4 @@ stdbool.h fcntl.h tgmath.h locale.h +malloc.h diff --git a/lang/cem/libcc.ansi/stdio/.distr b/lang/cem/libcc.ansi/stdio/.distr index 5ad14e146..4206946e7 100644 --- a/lang/cem/libcc.ansi/stdio/.distr +++ b/lang/cem/libcc.ansi/stdio/.distr @@ -39,6 +39,7 @@ rewind.c scanf.c setbuf.c setvbuf.c +snprintf.c sprintf.c sscanf.c tmpfile.c @@ -47,3 +48,4 @@ ungetc.c vfprintf.c vprintf.c vsprintf.c +vsnprintf.c diff --git a/lang/cem/libcc.ansi/stdlib/.distr b/lang/cem/libcc.ansi/stdlib/.distr index a556b3058..dd4a54186 100644 --- a/lang/cem/libcc.ansi/stdlib/.distr +++ b/lang/cem/libcc.ansi/stdlib/.distr @@ -17,6 +17,7 @@ mbstowcs.c mbtowc.c qsort.c rand.c +setenv.c strtod.c strtol.c system.c diff --git a/lang/cem/libcc.ansi/string/.distr b/lang/cem/libcc.ansi/string/.distr index f7ff5cc28..ef6a1164e 100644 --- a/lang/cem/libcc.ansi/string/.distr +++ b/lang/cem/libcc.ansi/string/.distr @@ -9,6 +9,7 @@ strcmp.c strcoll.c strcpy.c strcspn.c +strdup.c strerror.c strlen.c strncat.c diff --git a/mach/.distr b/mach/.distr index fb9d533eb..d2137b302 100644 --- a/mach/.distr +++ b/mach/.distr @@ -25,6 +25,7 @@ s2650 sun3 sun2 vax4 +vc4 xenix3 z80 z8000 diff --git a/mach/vc4/.distr b/mach/vc4/.distr new file mode 100644 index 000000000..38864464f --- /dev/null +++ b/mach/vc4/.distr @@ -0,0 +1,5 @@ +build.mk +as +ncg +libem +libend diff --git a/mach/vc4/as/.distr b/mach/vc4/as/.distr index 8ebe3797c..6ef7a1516 100644 --- a/mach/vc4/as/.distr +++ b/mach/vc4/as/.distr @@ -4,3 +4,4 @@ mach2.c mach3.c mach4.c mach5.c +binary.h diff --git a/mach/vc4/libem/.distr b/mach/vc4/libem/.distr new file mode 100644 index 000000000..5dff9f5ac --- /dev/null +++ b/mach/vc4/libem/.distr @@ -0,0 +1,3 @@ +csa.s +csb.s +videocore.h diff --git a/man/.distr b/man/.distr index f3262226b..4e52c6c32 100644 --- a/man/.distr +++ b/man/.distr @@ -1,15 +1,8 @@ -6500_as.6 -6800_as.6 -6805_as.6 -6809_as.6 i80_as.6 -z8000_as.6 i86_as.6 i386_as.6 m68020_as.6 -ns_as.6 vc4_as.6 -pdp_as.6 z80_as.6 em_cg.6 em_ncg.6 @@ -18,4 +11,3 @@ libpc.7 head pc_prlib.7 uni_ass.6 -proto.make diff --git a/plat/rpi/.distr b/plat/rpi/.distr new file mode 100644 index 000000000..529eec7e9 --- /dev/null +++ b/plat/rpi/.distr @@ -0,0 +1,31 @@ +descr +boot.s +build.mk +README +include/ack/config.h +include/sys/select.h +include/unistd.h +include/pi.h +include/termios.h +libsys/brk.c +libsys/close.c +libsys/creat.c +libsys/errno.s +libsys/getpid.c +libsys/_hol0.s +libsys/isatty.c +libsys/kill.c +libsys/libsysasm.h +libsys/libsys.h +libsys/lseek.c +libsys/open.c +libsys/pi_phys_to_user.s +libsys/pi_uart.s +libsys/pi_user_to_phys.s +libsys/read.c +libsys/select.c +libsys/signal.c +libsys/tcgetattr.c +libsys/tcsetattr.c +libsys/time.c +libsys/write.c diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s index 8bee47aba..a76d1e7a7 100644 --- a/plat/rpi/boot.s +++ b/plat/rpi/boot.s @@ -110,6 +110,10 @@ __exit: .define _pi_kernel_parameters .comm _pi_kernel_parameters, 4 +.define .linenumber, .filename +.comm .linenumber, 4 ! current linenumber (used for debugging) +.comm .filename, 4 ! ptr to current filename (used for debugging) + ! User stack. .comm .stack, STACKSIZE From c72eaef8ee959d9a250b1c3946b91ad25b2b7c75 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 24 Jun 2013 23:57:27 +0100 Subject: [PATCH 096/231] Add routine to set the Raspberry Pi clock to 250MHz (loads faster than the default 19.2MHz). --HG-- branch : dtrg-videocore rename : plat/rpi/libsys/pi_user_to_phys.s => plat/rpi/libsys/pi_fast_mode.s --- plat/rpi/build.mk | 1 + plat/rpi/include/pi.h | 12 ++++++ plat/rpi/libsys/pi_fast_mode.s | 70 ++++++++++++++++++++++++++++++++++ plat/rpi/libsys/pi_uart.s | 15 ++++++-- 4 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 plat/rpi/libsys/pi_fast_mode.s diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk index 4db4a4849..c89847607 100644 --- a/plat/rpi/build.mk +++ b/plat/rpi/build.mk @@ -23,6 +23,7 @@ platform-libsys := \ pi_phys_to_user.s \ pi_user_to_phys.s \ pi_uart.s \ + pi_fast_mode.s \ creat.c \ close.c \ open.c \ diff --git a/plat/rpi/include/pi.h b/plat/rpi/include/pi.h index 656543bde..24e89a9a1 100644 --- a/plat/rpi/include/pi.h +++ b/plat/rpi/include/pi.h @@ -32,5 +32,17 @@ extern void* pi_phys_to_user(void* ptr); /* Converts a pointer from a user address to a physical address. */ extern void* pi_user_to_phys(void* ptr); +/* Change the clock speed from 19.2MHz to 250MHz. Must be called *before* + * pi_init_uart(). */ +extern void pi_fast_mode(void); + +/* Initialise the RAM. */ +extern void pi_init_ram(void); + +/* The current clock speed (used by pi_init_uart to calculate the correct + * UART settings). */ + +extern int pi_clock_speed; + #endif diff --git a/plat/rpi/libsys/pi_fast_mode.s b/plat/rpi/libsys/pi_fast_mode.s new file mode 100644 index 000000000..8b50990f0 --- /dev/null +++ b/plat/rpi/libsys/pi_fast_mode.s @@ -0,0 +1,70 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +#define PASSWD 0x5a000000 +#define PLLC 5 +#define OSC 1 + +#define A2W 0x7e102000 +#define A2W_PLLC_MULT 0x7e102020 +#define A2W_PLLC_MULT2 0x7e102120 +#define A2W_PLLC_MULT_FRACT 0x7e102220 +#define A2W_PLLx_DIV 0x7e102620 + +#define CM 0x7e101000 +#define CM_VPU_CTL 0x7e101008 +#define CM_VPU_DIV 0x7e10100c +#define CM_TIME_DIV 0x7e1010ec +#define CM_TIME_CTL 0x7e1010e8 + +#define hash # +#define copy(A) A +#define poke(A, V) \ + mov r0, copy(hash) V; mov r1, copy(hash) A; st r0, (r1) + +! Changes the clock speed to 250MHz. + +.define _pi_fast_mode +_pi_fast_mode: + poke(A2W + 0x190, 0x5a000001) + poke(A2W_PLLC_MULT_FRACT, PASSWD | 87380) + poke(A2W_PLLC_MULT2, PASSWD | 52 | 0x1000) + poke(A2W + 0x3c, 0x5a000100) + poke(A2W + 0x38, 0x5a000000) + poke(A2W + 0x34, 0x5a144000) + poke(A2W + 0x30, 0x5a000000) + poke(CM + 0x108, 0x5a000200) + poke(CM + 0x108, 0x5a0002aa) + poke(A2W + 0x2c, 0x5a000000) + poke(A2W + 0x28, 0x5a400000) + poke(A2W + 0x24, 0x5a000005) + poke(A2W_PLLC_MULT, PASSWD | 52 | 0x555000) + poke(A2W_PLLC_MULT2, PASSWD | 52 | 0x21000) + poke(A2W + 0x2c, 0x5a000042) + poke(A2W + 0x28, 0x5a500401) + poke(A2W + 0x24, 0x5a004005) + poke(A2W_PLLC_MULT, PASSWD | 52 | 0x555000) + poke(A2W_PLLx_DIV, PASSWD | 2) + poke(CM + 0x108, 0x5a0002ab) + poke(CM + 0x108, 0x5a0002aa) + poke(CM + 0x108, 0x5a0002a8) + poke(CM_VPU_CTL, PASSWD | 0x200 | OSC | 0x40) + poke(CM_VPU_DIV, PASSWD | [4 << 12]) + poke(CM_VPU_CTL, PASSWD | PLLC | 0x40) + poke(CM_VPU_CTL, PASSWD | PLLC | 0x50) + poke(CM_TIME_DIV, PASSWD | [19 << 12] | 819) + poke(CM_TIME_CTL, PASSWD | OSC | 0x10) + + mov r0, #250000000 + st r0, _pi_clock_speed + b lr + diff --git a/plat/rpi/libsys/pi_uart.s b/plat/rpi/libsys/pi_uart.s index d52069d71..b7ce9898e 100644 --- a/plat/rpi/libsys/pi_uart.s +++ b/plat/rpi/libsys/pi_uart.s @@ -14,9 +14,6 @@ ! So be careful with your serial/terminal, some adjustment may be necessary. TARGET_BAUD_RATE = 115200 -! System clock is running directly off the 19.2MHz crystal at initial reset -SYSTEM_CLOCK = 19200000 - GPFSEL1 = 0x7e200004 GPSET0 = 0x7e20001C GPCLR0 = 0x7e200028 @@ -102,7 +99,10 @@ delay2: st r0, (r1) mov r1, #AUX_MU_BAUD_REG - mov r0, #[[SYSTEM_CLOCK/[TARGET_BAUD_RATE*8]]-1] + ld r0, _pi_clock_speed + mov r2, #TARGET_BAUD_RATE*8 + divu r0, r0, r2 + sub r0, #1 st r0, (r1) mov r1, #AUX_MU_LCR_REG @@ -176,3 +176,10 @@ recvwait: b lr .comm __uart_status, 1 + +.sect .data +.define _pi_clock_speed + +! System clock is running directly off the 19.2MHz crystal at initial reset +_pi_clock_speed: + .data4 19200000 From 2b3f95de0bcab8b5d037095d8dfff0ba3b61c0dd Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 26 Jun 2013 23:32:54 +0100 Subject: [PATCH 097/231] Fix jump range checking in the addcmpb family of instructions. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index de2bda2ad..350806e11 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -394,7 +394,7 @@ static void branch_addcmp_common(quad opcode, int bits, struct expr_t* expr) d -= DOTGAIN; d /= 2; - if (!fitx(d, bits)) + if ((pass == 2) && !fitx(d, bits)) serror("target of branch is too far away"); emit2(opcode | maskx(d, bits)); From 29af6f1adbdd7deb17851ce9e166d0d27dadf4c9 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 27 Jun 2013 11:25:50 +0100 Subject: [PATCH 098/231] ISA change: clz has been renamed to log2. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index 0ae247226..502894a9f 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -106,7 +106,7 @@ 0, OP_ALU, B8(00011000), "exts", 0, OP_ALU, B8(00011001), "neg", 0, OP_ALU, B8(00011010), "lsr", -0, OP_ALU, B8(00011011), "clz", +0, OP_ALU, B8(00011011), "log2", 0, OP_ALU, B8(00011100), "lsl", 0, OP_ALU, B8(00011101), "brev", 0, OP_ALU, B8(00011110), "asr", @@ -145,4 +145,4 @@ 0, OP_MEM, B8(00000110), "ldhs", 0, OP_MEM, B8(00000111), "sths", -0, OP_LEA, 0, "lea", \ No newline at end of file +0, OP_LEA, 0, "lea", From edb174da8d16d7c7429a790c4ee985996f848105 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 29 Jun 2013 00:32:39 +0100 Subject: [PATCH 099/231] Fix incorrect encoding of 'push lr' and 'pop pc'. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 350806e11..e98f67594 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -174,13 +174,11 @@ void stack_instr(quad opcode, int loreg, int hireg, int extrareg) case 26: /* lr */ extrareg = 26; hireg = loreg = -1; - b = 0; break; case 31: /* pc */ extrareg = 31; hireg = loreg = -1; - b = 0; break; default: @@ -204,7 +202,10 @@ void stack_instr(quad opcode, int loreg, int hireg, int extrareg) serror("invalid register range"); if (hireg == -1) - m = 31; + { + b = 3; + m = 15; + } else m = hireg - loreg; From 8b6951dac002428c8a8585137418754cfeae1a56 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 29 Jun 2013 00:35:07 +0100 Subject: [PATCH 100/231] Fix incorrect offset encoding in lea (sp) instructions. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index e98f67594..5f10facf0 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -457,6 +457,7 @@ void lea_stack_instr(int rd, long va, int rs) if (rs != 25) serror("source register must be sp"); + va /= 4; if (!fitx(va, 6)) serror("offset too big to encode in instruction"); va = maskx(va, 6); From e36d739fa44c27e6bb1d3154d19bb1eaf4abb856 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 1 Jul 2013 13:05:36 +0100 Subject: [PATCH 101/231] Add (largely untested) float/int conversion. --HG-- branch : dtrg-videocore --- mach/vc4/as/mach1.c | 3 ++- mach/vc4/as/mach2.c | 1 + mach/vc4/as/mach3.c | 5 +++++ mach/vc4/as/mach4.c | 9 +++++++++ mach/vc4/as/mach5.c | 10 ++++++++++ mach/vc4/ncg/table | 47 ++++++++++++++++++++++----------------------- 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 315468f8e..44caf0c57 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -24,4 +24,5 @@ extern void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct extern void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr); extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr); extern void lea_stack_instr(int rd, long va, int rs); -extern void lea_address_instr(int rd, struct expr_t* expr); \ No newline at end of file +extern void lea_address_instr(int rd, struct expr_t* expr); +extern void fltcnv_instr(quad opcode, int cc, int rd, int ra, quad shift); diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c index 4c02efb39..ec7a948d8 100644 --- a/mach/vc4/as/mach2.c +++ b/mach/vc4/as/mach2.c @@ -17,6 +17,7 @@ %token OP_MEM %token OP_MISC %token OP_MISCL +%token OP_FLTCNV %token OP_STACK %token OP_LEA diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index 502894a9f..4ca73f4ed 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -130,6 +130,11 @@ 0, OP_MISC, B16(11001001,11100000), "exp2", 0, OP_MISC, B16(11000101,11100000), "adds256", +0, OP_FLTCNV, B16(11001010,00000000), "ftrunc", +0, OP_FLTCNV, B16(11001010,00100000), "floor", +0, OP_FLTCNV, B16(11001010,01000000), "flts", +0, OP_FLTCNV, B16(11001010,01100000), "fltu", + 0, OP_MISCL, B16(11000100,10000000), "divs", 0, OP_MISCL, B16(11000100,11100000), "divu", diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index ef0b50082..99c368c12 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -74,5 +74,14 @@ operation | OP_LEA GPR ',' absexp '(' GPR ')' { lea_stack_instr($2, $4, $6); } | OP_LEA GPR ',' expr { lea_address_instr($2, &$4); } + + | OP_FLTCNV GPR ',' GPR { fltcnv_instr($1, ALWAYS, $2, $4, 0); } + | OP_FLTCNV CC GPR ',' GPR { fltcnv_instr($1, $2, $3, $5, 0); } + | OP_FLTCNV GPR ',' GPR ',' shift '#' absexp { fltcnv_instr($1, ALWAYS, $2, $4, $8); } + | OP_FLTCNV CC GPR ',' GPR ',' shift '#' absexp { fltcnv_instr($1, $2, $3, $5, $9); } ; +shift + : 'l' 's' 'r' + | 'l' 's' 'l'; + diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 350806e11..9166f340e 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -487,3 +487,13 @@ void lea_address_instr(int rd, struct expr_t* expr) emit4(expr->val - pc); } +/* Floating point conversion opcodes (ftrunc, floor, flts, fltu). */ + +void fltcnv_instr(quad opcode, int cc, int rd, int ra, quad shift) +{ + fitx(shift, 6); + + emit2(opcode | (rd<<0)); + emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | shift); +} + diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table index 963fb74e1..8b4fe60a5 100644 --- a/mach/vc4/ncg/table +++ b/mach/vc4/ncg/table @@ -131,8 +131,11 @@ INSTRUCTIONS fadd GPR:wo, GPR:ro, GPR:ro. fcmp GPR:wo, GPR:ro, GPR:ro. fdiv GPR:wo, GPR:ro, GPR:ro. + flts GPR:wo, GPR:ro. + fltu GPR:wo, GPR:ro. fmul GPR:wo, GPR:ro, GPR:ro. fsub GPR:wo, GPR:ro, GPR:ro. + ftrunc GPR:wo, GPR:ro. ld GPR:wo, GPRINC:rw. ld GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. ldb GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. @@ -1511,36 +1514,32 @@ PATTERNS nop pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */ - leaving - loc 0 -#if 0 - cal ".cfi" - lfr QUAD -#endif + with GPR + uses reusing %1, REG + gen + ftrunc %a, %1 + yields %a pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */ - leaving - loc 0 -#if 0 - cal ".cfu" - lfr QUAD -#endif + with GPR + uses reusing %1, REG + gen + ftrunc %a, %1 + yields %a pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */ - leaving - loc 0 -#if 0 - cal ".cif" - lfr QUAD -#endif + with GPR + uses reusing %1, REG + gen + flts %a, %1 + yields %a pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */ - leaving - loc 0 -#if 0 - cal ".cuf" - lfr QUAD -#endif + with GPR + uses reusing %1, REG + gen + fltu %a, %1 + yields %a pat fef /* Split float */ leaving From 6a340ea1bd8798b7c538ab794d76c555d4fdedad Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 31 Aug 2014 13:40:39 +0200 Subject: [PATCH 102/231] Remove regrettable comment. --- util/grind/run.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/util/grind/run.c b/util/grind/run.c index 0b793ba13..ce19af8e3 100644 --- a/util/grind/run.c +++ b/util/grind/run.c @@ -114,9 +114,7 @@ start_child(p) char *in_redirect = 0; /* standard input redirected */ char *out_redirect = 0; /* standard output redirected */ - signal_child(SIGKILL); /* like families in China, this debugger is only - allowed one child - */ + signal_child(SIGKILL); if (p != run_command) { freenode(run_command); From 2271bcd0a705b67c4d30cfa3b32cfcb5c71be8ba Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 9 Nov 2014 18:47:51 +0100 Subject: [PATCH 103/231] Fixed a parallel build race condition (forgot to declare a dependency to the makefile). --- util/ncgg/build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk index c3a7f31fa..aaa81769f 100644 --- a/util/ncgg/build.mk +++ b/util/ncgg/build.mk @@ -26,7 +26,7 @@ $(call cfile, $D/var.c) $(call cfile, $D/hall.c) $(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c) -$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords +$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(OBJDIR)/$D/y.tab.h @echo KEYWORDS $$@ @mkdir -p $$(dir $$@) $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) From 3d5e72e20b3651895693eaf21eb415287546d212 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 22 Mar 2015 12:09:46 +0100 Subject: [PATCH 104/231] Newer versions of GNU Make have a new function which collides with a variable we're using; change the name of the variable. --- first/core.mk | 2 +- lang/basic/src/build.mk | 14 +++++++------- lang/cem/cemcom.ansi/build.mk | 20 ++++++++++---------- lang/cem/cpp.ansi/build.mk | 12 ++++++------ lang/m2/comp/build.mk | 20 ++++++++++---------- lang/m2/libm2/build.mk | 2 +- lang/pc/comp/build.mk | 20 ++++++++++---------- mach/proto/as/build.mk | 2 +- mach/proto/ncg/build.mk | 4 ++-- util/amisc/build.mk | 2 +- util/arch/build.mk | 8 ++++---- util/ego/build.mk | 10 +++++----- util/led/build.mk | 4 ++-- util/misc/build.mk | 28 ++++++++++++++-------------- util/ncgg/build.mk | 2 +- util/opt/build.mk | 21 ++++++++++++--------- util/topgen/build.mk | 10 +++++----- 17 files changed, 92 insertions(+), 89 deletions(-) diff --git a/first/core.mk b/first/core.mk index d2e32fc68..261a2c30e 100644 --- a/first/core.mk +++ b/first/core.mk @@ -51,7 +51,7 @@ endef # --- Add a raw to the queue -define file +define rawfile $(eval q += $1) endef diff --git a/lang/basic/src/build.mk b/lang/basic/src/build.mk index 00d429107..95019babd 100644 --- a/lang/basic/src/build.mk +++ b/lang/basic/src/build.mk @@ -29,13 +29,13 @@ $g: $D/maketokentab $(OBJDIR)/$D/Lpars.h $(eval $q: $(OBJDIR)/$D/Lpars.h) $(eval $q: $(INCDIR)/print.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSTRING)) -$(call file, $(LIBSYSTEM)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSTRING)) +$(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_bem) $(call installto, $(PLATDEP)/em_bem) diff --git a/lang/cem/cemcom.ansi/build.mk b/lang/cem/cemcom.ansi/build.mk index 0e6b45267..1f2b483ec 100644 --- a/lang/cem/cemcom.ansi/build.mk +++ b/lang/cem/cemcom.ansi/build.mk @@ -134,16 +134,16 @@ $(call build-cemcom-ansi-next, \ $(eval $q: $(OBJDIR)/$D/Lpars.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBINPUT)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBFLT_ARITH)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/cemcom.ansi) $(call installto, $(PLATDEP)/em_cemcom.ansi) $(eval CEMCOMANSI := $o) diff --git a/lang/cem/cpp.ansi/build.mk b/lang/cem/cpp.ansi/build.mk index e102c523b..be03bc958 100644 --- a/lang/cem/cpp.ansi/build.mk +++ b/lang/cem/cpp.ansi/build.mk @@ -71,12 +71,12 @@ define build-cpp-ansi-impl $(call llgen, $(OBJDIR)/$D, $(OBJDIR)/$D/tokenfile.g $D/expression.g) - $(call file, $(LIBINPUT)) - $(call file, $(LIBASSERT)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSYSTEM)) - $(call file, $(LIBSTRING)) + $(call rawfile, $(LIBINPUT)) + $(call rawfile, $(LIBASSERT)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSYSTEM)) + $(call rawfile, $(LIBSTRING)) $(call tabgen, $D/char.tab) diff --git a/lang/m2/comp/build.mk b/lang/m2/comp/build.mk index a3be0ee7a..18ca8b7dd 100644 --- a/lang/m2/comp/build.mk +++ b/lang/m2/comp/build.mk @@ -108,16 +108,16 @@ $(eval $q: $(INCDIR)/em_codeEK.h) $(eval $q: $(INCDIR)/print.h) $(eval $q: $(INCDIR)/system.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBINPUT)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBFLT_ARITH)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/em_m2) $(call installto, $(PLATDEP)/em_m2) diff --git a/lang/m2/libm2/build.mk b/lang/m2/libm2/build.mk index 7dadeb347..1ebc89cc3 100644 --- a/lang/m2/libm2/build.mk +++ b/lang/m2/libm2/build.mk @@ -95,7 +95,7 @@ $(eval g := \ $(foreach f, $g, \ $(call reset) \ - $(call file, lang/m2/libm2/$f) \ + $(call rawfile, lang/m2/libm2/$f) \ $(call installto, $(PLATIND)/include/modula2/$f)) endef diff --git a/lang/pc/comp/build.mk b/lang/pc/comp/build.mk index 2939c4524..c3b4dd918 100644 --- a/lang/pc/comp/build.mk +++ b/lang/pc/comp/build.mk @@ -111,16 +111,16 @@ $(eval $q: $(INCDIR)/em_codeEK.h) $(eval $q: $(INCDIR)/print.h) $(eval $q: $(INCDIR)/system.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBINPUT)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBFLT_ARITH)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/em_pc) $(call installto, $(PLATDEP)/em_pc) diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 64eaab1e9..fce5ec204 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -36,7 +36,7 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ -Ih \ mach/proto/as/comm2.y > $$@ - $(call file, $(LIBOBJECT)) + $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/$(PLATFORM)/as) $(call installto, $(PLATDEP)/$(PLATFORM)/as) endef diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index 1bbda2b49..0056452c1 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -36,8 +36,8 @@ $(call cfile, $(OBJDIR)/$D/tables.c) $(eval $q: $(INCDIR)/flt_arith.h) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBFLT_ARITH)) $(call cprogram, $(BINDIR)/$(PLATFORM)/ncg) $(call installto, $(PLATDEP)/$(PLATFORM)/ncg) diff --git a/util/amisc/build.mk b/util/amisc/build.mk index 03f44b5e9..286b8f305 100644 --- a/util/amisc/build.mk +++ b/util/amisc/build.mk @@ -2,7 +2,7 @@ define build-simple-tool-impl $(call reset) $(call cfile, util/amisc/$1.c) - $(call file, $(LIBOBJECT)) + $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/$1) $(eval INSTALLABLES += $o) $(call installto, $(INSDIR)/bin/$1) diff --git a/util/arch/build.mk b/util/arch/build.mk index 4d283f881..11851f5c9 100644 --- a/util/arch/build.mk +++ b/util/arch/build.mk @@ -6,10 +6,10 @@ define build-aal-impl $(call cfile, $D/archiver.c) - $(call file, $(LIBOBJECT)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSTRING)) - $(call file, $(LIBSYSTEM)) + $(call rawfile, $(LIBOBJECT)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/aal) $(call installto, $(INSDIR)/bin/aal) diff --git a/util/ego/build.mk b/util/ego/build.mk index ee1e7f865..2fba61ff3 100644 --- a/util/ego/build.mk +++ b/util/ego/build.mk @@ -6,8 +6,8 @@ $(call reset) $(eval cflags += -DVERBOSE -DNOTCOMPACT) $(eval cflags += -I$D/share -I$(OBJDIR)/$D) $(foreach f, $2, $(call cfile, $f)) -$(call file, $(LIBDIR)/libegocore.a) -$(call file, $(LIBEM_DATA)) +$(call rawfile, $(LIBDIR)/libegocore.a) +$(call rawfile, $(LIBEM_DATA)) $(call cprogram, $(BINDIR)/ego/$(strip $1)) $(call installto, $(PLATDEP)/ego/$(strip $1)) $(eval EGO_MODULES += $q) @@ -166,9 +166,9 @@ $(call cfile, $D/em_ego/em_ego.c) $(eval $q: $(INCDIR)/print.h $(INCDIR)/system.h) $(eval $q: $(INCDIR)/em_path.h) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSTRING)) -$(call file, $(LIBSYSTEM)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSTRING)) +$(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_ego) $(call installto, $(PLATDEP)/em_ego) diff --git a/util/led/build.mk b/util/led/build.mk index d96dd35c6..419948a13 100644 --- a/util/led/build.mk +++ b/util/led/build.mk @@ -16,8 +16,8 @@ define build-led-impl $(call cfile, $D/sym.c) $(call cfile, $D/write.c) - $(call file, $(LIBSTRING)) - $(call file, $(LIBOBJECT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/em_led) $(call installto, $(PLATDEP)/em_led) diff --git a/util/misc/build.mk b/util/misc/build.mk index dfa8ac7c1..95b6fb2d9 100644 --- a/util/misc/build.mk +++ b/util/misc/build.mk @@ -14,13 +14,13 @@ define build-misc-impl $(eval objdir := encode) $(call cfile, $D/convert.c) $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) - $(call file, $(LIBREAD_EMEV)) - $(call file, $(LIBEMK)) - $(call file, $(LIBEM_DATA)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSTRING)) - $(call file, $(LIBSYSTEM)) + $(call rawfile, $(LIBREAD_EMEV)) + $(call rawfile, $(LIBEMK)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_encode) $(call installto, $(PLATDEP)/em_encode) $(eval EM_ENCODE := $o) @@ -30,13 +30,13 @@ define build-misc-impl $(eval objdir := decode) $(call cfile, $D/convert.c) $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) - $(call file, $(LIBREAD_EMKV)) - $(call file, $(LIBEME)) - $(call file, $(LIBEM_DATA)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSTRING)) - $(call file, $(LIBSYSTEM)) + $(call rawfile, $(LIBREAD_EMKV)) + $(call rawfile, $(LIBEME)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_decode) $(call installto, $(PLATDEP)/em_decode) $(eval EM_DECODE := $o) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk index c3a7f31fa..b0ee29d21 100644 --- a/util/ncgg/build.mk +++ b/util/ncgg/build.mk @@ -34,7 +34,7 @@ $(call cfile, $(OBJDIR)/$D/enterkeyw.c) $(eval $q: $(INCDIR)/em_spec.h) -$(call file, $(LIBEM_DATA)) +$(call rawfile, $(LIBEM_DATA)) $(call cprogram, $(BINDIR)/ncgg) $(eval NCGG := $o) diff --git a/util/opt/build.mk b/util/opt/build.mk index 39eafe355..75cb92553 100644 --- a/util/opt/build.mk +++ b/util/opt/build.mk @@ -10,12 +10,15 @@ $(call yacc, $(OBJDIR)/$D, $D/mktab.y) $(call flex, $(OBJDIR)/$D, $D/scan.l) $(call dependson, $(OBJDIR)/$D/y.tab.h) -$(call file, $(LIBEM_DATA)) -$(call file, -lfl) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, -lfl) $(call cprogram, $(OBJDIR)/$D/mktab) endef +.PHONY: -lfl +-lfl: + define build-opt-impl $(call reset) @@ -53,12 +56,12 @@ $g: $(OBJDIR)/$D/mktab $D/patterns $(BINDIR)/cpp.ansi $(hide) $(BINDIR)/cpp.ansi < $D/patterns | $(OBJDIR)/$D/mktab > $$@ $(call cfile, $g) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(eval $q: $(INCDIR)/em_spec.h) @@ -79,4 +82,4 @@ endef $(eval $(build-opt-mktab-impl)) $(eval $(call build-opt-impl, em_opt,)) $(eval $(call build-opt-impl, em_opt2, -DGLOBAL_OPT)) -$(eval $(build-opt-manpage-impl)) \ No newline at end of file +$(eval $(build-opt-manpage-impl)) diff --git a/util/topgen/build.mk b/util/topgen/build.mk index 4ef15c278..9bf48a4d3 100644 --- a/util/topgen/build.mk +++ b/util/topgen/build.mk @@ -15,11 +15,11 @@ define build-topgen-impl $(call llgen, $(OBJDIR)/$D, $D/topgen.g) - $(call file, $(LIBASSERT)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBSYSTEM)) - $(call file, $(LIBSTRING)) + $(call rawfile, $(LIBASSERT)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBSYSTEM)) + $(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/topgen) TOPGEN := $o From c5018d70880641643090602b7d9118e7b40bf3cc Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:07:59 +0100 Subject: [PATCH 105/231] 64-bit-ify (adhoc varargs are evil). --- mach/proto/as/comm0.h | 1 + mach/proto/as/comm1.h | 4 +++ mach/proto/as/comm7.c | 63 ++++++++++++++++++++++++++----------------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 11f1231a9..4996350ac 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -265,3 +265,4 @@ typedef struct sect_t sect_t; #endif extern FILE *fopen(); /* some systems don't have this in stdio.h */ + diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index 7e4620471..6a40a2e90 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -116,6 +116,10 @@ extern valu_t load(); extern FILE *ffcreat(); extern FILE *fftemp(); +extern void fatal(const char* s, ...); +extern void serror(const char* s, ...); +extern void warning(const char* s, ...); + /* ========== Machine dependent C declarations ========== */ #include "mach1.c" diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index d0a147bdb..3c7871fbe 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -11,6 +11,7 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include valu_t load(ip) @@ -27,7 +28,7 @@ register item_t *ip; if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) { if (pass == PASS_3) { if (relonami != 0) - serror("relocation error"); + serror("relocation error (relonami=%d, type=%08x)", relonami, ip->i_type); relonami = ip->i_valu+1; } return(0); @@ -380,13 +381,28 @@ wr_fatal() fatal("write error"); } -/* VARARGS1 */ -fatal(s, a1, a2, a3, a4) -char *s; +void diag(const char* tail, const char* s, va_list ap) { + fflush(stdout); + if (modulename) + fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno); + else + fprintf(stderr, "%s: ", progname); + vfprintf(stderr, s, ap); + fprintf(stderr, "%s", tail); +} + +/* VARARGS1 */ +void fatal(const char* s, ...) +{ + va_list ap; + va_start(ap, s); + nerrors++; - diag(" (fatal)\n", s, a1, a2, a3, a4); + diag(" (fatal)\n", s, ap); stop(); + + va_end(ap); } #if DEBUG == 2 @@ -400,37 +416,34 @@ char *file; #if DEBUG == 1 assert1() { - diag(" (fatal)\n", "assertion failed"); + fatal("assertion failed"); abort(); } #endif -/* VARARGS1 */ -serror(s, a1, a2, a3, a4) -char *s; +void serror(const char* s, ...) { + va_list ap; + va_start(ap, s); + nerrors++; - diag("\n", s, a1, a2, a3, a4); + diag("\n", s, ap); + stop(); + + va_end(ap); } /* VARARGS1 */ -warning(s, a1, a2, a3, a4) -char *s; +void warning(const char* s, ...) { - diag(" (warning)\n", s, a1, a2, a3, a4); -} + va_list ap; + va_start(ap, s); -/* VARARGS1 */ -diag(tail, s, a1, a2, a3, a4) -char *tail, *s; -{ - fflush(stdout); - if (modulename) - fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno); - else - fprintf(stderr, "%s: ", progname); - fprintf(stderr, s, a1, a2, a3, a4); - fprintf(stderr, tail); + nerrors++; + diag(" (warning)\n", s, ap); + stop(); + + va_end(ap); } nofit() From 9f23fbbe6a8f32dba3fa6aa7acf776b081d14af9 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:08:51 +0100 Subject: [PATCH 106/231] Allow machines to use cg if they wish. --HG-- rename : mach/proto/ncg/build.mk => mach/proto/cg/build.mk rename : util/ncgg/build.mk => util/cgg/build.mk --- mach/proto/cg/build.mk | 46 ++++++++++++++++++++++++++++++++++++++++++ plat/build.mk | 4 ++-- util/cgg/build.mk | 25 +++++++++++++++++++++++ util/cgg/main.c | 5 +++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 mach/proto/cg/build.mk create mode 100644 util/cgg/build.mk diff --git a/mach/proto/cg/build.mk b/mach/proto/cg/build.mk new file mode 100644 index 000000000..2327009e0 --- /dev/null +++ b/mach/proto/cg/build.mk @@ -0,0 +1,46 @@ +define build-cg-impl + +$(call reset) + +$(eval cflags += -Imach/$(ARCH)/cg -I$(OBJDIR)/$D -Imach/proto/cg) +$(eval objdir := $(ARCH)) + +$(call cfile, mach/proto/cg/codegen.c) +$(call cfile, mach/proto/cg/compute.c) +$(call cfile, mach/proto/cg/equiv.c) +$(call cfile, mach/proto/cg/fillem.c) +$(call cfile, mach/proto/cg/gencode.c) +$(call cfile, mach/proto/cg/glosym.c) +$(call cfile, mach/proto/cg/main.c) +$(call cfile, mach/proto/cg/move.c) +$(call cfile, mach/proto/cg/nextem.c) +$(call cfile, mach/proto/cg/reg.c) +$(call cfile, mach/proto/cg/regvar.c) +$(call cfile, mach/proto/cg/salloc.c) +$(call cfile, mach/proto/cg/state.c) +$(call cfile, mach/proto/cg/subr.c) +$(call cfile, mach/proto/cg/var.c) + +$(eval $q: $(OBJDIR)/$D/tables.h) +$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.c) +$(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h +$(OBJDIR)/$D/tables.h: $(CGG) $(CPPANSI) mach/$(ARCH)/cg/table + @echo CGG $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $$(dir $$@) && \ + $(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/cg) $(abspath mach/$(ARCH)/cg/table) | $(abspath $(CGG)) + +$(call cfile, $(OBJDIR)/$D/tables.c) + +$(eval $q: $(INCDIR)/flt_arith.h) + +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBFLT_ARITH)) + +$(call cprogram, $(BINDIR)/$(PLATFORM)/cg) +$(call installto, $(PLATDEP)/$(PLATFORM)/cg) + +endef + +build-cg = $(eval $(build-cg-impl)) + diff --git a/plat/build.mk b/plat/build.mk index aff84c04c..623658b07 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -17,7 +17,7 @@ define build-platform-impl $(PLATIND)/descr/$(PLATFORM) \ $(PLATFORM_HEADERS_$(PLATFORM)) \ $(PLATDEP)/$(PLATFORM)/as \ - $(PLATDEP)/$(PLATFORM)/ncg \ + $(if $(arch-cg-$(ARCH)), $(PLATDEP)/$(PLATFORM)/cg, $(PLATDEP)/$(PLATFORM)/ncg) \ $(ARCHITECTURE_$(ARCH))) # libsys @@ -48,7 +48,7 @@ define build-platform-impl # The tools themselves $(call build-as) - $(call build-ncg) + $(if $(arch-cg-$(ARCH)), $(call build-cg), $(call build-ncg)) # Build top only if the architecture asks for it. diff --git a/util/cgg/build.mk b/util/cgg/build.mk new file mode 100644 index 000000000..4fc8532b2 --- /dev/null +++ b/util/cgg/build.mk @@ -0,0 +1,25 @@ +D := util/cgg + +define build-cgg-impl + +$(call reset) +$(eval cflags += -I$D) + +$(call yacc, $(OBJDIR)/$D, $D/bootgram.y) + +$(call flex, $(OBJDIR)/$D, $D/bootlex.l) +$(call dependson, $(OBJDIR)/$D/y.tab.h) + +$(call cfile, $D/main.c) + +$(eval $q: $(INCDIR)/em_spec.h) + +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBSYSTEM)) +$(call cprogram, $(BINDIR)/cgg) +$(eval CGG := $o) + +endef + +$(eval $(build-cgg-impl)) diff --git a/util/cgg/main.c b/util/cgg/main.c index fba8e31b5..86375b776 100644 --- a/util/cgg/main.c +++ b/util/cgg/main.c @@ -1009,3 +1009,8 @@ max(a,b) { return(a); return(b); } + +int yywrap(void) { + return 1; +} + From 98ea849d031b68508970a13ebd17823d5532819e Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:09:27 +0100 Subject: [PATCH 107/231] Improve flex correctness. --- util/opt/build.mk | 1 - util/opt/mktab.y | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/util/opt/build.mk b/util/opt/build.mk index 75cb92553..a4e62ced7 100644 --- a/util/opt/build.mk +++ b/util/opt/build.mk @@ -11,7 +11,6 @@ $(call flex, $(OBJDIR)/$D, $D/scan.l) $(call dependson, $(OBJDIR)/$D/y.tab.h) $(call rawfile, $(LIBEM_DATA)) -$(call rawfile, -lfl) $(call cprogram, $(OBJDIR)/$D/mktab) endef diff --git a/util/opt/mktab.y b/util/opt/mktab.y index 08beaeccc..e2a6c0b1a 100644 --- a/util/opt/mktab.y +++ b/util/opt/mktab.y @@ -294,6 +294,10 @@ main() { return nerrors; } +int yywrap(void) { + return 1; +} + yyerror(s) char *s; { fprintf(stderr,"line %d: %s\n",lino,s); From b146d2641c494ddf97d24aebcc888e7e45cd528d Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:09:41 +0100 Subject: [PATCH 108/231] Fix a slightly mysterious dependency issue. --- util/data/build.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/data/build.mk b/util/data/build.mk index 424712956..b6b5c7cea 100644 --- a/util/data/build.mk +++ b/util/data/build.mk @@ -3,12 +3,13 @@ D := util/data define util-data-impl $(eval g := \ + $(OBJDIR)/$D/em_flag.c \ + $(OBJDIR)/$D/em_pseu.c \ + $(OBJDIR)/$D/em_mnem.c \ $(INCDIR)/em_spec.h \ $(INCDIR)/em_pseu.h \ $(INCDIR)/em_mnem.h \ - $(OBJDIR)/$D/em_flag.c \ - $(OBJDIR)/$D/em_pseu.c \ - $(OBJDIR)/$D/em_mnem.c) +) $(eval CLEANABLES += $g) $(wordlist 2, $(words $g), $g): $(firstword $g) From 171f16d7b8884dec5d915410e774a60a9d24f0cc Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 18 Jun 2015 23:38:50 +0200 Subject: [PATCH 109/231] Rename branch. --HG-- branch : dtrg-videocore-branch From ff774212beacd5da20bf2c1092bd2a6b30f4730c Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 18 Jun 2015 23:39:25 +0200 Subject: [PATCH 110/231] Rename branch. --HG-- branch : default-branch From f07c6e4d6a62694b8907c5f5c8b53f6504b94e8b Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 18 Jun 2015 23:39:25 +0200 Subject: [PATCH 111/231] Rename branch. --HG-- branch : dtrg-videocore-branch-branch From 5e9f79db0510df8bb734bd7bcbcccfcfb9cbd754 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 19 Jun 2015 22:07:16 +0200 Subject: [PATCH 112/231] Add Travis config file. --HG-- branch : default-branch --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e0f0a1abf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: c +script: + - make PREFIX=/tmp/acki -j4 + From 4c5eb9a602eb34926c4636702f58bc24d83b4c05 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 19 Jun 2015 22:14:09 +0200 Subject: [PATCH 113/231] The ACK needs ed? Also, Ubuntu doesn't *have* ed? --HG-- branch : default-branch --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e0f0a1abf..dd9fd3e0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +before_install: + - sudo apt-get install ed language: c script: - make PREFIX=/tmp/acki -j4 From e85991ec861477a5ab7f26934bcb2b1629e93bc8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 13 Mar 2016 21:40:05 +0100 Subject: [PATCH 114/231] Fix stray 'call file'. --HG-- branch : default-branch --- mach/proto/as/build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 726cd676e..d11ccf2b6 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -43,7 +43,7 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ $(call installto, $(PLATDEP)/$(PLATFORM)/as) $(call reset) - $(call file, man/$(ARCH)_as.6) + $(call rawfile, man/$(ARCH)_as.6) $(call installto, $(INSDIR)/share/man/man6/$(ARCH)_as.6) endef From 88e13ecce3125a163b92158d646600e5dcdf5d3d Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 14 Mar 2016 20:58:19 +0100 Subject: [PATCH 115/231] Don't use the ACK preprocessor on host files --- use the host preprocessor instead. --HG-- branch : default-branch --- first/core.mk | 20 ++++++++++++++++++++ mach/proto/as/build.mk | 20 ++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/first/core.mk b/first/core.mk index 0ee653a1c..6c386d0f5 100644 --- a/first/core.mk +++ b/first/core.mk @@ -28,6 +28,26 @@ define cfile $(eval $(cfile-rule)) endef +# --- Host preprocessor + +define cppfile-rule +$o: $s + @echo CPP $o + @mkdir -p $(dir $o) + @$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d -x c $s + $(hide) $(CC) $(CFLAGS) $(cflags) -E -P -o $o -x c $s +endef + +define cppfile + $(eval s := $1) + $(eval o := $(OBJDIR)/$(objdir)/$(1:=.m)) + $(eval d := $(OBJDIR)/$(objdir)/$(1:=.d)) + $(eval DEPENDS += $d) + $(eval CLEANABLES += $o $d) + $(eval q += $o) + $(eval $(cppfile-rule)) +endef + # --- ACK compiler define ackfile-rule diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index d11ccf2b6..64c75cf91 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -24,24 +24,16 @@ define build-as-impl $(call yacc, $(OBJDIR)/$D, $(OBJDIR)/$D/preprocessed-comm2.y) -$(eval CLEANABLES += $(OBJDIR)/$D/preprocessed-comm2.y) -$(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ - mach/$(ARCH)/as/mach1.c \ - mach/$(ARCH)/as/mach2.c \ - mach/$(ARCH)/as/mach3.c \ - mach/$(ARCH)/as/mach4.c - @echo PREPROCESS $$@ - @mkdir -p $$(dir $$@) - $(hide) $(CPPANSI) -P \ - -Imach/$(ARCH)/as \ - -Imach/proto/as \ - -Ih \ - mach/proto/as/comm2.y > $$@ - $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/$(PLATFORM)/as) $(call installto, $(PLATDEP)/$(PLATFORM)/as) + $(call reset) + $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D) + $(eval objdir := $(ARCH)) + $(call cppfile, mach/proto/as/comm2.y) + $(call installto, $(OBJDIR)/$D/preprocessed-comm2.y) + $(call reset) $(call rawfile, man/$(ARCH)_as.6) $(call installto, $(INSDIR)/share/man/man6/$(ARCH)_as.6) From 7e964dd25ed37930144dab92d484b9e2dd1b1471 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 14 Mar 2016 21:08:55 +0100 Subject: [PATCH 116/231] Raise the limit on ack.out relocation types by making the size of a relocation structure bigger. Bump ack.out magic number. --HG-- branch : default-branch --- h/out.h | 54 +++++++++++++++++++++++++--------------------- util/led/ack.out.5 | 49 ++++++++++++++++++++--------------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/h/out.h b/h/out.h index cf6ef7776..16c22be51 100644 --- a/h/out.h +++ b/h/out.h @@ -6,22 +6,25 @@ #ifndef __OUT_H_INCLUDED #define __OUT_H_INCLUDED + +#include + /* * output format for ACK assemblers */ struct outhead { - unsigned short oh_magic; /* magic number */ - unsigned short oh_stamp; /* version stamp */ - unsigned short oh_flags; /* several format flags */ - unsigned short oh_nsect; /* number of outsect structures */ - unsigned short oh_nrelo; /* number of outrelo structures */ - unsigned short oh_nname; /* number of outname structures */ - long oh_nemit; /* sum of all os_flen */ - long oh_nchar; /* size of string area */ + uint16_t oh_magic; /* magic number */ + uint16_t oh_stamp; /* version stamp */ + uint16_t oh_flags; /* several format flags */ + uint16_t oh_nsect; /* number of outsect structures */ + uint16_t oh_nrelo; /* number of outrelo structures */ + uint16_t oh_nname; /* number of outname structures */ + uint32_t oh_nemit; /* sum of all os_flen */ + uint32_t oh_nchar; /* size of string area */ }; -#define O_MAGIC 0x0201 /* magic number of output file */ +#define O_MAGIC 0x0202 /* magic number of output file */ #define O_STAMP 0 /* version stamp */ #define MAXSECT 64 /* Maximum number of sections */ @@ -29,18 +32,19 @@ struct outhead { #define HF_8086 0x0008 /* os_base specially encoded */ struct outsect { - long os_base; /* startaddress in machine */ - long os_size; /* section size in machine */ - long os_foff; /* startaddress in file */ - long os_flen; /* section size in file */ - long os_lign; /* section alignment */ + uint32_t os_base; /* startaddress in machine */ + uint32_t os_size; /* section size in machine */ + uint32_t os_foff; /* startaddress in file */ + uint32_t os_flen; /* section size in file */ + uint32_t os_lign; /* section alignment */ }; struct outrelo { - char or_type; /* type of reference */ - char or_sect; /* referencing section */ - unsigned short or_nami; /* referenced symbol index */ - long or_addr; /* referencing address */ + uint16_t or_type; /* type of reference */ + uint16_t or_sect; /* referencing section */ + uint16_t or_nami; /* referenced symbol index */ + uint16_t _padding; /* padding for alignment */ + uint32_t or_addr; /* referencing address */ }; struct outname { @@ -50,15 +54,15 @@ struct outname { } on_u; #define on_mptr on_u.on_ptr #define on_foff on_u.on_off - unsigned short on_type; /* symbol type */ - unsigned short on_desc; /* debug info */ - long on_valu; /* symbol value */ + uint16_t on_type; /* symbol type */ + uint16_t on_desc; /* debug info */ + uint32_t on_valu; /* symbol value */ }; /* * relocation type bits */ -#define RELSZ 0x07 /* relocation length */ +#define RELSZ 0x0fff /* relocation length */ #define RELO1 1 /* 1 byte */ #define RELO2 2 /* 2 bytes */ #define RELO4 3 /* 4 bytes */ @@ -66,9 +70,9 @@ struct outname { #define RELOH2 5 /* write top 2 bytes of 4 byte word */ #define RELOVC4 6 /* VideoCore IV address in 32-bit instruction */ -#define RELPC 0x08 /* pc relative */ -#define RELBR 0x10 /* High order byte lowest address. */ -#define RELWR 0x20 /* High order word lowest address. */ +#define RELPC 0x2000 /* pc relative */ +#define RELBR 0x4000 /* High order byte lowest address. */ +#define RELWR 0x8000 /* High order word lowest address. */ /* * section type bits and fields diff --git a/util/led/ack.out.5 b/util/led/ack.out.5 index d9e24bff6..3932a7f25 100644 --- a/util/led/ack.out.5 +++ b/util/led/ack.out.5 @@ -44,14 +44,14 @@ The header of an object file has the following structure: .PP .nf struct outhead { - unsigned short oh_magic; /* magic number */ - unsigned short oh_stamp; /* version stamp */ - unsigned short oh_flags; /* several format flags */ - unsigned short oh_nsect; /* number of outsect structures */ - unsigned short oh_nrelo; /* number of outrelo structures */ - unsigned short oh_nname; /* number of outname structures */ - long oh_nemit; /* length of sections */ - long oh_nchar; /* size of string area */ + uint16_t oh_magic; /* magic number */ + uint16_t oh_stamp; /* version stamp */ + uint16_t oh_flags; /* several format flags */ + uint16_t oh_nsect; /* number of outsect structures */ + uint16_t oh_nrelo; /* number of outrelo structures */ + uint16_t oh_nname; /* number of outname structures */ + uint32_t oh_nemit; /* length of sections */ + uint32_t oh_nchar; /* size of string area */ }; .fi .PP @@ -92,11 +92,11 @@ An outsect structure has the following layout: .PP .nf struct outsect { - long os_base; /* start address in machine */ - long os_size; /* section size in machine */ - long os_foff; /* start address in file */ - long os_flen; /* section size in file */ - long os_lign; /* section alignment */ + uint32_t os_base; /* start address in machine */ + uint32_t os_size; /* section size in machine */ + uint32_t os_foff; /* start address in file */ + uint32_t os_flen; /* section size in file */ + uint32_t os_lign; /* section alignment */ }; .fi .PP @@ -147,10 +147,11 @@ relocatable datum. The information has the following structure: .PP .nf struct outrelo { - char or_type; /* type of reference */ - char or_sect; /* referencing section */ - unsigned short or_nami; /* referenced symbol index */ - long or_addr; /* referencing address */ + uint16_t or_type; /* type of reference */ + uint16_t or_sect; /* referencing section */ + uint16_t or_nami; /* referenced symbol index */ + uint16_t _padding; /* padding for alignment; ignore */ + uint32_t or_addr; /* referencing address */ }; .fi .PP @@ -158,16 +159,16 @@ struct outrelo { /* * relocation type bits */ -#define RELSZ 0x07 /* relocation length */ +#define RELSZ 0x0fffi /* relocation length */ #define RELO1 0x01 /* 1 byte */ #define RELO2 0x02 /* 2 bytes */ #define RELO4 0x03 /* 4 bytes */ #define RELOPPC 0x04 /* 26-bit PowerPC address */ #define RELOH2 0x05 /* write top 2 bytes of 4 byte word */ #define RELOVC4 0x06 /* VideoCore IV address in 32-bit insruction */ -#define RELPC 0x08 /* pc relative */ -#define RELBR 0x10 /* High order byte lowest address. */ -#define RELWR 0x20 /* High order word lowest address. */ +#define RELPC 0x2000 /* pc relative */ +#define RELBR 0x4000 /* High order byte lowest address. */ +#define RELWR 0x8000 /* High order word lowest address. */ .fi .PP .nf @@ -232,9 +233,9 @@ struct outname { } on_u; #define on_mptr on_u.on_ptr #define on_foff on_u.on_off - unsigned short on_type; /* symbol type */ - unsigned short on_desc; /* debug info */ - long on_valu; /* symbol value */ + uint16_t on_type; /* symbol type */ + uint16_t on_desc; /* debug info */ + uint32_t on_valu; /* symbol value */ }; .fi .PP From b7b449cec355b1635db34996b2f3a0fb39d8231f Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 17 Mar 2016 20:52:15 +0100 Subject: [PATCH 117/231] Install directory now defaults to INSDIR, for ease of use during development. --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e203d3243..5a92bb593 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,12 @@ DEFAULT_PLATFORM = pc86 ACK_TEMP_DIR = /tmp -# Where is the ACK going to be installed, eventually? +# Where is the ACK going to be installed, eventually? If you don't want to +# install it and just want to run the ACK from the build directory +# (/tmp/ack-build/staging, by default), leave this as $(INSDIR). -PREFIX = /usr/local +#PREFIX = /usr/local +PREFIX = $(INSDIR) # Where do you want to put the object files used when building? From 863b61014470ca9397a1904472e8fc1e6791023e Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 17 Mar 2016 20:52:27 +0100 Subject: [PATCH 118/231] Fix use-after-free. --- lang/cem/cemcom.ansi/input.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lang/cem/cemcom.ansi/input.c b/lang/cem/cemcom.ansi/input.c index fc1e99f28..2b652b64f 100644 --- a/lang/cem/cemcom.ansi/input.c +++ b/lang/cem/cemcom.ansi/input.c @@ -82,10 +82,9 @@ AtEoIF() } IncludeLevel--; #endif - if (WorkingDir[0] != '\0') free(WorkingDir); + /* We don't free WorkingDir and FileName here because the rest of the + * compiler may be holding pointers to them for displaying error messages. + */ #endif /* NOPP */ -#ifndef LINT - if (FileName != source) free(FileName); -#endif return 0; } From fd7e9f9046115683d9227264cfe86e394c9a0e36 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 17 Mar 2016 22:30:24 +0100 Subject: [PATCH 119/231] Fix an insidious 64-bitness bug which was causing incorrectly optimised code. --HG-- branch : default-branch --- util/opt/peephole.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/opt/peephole.c b/util/opt/peephole.c index 236fe1bda..ccce6a9c0 100644 --- a/util/opt/peephole.c +++ b/util/opt/peephole.c @@ -417,14 +417,14 @@ eval_t compute(pexp) register expr_p pexp; { case EX_SFIT: mask = 0; for (i=leaf2.e_v.e_con - 1;i < 8*sizeof(offset); i++) - mask |= 1< Date: Fri, 18 Mar 2016 21:46:55 +0100 Subject: [PATCH 120/231] Fix a whole pile of issues related to the failed attempt to increase the number of types of relocation possible in the object file. (Now, hopefully, working.) Also change the object serialiser/deserialiser to never try to read or write raw structures; it's way safer this way and we don't need the performance boost any more. --HG-- branch : default-branch --- h/out.h | 15 +------------- mach/proto/as/comm6.c | 4 ++-- modules/src/object/obj.h | 36 +++++++--------------------------- modules/src/object/rd.c | 30 +++++++++------------------- modules/src/object/rd_ranlib.c | 3 --- modules/src/object/wr.c | 32 +++--------------------------- modules/src/object/wr_ranlib.c | 3 --- util/led/ack.out.5 | 12 +----------- util/led/relocate.c | 15 ++++---------- 9 files changed, 27 insertions(+), 123 deletions(-) diff --git a/h/out.h b/h/out.h index 16c22be51..30cb6ba69 100644 --- a/h/out.h +++ b/h/out.h @@ -43,7 +43,6 @@ struct outrelo { uint16_t or_type; /* type of reference */ uint16_t or_sect; /* referencing section */ uint16_t or_nami; /* referenced symbol index */ - uint16_t _padding; /* padding for alignment */ uint32_t or_addr; /* referencing address */ }; @@ -102,18 +101,6 @@ struct outname { reserved for debuggers */ -/* - * structure format strings - */ -#if 0 -/* The following strings only make sense on 32-bit platforms, so we're going - * to try and deprecate them. */ -#define SF_HEAD "22222244" -#define SF_SECT "44444" -#define SF_RELO "1124" -#define SF_NAME "4224" -#endif - /* * structure sizes on disk (bytes in file; add digits in SF_*) * Note! These are NOT the sizes in memory (64-bit architectures will have @@ -121,7 +108,7 @@ struct outname { */ #define SZ_HEAD 20 #define SZ_SECT 20 -#define SZ_RELO 8 +#define SZ_RELO 10 #define SZ_NAME 12 /* diff --git a/mach/proto/as/comm6.c b/mach/proto/as/comm6.c index 5c51d34e5..f5bd87f39 100644 --- a/mach/proto/as/comm6.c +++ b/mach/proto/as/comm6.c @@ -281,8 +281,8 @@ newrelo(s, n) return; } s &= ~S_VAR; - outrelo.or_type = (char)n; - outrelo.or_sect = (char)DOTTYP; + outrelo.or_type = n; + outrelo.or_sect = DOTTYP; #ifndef ASLD if (s == S_UND || iscomm) { assert(relonami != 0); diff --git a/modules/src/object/obj.h b/modules/src/object/obj.h index a725ed5bd..8f7fd8d32 100644 --- a/modules/src/object/obj.h +++ b/modules/src/object/obj.h @@ -15,38 +15,16 @@ #define CHAR_UNSIGNED 0 #endif -#if CHAR_UNSIGNED -#define Xchar(ch) (ch) -#else -#define Xchar(ch) ((ch) & 0377) -#endif +#define Xchar(ch) (uint32_t)(uint8_t)(ch) -#if ! defined(BYTE_ORDER) -#define BYTE_ORDER 0x3210 -#endif -#if (BYTE_ORDER == 0x3210 || BYTE_ORDER == 0x1032) -#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8)) -#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8)) -#define put2(i, c) { register int j = (i); Xput2(j, c); } -#else -#define uget2(c) (* ((unsigned short *) (c))) -#define Xput2(i, c) (* ((short *) (c)) = (i)) -#define put2(i, c) Xput2(i, c) -#endif +#define uget2(c) (Xchar((c)[0]) | (Xchar((c)[1])<<8)) +#define get2(c) ((int16_t) uget2(c)) +#define put2(i, c) (((c)[0] = i), ((c)[1] = i>>8)) -#define get2(c) ((short) uget2(c)) - -#if BYTE_ORDER != 0x0123 -#define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16)) -#define put4(l, c) { register long x=(l); \ - Xput2((int)x,c); \ - Xput2((int)(x>>16),(c)+2); \ - } -#else -#define get4(c) (* ((long *) (c))) -#define put4(l, c) (* ((long *) (c)) = (l)) -#endif +#define uget4(c) (uget2(c) | (uget2((c)+2)<<16)) +#define get4(c) ((int32_t) uget4(c)) +#define put4(i, c) (put2(i, c), put2((i)>>16, (c)+2)) #define SECTCNT 3 /* number of sections with own output buffer */ #if BIGMACHINE diff --git a/modules/src/object/rd.c b/modules/src/object/rd.c index 55f67bb8d..7790a4720 100644 --- a/modules/src/object/rd.c +++ b/modules/src/object/rd.c @@ -109,9 +109,6 @@ rd_ohead(head) register long off; OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD); -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outhead) != SZ_HEAD) -#endif { register char *c = (char *) head + (SZ_HEAD-4); @@ -157,16 +154,13 @@ rd_sect(sect, cnt) offcnt += cnt; while (cnt--) { sect--; -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outsect) != SZ_SECT) -#endif - { - c -= 4; sect->os_lign = get4(c); - c -= 4; sect->os_flen = get4(c); - c -= 4; sect->os_foff = get4(c); - c -= 4; sect->os_size = get4(c); - c -= 4; sect->os_base = get4(c); - } + + c -= 4; sect->os_lign = get4(c); + c -= 4; sect->os_flen = get4(c); + c -= 4; sect->os_foff = get4(c); + c -= 4; sect->os_size = get4(c); + c -= 4; sect->os_base = get4(c); + offset[--offcnt] = sect->os_foff + rd_base; } } @@ -197,9 +191,6 @@ rd_relo(relo, cnt) { OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outrelo) != SZ_RELO) -#endif { register char *c = (char *) relo + (long) cnt * SZ_RELO; @@ -208,8 +199,8 @@ rd_relo(relo, cnt) relo--; c -= 4; relo->or_addr = get4(c); c -= 2; relo->or_nami = uget2(c); - relo->or_sect = *--c; - relo->or_type = *--c; + c -= 2; relo->or_sect = uget2(c); + c -= 2; relo->or_type = uget2(c); } } } @@ -221,9 +212,6 @@ rd_name(name, cnt) { OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME); -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outname) != SZ_NAME) -#endif { register char *c = (char *) name + (long) cnt * SZ_NAME; diff --git a/modules/src/object/rd_ranlib.c b/modules/src/object/rd_ranlib.c index 63bc6964a..0a3d4d760 100644 --- a/modules/src/object/rd_ranlib.c +++ b/modules/src/object/rd_ranlib.c @@ -11,9 +11,6 @@ rd_ranlib(fd, ran, cnt) register long cnt; { rd_bytes(fd, (char *) ran, cnt * SZ_RAN); -#if BYTE_ORDER == 0x0123 - if (sizeof (struct ranlib) != SZ_RAN) -#endif { register char *c = (char *) ran + cnt * SZ_RAN; diff --git a/modules/src/object/wr.c b/modules/src/object/wr.c index 53267d0ee..20e5132f2 100644 --- a/modules/src/object/wr.c +++ b/modules/src/object/wr.c @@ -198,7 +198,7 @@ wr_ohead(head) BEGINSEEK(PARTDBUG, off); #endif } - if (BYTE_ORDER != 0x0123 || sizeof(struct outhead) != SZ_HEAD) + { char buf[SZ_HEAD]; @@ -214,7 +214,6 @@ wr_ohead(head) put4(head->oh_nchar, c); OUTWRITE(PARTEMIT, buf, (long)SZ_HEAD); } - else OUTWRITE(PARTEMIT, (char *)head, (long)SZ_HEAD); } void @@ -233,9 +232,6 @@ wr_sect(sect, cnt) } sect -= cnt; } -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outsect) != SZ_SECT) -#endif while (cnt) { register char *c; @@ -259,11 +255,6 @@ wr_sect(sect, cnt) __wr_flush(&__parts[PARTEMIT]); } } -#if BYTE_ORDER == 0x0123 - else { - OUTWRITE(PARTEMIT, (char *) sect, (long) cnt * SZ_SECT); - } -#endif } void @@ -313,9 +304,6 @@ wr_relo(relo, cnt) unsigned int cnt; { -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outrelo) != SZ_RELO) -#endif while (cnt) { register char *c; @@ -327,8 +315,8 @@ wr_relo(relo, cnt) cnt -= i; __parts[PARTRELO].cnt -= (i*SZ_RELO); while (i--) { - *c++ = relo->or_type; - *c++ = relo->or_sect; + put2(relo->or_type, c); c += 2; + put2(relo->or_sect, c); c += 2; put2(relo->or_nami, c); c += 2; put4(relo->or_addr, c); c += 4; relo++; @@ -338,11 +326,6 @@ wr_relo(relo, cnt) __wr_flush(&__parts[PARTRELO]); } } -#if BYTE_ORDER == 0x0123 - else { - OUTWRITE(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); - } -#endif } void @@ -350,9 +333,6 @@ wr_name(name, cnt) register struct outname *name; unsigned int cnt; { -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outname) != SZ_NAME) -#endif while (cnt) { register char *c; @@ -373,12 +353,6 @@ wr_name(name, cnt) __parts[PARTNAME].pnow = c; if (cnt) __wr_flush(&__parts[PARTNAME]); } -#if BYTE_ORDER == 0x0123 - else { - OUTWRITE(PARTNAME, (char *) name, (long)cnt * SZ_NAME); - } -#endif - } void diff --git a/modules/src/object/wr_ranlib.c b/modules/src/object/wr_ranlib.c index f55cef3cd..91274d71c 100644 --- a/modules/src/object/wr_ranlib.c +++ b/modules/src/object/wr_ranlib.c @@ -10,9 +10,6 @@ wr_ranlib(fd, ran, cnt1) struct ranlib *ran; long cnt1; { -#if BYTE_ORDER == 0x0123 - if (sizeof (struct ranlib) != SZ_RAN) -#endif { register long cnt = cnt1; register struct ranlib *r = ran; diff --git a/util/led/ack.out.5 b/util/led/ack.out.5 index 3932a7f25..8e34c1a06 100644 --- a/util/led/ack.out.5 +++ b/util/led/ack.out.5 @@ -150,7 +150,6 @@ struct outrelo { uint16_t or_type; /* type of reference */ uint16_t or_sect; /* referencing section */ uint16_t or_nami; /* referenced symbol index */ - uint16_t _padding; /* padding for alignment; ignore */ uint32_t or_addr; /* referencing address */ }; .fi @@ -285,15 +284,6 @@ object file. .br The following miscellaneous defines might come in handy when reading object files: -.PP -.nf -/* - * structure format strings - */ -#define SF_HEAD "22222244" -#define SF_SECT "44444" -#define SF_RELO "1124" -#define SF_NAME "4224" .fi .PP .nf @@ -302,7 +292,7 @@ object files: */ #define SZ_HEAD 20 #define SZ_SECT 20 -#define SZ_RELO 8 +#define SZ_RELO 10 #define SZ_NAME 12 .fi .PP diff --git a/util/led/relocate.c b/util/led/relocate.c index 3cc9ff904..b49e1c549 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -108,10 +108,7 @@ static long get_vc4_valu(char* addr) * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. */ -static long -getvalu(addr, type) - char addr[]; - char type; +static long getvalu(char* addr, uint16_t type) { switch (type & RELSZ) { case RELO1: @@ -127,7 +124,7 @@ getvalu(addr, type) case RELOVC4: return get_vc4_valu(addr); default: - fatal("bad relocation size"); + fatal("bad relocation type %x", type & RELSZ); } /* NOTREACHED */ } @@ -228,11 +225,7 @@ static void put_vc4_valu(char* addr, long value) * significance should be attributed to each byte. * We do not check for overflow. */ -static -putvalu(valu, addr, type) - long valu; - char addr[]; - char type; +static putvalu(long valu, char* addr, uint16_t type) { switch (type & RELSZ) { @@ -259,7 +252,7 @@ putvalu(valu, addr, type) put_vc4_valu(addr, valu); break; default: - fatal("bad relocation size"); + fatal("bad relocation type %x", type & RELSZ); } } From 7ee4dcde7b6d548331c390b8e1d3e6e8caa36c61 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 2 Jun 2016 12:06:54 +0200 Subject: [PATCH 121/231] Don't strip binaries so we retain debugging information. --HG-- branch : default-branch --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c88331d39..0a2e7cab7 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ BUILDDIR = $(ACK_TEMP_DIR)/ack-build # What build flags do you want to use? CFLAGS = -g -LDFLAGS = -s +LDFLAGS = # ======================================================================= # # END OF CONFIGURATION # From f24658181d085dbe79f586fb687aa5a34e9389ad Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 2 Jun 2016 12:07:31 +0200 Subject: [PATCH 122/231] Has it really been three years since the last release? --HG-- branch : default-branch --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 74ca13b55..956e25360 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ =================================== © 1987-2005 Vrije Universiteit, Amsterdam - 2013-05-15 + 2016-06-02 INTRODUCTION @@ -170,4 +170,4 @@ Please enjoy. David Given (dtrg on Sourceforge) dg@cowlark.com -2013-05-13 +2016-06-02 From 4b3c1a2d075d90d0320dd84aae237d6f58183bf3 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 2 Jun 2016 12:21:13 +0200 Subject: [PATCH 123/231] Add missing (but probably non-working) rpi file. --HG-- branch : default-branch --- plat/rpi/.distr | 1 + 1 file changed, 1 insertion(+) diff --git a/plat/rpi/.distr b/plat/rpi/.distr index 529eec7e9..cb3527f02 100644 --- a/plat/rpi/.distr +++ b/plat/rpi/.distr @@ -22,6 +22,7 @@ libsys/open.c libsys/pi_phys_to_user.s libsys/pi_uart.s libsys/pi_user_to_phys.s +libsys/pi_fast_mode.s libsys/read.c libsys/select.c libsys/signal.c From 9d620ad1c2c06d0092e1979c16a16934e569e222 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 2 Jun 2016 12:35:38 +0200 Subject: [PATCH 124/231] The archiver is called aal now. --HG-- branch : default-branch --- distr/mkdist | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/distr/mkdist b/distr/mkdist index 8366d69fb..1e302dc19 100755 --- a/distr/mkdist +++ b/distr/mkdist @@ -6,7 +6,7 @@ destdir= srcdir=`pwd` -arch=/usr/local/bin/arch +aal=/usr/local/bin/aal delete=no copy="ln" @@ -36,8 +36,8 @@ while [ "$1" != "" ]; do copy="ln -s" ;; - -a|--arch) - arch="$2" + -a|--aal) + aal="$2" shift ;; @@ -49,7 +49,7 @@ while [ "$1" != "" ]; do echo " -x --delete Erase the destination directory first." echo " -c --copy Make physical copies of the files. (default: hardlink)" echo " -S --symlink Make symbolic links instead of copying or hardlinking." - echo " -a --arch Where the ACK 'arch' tool is." + echo " -a --aal Where the ACK 'aal' tool is." echo " -h --help Display this message." exit 0 ;; @@ -110,7 +110,7 @@ process_dir() { elif [ "$i" = "$archivename" ]; then # Build the named archive. - $arch cDr `cat LIST` + $aal cDr `cat LIST` addfile $path/$archivename else echo "Don't know what to do with $i, listed in $PWD/.distr." @@ -123,12 +123,10 @@ process_dir() { # --- Main program ---------------------------------------------------------- -# Test to make sure that $arch points to the right thing. +# Test to make sure that $aal points to the right thing. -if !(strings $arch | grep archiver > /dev/null); then - echo "$arch does not seem to point at the ACK archiver tool." - echo "(Don't confuse this with the Linux tool for displaying your" - echo "architecture.)" +if !(strings $aal | grep archiver > /dev/null); then + echo "$aal does not seem to point at the ACK archiver tool." echo "" echo "Press RETURN to go ahead anyway, or CTRL+C to abort." read ignored From 88bd7ce12622cd7983eba2b5f4a9355eeac0c2c4 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 3 Jun 2016 13:56:50 +0200 Subject: [PATCH 125/231] Remove defunct pmfiles. --HG-- branch : default-branch --- first/ack-custom.pm | 21 --- first/ack.pm | 33 ---- first/c.pm | 238 --------------------------- first/llgen.pm | 37 ----- first/yacc.pm | 18 --- lang/basic/lib/pmfile | 45 ------ lang/basic/pmfile | 7 - lang/basic/src/pmfile | 64 -------- lang/cem/cemcom.ansi/pmfile | 210 ------------------------ lang/cem/cemcom/pmfile | 209 ------------------------ lang/cem/cpp.ansi/pmfile | 132 --------------- lang/cem/libcc.ansi/pmfile | 300 ----------------------------------- lang/cem/libcc/gen/pmfile | 94 ----------- lang/cem/libcc/math/pmfile | 31 ---- lang/cem/libcc/mon/pmfile | 101 ------------ lang/cem/libcc/pmfile | 41 ----- lang/cem/libcc/stdio/pmfile | 58 ------- lang/cem/pmfile | 9 -- lang/m2/comp/pmfile | 177 --------------------- lang/m2/libm2/pmfile | 99 ------------ lang/m2/pmfile | 7 - lang/occam/comp/pmfile | 62 -------- lang/occam/lib/pmfile | 21 --- lang/occam/pmfile | 20 --- lang/pc/comp/pmfile | 169 -------------------- lang/pc/libpc/pmfile | 95 ----------- lang/pc/pmfile | 7 - mach/6500/dl/pmfile | 19 --- mach/6500/libem/pmfile | 98 ------------ mach/6500/pmfile | 33 ---- mach/6800/pmfile | 16 -- mach/6805/pmfile | 16 -- mach/6809/pmfile | 16 -- mach/arm/cv/pmfile | 19 --- mach/arm/pmfile | 26 --- mach/i386/cv/pmfile | 19 --- mach/i386/libem/pmfile | 56 ------- mach/i386/libend/pmfile | 16 -- mach/i386/pmfile | 22 --- mach/i80/libem/pmfile | 49 ------ mach/i80/libend/pmfile | 16 -- mach/i80/pmfile | 25 --- mach/i86/libem/pmfile | 71 --------- mach/i86/libend/pmfile | 16 -- mach/i86/pmfile | 22 --- mach/m68020/libem/pmfile | 38 ----- mach/m68020/libend/pmfile | 16 -- mach/m68020/pmfile | 23 --- mach/m68k2/pmfile | 30 ---- mach/m68k4/pmfile | 25 --- mach/ns/pmfile | 19 --- mach/pdp/pmfile | 30 ---- mach/powerpc/libem/pmfile | 30 ---- mach/powerpc/libend/pmfile | 16 -- mach/powerpc/pmfile | 23 --- mach/proto/as/pmfile | 67 -------- mach/proto/cg/pmfile | 67 -------- mach/proto/ncg/pmfile | 57 ------- mach/proto/pmfile | 18 --- mach/proto/top/pmfile | 32 ---- mach/s2650/pmfile | 16 -- mach/vax4/pmfile | 29 ---- mach/z80/pmfile | 19 --- mach/z8000/pmfile | 19 --- modules/src/alloc/pmfile | 29 ---- modules/src/assert/pmfile | 20 --- modules/src/em_code/pmfile | 112 ------------- modules/src/em_mes/pmfile | 35 ---- modules/src/flt_arith/pmfile | 35 ---- modules/src/idf/pmfile | 17 -- modules/src/input/pmfile | 23 --- modules/src/object/pmfile | 55 ------- modules/src/print/pmfile | 27 ---- modules/src/read_em/pmfile | 96 ----------- modules/src/string/pmfile | 41 ----- modules/src/system/pmfile | 42 ----- plat/cpm/libsys/pmfile | 29 ---- plat/cpm/pmfile | 47 ------ plat/linux/liblinux/pmfile | 29 ---- plat/linux386/libsys/pmfile | 13 -- plat/linux386/pmfile | 48 ------ plat/linux68k/libsys/pmfile | 13 -- plat/linux68k/pmfile | 48 ------ plat/linuxppc/libsys/pmfile | 14 -- plat/linuxppc/pmfile | 48 ------ plat/pc86/libsys/pmfile | 29 ---- plat/pc86/pmfile | 46 ------ pmfile | 239 ---------------------------- util/LLgen/pmfile | 127 --------------- util/ack/pmfile | 61 ------- util/amisc/pmfile | 35 ---- util/arch/pmfile | 31 ---- util/ceg/as_parser/pmfile | 59 ------- util/ceg/assemble/pmfile | 20 --- util/ceg/ce_back/pmfile | 89 ----------- util/ceg/pmfile | 21 --- util/cgg/pmfile | 54 ------- util/cmisc/pmfile | 25 --- util/cpp/pmfile | 123 -------------- util/data/pmfile | 57 ------- util/ego/pmfile | 234 --------------------------- util/led/pmfile | 39 ----- util/misc/pmfile | 59 ------- util/ncgg/pmfile | 67 -------- util/opt/pmfile | 114 ------------- util/topgen/pmfile | 56 ------- 106 files changed, 5840 deletions(-) delete mode 100644 first/ack-custom.pm delete mode 100644 first/ack.pm delete mode 100644 first/c.pm delete mode 100644 first/llgen.pm delete mode 100644 first/yacc.pm delete mode 100644 lang/basic/lib/pmfile delete mode 100644 lang/basic/pmfile delete mode 100644 lang/basic/src/pmfile delete mode 100644 lang/cem/cemcom.ansi/pmfile delete mode 100644 lang/cem/cemcom/pmfile delete mode 100644 lang/cem/cpp.ansi/pmfile delete mode 100644 lang/cem/libcc.ansi/pmfile delete mode 100644 lang/cem/libcc/gen/pmfile delete mode 100644 lang/cem/libcc/math/pmfile delete mode 100644 lang/cem/libcc/mon/pmfile delete mode 100644 lang/cem/libcc/pmfile delete mode 100644 lang/cem/libcc/stdio/pmfile delete mode 100644 lang/cem/pmfile delete mode 100644 lang/m2/comp/pmfile delete mode 100644 lang/m2/libm2/pmfile delete mode 100644 lang/m2/pmfile delete mode 100644 lang/occam/comp/pmfile delete mode 100644 lang/occam/lib/pmfile delete mode 100644 lang/occam/pmfile delete mode 100644 lang/pc/comp/pmfile delete mode 100644 lang/pc/libpc/pmfile delete mode 100644 lang/pc/pmfile delete mode 100644 mach/6500/dl/pmfile delete mode 100644 mach/6500/libem/pmfile delete mode 100644 mach/6500/pmfile delete mode 100644 mach/6800/pmfile delete mode 100644 mach/6805/pmfile delete mode 100644 mach/6809/pmfile delete mode 100644 mach/arm/cv/pmfile delete mode 100644 mach/arm/pmfile delete mode 100644 mach/i386/cv/pmfile delete mode 100644 mach/i386/libem/pmfile delete mode 100644 mach/i386/libend/pmfile delete mode 100644 mach/i386/pmfile delete mode 100644 mach/i80/libem/pmfile delete mode 100644 mach/i80/libend/pmfile delete mode 100644 mach/i80/pmfile delete mode 100644 mach/i86/libem/pmfile delete mode 100644 mach/i86/libend/pmfile delete mode 100644 mach/i86/pmfile delete mode 100644 mach/m68020/libem/pmfile delete mode 100644 mach/m68020/libend/pmfile delete mode 100644 mach/m68020/pmfile delete mode 100644 mach/m68k2/pmfile delete mode 100644 mach/m68k4/pmfile delete mode 100644 mach/ns/pmfile delete mode 100644 mach/pdp/pmfile delete mode 100644 mach/powerpc/libem/pmfile delete mode 100644 mach/powerpc/libend/pmfile delete mode 100644 mach/powerpc/pmfile delete mode 100644 mach/proto/as/pmfile delete mode 100644 mach/proto/cg/pmfile delete mode 100644 mach/proto/ncg/pmfile delete mode 100644 mach/proto/pmfile delete mode 100644 mach/proto/top/pmfile delete mode 100644 mach/s2650/pmfile delete mode 100644 mach/vax4/pmfile delete mode 100644 mach/z80/pmfile delete mode 100644 mach/z8000/pmfile delete mode 100644 modules/src/alloc/pmfile delete mode 100644 modules/src/assert/pmfile delete mode 100644 modules/src/em_code/pmfile delete mode 100644 modules/src/em_mes/pmfile delete mode 100644 modules/src/flt_arith/pmfile delete mode 100644 modules/src/idf/pmfile delete mode 100644 modules/src/input/pmfile delete mode 100644 modules/src/object/pmfile delete mode 100644 modules/src/print/pmfile delete mode 100644 modules/src/read_em/pmfile delete mode 100644 modules/src/string/pmfile delete mode 100644 modules/src/system/pmfile delete mode 100644 plat/cpm/libsys/pmfile delete mode 100644 plat/cpm/pmfile delete mode 100644 plat/linux/liblinux/pmfile delete mode 100644 plat/linux386/libsys/pmfile delete mode 100644 plat/linux386/pmfile delete mode 100644 plat/linux68k/libsys/pmfile delete mode 100644 plat/linux68k/pmfile delete mode 100644 plat/linuxppc/libsys/pmfile delete mode 100644 plat/linuxppc/pmfile delete mode 100644 plat/pc86/libsys/pmfile delete mode 100644 plat/pc86/pmfile delete mode 100644 pmfile delete mode 100644 util/LLgen/pmfile delete mode 100644 util/ack/pmfile delete mode 100644 util/amisc/pmfile delete mode 100644 util/arch/pmfile delete mode 100644 util/ceg/as_parser/pmfile delete mode 100644 util/ceg/assemble/pmfile delete mode 100644 util/ceg/ce_back/pmfile delete mode 100644 util/ceg/pmfile delete mode 100644 util/cgg/pmfile delete mode 100644 util/cmisc/pmfile delete mode 100644 util/cpp/pmfile delete mode 100644 util/data/pmfile delete mode 100644 util/ego/pmfile delete mode 100644 util/led/pmfile delete mode 100644 util/misc/pmfile delete mode 100644 util/ncgg/pmfile delete mode 100644 util/opt/pmfile delete mode 100644 util/topgen/pmfile diff --git a/first/ack-custom.pm b/first/ack-custom.pm deleted file mode 100644 index a6b000dc4..000000000 --- a/first/ack-custom.pm +++ /dev/null @@ -1,21 +0,0 @@ --- $Source$ --- $State$ - --- Custom rules used by the ACK build process. - -preprocess = simple { - class = "preprocess", - outputs = {"%U%-%I%"}, - command = { - "cpp -I%HEADERDIR% %in% > %out[1]%" - } -} - --- Revision history --- $Log$ --- Revision 1.2 2007-02-20 00:32:58 dtrg --- Changed the 'preprocess' rule to use the system C preprocessor. --- --- Revision 1.1 2006/07/22 00:49:48 dtrg --- First version in CVS. --- diff --git a/first/ack.pm b/first/ack.pm deleted file mode 100644 index 6f3ac56ab..000000000 --- a/first/ack.pm +++ /dev/null @@ -1,33 +0,0 @@ --- $Source$ --- $State$ - --- Provides rules for building things with the half-built ACK itself. - -ACKBUILDFLAGS = {"-m%PLATFORM%", "%OPTIMISATION%"} -ACKDEFINES = EMPTY -ACKINCLUDES = EMPTY - -ackfile = simple_with_clike_dependencies { - class = "ackfile", - CINCLUDES = {REDIRECT, "ACKINCLUDES"}, - command = { - "%BINDIR%bin/ack %ACKBUILDFLAGS% %ACKINCLUDES:cincludes% %ACKDEFINES:cdefines% -c -o %out% %in%" - }, - outputs = {"%U%-%I%.o"}, -} - -ackprogram = simple { - class = "ackprogram", - command = { - "%BINDIR%bin/ack %ACKBUILDFLAGS% -o %out% %in%" - }, - outputs = {"%U%-%I%"}, -} - -acklibrary = simple { - class = "acklibrary", - command = { - "%RM% %out% && %BINDIR%bin/aal cr %out% %in%" - }, - outputs = {"%U%-%I%.a"}, -} diff --git a/first/c.pm b/first/c.pm deleted file mode 100644 index 3fdd716bd..000000000 --- a/first/c.pm +++ /dev/null @@ -1,238 +0,0 @@ --- $Id$ --- $HeadURL: https://primemover.svn.sf.net/svnroot/primemover/pm/lib/c.pm $ --- $LastChangedDate: 2007-02-24 01:37:06 +0000 (Sat, 24 Feb 2007) $ - --- pm includefile to compile *host* C programs. - --- Standard Lua boilerplate. - -local io_open = io.open -local string_gsub = string.gsub -local string_gfind = string.gfind -local string_find = string.find -local table_insert = table.insert -local table_getn = table.getn -local filetime = pm.filetime - --- Define some variables. - -CCOMPILER = "gcc" -CXXCOMPILER = "g++" -CC = "%CCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES:cincludes% %CINCLUDES:cincludes% %CDEFINES:cdefines% %CEXTRAFLAGS% -c -o %out% %in%" -CXX = "%CXXCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES:cincludes% %CINCLUDES:cincludes% %CDEFINES:cdefines% %CEXTRAFLAGS% -c -o %out% %in%" -CPROGRAM = "%CCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES:clibraries%" -CXXPROGRAM = "%CXXCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES:clibraries%" - -CLIBRARY = "rm -f %out% && ar cr %out% %in% && ranlib %out%" - -CBUILDFLAGS = {"-g"} -CINCLUDES = EMPTY -CDEFINES = EMPTY -CEXTRAFLAGS = EMPTY -CLINKFLAGS = EMPTY -CDYNINCLUDES = EMPTY -CLIBRARIES = EMPTY - ---- Custom string modifiers ------------------------------------------------- - -local function prepend(rule, arg, prefix) - if (arg == EMPTY) then - return EMPTY - end - - local t = {} - for i, j in ipairs(arg) do - t[i] = prefix..j - end - return t -end - -function pm.stringmodifier.cincludes(rule, arg) - return prepend(rule, arg, "-I") -end - -function pm.stringmodifier.cdefines(rule, arg) - return prepend(rule, arg, "-D") -end - -function pm.stringmodifier.clibraries(rule, arg) - if (arg == EMPTY) then - return EMPTY - end - - local t = {} - for i, j in ipairs(arg) do - if string_find(j, "%.a$") then - t[i] = j - else - t[i] = "-l"..j - end - end - return t -end - ---- Manage C file dependencies ---------------------------------------------- - -local dependency_cache = {} -local function calculate_dependencies(filename, includes) - -- Cache values, so we don't recalculate dependencies needlessly. - - local o = dependency_cache[filename] - if o then - return o - end - - local deps = {} - deps[filename] = true - - local calcdeps = 0 - calcdeps = function(filename, file) - file = file or io_open(filename) - if not file then - return - end - - local localincludes = string_gsub(filename, "/[^/]*$", "") - if localincludes then - localincludes = {localincludes, unpack(includes)} - else - localincludes = includes - end - - for line in file:lines() do - local _, _, f = string_find(line, '^[ \t]*#[ \t]*include[ \t]*["<]([^"]+)[">]') - if f then - for _, path in ipairs(localincludes) do - local subfilename = path.."/"..f - local subfile = io_open(subfilename) - if subfile then - if not deps[subfilename] then - deps[subfilename] = true - calcdeps(subfilename, subfile) - end - break - end - end - end - end - - -- Explicit close to avoid having to wait for the garbage collector - -- to free up the underlying fd. - - file:close() - end - - calcdeps(filename) - o = {} - for i, _ in pairs(deps) do - table_insert(o, i) - end - - dependency_cache[filename] = o - return o -end - --- This clause specialises 'simple' to add support for smart dependencies of C --- files. - -simple_with_clike_dependencies = simple { - class = "simple_with_clike_dependencies", - makedepends = {"%CDEPENDS%"}, - - __init = function(self, p) - simple.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- If dynamicheaders is an object, turn it into a singleton list. - - if self.dynamicheaders then - if (type(self.dynamicheaders) ~= "table") then - self:__error("doesn't know what to do with dynamicheaders, which ", - "should be a list or an object but was a ", type(self.dynamicheaders)) - end - if self.dynamicheaders.class then - self.dynamicheaders = {self.dynamicheaders} - end - end - end, - - __dependencies = function(self, inputs, outputs) - local cincludes = self:__index("CINCLUDES") - if (type(cincludes) == "string") then - cincludes = {cincludes} - end - - local includes = {} - for _, i in ipairs(cincludes) do - table_insert(includes, self:__expand(i)) - end - - local input = self:__expand(inputs[1]) - local depends = calculate_dependencies(input, includes) - if not depends then - self:__error("could not determine the dependencies for ", - pm.rendertable({input})) - end - if pm.verbose then - pm.message('"', input, '" appears to depend on ', - pm.rendertable(depends)) - end - return depends - end, - - __buildadditionalchildren = function(self) - self.CDYNINCLUDES = {} - if self.dynamicheaders then - for _, i in ipairs(self.dynamicheaders) do - local o = i:__build() - if o[1] then - table_insert(self.CDYNINCLUDES, (string_gsub(o[1], "/[^/]*$", ""))) - end - end - end - -- If no paths on the list, replace the list with EMPTY so it doesn't - -- expand to anything. - if (table_getn(self.CDYNINCLUDES) == 0) then - self.CDYNINCLUDES = EMPTY - end - end -} - --- These are the publically useful clauses. - -cfile = simple_with_clike_dependencies { - class = "cfile", - command = {"%CC%"}, - outputs = {"%U%-%I%.o"}, -} - -cxxfile = simple_with_clike_dependencies { - class = "cxxfile", - command = {"%CXX%"}, - outputs = {"%U%-%I%.o"}, -} - -cprogram = simple { - class = "cprogram", - command = {"%CPROGRAM%"}, - outputs = {"%U%-%I%"}, -} - -cxxprogram = simple { - class = "cxxprogram", - command = {"%CXXPROGRAM%"}, - outputs = {"%U%-%I%"}, -} - -clibrary = simple { - class = "clibrary", - command = { - "%CLIBRARY%" - }, - outputs = {"%U%-%I%.a"}, -} diff --git a/first/llgen.pm b/first/llgen.pm deleted file mode 100644 index e8f1e70eb..000000000 --- a/first/llgen.pm +++ /dev/null @@ -1,37 +0,0 @@ --- $Source$ --- $State$ - --- This is unpleasant. LLgen can generate an arbitrary number of output files, --- which means we need our own output filename generator. - -LLgen = simple { - class = "LLgen", - command = { - "rm -f %out%", - "cd %out[1]:dirname% && %TOOLDIR%LLgen %in%" - }, - - outputs = {"%U%/" }, - __outputs = function(self, inputs) - local o = simple.__outputs(self, inputs)[1] - - local outputs = {o.."Lpars.h", o.."Lpars.c"} - - for _, i in ipairs(inputs) do - i = string.gsub(i, "^.*/", "") - i = string.gsub(i, "%.g$", ".c") - table.insert(outputs, o..i) - end - - return outputs - end -} - --- Revision history --- $Log$ --- Revision 1.2 2006-11-11 22:59:01 dtrg --- Now uses the version of LLgen included with the ACK instead of the standalone version. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- \ No newline at end of file diff --git a/first/yacc.pm b/first/yacc.pm deleted file mode 100644 index 92bbe39dc..000000000 --- a/first/yacc.pm +++ /dev/null @@ -1,18 +0,0 @@ -yacc = simple { - class = "yacc", - outputs = {"%U%/%I%.c"}, - - command = { - "yacc -t -b %out[1]:dirname%/y -d %in%", - "mv %out[1]:dirname%/y.tab.c %out[1]%" - } -} - -flex = simple { - class = "flex", - outputs = {"%U%/%I%.c"}, - - command = { - "flex -s -t %in% > %out%" - } -} diff --git a/lang/basic/lib/pmfile b/lang/basic/lib/pmfile deleted file mode 100644 index eb069d330..000000000 --- a/lang/basic/lib/pmfile +++ /dev/null @@ -1,45 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."lang/basic/lib/" - -lang_basic_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."fif.e"), - ackfile (d.."fef.e"), - ackfile (d.."setline.e"), - ackfile (d.."abs.c"), - ackfile (d.."asc.c"), - ackfile (d.."asrt.c"), - ackfile (d.."atn.c"), - ackfile (d.."chr.c"), - ackfile (d.."conversion.c"), - ackfile (d.."error.c"), - ackfile (d.."exp.c"), - ackfile (d.."file.c"), - ackfile (d.."hlt.c"), - ackfile (d.."io.c"), - ackfile (d.."log.c"), - ackfile (d.."mki.c"), - ackfile (d.."oct.c"), - ackfile (d.."peek.c"), - ackfile (d.."power.c"), - ackfile (d.."print.c"), - ackfile (d.."random.c"), - ackfile (d.."read.c"), - ackfile (d.."return.c"), - ackfile (d.."salloc.c"), - ackfile (d.."sgn.c"), - ackfile (d.."sin.c"), - ackfile (d.."sqt.c"), - ackfile (d.."stop.c"), - ackfile (d.."string.c"), - ackfile (d.."swap.c"), - ackfile (d.."trace.c"), - ackfile (d.."trap.c"), - ackfile (d.."write.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libbasic.a") -} diff --git a/lang/basic/pmfile b/lang/basic/pmfile deleted file mode 100644 index 180d1a2ae..000000000 --- a/lang/basic/pmfile +++ /dev/null @@ -1,7 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/basic/" - -include (d.."src/pmfile") -include (d.."lib/pmfile") diff --git a/lang/basic/src/pmfile b/lang/basic/src/pmfile deleted file mode 100644 index 254f67707..000000000 --- a/lang/basic/src/pmfile +++ /dev/null @@ -1,64 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/basic/src/" - -local lpars = LLgen { - file (d.."basic.g"), -} - -local tokentab_h = simple { - outputs = {"%U%/token.h"}, - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."maketokentab"), - lpars -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars, - tokentab_h - } -} - -lang_basic_compiler = cprogram { - cfile_with_headers (d.."bem.c"), - cfile_with_headers (d.."symbols.c"), - cfile_with_headers (d.."initialize.c"), - cfile_with_headers (d.."compile.c"), - cfile_with_headers (d.."parsepar.c"), - cfile_with_headers (d.."gencode.c"), - cfile_with_headers (d.."util.c"), - cfile_with_headers (d.."graph.c"), - cfile_with_headers (d.."eval.c"), - cfile_with_headers (d.."func.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_bem"}, - install = { - pm.install("%BINDIR%%PLATDEP%/em_bem"), - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-26 23:08:09 dtrg --- Added support for the Basic compiler. --- \ No newline at end of file diff --git a/lang/cem/cemcom.ansi/pmfile b/lang/cem/cemcom.ansi/pmfile deleted file mode 100644 index c22795135..000000000 --- a/lang/cem/cemcom.ansi/pmfile +++ /dev/null @@ -1,210 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/cemcom.ansi/" - -local extract_parameters = simple { - outputs = { - "%U%/lint.h", - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/density.h", - "%U%/macbuf.h", - "%U%/strsize.h", - "%U%/trgt_sizes.h", - "%U%/botch_free.h", - "%U%/dataflow.h", - "%U%/debug.h", - "%U%/use_tmp.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/nopp.h", - "%U%/nobitfield.h", - "%U%/spec_arith.h", - "%U%/static.h", - "%U%/nocross.h", - "%U%/regcount.h", - "%U%/dbsymtab.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."BigPars") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), - file (d.."ival.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/code.h"}, (d.."code.str") }, - allocd_header { outputs = {"%U%/declar.h"}, (d.."declar.str") }, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.str") }, - allocd_header { outputs = {"%U%/expr.h"}, (d.."expr.str") }, - allocd_header { outputs = {"%U%/field.h"}, (d.."field.str") }, - allocd_header { outputs = {"%U%/estack.h"}, (d.."estack.str") }, - allocd_header { outputs = {"%U%/util.h"}, (d.."util.str") }, - allocd_header { outputs = {"%U%/proto.h"}, (d.."proto.str") }, - allocd_header { outputs = {"%U%/replace.h"}, (d.."replace.str") }, - allocd_header { outputs = {"%U%/idf.h"}, (d.."idf.str") }, - allocd_header { outputs = {"%U%/macro.h"}, (d.."macro.str") }, - allocd_header { outputs = {"%U%/stack.h"}, (d.."stack.str") }, - allocd_header { outputs = {"%U%/stmt.h"}, (d.."stmt.str") }, - allocd_header { outputs = {"%U%/struct.h"}, (d.."struct.str") }, - allocd_header { outputs = {"%U%/switch.h"}, (d.."switch.str") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.str") }, - allocd_header { outputs = {"%U%/l_brace.h"}, (d.."l_brace.str") }, - allocd_header { outputs = {"%U%/l_state.h"}, (d.."l_state.str") }, - allocd_header { outputs = {"%U%/l_outdef.h"}, (d.."l_outdef.str") }, - lpars - } -} - -lang_cem_ansi_compiler = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."arith.c"), - cfile_with_headers (d.."blocks.c"), - cfile_with_headers (d.."ch3.c"), - cfile_with_headers (d.."ch3bin.c"), - cfile_with_headers (d.."ch3mon.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."conversion.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."dataflow.c"), - cfile_with_headers (d.."declarator.c"), - cfile_with_headers (d.."decspecs.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."dumpidf.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."eval.c"), - cfile_with_headers (d.."expr.c"), - cfile_with_headers (d.."field.c"), - cfile_with_headers (d.."fltcstoper.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."l_comment.c"), - cfile_with_headers (d.."l_ev_ord.c"), - cfile_with_headers (d.."l_lint.c"), - cfile_with_headers (d.."l_misc.c"), - cfile_with_headers (d.."l_outdef.c"), - cfile_with_headers (d.."l_states.c"), - cfile_with_headers (d.."label.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."pragma.c"), - cfile_with_headers (d.."proto.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."stab.c"), - cfile_with_headers (d.."stack.c"), - cfile_with_headers (d.."struct.c"), - cfile_with_headers (d.."switch.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."util.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."code.str"), - file (d.."declar.str"), - file (d.."def.str"), - file (d.."expr.str"), - file (d.."field.str"), - file (d.."estack.str"), - file (d.."util.str"), - file (d.."proto.str"), - file (d.."replace.str"), - file (d.."idf.str"), - file (d.."macro.str"), - file (d.."stack.str"), - file (d.."stmt.str"), - file (d.."struct.str"), - file (d.."switch.str"), - file (d.."type.str"), - file (d.."l_brace.str"), - file (d.."l_state.str"), - file (d.."l_outdef.str"), - } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_system, - lib_string, - - outputs = {"%U%/em_cemcom.ansi"}, - install = { - pm.install( BINDIR..PLATDEP.."/em_cemcom.ansi"), - pm.install(d.."cemcom.ansi.1", BINDIR.."/man/man1/cemcom.ansi.1"), - } -} diff --git a/lang/cem/cemcom/pmfile b/lang/cem/cemcom/pmfile deleted file mode 100644 index e415c38ed..000000000 --- a/lang/cem/cemcom/pmfile +++ /dev/null @@ -1,209 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/cemcom/" - -local extract_parameters = simple { - outputs = { - "%U%/lint.h", - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/density.h", - "%U%/lapbuf.h", - "%U%/strsize.h", - "%U%/target_sizes.h", - "%U%/botch_free.h", - "%U%/dataflow.h", - "%U%/debug.h", - "%U%/use_tmp.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/nopp.h", - "%U%/nobitfield.h", - "%U%/spec_arith.h", - "%U%/static.h", - "%U%/nofloat.h", - "%U%/noRoption.h", - "%U%/nocross.h", - "%U%/regcount.h", - "%U%/dbsymtab.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."BigPars") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), - file (d.."ival.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/code.h"}, (d.."code.str") }, - allocd_header { outputs = {"%U%/declar.h"}, (d.."declar.str") }, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.str") }, - allocd_header { outputs = {"%U%/expr.h"}, (d.."expr.str") }, - allocd_header { outputs = {"%U%/field.h"}, (d.."field.str") }, - allocd_header { outputs = {"%U%/estack.h"}, (d.."estack.str") }, - allocd_header { outputs = {"%U%/util.h"}, (d.."util.str") }, - allocd_header { outputs = {"%U%/decspecs.h"}, (d.."decspecs.str") }, - allocd_header { outputs = {"%U%/idf.h"}, (d.."idf.str") }, - allocd_header { outputs = {"%U%/macro.h"}, (d.."macro.str") }, - allocd_header { outputs = {"%U%/stack.h"}, (d.."stack.str") }, - allocd_header { outputs = {"%U%/stmt.h"}, (d.."stmt.str") }, - allocd_header { outputs = {"%U%/struct.h"}, (d.."struct.str") }, - allocd_header { outputs = {"%U%/switch.h"}, (d.."switch.str") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.str") }, - allocd_header { outputs = {"%U%/l_brace.h"}, (d.."l_brace.str") }, - allocd_header { outputs = {"%U%/l_state.h"}, (d.."l_state.str") }, - allocd_header { outputs = {"%U%/l_outdef.h"}, (d.."l_outdef.str") }, - lpars - } -} - -lang_cem_compiler = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."arith.c"), - cfile_with_headers (d.."asm.c"), - cfile_with_headers (d.."blocks.c"), - cfile_with_headers (d.."ch7.c"), - cfile_with_headers (d.."ch7bin.c"), - cfile_with_headers (d.."ch7mon.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."conversion.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."dataflow.c"), - cfile_with_headers (d.."declarator.c"), - cfile_with_headers (d.."decspecs.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."dumpidf.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."eval.c"), - cfile_with_headers (d.."expr.c"), - cfile_with_headers (d.."field.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."l_comment.c"), - cfile_with_headers (d.."l_ev_ord.c"), - cfile_with_headers (d.."l_lint.c"), - cfile_with_headers (d.."l_misc.c"), - cfile_with_headers (d.."l_outdef.c"), - cfile_with_headers (d.."l_states.c"), - cfile_with_headers (d.."label.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."scan.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."stack.c"), - cfile_with_headers (d.."struct.c"), - cfile_with_headers (d.."switch.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."util.c"), - cfile_with_headers (d.."stab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."code.str"), - file (d.."declar.str"), - file (d.."decspecs.str"), - file (d.."def.str"), - file (d.."expr.str"), - file (d.."field.str"), - file (d.."estack.str"), - file (d.."util.str"), - file (d.."idf.str"), - file (d.."macro.str"), - file (d.."stack.str"), - file (d.."stmt.str"), - file (d.."struct.str"), - file (d.."switch.str"), - file (d.."type.str"), - file (d.."l_brace.str"), - file (d.."l_state.str"), - file (d.."l_outdef.str"), - } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_system, - lib_string, - - outputs = {"%U%/em_cemcom"}, - install = { - pm.install( BINDIR..PLATDEP.."/em_cemcom"), - pm.install(d.."cemcom.1", BINDIR.."/man/man1/cemcom.1"), - } -} diff --git a/lang/cem/cpp.ansi/pmfile b/lang/cem/cpp.ansi/pmfile deleted file mode 100644 index 2fb98fa8a..000000000 --- a/lang/cem/cpp.ansi/pmfile +++ /dev/null @@ -1,132 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/cpp.ansi/" - -local extract_parameters = simple { - outputs = { - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/macbuf.h", - "%U%/strsize.h", - "%U%/botch_free.h", - "%U%/debug.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/obufsize.h", - "%U%/dobits.h", - "%U%/ln_prefix.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."Parameters") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."expression.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/replace.h"}, (d.."replace.str") }, - allocd_header { outputs = {"%U%/macro.h"}, (d.."macro.str") }, - lpars - } -} - -tool_cpp_ansi = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."ch3bin.c"), - cfile_with_headers (d.."ch3mon.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."preprocess.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."expr.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."macro.str"), - file (d.."replace.str"), - } - }, - - lib_input, - lib_assert, - lib_alloc, - lib_print, - lib_system, - lib_string, - - outputs = {"%U%/cpp.ansi"}, - install = { - pm.install( BINDIR..PLATDEP.."/cpp.ansi"), - pm.install(d.."ncpp.6", BINDIR.."/man/man6/cpp.ansi.6"), - } -} diff --git a/lang/cem/libcc.ansi/pmfile b/lang/cem/libcc.ansi/pmfile deleted file mode 100644 index 21ac99219..000000000 --- a/lang/cem/libcc.ansi/pmfile +++ /dev/null @@ -1,300 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc.ansi/" - -local crt = ackfile { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - file (d.."head_ac.e"), - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/c-ansi.o") -} - -local libc = acklibrary { - ACKBUILDFLAGS = {PARENT, "-ansi"}, - ACKINCLUDES = {PARENT, "%ROOTDIR%h", d.."headers"}, - outputs = {"%U%/libc.a"}, - - -- assert - - ackfile (d.."assert/assert.c"), - - -- ctype - - ackfile (d.."ctype/tolower.c"), - ackfile (d.."ctype/toupper.c"), - ackfile { - tabgen (d.."ctype/char.tab") - }, - foreach { - rule = ackfile, - simple { - outputs = { - "%U%/isalnum.c", - "%U%/isalpha.c", - "%U%/iscntrl.c", - "%U%/isdigit.c", - "%U%/isgraph.c", - "%U%/islower.c", - "%U%/isprint.c", - "%U%/ispunct.c", - "%U%/isspace.c", - "%U%/isupper.c", - "%U%/isxdigit.c", - "%U%/isascii.c", - }, - command = { - "cd %out[1]:dirname% && sh %in[1]%" - }, - - file (d.."ctype/genfiles") - } - }, - - -- errno - - ackfile (d.."errno/errlist.c"), - - -- locale - - ackfile (d.."locale/localeconv.c"), - ackfile (d.."locale/setlocale.c"), - - -- math - - ackfile (d.."math/asin.c"), - ackfile (d.."math/atan2.c"), - ackfile (d.."math/atan.c"), - ackfile (d.."math/ceil.c"), - ackfile (d.."math/fabs.c"), - ackfile (d.."math/pow.c"), - ackfile (d.."math/log10.c"), - ackfile (d.."math/log.c"), - ackfile (d.."math/sin.c"), - ackfile (d.."math/sinh.c"), - ackfile (d.."math/sqrt.c"), - ackfile (d.."math/tan.c"), - ackfile (d.."math/tanh.c"), - ackfile (d.."math/exp.c"), - ackfile (d.."math/ldexp.c"), - ackfile (d.."math/fmod.c"), - ackfile (d.."math/floor.c"), - ackfile (d.."math/hugeval.c"), - ackfile (d.."math/frexp.e"), - ackfile (d.."math/modf.e"), - ackfile (d.."math/isnan.c"), - - -- misc - - ackfile (d.."misc/environ.c"), - --[[ - ackfile (d.."misc/getgrent.c"), - ackfile (d.."misc/getopt.c"), - ackfile (d.."misc/getpass.c"), - ackfile (d.."misc/getpw.c"), - ackfile (d.."misc/getw.c"), - ackfile (d.."misc/putw.c"), - ackfile (d.."misc/putenv.c"), - ackfile (d.."misc/environ.c"), - ackfile (d.."misc/popen.c"), - ackfile (d.."misc/sleep.c"), - ackfile (d.."misc/termcap.c"), - ackfile (d.."misc/fdopen.c"), - ackfile (d.."misc/closedir.c"), - group { - ACKDEFINES = {PARENT, "UFS"}, - ackfile (d.."misc/getdents.c") - }, - ackfile (d.."misc/opendir.c"), - ackfile (d.."misc/readdir.c"), - ackfile (d.."misc/rewinddir.c"), - ackfile (d.."misc/seekdir.c"), - ackfile (d.."misc/telldir.c"), - ackfile (d.."misc/isatty.c"), - ackfile (d.."misc/mktemp.c"), - ackfile (d.."misc/hypot.c"), - --]] - - -- setjmp - - ackfile (d.."setjmp/setjmp.e"), - --ackfile (d.."setjmp/sigmisc.c"), - - -- signal - - ackfile (d.."signal/raise.c"), - - -- stdio - - ackfile (d.."stdio/tmpfile.c"), - ackfile (d.."stdio/tmpnam.c"), --- ackfile (d.."stdio/rename.c"), --- ackfile (d.."stdio/remove.c"), - ackfile (d.."stdio/fopen.c"), - ackfile (d.."stdio/freopen.c"), - ackfile (d.."stdio/setbuf.c"), - ackfile (d.."stdio/setvbuf.c"), - ackfile (d.."stdio/perror.c"), - ackfile (d.."stdio/fprintf.c"), - ackfile (d.."stdio/printf.c"), - ackfile (d.."stdio/sprintf.c"), - ackfile (d.."stdio/vfprintf.c"), - ackfile (d.."stdio/vprintf.c"), - ackfile (d.."stdio/vsprintf.c"), - ackfile (d.."stdio/doprnt.c"), - ackfile (d.."stdio/icompute.c"), - ackfile (d.."stdio/fscanf.c"), - ackfile (d.."stdio/scanf.c"), - ackfile (d.."stdio/sscanf.c"), - ackfile (d.."stdio/doscan.c"), - ackfile (d.."stdio/fgetc.c"), - ackfile (d.."stdio/fgets.c"), - ackfile (d.."stdio/getc.c"), - ackfile (d.."stdio/getchar.c"), - ackfile (d.."stdio/gets.c"), - ackfile (d.."stdio/putc.c"), - ackfile (d.."stdio/putchar.c"), - ackfile (d.."stdio/fputc.c"), - ackfile (d.."stdio/puts.c"), - ackfile (d.."stdio/fputs.c"), - ackfile (d.."stdio/ungetc.c"), - ackfile (d.."stdio/fread.c"), - ackfile (d.."stdio/fwrite.c"), - ackfile (d.."stdio/fgetpos.c"), - ackfile (d.."stdio/fsetpos.c"), - ackfile (d.."stdio/rewind.c"), - ackfile (d.."stdio/fseek.c"), - ackfile (d.."stdio/ftell.c"), - ackfile (d.."stdio/clearerr.c"), - ackfile (d.."stdio/feof.c"), - ackfile (d.."stdio/ferror.c"), - ackfile (d.."stdio/fileno.c"), - ackfile (d.."stdio/fltpr.c"), - ackfile (d.."stdio/ecvt.c"), - ackfile (d.."stdio/fillbuf.c"), - ackfile (d.."stdio/fclose.c"), - ackfile (d.."stdio/flushbuf.c"), - ackfile (d.."stdio/fflush.c"), --- ackfile (d.."stdio/isatty.c"), - ackfile (d.."stdio/data.c"), - - -- stdlib - - ackfile (d.."stdlib/abort.c"), - ackfile (d.."stdlib/abs.c"), - ackfile (d.."stdlib/atof.c"), - ackfile (d.."stdlib/atoi.c"), - ackfile (d.."stdlib/atol.c"), - ackfile (d.."stdlib/bsearch.c"), - ackfile (d.."stdlib/div.c"), - ackfile (d.."stdlib/atexit.c"), - ackfile (d.."stdlib/exit.c"), - ackfile (d.."stdlib/getenv.c"), - ackfile (d.."stdlib/labs.c"), - ackfile (d.."stdlib/ldiv.c"), - ackfile (d.."stdlib/mblen.c"), - ackfile (d.."stdlib/mbstowcs.c"), - ackfile (d.."stdlib/mbtowc.c"), - ackfile (d.."stdlib/qsort.c"), - ackfile (d.."stdlib/rand.c"), - ackfile (d.."stdlib/strtod.c"), - ackfile (d.."stdlib/strtol.c"), --- ackfile (d.."stdlib/system.c"), - ackfile (d.."stdlib/wcstombs.c"), - ackfile (d.."stdlib/wctomb.c"), - ackfile (d.."stdlib/ext_comp.c"), - ackfile { - simple { - outputs = {"%U%/malloc.c"}, - command = { - "rm -f %out% && for i in %in[2-]%; do %in[1]% $i >> %out%; done" - }, - file (d.."stdlib/malloc/add_file"), - file (d.."stdlib/malloc/READ_ME"), - file (d.."stdlib/malloc/size_type.h"), - file (d.."stdlib/malloc/param.h"), - file (d.."stdlib/malloc/impl.h"), - file (d.."stdlib/malloc/check.h"), - file (d.."stdlib/malloc/log.h"), - file (d.."stdlib/malloc/phys.h"), - file (d.."stdlib/malloc/mal.c"), - file (d.."stdlib/malloc/log.c"), - file (d.."stdlib/malloc/phys.c"), - file (d.."stdlib/malloc/check.c"), - } - }, - - -- string - - ackfile (d.."string/memchr.c"), - ackfile (d.."string/memcmp.c"), - ackfile (d.."string/memcpy.c"), - ackfile (d.."string/memmove.c"), - ackfile (d.."string/memset.c"), - ackfile (d.."string/strcat.c"), - ackfile (d.."string/strchr.c"), - ackfile (d.."string/strcmp.c"), - ackfile (d.."string/strcoll.c"), - ackfile (d.."string/strcpy.c"), - ackfile (d.."string/strcspn.c"), - ackfile (d.."string/strerror.c"), - ackfile (d.."string/strncat.c"), - ackfile (d.."string/strncpy.c"), - ackfile (d.."string/strrchr.c"), - ackfile (d.."string/strstr.c"), - ackfile (d.."string/strlen.c"), - ackfile (d.."string/strtok.c"), - ackfile (d.."string/strpbrk.c"), - ackfile (d.."string/strspn.c"), - ackfile (d.."string/strncmp.c"), - ackfile (d.."string/strxfrm.c"), - - -- time - - ackfile (d.."time/ctime.c"), - ackfile (d.."time/asctime.c"), - ackfile (d.."time/localtime.c"), - ackfile (d.."time/clock.c"), - ackfile (d.."time/difftime.c"), - ackfile (d.."time/gmtime.c"), - ackfile (d.."time/mktime.c"), - ackfile (d.."time/strftime.c"), - ackfile (d.."time/time.c"), - ackfile (d.."time/tzset.c"), - ackfile (d.."time/misc.c"), - - install = { - pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libc.a") - } -} - -local headers = group { - install = { - pm.install(d.."headers/sys/time.h", "%BINDIR%include/ansi/sys/time.h"), - pm.install(d.."headers/sys/ioctl.h", "%BINDIR%include/ansi/sys/ioctl.h"), - pm.install(d.."headers/assert.h", "%BINDIR%include/ansi/assert.h"), - pm.install(d.."headers/ctype.h", "%BINDIR%include/ansi/ctype.h"), - pm.install(d.."headers/errno.h", "%BINDIR%include/ansi/errno.h"), - pm.install(d.."headers/float.h", "%BINDIR%include/ansi/float.h"), - pm.install(d.."headers/limits.h", "%BINDIR%include/ansi/limits.h"), - pm.install(d.."headers/math.h", "%BINDIR%include/ansi/math.h"), - pm.install(d.."headers/setjmp.h", "%BINDIR%include/ansi/setjmp.h"), - pm.install(d.."headers/signal.h", "%BINDIR%include/ansi/signal.h"), - pm.install(d.."headers/stdarg.h", "%BINDIR%include/ansi/stdarg.h"), - pm.install(d.."headers/stddef.h", "%BINDIR%include/ansi/stddef.h"), - pm.install(d.."headers/stdint.h", "%BINDIR%include/ansi/stdint.h"), - pm.install(d.."headers/stdio.h", "%BINDIR%include/ansi/stdio.h"), - pm.install(d.."headers/stdlib.h", "%BINDIR%include/ansi/stdlib.h"), - pm.install(d.."headers/string.h", "%BINDIR%include/ansi/string.h"), - pm.install(d.."headers/time.h", "%BINDIR%include/ansi/time.h"), - pm.install(d.."headers/iso646.h", "%BINDIR%include/ansi/iso646.h"), - pm.install(d.."headers/stdbool.h", "%BINDIR%include/ansi/stdbool.h"), - pm.install(d.."headers/locale.h", "%BINDIR%include/ansi/locale.h"), - pm.install(d.."headers/tgmath.h", "%BINDIR%include/ansi/tgmath.h"), - } -} - -lang_cem_ansi_runtime = group { - crt, - libc, - headers -} diff --git a/lang/cem/libcc/gen/pmfile b/lang/cem/libcc/gen/pmfile deleted file mode 100644 index f190777a8..000000000 --- a/lang/cem/libcc/gen/pmfile +++ /dev/null @@ -1,94 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/gen/" - -local head = acklibrary { - ackfile (d.."head_cc.e"), - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/c-knr.o") -} - -local tail = acklibrary { - ackfile (d.."abs.c"), - ackfile (d.."atof.c"), - ackfile (d.."strtod.c"), - ackfile (d.."atoi.c"), - ackfile (d.."atol.c"), - ackfile (d.."strtol.c"), - ackfile (d.."bcmp.c"), - ackfile (d.."bfill.c"), - ackfile (d.."bmove.c"), - ackfile (d.."bzero.c"), - ackfile (d.."calloc.c"), - ackfile (d.."crypt.c"), - ackfile (d.."ctime.c"), - ackfile (d.."asctime.c"), - ackfile (d.."execvp.c"), - ackfile (d.."ffc.c"), - ackfile (d.."ffs.c"), - ackfile (d.."gcvt.c"), - ackfile (d.."ecvt.c"), - ackfile (d.."ext_comp.c"), - ackfile (d.."getlogin.c"), - ackfile (d.."index.c"), - ackfile (d.."l3.c"), - ackfile (d.."ldexp.c"), - ackfile (d.."localtime.c"), - ackfile (d.."gmtime.c"), - ackfile (d.."memccpy.c"), - ackfile (d.."memchr.c"), - ackfile (d.."memcmp.c"), - ackfile (d.."memcpy.c"), - ackfile (d.."memset.c"), - ackfile (d.."mktemp.c"), - ackfile (d.."monitor.c"), - ackfile (d.."perror.c"), - ackfile (d.."procentry.c"), - ackfile (d.."qsort.c"), - ackfile (d.."bsearch.c"), - ackfile (d.."rand.c"), - ackfile (d.."seekdir.c"), - ackfile (d.."sleep.c"), - ackfile (d.."stb.c"), - ackfile (d.."strstr.c"), - ackfile (d.."strchr.c"), - ackfile (d.."strcmp.c"), - ackfile (d.."strcspn.c"), - ackfile (d.."strncat.c"), - ackfile (d.."strrchr.c"), - ackfile (d.."strtok.c"), - ackfile (d.."strpbrk.c"), - ackfile (d.."strspn.c"), - ackfile (d.."swab.c"), - ackfile (d.."telldir.c"), - ackfile (d.."ttyslot.c"), - ackfile (d.."rindex.c"), - ackfile (d.."strncmp.c"), - ackfile (d.."ttyname.c"), - ackfile (d.."closedir.c"), - ackfile (d.."isatty.c"), - ackfile (d.."opendir.c"), - ackfile (d.."malloc.c"), - ackfile (d.."bcopy.c"), - ackfile (d.."readdir.c"), - ackfile (d.."strcat.c"), - ackfile (d.."strcpy.c"), - ackfile (d.."strlen.c"), - ackfile (d.."tzset.c"), - ackfile (d.."getenv.c"), - ackfile (d.."strncpy.c"), - ackfile (d.."_c2type.c"), - ackfile (d.."abort.e"), - ackfile (d.."frexp.e"), - ackfile (d.."modf.e"), - ackfile (d.."setjmp.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libc-knr.a") -} - -lang_cem_gen_runtime = group { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - head, - tail -} diff --git a/lang/cem/libcc/math/pmfile b/lang/cem/libcc/math/pmfile deleted file mode 100644 index 9ba570868..000000000 --- a/lang/cem/libcc/math/pmfile +++ /dev/null @@ -1,31 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/math/" - -lang_cem_math_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."asin.c"), - ackfile (d.."atan2.c"), - ackfile (d.."atan.c"), - ackfile (d.."ceil.c"), - ackfile (d.."fabs.c"), - ackfile (d.."gamma.c"), - ackfile (d.."hypot.c"), - ackfile (d.."jn.c"), - ackfile (d.."j0.c"), - ackfile (d.."j1.c"), - ackfile (d.."log10.c"), - ackfile (d.."pow.c"), - ackfile (d.."log.c"), - ackfile (d.."sin.c"), - ackfile (d.."sinh.c"), - ackfile (d.."sqrt.c"), - ackfile (d.."tan.c"), - ackfile (d.."tanh.c"), - ackfile (d.."exp.c"), - ackfile (d.."floor.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libm-knr.a") -} diff --git a/lang/cem/libcc/mon/pmfile b/lang/cem/libcc/mon/pmfile deleted file mode 100644 index 43865f854..000000000 --- a/lang/cem/libcc/mon/pmfile +++ /dev/null @@ -1,101 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/mon/" - -lang_cem_mon_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h", "%ROOTDIR%include/_tail_mon"}, - - ackfile (d.."exit.c"), - ackfile (d.."gtty.c"), - ackfile (d.."signal.c"), - ackfile (d.."stty.c"), - ackfile (d.."tell.c"), - ackfile (d.."time.c"), - ackfile (d.."cleanup.c"), - ackfile (d.."access.e"), - ackfile (d.."acct.e"), - ackfile (d.."alarm.e"), - ackfile (d.."brk.e"), - ackfile (d.."chdir.e"), - ackfile (d.."chmod.e"), - ackfile (d.."chown.e"), - ackfile (d.."chroot.e"), - ackfile (d.."close.e"), - ackfile (d.."creat.e"), - ackfile (d.."dup.e"), - ackfile (d.."dup2.e"), - ackfile (d.."execl.e"), - ackfile (d.."execle.e"), - ackfile (d.."execv.e"), - ackfile (d.."execve.e"), - ackfile (d.."fork.e"), - ackfile (d.."fstat.e"), - ackfile (d.."ftime.e"), - ackfile (d.."getegid.e"), - ackfile (d.."geteuid.e"), - ackfile (d.."getgid.e"), - ackfile (d.."getpid.e"), - ackfile (d.."getuid.e"), - ackfile (d.."ioctl.e"), - ackfile (d.."kill.e"), - ackfile (d.."link.e"), - ackfile (d.."lock.e"), - ackfile (d.."lseek.e"), - ackfile (d.."mknod.e"), - ackfile (d.."mount.e"), - ackfile (d.."mpxcall.e"), - ackfile (d.."nice.e"), - ackfile (d.."open.e"), - ackfile (d.."pause.e"), - ackfile (d.."pipe.e"), - ackfile (d.."prof.e"), - ackfile (d.."ptrace.e"), - ackfile (d.."read.e"), - ackfile (d.."sbrk.e"), - ackfile (d.."setgid.e"), - ackfile (d.."setuid.e"), - ackfile (d.."setsig.e"), - ackfile (d.."sigtrp.e"), - ackfile (d.."stat.e"), - ackfile (d.."stime.e"), - ackfile (d.."sync.e"), - ackfile (d.."times.e"), - ackfile (d.."umask.e"), - ackfile (d.."umount.e"), - ackfile (d.."unlink.e"), - ackfile (d.."utime.e"), - ackfile (d.."wait.e"), - ackfile (d.."write.e"), - ackfile (d.."errno.e"), - ackfile (d.."_alarm.e"), - ackfile (d.."_brk.e"), - ackfile (d.."_close.e"), - ackfile (d.."_creat.e"), - ackfile (d.."_dup.e"), - ackfile (d.."_dup2.e"), - ackfile (d.."_execl.e"), - ackfile (d.."_execve.e"), - ackfile (d.."_exit.e"), - ackfile (d.."_fork.e"), - ackfile (d.."_fstat.e"), - ackfile (d.."_ftime.e"), - ackfile (d.."_getpid.e"), - ackfile (d.."_gtty.c"), - ackfile (d.."_stty.c"), - ackfile (d.."_ioctl.e"), - ackfile (d.."_kill.e"), - ackfile (d.."_link.e"), - ackfile (d.."_lseek.e"), - ackfile (d.."_open.e"), - ackfile (d.."_pause.e"), - ackfile (d.."_pipe.e"), - ackfile (d.."_read.e"), - ackfile (d.."_sbrk.e"), - ackfile (d.."_times.e"), - ackfile (d.."_unlink.e"), - ackfile (d.."_wait.e"), - ackfile (d.."_write.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libmon.a") -} diff --git a/lang/cem/libcc/pmfile b/lang/cem/libcc/pmfile deleted file mode 100644 index ec566096a..000000000 --- a/lang/cem/libcc/pmfile +++ /dev/null @@ -1,41 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/" - -include (d.."gen/pmfile") -include (d.."math/pmfile") -include (d.."mon/pmfile") -include (d.."stdio/pmfile") - -local headers = group { - install = { - pm.install(d.."headers/assert.h", "%BINDIR%include/knr/assert.h"), - pm.install(d.."headers/ctype.h", "%BINDIR%include/knr/ctype.h"), - pm.install(d.."headers/errno.h", "%BINDIR%include/knr/errno.h"), - pm.install(d.."headers/fcntl.h", "%BINDIR%include/knr/fcntl.h"), - pm.install(d.."headers/grp.h", "%BINDIR%include/knr/grp.h"), - pm.install(d.."headers/math.h", "%BINDIR%include/knr/math.h"), - pm.install(d.."headers/pwd.h", "%BINDIR%include/knr/pwd.h"), - pm.install(d.."headers/setjmp.h", "%BINDIR%include/knr/setjmp.h"), - pm.install(d.."headers/sgtty.h", "%BINDIR%include/knr/sgtty.h"), - pm.install(d.."headers/signal.h", "%BINDIR%include/knr/signal.h"), - pm.install(d.."headers/stdio.h", "%BINDIR%include/knr/stdio.h"), - pm.install(d.."headers/time.h", "%BINDIR%include/knr/time.h"), - pm.install(d.."headers/varargs.h", "%BINDIR%include/knr/varargs.h"), - pm.install(d.."headers/sys/dir.h", "%BINDIR%include/knr/sys/dir.h"), - pm.install(d.."headers/sys/errno.h", "%BINDIR%include/knr/sys/errno.h"), - pm.install(d.."headers/sys/stat.h", "%BINDIR%include/knr/sys/stat.h"), - pm.install(d.."headers/sys/stdtypes.h", "%BINDIR%include/knr/sys/stdtypes.h"), - pm.install(d.."headers/sys/types.h", "%BINDIR%include/knr/sys/types.h"), - pm.install(d.."headers/sys/timeb.h", "%BINDIR%include/knr/sys/timeb.h"), - } -} - -lang_cem_runtime = group { - headers, - lang_cem_gen_runtime, - lang_cem_math_runtime, - lang_cem_mon_runtime, - lang_cem_stdio_runtime -} diff --git a/lang/cem/libcc/stdio/pmfile b/lang/cem/libcc/stdio/pmfile deleted file mode 100644 index 577885838..000000000 --- a/lang/cem/libcc/stdio/pmfile +++ /dev/null @@ -1,58 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/stdio/" - -lang_cem_stdio_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."vsprintf.c"), - ackfile (d.."vfprintf.c"), - ackfile (d.."vprintf.c"), - ackfile (d.."termcap.c"), - ackfile (d.."getopt.c"), - ackfile (d.."clearerr.c"), - ackfile (d.."fgetc.c"), - ackfile (d.."fgets.c"), - ackfile (d.."fprintf.c"), - ackfile (d.."fputc.c"), - ackfile (d.."fputs.c"), - ackfile (d.."fread.c"), - ackfile (d.."freopen.c"), - ackfile (d.."fscanf.c"), - ackfile (d.."ftell.c"), - ackfile (d.."fwrite.c"), - ackfile (d.."getchar.c"), - ackfile (d.."getgrent.c"), - ackfile (d.."getpass.c"), - ackfile (d.."getpw.c"), - ackfile (d.."fopen.c"), - ackfile (d.."getpwent.c"), - ackfile (d.."gets.c"), - ackfile (d.."getw.c"), - ackfile (d.."popen.c"), - ackfile (d.."fdopen.c"), - ackfile (d.."printf.c"), - ackfile (d.."putchar.c"), - ackfile (d.."puts.c"), - ackfile (d.."putw.c"), - ackfile (d.."rewind.c"), - ackfile (d.."fseek.c"), - ackfile (d.."scanf.c"), - ackfile (d.."setbuf.c"), - ackfile (d.."sprintf.c"), - ackfile (d.."doprnt.c"), - ackfile (d.."fltpr.c"), - ackfile (d.."flushbuf.c"), - ackfile (d.."fclose.c"), - ackfile (d.."data.c"), - ackfile (d.."fflush.c"), - ackfile (d.."sscanf.c"), - ackfile (d.."doscan.c"), - ackfile (d.."fillbuf.c"), - ackfile (d.."system.c"), - ackfile (d.."timezone.c"), - ackfile (d.."ungetc.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libc-stdio-knr.a") -} diff --git a/lang/cem/pmfile b/lang/cem/pmfile deleted file mode 100644 index ca8eacd21..000000000 --- a/lang/cem/pmfile +++ /dev/null @@ -1,9 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/" - --- include (d.."cemcom/pmfile") -include (d.."cemcom.ansi/pmfile") --- include (d.."libcc/pmfile") -include (d.."libcc.ansi/pmfile") diff --git a/lang/m2/comp/pmfile b/lang/m2/comp/pmfile deleted file mode 100644 index 0e245b9cc..000000000 --- a/lang/m2/comp/pmfile +++ /dev/null @@ -1,177 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/m2/comp/" - -local extract_parameters = simple { - outputs = { - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/strsize.h", - "%U%/target_sizes.h", - "%U%/debugcst.h", - "%U%/inputtype.h", - "%U%/density.h", - "%U%/squeeze.h", - "%U%/strict3rd.h", - "%U%/nocross.h", - "%U%/nostrict.h", - "%U%/bigresult.h", - "%U%/dbsymtab.h", - "%U%/use_insert.h", - "%U%/uns_arith.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."BigPars") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.H") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.H") }, - allocd_header { outputs = {"%U%/real.h"}, (d.."real.H") }, - allocd_header { outputs = {"%U%/node.h"}, (d.."node.H") }, - lpars - } -} - -lang_m2_compiler = cprogram { - CDEFINES = {PARENT, "STATIC=static"}, - - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."def.c"), - cfile_with_headers (d.."misc.c"), - cfile_with_headers (d.."enter.c"), - cfile_with_headers (d.."defmodule.c"), - cfile_with_headers (d.."typequiv.c"), - cfile_with_headers (d.."node.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."chk_expr.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."walk.c"), - cfile_with_headers (d.."desig.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."lookup.c"), - cfile_with_headers (d.."stab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."def.H"), - file (d.."type.H"), - file (d.."real.H"), - file (d.."node.H"), - file (d.."scope.C"), - file (d.."tmpvar.C"), - file (d.."casestat.C"), - } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-scope.c"}, (d.."scope.C") } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-tmpvar.c"}, (d.."tmpvar.C") } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-casestat.c"}, (d.."casestat.C") } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_m2"}, - install = { - pm.install( "%BINDIR%%PLATDEP%/em_m2"), - pm.install(d.."em_m2.6", "%BINDIR%/man/man6/em_m2.6"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/26 18:19:15 dtrg --- Tweaked the CVS settings. --- --- Revision 1.1 2006/07/26 17:12:19 dtrg --- Added support for the Modula-2 compiler. \ No newline at end of file diff --git a/lang/m2/libm2/pmfile b/lang/m2/libm2/pmfile deleted file mode 100644 index 5b629dd07..000000000 --- a/lang/m2/libm2/pmfile +++ /dev/null @@ -1,99 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/m2/libm2/" - -local headers = group { - install = { - pm.install(d.."Arguments.def", "%BINDIR%include/m2/Arguments.def"), - pm.install(d.."ArraySort.def", "%BINDIR%include/m2/ArraySort.def"), - pm.install(d.."ASCII.def", "%BINDIR%include/m2/ASCII.def"), - pm.install(d.."Conversion.def", "%BINDIR%include/m2/Conversion.def"), - pm.install(d.."CSP.def", "%BINDIR%include/m2/CSP.def"), - pm.install(d.."EM.def", "%BINDIR%include/m2/EM.def"), - pm.install(d.."Epilogue.def", "%BINDIR%include/m2/Epilogue.def"), - pm.install(d.."InOut.def", "%BINDIR%include/m2/InOut.def"), - pm.install(d.."MathLib0.def", "%BINDIR%include/m2/MathLib0.def"), - pm.install(d.."Mathlib.def", "%BINDIR%include/m2/Mathlib.def"), - pm.install(d.."PascalIO.def", "%BINDIR%include/m2/PascalIO.def"), - pm.install(d.."Processes.def", "%BINDIR%include/m2/Processes.def"), - pm.install(d.."random.def", "%BINDIR%include/m2/random.def"), - pm.install(d.."RealConver.def", "%BINDIR%include/m2/RealConver.def"), - pm.install(d.."RealInOut.def", "%BINDIR%include/m2/RealInOut.def"), - pm.install(d.."Semaphores.def", "%BINDIR%include/m2/Semaphores.def"), - pm.install(d.."Storage.def", "%BINDIR%include/m2/Storage.def"), - pm.install(d.."Streams.def", "%BINDIR%include/m2/Streams.def"), - pm.install(d.."Strings.def", "%BINDIR%include/m2/Strings.def"), - pm.install(d.."StripUnix.def", "%BINDIR%include/m2/StripUnix.def"), - pm.install(d.."Termcap.def", "%BINDIR%include/m2/Termcap.def"), --- pm.install(d.."Terminal.def", "%BINDIR%include/m2/Terminal.def"), - pm.install(d.."Traps.def", "%BINDIR%include/m2/Traps.def"), - pm.install(d.."Unix.def", "%BINDIR%include/m2/Unix.def"), - pm.install(d.."XXTermcap.def", "%BINDIR%include/m2/XXTermcap.def"), - } -} - -local head = ackfile { - file (d.."head_m2.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/modula2.o") -} - -local tail = acklibrary { - ackfile (d.."Termcap.mod"), - ackfile (d.."CSP.mod"), - ackfile (d.."PascalIO.mod"), - ackfile (d.."RealInOut.mod"), - ackfile (d.."InOut.mod"), - ackfile (d.."Streams.mod"), --- ackfile (d.."Terminal.mod"), - ackfile (d.."MathLib0.mod"), - ackfile (d.."Mathlib.mod"), - ackfile (d.."Processes.mod"), - ackfile (d.."RealConver.mod"), - ackfile (d.."Storage.mod"), - ackfile (d.."Conversion.mod"), - ackfile (d.."Semaphores.mod"), - ackfile (d.."random.mod"), - ackfile (d.."Strings.mod"), - ackfile (d.."ArraySort.mod"), - ackfile (d.."catch.c"), - ackfile (d.."Traps.mod"), - ackfile (d.."XXTermcap.c"), - ackfile (d.."dvi.c"), - ackfile (d.."Arguments.c"), - ackfile (d.."LtoUset.e"), - ackfile (d.."StrAss.c"), - ackfile (d.."cap.c"), - ackfile (d.."absd.c"), - ackfile (d.."absf.e"), - ackfile (d.."absi.c"), - ackfile (d.."absl.c"), - ackfile (d.."halt.c"), - ackfile (d.."SYSTEM.c"), - ackfile (d.."par_misc.e"), - ackfile (d.."init.c"), - ackfile (d.."sigtrp.c"), - ackfile (d.."store.c"), - ackfile (d.."confarray.c"), - ackfile (d.."load.c"), - ackfile (d.."blockmove.c"), - ackfile (d.."stackprio.c"), - ackfile (d.."ucheck.c"), - ackfile (d.."rcka.c"), - ackfile (d.."rcku.c"), - ackfile (d.."rcki.c"), - ackfile (d.."rckul.c"), - ackfile (d.."rckil.c"), - ackfile (d.."EM.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libmodula2.a") -} - -lang_m2_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - headers, - head, - tail -} diff --git a/lang/m2/pmfile b/lang/m2/pmfile deleted file mode 100644 index 59270fd62..000000000 --- a/lang/m2/pmfile +++ /dev/null @@ -1,7 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/m2/" - -include (d.."comp/pmfile") -include (d.."libm2/pmfile") diff --git a/lang/occam/comp/pmfile b/lang/occam/comp/pmfile deleted file mode 100644 index 3a862d87d..000000000 --- a/lang/occam/comp/pmfile +++ /dev/null @@ -1,62 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/occam/comp/" - -local lpars = LLgen { - file (d.."occam.g"), -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars - } -} - -lang_occam_compiler = cprogram { - CLIBRARIES = {PARENT, "fl"}, - - cfile_with_headers (d.."builtin.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."em.c"), - cfile_with_headers (d.."expr.c"), - cfile_with_headers (d.."keytab.c"), - cfile_with_headers (d.."report.c"), - cfile_with_headers (d.."symtab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - flex (d.."lex.l") - }, - - lib_em_mes, - lib_emk, - lib_em_data, --- lib_input, --- lib_assert, - lib_alloc, --- lib_flt_arith, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_occam"}, - install = { - pm.install("%BINDIR%%PLATDEP%/em_occam"), - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/26 18:23:32 dtrg --- Added support for the Occam compiler. --- \ No newline at end of file diff --git a/lang/occam/lib/pmfile b/lang/occam/lib/pmfile deleted file mode 100644 index 4ed36f62a..000000000 --- a/lang/occam/lib/pmfile +++ /dev/null @@ -1,21 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/occam/lib/" - -lang_occam_lib_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."builtin.c"), - ackfile (d.."chan_strct.c"), - ackfile (d.."channel.c"), - ackfile (d.."co.c"), - ackfile (d.."misc.e"), - ackfile (d.."now.c"), - ackfile (d.."ocrt.c"), - ackfile (d.."par.c"), - ackfile (d.."par_misc.e"), - ackfile (d.."parco.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/liboccam.a") -} diff --git a/lang/occam/pmfile b/lang/occam/pmfile deleted file mode 100644 index 7c46574af..000000000 --- a/lang/occam/pmfile +++ /dev/null @@ -1,20 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/occam/" - -include (d.."comp/pmfile") -include (d.."lib/pmfile") - -local headers = group { - install = { - pm.install(d.."headers/dec.ocm", "%BINDIR%include/occam/dec.ocm"), - pm.install(d.."headers/printd.ocm", "%BINDIR%include/occam/printd.ocm"), - pm.install(d.."headers/prints.ocm", "%BINDIR%include/occam/prints.ocm"), - } -} - -lang_occam_runtime = group { - headers, - lang_occam_lib_runtime -} diff --git a/lang/pc/comp/pmfile b/lang/pc/comp/pmfile deleted file mode 100644 index d0dae7907..000000000 --- a/lang/pc/comp/pmfile +++ /dev/null @@ -1,169 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/pc/comp/" - -local extract_parameters = simple { - outputs = { - "%U%/debugcst.h", - "%U%/density.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/inputtype.h", - "%U%/numsize.h", - "%U%/strsize.h", - "%U%/target_sizes.h", - "%U%/nocross.h", - "%U%/dbsymtab.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."Parameters") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.H") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.H") }, - allocd_header { outputs = {"%U%/scope.h"}, (d.."scope.H") }, - allocd_header { outputs = {"%U%/node.h"}, (d.."node.H") }, - allocd_header { outputs = {"%U%/desig.h"}, (d.."desig.H") }, - lpars - } -} - -lang_pc_compiler = cprogram { - CDEFINES = {PARENT, "STATIC=static"}, - - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."body.c"), - cfile_with_headers (d.."chk_expr.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."def.c"), - cfile_with_headers (d.."desig.c"), - cfile_with_headers (d.."enter.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."label.c"), - cfile_with_headers (d.."lookup.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."misc.c"), - cfile_with_headers (d.."node.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."progs.c"), - cfile_with_headers (d.."readwrite.c"), - cfile_with_headers (d.."scope.c"), - cfile_with_headers (d.."stab.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."typequiv.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."def.H"), - file (d.."type.H"), - file (d.."node.H"), - file (d.."scope.H"), - file (d.."desig.H"), - file (d.."tmpvar.C"), - file (d.."casestat.C"), - } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-tmpvar.c"}, (d.."tmpvar.C") } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-casestat.c"}, (d.."casestat.C") } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_pc"}, - install = { - pm.install( "%BINDIR%%PLATDEP%/em_pc"), - pm.install(d.."em_pc.6", "%BINDIR%/man/man6/em_pc.6"), - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/22 21:03:07 dtrg --- Added support for the Pascal compiler. --- \ No newline at end of file diff --git a/lang/pc/libpc/pmfile b/lang/pc/libpc/pmfile deleted file mode 100644 index b63c635b2..000000000 --- a/lang/pc/libpc/pmfile +++ /dev/null @@ -1,95 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/pc/libpc/" - -head = ackfile { - file (d.."head_pc.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/pascal.o") -} - -tail = acklibrary { - ackfile (d.."abi.c"), - ackfile (d.."abl.c"), - ackfile (d.."abr.c"), - ackfile (d.."arg.c"), - ackfile (d.."ass.c"), - ackfile (d.."asz.c"), - ackfile (d.."atn.c"), - ackfile (d.."bcp.c"), - ackfile (d.."bts.e"), - ackfile (d.."buff.c"), - ackfile (d.."clock.c"), - ackfile (d.."diag.c"), - ackfile (d.."dis.c"), - ackfile (d.."efl.c"), - ackfile (d.."eln.c"), - ackfile (d.."encaps.e"), - ackfile (d.."exp.c"), - ackfile (d.."get.c"), - ackfile (d.."gto.e"), - ackfile (d.."hlt.c"), - ackfile (d.."ini.c"), - ackfile (d.."catch.c"), - ackfile (d.."log.c"), - ackfile (d.."mdi.c"), - ackfile (d.."mdl.c"), - ackfile (d.."new.c"), - ackfile (d.."nobuff.c"), - ackfile (d.."notext.c"), - ackfile (d.."opn.c"), - ackfile (d.."hol0.e"), - ackfile (d.."pac.c"), - ackfile (d.."pclose.c"), - ackfile (d.."pcreat.c"), - ackfile (d.."pentry.c"), - ackfile (d.."perrno.c"), - ackfile (d.."pexit.c"), - ackfile (d.."popen.c"), - ackfile (d.."cls.c"), - ackfile (d.."put.c"), - ackfile (d.."rdc.c"), - ackfile (d.."rdl.c"), - ackfile (d.."rdr.c"), - ackfile (d.."rdi.c"), - ackfile (d.."rln.c"), - ackfile (d.."rf.c"), - ackfile (d.."rnd.c"), - ackfile (d.."sav.e"), - ackfile (d.."sig.e"), - ackfile (d.."sin.c"), - ackfile (d.."sqt.c"), - ackfile (d.."fef.e"), - ackfile (d.."string.c"), - ackfile (d.."trap.e"), - ackfile (d.."unp.c"), - ackfile (d.."uread.c"), - ackfile (d.."uwrite.c"), - ackfile (d.."wdw.c"), - ackfile (d.."incpt.c"), - ackfile (d.."wrc.c"), - ackfile (d.."wrf.c"), - ackfile (d.."wri.c"), - ackfile (d.."wrl.c"), - ackfile (d.."wrr.c"), - ackfile (d.."cvt.c"), - ackfile (d.."fif.e"), - ackfile (d.."wrz.c"), - ackfile (d.."wrs.c"), - ackfile (d.."outcpt.c"), - ackfile (d.."wf.c"), - ackfile (d.."nfa.c"), - ackfile (d.."rcka.c"), - ackfile (d.."trp.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libpascal.a") -} - -lang_pc_runtime = group { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - head, - tail -} - diff --git a/lang/pc/pmfile b/lang/pc/pmfile deleted file mode 100644 index b1e0be707..000000000 --- a/lang/pc/pmfile +++ /dev/null @@ -1,7 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/pc/" - -include (d.."comp/pmfile") -include (d.."libpc/pmfile") diff --git a/mach/6500/dl/pmfile b/mach/6500/dl/pmfile deleted file mode 100644 index b5c904c4b..000000000 --- a/mach/6500/dl/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = "mach/6500/dl/" - -tool_6500_dl = cprogram { - cfile (d.."dl.c"), - - lib_object, - - outputs = {"%U%/dl"}, - install = pm.install(BINDIR..PLATDEP.."/6500/dl") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/6500/libem/pmfile b/mach/6500/libem/pmfile deleted file mode 100644 index dd12b24be..000000000 --- a/mach/6500/libem/pmfile +++ /dev/null @@ -1,98 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/6500/libem/" - -libem_6500 = acklibrary { - outputs = {"%U%/libem-%ARCH%.a"}, - - ackfile (d.."adi4.s"), - ackfile (d.."cmi.s"), - ackfile (d.."cmi4.s"), - ackfile (d.."sbi4.s"), - ackfile (d.."addsub.s"), - ackfile (d.."cmu4.s"), - ackfile (d.."dum_float.s"), - ackfile (d.."dvi4.s"), - ackfile (d.."dvu4.s"), - ackfile (d.."lar.s"), - ackfile (d.."lol.s"), - ackfile (d.."los.s"), - ackfile (d.."loil.s"), - ackfile (d.."loi1.s"), - ackfile (d.."loi.s"), - ackfile (d.."mli4.s"), - ackfile (d.."mlu.s"), - ackfile (d.."mlu4.s"), - ackfile (d.."mul4.s"), - ackfile (d.."rmi.s"), - ackfile (d.."rmi4.s"), - ackfile (d.."div4.s"), - ackfile (d.."rmu.s"), - ackfile (d.."dvi.s"), - ackfile (d.."rmu4.s"), - ackfile (d.."duv4.s"), - ackfile (d.."ngi4.s"), - ackfile (d.."rtt.s"), - ackfile (d.."ret.s"), - ackfile (d.."sar.s"), - ackfile (d.."aar.s"), - ackfile (d.."adi.s"), - ackfile (d.."sbi.s"), - ackfile (d.."mli.s"), - ackfile (d.."ngi.s"), - ackfile (d.."set.s"), - ackfile (d.."zer.s"), - ackfile (d.."stl.s"), - ackfile (d.."sts.s"), - ackfile (d.."sdl.s"), - ackfile (d.."sti.s"), - ackfile (d.."stil.s"), - ackfile (d.."blm.s"), - ackfile (d.."sti1.s"), - ackfile (d.."test2.s"), - ackfile (d.."testFFh.s"), - ackfile (d.."trap.s"), - ackfile (d.."ldi.s"), - ackfile (d.."data.s"), - ackfile (d.."zri.s"), - ackfile (d.."locaddr.s"), - ackfile (d.."and.s"), - ackfile (d.."asp.s"), - ackfile (d.."cii.s"), - ackfile (d.."cms.s"), - ackfile (d.."cmu.s"), - ackfile (d.."com.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvu.s"), - ackfile (d.."exg.s"), - ackfile (d.."exg2.s"), - ackfile (d.."gto.s"), - ackfile (d.."indir.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."lcs.s"), - ackfile (d.."lxa1.s"), - ackfile (d.."lxa2.s"), - ackfile (d.."lxl.s"), - ackfile (d.."pro.s"), - ackfile (d.."rol.s"), - ackfile (d.."rol4.s"), - ackfile (d.."ror.s"), - ackfile (d.."ror4.s"), - ackfile (d.."sli.s"), - ackfile (d.."sli4.s"), - ackfile (d.."sri.s"), - ackfile (d.."sri4.s"), - ackfile (d.."teq.s"), - ackfile (d.."tge.s"), - ackfile (d.."tgt.s"), - ackfile (d.."tle.s"), - ackfile (d.."tlt.s"), - ackfile (d.."tne.s"), - ackfile (d.."xor.s"), - - install = pm.install("%BINDIR%lib/%ARCH%/tail_em"), -} diff --git a/mach/6500/pmfile b/mach/6500/pmfile deleted file mode 100644 index 3bd8606b9..000000000 --- a/mach/6500/pmfile +++ /dev/null @@ -1,33 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/6500/" - -include (d.."dl/pmfile") -include (d.."libem/pmfile") - -mach_6500 = group { - ARCH = "6500", - - proto_cg, - proto_as, - tool_6500_dl, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - -support_6500 = group { - ARCH = "6500", - OPTIMISATION = "-O", - - libem_6500, -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/6800/pmfile b/mach/6800/pmfile deleted file mode 100644 index 516ab67de..000000000 --- a/mach/6800/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_6800 = group { - ARCH = "6800", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/mach/6805/pmfile b/mach/6805/pmfile deleted file mode 100644 index 926369a08..000000000 --- a/mach/6805/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_6805 = group { - ARCH = "6805", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/6809/pmfile b/mach/6809/pmfile deleted file mode 100644 index 3fc289783..000000000 --- a/mach/6809/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_6809 = group { - ARCH = "6809", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/arm/cv/pmfile b/mach/arm/cv/pmfile deleted file mode 100644 index 8ca8a9a4a..000000000 --- a/mach/arm/cv/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/arm/cv/" - -tool_arm_cv = cprogram { - cfile (d.."cv.c"), - - lib_object, - - outputs = {"%U%/cv"}, - install = pm.install(BINDIR.."%PLATDEP%/arm/dl") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/arm/pmfile b/mach/arm/pmfile deleted file mode 100644 index a7dbafc16..000000000 --- a/mach/arm/pmfile +++ /dev/null @@ -1,26 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/arm/" - -include (d.."cv/pmfile") - -mach_arm = group { - ARCH = "arm", - - proto_as, - proto_ncg { ARCHDIR = "arm" }, - proto_top, - tool_arm_cv, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/i386/cv/pmfile b/mach/i386/cv/pmfile deleted file mode 100644 index c68a47b79..000000000 --- a/mach/i386/cv/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/i386/cv/" - -tool_i386_cv = cprogram { - cfile (d.."cv.c"), - - lib_object, - - outputs = {"%U%/cv"}, - install = pm.install(BINDIR.."%PLATDEP%/i386/dl") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/i386/libem/pmfile b/mach/i386/libem/pmfile deleted file mode 100644 index d477e8170..000000000 --- a/mach/i386/libem/pmfile +++ /dev/null @@ -1,56 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i386/libem/" - -libem_i386 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ackfile (d.."adi.s"), - ackfile (d.."and.s"), - ackfile (d.."blm.s"), - ackfile (d.."cii.s"), - ackfile (d.."cms.s"), - ackfile (d.."com.s"), - ackfile (d.."csa4.s"), - ackfile (d.."csb4.s"), - ackfile (d.."cuu.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvi.s"), - ackfile (d.."dvu.s"), - ackfile (d.."error.s"), - ackfile (d.."exg.s"), - ackfile (d.."fp8087.s"), - ackfile (d.."fat.s"), - ackfile (d.."gto.s"), - ackfile (d.."iaar.s"), - ackfile (d.."ilar.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."isar.s"), - ackfile (d.."lar4.s"), - ackfile (d.."loi.s"), - ackfile (d.."mli.s"), - ackfile (d.."mon.s"), - ackfile (d.."ngi.s"), - ackfile (d.."nop.s"), - ackfile (d.."print.s"), - ackfile (d.."rck.s"), - ackfile (d.."rmi.s"), - ackfile (d.."rmu.s"), - ackfile (d.."rol.s"), - ackfile (d.."ror.s"), - ackfile (d.."sar4.s"), - ackfile (d.."sbi.s"), - ackfile (d.."set.s"), - ackfile (d.."sli.s"), - ackfile (d.."sri.s"), - ackfile (d.."sti.s"), - ackfile (d.."strhp.s"), - ackfile (d.."trp.s"), - ackfile (d.."unknown.s"), - ackfile (d.."xor.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/i386/libend/pmfile b/mach/i386/libend/pmfile deleted file mode 100644 index a5ae6730c..000000000 --- a/mach/i386/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i386/libend/" - -libend_i386 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/i386/pmfile b/mach/i386/pmfile deleted file mode 100644 index 250bce325..000000000 --- a/mach/i386/pmfile +++ /dev/null @@ -1,22 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i386/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_i386 = group { - proto_as, - proto_ncg { ARCHDIR = "i386" }, - ego_descr, -} - -support_i386 = group { - OPTIMISATION = "-O", - - libem_i386, - libend_i386, -} - diff --git a/mach/i80/libem/pmfile b/mach/i80/libem/pmfile deleted file mode 100644 index ecc69cf16..000000000 --- a/mach/i80/libem/pmfile +++ /dev/null @@ -1,49 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i80/libem/" - -libem_i80 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ackfile (d.."aar2.s"), - ackfile (d.."adi4.s"), - ackfile (d.."and.s"), - ackfile (d.."blm.s"), - ackfile (d.."cii.s"), - ackfile (d.."cmi4.s"), - ackfile (d.."cms.s"), - ackfile (d.."com.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvi2.s"), - ackfile (d.."exg.s"), - ackfile (d.."flp.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."lar2.s"), - ackfile (d.."mli2.s"), - ackfile (d.."mli4.s"), - ackfile (d.."mlu2.s"), - ackfile (d.."ngi4.s"), - ackfile (d.."nop.s"), - ackfile (d.."rol4.s"), - ackfile (d.."ror4.s"), - ackfile (d.."sar2.s"), - ackfile (d.."sbi4.s"), - ackfile (d.."set.s"), - ackfile (d.."set2.s"), - ackfile (d.."sli2.s"), - ackfile (d.."sli4.s"), - ackfile (d.."sri2.s"), - ackfile (d.."sri4.s"), - ackfile (d.."xor.s"), - ackfile (d.."loi.s"), - ackfile (d.."sti.s"), - ackfile (d.."dvi4.s"), - ackfile (d.."rck.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/i80/libend/pmfile b/mach/i80/libend/pmfile deleted file mode 100644 index 78e6bb5f3..000000000 --- a/mach/i80/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i80/libend/" - -libend_i80 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/i80/pmfile b/mach/i80/pmfile deleted file mode 100644 index d87cef81f..000000000 --- a/mach/i80/pmfile +++ /dev/null @@ -1,25 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/i80/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_i80 = group { - ARCH = "i80", - - proto_as, - proto_ncg { ARCHDIR = "i80" }, - proto_top, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - -support_i80 = group { - OPTIMISATION = "-O", - - libem_i80, - libend_i80, -} - diff --git a/mach/i86/libem/pmfile b/mach/i86/libem/pmfile deleted file mode 100644 index b0baa9ede..000000000 --- a/mach/i86/libem/pmfile +++ /dev/null @@ -1,71 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i86/libem/" - -libem_i86 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ackfile (d.."adi.s"), - ackfile (d.."and.s"), - ackfile (d.."cii.s"), - ackfile (d.."cms.s"), - ackfile (d.."cmi4.s"), - ackfile (d.."cmu4.s"), - ackfile (d.."com.s"), - ackfile (d.."csa2.s"), - ackfile (d.."csb2.s"), - ackfile (d.."csa4.s"), - ackfile (d.."csb4.s"), - ackfile (d.."cuu.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvi.s"), - ackfile (d.."dvi4.s"), - ackfile (d.."dvu.s"), - ackfile (d.."dvu4.s"), - ackfile (d.."exg.s"), - ackfile (d.."fp8087.s"), - ackfile (d.."gto.s"), - ackfile (d.."iaar.s"), - ackfile (d.."ilar.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."isar.s"), - ackfile (d.."lar2.s"), - ackfile (d.."loi.s"), - ackfile (d.."mli.s"), - ackfile (d.."mli4.s"), - ackfile (d.."mon.s"), - ackfile (d.."ngi.s"), - ackfile (d.."nop.s"), - ackfile (d.."rck.s"), - ackfile (d.."rmi.s"), - ackfile (d.."rmi4.s"), - ackfile (d.."rmu.s"), - ackfile (d.."rmu4.s"), - ackfile (d.."rol.s"), - ackfile (d.."ror.s"), - ackfile (d.."sar2.s"), - ackfile (d.."sbi.s"), - ackfile (d.."set.s"), - ackfile (d.."sli.s"), - ackfile (d.."sri.s"), - ackfile (d.."sti.s"), - ackfile (d.."strhp.s"), - ackfile (d.."xor.s"), - ackfile (d.."error.s"), - ackfile (d.."unknown.s"), - ackfile (d.."fat.s"), - ackfile (d.."trp.s"), - ackfile (d.."print.s"), - ackfile (d.."ret6.s"), - ackfile (d.."ret8.s"), - ackfile (d.."lfr6.s"), - ackfile (d.."lfr8.s"), - ackfile (d.."retarea.s"), - ackfile (d.."blm.s"), - ackfile (d.."return.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/i86/libend/pmfile b/mach/i86/libend/pmfile deleted file mode 100644 index 4b6843bd0..000000000 --- a/mach/i86/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i86/libend/" - -libend_i86 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/i86/pmfile b/mach/i86/pmfile deleted file mode 100644 index f2a26337e..000000000 --- a/mach/i86/pmfile +++ /dev/null @@ -1,22 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/i86/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_i86 = group { - proto_as, - proto_ncg { ARCHDIR = "i86" }, - ego_descr, -} - -support_i86 = group { - OPTIMISATION = "-O", - ACKBUILDFLAGS = {PARENT, "-ansi"}, - - libem_i86, - libend_i86, -} - diff --git a/mach/m68020/libem/pmfile b/mach/m68020/libem/pmfile deleted file mode 100644 index 0969eaa67..000000000 --- a/mach/m68020/libem/pmfile +++ /dev/null @@ -1,38 +0,0 @@ --- $Source: /cvsroot/tack/Ack/mach/i386/libem/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."mach/m68020/libem/" - -libem_m68020 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ACKINCLUDES = {PARENT, ROOTDIR.."h"}, - - ackfile (d.."fp68881.s"), - ackfile (d.."aar.s"), - ackfile (d.."lar.s"), - ackfile (d.."sar.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."shp.s"), - ackfile (d.."set.s"), - ackfile (d.."inn.s"), - ackfile (d.."fat.s"), - ackfile (d.."trp.s"), - ackfile (d.."trpstr.c"), - ackfile (d.."mon.s"), - ackfile (d.."nop.s"), - ackfile (d.."dia.s"), - ackfile (d.."cii.s"), - ackfile (d.."cuu.s"), - ackfile (d.."cmi.s"), - ackfile (d.."cms.s"), - ackfile (d.."cmu.s"), - ackfile (d.."cvf.s"), - ackfile (d.."exg.s"), - ackfile (d.."los.s"), - ackfile (d.."sts.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/m68020/libend/pmfile b/mach/m68020/libend/pmfile deleted file mode 100644 index 5e7e7e95e..000000000 --- a/mach/m68020/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source: /cvsroot/tack/Ack/mach/i386/libend/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."mach/m68020/libend/" - -libend_m68020 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/m68020/pmfile b/mach/m68020/pmfile deleted file mode 100644 index 9481a3bbb..000000000 --- a/mach/m68020/pmfile +++ /dev/null @@ -1,23 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/m68020/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_m68020 = group { - ARCH = "m68020", - - proto_as, - proto_ncg { ARCHDIR = "m68020" }, - proto_top, - ego_descr, -} - -support_m68020 = group { - OPTIMISATION = "-O6", - - libem_m68020, - libend_m68020, -} diff --git a/mach/m68k2/pmfile b/mach/m68k2/pmfile deleted file mode 100644 index 30c0e5545..000000000 --- a/mach/m68k2/pmfile +++ /dev/null @@ -1,30 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/m68k2/" - -mach_m68k2 = group { - ARCH = "m68k2", - - proto_as, - proto_ncg { ARCHDIR = "m68020" }, - proto_top, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - - --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/m68k4/pmfile b/mach/m68k4/pmfile deleted file mode 100644 index 161b6ba2c..000000000 --- a/mach/m68k4/pmfile +++ /dev/null @@ -1,25 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/m68k4/" - -mach_m68k4 = group { - ARCH = "m68k4", - - proto_ncg { ARCHDIR = "m68020" }, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/ns/pmfile b/mach/ns/pmfile deleted file mode 100644 index 6696e302d..000000000 --- a/mach/ns/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/ns/" - -mach_ns = group { - ARCH = "ns", - - proto_as, - proto_ncg { ARCHDIR = "ns" }, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/pdp/pmfile b/mach/pdp/pmfile deleted file mode 100644 index 65cfc62f7..000000000 --- a/mach/pdp/pmfile +++ /dev/null @@ -1,30 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/pdp/" - -mach_pdp = group { - ARCH = "pdp", - - proto_as, - proto_cg, - proto_ncg { ARCHDIR = "pdp" }, - proto_top, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. --- diff --git a/mach/powerpc/libem/pmfile b/mach/powerpc/libem/pmfile deleted file mode 100644 index 8c851f81e..000000000 --- a/mach/powerpc/libem/pmfile +++ /dev/null @@ -1,30 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/powerpc/libem/" - -libem_powerpc = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ACKINCLUDES = {PARENT, d}, - - ackfile (d.."ret.s"), - ackfile (d.."tge.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."los.s"), - ackfile (d.."sts.s"), - ackfile (d.."aar4.s"), - ackfile (d.."fef8.c"), - ackfile (d.."fif8.s"), - ackfile (d.."cif8.s"), - ackfile (d.."cuf8.s"), - ackfile (d.."cfi8.s"), - ackfile (d.."cfu8.s"), - ackfile (d.."fd_00000000.s"), - ackfile (d.."fd_80000000.s"), - ackfile (d.."fd_FFFFFFFF.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/powerpc/libend/pmfile b/mach/powerpc/libend/pmfile deleted file mode 100644 index 83f1c038d..000000000 --- a/mach/powerpc/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/powerpc/libend/" - -libend_powerpc = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/powerpc/pmfile b/mach/powerpc/pmfile deleted file mode 100644 index 8e4913560..000000000 --- a/mach/powerpc/pmfile +++ /dev/null @@ -1,23 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/powerpc/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_powerpc = group { - ARCH = "powerpc", - - proto_as, - proto_ncg { ARCHDIR = "powerpc" }, - proto_top, --- ego_descr, -} - -support_powerpc = group { - OPTIMISATION = "-O", - - libem_powerpc, - libend_powerpc, -} diff --git a/mach/proto/as/pmfile b/mach/proto/as/pmfile deleted file mode 100644 index c908fceb5..000000000 --- a/mach/proto/as/pmfile +++ /dev/null @@ -1,67 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/as/" - -local parser = yacc { - simple { - outputs = {"%U%-%I%.y"}, - command = { - "cd %out[1]:dirname% && ".. - "%BINDIR%%PLATDEP%/cpp.ansi -P -I%ROOTDIR%mach/%ARCH%/as -I"..d.." %CINCLUDES:cincludes% %in[1]% > %out[1]%" - }, - - file (d.."comm2.y"), - } -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - CINCLUDES = {PARENT, "%ROOTDIR%mach/%ARCH%/as"}, - - dynamicheaders = { - parser, - } -} - -proto_as = cprogram { - class = "proto_as", - - cfile_with_tables (d.."comm3.c"), - cfile_with_tables (d.."comm4.c"), - cfile_with_tables (d.."comm5.c"), - cfile_with_tables (d.."comm6.c"), - cfile_with_tables (d.."comm7.c"), - cfile_with_tables (d.."comm8.c"), - - cfile { - parser, - }, - - lib_object, - - outputs = {"%U%/%PLATFORM%-as"}, - install = pm.install(BINDIR.."%PLATDEP%/%PLATFORM%/as") -} - --- Revision history --- $Log$ --- Revision 1.5 2007-04-21 22:55:59 dtrg --- yacc source files are now run through the ANSI C preprocessor, not the K&R one. --- --- Revision 1.4 2007/02/20 00:45:19 dtrg --- Done a major overhaul of the way target include files are installed and --- how platform libraries are built. The ARCH pm variable has now been --- renamed PLATFORM (which is more accurate) and a different ARCH --- variable added, which represents the CPU family rather than the --- hardware platform. --- --- Revision 1.3 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/30 23:41:16 dtrg --- Broke dependency on tool_cpp in order to speed up the build. --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. --- diff --git a/mach/proto/cg/pmfile b/mach/proto/cg/pmfile deleted file mode 100644 index d74c4ecbc..000000000 --- a/mach/proto/cg/pmfile +++ /dev/null @@ -1,67 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/cg/" - -local make_tables = cgg { - CGGINCLUDEDIR = (ROOTDIR.."mach/%PLATFORM%/cg/"), - file (ROOTDIR.."mach/%PLATFORM%/cg/table") -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - dynamicheaders = { - make_tables, - file (ROOTDIR.."mach/%PLATFORM%/cg/"), - file (ROOTDIR.."mach/") - } -} - -proto_cg = cprogram { - class = "proto_cg", - - cfile_with_tables (d.."codegen.c"), - cfile_with_tables (d.."compute.c"), - cfile_with_tables (d.."equiv.c"), - cfile_with_tables (d.."gencode.c"), - cfile_with_tables (d.."glosym.c"), - cfile_with_tables (d.."move.c"), - cfile_with_tables (d.."nextem.c"), - cfile_with_tables (d.."reg.c"), - cfile_with_tables (d.."regvar.c"), - cfile_with_tables (d.."salloc.c"), - cfile_with_tables (d.."state.c"), - cfile_with_tables (d.."subr.c"), - cfile_with_tables (d.."var.c"), - cfile_with_tables (d.."fillem.c"), - cfile_with_tables (d.."main.c"), - - cfile { - ith { make_tables, i = 1 }, - dynamicheaders = { - file (ROOTDIR.."mach/%PLATFORM%/cg/"), - file (d) - } - }, - - lib_em_data, - lib_flt_arith, - - outputs = {"%U%/%PLATFORM%-cg"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/cg") -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-20 00:45:19 dtrg --- Done a major overhaul of the way target include files are installed and --- how platform libraries are built. The ARCH pm variable has now been --- renamed PLATFORM (which is more accurate) and a different ARCH --- variable added, which represents the CPU family rather than the --- hardware platform. --- --- Revision 1.2 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. diff --git a/mach/proto/ncg/pmfile b/mach/proto/ncg/pmfile deleted file mode 100644 index 7f29aaa09..000000000 --- a/mach/proto/ncg/pmfile +++ /dev/null @@ -1,57 +0,0 @@ --- $Source: /cvsroot/tack/Ack/mach/proto/ncg/pmfile,v $ --- $State: Exp $ - -local d = ROOTDIR.."mach/proto/ncg/" - -local make_tables = ncgg { - NCGGINCLUDEDIR = (ROOTDIR.."mach/%ARCHDIR%/ncg/"), - file (ROOTDIR.."mach/%ARCHDIR%/ncg/table") -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - dynamicheaders = { - make_tables, - } -} - -proto_ncg = cprogram { - class = "proto_ncg", - - exename = "ncg", - - CINCLUDES = { - PARENT, - "mach/%PLATFORM%/ncg", - "mach/%ARCHDIR%/ncg", - "mach" - }, - - cfile_with_tables (d.."codegen.c"), - cfile_with_tables (d.."compute.c"), - cfile_with_tables (d.."equiv.c"), - cfile_with_tables (d.."fillem.c"), - cfile_with_tables (d.."gencode.c"), - cfile_with_tables (d.."glosym.c"), - cfile_with_tables (d.."label.c"), - cfile_with_tables (d.."main.c"), - cfile_with_tables (d.."move.c"), - cfile_with_tables (d.."nextem.c"), - cfile_with_tables (d.."reg.c"), - cfile_with_tables (d.."regvar.c"), - cfile_with_tables (d.."salloc.c"), - cfile_with_tables (d.."state.c"), - cfile_with_tables (d.."subr.c"), - cfile_with_tables (d.."var.c"), - - cfile { - ith { make_tables, i = 1 }, - CINCLUDES = {PARENT, d}, - }, - - lib_em_data, - lib_flt_arith, - - outputs = {"%U%/%PLATFORM%-%exename%"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/%exename%") -} diff --git a/mach/proto/pmfile b/mach/proto/pmfile deleted file mode 100644 index 9ae89d391..000000000 --- a/mach/proto/pmfile +++ /dev/null @@ -1,18 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/" - -include (d.."as/pmfile") -include (d.."cg/pmfile") -include (d.."ncg/pmfile") -include (d.."top/pmfile") - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/proto/top/pmfile b/mach/proto/top/pmfile deleted file mode 100644 index 121bb6ce2..000000000 --- a/mach/proto/top/pmfile +++ /dev/null @@ -1,32 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/top/" - -local make_tables = topgen { - file (ROOTDIR.."mach/%ARCH%/top/table") -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - dynamicheaders = { - make_tables, - } -} - -proto_top = cprogram { - CINCLUDES = { - PARENT, - "mach/%ARCH%/ncg", - "mach", - d - }, - - cfile_with_tables (d.."queue.c"), - cfile_with_tables (d.."top.c"), - - lib_string, - - outputs = {"%U%/%ARCH%-top"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/top") -} diff --git a/mach/s2650/pmfile b/mach/s2650/pmfile deleted file mode 100644 index d9d41c9cd..000000000 --- a/mach/s2650/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_s2650 = group { - ARCH = "s2650", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/vax4/pmfile b/mach/vax4/pmfile deleted file mode 100644 index 55ac2a34f..000000000 --- a/mach/vax4/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/vax4/" - -mach_vax4 = group { - ARCH = "vax4", - - proto_as, - proto_cg, - proto_top, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/z80/pmfile b/mach/z80/pmfile deleted file mode 100644 index 41d92d389..000000000 --- a/mach/z80/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/z80/" - -mach_z80 = group { - ARCH = "z80", - - proto_as, - proto_cg, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/z8000/pmfile b/mach/z8000/pmfile deleted file mode 100644 index a596356c2..000000000 --- a/mach/z8000/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/z8000/" - -mach_z8000 = group { - ARCH = "z8000", - - proto_as, - proto_cg, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/alloc/pmfile b/modules/src/alloc/pmfile deleted file mode 100644 index 5200f3097..000000000 --- a/modules/src/alloc/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."modules/src/alloc/" -lib_alloc = file (LIBDIR.."liballoc.a") - -module_alloc = clibrary { - cfile (d.."Malloc.c"), - cfile (d.."Salloc.c"), - cfile (d.."Srealloc.c"), - cfile (d.."Realloc.c"), - cfile (d.."botch.c"), - cfile (d.."clear.c"), - cfile (d.."st_alloc.c"), - cfile (d.."std_alloc.c"), - cfile (d.."No_Mem.c"), - - outputs = {"%U%/liballoc.a"}, - install = { - pm.install(LIBDIR.."liballoc.a"), - pm.install(d.."alloc.h", HEADERDIR.."alloc.h") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/assert/pmfile b/modules/src/assert/pmfile deleted file mode 100644 index 72d72b5bb..000000000 --- a/modules/src/assert/pmfile +++ /dev/null @@ -1,20 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/assert/" -lib_assert = file (LIBDIR.."libassert.a") - -module_assert = clibrary { - cfile (d.."BadAssert.c"), - - outputs = {"%U%/libassert.a"}, - install = { - pm.install(LIBDIR.."libassert.a") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/em_code/pmfile b/modules/src/em_code/pmfile deleted file mode 100644 index 60ce20d91..000000000 --- a/modules/src/em_code/pmfile +++ /dev/null @@ -1,112 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/em_code/" -lib_eme = file (LIBDIR.."libeme.a") -lib_emk = file (LIBDIR.."libemk.a") - -local em_codeMK_h = simple { - outputs = {"%U%-%I%.h"}, - command = { - "%in[1]% %in[2]% "..d.."em.nogen > %out%", - "cat "..d.."em.nogen >> %out%" - }, - install = pm.install(HEADERDIR.."em_codeEK.h"), - - file (d.."make.em.gen"), - file ("%ROOTDIR%h/em_table") -} - -local em_cfile = cfile { - class = "em_cfile", - dynamicheaders = em_codeMK_h -} - -local library_core = group { - em_cfile (d.."bhcst.c"), - em_cfile (d.."bhdlb.c"), - em_cfile (d.."bhdnam.c"), - em_cfile (d.."bhfcon.c"), - em_cfile (d.."bhicon.c"), - em_cfile (d.."bhilb.c"), - em_cfile (d.."bhpnam.c"), - em_cfile (d.."bhucon.c"), - em_cfile (d.."crcst.c"), - em_cfile (d.."crdlb.c"), - em_cfile (d.."crdnam.c"), - em_cfile (d.."crxcon.c"), - em_cfile (d.."crilb.c"), - em_cfile (d.."crpnam.c"), - em_cfile (d.."crscon.c"), - em_cfile (d.."cst.c"), - em_cfile (d.."dfdlb.c"), - em_cfile (d.."dfdnam.c"), - em_cfile (d.."dfilb.c"), - em_cfile (d.."dlb.c"), - em_cfile (d.."dnam.c"), - em_cfile (d.."end.c"), - em_cfile (d.."endarg.c"), - em_cfile (d.."exc.c"), - em_cfile (d.."fcon.c"), - em_cfile (d.."getid.c"), - em_cfile (d.."icon.c"), - em_cfile (d.."ilb.c"), - em_cfile (d.."insert.c"), - em_cfile (d.."internerr.c"), - em_cfile (d.."msend.c"), - em_cfile (d.."op.c"), - em_cfile (d.."opcst.c"), - em_cfile (d.."opdlb.c"), - em_cfile (d.."opdnam.c"), - em_cfile (d.."opilb.c"), - em_cfile (d.."opnarg.c"), - em_cfile (d.."oppnam.c"), - em_cfile (d.."pnam.c"), - em_cfile (d.."pro.c"), - em_cfile (d.."pronarg.c"), - em_cfile (d.."msstart.c"), - em_cfile (d.."psdlb.c"), - em_cfile (d.."psdnam.c"), - em_cfile (d.."pspnam.c"), - em_cfile (d.."scon.c"), - em_cfile (d.."ucon.c"), - em_cfile (d.."C_out.c"), - em_cfile (d.."failed.c"), - em_cfile (d.."em.c") -} - -module_eme = clibrary { - CDEFINES = {PARENT, "READABLE_EM"}, - library_core, - - outputs = {"%U%/libeme.a"}, - install = { - pm.install(LIBDIR.."libeme.a") - } -} - -module_emk = clibrary { - library_core, - - outputs = {"%U%/libemk.a"}, - install = { - pm.install(LIBDIR.."libemk.a") - } -} - -module_em_code = group { - module_eme, - module_emk, -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-25 12:46:41 dtrg --- em_table is now in /h, not /etc. --- --- Revision 1.2 2006/10/15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/em_mes/pmfile b/modules/src/em_mes/pmfile deleted file mode 100644 index f70ff2081..000000000 --- a/modules/src/em_mes/pmfile +++ /dev/null @@ -1,35 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/em_mes/" -lib_em_mes = file (LIBDIR.."libem_mes.a") - -local library_core = group { - cfile (d.."C_ms_err.c"), - cfile (d.."C_ms_opt.c"), - cfile (d.."C_ms_emx.c"), - cfile (d.."C_ms_reg.c"), - cfile (d.."C_ms_src.c"), - cfile (d.."C_ms_flt.c"), - cfile (d.."C_ms_com.c"), - cfile (d.."C_ms_par.c"), - cfile (d.."C_ms_ego.c"), - cfile (d.."C_ms_gto.c"), - cfile (d.."C_ms_stb.c"), - cfile (d.."C_ms_std.c"), -} - -module_em_mes = clibrary { - library_core, - - outputs = {"%U%/libem_mes.a"}, - install = { - pm.install(LIBDIR.."libem_mes.a") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/flt_arith/pmfile b/modules/src/flt_arith/pmfile deleted file mode 100644 index 683cbffa4..000000000 --- a/modules/src/flt_arith/pmfile +++ /dev/null @@ -1,35 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."modules/src/flt_arith/" -lib_flt_arith = file (LIBDIR.."libflt_arith.a") - -module_flt_arith = clibrary { - cfile (d.."flt_ar2flt.c"), - cfile (d.."flt_div.c"), - cfile (d.."flt_flt2ar.c"), - cfile (d.."flt_modf.c"), - cfile (d.."flt_str2fl.c"), - cfile (d.."flt_cmp.c"), - cfile (d.."flt_add.c"), - cfile (d.."b64_add.c"), - cfile (d.."flt_mul.c"), - cfile (d.."flt_nrm.c"), - cfile (d.."b64_sft.c"), - cfile (d.."flt_umin.c"), - cfile (d.."flt_chk.c"), - cfile (d.."split.c"), - cfile (d.."ucmp.c"), - - outputs = {"%U%/libflt_arith.a"}, - install = { - pm.install(LIBDIR.."libflt_arith.a"), - pm.install(d.."flt_arith.h", HEADERDIR.."flt_arith.h") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/idf/pmfile b/modules/src/idf/pmfile deleted file mode 100644 index 80acffcdb..000000000 --- a/modules/src/idf/pmfile +++ /dev/null @@ -1,17 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/idf/" - -module_idf = group { - install = { - pm.install(d.."idf_pkg.spec", HEADERDIR.."idf_pkg.spec"), - pm.install(d.."idf_pkg.body", HEADERDIR.."idf_pkg.body"), - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/input/pmfile b/modules/src/input/pmfile deleted file mode 100644 index 71be8dbb9..000000000 --- a/modules/src/input/pmfile +++ /dev/null @@ -1,23 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/input/" -lib_input = file (LIBDIR.."libinput.a") - -module_input = clibrary { - cfile (d.."AtEoIF.c"), - cfile (d.."AtEoIT.c"), - - outputs = {"%U%/libinput.a"}, - install = { - pm.install(LIBDIR.."libinput.a"), - pm.install(d.."inp_pkg.spec", HEADERDIR.."inp_pkg.spec"), - pm.install(d.."inp_pkg.body", HEADERDIR.."inp_pkg.body") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/object/pmfile b/modules/src/object/pmfile deleted file mode 100644 index 2806f50b3..000000000 --- a/modules/src/object/pmfile +++ /dev/null @@ -1,55 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/object/" -lib_object = file (LIBDIR.."libobject.a") - -module_object = clibrary { - cfile (d.."rd_arhdr.c"), - cfile (d.."rd_bytes.c"), - cfile (d.."rd_int2.c"), - cfile (d.."rd_long.c"), - cfile (d.."rd_ranlib.c"), - cfile (d.."rd_unsig2.c"), - cfile (d.."rd.c"), - cfile (d.."wr_arhdr.c"), - cfile (d.."wr_bytes.c"), - cfile (d.."wr_int2.c"), - cfile (d.."wr_long.c"), - cfile (d.."wr_putc.c"), - cfile (d.."wr_ranlib.c"), - cfile (d.."wr.c"), - - outputs = {"%U%/lib_object.a"}, - install = { - pm.install(LIBDIR.."libobject.a") - } -} ---[[ - - -# genmakefile -# This genmakefile doesn't have a real comment yet. -# -# $Source$ -# $State$ - -push - addincludeq src/lib/object - - - hostlibrary $LIBDIR/libobject.a $OBJS -pop - -# Revision history -# $Log$ -# Revision 1.1 2006-07-20 23:18:18 dtrg -# First version in CVS. -# ---]] - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/print/pmfile b/modules/src/print/pmfile deleted file mode 100644 index 6f7c0504d..000000000 --- a/modules/src/print/pmfile +++ /dev/null @@ -1,27 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/print/" -lib_print = file (LIBDIR.."libprint.a") - -module_print = clibrary { - cfile (d.."doprnt.c"), - cfile (d.."fprint.c"), - cfile (d.."print.c"), - cfile (d.."sprint.c"), - cfile (d.."format.c"), - - outputs = {"%U%/libprint.a"}, - install = { - pm.install("%LIBDIR%libprint.a"), - pm.install(d.."print.h", "%HEADERDIR%print.h") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 20:59:22 dtrg --- Changed to export a header file so it can be correctly referred to. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. diff --git a/modules/src/read_em/pmfile b/modules/src/read_em/pmfile deleted file mode 100644 index 1b8dddad7..000000000 --- a/modules/src/read_em/pmfile +++ /dev/null @@ -1,96 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/read_em/" -lib_read_emk = file (LIBDIR.."libread_emk.a") -lib_read_emkV = file (LIBDIR.."libread_emkV.a") -lib_read_emeV = file (LIBDIR.."libread_emeV.a") - -local C_mnem_h = simple { - command = {"(cd "..d.." && sh %in[1]% %in[2]%) > %out%"}, - outputs = {"%U%-%I%.h"}, - install = pm.install(HEADERDIR.."C_mnem.h"), - - file (ROOTDIR..d.."m_C_mnem"), - file ("%ROOTDIR%h/em_table") -} - -local C_mnem_narg_h = simple { - command = {"(cd "..d.." && %in[1]% %in[2]%) > %out%"}, - outputs = {"%U%-%I%.h"}, - install = pm.install(HEADERDIR.."C_mnem_narg.h"), - - file (ROOTDIR..d.."m_C_mnem_na"), - file ("%ROOTDIR%h/em_table") -} - -local withdynamic = cfile { - dynamicheaders = {C_mnem_h, C_mnem_narg_h} -} - -module_read_emk = clibrary { - CDEFINES = {PARENT, "PRIVATE=static", "EXPORT=", "NDEBUG"}, - cfile (d.."EM_vars.c"), - cfile { - CDEFINES = {PARENT, "COMPACT"}, - (d.."read_em.c") - }, - withdynamic (d.."mkcalls.c"), - - outputs = {"%U%/libread_emk.a"}, - install = pm.install(LIBDIR.."libread_emk.a") -} - -module_read_emkV = clibrary { - CDEFINES = {PARENT, "PRIVATE=static", "EXPORT=", "NDEBUG"}, - cfile (d.."EM_vars.c"), - cfile { - CDEFINES = {PARENT, "COMPACT", "CHECKING"}, - (d.."read_em.c") - }, - withdynamic { - CDEFINES = {PARENT, "CHECKING"}, - (d.."mkcalls.c"), - }, - - outputs = {"%U%/libread_emkV.a"}, - install = pm.install(LIBDIR.."libread_emkV.a") -} - -module_read_emeV = clibrary { - CDEFINES = {PARENT, "PRIVATE=static", "EXPORT=", "NDEBUG"}, - cfile (d.."EM_vars.c"), - cfile { - CDEFINES = {PARENT, "CHECKING"}, - (d.."read_em.c") - }, - withdynamic { - CDEFINES = {PARENT, "CHECKING"}, - (d.."mkcalls.c"), - }, - - outputs = {"%U%/lib_read_emeV.a"}, - install = pm.install(LIBDIR.."libread_emeV.a") -} - -module_read_em = group { - module_read_emk, - module_read_emkV, - module_read_emeV, - - install = { - pm.install(d.."em_comp.h", HEADERDIR.."em_comp.h"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-25 12:47:10 dtrg --- em_table is now in /h, not /etc. --- --- Revision 1.2 2006/10/15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/string/pmfile b/modules/src/string/pmfile deleted file mode 100644 index 3090ce637..000000000 --- a/modules/src/string/pmfile +++ /dev/null @@ -1,41 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/string/" -lib_string = file (LIBDIR.."libstring.a") - -module_string = clibrary { - cfile (d.."bts2str.c"), - cfile (d.."btscat.c"), - cfile (d.."btscmp.c"), - cfile (d.."btscpy.c"), - cfile (d.."btszero.c"), - cfile (d.."long2str.c"), - cfile (d.."str2bts.c"), - cfile (d.."str2long.c"), --- cfile (d.."strcat.c"), --- cfile (d.."strcmp.c"), --- cfile (d.."strcpy.c"), --- cfile (d.."strindex.c"), --- cfile (d.."strlen.c"), --- cfile (d.."strncat.c"), --- cfile (d.."strncmp.c"), --- cfile (d.."strncpy.c"), --- cfile (d.."strrindex.c"), - cfile (d.."strzero.c"), - - outputs = {"%U%/lib_string.a"}, - install = { - pm.install(LIBDIR.."libstring.a") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-23 19:58:27 dtrg --- Modified to no longer build unoptimised duplicates of all the standard --- string functions (strcpy, strlen, etc). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/system/pmfile b/modules/src/system/pmfile deleted file mode 100644 index c58cfcd70..000000000 --- a/modules/src/system/pmfile +++ /dev/null @@ -1,42 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/system/" -lib_system = file (LIBDIR.."libsystem.a") - -module_system = clibrary { - cfile (d.."access.c"), - cfile (d.."break.c"), - cfile (d.."chmode.c"), - cfile (d.."close.c"), - cfile (d.."create.c"), - cfile (d.."filesize.c"), - cfile (d.."modtime.c"), --- cfile (d.."lock.c"), - cfile (d.."open.c"), - cfile (d.."read.c"), - cfile (d.."remove.c"), - cfile (d.."stop.c"), - cfile (d.."system.c"), - cfile (d.."time.c"), --- cfile (d.."unlock.c"), - cfile (d.."write.c"), - cfile (d.."seek.c"), - cfile (d.."rename.c"), - - outputs = {"%U%/libsystem.a"}, - install = { - pm.install(LIBDIR.."libsystem.a"), - pm.install(d.."system.h", HEADERDIR.."system.h") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-26 12:40:59 dtrg --- Changed to no longer build sys_lock() and sys_unlock(); they only work --- on platforms that support hardlinks, and nobody uses them anyway. --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. --- diff --git a/plat/cpm/libsys/pmfile b/plat/cpm/libsys/pmfile deleted file mode 100644 index cb564e9c3..000000000 --- a/plat/cpm/libsys/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/cpm/libsys/" - -libsys_cpm = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), - ackfile (d.."_bdos.s"), - ackfile (d.."_trap.s"), - ackfile (d.."_inn2.s"), - ackfile (d.."open.c"), - ackfile (d.."creat.c"), - ackfile (d.."close.c"), - ackfile (d.."read.c"), - ackfile (d.."write.c"), - ackfile (d.."brk.c"), - ackfile (d.."getpid.c"), - ackfile (d.."kill.c"), - ackfile (d.."isatty.c"), - ackfile (d.."lseek.c"), - ackfile (d.."time.c"), - ackfile (d.."signal.c"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/cpm/pmfile b/plat/cpm/pmfile deleted file mode 100644 index 43320f1c2..000000000 --- a/plat/cpm/pmfile +++ /dev/null @@ -1,47 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/cpm/" - -include (d.."libsys/pmfile") - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/cpm/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - pm.install(d.."include/cpm.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/cpm.h"), - } -} - -platform_cpm = group { - ARCH = "i80", - PLATFORM = "cpm", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need - -- them to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_i80, - support_i80, - lang_runtimes, - - -- Build the CP/M syscall library. - - libsys_cpm, - bootsector, -} diff --git a/plat/linux/liblinux/pmfile b/plat/linux/liblinux/pmfile deleted file mode 100644 index a5d008dc5..000000000 --- a/plat/linux/liblinux/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linux/liblinux/" - -liblinux = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), - - ackfile (d.."brk.c"), - ackfile (d.."close.c"), - ackfile (d.."creat.c"), - ackfile (d.."getpid.c"), - ackfile (d.."gettimeofday.c"), - ackfile (d.."_exit.c"), - ackfile (d.."isatty.c"), - ackfile (d.."kill.c"), - ackfile (d.."lseek.c"), - ackfile (d.."open.c"), - ackfile (d.."read.c"), - ackfile (d.."sbrk.c"), - ackfile (d.."signal.c"), - ackfile (d.."write.c"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/liblinux.a"), -} diff --git a/plat/linux386/libsys/pmfile b/plat/linux386/libsys/pmfile deleted file mode 100644 index d7d4930c5..000000000 --- a/plat/linux386/libsys/pmfile +++ /dev/null @@ -1,13 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linux386/libsys/" - -libsys_linux386 = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."_syscall.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/linux386/pmfile b/plat/linux386/pmfile deleted file mode 100644 index b7ce18123..000000000 --- a/plat/linux386/pmfile +++ /dev/null @@ -1,48 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/linux386/" - -include (d.."libsys/pmfile") -include "plat/linux/liblinux/pmfile" - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/linux386/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_linux386 = group { - ARCH = "i386", - PLATFORM = "linux386", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need it - -- to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_i386, - support_i386, - lang_runtimes, - - -- Build the PC standalone syscall library. - - liblinux, - libsys_linux386, - bootsector, -} diff --git a/plat/linux68k/libsys/pmfile b/plat/linux68k/libsys/pmfile deleted file mode 100644 index 2bcf6b939..000000000 --- a/plat/linux68k/libsys/pmfile +++ /dev/null @@ -1,13 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linux68k/libsys/" - -libsys_linux68k = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."_syscall.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/linux68k/pmfile b/plat/linux68k/pmfile deleted file mode 100644 index f28fd1cb8..000000000 --- a/plat/linux68k/pmfile +++ /dev/null @@ -1,48 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $ --- $State: Exp $ --- $Revision: 1.3 $ - -local d = ROOTDIR.."plat/linux68k/" - -include (d.."libsys/pmfile") -include "plat/linux/liblinux/pmfile" - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_linux68k = group { - ARCH = "m68020", - PLATFORM = "linux68k", - OPTIMISATION = "-O6", - - -- Ensure the descr and headers are installed first because we'll need it - -- to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_m68020, - support_m68020, - lang_runtimes, - - -- Build the PC standalone syscall library. - - liblinux, - libsys_linux68k, - bootsector, -} diff --git a/plat/linuxppc/libsys/pmfile b/plat/linuxppc/libsys/pmfile deleted file mode 100644 index 0b3839aae..000000000 --- a/plat/linuxppc/libsys/pmfile +++ /dev/null @@ -1,14 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linuxppc/libsys/" - -libsys_linuxppc = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."_syscall.s"), - ackfile (d.."trap.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/linuxppc/pmfile b/plat/linuxppc/pmfile deleted file mode 100644 index 34acd7002..000000000 --- a/plat/linuxppc/pmfile +++ /dev/null @@ -1,48 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $ --- $State: Exp $ --- $Revision: 1.3 $ - -local d = ROOTDIR.."plat/linuxppc/" - -include (d.."libsys/pmfile") -include "plat/linux/liblinux/pmfile" - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_linuxppc = group { - ARCH = "powerpc", - PLATFORM = "linuxppc", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need it - -- to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_powerpc, - support_powerpc, - lang_runtimes, - - -- Build the PC standalone syscall library. - - liblinux, - libsys_linuxppc, - bootsector, -} diff --git a/plat/pc86/libsys/pmfile b/plat/pc86/libsys/pmfile deleted file mode 100644 index 99a4ee85b..000000000 --- a/plat/pc86/libsys/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/pc86/libsys/" - -libsys_pc86 = acklibrary { - ACKBUILDFLAGS = {PARENT, "-ansi"}, - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), - ackfile (d.."_sys_rawread.s"), - ackfile (d.."_sys_rawwrite.s"), - ackfile (d.."open.c"), - ackfile (d.."creat.c"), - ackfile (d.."close.c"), - ackfile (d.."read.c"), - ackfile (d.."write.c"), - ackfile (d.."brk.c"), - ackfile (d.."getpid.c"), - ackfile (d.."kill.c"), - ackfile (d.."isatty.c"), - ackfile (d.."lseek.c"), - ackfile (d.."time.c"), - ackfile (d.."signal.c"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/pc86/pmfile b/plat/pc86/pmfile deleted file mode 100644 index 0afe6a5b0..000000000 --- a/plat/pc86/pmfile +++ /dev/null @@ -1,46 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/pc86/" - -include (d.."libsys/pmfile") - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/pc86/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_pc86 = group { - ARCH = "i86", - PLATFORM = "pc86", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need - -- them to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_i86, - support_i86, - lang_runtimes, - - -- Build the PC standalone syscall library. - - libsys_pc86, - bootsector, -} diff --git a/pmfile b/pmfile deleted file mode 100644 index 2f6d416df..000000000 --- a/pmfile +++ /dev/null @@ -1,239 +0,0 @@ --- $Id$ --- $Source$ --- $State$ - -include "first/c.pm" -include "first/yacc.pm" -include "first/llgen.pm" -include "config.pm" -include "first/ack.pm" -include "first/ack-custom.pm" - -CINCLUDES = { - ROOTDIR.."h", - ROOTDIR.."modules/h", - HEADERDIR, -} - --- Load the pmfiles for the various modules. - -include "util/data/pmfile" - -include "util/LLgen/pmfile-ack" - -include "modules/src/alloc/pmfile" -include "modules/src/assert/pmfile" -include "modules/src/system/pmfile" -include "modules/src/string/pmfile" -include "modules/src/read_em/pmfile" -include "modules/src/em_code/pmfile" -include "modules/src/em_mes/pmfile" -include "modules/src/print/pmfile" -include "modules/src/object/pmfile" -include "modules/src/idf/pmfile" -include "modules/src/input/pmfile" -include "modules/src/flt_arith/pmfile" - -include "util/amisc/pmfile" -include "util/cmisc/pmfile" -include "util/ack/pmfile" -include "util/arch/pmfile" --- include "util/cpp/pmfile" -include "lang/cem/cpp.ansi/pmfile" -include "util/cgg/pmfile" -include "util/ncgg/pmfile" --- include "util/ceg/pmfile" -include "util/misc/pmfile" -include "util/opt/pmfile" -include "util/ego/pmfile" -include "util/topgen/pmfile" -include "util/led/pmfile" - -include "lang/cem/pmfile" -include "lang/pc/pmfile" -include "lang/m2/pmfile" --- include "lang/occam/pmfile" --- include "lang/basic/pmfile" - -include "mach/proto/pmfile" - ---[[ -include "mach/i386/pmfile" -include "mach/6500/pmfile" -include "mach/6800/pmfile" -include "mach/6805/pmfile" -include "mach/6809/pmfile" -include "mach/arm/pmfile" -include "mach/i80/pmfile" -include "mach/m68020/pmfile" -include "mach/m68k2/pmfile" -include "mach/m68k4/pmfile" -include "mach/ns/pmfile" -include "mach/pdp/pmfile" -include "mach/s2650/pmfile" -include "mach/vax4/pmfile" -include "mach/z80/pmfile" -include "mach/z8000/pmfile" ---]] - --- This is the list of language runtimes that is built for each architecture. - -lang_runtimes = group { --- lang_cem_runtime, -- K&R C (obsolete and useless) - lang_cem_ansi_runtime, -- ANSI C - lang_pc_runtime, -- Pascal - lang_m2_runtime, -- Modula-2 --- lang_occam_runtime, -- Occam 1 (obsolete and useless) --- lang_basic_runtime, -- Basic -} - --- Include the platform descriptions. - -include "mach/i86/pmfile" -- generic i86 -include "plat/pc86/pmfile" -- PC standalone - -include "mach/i386/pmfile" -- generic i386 -include "plat/linux386/pmfile" -- Linux executables - -include "mach/powerpc/pmfile" -- generic PowerPC -include "plat/linuxppc/pmfile" -- Linux executables - -include "mach/m68020/pmfile" -- generic M68k -include "plat/linux68k/pmfile" -- Linux executables - -include "mach/i80/pmfile" -- generic 8080 -include "plat/cpm/pmfile" -- CP/M - -default = group { - -- Lots of things use LLgen, so we need to build it first. - - tool_LLgen, - - -- Some of the dependency management across modules isn't entirely - -- complete, for simplicity; as a result, the order here is important. - -- In particular, referencing a library does not cause the library to - -- be built, hence the reason why the modules must be built first. Also, - -- some of these generate header files... - - module_em_data, - module_system, - module_alloc, - module_assert, - module_string, - module_em_code, - module_read_em, - module_em_mes, - module_print, - module_object, - module_idf, - module_print, - module_input, - module_flt_arith, - - tool_tabgen, - tool_aal, - tool_ack, --- tool_cpp, -- K&R C - tool_cpp_ansi, -- ANSI C - tool_cgg, - tool_ncgg, --- tool_ceg, - tool_em_decode, - tool_em_encode, - tool_esize, - tool_opt, - tool_ego, - tool_topgen, - tool_led, - tool_anm, - tool_ashow, - tool_asize, - tool_astrip, - tool_aslod, - tool_aelflod, - --- lang_cem_compiler, - lang_cem_ansi_compiler, - lang_pc_compiler, - lang_m2_compiler, --- lang_occam_compiler, --- lang_basic_compiler, - - -- Build the code generators and the architecture-independent - -- libraries. - ---[[ - mach_6500, - lang_runtimes { ARCH="6500", OPTIMISATION="-O" }, - - mach_6800, - mach_6805, - mach_6809, - mach_arm, lang_runtimes { ARCH="arm", OPTIMISATION="-O" }, - - mach_m68020, lang_runtimes { ARCH="m68020", OPTIMISATION="-O" }, --- mach_m68k2, lang_runtimes { ARCH="m68k2", OPTIMISATION="-O" }, --- mach_m68k4, lang_runtimes { ARCH="m68k4", OPTIMISATION="-O" }, - mach_ns, lang_runtimes { ARCH="ns", OPTIMISATION="-O" }, --- mach_pdp, lang_runtimes { ARCH="pdp", OPTIMISATION="-O" }, - mach_s2650, --- mach_vax4, lang_runtimes { ARCH="vax4", OPTIMISATION="-O" }, - mach_z80, lang_runtimes { ARCH="z80", OPTIMISATION="-O" }, - mach_z8000, lang_runtimes { ARCH="z8000", OPTIMISATION="-O" }, ---]] - - -- Build the platforms. - - platform_pc86, - platform_linux386, --- platform_linuxppc, - platform_linux68k, - platform_cpm, -} - --- Ensure that the work directories exist. - -posix.mkdir(TEMPDIR) -posix.mkdir(HEADERDIR) - --- When doing the build, we want to ensure that the ACK looks in the staging --- area for its files, and not in the final installation directory (because --- we haven't been installed yet). - -posix.putenv("ACKDIR="..BINDIR) - --- Build the configuration headers, rather crudely. FIXME. - -configure = simple { - outputs = {HEADERDIR.."local.h", HEADERDIR.."em_path.h"}, - command = "", - __dobuild = function(self, inputs, outputs) - -- Build 'local.h', rather crudely - - local f = io.open(HEADERDIR.."local.h", "w") - f:write("#define VERSION 3\n") -- EM byte-code version - f:write("#define ACKM \"", DEFAULT_PLATFORM, "\"\n") - f:write("#define BIGMACHINE 1\n") -- No, we don't have a 16-bit architecture - f:write("#define SYS_5\n") - f:close() - - -- Build 'em_path.h', rather crudely - - local f = io.open(HEADERDIR.."em_path.h", "w") - f:write("#define TMP_DIR \"", ACK_TEMP_DIR, "\"\n") - f:write("#define EM_DIR \"", PREFIX, "\"\n") - f:write("#define ACK_PATH \"", PLATIND, "/descr\"\n") - f:close() - end -} - --- Once built, do the installation, rather crudely. FIXME. - -install = simple { - outputs = {"dummy"}, - command = "", - __dobuild = function(self, inputs, outputs) - os.execute("mkdir -p "..PREFIX) - os.execute("(cd "..BINDIR.." && tar chf - .) | (cd "..PREFIX.." && tar xvf -)") - end -} diff --git a/util/LLgen/pmfile b/util/LLgen/pmfile deleted file mode 100644 index 7b1548845..000000000 --- a/util/LLgen/pmfile +++ /dev/null @@ -1,127 +0,0 @@ --- $Source$ --- $State$ --- --- $Id$ --- --- This is the build file used to compile LLgen. It should be run through --- Prime Mover (copy supplied). See the READ_ME file for more information. - -include "c.pm" - --- Where is LLgen going to be installed eventually? (Needs trailing slash.) - -PREFIX = PREFIX or "/usr/local/" - --- Where's LLgen's staging area? (Don't change. Needs trailing slash.) - -INSTALLPATH = "bin/" - -LLgen = cprogram { - CEXTRAFLAGS = '-DLIBDIR=\\"'..PREFIX..'share/LLgen\\" -DNON_CORRECTING', - - -- This line is needed to work around an OSX bug --- Apple's hacked gcc's - -- preprocessor doesn't find LLgen.c's include files properly. Don't know - -- why. - - CINCLUDES = {PARENT, "-Isrc"}, - - cfile "src/main.c", - cfile "src/gencode.c", - cfile "src/compute.c", - cfile "src/check.c", - cfile "src/reach.c", - cfile "src/global.c", - cfile "src/name.c", - cfile "src/sets.c", - cfile "src/alloc.c", - cfile "src/machdep.c", - cfile "src/cclass.c", - cfile "src/savegram.c", - - -- These use pre-LLgen'd version of the files. If LLgen.g gets updated, - -- they need rebuilding. Use the bootstrap script to do this. - - cfile "src/LLgen.c", - cfile "src/Lpars.c", - cfile "src/tokens.c", - - outputs = {"%U%/LLgen"}, - install = pm.install( INSTALLPATH.."bin/LLgen") -} - -library = group { - install = { - pm.install("lib/rec", INSTALLPATH.."share/LLgen/rec"), - pm.install("lib/incl", INSTALLPATH.."share/LLgen/incl"), - pm.install("lib/nc_incl", INSTALLPATH.."share/LLgen/nc_incl"), - pm.install("lib/nc_rec", INSTALLPATH.."share/LLgen/nc_rec"), - } -} - -manpage = group { - install = { - pm.install("doc/LLgen.1", INSTALLPATH.."man/man1/LLgen.1"), - } -} - -documentation = group { - simple { - outputs = {"%U%-%I%.ps.gz"}, - command = "refer -sA+T -p %in[1]% %in[2]% | groff -Tps -e -t -ms ".. - "| gzip -c9 > %out[1]%", - - file "doc/LLgen.refs", - file "doc/LLgen.n", - - install = { - pm.install(INSTALLPATH.."share/doc/LLgen/LLgen.ps.gz") - } - }, - - simple { - outputs = {"%U%-%I%.ps.gz"}, - command = "groff -Tps -e -t -p -ms %in% | gzip -c9 > %out[1]%", - - file "doc/LLgen_NCER.n", - - install = { - pm.install(INSTALLPATH.."share/doc/LLgen/NCER.ps.gz") - } - }, -} - --- Default rule: builds everything into the staging area, but does nothing --- else. - -default = group { - LLgen, -- build LLgen itself - library, -- copy over the library - manpage, -- copy over the man page - documentation, -- build the two white papers -} - --- This rule will build everything, and then install it to its final location. - -install = group { - default, - - install = { - "mkdir -p %PREFIX%", - "(cd bin && tar chvf - $(find . ! -type d)) | (cd %PREFIX% && tar xUf -)" - } -} - --- Revision history --- $Log$ --- Revision 1.5 2006-07-25 23:29:12 dtrg --- Modified to not try to unlink directories when installing. --- --- Revision 1.4 2006/07/25 23:22:58 dtrg --- Updated to the latest version of pm which installs files with symlinks. --- --- Revision 1.3 2006/07/23 20:33:26 dtrg --- Added a workaround for an OSX compiler bug. --- --- Revision 1.2 2006/07/21 11:15:14 dtrg --- Updated to the latest version of pm. --- diff --git a/util/ack/pmfile b/util/ack/pmfile deleted file mode 100644 index 4d4b78c8c..000000000 --- a/util/ack/pmfile +++ /dev/null @@ -1,61 +0,0 @@ --- $Source$ --- $State$ - -local d = "%ROOTDIR%util/ack/" - -local mktable = cprogram { - cfile (d.."mktables.c") -} - -local makeheaders = simple { - outputs= {"%U%/dmach.c", "%U%/intable.c"}, - command = { - "cd %out[1]:dirname% && %in[1]% %BINDIR%lib" - }, - - mktable -} - -tool_ack = cprogram { - cfile (d.."list.c"), - cfile (d.."data.c"), - cfile (d.."main.c"), - cfile (d.."scan.c"), - cfile (d.."svars.c"), - cfile (d.."trans.c"), - cfile (d.."util.c"), - cfile (d.."rmach.c"), - cfile (d.."run.c"), - cfile (d.."grows.c"), - cfile (d.."files.c"), - - cfile { - CINCLUDES = {PARENT, d}, - ith { makeheaders, i = 1 } - }, - cfile { - CINCLUDES = {PARENT, d}, - ith { makeheaders, i = 2 } - }, - - lib_string, - - outputs = {"%U%/ack"}, - install = { - pm.install("%BINDIR%bin/ack"), - pm.install("%ROOTDIR%/lib/descr/fe", "%BINDIR%%PLATIND%/descr/fe"), - pm.install(d.."ack.1.X", "%BINDIR%man/man1/ack.1") - } -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-25 12:48:06 dtrg --- Now installs the man page. --- --- Revision 1.2 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/amisc/pmfile b/util/amisc/pmfile deleted file mode 100644 index 4faa7c6c2..000000000 --- a/util/amisc/pmfile +++ /dev/null @@ -1,35 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/amisc/" - -local simple_tool = cprogram { - class = "simple_tool", - - cfile (d.."%S%.c"), - lib_object, - - outputs = {"%U%/%S%"}, - install = { - pm.install("%U%/%S%", "%BINDIR%bin/%S%"), - pm.install(d.."%S%.1", "%BINDIR%man/man1/%S%.1") - } -} - -tool_anm = simple_tool { S = "anm" } -tool_ashow = simple_tool { S = "ashow" } -tool_asize = simple_tool { S = "asize" } -tool_astrip = simple_tool { S = "astrip" } -tool_aslod = simple_tool { S = "aslod" } -tool_aelflod = simple_tool { S = "aelflod" } - --- Revision history --- $Log$ --- Revision 1.3 2007-04-23 23:40:10 dtrg --- Added the aelflod tool for generating ELF executables. Added documentation for aelflod and ashow. Now installs the documentation when built. --- --- Revision 1.2 2006/10/16 23:25:56 dtrg --- Added support for anm, asize, ashow, astrip and the new aslod tool. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. diff --git a/util/arch/pmfile b/util/arch/pmfile deleted file mode 100644 index 9f7c67d0d..000000000 --- a/util/arch/pmfile +++ /dev/null @@ -1,31 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/arch/" - -tool_aal = cprogram { - CDEFINES = {PARENT, "AAL"}, - cfile (d.."archiver.c"), - - lib_print, - lib_string, - lib_system, - lib_object, - - install = { - pm.install("%BINDIR%bin/aal"), - pm.install(d.."aal.1", "%BINDIR%man/man1/aal.1") - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/30 23:45:35 dtrg --- Modified to install aal's manpage. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/ceg/as_parser/pmfile b/util/ceg/as_parser/pmfile deleted file mode 100644 index da3c67023..000000000 --- a/util/ceg/as_parser/pmfile +++ /dev/null @@ -1,59 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/as_parser/" - -local lpars = LLgen { - file (d.."pars.g") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars - } -} - -tool_ceg_as_parser = cprogram { - CDEFINES = {PARENT, "FLEX"}, - CLIBRARIES = {PARENT, "fl"}, - - cfile_with_headers (d.."conversion.c"), - cfile_with_headers (d.."help.c"), - - cfile_with_headers { - flex { - file (d.."table.l") - } - }, - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/as_parser"}, - install = pm.install(BINDIR.."%PLATDEP%/ceg/as_parser/as_parser"), -} - -tool_ceg_as_parser_eval = cprogram { - cfile (d.."eval/eval.c"), - - outputs = {"%U%/eval"}, - install = pm.install(BINDIR.."%PLATDEP%/ceg/as_parser/eval"), -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/ceg/assemble/pmfile b/util/ceg/assemble/pmfile deleted file mode 100644 index 05671a71f..000000000 --- a/util/ceg/assemble/pmfile +++ /dev/null @@ -1,20 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/assemble/" - -tool_ceg_assemble = group { - install = { - pm.install(d.."as_assemble/assemble.c", BINDIR..PLATDEP.."/ceg/assemble/as_assemble/assemble.c"), - pm.install(d.."as_assemble/block_as.c", BINDIR..PLATDEP.."/ceg/assemble/as_assemble/block_as.c"), - pm.install(d.."obj_assemble/assemble.c", BINDIR..PLATDEP.."/ceg/assemble/obj_assemble/assemble.c"), - pm.install(d.."obj_assemble/block_as.c", BINDIR..PLATDEP.."/ceg/assemble/obj_assemble/block_as.c"), - pm.install(d.."obj_assemble/const.h", BINDIR..PLATDEP.."/ceg/assemble/obj_assemble/const.h"), - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/util/ceg/ce_back/pmfile b/util/ceg/ce_back/pmfile deleted file mode 100644 index 5710282c8..000000000 --- a/util/ceg/ce_back/pmfile +++ /dev/null @@ -1,89 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/ce_back/" - -local function installmany(srcroot, destroot, list) - local o = {} - - for _, i in ipairs(list) do - table.insert(o, pm.install(srcroot..i, destroot..i)) - end - - return o -end - -tool_ceg_assemble = group { - install = installmany(d, BINDIR.."%PLATDEP%/ceg/ce_back/", - { - "as_back/back.h", - "as_back/bottom.c", - "as_back/bss.c", - "as_back/con1.c", - "as_back/con2.c", - "as_back/con4.c", - "as_back/do_close.c", - "as_back/do_open.c", - "as_back/end_back.c", - "as_back/gen1.c", - "as_back/gen2.c", - "as_back/gen4.c", - "as_back/header.h", - "as_back/init_back.c", - "as_back/reloc1.c", - "as_back/reloc2.c", - "as_back/reloc4.c", - "as_back/rom1.c", - "as_back/rom2.c", - "as_back/rom4.c", - "as_back/set_global.c", - "as_back/set_local.c", - "as_back/switchseg.c", - "as_back/symboldef.c", - "as_back/text1.c", - "as_back/text2.c", - "as_back/text4.c", - "as_back/dbsym.c", - - "obj_back/back.h", - "obj_back/con2.c", - "obj_back/con4.c", - "obj_back/data.c", - "obj_back/data.h", - "obj_back/do_close.c", - "obj_back/do_open.c", - "obj_back/end_back.c", - "obj_back/extnd.c", - "obj_back/gen1.c", - "obj_back/gen2.c", - "obj_back/gen4.c", - "obj_back/hash.h", - "obj_back/header.h", - "obj_back/init_back.c", - "obj_back/label.c", - "obj_back/memory.c", - "obj_back/misc.c", - "obj_back/output.c", - "obj_back/reloc1.c", - "obj_back/reloc2.c", - "obj_back/reloc4.c", - "obj_back/relocation.c", - "obj_back/rom2.c", - "obj_back/rom4.c", - "obj_back/set_global.c", - "obj_back/set_local.c", - "obj_back/switchseg.c", - "obj_back/symboldef.c", - "obj_back/symtable.c", - "obj_back/text2.c", - "obj_back/text4.c", - "obj_back/common.c", - "obj_back/dbsym.c", - }) -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/util/ceg/pmfile b/util/ceg/pmfile deleted file mode 100644 index 8de3fbc6c..000000000 --- a/util/ceg/pmfile +++ /dev/null @@ -1,21 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/" - -include (d.."as_parser/pmfile") -include (d.."assemble/pmfile") -include (d.."ce_back/pmfile") - -tool_ceg = group { - tool_ceg_as_parser, - tool_ceg_as_parser_eval, - tool_ceg_assemble, - tool_ceg_ce_back, -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/cgg/pmfile b/util/cgg/pmfile deleted file mode 100644 index cb2e4a369..000000000 --- a/util/cgg/pmfile +++ /dev/null @@ -1,54 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/cgg/" - -local yacc_bootgram = yacc { - file (d.."bootgram.y") - } - -tool_cgg = cprogram { - cfile (d.."main.c"), - - cfile { - CINCLUDES = {PARENT, d}, - yacc_bootgram, - }, - - cfile { - CINCLUDES = {PARENT, d}, - flex { - file (d.."bootlex.l") - }, - - dynamicheaders = yacc_bootgram - }, - - CLIBRARIES = {PARENT, "fl"}, - lib_em_data, - lib_assert, - lib_system, - - install = pm.install(TOOLDIR.."cgg") -} - -cgg = simple { - class = "cgg", - - outputs = {"%U%/tables.c", "%U%/tables.h"}, - command = { - "cd %out[1]:dirname% && (%BINDIR%%PLATDEP%/cpp -P -I%CGGINCLUDEDIR% %in% | %TOOLDIR%cgg)", - }, -} - --- Revision history --- $Log$ --- Revision 1.3 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/22 20:58:27 dtrg --- cpp now gets installed in the right place. --- --- Revision 1.1 2006/07/20 23:21:17 dtrg --- First version in CVS. --- diff --git a/util/cmisc/pmfile b/util/cmisc/pmfile deleted file mode 100644 index b67734077..000000000 --- a/util/cmisc/pmfile +++ /dev/null @@ -1,25 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/cmisc/" - -tool_tabgen = cprogram { - cfile (d.."tabgen.c"), - - outputs = {"%U%/tabgen"}, - install = pm.install(TOOLDIR.."tabgen") -} - -tabgen = simple { - class = "tabgen", - outputs = {"%U%-char.c"}, - command = { - "%TOOLDIR%tabgen -f%in[1]% > %out[1]%" - }, -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:21:17 dtrg --- First version in CVS. --- diff --git a/util/cpp/pmfile b/util/cpp/pmfile deleted file mode 100644 index 2f777591c..000000000 --- a/util/cpp/pmfile +++ /dev/null @@ -1,123 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/cpp/" - -local extract_parameters = simple { - outputs = { - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/lapbuf.h", - "%U%/strsize.h", - "%U%/botch_free.h", - "%U%/debug.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/obufsize.h", - "%U%/dobits.h", - "%U%/line_prefix.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."Parameters") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."expression.g") -} - - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - lpars - } -} - -tool_cpp = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."ch7bin.c"), - cfile_with_headers (d.."ch7mon.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."preprocess.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."scan.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."next.c"), - cfile_with_headers (d.."expr.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - lib_assert, - lib_print, - lib_alloc, - lib_system, - lib_string, - - outputs = {"%U%/cpp"}, - install = { - pm.install("%BINDIR%%PLATDEP%/cpp"), - pm.install(d.."cpp.6", "%BINDIR%man/man6/cpp.6") - } -} - --- Revision history --- $Log$ --- Revision 1.4 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.3 2006/07/22 20:58:27 dtrg --- cpp now gets installed in the right place. --- --- Revision 1.2 2006/07/22 12:27:31 dtrg --- Removed a huge, ancient comment dating from the genmake days. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. diff --git a/util/data/pmfile b/util/data/pmfile deleted file mode 100644 index df7544415..000000000 --- a/util/data/pmfile +++ /dev/null @@ -1,57 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/data/" - -local datafiles = simple { - outputs = { - "%U%/em_spec.h", - "%U%/em_pseu.h", - "%U%/em_mnem.h", - "%U%/em_flag.c", - "%U%/em_pseu.c", - "%U%/em_mnem.c" - }, - - command = { - "%in[1]% %in[2]% %out[1]:dirname% %out[1]:dirname%" - }, - - install = { - pm.install("%U%/em_spec.h", "%HEADERDIR%em_spec.h"), - pm.install("%U%/em_pseu.h", "%HEADERDIR%em_pseu.h"), - pm.install("%U%/em_mnem.h", "%HEADERDIR%em_mnem.h") - }, - - file (d.."new_table"), - file ("%ROOTDIR%h/em_table"), -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - datafiles, - } -} - -module_em_data = clibrary { - cfile_with_headers (d.."em_ptyp.c"), - foreach { - rule = cfile_with_headers, - ith { datafiles, from=4 } - }, - - outputs = {"%U%/libem_data.a"}, - install = pm.install("%LIBDIR%libem_data.a") -} - -lib_em_data = file "%LIBDIR%libem_data.a" - --- Revision history --- $Log$ --- Revision 1.2 2007-02-25 12:49:04 dtrg --- new_table is now in /util/data, not /etc. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. --- diff --git a/util/ego/pmfile b/util/ego/pmfile deleted file mode 100644 index 875dd6952..000000000 --- a/util/ego/pmfile +++ /dev/null @@ -1,234 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ego/" - -local makecldef = cprogram { - cfile (d.."share/makecldef.c") -} - -local classdefs_h = simple { - outputs = {"%U%/classdefs.h"}, - command = { - "%in[1]% %in[2]% %in[3]% > %out[1]%" - }, - - makecldef, - file ("%HEADERDIR%em_mnem.h"), - file (d.."share/cldefs.src") -} - -local pop_push_h = simple { - outputs = {"%U%/pop_push.h"}, - command = { - "awk -f %in[1]% < %in[2]% > %out%" - }, - - file (d.."share/pop_push.awk"), - file ("%ROOTDIR%h/em_table") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - classdefs_h, - pop_push_h - } -} - -local ego_core = cprogram { - CINCLUDES = {PARENT, ("-I"..d.."share")}, - - cfile_with_headers (d.."share/debug.c"), - cfile_with_headers (d.."share/global.c"), - cfile_with_headers (d.."share/files.c"), - cfile_with_headers (d.."share/go.c"), - cfile_with_headers (d.."share/map.c"), - cfile_with_headers (d.."share/aux.c"), - cfile_with_headers (d.."share/get.c"), - cfile_with_headers (d.."share/put.c"), - cfile_with_headers (d.."share/alloc.c"), - cfile_with_headers (d.."share/lset.c"), - cfile_with_headers (d.."share/cset.c"), - cfile_with_headers (d.."share/parser.c"), - cfile_with_headers (d.."share/stack_chg.c"), - cfile_with_headers (d.."share/locals.c"), - cfile_with_headers (d.."share/init_glob.c"), -} - -tool_ego = group { - CDEFINES = {PARENT, "VERBOSE", "NOTCOMPACT"}, - - ego_core { - cfile_with_headers (d.."bo/bo.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/bo") - }, - - ego_core { - cfile_with_headers (d.."ca/ca.c"), - cfile_with_headers (d.."ca/ca_put.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ca") - }, - - ego_core { - cfile_with_headers (d.."cf/cf.c"), - cfile_with_headers (d.."cf/cf_idom.c"), - cfile_with_headers (d.."cf/cf_loop.c"), - cfile_with_headers (d.."cf/cf_succ.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/cf") - }, - - ego_core { - cfile_with_headers (d.."cj/cj.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/cj") - }, - - ego_core { - cfile_with_headers (d.."cs/cs.c"), - cfile_with_headers (d.."cs/cs_alloc.c"), - cfile_with_headers (d.."cs/cs_aux.c"), - cfile_with_headers (d.."cs/cs_avail.c"), - cfile_with_headers (d.."cs/cs_debug.c"), - cfile_with_headers (d.."cs/cs_elim.c"), - cfile_with_headers (d.."cs/cs_entity.c"), - cfile_with_headers (d.."cs/cs_getent.c"), - cfile_with_headers (d.."cs/cs_kill.c"), - cfile_with_headers (d.."cs/cs_partit.c"), - cfile_with_headers (d.."cs/cs_profit.c"), - cfile_with_headers (d.."cs/cs_stack.c"), - cfile_with_headers (d.."cs/cs_vnm.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/cs") - }, - - ego_core { - cfile_with_headers (d.."ic/ic.c"), - cfile_with_headers (d.."ic/ic_aux.c"), - cfile_with_headers (d.."ic/ic_io.c"), - cfile_with_headers (d.."ic/ic_lib.c"), - cfile_with_headers (d.."ic/ic_lookup.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ic") - }, - - ego_core { - cfile_with_headers (d.."il/il.c"), - cfile_with_headers (d.."il/il1_anal.c"), - cfile_with_headers (d.."il/il1_aux.c"), - cfile_with_headers (d.."il/il1_cal.c"), - cfile_with_headers (d.."il/il1_formal.c"), - cfile_with_headers (d.."il/il2_aux.c"), - cfile_with_headers (d.."il/il3_aux.c"), - cfile_with_headers (d.."il/il3_change.c"), - cfile_with_headers (d.."il/il3_subst.c"), - cfile_with_headers (d.."il/il_aux.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/il") - }, - - ego_core { - cfile_with_headers (d.."lv/lv.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/lv") - }, - - ego_core { - cfile_with_headers (d.."ra/ra.c"), - cfile_with_headers (d.."ra/ra_allocl.c"), - cfile_with_headers (d.."ra/ra_aux.c"), - cfile_with_headers (d.."ra/ra_interv.c"), - cfile_with_headers (d.."ra/ra_lifet.c"), - cfile_with_headers (d.."ra/ra_pack.c"), - cfile_with_headers (d.."ra/ra_profits.c"), - cfile_with_headers (d.."ra/ra_xform.c"), - cfile { - file (d.."ra/ra_items.c"), - dynamicheaders = { - simple { - outputs = {"%U%/itemtab.h"}, - command = { - "%in[1]% %in[2]% %in[3]% > %out[1]%" - }, - - cprogram { - cfile (d.."ra/makeitems.c"), - }, - file (HEADERDIR.."em_mnem.h"), - file (d.."ra/itemtab.src") - } - } - }, - - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ra") - }, - - ego_core { - cfile_with_headers (d.."sp/sp.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/sp") - }, - - ego_core { - cfile_with_headers (d.."sr/sr.c"), - cfile_with_headers (d.."sr/sr_aux.c"), - cfile_with_headers (d.."sr/sr_cand.c"), - cfile_with_headers (d.."sr/sr_expr.c"), - cfile_with_headers (d.."sr/sr_iv.c"), - cfile_with_headers (d.."sr/sr_reduce.c"), - cfile_with_headers (d.."sr/sr_xform.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/sr") - }, - - ego_core { - cfile_with_headers (d.."ud/ud.c"), - cfile_with_headers (d.."ud/ud_aux.c"), - cfile_with_headers (d.."ud/ud_const.c"), - cfile_with_headers (d.."ud/ud_copy.c"), - cfile_with_headers (d.."ud/ud_defs.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ud") - }, - - cprogram { - cfile (d.."em_ego/em_ego.c"), - - lib_print, - lib_string, - lib_system, - - install = pm.install("%BINDIR%%PLATDEP%/em_ego") - } -} - --- This rule is used by the machine description pmfiles to massage and install --- the ego descr files. - -ego_descr = simple { - outputs = {"%U%-%I%"}, - command = { - "%BINDIR%%PLATDEP%/cpp.ansi -P -I%HEADERDIR% %in[1]% | sed -f %in[2]% > %out[1]%" - }, - - file (d.."descr/%ARCH%.descr"), - file (d.."descr/descr.sed"), - - install = pm.install("%BINDIR%%PLATDEP%/ego/%ARCH%descr") -} diff --git a/util/led/pmfile b/util/led/pmfile deleted file mode 100644 index 37aeba090..000000000 --- a/util/led/pmfile +++ /dev/null @@ -1,39 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/led/" - -tool_led = cprogram { - cfile (d.."archive.c"), - cfile (d.."error.c"), - cfile (d.."extract.c"), - cfile (d.."finish.c"), - cfile (d.."main.c"), - cfile (d.."memory.c"), - cfile (d.."output.c"), - cfile (d.."read.c"), - cfile (d.."relocate.c"), - cfile (d.."save.c"), - cfile (d.."scan.c"), - cfile (d.."sym.c"), - cfile (d.."write.c"), - - lib_string, - lib_object, - - outputs = {"%U%/led"}, - install = { - -- FIXME lib.bin in next line needs removing --- pm bug? - pm.install("%BINDIR%%PLATDEP%/em_led"), - pm.install(d.."ack.out.5", "%BINDIR%man/man5/ack.out.5"), - pm.install(d.."led.6", "%BINDIR%man/man6/em_led.6"), - } -} - --- Revision history --- $Log: pmfile,v $ --- Revision 1.2 2006/07/22 20:52:44 dtrg --- led now gets installed into the right place. --- --- Revision 1.1 2006/07/22 20:04:41 dtrg --- Added support for the led link editor. \ No newline at end of file diff --git a/util/misc/pmfile b/util/misc/pmfile deleted file mode 100644 index f82d1ad88..000000000 --- a/util/misc/pmfile +++ /dev/null @@ -1,59 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/misc/" - -tool_em_decode = cprogram { - cfile (d.."convert.c"), - - lib_read_emkV, - lib_eme, - lib_em_data, - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_decode"}, - install = { - -- FIXME lib.bin in next line needs removing --- pm bug? - pm.install("%BINDIR%lib.bin/em_decode"), - pm.install(d.."em_decode.6", "%BINDIR%man/man6/em_decode.6"), - } -} - -tool_em_encode = cprogram { - cfile (d.."convert.c"), - - lib_read_emeV, - lib_emk, - lib_em_data, - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_encode"}, - install = { - pm.install("%BINDIR%%PLATDEP%/em_encode"), - pm.install(d.."em_decode.6", "%BINDIR%man/man6/em_decode.6") - } -} - -tool_esize = cprogram { - cfile (d.."esize.c"), - - outputs = {"%U%/esize"}, - install = { - pm.install("%BINDIR%/bin/esize"), - pm.install(d.."esize.1", "%BINDIR%man/man1/esize.1") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 20:10:41 dtrg --- Added support for the esize object inspection tool. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. \ No newline at end of file diff --git a/util/ncgg/pmfile b/util/ncgg/pmfile deleted file mode 100644 index 21ce2d92c..000000000 --- a/util/ncgg/pmfile +++ /dev/null @@ -1,67 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/ncgg/" - -local ncgg_yacc = yacc { - file (d.."cgg.y") -} - -tool_ncgg = cprogram { - cfile (d.."subr.c"), - cfile (d.."main.c"), - cfile (d.."coerc.c"), - cfile (d.."error.c"), - cfile (d.."emlookup.c"), - cfile (d.."expr.c"), - cfile (d.."instruct.c"), - cfile (d.."iocc.c"), - cfile (d.."lookup.c"), - cfile (d.."output.c"), - cfile (d.."set.c"), - cfile (d.."strlookup.c"), - cfile (d.."var.c"), - cfile (d.."hall.c"), - - cfile { - CEXTRAFLAGS = "-I"..d, - - ncgg_yacc, - dynamicheaders = flex { - file (d.."scan.l") - } - }, - - cfile { - CEXTRAFLAGS = "-I"..d, - simple { - outputs = {"%U%/enterkeyw.c"}, - - command = { - "cp %{return posix.dirname(self['in'][3])}%/y.tab.h %{return posix.dirname(self.out[1])}%", - "cd %{return posix.dirname(self.out[1])}% && "..ROOTDIR..d.."cvtkeywords "..ROOTDIR..d.."keywords", - }, - - file (d.."cvtkeywords"), - file (d.."keywords"), - ncgg_yacc - }, - - dynamicheaders = ncgg_yacc - }, - - lib_em_data, - - outputs = {"%U%-ncgg"}, - install = pm.install(TOOLDIR.."ncgg") -} - -ncgg = simple { - class = "ncgg", - - outputs = {"%U%/tables.c", "%U%/tables.h"}, - command = { - "cd %out[1]:dirname% && (%BINDIR%%PLATDEP%/cpp.ansi -I%NCGGINCLUDEDIR% %in% | %TOOLDIR%ncgg)", - "mv %out[1]:dirname%/tables.H %out[2]%" - }, -} diff --git a/util/opt/pmfile b/util/opt/pmfile deleted file mode 100644 index 450f02745..000000000 --- a/util/opt/pmfile +++ /dev/null @@ -1,114 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/opt/" - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - } -} - -local local_tool_opt = cprogram { - class = "opt_rule", - - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."getline.c"), - cfile_with_headers (d.."lookup.c"), - cfile_with_headers (d.."var.c"), - cfile_with_headers (d.."process.c"), - cfile_with_headers (d.."backward.c"), - cfile_with_headers (d.."util.c"), - cfile_with_headers (d.."alloc.c"), - cfile_with_headers (d.."putline.c"), - cfile_with_headers (d.."cleanup.c"), - cfile_with_headers (d.."peephole.c"), - cfile_with_headers (d.."flow.c"), - cfile_with_headers (d.."tes.c"), - cfile_with_headers (d.."reg.c"), - - cfile_with_headers { - simple { - outputs = {"%U%-pop_push.c"}, - command = { - "awk -f %in[1]% < %in[2]% > %out%" - }, - - file (d.."pop_push.awk"), - file ("%ROOTDIR%h/em_table") - } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-pattern.c"}, - command = { - "%in[1]% < %in[2]% > %out%" - }, - install = pm.install("pattern.c"), - - cprogram { - CLIBRARIES = {PARENT, "fl"}, - - cfile { - yacc { - file (d.."mktab.y") - }, - - dynamicheaders = { - file (d), - flex { - file (d.."scan.l") - } - }, - }, - - lib_em_data, - }, - - preprocess { - file (d.."patterns") - } - } - }, - - lib_em_data, - lib_assert, - lib_print, - lib_alloc, - lib_system, - lib_string, - - outputs = {"%U%/em_opt"}, -} - -tool_opt = group { - group { - local_tool_opt, - install = pm.install(BINDIR.."lib.bin/em_opt") - }, - - group { - CDEFINES = {PARENT, "GLOBAL_OPT"}, - local_tool_opt, - install = pm.install(BINDIR.."lib.bin/em_opt2") - }, -} - --- Revision history --- $Log$ --- Revision 1.5 2007-02-25 12:51:21 dtrg --- em_table is now in /h, not /etc. --- --- Revision 1.4 2007/02/20 00:27:01 dtrg --- Fixed a compilation error that was causing opt to not have its --- peephole optimisation tables, which would make it generate --- duff code. --- --- Revision 1.3 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/20 23:10:07 dtrg --- Fixed revision history. --- diff --git a/util/topgen/pmfile b/util/topgen/pmfile deleted file mode 100644 index e48383e4d..000000000 --- a/util/topgen/pmfile +++ /dev/null @@ -1,56 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/topgen/" - -local lpars = LLgen { - file (d.."topgen.g") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars - } -} - -tool_topgen = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."hash.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."pattern.c"), - cfile_with_headers (d.."symtab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - lib_assert, - lib_print, - lib_alloc, - lib_system, - lib_string, - - outputs = {"%U%/topgen"}, - install = pm.install("%TOOLDIR%topgen") -} - -topgen = simple { - class = "topgen", - - outputs = {"%U%/gen.c"}, - command = { - "mkdir -p %out[1]:dirname%", - "cd %out[1]:dirname% && %TOOLDIR%topgen %in[1]%" - }, -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. From 82399d86aef6187a3ca35cacaa79f08d6c009b9e Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Jun 2016 12:53:57 +0200 Subject: [PATCH 126/231] Added tag release-6-0-pre-5 for changeset 0708542a3c39 --HG-- branch : default-branch --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 425e6c9c6..ba77b0600 100644 --- a/.hgtags +++ b/.hgtags @@ -7,3 +7,4 @@ e880082b57f12a7df1c33a2da2c7424d6368f185 dist2 fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6 90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3 ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 +0708542a3c391238beadc8e2cf9b25283161848b release-6-0-pre-5 From 73ade9cbcfe24eff7787df309669e38d7f2d1024 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Jun 2016 12:55:27 +0200 Subject: [PATCH 127/231] Added tag release-6-0-pre-4 for changeset 42d4fcc3a87c --HG-- branch : default-branch --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index ba77b0600..9a22da112 100644 --- a/.hgtags +++ b/.hgtags @@ -8,3 +8,5 @@ fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6 90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3 ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 0708542a3c391238beadc8e2cf9b25283161848b release-6-0-pre-5 +0000000000000000000000000000000000000000 release-6-0-pre-4 +42d4fcc3a87cb36f6829814cce9b39fcf2f34e00 release-6-0-pre-4 From ca981a2f6a5ff82a35c65607ca581d06b103b3d1 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Jun 2016 12:55:36 +0200 Subject: [PATCH 128/231] Added tag release-6-0-pre-3 for changeset dd12ef08179d --HG-- branch : default-branch --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 9a22da112..d3421c787 100644 --- a/.hgtags +++ b/.hgtags @@ -10,3 +10,5 @@ ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 0708542a3c391238beadc8e2cf9b25283161848b release-6-0-pre-5 0000000000000000000000000000000000000000 release-6-0-pre-4 42d4fcc3a87cb36f6829814cce9b39fcf2f34e00 release-6-0-pre-4 +0000000000000000000000000000000000000000 release-6-0-pre-3 +dd12ef08179d853fe6ec2fbcdfe8a0c5b1409c8d release-6-0-pre-3 From 6db95dc81efaf3118b6e4afbf2b1fd35e17393e8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Jun 2016 12:55:42 +0200 Subject: [PATCH 129/231] Added tag release-6-0-pre-1 for changeset 3d69c08001d4 --HG-- branch : default-branch --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index d3421c787..99bdf2841 100644 --- a/.hgtags +++ b/.hgtags @@ -12,3 +12,5 @@ ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 42d4fcc3a87cb36f6829814cce9b39fcf2f34e00 release-6-0-pre-4 0000000000000000000000000000000000000000 release-6-0-pre-3 dd12ef08179d853fe6ec2fbcdfe8a0c5b1409c8d release-6-0-pre-3 +0000000000000000000000000000000000000000 release-6-0-pre-1 +3d69c08001d4749a327b636a5fdb472a5573c2a3 release-6-0-pre-1 From 45f0cb3c0d305ddf8619dd266ac90ee102c771c6 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Jun 2016 12:56:00 +0200 Subject: [PATCH 130/231] Added tag release-5-6 for changeset 976d56ed63bd --HG-- branch : default-branch --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 99bdf2841..25b7217e8 100644 --- a/.hgtags +++ b/.hgtags @@ -14,3 +14,5 @@ ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 dd12ef08179d853fe6ec2fbcdfe8a0c5b1409c8d release-6-0-pre-3 0000000000000000000000000000000000000000 release-6-0-pre-1 3d69c08001d4749a327b636a5fdb472a5573c2a3 release-6-0-pre-1 +0000000000000000000000000000000000000000 release-5-6 +976d56ed63bda3752bc0db7e0b753cd193489f3b release-5-6 From ffc03090ea8ae646a8525b3105118552268cdf82 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Jun 2016 18:16:52 +0200 Subject: [PATCH 131/231] hgtags shouldn't be checked in. --- .hgtags | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .hgtags diff --git a/.hgtags b/.hgtags deleted file mode 100644 index 25b7217e8..000000000 --- a/.hgtags +++ /dev/null @@ -1,18 +0,0 @@ -5a0daa6017c4aa5ae23b870e97eb7431021762bc distr2 -15b742c4c278c27029eca0e41f16463bc076de6e distr3 -a0686e2ca8d6780ce37b8267b865f60e9317a340 llgen-1-0 -d96cd06672c368e8aaa584fead379ce1d343acad oct-1 -bf69b3579e8545ecfc03f5e2550586e3c479270d release-6-0-pre-4 -e880082b57f12a7df1c33a2da2c7424d6368f185 dist2 -fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6 -90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3 -ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 -0708542a3c391238beadc8e2cf9b25283161848b release-6-0-pre-5 -0000000000000000000000000000000000000000 release-6-0-pre-4 -42d4fcc3a87cb36f6829814cce9b39fcf2f34e00 release-6-0-pre-4 -0000000000000000000000000000000000000000 release-6-0-pre-3 -dd12ef08179d853fe6ec2fbcdfe8a0c5b1409c8d release-6-0-pre-3 -0000000000000000000000000000000000000000 release-6-0-pre-1 -3d69c08001d4749a327b636a5fdb472a5573c2a3 release-6-0-pre-1 -0000000000000000000000000000000000000000 release-5-6 -976d56ed63bda3752bc0db7e0b753cd193489f3b release-5-6 From d0bfee142bd52d5f02c0a291de28cbd107d0d56c Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 5 Jun 2016 10:39:29 +0200 Subject: [PATCH 132/231] Archival non-working checkin of the experimental build tool. --- first/ackbuilder.lua | 254 +++++++++++++++++++++++++++++++++++++++++++ first/bouncer | 32 ++++++ 2 files changed, 286 insertions(+) create mode 100644 first/ackbuilder.lua create mode 100755 first/bouncer diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua new file mode 100644 index 000000000..963173405 --- /dev/null +++ b/first/ackbuilder.lua @@ -0,0 +1,254 @@ +local M = {} + +function M.subenv(p) + local e = p[1] + setmetable(p, {__index = e}) + return p +end + +local function check_filename(fn) + if type(fn) == "table" then + for _, f in ipairs(fn) do + check_filename(f) + end + else + if fn:find("%s") then + error("Filename '"+fn+"' contains spaces. This will make the build system sad.") + end + end +end + +function M.basename(fn) + if type(fn) == "table" then + local nfn = {} + for _, f in ipairs(fn) do + nfn[#nfn+1] = M.basename(f) + end + return nfn + else + local _, _, base = fn:find("([^/]*)$") + return base + end +end + +function M.flatten(t) + if t == nil then + return {} + end + + local tt = {} + for _, subt in ipairs(t) do + if type(subt) == "table" then + for _, subt in ipairs(M.flatten(subt)) do + tt[#tt+1] = subt + end + else + tt[#tt+1] = subt + end + end + return tt +end + +local function append(...) + local ts = {} + for _, t in ipairs({...}) do + for _, v in ipairs(t) do + ts[#ts+1] = v + end + end + return ts +end + +local function settotable(s) + local t = {} + for k in pairs(s) do + t[#t+1] = k + end + return t +end + +local function asstring(t) + return table.concat(M.flatten(t), " ") +end + +local function emit(...) + for _, s in ipairs({...}) do + io.stdout:write(s) + end +end + +function M.rawtarget(p) + local description = p.description or error("no description supplied") + local ins = M.flatten(p.ins) + local outs = M.flatten(p.outs) + + local cmd = p.command + if type(cmd) ~= "table" then + cmd = {cmd} + end + + for _, s in ipairs(ins) do + check_filename(s) + end + for _, s in ipairs(outs) do + check_filename(s) + end + + emit(outs[1], ":") + for _, s in ipairs(ins) do + emit(" ", s) + end + emit("\n") + + emit("\t@echo ", p.description, "\n") + + emit("\t$(hide) ", table.concat(cmd, " && "), "\n") + + for i = 2, #outs do + emit(outs[i], ": ", outs[1], "\n") + end + + emit("\n") +end + +function M.export(p) + local e = p[1] + local dest = p.dest or error("no export destination provided") + local deps = p.deps or error("nothing to export") + + local fdeps = M.flatten(deps) + + if #fdeps ~= 1 then + error("you can only export one thing at a time") + end + + return M.rawtarget {e, + ins=deps, + outs={dest}, + command="cp "..fdeps[1].." "..dest, + description="EXPORT "..dest + } +end + +function M.hermetic(p) + local e = p[1] + local ins = M.flatten(p.ins) + local deps = M.flatten(p.deps) + local baseouts = p.baseouts or error("you must specify some baseouts") + local description = p.description + + local absouts = {} + local path = e.PATH .. "/" .. p.baseouts[1] .. ".env" + + for _, s in ipairs(M.flatten(p.baseouts)) do + absouts[#absouts+1] = path .. "/" .. s + end + + local dirset = {} + for _, s in ipairs(absouts) do + local d = s:gsub("^(.*/).*$", "%1") + if d then + dirset[d] = true + end + end + + local newcmd = { + "rm -rf "..path, + "mkdir -p "..asstring(settotable(dirset)), + "ln -srf "..asstring(append(ins, deps)).." "..path, + "cd "..path + } + for _, s in ipairs(p.command) do + newcmd[#newcmd+1] = "(" .. s .. ")" + end + + M.rawtarget {e, + ins={ins, unpack(deps)}, + outs=absouts, + command=newcmd, + description=description + } + + return absouts +end + +function M.cfile(p) + local e = p[1] + local src = p.src + local deps = p.deps or {} + + local outfile = p.src:gsub("%.c$", ".o") + local basesrc = M.basename(p.src) + + return M.hermetic {e, + ins={src}, + deps=deps, + baseouts={outfile}, + command={e.CC.." "..e.CFLAGS.." -c -o "..outfile.." "..basesrc}, + description="CC "..src + } +end + +function M.cprogram(p) + local e = p[1] + local name = p.name or error("cprogram must have a name specified") + local deps = p.deps or {} + local libs = p.libraries or {} + local headers = p.headers or {} + + if p.srcs then + local mainlib = M.clibrary {e, + name=name..".a", + deps=deps, + srcs=p.srcs, + headers=headers + } + + deps = append(deps, {mainlib}) + end + + local libflags = {} + for _, s in ipairs(libs) do + libflags[#libflags+1] = "-l"..s + end + + return M.hermetic {e, + ins=deps, + baseouts={name}, + command={e.CC.." "..e.CFLAGS.." -o "..name.." "..asstring(M.basename(deps)).." "..asstring(libflags)}, + description="CLINK "..name + } +end + +function M.clibrary(p) + local e = p[1] + local name = p.name or error("clibrary must have a name specified") + local deps = M.flatten(p.deps) + local srcs = M.flatten(p.srcs) + local headers = M.flatten(p.headers) + + local baseouts = {name} + + local objs = deps + for _, f in ipairs(srcs) do + objs[#objs+1] = M.cfile {e, + src=f, + deps=headers + } + end + + return M.hermetic {e, + ins=append(objs, headers), + baseouts=baseouts, + command={ + e.AR.." q "..name.." "..asstring(M.basename(objs)), + e.RANLIB.." "..name, + }, + description="CLIBRARY "..name + } +end + +emit("hide = @\n") + +return M + diff --git a/first/bouncer b/first/bouncer new file mode 100755 index 000000000..f7408a012 --- /dev/null +++ b/first/bouncer @@ -0,0 +1,32 @@ +#!/bin/sh +set -e +set -x + +logfile=/tmp/bouncer.$$ +trap "rm -f $logfile" EXIT + +if [ S"$1" = S"" ]; then + >&2 echo "bouncer: syntax error: BOUNCER_WHITELIST=... bouncer " + exit 1 +fi + +strace -eopen,chdir -o $logfile -f "$@" + +awk -f- -F '[ "()]+' $logfile <<"EOF" + +BEGIN { + split(ENVIRON["BOUNCER_WHITELIST"], whitelist_array, " +"); + for (i in whitelist_array) + whitelist[whitelist_array[i]] = 1; +} + +$2 == "chdir" { + print "pid ", $1, " chdir: ", $3; +} + +($2 == "open") && ($5 !~ /O_CREAT/) && ($7 != -1) { + print "pid ", $1, " open: ", $3, $7; +} + +EOF + From df1372ab3509a0818ade875d35533c9828d99a64 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 6 Jun 2016 17:18:19 +0200 Subject: [PATCH 133/231] Really basic skeleton of Ackbuilder mark 2. --- first/ackbuilder.lua | 295 +++++++++---------------------------------- 1 file changed, 63 insertions(+), 232 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 963173405..1ac37350f 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -1,254 +1,85 @@ -local M = {} +-- Targets: +-- +-- { +-- dir = target's build directory +-- outs = target's object files +-- is = { set of rule types which made the target } +-- } -function M.subenv(p) - local e = p[1] - setmetable(p, {__index = e}) - return p +local environment = {} +local rules = {} + +local function subenv(old, cb) + if not old then + old = environment + end + local new = {} + setmetatable(new, {__index = old}) + cb(new, old) + return new end -local function check_filename(fn) - if type(fn) == "table" then - for _, f in ipairs(fn) do - check_filename(f) +local function asstring(o) + local t = type(o) + if (t == "string") then + return o + elseif (t == "number") then + return o + elseif (t == "table") then + local s = {} + for _, v in pairs(o) do + s[#s+1] = asstring(v) end + return table.concat(s, " ") else - if fn:find("%s") then - error("Filename '"+fn+"' contains spaces. This will make the build system sad.") - end + error(string.format("can't turn values of type '%s' into strings", t)) end end -function M.basename(fn) - if type(fn) == "table" then - local nfn = {} - for _, f in ipairs(fn) do - nfn[#nfn+1] = M.basename(f) - end - return nfn - else - local _, _, base = fn:find("([^/]*)$") - return base - end -end - -function M.flatten(t) - if t == nil then - return {} - end - - local tt = {} - for _, subt in ipairs(t) do - if type(subt) == "table" then - for _, subt in ipairs(M.flatten(subt)) do - tt[#tt+1] = subt - end - else - tt[#tt+1] = subt - end - end - return tt -end - -local function append(...) - local ts = {} - for _, t in ipairs({...}) do - for _, v in ipairs(t) do - ts[#ts+1] = v - end - end - return ts -end - -local function settotable(s) - local t = {} - for k in pairs(s) do - t[#t+1] = k - end - return t -end - -local function asstring(t) - return table.concat(M.flatten(t), " ") -end - local function emit(...) - for _, s in ipairs({...}) do + local n = select("#", ...) + local args = {...} + + for i=1, n do + local s = asstring(args[i]) io.stdout:write(s) - end -end - -function M.rawtarget(p) - local description = p.description or error("no description supplied") - local ins = M.flatten(p.ins) - local outs = M.flatten(p.outs) - - local cmd = p.command - if type(cmd) ~= "table" then - cmd = {cmd} - end - - for _, s in ipairs(ins) do - check_filename(s) - end - for _, s in ipairs(outs) do - check_filename(s) - end - - emit(outs[1], ":") - for _, s in ipairs(ins) do - emit(" ", s) - end - emit("\n") - - emit("\t@echo ", p.description, "\n") - - emit("\t$(hide) ", table.concat(cmd, " && "), "\n") - - for i = 2, #outs do - emit(outs[i], ": ", outs[1], "\n") - end - - emit("\n") -end - -function M.export(p) - local e = p[1] - local dest = p.dest or error("no export destination provided") - local deps = p.deps or error("nothing to export") - - local fdeps = M.flatten(deps) - - if #fdeps ~= 1 then - error("you can only export one thing at a time") - end - - return M.rawtarget {e, - ins=deps, - outs={dest}, - command="cp "..fdeps[1].." "..dest, - description="EXPORT "..dest - } -end - -function M.hermetic(p) - local e = p[1] - local ins = M.flatten(p.ins) - local deps = M.flatten(p.deps) - local baseouts = p.baseouts or error("you must specify some baseouts") - local description = p.description - - local absouts = {} - local path = e.PATH .. "/" .. p.baseouts[1] .. ".env" - - for _, s in ipairs(M.flatten(p.baseouts)) do - absouts[#absouts+1] = path .. "/" .. s - end - - local dirset = {} - for _, s in ipairs(absouts) do - local d = s:gsub("^(.*/).*$", "%1") - if d then - dirset[d] = true + if not s:find("\n$") then + io.stdout:write(" ") end end - - local newcmd = { - "rm -rf "..path, - "mkdir -p "..asstring(settotable(dirset)), - "ln -srf "..asstring(append(ins, deps)).." "..path, - "cd "..path - } - for _, s in ipairs(p.command) do - newcmd[#newcmd+1] = "(" .. s .. ")" - end - - M.rawtarget {e, - ins={ins, unpack(deps)}, - outs=absouts, - command=newcmd, - description=description - } - - return absouts end -function M.cfile(p) - local e = p[1] - local src = p.src - local deps = p.deps or {} - - local outfile = p.src:gsub("%.c$", ".o") - local basesrc = M.basename(p.src) - - return M.hermetic {e, - ins={src}, - deps=deps, - baseouts={outfile}, - command={e.CC.." "..e.CFLAGS.." -c -o "..outfile.." "..basesrc}, - description="CC "..src - } +local function definerule(name, cb) + if rules[name] then + error(string.format("rule '%s' is already defined", name)) + end end -function M.cprogram(p) - local e = p[1] - local name = p.name or error("cprogram must have a name specified") - local deps = p.deps or {} - local libs = p.libraries or {} - local headers = p.headers or {} +----------------------------------------------------------------------------- +-- MAIN PROGRAM -- +----------------------------------------------------------------------------- - if p.srcs then - local mainlib = M.clibrary {e, - name=name..".a", - deps=deps, - srcs=p.srcs, - headers=headers - } +local globals = { + asstring = asstring, + definerule = definerule, + emit = emit, + environment = environment, +} +setmetatable(globals, {__index = _G}) - deps = append(deps, {mainlib}) +emit("hide=@\n") +for _, file in ipairs({...}) do + local data, chunk, e + data = io.open(file):read("*a") + if not e then + local thisglobals = {_G = thisglobals} + setmetatable(thisglobals, {__index = globals}) + chunk, e = loadstring(data, file, "text", thisglobals) + end + if e then + error(string.format("couldn't load '%s': %s", file, e)) end - local libflags = {} - for _, s in ipairs(libs) do - libflags[#libflags+1] = "-l"..s - end - - return M.hermetic {e, - ins=deps, - baseouts={name}, - command={e.CC.." "..e.CFLAGS.." -o "..name.." "..asstring(M.basename(deps)).." "..asstring(libflags)}, - description="CLINK "..name - } + local _, e = pcall(chunk) end -function M.clibrary(p) - local e = p[1] - local name = p.name or error("clibrary must have a name specified") - local deps = M.flatten(p.deps) - local srcs = M.flatten(p.srcs) - local headers = M.flatten(p.headers) - - local baseouts = {name} - - local objs = deps - for _, f in ipairs(srcs) do - objs[#objs+1] = M.cfile {e, - src=f, - deps=headers - } - end - - return M.hermetic {e, - ins=append(objs, headers), - baseouts=baseouts, - command={ - e.AR.." q "..name.." "..asstring(M.basename(objs)), - e.RANLIB.." "..name, - }, - description="CLIBRARY "..name - } -end - -emit("hide = @\n") - -return M - From cb0111b2904d1c01885a1e739a3dae5f31a41673 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 6 Jun 2016 20:50:48 +0200 Subject: [PATCH 134/231] Skeleton of the rule engine and type system. --- first/ackbuilder.lua | 170 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 153 insertions(+), 17 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 1ac37350f..301078c6d 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -8,6 +8,10 @@ local environment = {} local rules = {} +local targets = {} +local buildfiles = {} +local globals +local cwd = "." local function subenv(old, cb) if not old then @@ -49,37 +53,169 @@ local function emit(...) end end -local function definerule(name, cb) - if rules[name] then - error(string.format("rule '%s' is already defined", name)) +local function loadbuildfile(filename) + local data, chunk, e + data = io.open(filename):read("*a") + if not e then + local thisglobals = {_G = thisglobals} + setmetatable(thisglobals, {__index = globals}) + chunk, e = loadstring(data, filename, "text", thisglobals) + end + if e then + error(string.format("couldn't load '%s': %s", filename, e)) + end + + chunk() +end + +local function loadtarget(targetname) + if targets[target] then + return targets[targetname] + end + + local target + if not target:find(":") then + target = { + outs = {targetname}, + is = { + __implicitfile = true + } + } + targets[targetname] = target + else + local _, _, filepart, targetpart = targetname:find("^([^:]+):(%w+)$") + if not filepart or not targetpart then + error(string.format("malformed target name '%s'", targetname)) + end + if not buildfiles[filepart] then + buildfiles[filepart] = true + + local oldcwd = cwd + cwd = filepart + loadbuildfile(filepart.."/build.lua") + cwd = oldcwd + end + + target = targets[targetname] + if not target then + error(string.format("build file '%s' contains no rule '%s'", + filepart, targetpart)) + end + end + + return target +end + +local typeconverters = { + targets = function(propname, i) + if (type(i) == "string") then + i = {i} + elseif (type(i) ~= "table") then + error(string.format("property '%s' must be a target list", propname)) + end + + local o = {} + for _, s in ipairs(i) do + if (type(s) ~= "string") then + error(string.format("member of target list '%s' is not a string", propname)) + end + + if s:find("^//") then + s = s:gsub("^//", "") + elseif s:find("^[/]") then + s = concatpath(cwd, s) + end + o[#o+1] = s + end + end, + + strings = function(propname, i) + if (type(i) == "string") then + i = {i} + elseif (type(i) ~= "table") then + error(string.format("property '%s' must be a string list", propname)) + end + + return i + end, + + string = function(propname, i) + if (type(i) ~= "string") then + error(string.format("property '%s' must be a string", propname)) + end + end, +} + +local function definerule(rulename, types, cb) + if rules[rulename] then + error(string.format("rule '%s' is already defined", rulename)) + end + + types.name = { type="string" } + + for propname, typespec in pairs(types) do + if not typeconverters[typespec.type] then + error(string.format("property '%s' has unrecognised type '%s'", + propname, typespec.type)) + end + end + + rules[rulename] = function(e) + local args = {} + for propname, typespec in pairs(types) do + if not e[propname] and not typespec.optional then + error(string.format("missing mandatory property '%s'", propname)) + end + + args[propname] = typeconverters[typespec.type](propname, e[propname]) + e[propname] = nil + end + + local propname, _ = next(e) + if propname then + error(string.format("don't know what to do with property '%s'", propname)) + end end end +----------------------------------------------------------------------------- +-- DEFAULT RULES -- +----------------------------------------------------------------------------- + +definerule("simplerule", + { + ins = { type="targets" }, + outs = { type="strings" }, + }, + function (e) + end +) + ----------------------------------------------------------------------------- -- MAIN PROGRAM -- ----------------------------------------------------------------------------- -local globals = { +globals = { asstring = asstring, definerule = definerule, emit = emit, environment = environment, } -setmetatable(globals, {__index = _G}) +setmetatable(globals, + { + __index = function(self, k) + local rule = rules[k] + if rule then + return rule + else + return _G[k] + end + end + } +) emit("hide=@\n") for _, file in ipairs({...}) do - local data, chunk, e - data = io.open(file):read("*a") - if not e then - local thisglobals = {_G = thisglobals} - setmetatable(thisglobals, {__index = globals}) - chunk, e = loadstring(data, file, "text", thisglobals) - end - if e then - error(string.format("couldn't load '%s': %s", file, e)) - end - - local _, e = pcall(chunk) + loadbuildfile(file) end From 14ccf7151e1c7d35a0b259106df3773ba6cd101e Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 6 Jun 2016 22:13:30 +0200 Subject: [PATCH 135/231] Most of simplerule now looks like it's working. --- first/ackbuilder.lua | 109 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 100 insertions(+), 9 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 301078c6d..4a0888c22 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -40,6 +40,52 @@ local function asstring(o) end end +local function concatpath(...) + local p = table.concat({...}, "/") + return p:gsub("/+", "/"):gsub("^%./", "") +end + +local function dirname(filename) + local _, _, b = filename:find("^(.*)/[^/]*$") + if not b then + return "" + end + return b +end + +local function dirnames(collection) + local o = {} + for _, s in pairs(collection) do + local b = dirname(s) + if (b ~= "") then + o[#o+1] = b + end + end + return o +end + +local function filenamesof(results) + local f = {} + for _, r in pairs(results) do + for _, o in pairs(r.outs) do + f[#f+1] = o + end + end + return f +end + +local function uniquify(collection) + local s = {} + local o = {} + for _, v in pairs(collection) do + if not s[v] then + s[v] = true + o[#o+1] = s + end + end + return o +end + local function emit(...) local n = select("#", ...) local args = {...} @@ -74,7 +120,7 @@ local function loadtarget(targetname) end local target - if not target:find(":") then + if not targetname:find(":") then target = { outs = {targetname}, is = { @@ -122,11 +168,12 @@ local typeconverters = { if s:find("^//") then s = s:gsub("^//", "") - elseif s:find("^[/]") then + elseif s:find("^[^/]") then s = concatpath(cwd, s) end - o[#o+1] = s + o[#o+1] = loadtarget(s) end + return o end, strings = function(propname, i) @@ -135,7 +182,6 @@ local typeconverters = { elseif (type(i) ~= "table") then error(string.format("property '%s' must be a string list", propname)) end - return i end, @@ -143,6 +189,7 @@ local typeconverters = { if (type(i) ~= "string") then error(string.format("property '%s' must be a string", propname)) end + return i end, } @@ -163,18 +210,25 @@ local function definerule(rulename, types, cb) rules[rulename] = function(e) local args = {} for propname, typespec in pairs(types) do - if not e[propname] and not typespec.optional then - error(string.format("missing mandatory property '%s'", propname)) - end + if not e[propname] then + if not typespec.optional then + error(string.format("missing mandatory property '%s'", propname)) + end - args[propname] = typeconverters[typespec.type](propname, e[propname]) - e[propname] = nil + args[propname] = typespec.default + else + args[propname] = typeconverters[typespec.type](propname, e[propname]) + e[propname] = nil + end end local propname, _ = next(e) if propname then error(string.format("don't know what to do with property '%s'", propname)) end + + args.environment = environment + cb(args) end end @@ -182,12 +236,49 @@ end -- DEFAULT RULES -- ----------------------------------------------------------------------------- +function environment:rule(ins, outs) + local firstout = outs[1] + for i = 2, #outs do + emit(outs[i], ":", outs[1], "\n") + end + for i = 1, #ins do + emit(firstout, ":", ins[i], "\n") + end + emit(firstout, ":\n") +end + +function environment:label(...) + local s = table.concat({...}, " ") + emit("\t@echo", s, "\n") +end + +function environment:mkdirs(dirs) + dirs = uniquify(dirs) + if (#dirs > 0) then + emit("\t@mkdir -p ", dirs, "\n") + end +end + +function environment:exec(commands) + local o = {} + for _, s in ipairs(commands) do + o[#o+1] = "("..s..")" + end + emit("\t$(hide)", table.concat(o, " && "), "\n") +end + definerule("simplerule", { ins = { type="targets" }, outs = { type="strings" }, + label = { type="string", optional=true }, + commands = { type="strings" }, }, function (e) + e.environment:rule(filenamesof(e.ins), e.outs) + e.environment:label(e.name, " ", e.label or "") + e.environment:mkdirs(dirnames(e.outs)) + e.environment:exec(e.commands) end ) From b7d2b9c3cfbe4f3bf324a91dbd3766761113806d Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 7 Jun 2016 00:10:22 +0200 Subject: [PATCH 136/231] Dependent rules work! --- first/ackbuilder.lua | 116 ++++++++++++----- first/build.lua | 300 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 383 insertions(+), 33 deletions(-) create mode 100644 first/build.lua diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 4a0888c22..413389a98 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -30,11 +30,15 @@ local function asstring(o) elseif (t == "number") then return o elseif (t == "table") then - local s = {} - for _, v in pairs(o) do - s[#s+1] = asstring(v) + if o.outs then + return asstring(o.outs) + else + local s = {} + for _, v in pairs(o) do + s[#s+1] = asstring(v) + end + return table.concat(s, " ") end - return table.concat(s, " ") else error(string.format("can't turn values of type '%s' into strings", t)) end @@ -99,23 +103,54 @@ local function emit(...) end end -local function loadbuildfile(filename) - local data, chunk, e - data = io.open(filename):read("*a") - if not e then - local thisglobals = {_G = thisglobals} - setmetatable(thisglobals, {__index = globals}) - chunk, e = loadstring(data, filename, "text", thisglobals) - end - if e then - error(string.format("couldn't load '%s': %s", filename, e)) - end +local function templateexpand(list, vars) + setmetatable(vars, { __index = globals }) - chunk() + local o = {} + for _, s in ipairs(list) do + o[#o+1] = s:gsub("%%%b{}", + function(expr) + expr = expr:sub(3, -2) + local chunk, e = loadstring("return "..expr, expr, "text", vars) + if e then + error(string.format("error evaluating expression: %s", e)) + end + return asstring(chunk()) + end + ) + end + return o +end + +local function loadbuildfile(filename) + if not buildfiles[filename] then + buildfiles[filename] = true + + local fp, data, chunk, e + io.stderr:write("loading ", filename, "\n") + fp, e = io.open(filename) + if not e then + data, e = fp:read("*a") + fp:close() + if not e then + local thisglobals = {_G = thisglobals} + setmetatable(thisglobals, {__index = globals}) + chunk, e = loadstring(data, filename, "text", thisglobals) + end + end + if e then + error(string.format("couldn't load '%s': %s", filename, e)) + end + + local oldcwd = cwd + cwd = dirname(filename) + chunk() + cwd = oldcwd + end end local function loadtarget(targetname) - if targets[target] then + if targets[targetname] then return targets[targetname] end @@ -129,23 +164,20 @@ local function loadtarget(targetname) } targets[targetname] = target else - local _, _, filepart, targetpart = targetname:find("^([^:]+):(%w+)$") + local _, _, filepart, targetpart = targetname:find("^([^:]*):(%w+)$") if not filepart or not targetpart then error(string.format("malformed target name '%s'", targetname)) end - if not buildfiles[filepart] then - buildfiles[filepart] = true - - local oldcwd = cwd - cwd = filepart - loadbuildfile(filepart.."/build.lua") - cwd = oldcwd + if (filepart == "") then + filepart = cwd end + local filename = concatpath(filepart, "/build.lua") + loadbuildfile(concatpath(filename)) target = targets[targetname] if not target then error(string.format("build file '%s' contains no rule '%s'", - filepart, targetpart)) + filename, targetpart)) end end @@ -168,6 +200,8 @@ local typeconverters = { if s:find("^//") then s = s:gsub("^//", "") + elseif s:find("^:") then + s = cwd..s elseif s:find("^[^/]") then s = concatpath(cwd, s) end @@ -228,7 +262,11 @@ local function definerule(rulename, types, cb) end args.environment = environment - cb(args) + + local result = cb(args) or {} + result.is = result.is or {} + result.is[rulename] = true + targets[cwd..":"..args.name] = result end end @@ -260,11 +298,11 @@ function environment:mkdirs(dirs) end function environment:exec(commands) - local o = {} - for _, s in ipairs(commands) do - o[#o+1] = "("..s..")" - end - emit("\t$(hide)", table.concat(o, " && "), "\n") + emit("\t$(hide)", table.concat(commands, " && "), "\n") +end + +function environment:endrule() + emit("\n") end definerule("simplerule", @@ -278,7 +316,19 @@ definerule("simplerule", e.environment:rule(filenamesof(e.ins), e.outs) e.environment:label(e.name, " ", e.label or "") e.environment:mkdirs(dirnames(e.outs)) - e.environment:exec(e.commands) + e.environment:exec( + templateexpand(e.commands, + { + ins = e.ins, + outs = e.outs + } + ) + ) + e.environment:endrule() + + return { + outs = e.outs + } end ) diff --git a/first/build.lua b/first/build.lua new file mode 100644 index 000000000..ded146587 --- /dev/null +++ b/first/build.lua @@ -0,0 +1,300 @@ +simplerule { + name = "random", + ins = {}, + outs = {"out"}, + commands = { + "dd if=/dev/random of=%{outs} bs=1024 count=1" + } +} + +simplerule { + name = "sorted", + ins = { ":random" }, + outs = { "sorted" }, + commands = { + "sort %{ins} > %{outs}" + } +} + +--[[ +function environment:cfileflags() + emit("$CFLAGS") +end + +function environment:cfile(srcs, obj, includes) + emit("$CC -o", obj, srcs) + emit(ab.expand(includes, "-I%")) + self:cflags() + emit("\n") +end + +function environment:clinkflags() + emit("$LDFLAGS") +end + +function environment:clink(objs, exe, libraryFlags) + emit("$CC -o", exe, objs, libraryFlags) + self:clinkflags() + emit("\n") +end + +-- +-- Targets: +-- +-- { +-- dir = target's build directory +-- outs = target's object files +-- is = { set of rule types which made the target } +-- } +function M.subenv(p) + local e = p[1] + setmetable(p, {__index = e}) + return p +end + +local function check_filename(fn) + if type(fn) == "table" then + for _, f in ipairs(fn) do + check_filename(f) + end + else + if fn:find("%s") then + error("Filename '"+fn+"' contains spaces. This will make the build system sad.") + end + end +end + +function M.basename(fn) + if type(fn) == "table" then + local nfn = {} + for _, f in ipairs(fn) do + nfn[#nfn+1] = M.basename(f) + end + return nfn + else + local _, _, base = fn:find("([^/]*)$") + return base + end +end + +function M.flatten(t) + if t == nil then + return {} + end + + local tt = {} + for _, subt in ipairs(t) do + if type(subt) == "table" then + for _, subt in ipairs(M.flatten(subt)) do + tt[#tt+1] = subt + end + else + tt[#tt+1] = subt + end + end + return tt +end + +local function append(...) + local ts = {} + for _, t in ipairs({...}) do + for _, v in ipairs(t) do + ts[#ts+1] = v + end + end + return ts +end + +local function settotable(s) + local t = {} + for k in pairs(s) do + t[#t+1] = k + end + return t +end + +local function asstring(t) + return table.concat(M.flatten(t), " ") +end + +local function emit(...) + for _, s in ipairs({...}) do + io.stdout:write(s) + end +end + +function M.rawtarget(p) + local description = p.description or error("no description supplied") + local ins = M.flatten(p.ins) + local outs = M.flatten(p.outs) + + local cmd = p.command + if type(cmd) ~= "table" then + cmd = {cmd} + end + + for _, s in ipairs(ins) do + check_filename(s) + end + for _, s in ipairs(outs) do + check_filename(s) + end + + emit(outs[1], ":") + for _, s in ipairs(ins) do + emit(" ", s) + end + emit("\n") + + emit("\t@echo ", p.description, "\n") + + emit("\t$(hide) ", table.concat(cmd, " && "), "\n") + + for i = 2, #outs do + emit(outs[i], ": ", outs[1], "\n") + end + + emit("\n") +end + +function M.export(p) + local e = p[1] + local dest = p.dest or error("no export destination provided") + local deps = p.deps or error("nothing to export") + + local fdeps = M.flatten(deps) + + if #fdeps ~= 1 then + error("you can only export one thing at a time") + end + + return M.rawtarget {e, + ins=deps, + outs={dest}, + command="cp "..fdeps[1].." "..dest, + description="EXPORT "..dest + } +end + +function M.hermetic(p) + local e = p[1] + local ins = M.flatten(p.ins) + local deps = M.flatten(p.deps) + local baseouts = p.baseouts or error("you must specify some baseouts") + local description = p.description + + local absouts = {} + local path = e.PATH .. "/" .. p.baseouts[1] .. ".env" + + for _, s in ipairs(M.flatten(p.baseouts)) do + absouts[#absouts+1] = path .. "/" .. s + end + + local dirset = {} + for _, s in ipairs(absouts) do + local d = s:gsub("^(.*/).*$", "%1") + if d then + dirset[d] = true + end + end + + local newcmd = { + "rm -rf "..path, + "mkdir -p "..asstring(settotable(dirset)), + "ln -srf "..asstring(append(ins, deps)).." "..path, + "cd "..path + } + for _, s in ipairs(p.command) do + newcmd[#newcmd+1] = "(" .. s .. ")" + end + + M.rawtarget {e, + ins={ins, unpack(deps)}, + outs=absouts, + command=newcmd, + description=description + } + + return absouts +end + +function M.cfile(p) + local e = p[1] + local src = p.src + local deps = p.deps or {} + + local outfile = p.src:gsub("%.c$", ".o") + local basesrc = M.basename(p.src) + + return M.hermetic {e, + ins={src}, + deps=deps, + baseouts={outfile}, + command={e.CC.." "..e.CFLAGS.." -c -o "..outfile.." "..basesrc}, + description="CC "..src + } +end + +function M.cprogram(p) + local e = p[1] + local name = p.name or error("cprogram must have a name specified") + local deps = p.deps or {} + local libs = p.libraries or {} + local headers = p.headers or {} + + if p.srcs then + local mainlib = M.clibrary {e, + name=name..".a", + deps=deps, + srcs=p.srcs, + headers=headers + } + + deps = append(deps, {mainlib}) + end + + local libflags = {} + for _, s in ipairs(libs) do + libflags[#libflags+1] = "-l"..s + end + + return M.hermetic {e, + ins=deps, + baseouts={name}, + command={e.CC.." "..e.CFLAGS.." -o "..name.." "..asstring(M.basename(deps)).." "..asstring(libflags)}, + description="CLINK "..name + } +end + +function M.clibrary(p) + local e = p[1] + local name = p.name or error("clibrary must have a name specified") + local deps = M.flatten(p.deps) + local srcs = M.flatten(p.srcs) + local headers = M.flatten(p.headers) + + local baseouts = {name} + + local objs = deps + for _, f in ipairs(srcs) do + objs[#objs+1] = M.cfile {e, + src=f, + deps=headers + } + end + + return M.hermetic {e, + ins=append(objs, headers), + baseouts=baseouts, + command={ + e.AR.." q "..name.." "..asstring(M.basename(objs)), + e.RANLIB.." "..name, + }, + description="CLIBRARY "..name + } +end + +emit("hide = @\n") + +return M +--]] From 79f7c0ad2374006a68cb1074d34e5d93d1af5da1 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 7 Jun 2016 04:13:56 +0200 Subject: [PATCH 137/231] Leaf rules work! --- first/ackbuilder.lua | 35 ++++++++++++++++++++++++----------- first/build.lua | 29 +++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 413389a98..d708105f1 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -1,3 +1,5 @@ +local posix = require("posix") + -- Targets: -- -- { @@ -25,12 +27,14 @@ end local function asstring(o) local t = type(o) - if (t == "string") then + if (t == "nil") then + return "" + elseif (t == "string") then return o elseif (t == "number") then return o elseif (t == "table") then - if o.outs then + if o.is then return asstring(o.outs) else local s = {} @@ -71,8 +75,14 @@ end local function filenamesof(results) local f = {} for _, r in pairs(results) do - for _, o in pairs(r.outs) do - f[#f+1] = o + if (type(r) == "string") then + f[#f+1] = r + elseif (type(r) == "table") then + if r.is and r.outs then + for _, o in pairs(r.outs) do + f[#f+1] = o + end + end end end return f @@ -84,7 +94,7 @@ local function uniquify(collection) for _, v in pairs(collection) do if not s[v] then s[v] = true - o[#o+1] = s + o[#o+1] = v end end return o @@ -267,6 +277,7 @@ local function definerule(rulename, types, cb) result.is = result.is or {} result.is[rulename] = true targets[cwd..":"..args.name] = result + return result end end @@ -277,12 +288,12 @@ end function environment:rule(ins, outs) local firstout = outs[1] for i = 2, #outs do - emit(outs[i], ":", outs[1], "\n") + emit(outs[i]..":", outs[1], "\n") end for i = 1, #ins do - emit(firstout, ":", ins[i], "\n") + emit(firstout..":", ins[i], "\n") end - emit(firstout, ":\n") + emit(firstout..":\n") end function environment:label(...) @@ -293,7 +304,7 @@ end function environment:mkdirs(dirs) dirs = uniquify(dirs) if (#dirs > 0) then - emit("\t@mkdir -p ", dirs, "\n") + emit("\t@mkdir -p", dirs, "\n") end end @@ -314,8 +325,8 @@ definerule("simplerule", }, function (e) e.environment:rule(filenamesof(e.ins), e.outs) - e.environment:label(e.name, " ", e.label or "") - e.environment:mkdirs(dirnames(e.outs)) + e.environment:label(cwd..":"..e.name, " ", e.label or "") + e.environment:mkdirs(dirnames(filenamesof(e.outs))) e.environment:exec( templateexpand(e.commands, { @@ -338,6 +349,8 @@ definerule("simplerule", globals = { asstring = asstring, + concatpath = concatpath, + cwd = cwd, definerule = definerule, emit = emit, environment = environment, diff --git a/first/build.lua b/first/build.lua index ded146587..2b3afb974 100644 --- a/first/build.lua +++ b/first/build.lua @@ -1,7 +1,32 @@ -simplerule { +definerule("normalrule", + { + ins = { type="targets" }, + outleaves = { type="strings" }, + label = { type="string", optional=true }, + commands = { type="strings" }, + }, + function (e) + local objpath = "$(OBJDIR)/"..e.name + local realouts = {} + for k, v in pairs(e.outleaves) do + realouts[k] = concatpath(objpath, v) + end + + return simplerule { + name = e.name, + ins = e.ins, + outs = realouts, + label = e.label, + commands = e.commands, + } + end +) + + +normalrule { name = "random", ins = {}, - outs = {"out"}, + outleaves = {"out"}, commands = { "dd if=/dev/random of=%{outs} bs=1024 count=1" } From f4449e3f97096ac92fe2407d981d76bc6abdf1c8 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 7 Jun 2016 04:20:08 +0200 Subject: [PATCH 138/231] Multioutput rules work! --- first/ackbuilder.lua | 25 ++++++++++++++----------- first/build.lua | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index d708105f1..3a85c1e2c 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -204,18 +204,21 @@ local typeconverters = { local o = {} for _, s in ipairs(i) do - if (type(s) ~= "string") then - error(string.format("member of target list '%s' is not a string", propname)) + if (type(s) == "table") and s.is then + o[#o+1] = s + elseif (type(s) == "string") then + if s:find("^//") then + s = s:gsub("^//", "") + elseif s:find("^:") then + s = cwd..s + elseif s:find("^[^/]") then + s = concatpath(cwd, s) + end + o[#o+1] = loadtarget(s) + else + error(string.format("member of target list '%s' is not a string or a target", + propname)) end - - if s:find("^//") then - s = s:gsub("^//", "") - elseif s:find("^:") then - s = cwd..s - elseif s:find("^[^/]") then - s = concatpath(cwd, s) - end - o[#o+1] = loadtarget(s) end return o end, diff --git a/first/build.lua b/first/build.lua index 2b3afb974..2ab1b3cc4 100644 --- a/first/build.lua +++ b/first/build.lua @@ -32,6 +32,25 @@ normalrule { } } +normalrule { + name = "onetwo", + ins = {}, + outleaves = {"one.txt", "two.txt"}, + commands = { + "echo 1 >> %{outs[1]}", + "echo 2 >> %{outs[2]}", + } +} + +normalrule { + name = "concat", + ins = {":onetwo"}, + outleaves = {"result.txt"}, + commands = { + "cat %{ins} > %{outs}" + } +} + simplerule { name = "sorted", ins = { ":random" }, From 8082ef16a7d2bb95dff620469817560bd422d63c Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 7 Jun 2016 05:00:26 +0200 Subject: [PATCH 139/231] cfile with dynamically generated headers sort of works. --- first/ackbuilder.lua | 90 +++++++++++++++++++++++++++++++------- first/build.lua | 101 ++++++++++++++++++++++--------------------- 2 files changed, 125 insertions(+), 66 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 3a85c1e2c..72b4392a3 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -53,6 +53,25 @@ local function concatpath(...) return p:gsub("/+", "/"):gsub("^%./", "") end +local function basename(filename) + local _, _, b = filename:find("^.*/([^/]*)$") + if not b then + return "" + end + return b +end + +local function basenames(collection) + local o = {} + for _, s in pairs(collection) do + local b = basename(s) + if (b ~= "") then + o[#o+1] = b + end + end + return o +end + local function dirname(filename) local _, _, b = filename:find("^(.*)/[^/]*$") if not b then @@ -74,13 +93,15 @@ end local function filenamesof(results) local f = {} - for _, r in pairs(results) do - if (type(r) == "string") then - f[#f+1] = r - elseif (type(r) == "table") then - if r.is and r.outs then - for _, o in pairs(r.outs) do - f[#f+1] = o + if results then + for _, r in pairs(results) do + if (type(r) == "string") then + f[#f+1] = r + elseif (type(r) == "table") then + if r.is and r.outs then + for _, o in pairs(r.outs) do + f[#f+1] = o + end end end end @@ -88,6 +109,27 @@ local function filenamesof(results) return f end +local function selectof(pattern, targets) + local o = {} + for k, v in pairs(targets) do + if v.is and v.outs then + local targetmatches = nil + for _, f in pairs(v.outs) do + local matches = not not f:find(pattern) + if (targetmatches == nil) then + targetmatches = matches + elseif (targetmatches ~= matches) then + error("selectof() is matching only part of a target") + end + end + if targetmatches then + o[#o+1] = v + end + end + end + return o +end + local function uniquify(collection) local s = {} local o = {} @@ -238,6 +280,13 @@ local typeconverters = { end return i end, + + table = function(propname, i) + if (type(i) ~= "table") then + error(string.format("property '%s' must be a table", propname)) + end + return i + end, } local function definerule(rulename, types, cb) @@ -258,7 +307,7 @@ local function definerule(rulename, types, cb) local args = {} for propname, typespec in pairs(types) do if not e[propname] then - if not typespec.optional then + if not typespec.optional and not typespec.default then error(string.format("missing mandatory property '%s'", propname)) end @@ -325,19 +374,22 @@ definerule("simplerule", outs = { type="strings" }, label = { type="string", optional=true }, commands = { type="strings" }, + vars = { type="table", default={} }, }, function (e) e.environment:rule(filenamesof(e.ins), e.outs) e.environment:label(cwd..":"..e.name, " ", e.label or "") e.environment:mkdirs(dirnames(filenamesof(e.outs))) - e.environment:exec( - templateexpand(e.commands, - { - ins = e.ins, - outs = e.outs - } - ) - ) + + local vars = { + ins = e.ins, + outs = e.outs + } + for k, v in pairs(e.vars) do + vars[k] = v + end + + e.environment:exec(templateexpand(e.commands, vars)) e.environment:endrule() return { @@ -352,11 +404,17 @@ definerule("simplerule", globals = { asstring = asstring, + basename = basename, + basenames = basenames, concatpath = concatpath, cwd = cwd, definerule = definerule, + dirname = dirname, + dirnames = dirnames, emit = emit, environment = environment, + filenamesof = filenamesof, + selectof = selectof, } setmetatable(globals, { diff --git a/first/build.lua b/first/build.lua index 2ab1b3cc4..03077a414 100644 --- a/first/build.lua +++ b/first/build.lua @@ -4,6 +4,7 @@ definerule("normalrule", outleaves = { type="strings" }, label = { type="string", optional=true }, commands = { type="strings" }, + vars = { type="table", default={} }, }, function (e) local objpath = "$(OBJDIR)/"..e.name @@ -12,76 +13,76 @@ definerule("normalrule", realouts[k] = concatpath(objpath, v) end - return simplerule { + local result = simplerule { name = e.name, ins = e.ins, outs = realouts, label = e.label, commands = e.commands, + vars = e.vars, + } + result.dir = objpath + return result + end +) + +definerule("cfile", + { + srcs = { type="targets" }, + hdrs = { type="targets", default={} }, + commands = { + type="strings", + default={ + "$CC -c -o %{outs[1]} %{ins[1]} %{hdrpaths}" + }, + } + }, + function (e) + if (#e.srcs ~= 1) then + error("you must have exactly one .c file") + end + + hdrpaths = {} + for _, t in pairs(e.hdrs) do + hdrpaths[#hdrpaths+1] = "-I"..t.dir + end + + local outleaf = basename(filenamesof(e.srcs)[1]):gsub("%.c$", ".o") + + return normalrule { + name = e.name, + ins = {e.srcs[1], unpack(e.hdrs)}, + outleaves = {outleaf}, + label = e.label, + commands = e.commands, + vars = { + hdrpaths = hdrpaths + } } end ) - normalrule { - name = "random", + name = "mkheader", ins = {}, - outleaves = {"out"}, + outleaves = {"foo.h"}, commands = { - "dd if=/dev/random of=%{outs} bs=1024 count=1" + "echo 1 >> %{outs}" } } -normalrule { - name = "onetwo", - ins = {}, - outleaves = {"one.txt", "two.txt"}, - commands = { - "echo 1 >> %{outs[1]}", - "echo 2 >> %{outs[2]}", - } +cfile { + name = "testfile-foo", + srcs = "foo.c", } -normalrule { - name = "concat", - ins = {":onetwo"}, - outleaves = {"result.txt"}, - commands = { - "cat %{ins} > %{outs}" - } -} - -simplerule { - name = "sorted", - ins = { ":random" }, - outs = { "sorted" }, - commands = { - "sort %{ins} > %{outs}" - } +cfile { + name = "testfile-bar", + srcs = "bar.c", + hdrs = ":mkheader", } --[[ -function environment:cfileflags() - emit("$CFLAGS") -end - -function environment:cfile(srcs, obj, includes) - emit("$CC -o", obj, srcs) - emit(ab.expand(includes, "-I%")) - self:cflags() - emit("\n") -end - -function environment:clinkflags() - emit("$LDFLAGS") -end - -function environment:clink(objs, exe, libraryFlags) - emit("$CC -o", exe, objs, libraryFlags) - self:clinkflags() - emit("\n") -end - -- -- Targets: -- From fcc5a878ae391b595578a77ac259a3d33898cea0 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 8 Jun 2016 03:21:53 +0200 Subject: [PATCH 140/231] Rather cleaner cfile implementation where you just give it a .c and a pile of .h files. --- first/ackbuilder.lua | 37 ++++++++++++++++++++----------------- first/build.lua | 17 +++++++++-------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 72b4392a3..850e22875 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -91,38 +91,40 @@ local function dirnames(collection) return o end -local function filenamesof(results) +local function filenamesof(targets, pattern) local f = {} - if results then - for _, r in pairs(results) do - if (type(r) == "string") then - f[#f+1] = r - elseif (type(r) == "table") then - if r.is and r.outs then + if targets then + for _, r in pairs(targets) do + if (type(r) == "table") and r.is then + if r.outs then for _, o in pairs(r.outs) do - f[#f+1] = o + if not pattern or o:find(pattern) then + f[#f+1] = o + end end end + else + error("list of targets contains something which isn't a target") end end end return f end -local function selectof(pattern, targets) +-- Selects all targets containing at least one output file that matches +-- the pattern. +local function selectof(targets, pattern) local o = {} for k, v in pairs(targets) do if v.is and v.outs then - local targetmatches = nil + local matches = false for _, f in pairs(v.outs) do - local matches = not not f:find(pattern) - if (targetmatches == nil) then - targetmatches = matches - elseif (targetmatches ~= matches) then - error("selectof() is matching only part of a target") + if f:find(pattern) then + matches = true + break end end - if targetmatches then + if matches then o[#o+1] = v end end @@ -379,7 +381,7 @@ definerule("simplerule", function (e) e.environment:rule(filenamesof(e.ins), e.outs) e.environment:label(cwd..":"..e.name, " ", e.label or "") - e.environment:mkdirs(dirnames(filenamesof(e.outs))) + e.environment:mkdirs(dirnames(e.outs)) local vars = { ins = e.ins, @@ -415,6 +417,7 @@ globals = { environment = environment, filenamesof = filenamesof, selectof = selectof, + uniquify = uniquify, } setmetatable(globals, { diff --git a/first/build.lua b/first/build.lua index 03077a414..95b6a64f6 100644 --- a/first/build.lua +++ b/first/build.lua @@ -29,7 +29,6 @@ definerule("normalrule", definerule("cfile", { srcs = { type="targets" }, - hdrs = { type="targets", default={} }, commands = { type="strings", default={ @@ -38,20 +37,23 @@ definerule("cfile", } }, function (e) - if (#e.srcs ~= 1) then + local csrcs = filenamesof(e.srcs, "%.c$") + if (#csrcs ~= 1) then error("you must have exactly one .c file") end - hdrpaths = {} - for _, t in pairs(e.hdrs) do + local htargets = selectof(e.srcs, "%.h$") + local hdrpaths = {} + for _, t in pairs(htargets) do hdrpaths[#hdrpaths+1] = "-I"..t.dir end + hdrpaths = uniquify(hdrpaths) - local outleaf = basename(filenamesof(e.srcs)[1]):gsub("%.c$", ".o") + local outleaf = basename(csrcs[1]):gsub("%.c$", ".o") return normalrule { name = e.name, - ins = {e.srcs[1], unpack(e.hdrs)}, + ins = {csrcs[1], unpack(htargets)}, outleaves = {outleaf}, label = e.label, commands = e.commands, @@ -78,8 +80,7 @@ cfile { cfile { name = "testfile-bar", - srcs = "bar.c", - hdrs = ":mkheader", + srcs = {"bar.c", ":mkheader"}, } --[[ From f47bb49c1f292fbee75f09f0d0e9f64127feedb9 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 9 Jun 2016 06:55:44 +0200 Subject: [PATCH 141/231] Multiple build files work. Use deps intelligently. clibraries. --- first/ackbuilder.lua | 55 +++++++++++++-------- first/build.lua | 112 +++++++++++++++++++++++++++++++++++-------- modules/build.lua | 5 ++ 3 files changed, 131 insertions(+), 41 deletions(-) create mode 100644 modules/build.lua diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 850e22875..33806b3be 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -15,14 +15,18 @@ local buildfiles = {} local globals local cwd = "." -local function subenv(old, cb) - if not old then - old = environment - end - local new = {} - setmetatable(new, {__index = old}) - cb(new, old) - return new +local function inherit(high, low) + local o = {} + setmetatable(o, { + __index = function(self, k) + local x = high[k] + if x then + return x + end + return low[k] + end + }) + return o end local function asstring(o) @@ -50,7 +54,7 @@ end local function concatpath(...) local p = table.concat({...}, "/") - return p:gsub("/+", "/"):gsub("^%./", "") + return p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/") end local function basename(filename) @@ -144,6 +148,10 @@ local function uniquify(collection) return o end +local function startswith(needle, haystack) + return haystack:sub(1, #needle) == needle +end + local function emit(...) local n = select("#", ...) local args = {...} @@ -158,7 +166,7 @@ local function emit(...) end local function templateexpand(list, vars) - setmetatable(vars, { __index = globals }) + vars = inherit(vars, globals) local o = {} for _, s in ipairs(list) do @@ -210,8 +218,18 @@ local function loadtarget(targetname) local target if not targetname:find(":") then + local files + if targetname:find("[?*]") then + files = posix.glob(targetname) + if not files then + error(string.format("glob '%s' matches no files", targetname)) + end + else + files = {targetname} + end + target = { - outs = {targetname}, + outs = files, is = { __implicitfile = true } @@ -251,11 +269,9 @@ local typeconverters = { if (type(s) == "table") and s.is then o[#o+1] = s elseif (type(s) == "string") then - if s:find("^//") then - s = s:gsub("^//", "") - elseif s:find("^:") then + if s:find("^:") then s = cwd..s - elseif s:find("^[^/]") then + elseif s:find("^%./") then s = concatpath(cwd, s) end o[#o+1] = loadtarget(s) @@ -383,13 +399,10 @@ definerule("simplerule", e.environment:label(cwd..":"..e.name, " ", e.label or "") e.environment:mkdirs(dirnames(e.outs)) - local vars = { + local vars = inherit(e.vars, { ins = e.ins, outs = e.outs - } - for k, v in pairs(e.vars) do - vars[k] = v - end + }) e.environment:exec(templateexpand(e.commands, vars)) e.environment:endrule() @@ -416,7 +429,9 @@ globals = { emit = emit, environment = environment, filenamesof = filenamesof, + inherit = inherit, selectof = selectof, + startswith = startswith, uniquify = uniquify, } setmetatable(globals, diff --git a/first/build.lua b/first/build.lua index 95b6a64f6..6dc0e49cf 100644 --- a/first/build.lua +++ b/first/build.lua @@ -13,13 +13,17 @@ definerule("normalrule", realouts[k] = concatpath(objpath, v) end + local vars = inherit(e.vars, { + dir = objpath + }) + local result = simplerule { name = e.name, ins = e.ins, outs = realouts, label = e.label, commands = e.commands, - vars = e.vars, + vars = vars, } result.dir = objpath return result @@ -29,10 +33,11 @@ definerule("normalrule", definerule("cfile", { srcs = { type="targets" }, + deps = { type="targets", default={} }, commands = { type="strings", default={ - "$CC -c -o %{outs[1]} %{ins[1]} %{hdrpaths}" + "$(CC) -c -o %{outs[1]} %{ins[1]} %{hdrpaths}" }, } }, @@ -42,18 +47,23 @@ definerule("cfile", error("you must have exactly one .c file") end - local htargets = selectof(e.srcs, "%.h$") + local hsrcs = filenamesof(e.srcs, "%.h$") + local hdeps = selectof(e.deps, "%.h$") local hdrpaths = {} - for _, t in pairs(htargets) do + for _, t in pairs(hdeps) do hdrpaths[#hdrpaths+1] = "-I"..t.dir end hdrpaths = uniquify(hdrpaths) + for _, f in pairs(filenamesof(hdeps)) do + hsrcs[#hsrcs+1] = f + end + local outleaf = basename(csrcs[1]):gsub("%.c$", ".o") return normalrule { name = e.name, - ins = {csrcs[1], unpack(htargets)}, + ins = {csrcs[1], unpack(hsrcs)}, outleaves = {outleaf}, label = e.label, commands = e.commands, @@ -64,25 +74,85 @@ definerule("cfile", end ) -normalrule { - name = "mkheader", - ins = {}, - outleaves = {"foo.h"}, - commands = { - "echo 1 >> %{outs}" +definerule("bundle", + { + srcs = { type="targets" }, + commands = { + type="strings", + default={ + "tar cf - %{ins} | (cd %{dir} && tar xf -)" + } + } + }, + function (e) + local outleaves = {} + local commands = {} + for _, f in pairs(filenamesof(e.srcs)) do + local localf = basename(f) + outleaves[#outleaves+1] = localf + commands[#commands+1] = "cp "..f.." %{dir}/"..localf + end + + return normalrule { + name = e.name, + ins = e.srcs, + outleaves = outleaves, + label = e.label, + commands = commands + } + end +) + +definerule("clibrary", + { + srcs = { type="targets" }, + deps = { type="targets", default={} }, + commands = { + type="strings", + default={ + "rm -f %{outs}", + "$(AR) qs %{outs} %{ins}" + }, + } + }, + function (e) + local csrcs = filenamesof(e.srcs, "%.c$") + if (#csrcs < 1) then + error("you must supply at least one C source file") + end + + local hsrcs = filenamesof(e.srcs, "%.h$") + + local ins = {} + for _, csrc in pairs(csrcs) do + local n = basename(csrc):gsub("%.%w*$", "") + ins[#ins+1] = cfile { + name = e.name.."/"..n, + srcs = {csrc, unpack(hsrcs)}, + deps = e.deps, + } + end + + return normalrule { + name = e.name, + ins = ins, + outleaves = { e.name..".a" }, + label = e.label, + commands = e.commands + } + end +) + +clibrary { + name = "mylib", + srcs = { + "modules/src/string/*.c", + }, + deps = { + "modules:headers" } } -cfile { - name = "testfile-foo", - srcs = "foo.c", -} - -cfile { - name = "testfile-bar", - srcs = {"bar.c", ":mkheader"}, -} - --[[ -- -- Targets: diff --git a/modules/build.lua b/modules/build.lua new file mode 100644 index 000000000..4297f59d0 --- /dev/null +++ b/modules/build.lua @@ -0,0 +1,5 @@ +bundle { + name = "headers", + srcs = { "./h/*.h" } +} + From 015804afcef85e8cfeddceb24c074ef06dbdb0ef Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 9 Jun 2016 07:14:41 +0200 Subject: [PATCH 142/231] cprogram works. --- first/ackbuilder.lua | 5 +- first/build.lua | 306 ++++++------------------------------------- modules/build.lua | 6 + 3 files changed, 50 insertions(+), 267 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 33806b3be..866412848 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -60,7 +60,7 @@ end local function basename(filename) local _, _, b = filename:find("^.*/([^/]*)$") if not b then - return "" + return filename end return b end @@ -108,7 +108,8 @@ local function filenamesof(targets, pattern) end end else - error("list of targets contains something which isn't a target") + error(string.format("list of targets contains a %s which isn't a target", + type(r))) end end end diff --git a/first/build.lua b/first/build.lua index 6dc0e49cf..47faa7f56 100644 --- a/first/build.lua +++ b/first/build.lua @@ -143,274 +143,50 @@ definerule("clibrary", end ) -clibrary { - name = "mylib", +definerule("cprogram", + { + srcs = { type="targets", default={} }, + deps = { type="targets", default={} }, + commands = { + type="strings", + default={ + "$(CC) -o %{outs[1]} %{ins}" + }, + } + }, + function (e) + local libs = filenamesof(e.deps, "%.a$") + if (#e.srcs > 0) then + for _, f in pairs(filenamesof( + { + clibrary { + name = e.name .. "/main", + srcs = e.srcs, + deps = e.deps + } + }, + "%.a$" + )) do + libs[#libs+1] = f + end + end + + return normalrule { + name = e.name, + ins = libs, + outleaves = { e.name }, + commands = e.commands, + } + end +) + +cprogram { + name = "test", srcs = { - "modules/src/string/*.c", + "foo.c", }, deps = { - "modules:headers" + "modules:string" } } ---[[ --- --- Targets: --- --- { --- dir = target's build directory --- outs = target's object files --- is = { set of rule types which made the target } --- } -function M.subenv(p) - local e = p[1] - setmetable(p, {__index = e}) - return p -end - -local function check_filename(fn) - if type(fn) == "table" then - for _, f in ipairs(fn) do - check_filename(f) - end - else - if fn:find("%s") then - error("Filename '"+fn+"' contains spaces. This will make the build system sad.") - end - end -end - -function M.basename(fn) - if type(fn) == "table" then - local nfn = {} - for _, f in ipairs(fn) do - nfn[#nfn+1] = M.basename(f) - end - return nfn - else - local _, _, base = fn:find("([^/]*)$") - return base - end -end - -function M.flatten(t) - if t == nil then - return {} - end - - local tt = {} - for _, subt in ipairs(t) do - if type(subt) == "table" then - for _, subt in ipairs(M.flatten(subt)) do - tt[#tt+1] = subt - end - else - tt[#tt+1] = subt - end - end - return tt -end - -local function append(...) - local ts = {} - for _, t in ipairs({...}) do - for _, v in ipairs(t) do - ts[#ts+1] = v - end - end - return ts -end - -local function settotable(s) - local t = {} - for k in pairs(s) do - t[#t+1] = k - end - return t -end - -local function asstring(t) - return table.concat(M.flatten(t), " ") -end - -local function emit(...) - for _, s in ipairs({...}) do - io.stdout:write(s) - end -end - -function M.rawtarget(p) - local description = p.description or error("no description supplied") - local ins = M.flatten(p.ins) - local outs = M.flatten(p.outs) - - local cmd = p.command - if type(cmd) ~= "table" then - cmd = {cmd} - end - - for _, s in ipairs(ins) do - check_filename(s) - end - for _, s in ipairs(outs) do - check_filename(s) - end - - emit(outs[1], ":") - for _, s in ipairs(ins) do - emit(" ", s) - end - emit("\n") - - emit("\t@echo ", p.description, "\n") - - emit("\t$(hide) ", table.concat(cmd, " && "), "\n") - - for i = 2, #outs do - emit(outs[i], ": ", outs[1], "\n") - end - - emit("\n") -end - -function M.export(p) - local e = p[1] - local dest = p.dest or error("no export destination provided") - local deps = p.deps or error("nothing to export") - - local fdeps = M.flatten(deps) - - if #fdeps ~= 1 then - error("you can only export one thing at a time") - end - - return M.rawtarget {e, - ins=deps, - outs={dest}, - command="cp "..fdeps[1].." "..dest, - description="EXPORT "..dest - } -end - -function M.hermetic(p) - local e = p[1] - local ins = M.flatten(p.ins) - local deps = M.flatten(p.deps) - local baseouts = p.baseouts or error("you must specify some baseouts") - local description = p.description - - local absouts = {} - local path = e.PATH .. "/" .. p.baseouts[1] .. ".env" - - for _, s in ipairs(M.flatten(p.baseouts)) do - absouts[#absouts+1] = path .. "/" .. s - end - - local dirset = {} - for _, s in ipairs(absouts) do - local d = s:gsub("^(.*/).*$", "%1") - if d then - dirset[d] = true - end - end - - local newcmd = { - "rm -rf "..path, - "mkdir -p "..asstring(settotable(dirset)), - "ln -srf "..asstring(append(ins, deps)).." "..path, - "cd "..path - } - for _, s in ipairs(p.command) do - newcmd[#newcmd+1] = "(" .. s .. ")" - end - - M.rawtarget {e, - ins={ins, unpack(deps)}, - outs=absouts, - command=newcmd, - description=description - } - - return absouts -end - -function M.cfile(p) - local e = p[1] - local src = p.src - local deps = p.deps or {} - - local outfile = p.src:gsub("%.c$", ".o") - local basesrc = M.basename(p.src) - - return M.hermetic {e, - ins={src}, - deps=deps, - baseouts={outfile}, - command={e.CC.." "..e.CFLAGS.." -c -o "..outfile.." "..basesrc}, - description="CC "..src - } -end - -function M.cprogram(p) - local e = p[1] - local name = p.name or error("cprogram must have a name specified") - local deps = p.deps or {} - local libs = p.libraries or {} - local headers = p.headers or {} - - if p.srcs then - local mainlib = M.clibrary {e, - name=name..".a", - deps=deps, - srcs=p.srcs, - headers=headers - } - - deps = append(deps, {mainlib}) - end - - local libflags = {} - for _, s in ipairs(libs) do - libflags[#libflags+1] = "-l"..s - end - - return M.hermetic {e, - ins=deps, - baseouts={name}, - command={e.CC.." "..e.CFLAGS.." -o "..name.." "..asstring(M.basename(deps)).." "..asstring(libflags)}, - description="CLINK "..name - } -end - -function M.clibrary(p) - local e = p[1] - local name = p.name or error("clibrary must have a name specified") - local deps = M.flatten(p.deps) - local srcs = M.flatten(p.srcs) - local headers = M.flatten(p.headers) - - local baseouts = {name} - - local objs = deps - for _, f in ipairs(srcs) do - objs[#objs+1] = M.cfile {e, - src=f, - deps=headers - } - end - - return M.hermetic {e, - ins=append(objs, headers), - baseouts=baseouts, - command={ - e.AR.." q "..name.." "..asstring(M.basename(objs)), - e.RANLIB.." "..name, - }, - description="CLIBRARY "..name - } -end - -emit("hide = @\n") - -return M ---]] diff --git a/modules/build.lua b/modules/build.lua index 4297f59d0..4ad93bbea 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -3,3 +3,9 @@ bundle { srcs = { "./h/*.h" } } +clibrary { + name = "string", + srcs = { "./src/string/*.c" }, + deps = { ":headers" }, +} + From a04dbf33f330e656ff3a2c5e50c0780539768207 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 12 Jun 2016 20:59:16 +0200 Subject: [PATCH 143/231] Add hgignore file. --- .hgignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .hgignore diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..231210b94 --- /dev/null +++ b/.hgignore @@ -0,0 +1,3 @@ +.obj +.sass-cache +_site From 605651776e94c4a09ac2f35aa51d92f4cfdfff02 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 12 Jun 2016 20:59:43 +0200 Subject: [PATCH 144/231] We can build a real program now! --- first/ackbuilder.lua | 119 +++++++++++++++++++++++++++---------------- first/build.lua | 38 +++++++------- h/build.lua | 31 +++++++++++ util/ack/build.lua | 89 ++++++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+), 62 deletions(-) create mode 100644 h/build.lua create mode 100644 util/ack/build.lua diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 866412848..525e6051c 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -57,44 +57,6 @@ local function concatpath(...) return p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/") end -local function basename(filename) - local _, _, b = filename:find("^.*/([^/]*)$") - if not b then - return filename - end - return b -end - -local function basenames(collection) - local o = {} - for _, s in pairs(collection) do - local b = basename(s) - if (b ~= "") then - o[#o+1] = b - end - end - return o -end - -local function dirname(filename) - local _, _, b = filename:find("^(.*)/[^/]*$") - if not b then - return "" - end - return b -end - -local function dirnames(collection) - local o = {} - for _, s in pairs(collection) do - local b = dirname(s) - if (b ~= "") then - o[#o+1] = b - end - end - return o -end - local function filenamesof(targets, pattern) local f = {} if targets then @@ -107,6 +69,8 @@ local function filenamesof(targets, pattern) end end end + elseif (type(r) == "string") then + f[#f+1] = r else error(string.format("list of targets contains a %s which isn't a target", type(r))) @@ -116,8 +80,75 @@ local function filenamesof(targets, pattern) return f end +local function dotocollection(collection, callback) + if (type(collection) == "string") then + return callback(collection) + elseif collection.is then + local files = filenamesof(collection.outs) + if (#files ~= 1) then + error("inputs with more than one output need to be in a list") + end + return callback(files[1]) + end + + local o = {} + for _, s in pairs(collection) do + if s.is then + for _, b in pairs(dotocollection(filenamesof(s), callback)) do + o[#o+1] = b + end + else + local b = callback(s) + if (b ~= "") then + o[#o+1] = b + end + end + end + return o +end + +local function abspath(collection) + return dotocollection(collection, + function(filename) + return concatpath(posix.getcwd(), filename) + end + ) +end + +local function basename(collection) + return dotocollection(collection, + function(filename) + local _, _, b = filename:find("^.*/([^/]*)$") + if not b then + return filename + end + return b + end + ) +end + +local function dirname(collection) + return dotocollection(collection, + function(filename) + local _, _, b = filename:find("^(.*)/[^/]*$") + if not b then + return "" + end + return b + end + ) +end + +local function fpairs(collection) + if (type(collection) == "string") or collection.is then + return tpairs({collection}) + end + + return pairs(filenamesof(collection)) +end + -- Selects all targets containing at least one output file that matches --- the pattern. +-- the pattern (or all, if the pattern is nil). local function selectof(targets, pattern) local o = {} for k, v in pairs(targets) do @@ -237,7 +268,7 @@ local function loadtarget(targetname) } targets[targetname] = target else - local _, _, filepart, targetpart = targetname:find("^([^:]*):(%w+)$") + local _, _, filepart, targetpart = targetname:find("^([^:]*):([%w-_]+)$") if not filepart or not targetpart then error(string.format("malformed target name '%s'", targetname)) end @@ -398,7 +429,7 @@ definerule("simplerule", function (e) e.environment:rule(filenamesof(e.ins), e.outs) e.environment:label(cwd..":"..e.name, " ", e.label or "") - e.environment:mkdirs(dirnames(e.outs)) + e.environment:mkdirs(dirname(e.outs)) local vars = inherit(e.vars, { ins = e.ins, @@ -419,20 +450,20 @@ definerule("simplerule", ----------------------------------------------------------------------------- globals = { + abspath = abspath, asstring = asstring, basename = basename, - basenames = basenames, concatpath = concatpath, - cwd = cwd, + cwd = function() return cwd end, definerule = definerule, dirname = dirname, - dirnames = dirnames, emit = emit, environment = environment, filenamesof = filenamesof, inherit = inherit, selectof = selectof, startswith = startswith, + fpairs = fpairs, uniquify = uniquify, } setmetatable(globals, diff --git a/first/build.lua b/first/build.lua index 47faa7f56..35821b484 100644 --- a/first/build.lua +++ b/first/build.lua @@ -1,20 +1,25 @@ +local function objdir(e) + return concatpath("$(OBJDIR)", cwd(), e.name) +end + definerule("normalrule", { ins = { type="targets" }, outleaves = { type="strings" }, label = { type="string", optional=true }, + objdir = { type="string", optional=true }, commands = { type="strings" }, vars = { type="table", default={} }, }, function (e) - local objpath = "$(OBJDIR)/"..e.name + local dir = e.objdir or objdir(e) local realouts = {} for k, v in pairs(e.outleaves) do - realouts[k] = concatpath(objpath, v) + realouts[k] = concatpath(dir, v) end local vars = inherit(e.vars, { - dir = objpath + dir = dir }) local result = simplerule { @@ -25,7 +30,7 @@ definerule("normalrule", commands = e.commands, vars = vars, } - result.dir = objpath + result.dir = dir return result end ) @@ -34,10 +39,11 @@ definerule("cfile", { srcs = { type="targets" }, deps = { type="targets", default={} }, + cflags = { type="strings", default={} }, commands = { type="strings", default={ - "$(CC) -c -o %{outs[1]} %{ins[1]} %{hdrpaths}" + "$(CC) -c -o %{outs[1]} %{ins[1]} %{hdrpaths} %{cflags}" }, } }, @@ -68,7 +74,8 @@ definerule("cfile", label = e.label, commands = e.commands, vars = { - hdrpaths = hdrpaths + hdrpaths = hdrpaths, + cflags = e.cflags, } } end @@ -87,7 +94,7 @@ definerule("bundle", function (e) local outleaves = {} local commands = {} - for _, f in pairs(filenamesof(e.srcs)) do + for _, f in fpairs(e.srcs) do local localf = basename(f) outleaves[#outleaves+1] = localf commands[#commands+1] = "cp "..f.." %{dir}/"..localf @@ -107,6 +114,7 @@ definerule("clibrary", { srcs = { type="targets" }, deps = { type="targets", default={} }, + cflags = { type="strings", default={} }, commands = { type="strings", default={ @@ -124,12 +132,16 @@ definerule("clibrary", local hsrcs = filenamesof(e.srcs, "%.h$") local ins = {} - for _, csrc in pairs(csrcs) do + for _, csrc in fpairs(csrcs) do local n = basename(csrc):gsub("%.%w*$", "") ins[#ins+1] = cfile { name = e.name.."/"..n, srcs = {csrc, unpack(hsrcs)}, deps = e.deps, + cflags = { + "-I"..cwd(), + unpack(e.cflags) + }, } end @@ -180,13 +192,3 @@ definerule("cprogram", end ) -cprogram { - name = "test", - srcs = { - "foo.c", - }, - deps = { - "modules:string" - } -} - diff --git a/h/build.lua b/h/build.lua new file mode 100644 index 000000000..25b7e3324 --- /dev/null +++ b/h/build.lua @@ -0,0 +1,31 @@ +normalrule { + name = "em_path", + ins = {}, + outleaves = { "em_path.h" }, + commands = { + "echo '#define TMP_DIR \"$(ACK_TEMP_DIR)\"' > %{outs}", + "echo '#define EM_DIR \"$(PREFIX)\"' >> %{outs}", + "echo '#define ACK_PATH \"share/ack/descr\"' >> %{outs}", + } +} + +bundle { + name = "emheaders", + srcs = { + "./em_*.h", + ":em_path", + } +} + +normalrule { + name = "local", + ins = {}, + outleaves = { "local.h" }, + commands = { + "echo '#define VERSION 3' > %{outs}", + "echo '#define ACKM \"$(DEFAULT_PLATFORM)\"' >> %{outs}", + "echo '#define BIGMACHINE 1' >> %{outs}", + "echo '#define SYS_5' >> %{outs}", + } +} + diff --git a/util/ack/build.lua b/util/ack/build.lua new file mode 100644 index 000000000..3e1b77167 --- /dev/null +++ b/util/ack/build.lua @@ -0,0 +1,89 @@ +cprogram { + name = "mktables", + srcs = { "./mktables.c" }, +} + +normalrule { + name = "tables", + outleaves = { "dmach.c", "intable.c" }, + ins = { + ":mktables", + "lib/descr/fe", + }, + commands = { + "(cd %{dir} && %{abspath(ins[1])} lib)" + } +} + +cprogram { + name = "ack", + srcs = { + "./*.c", + "./*.h", + ":tables", + }, + deps = { + "h:emheaders", + "h:local", + } +} + +--[[ +D := util/ack + +define util-ack-makeheaders-rule +$(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) +$(wordlist 2, $(words $g), $g): $(firstword $g) +$(firstword $g): $(util-ack-mktables) + @echo MKTABLES + @mkdir -p $(OBJDIR)/$D + $(hide) cd $(OBJDIR)/$D && $(util-ack-mktables) $(INSDIR)/share + +$(eval CLEANABLES += $g) +endef + +define build-ack-impl + $(call reset) + $(call cfile, $D/mktables.c) + $(call cprogram, $(OBJDIR)/$D/mktables) + $(eval util-ack-mktables := $o) + + $(call reset) + $(eval cflags += -I$D) + $(call cfile, $D/list.c) + $(call cfile, $D/data.c) + $(call cfile, $D/main.c) + $(call cfile, $D/scan.c) + $(call cfile, $D/svars.c) + $(call cfile, $D/trans.c) + $(call cfile, $D/util.c) + + $(call cfile, $D/rmach.c) + $(call dependson, $(INCDIR)/em_path.h) + + $(call cfile, $D/run.c) + $(call cfile, $D/grows.c) + + $(call cfile, $D/files.c) + $(call dependson, $(INCDIR)/em_path.h) + + $(eval $(util-ack-makeheaders-rule)) + $(call cfile, $(OBJDIR)/$D/dmach.c) + $(call cfile, $(OBJDIR)/$D/intable.c) + + $(call cprogram, $(BINDIR)/ack) + $(call installto, $(INSDIR)/bin/ack) + $(eval ACK := $o) + + $(call reset) + $(eval q := lib/descr/fe) + $(call installto, $(PLATIND)/descr/fe) + $(eval $(ACK): $o) + + $(call reset) + $(eval q := $D/ack.1.X) + $(call installto, $(INSDIR)/share/man/man1/ack.1) +endef + +$(eval $(build-ack-impl)) +--]] From 09554cb324b979b5c539097a1ee349677cd9a838 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 14 Jun 2016 07:34:14 +0200 Subject: [PATCH 145/231] installable works, although it's a bit kludgy. Change the : separator to + because : is special in make and non of the others I could think of would work. --- build.lua | 7 ++++ first/ackbuilder.lua | 79 ++++++++++++++++++++++++++++++++++++++------ h/build.lua | 2 +- modules/build.lua | 2 +- util/ack/build.lua | 17 +++++++--- 5 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 build.lua diff --git a/build.lua b/build.lua new file mode 100644 index 000000000..8c59429d0 --- /dev/null +++ b/build.lua @@ -0,0 +1,7 @@ +installable { + name = "ack", + map = { + "util/ack+ack-pkg" + } +} + diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 525e6051c..2d198974b 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -3,6 +3,7 @@ local posix = require("posix") -- Targets: -- -- { +-- fullname = full name of target -- dir = target's build directory -- outs = target's object files -- is = { set of rule types which made the target } @@ -60,6 +61,10 @@ end local function filenamesof(targets, pattern) local f = {} if targets then + if targets.is then + targets = {targets} + end + for _, r in pairs(targets) do if (type(r) == "table") and r.is then if r.outs then @@ -141,7 +146,7 @@ end local function fpairs(collection) if (type(collection) == "string") or collection.is then - return tpairs({collection}) + return fpairs({collection}) end return pairs(filenamesof(collection)) @@ -249,7 +254,7 @@ local function loadtarget(targetname) end local target - if not targetname:find(":") then + if not targetname:find("%+") then local files if targetname:find("[?*]") then files = posix.glob(targetname) @@ -268,7 +273,7 @@ local function loadtarget(targetname) } targets[targetname] = target else - local _, _, filepart, targetpart = targetname:find("^([^:]*):([%w-_]+)$") + local _, _, filepart, targetpart = targetname:find("^([^+]*)%+([%w-_]+)$") if not filepart or not targetpart then error(string.format("malformed target name '%s'", targetname)) end @@ -297,16 +302,16 @@ local typeconverters = { end local o = {} - for _, s in ipairs(i) do + for k, s in pairs(i) do if (type(s) == "table") and s.is then - o[#o+1] = s + o[k] = s elseif (type(s) == "string") then - if s:find("^:") then + if s:find("^%+") then s = cwd..s elseif s:find("^%./") then s = concatpath(cwd, s) end - o[#o+1] = loadtarget(s) + o[k] = loadtarget(s) else error(string.format("member of target list '%s' is not a string or a target", propname)) @@ -374,11 +379,13 @@ local function definerule(rulename, types, cb) end args.environment = environment + args.fullname = cwd.."+"..args.name local result = cb(args) or {} result.is = result.is or {} result.is[rulename] = true - targets[cwd..":"..args.name] = result + result.fullname = args.fullname + targets[result.fullname] = result return result end end @@ -398,6 +405,11 @@ function environment:rule(ins, outs) emit(firstout..":\n") end +function environment:phony(ins, outs) + emit(".PHONY:", outs, "\n") + self:rule(ins, outs) +end + function environment:label(...) local s = table.concat({...}, " ") emit("\t@echo", s, "\n") @@ -411,7 +423,9 @@ function environment:mkdirs(dirs) end function environment:exec(commands) - emit("\t$(hide)", table.concat(commands, " && "), "\n") + for _, s in ipairs(commands) do + emit("\t$(hide)", s, "\n") + end end function environment:endrule() @@ -428,7 +442,7 @@ definerule("simplerule", }, function (e) e.environment:rule(filenamesof(e.ins), e.outs) - e.environment:label(cwd..":"..e.name, " ", e.label or "") + e.environment:label(e.fullname, " ", e.label or "") e.environment:mkdirs(dirname(e.outs)) local vars = inherit(e.vars, { @@ -445,6 +459,51 @@ definerule("simplerule", end ) +definerule("installable", + { + map = { type="targets", default={} }, + }, + function (e) + local deps = {} + local commands = {} + local srcs = {} + local dests = {} + for dest, src in pairs(e.map) do + if src.is.installable then + if (type(dest) ~= "number") then + error("can't specify a destination filename when installing an installable") + end + deps[#deps+1] = src.fullname + elseif (type(dest) == "number") then + error("only references to other installables can be missing a destination") + else + local f = filenamesof(src) + if (#f ~= 1) then + error("installable can only cope with targets emitting single files") + end + + srcs[#srcs+1] = src + dests[#dests+1] = dest + commands[#commands+1] = "cp "..f[1].." "..dest + deps[#deps+1] = dest + end + end + + if (#dests > 0) then + e.environment:rule(srcs, dests) + e.environment:label(e.fullname, " ", e.label or "") + if (#commands > 0) then + e.environment:mkdirs(dirname(dests)) + e.environment:exec(commands) + end + e.environment:endrule() + end + + e.environment:phony(deps, {cwd.."+"..e.name}) + e.environment:endrule() + end +) + ----------------------------------------------------------------------------- -- MAIN PROGRAM -- ----------------------------------------------------------------------------- diff --git a/h/build.lua b/h/build.lua index 25b7e3324..aca6a8fd4 100644 --- a/h/build.lua +++ b/h/build.lua @@ -13,7 +13,7 @@ bundle { name = "emheaders", srcs = { "./em_*.h", - ":em_path", + "+em_path", } } diff --git a/modules/build.lua b/modules/build.lua index 4ad93bbea..e3fb471df 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -6,6 +6,6 @@ bundle { clibrary { name = "string", srcs = { "./src/string/*.c" }, - deps = { ":headers" }, + deps = { "#headers" }, } diff --git a/util/ack/build.lua b/util/ack/build.lua index 3e1b77167..f30eedf4a 100644 --- a/util/ack/build.lua +++ b/util/ack/build.lua @@ -7,7 +7,7 @@ normalrule { name = "tables", outleaves = { "dmach.c", "intable.c" }, ins = { - ":mktables", + "+mktables", "lib/descr/fe", }, commands = { @@ -20,11 +20,20 @@ cprogram { srcs = { "./*.c", "./*.h", - ":tables", + "+tables", }, deps = { - "h:emheaders", - "h:local", + "h+emheaders", + "h+local", + } +} + +installable { + name = "ack-pkg", + map = { + ["$(INSDIR)/bin/ack"] = "+ack", + ["$(INSDIR)/share/man/man1/ack.1"] = "./ack.1.X", + ["$(PLATIND)/descr/fe"] = "lib/descr/fe", } } From 2af8568cc3dfa545835492b08de2362cbb211b44 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 16 Jun 2016 05:26:44 +0200 Subject: [PATCH 146/231] First draft at installables; not very satisfactory. make bugs with multiple output targets and parallelism? --- build.lua | 3 ++- first/ackbuilder.lua | 52 ++++++++++++++++++-------------------------- first/build.lua | 2 +- h/build.lua | 1 + util/amisc/build.lua | 16 ++++++++++++++ 5 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 util/amisc/build.lua diff --git a/build.lua b/build.lua index 8c59429d0..45bd06717 100644 --- a/build.lua +++ b/build.lua @@ -1,7 +1,8 @@ installable { name = "ack", map = { - "util/ack+ack-pkg" + "util/ack+ack-pkg", + "util/amisc+aelflod-pkg", } } diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 2d198974b..e919a8d90 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -394,20 +394,25 @@ end -- DEFAULT RULES -- ----------------------------------------------------------------------------- -function environment:rule(ins, outs) - local firstout = outs[1] - for i = 2, #outs do - emit(outs[i]..":", outs[1], "\n") - end +function environment:rule(name, ins, outs) + emit(".INTERMEDIATE:", name, "\n") for i = 1, #ins do - emit(firstout..":", ins[i], "\n") + emit(name..":", ins[i], "\n") + end + for i = 1, #outs do + emit(outs[i]..":", name, "\n") + end + emit(name..":\n") + + local dirs = uniquify(dirname(outs)) + if (#dirs > 0) then + emit("\t@mkdir -p", dirs, "\n") end - emit(firstout..":\n") end -function environment:phony(ins, outs) - emit(".PHONY:", outs, "\n") - self:rule(ins, outs) +function environment:phony(name, ins, outs) + emit(".PHONY:", name, "\n") + self:rule(name, ins, outs) end function environment:label(...) @@ -415,13 +420,6 @@ function environment:label(...) emit("\t@echo", s, "\n") end -function environment:mkdirs(dirs) - dirs = uniquify(dirs) - if (#dirs > 0) then - emit("\t@mkdir -p", dirs, "\n") - end -end - function environment:exec(commands) for _, s in ipairs(commands) do emit("\t$(hide)", s, "\n") @@ -441,9 +439,8 @@ definerule("simplerule", vars = { type="table", default={} }, }, function (e) - e.environment:rule(filenamesof(e.ins), e.outs) + e.environment:rule(e.fullname, filenamesof(e.ins), e.outs) e.environment:label(e.fullname, " ", e.label or "") - e.environment:mkdirs(dirname(e.outs)) local vars = inherit(e.vars, { ins = e.ins, @@ -482,24 +479,17 @@ definerule("installable", error("installable can only cope with targets emitting single files") end - srcs[#srcs+1] = src + deps[#deps+1] = src dests[#dests+1] = dest commands[#commands+1] = "cp "..f[1].." "..dest - deps[#deps+1] = dest end end - if (#dests > 0) then - e.environment:rule(srcs, dests) - e.environment:label(e.fullname, " ", e.label or "") - if (#commands > 0) then - e.environment:mkdirs(dirname(dests)) - e.environment:exec(commands) - end - e.environment:endrule() + e.environment:rule(e.fullname, deps, dests) + e.environment:label(e.fullname, " ", e.label or "") + if (#commands > 0) then + e.environment:exec(commands) end - - e.environment:phony(deps, {cwd.."+"..e.name}) e.environment:endrule() end ) diff --git a/first/build.lua b/first/build.lua index 35821b484..354848704 100644 --- a/first/build.lua +++ b/first/build.lua @@ -119,7 +119,7 @@ definerule("clibrary", type="strings", default={ "rm -f %{outs}", - "$(AR) qs %{outs} %{ins}" + "$(AR) cqs %{outs} %{ins}" }, } }, diff --git a/h/build.lua b/h/build.lua index aca6a8fd4..2c9c3886a 100644 --- a/h/build.lua +++ b/h/build.lua @@ -13,6 +13,7 @@ bundle { name = "emheaders", srcs = { "./em_*.h", + "./out.h", "+em_path", } } diff --git a/util/amisc/build.lua b/util/amisc/build.lua new file mode 100644 index 000000000..9e9fad4cc --- /dev/null +++ b/util/amisc/build.lua @@ -0,0 +1,16 @@ +cprogram { + name = "aelflod", + srcs = { "./aelflod.c" }, + deps = { + "h+emheaders" + } +} + +installable { + name = "aelflod-pkg", + map = { + ["$(INSDIR)/bin/aelflod"] = "+aelflod", + ["$(PLATIND)/man/man1/aelflod.1"] = "./aelflod.1", + } +} + From 1978867fd280ed7d7b9a41f2523fbfc800026cca Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 Jun 2016 08:55:02 +0200 Subject: [PATCH 147/231] Add ninja support. It works so much better than make. --- first/ackbuilder.lua | 174 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 142 insertions(+), 32 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index e919a8d90..66f6f7027 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -394,40 +394,81 @@ end -- DEFAULT RULES -- ----------------------------------------------------------------------------- -function environment:rule(name, ins, outs) - emit(".INTERMEDIATE:", name, "\n") - for i = 1, #ins do - emit(name..":", ins[i], "\n") - end - for i = 1, #outs do - emit(outs[i]..":", name, "\n") - end - emit(name..":\n") +local function install_make_environment() + emit("hide = @\n") + function environment:rule(name, ins, outs) + emit(".INTERMEDIATE:", name, "\n") + for i = 1, #ins do + emit(name..":", ins[i], "\n") + end + for i = 1, #outs do + emit(outs[i]..":", name, "\n") + end + emit(name..":\n") - local dirs = uniquify(dirname(outs)) - if (#dirs > 0) then - emit("\t@mkdir -p", dirs, "\n") + local dirs = uniquify(dirname(outs)) + if (#dirs > 0) then + emit("\t@mkdir -p", dirs, "\n") + end + end + + function environment:phony(name, ins, outs) + emit(".PHONY:", name, "\n") + self:rule(name, ins, outs) + end + + function environment:label(...) + local s = table.concat({...}, " ") + emit("\t@echo", s, "\n") + end + + function environment:exec(commands) + for _, s in ipairs(commands) do + emit("\t$(hide)", s, "\n") + end + end + + function environment:endrule() + emit("\n") end end -function environment:phony(name, ins, outs) - emit(".PHONY:", name, "\n") - self:rule(name, ins, outs) -end - -function environment:label(...) - local s = table.concat({...}, " ") - emit("\t@echo", s, "\n") -end - -function environment:exec(commands) - for _, s in ipairs(commands) do - emit("\t$(hide)", s, "\n") - end -end - -function environment:endrule() +local function install_ninja_environment() + emit("rule build\n") + emit(" command = $command\n") emit("\n") + + local function unmake(collection) + return dotocollection(collection, + function(s) + return s:gsub("%$%b()", + function(expr) + return "${"..expr:sub(3, -2).."}" + end + ) + end + ) + end + + function environment:rule(name, ins, outs) + if (#outs == 0) then + emit("build", name, ": phony", unmake(ins), "\n") + else + emit("build", name, ": phony", unmake(outs), "\n") + emit("build", unmake(outs), ": build", unmake(ins), "\n") + end + end + + function environment:label(...) + end + + function environment:exec(commands) + emit(" command =", table.concat(unmake(commands), " && "), "\n") + end + + function environment:endrule() + emit("\n") + end end definerule("simplerule", @@ -498,6 +539,51 @@ definerule("installable", -- MAIN PROGRAM -- ----------------------------------------------------------------------------- +local function parse_arguments(argmap, arg) + local i = 1 + local files = {} + + local function unrecognisedarg(arg) + argmap[" unrecognised"](arg) + end + + while (i <= #arg) do + local o = arg[i] + local op + + if (o:byte(1) == 45) then + -- This is an option. + if (o:byte(2) == 45) then + -- ...with a -- prefix. + o = o:sub(3) + local fn = argmap[o] + if not fn then + unrecognisedarg("--"..o) + end + i = i + fn(arg[i+1], arg[i+2]) + else + -- ...without a -- prefix. + local od = o:sub(2, 2) + local fn = argmap[od] + if not fn then + unrecognisedarg("-"..od) + end + op = o:sub(3) + if (op == "") then + i = i + fn(arg[i+1], arg[i+2]) + else + fn(op) + end + end + else + files[#files+1] = o + end + i = i + 1 + end + + argmap[" files"](files) +end + globals = { abspath = abspath, asstring = asstring, @@ -528,8 +614,32 @@ setmetatable(globals, } ) -emit("hide=@\n") -for _, file in ipairs({...}) do - loadbuildfile(file) +do + local environment_type = install_make_environment + parse_arguments( + { + ["make"] = function() + environment_type = install_make_environment + return 1 + end, + + ["ninja"] = function() + environment_type = install_ninja_environment + return 1 + end, + + [" unrecognised"] = function(arg) + error(string.format("unrecognised argument '%s'", arg)) + end, + + [" files"] = function(files) + environment_type() + for _, f in ipairs(files) do + loadbuildfile(f) + end + end + }, + {...} + ) end From d805052205296062a04f4e899a11b73be3008baf Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 19 Jun 2016 09:32:45 +0200 Subject: [PATCH 148/231] All the amisc binaries now build. --- build.lua | 2 +- first/build.lua | 2 +- h/build.lua | 2 ++ modules/build.lua | 12 +++++++++++- util/amisc/build.lua | 40 +++++++++++++++++++++++++++++++--------- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/build.lua b/build.lua index 45bd06717..c01435a83 100644 --- a/build.lua +++ b/build.lua @@ -2,7 +2,7 @@ installable { name = "ack", map = { "util/ack+ack-pkg", - "util/amisc+aelflod-pkg", + "util/amisc+pkg", } } diff --git a/first/build.lua b/first/build.lua index 354848704..2c820da47 100644 --- a/first/build.lua +++ b/first/build.lua @@ -162,7 +162,7 @@ definerule("cprogram", commands = { type="strings", default={ - "$(CC) -o %{outs[1]} %{ins}" + "$(CC) -o %{outs[1]} %{ins} %{ins}" }, } }, diff --git a/h/build.lua b/h/build.lua index 2c9c3886a..d1900ac5f 100644 --- a/h/build.lua +++ b/h/build.lua @@ -13,7 +13,9 @@ bundle { name = "emheaders", srcs = { "./em_*.h", + "./arch.h", "./out.h", + "./ranlib.h", "+em_path", } } diff --git a/modules/build.lua b/modules/build.lua index e3fb471df..40a9d1737 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -6,6 +6,16 @@ bundle { clibrary { name = "string", srcs = { "./src/string/*.c" }, - deps = { "#headers" }, + deps = { "+headers" }, +} + +clibrary { + name = "object", + srcs = { "./src/object/*.c" }, + deps = { + "+headers", + "h+local", + "h+emheaders", + }, } diff --git a/util/amisc/build.lua b/util/amisc/build.lua index 9e9fad4cc..099e51a82 100644 --- a/util/amisc/build.lua +++ b/util/amisc/build.lua @@ -1,16 +1,38 @@ -cprogram { - name = "aelflod", - srcs = { "./aelflod.c" }, - deps = { - "h+emheaders" +local function simpleprogram(name) + cprogram { + name = name, + srcs = { "./"..name..".c" }, + deps = { + "h+emheaders", + "modules+object", + } } -} + + installable { + name = name.."-pkg", + map = { + ["$(INSDIR)/bin/"..name] = "+"..name, + ["$(PLATIND)/man/man1/"..name..".1"] = "./"..name..".1", + } + } +end + +simpleprogram("aelflod") +simpleprogram("anm") +simpleprogram("ashow") +simpleprogram("asize") +simpleprogram("aslod") +simpleprogram("astrip") installable { - name = "aelflod-pkg", + name = "pkg", map = { - ["$(INSDIR)/bin/aelflod"] = "+aelflod", - ["$(PLATIND)/man/man1/aelflod.1"] = "./aelflod.1", + "+aelflod-pkg", + "+anm-pkg", + "+ashow-pkg", + "+asize-pkg", + "+aslod-pkg", + "+astrip-pkg", } } From 7f7005bac5d6600c07b51ac66d301cd0d72e9369 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 Jun 2016 13:28:22 +0200 Subject: [PATCH 149/231] Local rules; include() and replace(). --- first/ackbuilder.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 66f6f7027..9eef1f7a8 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -144,6 +144,14 @@ local function dirname(collection) ) end +local function replace(collection, pattern, repl) + return dotocollection(collection, + function(filename) + return filename:gsub(pattern, repl) + end + ) +end + local function fpairs(collection) if (type(collection) == "string") or collection.is then return fpairs({collection}) @@ -345,7 +353,7 @@ local typeconverters = { } local function definerule(rulename, types, cb) - if rules[rulename] then + if rulename and rules[rulename] then error(string.format("rule '%s' is already defined", rulename)) end @@ -358,7 +366,7 @@ local function definerule(rulename, types, cb) end end - rules[rulename] = function(e) + local rule = function(e) local args = {} for propname, typespec in pairs(types) do if not e[propname] then @@ -388,6 +396,11 @@ local function definerule(rulename, types, cb) targets[result.fullname] = result return result end + + if rulename then + rules[rulename] = rule + end + return rule end ----------------------------------------------------------------------------- @@ -595,7 +608,9 @@ globals = { emit = emit, environment = environment, filenamesof = filenamesof, + include = loadbuildfile, inherit = inherit, + replace = replace, selectof = selectof, startswith = startswith, fpairs = fpairs, From c8711628abd612171e58b058853e8cce74f1884c Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 Jun 2016 13:28:45 +0200 Subject: [PATCH 150/231] clibrary can now export headers. --- first/build.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/first/build.lua b/first/build.lua index 2c820da47..fc3429c7b 100644 --- a/first/build.lua +++ b/first/build.lua @@ -113,13 +113,14 @@ definerule("bundle", definerule("clibrary", { srcs = { type="targets" }, + hdrs = { type="targets", default={} }, deps = { type="targets", default={} }, cflags = { type="strings", default={} }, commands = { type="strings", default={ - "rm -f %{outs}", - "$(AR) cqs %{outs} %{ins}" + "rm -f %{outs[1]}", + "$(AR) cqs %{outs[1]} %{ins}", }, } }, @@ -145,12 +146,25 @@ definerule("clibrary", } end + local hdrs = filenamesof(e.hdrs, "%.h$") + + local commands = {} + for _, s in ipairs(e.commands) do + commands[#commands+1] = s + end + if (#hdrs > 0) then + commands[#commands+1] = "cp %{hdrs} %{dir}" + end + return normalrule { name = e.name, ins = ins, - outleaves = { e.name..".a" }, + outleaves = { e.name..".a", unpack(basename(hdrs)) }, label = e.label, - commands = e.commands + commands = commands, + vars = { + hdrs = hdrs + } } end ) @@ -159,6 +173,7 @@ definerule("cprogram", { srcs = { type="targets", default={} }, deps = { type="targets", default={} }, + cflags = { type="strings", default={} }, commands = { type="strings", default={ @@ -174,7 +189,8 @@ definerule("cprogram", clibrary { name = e.name .. "/main", srcs = e.srcs, - deps = e.deps + deps = e.deps, + cflags = e.cflags, } }, "%.a$" From 90764320bb5f30fd30c2bcd20f551aa3faeab001 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 Jun 2016 13:58:38 +0200 Subject: [PATCH 151/231] Better cwd handling. --- first/ackbuilder.lua | 10 ++++++++++ first/build.lua | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 9eef1f7a8..fbe0ee733 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -358,6 +358,7 @@ local function definerule(rulename, types, cb) end types.name = { type="string" } + types.cwd = { type="string", optional=true } for propname, typespec in pairs(types) do if not typeconverters[typespec.type] then @@ -366,6 +367,7 @@ local function definerule(rulename, types, cb) end end + local rulecwd = cwd local rule = function(e) local args = {} for propname, typespec in pairs(types) do @@ -388,8 +390,16 @@ local function definerule(rulename, types, cb) args.environment = environment args.fullname = cwd.."+"..args.name + args.rulecwd = rulecwd + if not args.cwd then + args.cwd = cwd + end + local oldcwd = cwd + cwd = rulecwd local result = cb(args) or {} + cwd = oldcwd + result.is = result.is or {} result.is[rulename] = true result.fullname = args.fullname diff --git a/first/build.lua b/first/build.lua index fc3429c7b..762d279d0 100644 --- a/first/build.lua +++ b/first/build.lua @@ -1,5 +1,5 @@ local function objdir(e) - return concatpath("$(OBJDIR)", cwd(), e.name) + return concatpath("$(OBJDIR)", e.cwd, e.name) end definerule("normalrule", @@ -69,6 +69,7 @@ definerule("cfile", return normalrule { name = e.name, + cwd = e.cwd, ins = {csrcs[1], unpack(hsrcs)}, outleaves = {outleaf}, label = e.label, @@ -102,6 +103,7 @@ definerule("bundle", return normalrule { name = e.name, + cwd = e.cwd, ins = e.srcs, outleaves = outleaves, label = e.label, @@ -137,10 +139,11 @@ definerule("clibrary", local n = basename(csrc):gsub("%.%w*$", "") ins[#ins+1] = cfile { name = e.name.."/"..n, + cwd = e.cwd, srcs = {csrc, unpack(hsrcs)}, deps = e.deps, cflags = { - "-I"..cwd(), + "-I"..e.cwd, unpack(e.cflags) }, } @@ -158,6 +161,7 @@ definerule("clibrary", return normalrule { name = e.name, + cwd = e.cwd, ins = ins, outleaves = { e.name..".a", unpack(basename(hdrs)) }, label = e.label, @@ -188,6 +192,7 @@ definerule("cprogram", { clibrary { name = e.name .. "/main", + cwd = e.cwd, srcs = e.srcs, deps = e.deps, cflags = e.cflags, @@ -201,6 +206,7 @@ definerule("cprogram", return normalrule { name = e.name, + cwd = e.cwd, ins = libs, outleaves = { e.name }, commands = e.commands, From 60edd08390661c0d86f962b7ca2abb31e1d3db1a Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 30 Jun 2016 13:19:10 +0200 Subject: [PATCH 152/231] Make work with make. --- first/ackbuilder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index fbe0ee733..52dd97dcd 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -425,7 +425,7 @@ local function install_make_environment() emit(name..":", ins[i], "\n") end for i = 1, #outs do - emit(outs[i]..":", name, "\n") + emit(outs[i]..":", name, ";\n") end emit(name..":\n") From f70c12fad52007c147190a9f37cc9374142b88e8 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 30 Jun 2016 13:27:47 +0200 Subject: [PATCH 153/231] Allow headers which aren't .h files. --- first/build.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/first/build.lua b/first/build.lua index 762d279d0..1501500c8 100644 --- a/first/build.lua +++ b/first/build.lua @@ -54,9 +54,8 @@ definerule("cfile", end local hsrcs = filenamesof(e.srcs, "%.h$") - local hdeps = selectof(e.deps, "%.h$") local hdrpaths = {} - for _, t in pairs(hdeps) do + for _, t in pairs(e.deps) do hdrpaths[#hdrpaths+1] = "-I"..t.dir end hdrpaths = uniquify(hdrpaths) @@ -128,9 +127,6 @@ definerule("clibrary", }, function (e) local csrcs = filenamesof(e.srcs, "%.c$") - if (#csrcs < 1) then - error("you must supply at least one C source file") - end local hsrcs = filenamesof(e.srcs, "%.h$") @@ -149,7 +145,7 @@ definerule("clibrary", } end - local hdrs = filenamesof(e.hdrs, "%.h$") + local hdrs = filenamesof(e.hdrs) local commands = {} for _, s in ipairs(e.commands) do From cdbd60580388631bf95fbcce30dc97b3c0433b6e Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 14 Jul 2016 23:53:34 +0200 Subject: [PATCH 154/231] concat, targetnamesof. deps is now handled more consistently (treated the same as ins but not passed in as inputs). --- first/ackbuilder.lua | 53 ++++++++++++++++++++++++++++++++++++++------ first/build.lua | 7 ++++-- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 52dd97dcd..2b6522246 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -53,6 +53,16 @@ local function asstring(o) end end +local function concat(...) + local r = {} + for _, t in ipairs({...}) do + for _, v in ipairs(t) do + r[#r+1] = v + end + end + return r +end + local function concatpath(...) local p = table.concat({...}, "/") return p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/") @@ -85,6 +95,27 @@ local function filenamesof(targets, pattern) return f end +local function targetnamesof(targets) + local f = {} + if targets then + if targets.is then + targets = {targets} + end + + for _, r in pairs(targets) do + if (type(r) == "table") and r.is then + f[#f+1] = r.fullname + elseif (type(r) == "string") then + f[#f+1] = r + else + error(string.format("list of targets contains a %s which isn't a target", + type(r))) + end + end + end + return f +end + local function dotocollection(collection, callback) if (type(collection) == "string") then return callback(collection) @@ -389,25 +420,28 @@ local function definerule(rulename, types, cb) end args.environment = environment - args.fullname = cwd.."+"..args.name - args.rulecwd = rulecwd if not args.cwd then args.cwd = cwd end + args.fullname = args.cwd.."+"..args.name - local oldcwd = cwd - cwd = rulecwd local result = cb(args) or {} - cwd = oldcwd result.is = result.is or {} result.is[rulename] = true result.fullname = args.fullname + + if targets[arg.fullname] and (targets[arg.fullname] ~= result) then + error(string.format("target '%s' is already defined", args.fullname)) + end targets[result.fullname] = result return result end if rulename then + if rules[rulename] then + error(string.format("rule '%s' is already defined", rulename)) + end rules[rulename] = rule end return rule @@ -498,12 +532,15 @@ definerule("simplerule", { ins = { type="targets" }, outs = { type="strings" }, + deps = { type="targets", default={} }, label = { type="string", optional=true }, commands = { type="strings" }, vars = { type="table", default={} }, }, function (e) - e.environment:rule(e.fullname, filenamesof(e.ins), e.outs) + e.environment:rule(e.fullname, + concat(filenamesof(e.ins), filenamesof(e.deps)), + e.outs) e.environment:label(e.fullname, " ", e.label or "") local vars = inherit(e.vars, { @@ -611,6 +648,7 @@ globals = { abspath = abspath, asstring = asstring, basename = basename, + concat = concat, concatpath = concatpath, cwd = function() return cwd end, definerule = definerule, @@ -618,12 +656,13 @@ globals = { emit = emit, environment = environment, filenamesof = filenamesof, + fpairs = fpairs, include = loadbuildfile, inherit = inherit, replace = replace, selectof = selectof, startswith = startswith, - fpairs = fpairs, + targetnamesof = targetnamesof, uniquify = uniquify, } setmetatable(globals, diff --git a/first/build.lua b/first/build.lua index 1501500c8..ffd163a6e 100644 --- a/first/build.lua +++ b/first/build.lua @@ -5,6 +5,7 @@ end definerule("normalrule", { ins = { type="targets" }, + deps = { type="targets", default={} }, outleaves = { type="strings" }, label = { type="string", optional=true }, objdir = { type="string", optional=true }, @@ -25,6 +26,7 @@ definerule("normalrule", local result = simplerule { name = e.name, ins = e.ins, + deps = e.deps, outs = realouts, label = e.label, commands = e.commands, @@ -69,7 +71,8 @@ definerule("cfile", return normalrule { name = e.name, cwd = e.cwd, - ins = {csrcs[1], unpack(hsrcs)}, + ins = {csrcs[1]}, + deps = e.deps, outleaves = {outleaf}, label = e.label, commands = e.commands, @@ -127,7 +130,6 @@ definerule("clibrary", }, function (e) local csrcs = filenamesof(e.srcs, "%.c$") - local hsrcs = filenamesof(e.srcs, "%.h$") local ins = {} @@ -203,6 +205,7 @@ definerule("cprogram", return normalrule { name = e.name, cwd = e.cwd, + deps = e.deps, ins = libs, outleaves = { e.name }, commands = e.commands, From bcf3408e36f7cc87d6bbd09266ac79d40528e350 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 14 Jul 2016 23:54:13 +0200 Subject: [PATCH 155/231] More stuff builds; almost the C compiler now. --- build.lua | 1 + lang/cem/cemcom.ansi/build.lua | 254 +++++++++++++++++++++++++++++++++ lang/cem/cemcom.ansi/char.tab | 2 + modules/build.lua | 32 +++++ util/LLgen/build.lua | 97 +++++++++++++ 5 files changed, 386 insertions(+) create mode 100644 lang/cem/cemcom.ansi/build.lua create mode 100644 util/LLgen/build.lua diff --git a/build.lua b/build.lua index c01435a83..b446dbd5e 100644 --- a/build.lua +++ b/build.lua @@ -3,6 +3,7 @@ installable { map = { "util/ack+ack-pkg", "util/amisc+pkg", + "lang/cem/cemcom.ansi+pkg", } } diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua new file mode 100644 index 000000000..8dfd6ab7c --- /dev/null +++ b/lang/cem/cemcom.ansi/build.lua @@ -0,0 +1,254 @@ +local posix = require("posix") +include("util/LLgen/build.lua") + +normalrule { + name = "parameters", + ins = { "./BigPars" }, + outleaves = { "parameters.h" }, + commands = { + "echo '#ifndef PARAMETERS_H' > %{outs}", + "echo '#define PARAMETERS_H' >> %{outs}", + "grep -v '^!' < %{ins} >> %{outs}", + "echo '#endif' >> %{outs}" + } +} + +local str_files = basename(posix.glob("lang/cem/cemcom.ansi/*.str")) +local str_targets = {} + +for _, f in ipairs(str_files) do + local bf = f:gsub("%.str$", "") + str_targets[#str_targets+1] = normalrule { + name = "allocd_header/"..bf, + ins = { "./make.allocd", "./"..f }, + outleaves = { bf..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next-c", + ins = { + "./make.next", + "./*.str", + }, + outleaves = { "next.c" }, + commands = { + "%{ins} > %{outs[1]}" + } +} + +clibrary { + name = "nextlib", + srcs = { "+next-c" }, + hdrs = str_targets, + deps = { + "+parameters", + unpack(str_targets) + } +} + +normalrule { + name = "tokenname-g", + ins = { + "./make.tokfile", + "./tokenname.c", + }, + outleaves = { "tokenname.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}", + } +} + +llgen { + name = "llgen", + srcs = { + "+tokenname-g", -- must be first + "./*.g", + }, +} + +cprogram { + name = "cemcom", + srcs = { + "./ch3.c", + "./ch3bin.c", + "./ch3mon.c", + "./code.c", + "./conversion.c", + "./cstoper.c", + "./dataflow.c", + "./declarator.c", + "./decspecs.c", + "./domacro.c", + "./dumpidf.c", + "./error.c", + "./eval.c", + "./expr.c", + "./field.c", + "./fltcstoper.c", + "./idf.c", + "./init.c", + "./input.c", + "./l_comment.c", + "./l_ev_ord.c", + "./l_lint.c", + "./l_misc.c", + "./l_outdef.c", + "./l_states.c", + "./label.c", + "./main.c", + "./options.c", + "./pragma.c", + "./proto.c", + "./replace.c", + "./skip.c", + "./stab.c", + "./stack.c", + "./struct.c", + "./switch.c", + "./tokenname.c", + "./type.c", + "./util.c", + }, + deps = { + "+parameters", + "+nextlib", + "+llgen", + "h+emheaders", + "modules+alloc", + "modules+flt_arith", + "modules+idf", + "modules+headers", + "modules+system", + }, +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_cemcom.ansi"] = "+cemcom" + } +} +--[[ + +D := lang/cem/cemcom.ansi + +define build-cemcom-ansi-allocd-header +$(eval g := $(OBJDIR)/$D/$(strip $1).h) +$g: $D/$(strip $1).str $D/make.allocd + @echo ALLOCD $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.allocd < $$^ > $$@ + +$(eval CLEANABLES += $g) +$(eval $q: $g) +endef + +define build-cemcom-ansi-next +$(eval CLEANABLES += $(OBJDIR)/$D/next.c) +$(OBJDIR)/$D/next.c: $D/make.next $1 + @echo NEXT $$@ + @mkdir -p $$(dir $$@) + $(hide) $$^ > $$@ +$(call cfile, $(OBJDIR)/$D/next.c) + +$(foreach f, $1, $(call build-cemcom-ansi-allocd-header, \ + $(basename $(notdir $f)))) +endef + +define build-cemcom-ansi-impl + +$(call reset) +$(eval cflags += -I$(OBJDIR)/$D -I$D) + +$(call cfile, $D/arith.c) +$(call dependson, $(INCDIR)/flt_arith.h) + +$(call cfile, $D/blocks.c) +$(call dependson, $(INCDIR)/em_codeEK.h) + +$(call cfile, $D/LLlex.c) +$(call cfile, $D/LLmessage.c) + + +$(call llgen, $(OBJDIR)/$D, \ + $(OBJDIR)/$D/tokenfile.g \ + $D/program.g \ + $D/declar.g \ + $D/expression.g \ + $D/statement.g \ + $D/ival.g) + +$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) +$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c + @echo TOKENFILE $$@ + @mkdir -p $$(dir $$@) + $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ + +$(call tabgen, $D/char.tab) + +$(eval $q: $(OBJDIR)/$D/parameters.h) + +$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) +$(OBJDIR)/$D/parameters.h: $D/BigPars + @echo PARAMETERS $$@ + @mkdir -p $$(dir $$@) + $(hide) echo '#ifndef PARAMETERS_H' > $$@ + $(hide) echo '#define PARAMETERS_H' >> $$@ + $(hide) grep -v '^!' < $D/BigPars >> $$@ + $(hide) echo '#endif' >> $$@ + +$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) +$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c + @echo TOKCASE $$@ + @mkdir -p $$(dir $$@) + $(hide) $D/make.tokcase < $D/tokenname.c > $$@ +$(call cfile, $(OBJDIR)/$D/symbol2str.c) + +$(call build-cemcom-ansi-next, \ + $D/code.str \ + $D/declar.str \ + $D/def.str \ + $D/expr.str \ + $D/field.str \ + $D/estack.str \ + $D/util.str \ + $D/proto.str \ + $D/replace.str \ + $D/idf.str \ + $D/macro.str \ + $D/stack.str \ + $D/stmt.str \ + $D/struct.str \ + $D/switch.str \ + $D/type.str \ + $D/l_brace.str \ + $D/l_state.str \ + $D/l_outdef.str) + +$(eval $q: $(OBJDIR)/$D/Lpars.h) + +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) +$(call cprogram, $(BINDIR)/cemcom.ansi) +$(call installto, $(PLATDEP)/em_cemcom.ansi) +$(eval CEMCOMANSI := $o) + +$(call reset) +$(eval q := $D/cemcom.ansi.1) +$(call installto, $(INSDIR)/share/man/man1/cemcom.6) +endef + +$(eval $(build-cemcom-ansi-impl)) +--]] diff --git a/lang/cem/cemcom.ansi/char.tab b/lang/cem/cemcom.ansi/char.tab index 329178284..809f1c6ce 100644 --- a/lang/cem/cemcom.ansi/char.tab +++ b/lang/cem/cemcom.ansi/char.tab @@ -1,4 +1,6 @@ % +hdrs = { "./src/system/system.h" }, +hdrs = { "./src/system/system.h" }, % CHARACTER CLASSES % % some general settings: diff --git a/modules/build.lua b/modules/build.lua index 40a9d1737..18a380f20 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -3,6 +3,38 @@ bundle { srcs = { "./h/*.h" } } +clibrary { + name = "system", + srcs = { "./src/system/*.c" }, + hdrs = { "./src/system/system.h" }, + deps = { "+headers" }, +} + +clibrary { + name = "alloc", + srcs = { "./src/alloc/*.c" }, + hdrs = { "./src/alloc/alloc.h" }, + deps = { + "+headers", + "+system" + }, +} + +clibrary { + name = "flt_arith", + srcs = { "./src/flt_arith/*.c" }, + hdrs = { "./src/flt_arith/flt_arith.h" }, + deps = { + "+headers" + } +} + +clibrary { + name = "idf", + srcs = {}, + hdrs = { "./src/idf/idf_pkg.*" }, +} + clibrary { name = "string", srcs = { "./src/string/*.c" }, diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua new file mode 100644 index 000000000..0a2c29f6f --- /dev/null +++ b/util/LLgen/build.lua @@ -0,0 +1,97 @@ +cprogram { + name = "llgen", + + -- These use pre-LLgen'd versions of LLgen.c, Lpars.c and tokens.c. If + -- LLgen.g gets updated, they need rebuilding. Use the bootstrap script to + -- do this. + + srcs = { "./src/*.c" }, + cflags = { "-DLIBDIR=\\\""..abspath("util/LLgen/lib").."\\\"", "-DNON_CORRECTING" }, +} + +definerule("llgen", + { + srcs = { type="targets" }, + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local fs = replace(basename(e.srcs), "%.g$", "") + + return normalrule { + name = e.name, + cwd = e.cwd, + outleaves = { + "Lpars.c", + "Lpars.h", + unpack(replace(fs, "$", ".c")) + }, + ins = { + "util/LLgen+llgen", + unpack(e.srcs), + }, + commands = { + "cd %{dir} && %{abspath(ins)}" + } + } + end +) + +--[[ +D := util/LLgen + +# Rule to build LLgen. + +define build-llgen-impl + $(call reset) + $(eval cflags += -DNON_CORRECTING -DLIBDIR=\"$(abspath $D/lib)\") + $(call cfile, $D/src/main.c) + $(call cfile, $D/src/gencode.c) + $(call cfile, $D/src/compute.c) + $(call cfile, $D/src/check.c) + $(call cfile, $D/src/reach.c) + $(call cfile, $D/src/global.c) + $(call cfile, $D/src/name.c) + $(call cfile, $D/src/sets.c) + $(call cfile, $D/src/alloc.c) + $(call cfile, $D/src/machdep.c) + $(call cfile, $D/src/cclass.c) + $(call cfile, $D/src/savegram.c) + + # These use pre-LLgen'd version of the files. If LLgen.g gets updated, + # they need rebuilding. Use the bootstrap script to do this. + + $(call cfile, $D/src/LLgen.c) + $(call cfile, $D/src/Lpars.c) + $(call cfile, $D/src/tokens.c) + + $(call cprogram, $(BINDIR)/LLgen) + LLGEN := $o +endef + +$(eval $(build-llgen-impl)) + +# Rule to invoke to *use* LLgen. +# +# $1: directory to put output files +# $2: input files +# +# Output files are compiled via cfile and queued. + +define llgen-impl +$(eval o := $1/Lpars.c $(patsubst %.g, $(strip $1)/%.c, $(notdir $2))) +$(eval CLEANABLES += $o $1/Lpars.h) + +$o: $1/Lpars.h +$1/Lpars.h: $2 $(LLGEN) + @echo LLGEN $1/Lpars.c + @mkdir -p $1 + $(hide) $(RM) $o $1/Lpars.h + $(hide) cd $1 && $(LLGEN) $(abspath $2) + +$(foreach f,$o,$(call cfile,$f)) + +endef + +llgen = $(eval $(call llgen-impl,$1,$2)) +--]] From 523374c36ba1fedb5d4e65dbf8305486fbc73f79 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 16 Jul 2016 14:58:29 +0200 Subject: [PATCH 156/231] Built a make bootstrap that runs either make or ninja depending on which is installed. --- Makefile | 246 ++++++++++++++++++++++++++----------------- first/ackbuilder.lua | 5 +- first/build.ninja | 2 + 3 files changed, 158 insertions(+), 95 deletions(-) create mode 100644 first/build.ninja diff --git a/Makefile b/Makefile index 0a2e7cab7..4cdb47e92 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,15 @@ BUILDDIR = $(ACK_TEMP_DIR)/ack-build CFLAGS = -g LDFLAGS = +# Various commands. + +AR = ar +CC = gcc + # ======================================================================= # # END OF CONFIGURATION # # ======================================================================= # -# + # You shouldn't need to change anything below this point unless you are # actually developing ACK. @@ -43,107 +48,160 @@ INSDIR = $(BUILDDIR)/staging PLATIND = $(INSDIR)/share/ack PLATDEP = $(INSDIR)/lib/ack -CC = gcc -AR = ar -RM = rm -f -CP = cp +MAKECMDGOALS ?= +ack +BUILD_FILES = $(shell find * -name build.lua) -hide = @ +NINJA := $(shell which ninja) +ifneq ($(findstring +, $(MAKECMDGOALS)),) +ifneq ($(NINJA),) -CFLAGS += \ - -I$(INCDIR) \ - -Imodules/h \ - -Ih +$(MAKECMDGOALS): $(BUILDDIR)/build.ninja $(BUILDDIR)/rules.ninja + @ninja -f $(BUILDDIR)/build.ninja $(MAKECMDGOALS) -LDFLAGS += +$(BUILDDIR)/build.ninja: Makefile + @mkdir -p $(BUILDDIR) + echo "OBJDIR = $(OBJDIR)" > $@ + echo "BINDIR = $(BINDIR)" >> $@ + echo "LIBDIR = $(LIBDIR)" >> $@ + echo "INCDIR = $(INCDIR)" >> $@ + echo "INSDIR = $(INSDIR)" >> $@ + echo "PLATIND = $(PLATIND)" >> $@ + echo "PLATDEP = $(PLATDEP)" >> $@ + echo "AR = $(AR)" >> $@ + echo "CC = $(CC)" >> $@ + echo "subninja $(BUILDDIR)/rules.ninja" >> $@ -ACKFLAGS = -Ih +else -all: installables +$(MAKECMDGOALS): $(BUILDDIR)/rules.mk + make -r -f $(BUILDDIR)/rules.mk $@ \ + $(MAKEFLAGS) \ + OBJDIR=$(OBJDIR) \ + BINDIR=$(BINDIR) \ + LIBDIR=$(LIBDIR) \ + INCDIR=$(INCDIR) \ + INSDIR=$(INSDIR) \ + PLATIND=$(PLATIND) \ + PLATDEP=$(PLATDEP) \ + AR=$(AR) \ + CC=$(CC) -.DELETE_ON_ERROR: +endif +endif -include first/core.mk +$(BUILDDIR)/rules.ninja: first/ackbuilder.lua $(BUILD_FILES) + @mkdir -p $(BUILDDIR) + lua5.2 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja -include modules/src/object/build.mk -include modules/src/alloc/build.mk -include modules/src/input/build.mk -include modules/src/idf/build.mk -include modules/src/system/build.mk -include modules/src/string/build.mk -include modules/src/print/build.mk -include modules/src/flt_arith/build.mk -include modules/src/em_code/build.mk -include modules/src/em_mes/build.mk -include modules/src/read_em/build.mk +$(BUILDDIR)/rules.mk: first/ackbuilder.lua $(BUILD_FILES) + @mkdir -p $(BUILDDIR) + lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk -include util/amisc/build.mk -include util/cmisc/build.mk -include util/ack/build.mk -include util/LLgen/build.mk -include util/data/build.mk -include util/opt/build.mk -include util/ncgg/build.mk -include util/arch/build.mk -include util/misc/build.mk -include util/led/build.mk -include util/topgen/build.mk -include util/ego/build.mk - -include lang/cem/build.mk -include lang/basic/build.mk -include lang/pc/build.mk -include lang/m2/build.mk - -include mach/proto/as/build.mk -include mach/proto/ncg/build.mk -include mach/proto/top/build.mk - -include plat/linux/liblinux/build.mk - -include mach/i80/build.mk -include mach/i386/build.mk -include mach/i86/build.mk -include mach/m68020/build.mk -# include mach/powerpc/build.mk -include mach/vc4/build.mk - -include plat/build.mk -include plat/pc86/build.mk -include plat/cpm/build.mk -include plat/linux386/build.mk -include plat/linux68k/build.mk -# include plat/linuxppc/build.mk -include plat/rpi/build.mk - -.PHONY: installables -installables: $(INSTALLABLES) - @echo "" - @echo "Build completed successfully." - -.PHONY: install -install: installables - @echo INSTALLING into $(PREFIX) - $(hide) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) - -.PHONY: clean clean: - @echo CLEAN - $(hide) $(RM) $(CLEANABLES) + @rm -rf $(BUILDDIR) -$(INCDIR)/local.h: - @echo LOCAL - @mkdir -p $(dir $@) - $(hide) echo '#define VERSION 3' > $@ - $(hide) echo '#define ACKM "$(DEFAULT_PLATFORM)"' >> $@ - $(hide) echo '#define BIGMACHINE 1' >> $@ - $(hide) echo '#define SYS_5' >> $@ - -$(INCDIR)/em_path.h: - @echo EM_PATH - @mkdir -p $(dir $@) - $(hide) echo '#define TMP_DIR "$(ACK_TEMP_DIR)"' > $@ - $(hide) echo '#define EM_DIR "$(PREFIX)"' >> $@ - $(hide) echo '#define ACK_PATH "share/ack/descr"' >> $@ - --include $(DEPENDS) +# +#CC = gcc +#AR = ar +#RM = rm -f +#CP = cp +# +#hide = @ +# +#CFLAGS += \ +# -I$(INCDIR) \ +# -Imodules/h \ +# -Ih +# +#LDFLAGS += +# +#ACKFLAGS = -Ih +# +#all: installables +# +#.DELETE_ON_ERROR: +# +#include first/core.mk +# +#include modules/src/object/build.mk +#include modules/src/alloc/build.mk +#include modules/src/input/build.mk +#include modules/src/idf/build.mk +#include modules/src/system/build.mk +#include modules/src/string/build.mk +#include modules/src/print/build.mk +#include modules/src/flt_arith/build.mk +#include modules/src/em_code/build.mk +#include modules/src/em_mes/build.mk +#include modules/src/read_em/build.mk +# +#include util/amisc/build.mk +#include util/cmisc/build.mk +#include util/ack/build.mk +#include util/LLgen/build.mk +#include util/data/build.mk +#include util/opt/build.mk +#include util/ncgg/build.mk +#include util/arch/build.mk +#include util/misc/build.mk +#include util/led/build.mk +#include util/topgen/build.mk +#include util/ego/build.mk +# +#include lang/cem/build.mk +#include lang/basic/build.mk +#include lang/pc/build.mk +#include lang/m2/build.mk +# +#include mach/proto/as/build.mk +#include mach/proto/ncg/build.mk +#include mach/proto/top/build.mk +# +#include plat/linux/liblinux/build.mk +# +#include mach/i80/build.mk +#include mach/i386/build.mk +#include mach/i86/build.mk +#include mach/m68020/build.mk +## include mach/powerpc/build.mk +#include mach/vc4/build.mk +# +#include plat/build.mk +#include plat/pc86/build.mk +#include plat/cpm/build.mk +#include plat/linux386/build.mk +#include plat/linux68k/build.mk +## include plat/linuxppc/build.mk +#include plat/rpi/build.mk +# +#.PHONY: installables +#installables: $(INSTALLABLES) +# @echo "" +# @echo "Build completed successfully." +# +#.PHONY: install +#install: installables +# @echo INSTALLING into $(PREFIX) +# $(hide) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) +# +#.PHONY: clean +#clean: +# @echo CLEAN +# $(hide) $(RM) $(CLEANABLES) +# +#$(INCDIR)/local.h: +# @echo LOCAL +# @mkdir -p $(dir $@) +# $(hide) echo '#define VERSION 3' > $@ +# $(hide) echo '#define ACKM "$(DEFAULT_PLATFORM)"' >> $@ +# $(hide) echo '#define BIGMACHINE 1' >> $@ +# $(hide) echo '#define SYS_5' >> $@ +# +#$(INCDIR)/em_path.h: +# @echo EM_PATH +# @mkdir -p $(dir $@) +# $(hide) echo '#define TMP_DIR "$(ACK_TEMP_DIR)"' > $@ +# $(hide) echo '#define EM_DIR "$(PREFIX)"' >> $@ +# $(hide) echo '#define ACK_PATH "share/ack/descr"' >> $@ +# +#-include $(DEPENDS) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 2b6522246..935346c74 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -146,7 +146,10 @@ end local function abspath(collection) return dotocollection(collection, function(filename) - return concatpath(posix.getcwd(), filename) + if not filename:find("^[/$]") then + filename = concatpath(posix.getcwd(), filename) + end + return filename end ) end diff --git a/first/build.ninja b/first/build.ninja new file mode 100644 index 000000000..d95daeed9 --- /dev/null +++ b/first/build.ninja @@ -0,0 +1,2 @@ +subninja .obj/rules.ninja + From 2d2497c318cd1870a57dbfdd7ad8eed838a1b56e Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 18 Jul 2016 23:16:27 +0200 Subject: [PATCH 157/231] ackbuilder rules files now require absolute paths in external variables (otherwise commands which change directory don't work). --- Makefile | 14 +++++++------- first/ackbuilder.lua | 6 ++++-- lang/cem/cemcom.ansi/build.lua | 2 +- util/LLgen/build.lua | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 4cdb47e92..7cc12c271 100644 --- a/Makefile +++ b/Makefile @@ -39,11 +39,11 @@ CC = gcc # You shouldn't need to change anything below this point unless you are # actually developing ACK. -OBJDIR = $(BUILDDIR)/obj -BINDIR = $(BUILDDIR)/bin -LIBDIR = $(BUILDDIR)/lib -INCDIR = $(BUILDDIR)/include -INSDIR = $(BUILDDIR)/staging +OBJDIR = $(abspath $(BUILDDIR)/obj) +BINDIR = $(abspath $(BUILDDIR)/bin) +LIBDIR = $(abspath $(BUILDDIR)/lib) +INCDIR = $(abspath $(BUILDDIR)/include) +INSDIR = $(abspath $(BUILDDIR)/staging) PLATIND = $(INSDIR)/share/ack PLATDEP = $(INSDIR)/lib/ack @@ -91,11 +91,11 @@ endif $(BUILDDIR)/rules.ninja: first/ackbuilder.lua $(BUILD_FILES) @mkdir -p $(BUILDDIR) - lua5.2 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja + @lua5.2 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja $(BUILDDIR)/rules.mk: first/ackbuilder.lua $(BUILD_FILES) @mkdir -p $(BUILDDIR) - lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk + @lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk clean: @rm -rf $(BUILDDIR) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 935346c74..a799c8a4b 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -65,7 +65,7 @@ end local function concatpath(...) local p = table.concat({...}, "/") - return p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/") + return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/")) end local function filenamesof(targets, pattern) @@ -153,7 +153,7 @@ local function abspath(collection) end ) end - + local function basename(collection) return dotocollection(collection, function(filename) @@ -648,6 +648,8 @@ local function parse_arguments(argmap, arg) end globals = { + posix = posix, + abspath = abspath, asstring = asstring, basename = basename, diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index 8dfd6ab7c..5f8476ad3 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -13,7 +13,7 @@ normalrule { } } -local str_files = basename(posix.glob("lang/cem/cemcom.ansi/*.str")) +local str_files = basename(posix.glob(cwd().."/*.str")) local str_targets = {} for _, f in ipairs(str_files) do diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua index 0a2c29f6f..ff0b7f638 100644 --- a/util/LLgen/build.lua +++ b/util/LLgen/build.lua @@ -6,7 +6,7 @@ cprogram { -- do this. srcs = { "./src/*.c" }, - cflags = { "-DLIBDIR=\\\""..abspath("util/LLgen/lib").."\\\"", "-DNON_CORRECTING" }, + cflags = { "-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"", "-DNON_CORRECTING" }, } definerule("llgen", From b7720c298bec0c385917bb53147d827abd71318f Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 19 Jul 2016 23:42:42 +0200 Subject: [PATCH 158/231] Error out if a template expansion returns nil (as it's normally an error). --- first/ackbuilder.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index a799c8a4b..539b34897 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -256,7 +256,11 @@ local function templateexpand(list, vars) if e then error(string.format("error evaluating expression: %s", e)) end - return asstring(chunk()) + local value = chunk() + if (value == nil) then + error(string.format("template expression expands to nil (probably an undefined variable)")) + end + return asstring(value) end ) end From 05e3cf286f0081342fadfc76d65e54377aad1ba2 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 19 Jul 2016 23:42:56 +0200 Subject: [PATCH 159/231] Saner clibrary dependency and header handling. --- first/build.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/first/build.lua b/first/build.lua index ffd163a6e..9a35c36a6 100644 --- a/first/build.lua +++ b/first/build.lua @@ -116,7 +116,7 @@ definerule("bundle", definerule("clibrary", { - srcs = { type="targets" }, + srcs = { type="targets", default={} }, hdrs = { type="targets", default={} }, deps = { type="targets", default={} }, cflags = { type="strings", default={} }, @@ -161,6 +161,7 @@ definerule("clibrary", name = e.name, cwd = e.cwd, ins = ins, + deps = concat(e.hdrs, e.deps), outleaves = { e.name..".a", unpack(basename(hdrs)) }, label = e.label, commands = commands, From 1fdc69fb97e53a92204771742ec63d67b5b35d33 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 19 Jul 2016 23:43:14 +0200 Subject: [PATCH 160/231] cemcom.ansi now builds. --- Makefile | 22 +++---- h/build.lua | 20 +++---- lang/cem/cemcom.ansi/build.lua | 3 + modules/build.lua | 104 ++++++++++++++++++++++++++++++++- util/LLgen/build.lua | 59 ------------------- util/data/build.lua | 36 ++++++++++++ 6 files changed, 161 insertions(+), 83 deletions(-) create mode 100644 util/data/build.lua diff --git a/Makefile b/Makefile index 7cc12c271..a8381b487 100644 --- a/Makefile +++ b/Makefile @@ -60,21 +60,21 @@ $(MAKECMDGOALS): $(BUILDDIR)/build.ninja $(BUILDDIR)/rules.ninja $(BUILDDIR)/build.ninja: Makefile @mkdir -p $(BUILDDIR) - echo "OBJDIR = $(OBJDIR)" > $@ - echo "BINDIR = $(BINDIR)" >> $@ - echo "LIBDIR = $(LIBDIR)" >> $@ - echo "INCDIR = $(INCDIR)" >> $@ - echo "INSDIR = $(INSDIR)" >> $@ - echo "PLATIND = $(PLATIND)" >> $@ - echo "PLATDEP = $(PLATDEP)" >> $@ - echo "AR = $(AR)" >> $@ - echo "CC = $(CC)" >> $@ - echo "subninja $(BUILDDIR)/rules.ninja" >> $@ + @echo "OBJDIR = $(OBJDIR)" > $@ + @echo "BINDIR = $(BINDIR)" >> $@ + @echo "LIBDIR = $(LIBDIR)" >> $@ + @echo "INCDIR = $(INCDIR)" >> $@ + @echo "INSDIR = $(INSDIR)" >> $@ + @echo "PLATIND = $(PLATIND)" >> $@ + @echo "PLATDEP = $(PLATDEP)" >> $@ + @echo "AR = $(AR)" >> $@ + @echo "CC = $(CC)" >> $@ + @echo "subninja $(BUILDDIR)/rules.ninja" >> $@ else $(MAKECMDGOALS): $(BUILDDIR)/rules.mk - make -r -f $(BUILDDIR)/rules.mk $@ \ + @make -r -f $(BUILDDIR)/rules.mk $@ \ $(MAKEFLAGS) \ OBJDIR=$(OBJDIR) \ BINDIR=$(BINDIR) \ diff --git a/h/build.lua b/h/build.lua index d1900ac5f..7fd9d6728 100644 --- a/h/build.lua +++ b/h/build.lua @@ -9,17 +9,6 @@ normalrule { } } -bundle { - name = "emheaders", - srcs = { - "./em_*.h", - "./arch.h", - "./out.h", - "./ranlib.h", - "+em_path", - } -} - normalrule { name = "local", ins = {}, @@ -32,3 +21,12 @@ normalrule { } } +clibrary { + name = "emheaders", + hdrs = { + "./*.h", + "+em_path", + "+local", + } +} + diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index 5f8476ad3..e330eded9 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -119,10 +119,13 @@ cprogram { "+llgen", "h+emheaders", "modules+alloc", + "modules+em_code_k", "modules+flt_arith", "modules+idf", + "modules+input", "modules+headers", "modules+system", + "util/data+libem", }, } diff --git a/modules/build.lua b/modules/build.lua index 18a380f20..cbf72d0ba 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -1,6 +1,8 @@ -bundle { +clibrary { name = "headers", - srcs = { "./h/*.h" } + hdrs = { + "./h/*.h" + } } clibrary { @@ -35,6 +37,14 @@ clibrary { hdrs = { "./src/idf/idf_pkg.*" }, } +clibrary { + name = "input", + srcs = { + "./src/input/*.c" + }, + hdrs = { "./src/input/inp_pkg.*" } +} + clibrary { name = "string", srcs = { "./src/string/*.c" }, @@ -51,3 +61,93 @@ clibrary { }, } +normalrule { + name = "em_code_ek_h", + ins = { + "./src/em_code/make.em.gen", + "./src/em_code/em.nogen", + "h/em_table" + }, + outleaves = { "em_codeEK.h" }, + commands = { + "%{ins[1]} %{ins[3]} > %{outs}", + "cat %{ins[2]} >> %{outs}" + } +} + +for _, variant in ipairs { + { "e", "-DREADABLE_EM" }, + { "k", "" } +} do + local code = variant[1] + local cflags = variant[2] + + clibrary { + name = "em_code_"..code, + srcs = { + "./src/em_code/C_out.c", + "./src/em_code/bhcst.c", + "./src/em_code/bhdlb.c", + "./src/em_code/bhdnam.c", + "./src/em_code/bhfcon.c", + "./src/em_code/bhicon.c", + "./src/em_code/bhilb.c", + "./src/em_code/bhpnam.c", + "./src/em_code/bhucon.c", + "./src/em_code/crcst.c", + "./src/em_code/crdlb.c", + "./src/em_code/crdnam.c", + "./src/em_code/crilb.c", + "./src/em_code/crpnam.c", + "./src/em_code/crscon.c", + "./src/em_code/crxcon.c", + "./src/em_code/cst.c", + "./src/em_code/dfdlb.c", + "./src/em_code/dfdnam.c", + "./src/em_code/dfilb.c", + "./src/em_code/dlb.c", + "./src/em_code/dnam.c", + "./src/em_code/em.c", + "./src/em_code/end.c", + "./src/em_code/endarg.c", + "./src/em_code/exc.c", + "./src/em_code/failed.c", + "./src/em_code/fcon.c", + "./src/em_code/getid.c", + "./src/em_code/icon.c", + "./src/em_code/ilb.c", + "./src/em_code/insert.c", + "./src/em_code/internerr.c", + "./src/em_code/msend.c", + "./src/em_code/msstart.c", + "./src/em_code/op.c", + "./src/em_code/opcst.c", + "./src/em_code/opdlb.c", + "./src/em_code/opdnam.c", + "./src/em_code/opilb.c", + "./src/em_code/opnarg.c", + "./src/em_code/oppnam.c", + "./src/em_code/pnam.c", + "./src/em_code/pro.c", + "./src/em_code/pronarg.c", + "./src/em_code/psdlb.c", + "./src/em_code/psdnam.c", + "./src/em_code/pspnam.c", + "./src/em_code/scon.c", + "./src/em_code/ucon.c", + }, + hdrs = { + "+em_code_ek_h" + }, + deps = { + "+alloc", + "+em_code_ek_h", + "+headers", + "+system", + "h+emheaders", + "h+local", + "util/data+libem", + }, + cflags = { cflags } + } +end diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua index ff0b7f638..fd60daa59 100644 --- a/util/LLgen/build.lua +++ b/util/LLgen/build.lua @@ -36,62 +36,3 @@ definerule("llgen", } end ) - ---[[ -D := util/LLgen - -# Rule to build LLgen. - -define build-llgen-impl - $(call reset) - $(eval cflags += -DNON_CORRECTING -DLIBDIR=\"$(abspath $D/lib)\") - $(call cfile, $D/src/main.c) - $(call cfile, $D/src/gencode.c) - $(call cfile, $D/src/compute.c) - $(call cfile, $D/src/check.c) - $(call cfile, $D/src/reach.c) - $(call cfile, $D/src/global.c) - $(call cfile, $D/src/name.c) - $(call cfile, $D/src/sets.c) - $(call cfile, $D/src/alloc.c) - $(call cfile, $D/src/machdep.c) - $(call cfile, $D/src/cclass.c) - $(call cfile, $D/src/savegram.c) - - # These use pre-LLgen'd version of the files. If LLgen.g gets updated, - # they need rebuilding. Use the bootstrap script to do this. - - $(call cfile, $D/src/LLgen.c) - $(call cfile, $D/src/Lpars.c) - $(call cfile, $D/src/tokens.c) - - $(call cprogram, $(BINDIR)/LLgen) - LLGEN := $o -endef - -$(eval $(build-llgen-impl)) - -# Rule to invoke to *use* LLgen. -# -# $1: directory to put output files -# $2: input files -# -# Output files are compiled via cfile and queued. - -define llgen-impl -$(eval o := $1/Lpars.c $(patsubst %.g, $(strip $1)/%.c, $(notdir $2))) -$(eval CLEANABLES += $o $1/Lpars.h) - -$o: $1/Lpars.h -$1/Lpars.h: $2 $(LLGEN) - @echo LLGEN $1/Lpars.c - @mkdir -p $1 - $(hide) $(RM) $o $1/Lpars.h - $(hide) cd $1 && $(LLGEN) $(abspath $2) - -$(foreach f,$o,$(call cfile,$f)) - -endef - -llgen = $(eval $(call llgen-impl,$1,$2)) ---]] diff --git a/util/data/build.lua b/util/data/build.lua new file mode 100644 index 000000000..7ed75e280 --- /dev/null +++ b/util/data/build.lua @@ -0,0 +1,36 @@ +normalrule { + name = "generated", + ins = { + "./new_table", + "h/em_table", -- relative to root, which is a bit evil + }, + outleaves = { + "em_flag.c", + "em_pseu.c", + "em_mnem.c", + "em_spec.h", + "em_pseu.h", + "em_mnem.h", + }, + deps = { + "h+emheaders" + }, + commands = { + "%{ins[1]} %{ins[2]} %{dir} %{dir}" + } +} + +clibrary { + name = "libem", + srcs = { + "./em_ptyp.c", + "+generated", -- so we build the C files + }, + hdrs = { + "+generated" -- so we export the H files + }, + deps = { + "+generated", -- so we can see the H files + "h+emheaders" + } +} From 2770a838375bebe66bc5ee6329a5ed06fc6b1c10 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 23 Jul 2016 00:30:31 +0200 Subject: [PATCH 161/231] More programs, more libraries. src/modules build files are now saner. --- build.lua | 6 +- first/build.lua | 2 +- lang/cem/cemcom.ansi/build.lua | 14 +-- modules/build.lua | 146 -------------------------------- modules/src/alloc/build.lua | 10 +++ modules/src/em_code/build.lua | 88 +++++++++++++++++++ modules/src/flt_arith/build.lua | 10 +++ modules/src/idf/build.lua | 7 ++ modules/src/input/build.lua | 9 ++ modules/src/object/build.lua | 11 +++ modules/src/print/build.lua | 11 +++ modules/src/read_em/build.lua | 56 ++++++++++++ modules/src/read_em/m_C_mnem | 5 +- modules/src/read_em/m_C_mnem_na | 3 +- modules/src/string/build.lua | 7 ++ modules/src/system/build.lua | 8 ++ util/ack/build.lua | 61 +------------ util/amisc/build.lua | 2 +- util/arch/build.lua | 19 +++++ util/data/build.lua | 2 +- 20 files changed, 256 insertions(+), 221 deletions(-) create mode 100644 modules/src/alloc/build.lua create mode 100644 modules/src/em_code/build.lua create mode 100644 modules/src/flt_arith/build.lua create mode 100644 modules/src/idf/build.lua create mode 100644 modules/src/input/build.lua create mode 100644 modules/src/object/build.lua create mode 100644 modules/src/print/build.lua create mode 100644 modules/src/read_em/build.lua create mode 100644 modules/src/string/build.lua create mode 100644 modules/src/system/build.lua create mode 100644 util/arch/build.lua diff --git a/build.lua b/build.lua index b446dbd5e..86641357d 100644 --- a/build.lua +++ b/build.lua @@ -1,9 +1,11 @@ installable { name = "ack", map = { - "util/ack+ack-pkg", - "util/amisc+pkg", "lang/cem/cemcom.ansi+pkg", + "util/ack+pkg", + "util/amisc+pkg", + "util/arch+pkg", + "util/misc+pkg", } } diff --git a/first/build.lua b/first/build.lua index 9a35c36a6..dcddaae90 100644 --- a/first/build.lua +++ b/first/build.lua @@ -180,7 +180,7 @@ definerule("cprogram", commands = { type="strings", default={ - "$(CC) -o %{outs[1]} %{ins} %{ins}" + "$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group" }, } }, diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index e330eded9..ff07e4b36 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -118,14 +118,14 @@ cprogram { "+nextlib", "+llgen", "h+emheaders", - "modules+alloc", - "modules+em_code_k", - "modules+flt_arith", - "modules+idf", - "modules+input", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/system+lib", "modules+headers", - "modules+system", - "util/data+libem", + "util/data+em_data", }, } diff --git a/modules/build.lua b/modules/build.lua index cbf72d0ba..a2228f2a8 100644 --- a/modules/build.lua +++ b/modules/build.lua @@ -5,149 +5,3 @@ clibrary { } } -clibrary { - name = "system", - srcs = { "./src/system/*.c" }, - hdrs = { "./src/system/system.h" }, - deps = { "+headers" }, -} - -clibrary { - name = "alloc", - srcs = { "./src/alloc/*.c" }, - hdrs = { "./src/alloc/alloc.h" }, - deps = { - "+headers", - "+system" - }, -} - -clibrary { - name = "flt_arith", - srcs = { "./src/flt_arith/*.c" }, - hdrs = { "./src/flt_arith/flt_arith.h" }, - deps = { - "+headers" - } -} - -clibrary { - name = "idf", - srcs = {}, - hdrs = { "./src/idf/idf_pkg.*" }, -} - -clibrary { - name = "input", - srcs = { - "./src/input/*.c" - }, - hdrs = { "./src/input/inp_pkg.*" } -} - -clibrary { - name = "string", - srcs = { "./src/string/*.c" }, - deps = { "+headers" }, -} - -clibrary { - name = "object", - srcs = { "./src/object/*.c" }, - deps = { - "+headers", - "h+local", - "h+emheaders", - }, -} - -normalrule { - name = "em_code_ek_h", - ins = { - "./src/em_code/make.em.gen", - "./src/em_code/em.nogen", - "h/em_table" - }, - outleaves = { "em_codeEK.h" }, - commands = { - "%{ins[1]} %{ins[3]} > %{outs}", - "cat %{ins[2]} >> %{outs}" - } -} - -for _, variant in ipairs { - { "e", "-DREADABLE_EM" }, - { "k", "" } -} do - local code = variant[1] - local cflags = variant[2] - - clibrary { - name = "em_code_"..code, - srcs = { - "./src/em_code/C_out.c", - "./src/em_code/bhcst.c", - "./src/em_code/bhdlb.c", - "./src/em_code/bhdnam.c", - "./src/em_code/bhfcon.c", - "./src/em_code/bhicon.c", - "./src/em_code/bhilb.c", - "./src/em_code/bhpnam.c", - "./src/em_code/bhucon.c", - "./src/em_code/crcst.c", - "./src/em_code/crdlb.c", - "./src/em_code/crdnam.c", - "./src/em_code/crilb.c", - "./src/em_code/crpnam.c", - "./src/em_code/crscon.c", - "./src/em_code/crxcon.c", - "./src/em_code/cst.c", - "./src/em_code/dfdlb.c", - "./src/em_code/dfdnam.c", - "./src/em_code/dfilb.c", - "./src/em_code/dlb.c", - "./src/em_code/dnam.c", - "./src/em_code/em.c", - "./src/em_code/end.c", - "./src/em_code/endarg.c", - "./src/em_code/exc.c", - "./src/em_code/failed.c", - "./src/em_code/fcon.c", - "./src/em_code/getid.c", - "./src/em_code/icon.c", - "./src/em_code/ilb.c", - "./src/em_code/insert.c", - "./src/em_code/internerr.c", - "./src/em_code/msend.c", - "./src/em_code/msstart.c", - "./src/em_code/op.c", - "./src/em_code/opcst.c", - "./src/em_code/opdlb.c", - "./src/em_code/opdnam.c", - "./src/em_code/opilb.c", - "./src/em_code/opnarg.c", - "./src/em_code/oppnam.c", - "./src/em_code/pnam.c", - "./src/em_code/pro.c", - "./src/em_code/pronarg.c", - "./src/em_code/psdlb.c", - "./src/em_code/psdnam.c", - "./src/em_code/pspnam.c", - "./src/em_code/scon.c", - "./src/em_code/ucon.c", - }, - hdrs = { - "+em_code_ek_h" - }, - deps = { - "+alloc", - "+em_code_ek_h", - "+headers", - "+system", - "h+emheaders", - "h+local", - "util/data+libem", - }, - cflags = { cflags } - } -end diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua new file mode 100644 index 000000000..a274c390e --- /dev/null +++ b/modules/src/alloc/build.lua @@ -0,0 +1,10 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./alloc.h" }, + deps = { + "modules+headers", + "modules/src/system+lib" + }, +} + diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua new file mode 100644 index 000000000..80ea28a8b --- /dev/null +++ b/modules/src/em_code/build.lua @@ -0,0 +1,88 @@ +normalrule { + name = "em_code_ek_h", + ins = { + "./make.em.gen", + "./em.nogen", + "h/em_table" + }, + outleaves = { "em_codeEK.h" }, + commands = { + "%{ins[1]} %{ins[3]} > %{outs}", + "cat %{ins[2]} >> %{outs}" + } +} + +local function build_variant(code, cflags) + clibrary { + name = "lib_"..code, + srcs = { + "./C_out.c", + "./bhcst.c", + "./bhdlb.c", + "./bhdnam.c", + "./bhfcon.c", + "./bhicon.c", + "./bhilb.c", + "./bhpnam.c", + "./bhucon.c", + "./crcst.c", + "./crdlb.c", + "./crdnam.c", + "./crilb.c", + "./crpnam.c", + "./crscon.c", + "./crxcon.c", + "./cst.c", + "./dfdlb.c", + "./dfdnam.c", + "./dfilb.c", + "./dlb.c", + "./dnam.c", + "./em.c", + "./end.c", + "./endarg.c", + "./exc.c", + "./failed.c", + "./fcon.c", + "./getid.c", + "./icon.c", + "./ilb.c", + "./insert.c", + "./internerr.c", + "./msend.c", + "./msstart.c", + "./op.c", + "./opcst.c", + "./opdlb.c", + "./opdnam.c", + "./opilb.c", + "./opnarg.c", + "./oppnam.c", + "./pnam.c", + "./pro.c", + "./pronarg.c", + "./psdlb.c", + "./psdnam.c", + "./pspnam.c", + "./scon.c", + "./ucon.c", + }, + hdrs = { + "+em_code_ek_h" + }, + deps = { + "+em_code_ek_h", + "h+emheaders", + "h+local", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/system+lib", + "util/data+em_data", + }, + cflags = { cflags } + } +end + +build_variant("e", "-DREADABLE_EM") +build_variant("k", "") + diff --git a/modules/src/flt_arith/build.lua b/modules/src/flt_arith/build.lua new file mode 100644 index 000000000..10ce7b8ce --- /dev/null +++ b/modules/src/flt_arith/build.lua @@ -0,0 +1,10 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./flt_arith.h" }, + deps = { + "modules+headers" + } +} + + diff --git a/modules/src/idf/build.lua b/modules/src/idf/build.lua new file mode 100644 index 000000000..ac30ac54e --- /dev/null +++ b/modules/src/idf/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = {}, + hdrs = { "./idf_pkg.*" }, +} + + diff --git a/modules/src/input/build.lua b/modules/src/input/build.lua new file mode 100644 index 000000000..7f59455e0 --- /dev/null +++ b/modules/src/input/build.lua @@ -0,0 +1,9 @@ +clibrary { + name = "lib", + srcs = { + "./*.c" + }, + hdrs = { "./inp_pkg.*" } +} + + diff --git a/modules/src/object/build.lua b/modules/src/object/build.lua new file mode 100644 index 000000000..61a9907f1 --- /dev/null +++ b/modules/src/object/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { + "modules+headers", + "h+local", + "h+emheaders", + }, +} + + diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua new file mode 100644 index 000000000..a3bc48b06 --- /dev/null +++ b/modules/src/print/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./print.h" }, + deps = { + "modules+headers", + "modules/src/system+lib" + } +} + + diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua new file mode 100644 index 000000000..860f29df1 --- /dev/null +++ b/modules/src/read_em/build.lua @@ -0,0 +1,56 @@ + +normalrule { + name = "c_mnem_narg_h", + ins = { + "./m_C_mnem_na", + "h/em_table", + "./argtype" + }, + outleaves = "C_mnem_narg.h", + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "c_mnem_h", + ins = { + "./m_C_mnem", + "h/em_table", + "./argtype" + }, + outleaves = "C_mnem.h", + commands = { + "%{ins} > %{outs}" + } +} + +clibrary { + name = "lib_ev", + cflags = { + "-DPRIVATE=static", + "-DEXPORT=", + "-DNDEBUG", + "-DCHECKING" + }, + srcs = { + "./EM_vars.c", + "./read_em.c", + "./mkcalls.c", + }, + hdrs = { + "./em_comp.h", + }, + deps = { + "+c_mnem_h", + "+c_mnem_narg_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+em_code_ek_h", + "modules/src/system+lib", + "util/data+em_data", + } +} + + diff --git a/modules/src/read_em/m_C_mnem b/modules/src/read_em/m_C_mnem index 70152f5c4..67b6056b5 100755 --- a/modules/src/read_em/m_C_mnem +++ b/modules/src/read_em/m_C_mnem @@ -1,10 +1,11 @@ #!/bin/sh EM_TABLE=$1 +ARGTYPE=$2 echo "switch(p->em_opcode) {" for i in - cdflnorswz p b do - list=`./argtype $i $EM_TABLE` + list=`$ARGTYPE $i $EM_TABLE` case $i in -) args='()' echo " /* no arguments */" @@ -34,7 +35,7 @@ do EOF done done -list=`./argtype g $EM_TABLE` +list=`$ARGTYPE g $EM_TABLE` cat << 'EOF' default: /* a "g" argument */ diff --git a/modules/src/read_em/m_C_mnem_na b/modules/src/read_em/m_C_mnem_na index 535ea0831..07e80daad 100755 --- a/modules/src/read_em/m_C_mnem_na +++ b/modules/src/read_em/m_C_mnem_na @@ -1,5 +1,6 @@ EM_TABLE=$1 -list=`./argtype w $EM_TABLE` +ARGTYPE=$2 +list=`$ARGTYPE w $EM_TABLE` echo "switch(p->em_opcode) {" for i in $list do diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua new file mode 100644 index 000000000..c45a84577 --- /dev/null +++ b/modules/src/string/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { "modules+headers" }, +} + + diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua new file mode 100644 index 000000000..47587e122 --- /dev/null +++ b/modules/src/system/build.lua @@ -0,0 +1,8 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./system.h" }, + deps = { "modules+headers" }, +} + + diff --git a/util/ack/build.lua b/util/ack/build.lua index f30eedf4a..dc46d44a8 100644 --- a/util/ack/build.lua +++ b/util/ack/build.lua @@ -29,7 +29,7 @@ cprogram { } installable { - name = "ack-pkg", + name = "pkg", map = { ["$(INSDIR)/bin/ack"] = "+ack", ["$(INSDIR)/share/man/man1/ack.1"] = "./ack.1.X", @@ -37,62 +37,3 @@ installable { } } ---[[ -D := util/ack - -define util-ack-makeheaders-rule -$(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) -$(wordlist 2, $(words $g), $g): $(firstword $g) -$(firstword $g): $(util-ack-mktables) - @echo MKTABLES - @mkdir -p $(OBJDIR)/$D - $(hide) cd $(OBJDIR)/$D && $(util-ack-mktables) $(INSDIR)/share - -$(eval CLEANABLES += $g) -endef - -define build-ack-impl - $(call reset) - $(call cfile, $D/mktables.c) - $(call cprogram, $(OBJDIR)/$D/mktables) - $(eval util-ack-mktables := $o) - - $(call reset) - $(eval cflags += -I$D) - $(call cfile, $D/list.c) - $(call cfile, $D/data.c) - $(call cfile, $D/main.c) - $(call cfile, $D/scan.c) - $(call cfile, $D/svars.c) - $(call cfile, $D/trans.c) - $(call cfile, $D/util.c) - - $(call cfile, $D/rmach.c) - $(call dependson, $(INCDIR)/em_path.h) - - $(call cfile, $D/run.c) - $(call cfile, $D/grows.c) - - $(call cfile, $D/files.c) - $(call dependson, $(INCDIR)/em_path.h) - - $(eval $(util-ack-makeheaders-rule)) - $(call cfile, $(OBJDIR)/$D/dmach.c) - $(call cfile, $(OBJDIR)/$D/intable.c) - - $(call cprogram, $(BINDIR)/ack) - $(call installto, $(INSDIR)/bin/ack) - $(eval ACK := $o) - - $(call reset) - $(eval q := lib/descr/fe) - $(call installto, $(PLATIND)/descr/fe) - $(eval $(ACK): $o) - - $(call reset) - $(eval q := $D/ack.1.X) - $(call installto, $(INSDIR)/share/man/man1/ack.1) -endef - -$(eval $(build-ack-impl)) ---]] diff --git a/util/amisc/build.lua b/util/amisc/build.lua index 099e51a82..d1b8a3356 100644 --- a/util/amisc/build.lua +++ b/util/amisc/build.lua @@ -4,7 +4,7 @@ local function simpleprogram(name) srcs = { "./"..name..".c" }, deps = { "h+emheaders", - "modules+object", + "modules/src/object+lib", } } diff --git a/util/arch/build.lua b/util/arch/build.lua new file mode 100644 index 000000000..ad207c60e --- /dev/null +++ b/util/arch/build.lua @@ -0,0 +1,19 @@ +cprogram { + name = "aal", + srcs = { "./archiver.c" }, + deps = { + "h+emheaders", + "modules/src/object+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib" + } +} + +installable { + name = "pkg", + map = { + ["$(INSDIR)/bin/aal"] = "+aal", + ["$(PLATIND)/man/man1/aal.1"] = "./aal.1" + } +} diff --git a/util/data/build.lua b/util/data/build.lua index 7ed75e280..784e1d6ac 100644 --- a/util/data/build.lua +++ b/util/data/build.lua @@ -21,7 +21,7 @@ normalrule { } clibrary { - name = "libem", + name = "em_data", srcs = { "./em_ptyp.c", "+generated", -- so we build the C files From bff5c4019c23b617736e9f789b8b22ded86bfb91 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 24 Jul 2016 00:50:02 +0200 Subject: [PATCH 162/231] Baby steps towards building a platform --- make the assembler work. Add ackbuilder support for C preprocessor files and yacc. --- build.lua | 1 + first/ackbuilder.lua | 9 ++++- first/build.lua | 44 ++++++++++++++++++++-- first/yacc.lua | 23 ++++++++++++ mach/proto/as/build.lua | 46 +++++++++++++++++++++++ plat/build.lua | 0 plat/pc86/build.lua | 14 +++++++ util/misc/build.lua | 82 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 214 insertions(+), 5 deletions(-) create mode 100644 first/yacc.lua create mode 100644 mach/proto/as/build.lua create mode 100644 plat/build.lua create mode 100644 plat/pc86/build.lua create mode 100644 util/misc/build.lua diff --git a/build.lua b/build.lua index 86641357d..7b28b0d30 100644 --- a/build.lua +++ b/build.lua @@ -6,6 +6,7 @@ installable { "util/amisc+pkg", "util/arch+pkg", "util/misc+pkg", + "plat/pc86+pkg", } } diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 539b34897..c7184bc9f 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -375,6 +375,13 @@ local typeconverters = { return i end, + boolean = function(propname, i) + if (type(i) ~= "boolean") then + error(string.format("property '%s' must be a boolean", propname)) + end + return i + end, + string = function(propname, i) if (type(i) ~= "string") then error(string.format("property '%s' must be a string", propname)) @@ -410,7 +417,7 @@ local function definerule(rulename, types, cb) local args = {} for propname, typespec in pairs(types) do if not e[propname] then - if not typespec.optional and not typespec.default then + if not typespec.optional and (typespec.default == nil) then error(string.format("missing mandatory property '%s'", propname)) end diff --git a/first/build.lua b/first/build.lua index dcddaae90..31c790f13 100644 --- a/first/build.lua +++ b/first/build.lua @@ -62,10 +62,6 @@ definerule("cfile", end hdrpaths = uniquify(hdrpaths) - for _, f in pairs(filenamesof(hdeps)) do - hsrcs[#hsrcs+1] = f - end - local outleaf = basename(csrcs[1]):gsub("%.c$", ".o") return normalrule { @@ -84,6 +80,46 @@ definerule("cfile", end ) +definerule("cppfile", + { + srcs = { type="targets" }, + deps = { type="targets", default={} }, + outleaf = { type="string" }, + cflags = { type="strings", default={} }, + commands = { + type="strings", + default={ + "$(CC) -E -P -o %{outs[1]} %{hdrpaths} %{cflags} -x c %{ins}" + } + }, + }, + function (e) + if (#e.srcs ~= 1) then + error("you must have exactly one input file") + end + + local hdrpaths = {} + for _, t in pairs(e.deps) do + hdrpaths[#hdrpaths+1] = "-I"..t.dir + end + hdrpaths = uniquify(hdrpaths) + + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + deps = e.deps, + outleaves = {e.outleaf}, + label = e.label, + commands = e.commands, + vars = { + hdrpaths = hdrpaths, + cflags = e.cflags, + } + } + end +) + definerule("bundle", { srcs = { type="targets" }, diff --git a/first/yacc.lua b/first/yacc.lua new file mode 100644 index 000000000..bb308003e --- /dev/null +++ b/first/yacc.lua @@ -0,0 +1,23 @@ +definerule("yacc", + { + srcs = { type="targets" }, + commands = { + type="strings", + default={ + "yacc -t -b %{dir}/y -d %{ins}" + } + }, + }, + function (e) + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + outleaves = { "y.tab.c", "y.tab.h" }, + label = e.label, + commands = e.commands, + } + end +) + + diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua new file mode 100644 index 000000000..39e491813 --- /dev/null +++ b/mach/proto/as/build.lua @@ -0,0 +1,46 @@ +include("first/yacc.lua") + +definerule("build_as", + { + arch = { type="string" } + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local archlib = clibrary { + name = e.name.."/archlib", + srcs = {}, + hdrs = { "mach/"..e.arch.."/as/mach*.c" } + } + + local preprocessedy = cppfile { + name = e.name.."/yaccinput", + srcs = { "mach/proto/as/comm2.y" }, + outleaf = "comm2.y", + deps = { + "h+emheaders", + archlib, + }, + } + + local yaccfiles = yacc { + name = e.name.."/yacc", + srcs = { preprocessedy } + } + + return cprogram { + name = e.name, + srcs = { + "mach/proto/as/*.c", + yaccfiles, -- for .c file + }, + deps = { + "h+emheaders", + "modules/src/object+lib", + archlib, + yaccfiles, -- for .h file + } + } + end +) + diff --git a/plat/build.lua b/plat/build.lua new file mode 100644 index 000000000..e69de29bb diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua new file mode 100644 index 000000000..c3a70093e --- /dev/null +++ b/plat/pc86/build.lua @@ -0,0 +1,14 @@ +include("mach/proto/as/build.lua") + +build_as { + name = "as", + arch = "i86" +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/pc86/as"] = "+as" + } +} + diff --git a/util/misc/build.lua b/util/misc/build.lua new file mode 100644 index 000000000..ab0a26d7d --- /dev/null +++ b/util/misc/build.lua @@ -0,0 +1,82 @@ +cprogram { + name = "esize", + srcs = { "./esize.c" }, +} + +cprogram { + name = "encode", + srcs = { "./convert.c" }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/print+lib", + "modules/src/read_em+lib_ev", + "modules/src/string+lib", + "modules/src/system+lib", + "util/data+em_data", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_encode"] = "+encode", + ["$(INSDIR)/bin/esize"] = "+esize", + ["$(PLATIND)/man/man1/esize.1"] = "./esize.1", + ["$(PLATIND)/man/man6/em_decode.6"] = "./em_decode.6" + } +} + +--[[ +D := util/misc + +define build-misc-impl + $(call reset) + $(call cfile, $D/esize.c) + $(call cprogram, $(BINDIR)/esize) + $(call installto, $(INSDIR)/bin/esize) + + $(call reset) + $(eval q := $D/esize.1) + $(call installto, $(INSDIR)/share/man/man1/esize.1) + + $(call reset) + $(eval objdir := encode) + $(call cfile, $D/convert.c) + $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) + $(call rawfile, $(LIBREAD_EMEV)) + $(call rawfile, $(LIBEMK)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) + $(call cprogram, $(BINDIR)/em_encode) + $(call installto, $(PLATDEP)/em_encode) + $(eval EM_ENCODE := $o) + $(eval ACK_CORE_TOOLS += $o) + + $(call reset) + $(eval objdir := decode) + $(call cfile, $D/convert.c) + $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) + $(call rawfile, $(LIBREAD_EMKV)) + $(call rawfile, $(LIBEME)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) + $(call cprogram, $(BINDIR)/em_decode) + $(call installto, $(PLATDEP)/em_decode) + $(eval EM_DECODE := $o) + + $(call reset) + $(eval q := $D/em_decode.6) + $(call installto, $(INSDIR)/share/man/man6/em_decode.6) +endef + +$(eval $(build-misc-impl)) +--]] From a8a9d1bbfa9563beea01d6da1dd9efe947e1a7f2 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 26 Jul 2016 23:35:30 +0200 Subject: [PATCH 163/231] yacc, ncgg; platform ncg builds now. --- first/yacc.lua | 21 +++++++ h/build.lua | 1 + mach/proto/ncg/build.lua | 45 +++++++++++++++ plat/build.lua | 46 +++++++++++++++ plat/pc86/build.lua | 15 ++--- util/ncgg/build.lua | 122 +++++++++++++++++++++++++++++++++++++++ util/ncgg/cvtkeywords | 7 ++- 7 files changed, 243 insertions(+), 14 deletions(-) create mode 100644 mach/proto/ncg/build.lua create mode 100644 util/ncgg/build.lua diff --git a/first/yacc.lua b/first/yacc.lua index bb308003e..bffaeee4c 100644 --- a/first/yacc.lua +++ b/first/yacc.lua @@ -20,4 +20,25 @@ definerule("yacc", end ) +definerule("flex", + { + srcs = { type="targets" }, + commands = { + type="strings", + default={ + "flex -s -t %{ins} > %{outs[1]}" + } + } + }, + function (e) + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + outleaves = { "lex.yy.c" }, + label = e.label, + commands = e.commands + } + end +) diff --git a/h/build.lua b/h/build.lua index 7fd9d6728..db9400fdc 100644 --- a/h/build.lua +++ b/h/build.lua @@ -25,6 +25,7 @@ clibrary { name = "emheaders", hdrs = { "./*.h", + "./con_float", "+em_path", "+local", } diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua new file mode 100644 index 000000000..1553d3975 --- /dev/null +++ b/mach/proto/ncg/build.lua @@ -0,0 +1,45 @@ +include("util/ncgg/build.lua") + +definerule("build_ncg", + { + arch = { type="string" } + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local headers = clibrary { + name = e.name.."/headers", + srcs = {}, + hdrs = { + "mach/proto/ncg/*.h", + "mach/"..e.arch.."/ncg/mach*" + } + } + + local tables = ncgg { + name = e.name.."/tables", + srcs = { "mach/"..e.arch.."/ncg/table" } + } + + return cprogram { + name = e.name, + srcs = { + "mach/proto/ncg/*.c", + "mach/"..e.arch.."/ncg/mach.h", + archlib, -- for .c file + tables, -- for .c file + }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/flt_arith+lib", + "modules/src/object+lib", + "util/data+em_data", + archlib, -- for .h file + headers, + tables, -- for .h file + } + } + end +) + diff --git a/plat/build.lua b/plat/build.lua index e69de29bb..cd220bb9f 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -0,0 +1,46 @@ +include("mach/proto/as/build.lua") +include("mach/proto/ncg/build.lua") + +definerule("build_plat", + { + arch = { type = "string" }, + plat = { type = "string" }, + }, + function(e) + local descr = "plat/"..e.plat.."/descr" + + local as = build_as { + name = "as", + arch = e.arch + } + + local ncg = build_ncg { + name = "ncg", + arch = e.arch, + } + + local tools = installable { + name = "tools", + map = { + ["$(PLATDEP)/"..e.arch.."/as"] = as, + ["$(PLATDEP)/"..e.plat.."/ncg"] = ncg, + ["$(PLATIND)/descr/"..e.plat.."/descr"] = descr, + } + } + + local libraries = installable { + name = "libraries", + map = { + } + } + + return installable { + name = e.name, + map = { + tools, + libraries, + } + } + end +) + diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua index c3a70093e..5976b8933 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build.lua @@ -1,14 +1,7 @@ -include("mach/proto/as/build.lua") +include("plat/build.lua") -build_as { - name = "as", - arch = "i86" -} - -installable { +build_plat { name = "pkg", - map = { - ["$(PLATDEP)/pc86/as"] = "+as" - } + arch = "i86", + plat = "pc86", } - diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua new file mode 100644 index 000000000..110272b8b --- /dev/null +++ b/util/ncgg/build.lua @@ -0,0 +1,122 @@ +include("first/yacc.lua") + +local cggparser = yacc { + name = "cggparser", + srcs = { "./cgg.y" } +} + +flex { + name = "cgglexer", + srcs = { "./scan.l" } +} + +normalrule { + name = "keywords", + ins = { + "./cvtkeywords", + "./keywords", + unpack(filenamesof({cggparser}, "%.h$")) + }, + outleaves = { "enterkeyw.c" }, + commands = { + "%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" + } +} + +cprogram { + name = "ncgg", + srcs = { + "./*.c", + "+cggparser", -- for .c file + "+cgglexer", -- for .c file + "+keywords", + }, + deps = { + "+cggparser", -- for .h file + "+cgglexer", -- for .h file + "h+emheaders", + "util/data+em_data", + } +} + +definerule("ncgg", + { + srcs = { type="targets" } + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + if (#e.srcs ~= 1) then + error("you must supply exactly one input file") + end + + local cpptable = cppfile { + name = e.name.."/cpptable", + outleaf = "cpptable", + srcs = e.srcs + } + + return normalrule { + name = e.name, + cwd = e.cwd, + outleaves = { + "tables.c", + "tables.h", + }, + ins = { + "util/ncgg+ncgg", + cpptable + }, + commands = { + "cd %{dir} && %{ins}", + "mv %{dir}/tables.H %{dir}/tables.h" + } + } + end +) + +--[[ +D := util/ncgg + +define build-ncgg-impl + +$(call reset) +$(eval cflags += -I$D) + +$(call yacc, $(OBJDIR)/$D, $D/cgg.y) + +$(call flex, $(OBJDIR)/$D, $D/scan.l) +$(call dependson, $(OBJDIR)/$D/y.tab.h) + +$(call cfile, $D/subr.c) +$(call cfile, $D/main.c) +$(call cfile, $D/coerc.c) +$(call cfile, $D/error.c) +$(call cfile, $D/emlookup.c) +$(call cfile, $D/expr.c) +$(call cfile, $D/instruct.c) +$(call cfile, $D/iocc.c) +$(call cfile, $D/lookup.c) +$(call cfile, $D/output.c) +$(call cfile, $D/set.c) +$(call cfile, $D/strlookup.c) +$(call cfile, $D/var.c) +$(call cfile, $D/hall.c) + +$(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c) +$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(OBJDIR)/$D/y.tab.h + @echo KEYWORDS $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) +$(call cfile, $(OBJDIR)/$D/enterkeyw.c) + +$(eval $q: $(INCDIR)/em_spec.h) + +$(call rawfile, $(LIBEM_DATA)) +$(call cprogram, $(BINDIR)/ncgg) +$(eval NCGG := $o) + +endef + +$(eval $(build-ncgg-impl)) +--]] diff --git a/util/ncgg/cvtkeywords b/util/ncgg/cvtkeywords index 85b7e035c..a478b3f1a 100755 --- a/util/ncgg/cvtkeywords +++ b/util/ncgg/cvtkeywords @@ -1,8 +1,8 @@ #!/bin/sh : '$Id$' -grep '^#' y.tab.h >tokendefs -ed -s $1 <<'!Funky!Stuff!' +grep '^#' $2 >tokendefs +ed -s $1 > $3 <<'!Funky!Stuff!' g/^#/d 1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/ 1i @@ -18,7 +18,8 @@ enterkeyw() { $a } . -w enterkeyw.c +,p q !Funky!Stuff! rm tokendefs + From cdeea836f2888a878c50ed6ee183ca33991c777b Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 26 Jul 2016 23:43:31 +0200 Subject: [PATCH 164/231] Replaced the fairly complex environment code with a much simpler emitter object. --- first/ackbuilder.lua | 50 +++++++++++++++++++++----------------------- util/ncgg/build.lua | 46 ---------------------------------------- 2 files changed, 24 insertions(+), 72 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index c7184bc9f..fa56a8474 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -9,7 +9,7 @@ local posix = require("posix") -- is = { set of rule types which made the target } -- } -local environment = {} +local emitter = {} local rules = {} local targets = {} local buildfiles = {} @@ -433,7 +433,6 @@ local function definerule(rulename, types, cb) error(string.format("don't know what to do with property '%s'", propname)) end - args.environment = environment if not args.cwd then args.cwd = cwd end @@ -465,9 +464,9 @@ end -- DEFAULT RULES -- ----------------------------------------------------------------------------- -local function install_make_environment() +local function install_make_emitter() emit("hide = @\n") - function environment:rule(name, ins, outs) + function emitter:rule(name, ins, outs) emit(".INTERMEDIATE:", name, "\n") for i = 1, #ins do emit(name..":", ins[i], "\n") @@ -483,28 +482,28 @@ local function install_make_environment() end end - function environment:phony(name, ins, outs) + function emitter:phony(name, ins, outs) emit(".PHONY:", name, "\n") self:rule(name, ins, outs) end - function environment:label(...) + function emitter:label(...) local s = table.concat({...}, " ") emit("\t@echo", s, "\n") end - function environment:exec(commands) + function emitter:exec(commands) for _, s in ipairs(commands) do emit("\t$(hide)", s, "\n") end end - function environment:endrule() + function emitter:endrule() emit("\n") end end -local function install_ninja_environment() +local function install_ninja_emitter() emit("rule build\n") emit(" command = $command\n") emit("\n") @@ -521,7 +520,7 @@ local function install_ninja_environment() ) end - function environment:rule(name, ins, outs) + function emitter:rule(name, ins, outs) if (#outs == 0) then emit("build", name, ": phony", unmake(ins), "\n") else @@ -530,14 +529,14 @@ local function install_ninja_environment() end end - function environment:label(...) + function emitter:label(...) end - function environment:exec(commands) + function emitter:exec(commands) emit(" command =", table.concat(unmake(commands), " && "), "\n") end - function environment:endrule() + function emitter:endrule() emit("\n") end end @@ -552,18 +551,18 @@ definerule("simplerule", vars = { type="table", default={} }, }, function (e) - e.environment:rule(e.fullname, + emitter:rule(e.fullname, concat(filenamesof(e.ins), filenamesof(e.deps)), e.outs) - e.environment:label(e.fullname, " ", e.label or "") + emitter:label(e.fullname, " ", e.label or "") local vars = inherit(e.vars, { ins = e.ins, outs = e.outs }) - e.environment:exec(templateexpand(e.commands, vars)) - e.environment:endrule() + emitter:exec(templateexpand(e.commands, vars)) + emitter:endrule() return { outs = e.outs @@ -600,12 +599,12 @@ definerule("installable", end end - e.environment:rule(e.fullname, deps, dests) - e.environment:label(e.fullname, " ", e.label or "") + emitter:rule(e.fullname, deps, dests) + emitter:label(e.fullname, " ", e.label or "") if (#commands > 0) then - e.environment:exec(commands) + emitter:exec(commands) end - e.environment:endrule() + emitter:endrule() end ) @@ -670,7 +669,6 @@ globals = { definerule = definerule, dirname = dirname, emit = emit, - environment = environment, filenamesof = filenamesof, fpairs = fpairs, include = loadbuildfile, @@ -695,16 +693,16 @@ setmetatable(globals, ) do - local environment_type = install_make_environment + local emitter_type = install_make_emitter parse_arguments( { ["make"] = function() - environment_type = install_make_environment + emitter_type = install_make_emitter return 1 end, ["ninja"] = function() - environment_type = install_ninja_environment + emitter_type = install_ninja_emitter return 1 end, @@ -713,7 +711,7 @@ do end, [" files"] = function(files) - environment_type() + emitter_type() for _, f in ipairs(files) do loadbuildfile(f) end diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index 110272b8b..e583963a2 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -74,49 +74,3 @@ definerule("ncgg", } end ) - ---[[ -D := util/ncgg - -define build-ncgg-impl - -$(call reset) -$(eval cflags += -I$D) - -$(call yacc, $(OBJDIR)/$D, $D/cgg.y) - -$(call flex, $(OBJDIR)/$D, $D/scan.l) -$(call dependson, $(OBJDIR)/$D/y.tab.h) - -$(call cfile, $D/subr.c) -$(call cfile, $D/main.c) -$(call cfile, $D/coerc.c) -$(call cfile, $D/error.c) -$(call cfile, $D/emlookup.c) -$(call cfile, $D/expr.c) -$(call cfile, $D/instruct.c) -$(call cfile, $D/iocc.c) -$(call cfile, $D/lookup.c) -$(call cfile, $D/output.c) -$(call cfile, $D/set.c) -$(call cfile, $D/strlookup.c) -$(call cfile, $D/var.c) -$(call cfile, $D/hall.c) - -$(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c) -$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(OBJDIR)/$D/y.tab.h - @echo KEYWORDS $$@ - @mkdir -p $$(dir $$@) - $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) -$(call cfile, $(OBJDIR)/$D/enterkeyw.c) - -$(eval $q: $(INCDIR)/em_spec.h) - -$(call rawfile, $(LIBEM_DATA)) -$(call cprogram, $(BINDIR)/ncgg) -$(eval NCGG := $o) - -endef - -$(eval $(build-ncgg-impl)) ---]] From f9c77fca03a49a1d777f12ef01ab273eb89c3bf5 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 27 Jul 2016 00:10:15 +0200 Subject: [PATCH 165/231] Replace the hacky cflags variable with an equally hacky but vastly more useful magic vars variable. --- build.lua | 4 +++ first/ackbuilder.lua | 46 ++++++++++++++++++++++++++--------- first/build.lua | 13 ++-------- modules/src/em_code/build.lua | 8 +++--- modules/src/read_em/build.lua | 12 +++++---- util/LLgen/build.lua | 7 +++++- 6 files changed, 58 insertions(+), 32 deletions(-) diff --git a/build.lua b/build.lua index 7b28b0d30..cc483e438 100644 --- a/build.lua +++ b/build.lua @@ -1,3 +1,7 @@ +vars.cflags = { + "-g", "-O" +} + installable { name = "ack", map = { diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index fa56a8474..05772af2e 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -15,6 +15,18 @@ local targets = {} local buildfiles = {} local globals local cwd = "." +local vars = {} +local parente = {} + +local function concat(...) + local r = {} + for k, t in ipairs({...}) do + for _, v in ipairs(t) do + r[#r+1] = v + end + end + return r +end local function inherit(high, low) local o = {} @@ -27,6 +39,12 @@ local function inherit(high, low) return low[k] end }) + for k, v in pairs(high) do + local _, _, kk = k:find("^%+(.*)$") + if kk then + o[kk] = concat(low[kk], v) + end + end return o end @@ -53,16 +71,6 @@ local function asstring(o) end end -local function concat(...) - local r = {} - for _, t in ipairs({...}) do - for _, v in ipairs(t) do - r[#r+1] = v - end - end - return r -end - local function concatpath(...) local p = table.concat({...}, "/") return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/")) @@ -404,6 +412,7 @@ local function definerule(rulename, types, cb) types.name = { type="string" } types.cwd = { type="string", optional=true } + types.vars = { type="table", default={} } for propname, typespec in pairs(types) do if not typeconverters[typespec.type] then @@ -414,6 +423,11 @@ local function definerule(rulename, types, cb) local rulecwd = cwd local rule = function(e) + local definedprops = {} + for propname, _ in pairs(e) do + definedprops[propname] = true + end + local args = {} for propname, typespec in pairs(types) do if not e[propname] then @@ -424,11 +438,11 @@ local function definerule(rulename, types, cb) args[propname] = typespec.default else args[propname] = typeconverters[typespec.type](propname, e[propname]) - e[propname] = nil + definedprops[propname] = nil end end - local propname, _ = next(e) + local propname, _ = next(definedprops) if propname then error(string.format("don't know what to do with property '%s'", propname)) end @@ -438,7 +452,11 @@ local function definerule(rulename, types, cb) end args.fullname = args.cwd.."+"..args.name + local oldparente = parente + parente = args + args.vars = inherit(args.vars, oldparente.vars) local result = cb(args) or {} + parente = oldparente result.is = result.is or {} result.is[rulename] = true @@ -678,6 +696,7 @@ globals = { startswith = startswith, targetnamesof = targetnamesof, uniquify = uniquify, + vars = vars, } setmetatable(globals, { @@ -692,6 +711,9 @@ setmetatable(globals, } ) +vars.cflags = {} +parente.vars = vars + do local emitter_type = install_make_emitter parse_arguments( diff --git a/first/build.lua b/first/build.lua index 31c790f13..e514384b9 100644 --- a/first/build.lua +++ b/first/build.lua @@ -10,7 +10,6 @@ definerule("normalrule", label = { type="string", optional=true }, objdir = { type="string", optional=true }, commands = { type="strings" }, - vars = { type="table", default={} }, }, function (e) local dir = e.objdir or objdir(e) @@ -41,7 +40,6 @@ definerule("cfile", { srcs = { type="targets" }, deps = { type="targets", default={} }, - cflags = { type="strings", default={} }, commands = { type="strings", default={ @@ -74,7 +72,6 @@ definerule("cfile", commands = e.commands, vars = { hdrpaths = hdrpaths, - cflags = e.cflags, } } end @@ -85,7 +82,6 @@ definerule("cppfile", srcs = { type="targets" }, deps = { type="targets", default={} }, outleaf = { type="string" }, - cflags = { type="strings", default={} }, commands = { type="strings", default={ @@ -114,7 +110,6 @@ definerule("cppfile", commands = e.commands, vars = { hdrpaths = hdrpaths, - cflags = e.cflags, } } end @@ -155,7 +150,6 @@ definerule("clibrary", srcs = { type="targets", default={} }, hdrs = { type="targets", default={} }, deps = { type="targets", default={} }, - cflags = { type="strings", default={} }, commands = { type="strings", default={ @@ -176,9 +170,8 @@ definerule("clibrary", cwd = e.cwd, srcs = {csrc, unpack(hsrcs)}, deps = e.deps, - cflags = { - "-I"..e.cwd, - unpack(e.cflags) + vars = { + ["+cflags"] = { "-I"..e.cwd, }, }, } end @@ -212,7 +205,6 @@ definerule("cprogram", { srcs = { type="targets", default={} }, deps = { type="targets", default={} }, - cflags = { type="strings", default={} }, commands = { type="strings", default={ @@ -230,7 +222,6 @@ definerule("cprogram", cwd = e.cwd, srcs = e.srcs, deps = e.deps, - cflags = e.cflags, } }, "%.a$" diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua index 80ea28a8b..b530f2a51 100644 --- a/modules/src/em_code/build.lua +++ b/modules/src/em_code/build.lua @@ -79,10 +79,12 @@ local function build_variant(code, cflags) "modules/src/system+lib", "util/data+em_data", }, - cflags = { cflags } + vars = { + ["+cflags"] = cflags + }, } end -build_variant("e", "-DREADABLE_EM") -build_variant("k", "") +build_variant("e", { "-DREADABLE_EM" }) +build_variant("k", { }) diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua index 860f29df1..d80d0569c 100644 --- a/modules/src/read_em/build.lua +++ b/modules/src/read_em/build.lua @@ -27,11 +27,13 @@ normalrule { clibrary { name = "lib_ev", - cflags = { - "-DPRIVATE=static", - "-DEXPORT=", - "-DNDEBUG", - "-DCHECKING" + vars = { + ["+cflags"] = { + "-DPRIVATE=static", + "-DEXPORT=", + "-DNDEBUG", + "-DCHECKING" + }, }, srcs = { "./EM_vars.c", diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua index fd60daa59..5939332d4 100644 --- a/util/LLgen/build.lua +++ b/util/LLgen/build.lua @@ -6,7 +6,12 @@ cprogram { -- do this. srcs = { "./src/*.c" }, - cflags = { "-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"", "-DNON_CORRECTING" }, + vars = { + ["+cflags"] = { + "-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"", + "-DNON_CORRECTING" + }, + } } definerule("llgen", From c6292642c6e3b7e933c5919fac5cd11558a56d5c Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 29 Jul 2016 00:22:22 +0200 Subject: [PATCH 166/231] Fix a nasty dependency bug where filenamesof() on installables wouldn't return any of the installable files (which meant installables were never considered as dependencies). --- first/ackbuilder.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 05772af2e..49937d168 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -18,6 +18,16 @@ local cwd = "." local vars = {} local parente = {} +local function print(...) + for _, s in ipairs({...}) do + if (type(s) ~= "string") then + s = tostring(s) + end + io.stderr:write(s) + end + io.stderr:write("\n") +end + local function concat(...) local r = {} for k, t in ipairs({...}) do @@ -459,7 +469,9 @@ local function definerule(rulename, types, cb) parente = oldparente result.is = result.is or {} - result.is[rulename] = true + if rulename then + result.is[rulename] = true + end result.fullname = args.fullname if targets[arg.fullname] and (targets[arg.fullname] ~= result) then @@ -623,6 +635,10 @@ definerule("installable", emitter:exec(commands) end emitter:endrule() + + return { + outs = dests + } end ) @@ -691,6 +707,7 @@ globals = { fpairs = fpairs, include = loadbuildfile, inherit = inherit, + print = print, replace = replace, selectof = selectof, startswith = startswith, From 363d13cc2f063568c5a2dd53c5db3ba07055b19c Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 29 Jul 2016 00:22:49 +0200 Subject: [PATCH 167/231] C preprocessor; tabgen; now the pc86 boot.s builds using the ack toolchain. --- build.lua | 3 + first/build.lua | 14 ++-- h/build.lua | 2 +- lang/cem/cemcom.ansi/build.lua | 120 --------------------------------- lang/cem/cpp.ansi/build.lua | 110 ++++++++++++++++++++++++++++++ plat/build.lua | 48 +++++++------ plat/pc86/build.lua | 19 +++++- util/cmisc/build.lua | 25 +++++++ 8 files changed, 190 insertions(+), 151 deletions(-) create mode 100644 lang/cem/cpp.ansi/build.lua create mode 100644 util/cmisc/build.lua diff --git a/build.lua b/build.lua index cc483e438..9db83f5cd 100644 --- a/build.lua +++ b/build.lua @@ -1,6 +1,9 @@ vars.cflags = { "-g", "-O" } +vars.ackcflags = { + "-O" +} installable { name = "ack", diff --git a/first/build.lua b/first/build.lua index e514384b9..6a8bc4c93 100644 --- a/first/build.lua +++ b/first/build.lua @@ -48,24 +48,20 @@ definerule("cfile", } }, function (e) - local csrcs = filenamesof(e.srcs, "%.c$") - if (#csrcs ~= 1) then - error("you must have exactly one .c file") - end - - local hsrcs = filenamesof(e.srcs, "%.h$") local hdrpaths = {} for _, t in pairs(e.deps) do - hdrpaths[#hdrpaths+1] = "-I"..t.dir + if t.dir then + hdrpaths[#hdrpaths+1] = "-I"..t.dir + end end hdrpaths = uniquify(hdrpaths) - local outleaf = basename(csrcs[1]):gsub("%.c$", ".o") + local outleaf = basename(e.name)..".o" return normalrule { name = e.name, cwd = e.cwd, - ins = {csrcs[1]}, + ins = e.srcs, deps = e.deps, outleaves = {outleaf}, label = e.label, diff --git a/h/build.lua b/h/build.lua index db9400fdc..4249c1e55 100644 --- a/h/build.lua +++ b/h/build.lua @@ -3,7 +3,7 @@ normalrule { ins = {}, outleaves = { "em_path.h" }, commands = { - "echo '#define TMP_DIR \"$(ACK_TEMP_DIR)\"' > %{outs}", + "echo '#define TMP_DIR \"/tmp\"' > %{outs}", "echo '#define EM_DIR \"$(PREFIX)\"' >> %{outs}", "echo '#define ACK_PATH \"share/ack/descr\"' >> %{outs}", } diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index ff07e4b36..f402bd697 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -135,123 +135,3 @@ installable { ["$(PLATDEP)/em_cemcom.ansi"] = "+cemcom" } } ---[[ - -D := lang/cem/cemcom.ansi - -define build-cemcom-ansi-allocd-header -$(eval g := $(OBJDIR)/$D/$(strip $1).h) -$g: $D/$(strip $1).str $D/make.allocd - @echo ALLOCD $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.allocd < $$^ > $$@ - -$(eval CLEANABLES += $g) -$(eval $q: $g) -endef - -define build-cemcom-ansi-next -$(eval CLEANABLES += $(OBJDIR)/$D/next.c) -$(OBJDIR)/$D/next.c: $D/make.next $1 - @echo NEXT $$@ - @mkdir -p $$(dir $$@) - $(hide) $$^ > $$@ -$(call cfile, $(OBJDIR)/$D/next.c) - -$(foreach f, $1, $(call build-cemcom-ansi-allocd-header, \ - $(basename $(notdir $f)))) -endef - -define build-cemcom-ansi-impl - -$(call reset) -$(eval cflags += -I$(OBJDIR)/$D -I$D) - -$(call cfile, $D/arith.c) -$(call dependson, $(INCDIR)/flt_arith.h) - -$(call cfile, $D/blocks.c) -$(call dependson, $(INCDIR)/em_codeEK.h) - -$(call cfile, $D/LLlex.c) -$(call cfile, $D/LLmessage.c) - - -$(call llgen, $(OBJDIR)/$D, \ - $(OBJDIR)/$D/tokenfile.g \ - $D/program.g \ - $D/declar.g \ - $D/expression.g \ - $D/statement.g \ - $D/ival.g) - -$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) -$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c - @echo TOKENFILE $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ - -$(call tabgen, $D/char.tab) - -$(eval $q: $(OBJDIR)/$D/parameters.h) - -$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) -$(OBJDIR)/$D/parameters.h: $D/BigPars - @echo PARAMETERS $$@ - @mkdir -p $$(dir $$@) - $(hide) echo '#ifndef PARAMETERS_H' > $$@ - $(hide) echo '#define PARAMETERS_H' >> $$@ - $(hide) grep -v '^!' < $D/BigPars >> $$@ - $(hide) echo '#endif' >> $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) -$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c - @echo TOKCASE $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.tokcase < $D/tokenname.c > $$@ -$(call cfile, $(OBJDIR)/$D/symbol2str.c) - -$(call build-cemcom-ansi-next, \ - $D/code.str \ - $D/declar.str \ - $D/def.str \ - $D/expr.str \ - $D/field.str \ - $D/estack.str \ - $D/util.str \ - $D/proto.str \ - $D/replace.str \ - $D/idf.str \ - $D/macro.str \ - $D/stack.str \ - $D/stmt.str \ - $D/struct.str \ - $D/switch.str \ - $D/type.str \ - $D/l_brace.str \ - $D/l_state.str \ - $D/l_outdef.str) - -$(eval $q: $(OBJDIR)/$D/Lpars.h) - -$(call rawfile, $(LIBEM_MES)) -$(call rawfile, $(LIBEMK)) -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBINPUT)) -$(call rawfile, $(LIBASSERT)) -$(call rawfile, $(LIBALLOC)) -$(call rawfile, $(LIBFLT_ARITH)) -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBSYSTEM)) -$(call rawfile, $(LIBSTRING)) -$(call cprogram, $(BINDIR)/cemcom.ansi) -$(call installto, $(PLATDEP)/em_cemcom.ansi) -$(eval CEMCOMANSI := $o) - -$(call reset) -$(eval q := $D/cemcom.ansi.1) -$(call installto, $(INSDIR)/share/man/man1/cemcom.6) -endef - -$(eval $(build-cemcom-ansi-impl)) ---]] diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua new file mode 100644 index 000000000..ee3275a51 --- /dev/null +++ b/lang/cem/cpp.ansi/build.lua @@ -0,0 +1,110 @@ +include("util/cmisc/build.lua") + +local allocd_header = definerule(null, + { + srcs = { type="targets" } + }, + function (e) + return normalrule { + name = e.name, + ins = { + "./make.allocd", + unpack(e.srcs) + }, + outleaves = replace(basename(e.srcs), "%.str$", ".h"), + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } + end +) + +allocd_header { + name = "macro_h", + srcs = { "./macro.str" } +} + +allocd_header { + name = "replace_h", + srcs = { "./replace.str" } +} + +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c", + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.str", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +llgen { + name = "llgen", + srcs = { + "+tokenfile_g", + "./expression.g" + } +} + +tabgen { + name = "tabgen_c", + srcs = { "./char.tab" } +} + +cprogram { + name = "cpp", + srcs = { + "./*.c", + "+llgen", + "+next_c", + "+symbol2str_c", + "+tabgen_c", + }, + deps = { + "+llgen", + "+macro_h", + "+replace_h", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/cpp.ansi"] = "+cpp" + } +} + diff --git a/plat/build.lua b/plat/build.lua index cd220bb9f..b8b457c0d 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -1,7 +1,32 @@ include("mach/proto/as/build.lua") include("mach/proto/ncg/build.lua") -definerule("build_plat", +definerule("ackfile", + { + srcs = { type="targets" }, + deps = { type="targets", default={} }, + }, + function (e) + local plat = e.vars.plat + + return cfile { + name = e.name, + srcs = e.srcs, + deps = { + "plat/"..plat.."+tools", + "util/ack+pkg", + "lang/cem/cpp.ansi+pkg", + unpack(e.deps) + }, + commands = { + "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -c -o %{outs} %{ins} %{hdrpaths} %{ackcflags}" + } + } + end +) + + +definerule("build_plat_tools", { arch = { type = "string" }, plat = { type = "string" }, @@ -19,28 +44,13 @@ definerule("build_plat", arch = e.arch, } - local tools = installable { - name = "tools", - map = { - ["$(PLATDEP)/"..e.arch.."/as"] = as, - ["$(PLATDEP)/"..e.plat.."/ncg"] = ncg, - ["$(PLATIND)/descr/"..e.plat.."/descr"] = descr, - } - } - - local libraries = installable { - name = "libraries", - map = { - } - } - return installable { name = e.name, map = { - tools, - libraries, + ["$(PLATDEP)/"..e.plat.."/as"] = as, + ["$(PLATDEP)/"..e.plat.."/ncg"] = ncg, + ["$(PLATIND)/descr/"..e.plat] = descr, } } end ) - diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua index 5976b8933..baef77e7e 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build.lua @@ -1,7 +1,22 @@ include("plat/build.lua") -build_plat { - name = "pkg", +build_plat_tools { + name = "tools", arch = "i86", plat = "pc86", } + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "pc86" } +} + +installable { + name = "pkg", + map = { + "+tools", + ["$(PLATIND)/pc86/boot.o"] = "+boot" + } +} + diff --git a/util/cmisc/build.lua b/util/cmisc/build.lua new file mode 100644 index 000000000..8ffe24a36 --- /dev/null +++ b/util/cmisc/build.lua @@ -0,0 +1,25 @@ +cprogram { + name = "tabgen", + srcs = { "./tabgen.c" } +} + +definerule("tabgen", + { + srcs = { type="targets" }, + }, + function(e) + local symname = replace(basename(e.srcs[1]), "%.tab$", "") + + return normalrule { + name = e.name, + ins = { + "util/cmisc+tabgen", + unpack(e.srcs) + }, + outleaves = { symname..".c" }, + commands = { + "%{ins[1]} -f%{ins[2]} > %{outs} || rm %{outs}" + } + } + end +) From b2bb4ce3b28634135c6acc6f692df67e1869d847 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 30 Jul 2016 00:39:22 +0200 Subject: [PATCH 168/231] Builds libend (the simplest library). Becoming obvious I need to rework the way ackbuilder deals with lists. --- Makefile | 2 +- build.lua | 3 +++ first/ackbuilder.lua | 14 +++++++++--- first/build.lua | 12 +++++------ lang/cem/cpp.ansi/build.lua | 10 ++++----- mach/i86/libend/build.lua | 8 +++++++ mach/proto/as/build.lua | 8 +++---- plat/build.lua | 43 +++++++++++++++++++++++++++++++++++-- plat/pc86/build.lua | 7 ++++++ util/ack/build.lua | 1 - util/data/build.lua | 8 +++---- util/ncgg/build.lua | 18 ++++++++-------- 12 files changed, 98 insertions(+), 36 deletions(-) create mode 100644 mach/i86/libend/build.lua diff --git a/Makefile b/Makefile index a8381b487..78d3f9c2b 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ $(BUILDDIR)/build.ninja: Makefile else $(MAKECMDGOALS): $(BUILDDIR)/rules.mk - @make -r -f $(BUILDDIR)/rules.mk $@ \ + +@make -r -f $(BUILDDIR)/rules.mk $@ \ $(MAKEFLAGS) \ OBJDIR=$(OBJDIR) \ BINDIR=$(BINDIR) \ diff --git a/build.lua b/build.lua index 9db83f5cd..200744a4c 100644 --- a/build.lua +++ b/build.lua @@ -4,6 +4,9 @@ vars.cflags = { vars.ackcflags = { "-O" } +vars.plats = { + "pc86" +} installable { name = "ack", diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 49937d168..1330f53cd 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -30,9 +30,13 @@ end local function concat(...) local r = {} - for k, t in ipairs({...}) do - for _, v in ipairs(t) do - r[#r+1] = v + for _, t in ipairs({...}) do + if (type(t) == "table") and not t.is then + for _, v in ipairs(t) do + r[#r+1] = v + end + else + r[#r+1] = t end end return r @@ -413,6 +417,10 @@ local typeconverters = { end return i end, + + object = function(propname, i) + return i + end, } local function definerule(rulename, types, cb) diff --git a/first/build.lua b/first/build.lua index 6a8bc4c93..192f512e1 100644 --- a/first/build.lua +++ b/first/build.lua @@ -146,6 +146,7 @@ definerule("clibrary", srcs = { type="targets", default={} }, hdrs = { type="targets", default={} }, deps = { type="targets", default={} }, + _cfile = { type="object", default=cfile }, commands = { type="strings", default={ @@ -155,16 +156,13 @@ definerule("clibrary", } }, function (e) - local csrcs = filenamesof(e.srcs, "%.c$") - local hsrcs = filenamesof(e.srcs, "%.h$") - local ins = {} - for _, csrc in fpairs(csrcs) do - local n = basename(csrc):gsub("%.%w*$", "") - ins[#ins+1] = cfile { + for _, src in fpairs(e.srcs) do + local n = basename(src):gsub("%.%w*$", "") + ins[#ins+1] = e._cfile { name = e.name.."/"..n, cwd = e.cwd, - srcs = {csrc, unpack(hsrcs)}, + srcs = {src}, deps = e.deps, vars = { ["+cflags"] = { "-I"..e.cwd, }, diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index ee3275a51..85d92b925 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -65,7 +65,7 @@ normalrule { } } -llgen { +local llgen = llgen { name = "llgen", srcs = { "+tokenfile_g", @@ -80,13 +80,13 @@ tabgen { cprogram { name = "cpp", - srcs = { + srcs = concat( "./*.c", - "+llgen", + filenamesof(llgen, "%.c$"), "+next_c", "+symbol2str_c", - "+tabgen_c", - }, + "+tabgen_c" + ), deps = { "+llgen", "+macro_h", diff --git a/mach/i86/libend/build.lua b/mach/i86/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua index 39e491813..89731351c 100644 --- a/mach/proto/as/build.lua +++ b/mach/proto/as/build.lua @@ -30,15 +30,15 @@ definerule("build_as", return cprogram { name = e.name, - srcs = { + srcs = concat( "mach/proto/as/*.c", - yaccfiles, -- for .c file - }, + filenamesof(yaccfiles, "%.c$") + ), deps = { "h+emheaders", "modules/src/object+lib", archlib, - yaccfiles, -- for .h file + yaccfiles } } end diff --git a/plat/build.lua b/plat/build.lua index b8b457c0d..7febb9ada 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -25,11 +25,33 @@ definerule("ackfile", end ) +definerule("acklibrary", + { + srcs = { type="targets", default={} }, + hdrs = { type="targets", default={} }, + deps = { type="targets", default={} }, + }, + function (e) + return clibrary { + name = e.name, + srcs = e.srcs, + hdrs = e.hdrs, + deps = { + "util/arch+pkg", + unpack(e.deps) + }, + _cfile = ackfile, + commands = { + "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal q %{outs[1]} %{ins}" + } + } + end +) definerule("build_plat_tools", { - arch = { type = "string" }, - plat = { type = "string" }, + arch = { type="string" }, + plat = { type="string" }, }, function(e) local descr = "plat/"..e.plat.."/descr" @@ -54,3 +76,20 @@ definerule("build_plat_tools", } end ) + +definerule("build_plat_libs", + { + arch = { type="string" }, + plat = { type="string" }, + }, + function(e) + return installable { + name = e.name, + map = { + ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat + } + } + end +) + + diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua index baef77e7e..c293a4ea6 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build.lua @@ -12,10 +12,17 @@ ackfile { vars = { plat = "pc86" } } +build_plat_libs { + name = "libs", + arch = "i86", + plat = "pc86", +} + installable { name = "pkg", map = { "+tools", + "+libs", ["$(PLATIND)/pc86/boot.o"] = "+boot" } } diff --git a/util/ack/build.lua b/util/ack/build.lua index dc46d44a8..4394484b4 100644 --- a/util/ack/build.lua +++ b/util/ack/build.lua @@ -19,7 +19,6 @@ cprogram { name = "ack", srcs = { "./*.c", - "./*.h", "+tables", }, deps = { diff --git a/util/data/build.lua b/util/data/build.lua index 784e1d6ac..5c9f0b3f8 100644 --- a/util/data/build.lua +++ b/util/data/build.lua @@ -1,4 +1,4 @@ -normalrule { +local generated = normalrule { name = "generated", ins = { "./new_table", @@ -22,10 +22,10 @@ normalrule { clibrary { name = "em_data", - srcs = { + srcs = concat( "./em_ptyp.c", - "+generated", -- so we build the C files - }, + filenamesof(generated, "%.c$") + ), hdrs = { "+generated" -- so we export the H files }, diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index e583963a2..57d9e4753 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -5,18 +5,18 @@ local cggparser = yacc { srcs = { "./cgg.y" } } -flex { +local cgglexer = flex { name = "cgglexer", srcs = { "./scan.l" } } normalrule { name = "keywords", - ins = { + ins = concat( "./cvtkeywords", "./keywords", - unpack(filenamesof({cggparser}, "%.h$")) - }, + filenamesof({cggparser}, "%.h$") + ), outleaves = { "enterkeyw.c" }, commands = { "%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" @@ -25,12 +25,12 @@ normalrule { cprogram { name = "ncgg", - srcs = { + srcs = concat( "./*.c", - "+cggparser", -- for .c file - "+cgglexer", -- for .c file - "+keywords", - }, + filenamesof({cggparser}, "%.c$"), + filenamesof({cgglexer}, "%.c$"), + "+keywords" + ), deps = { "+cggparser", -- for .h file "+cgglexer", -- for .h file From 5e84be70fd703ff42558adee78d6e581a2d2a7fd Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 4 Aug 2016 23:51:19 +0200 Subject: [PATCH 169/231] Massive ackbuilder refactor --- cleaner and more expressive. Lists are automatically flattened (leading to better build files), and the list and filename functions are vastly more orthogonal. --- first/ackbuilder.lua | 274 +++++++++++++++++++-------------- first/build.lua | 32 ++-- lang/cem/cemcom.ansi/build.lua | 5 +- lang/cem/cpp.ansi/build.lua | 6 +- mach/proto/as/build.lua | 2 +- mach/proto/ncg/build.lua | 1 - plat/build.lua | 5 +- util/LLgen/build.lua | 6 +- util/cmisc/build.lua | 4 +- util/data/build.lua | 2 +- util/ncgg/build.lua | 10 +- 11 files changed, 198 insertions(+), 149 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 1330f53cd..1a150cb4a 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -18,27 +18,51 @@ local cwd = "." local vars = {} local parente = {} +-- Forward references +local loadtarget + local function print(...) - for _, s in ipairs({...}) do - if (type(s) ~= "string") then - s = tostring(s) + local function print_no_nl(list) + for _, s in ipairs(list) do + if (type(s) == "table") then + io.stderr:write("{") + for k, v in pairs(s) do + print_no_nl({k}) + io.stderr:write("=") + print_no_nl({v}) + io.stderr:write(" ") + end + io.stderr:write("}") + else + io.stderr:write(tostring(s)) + end end - io.stderr:write(s) end + + print_no_nl({...}) io.stderr:write("\n") end +local function assertString(s, i) + if (type(s) ~= "string") then + error(string.format("parameter %d must be a string", i)) + end +end + local function concat(...) local r = {} - for _, t in ipairs({...}) do - if (type(t) == "table") and not t.is then - for _, v in ipairs(t) do - r[#r+1] = v + + local function process(list) + for _, t in ipairs(list) do + if (type(t) == "table") and not t.is then + process(t) + else + r[#r+1] = t end - else - r[#r+1] = t end end + process({...}) + return r end @@ -90,84 +114,108 @@ local function concatpath(...) return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/")) end -local function filenamesof(targets, pattern) - local f = {} - if targets then - if targets.is then - targets = {targets} - end +-- Turns a list of strings or targets into a list of targets, expanding +-- recursive lists and wildcards. +local function targetsof(...) + local o = {} - for _, r in pairs(targets) do - if (type(r) == "table") and r.is then - if r.outs then - for _, o in pairs(r.outs) do - if not pattern or o:find(pattern) then - f[#f+1] = o - end - end + local function process(items) + for _, item in ipairs(items) do + if (type(item) == "table") then + if item.is then + -- This is a target. + o[#o+1] = item + else + -- This is a list. + process(item) end - elseif (type(r) == "string") then - f[#f+1] = r + elseif (type(item) == "string") then + -- Filename! + if item:find("^%+") then + item = cwd..item + elseif item:find("^%./") then + item = concatpath(cwd, item) + end + o[#o+1] = loadtarget(item) else - error(string.format("list of targets contains a %s which isn't a target", - type(r))) + error(string.format("member of target list is not a string or a target")) end end end - return f + + process({...}) + return o end -local function targetnamesof(targets) +local function filenamesof(...) + local targets = targetsof(...) + local f = {} - if targets then - if targets.is then - targets = {targets} - end - - for _, r in pairs(targets) do - if (type(r) == "table") and r.is then - f[#f+1] = r.fullname - elseif (type(r) == "string") then - f[#f+1] = r - else - error(string.format("list of targets contains a %s which isn't a target", - type(r))) + for _, r in ipairs(targets) do + if (type(r) == "table") and r.is then + if r.outs then + for _, o in ipairs(r.outs) do + f[#f+1] = o + end end + elseif (type(r) == "string") then + f[#f+1] = r + else + error(string.format("list of targets contains a %s which isn't a target", + type(r))) end end return f end -local function dotocollection(collection, callback) - if (type(collection) == "string") then - return callback(collection) - elseif collection.is then - local files = filenamesof(collection.outs) - if (#files ~= 1) then - error("inputs with more than one output need to be in a list") +local function targetnamesof(...) + local targets = targetsof(...) + + local f + for _, r in pairs(targets) do + if (type(r) == "table") and r.is then + f[#f+1] = r.fullname + elseif (type(r) == "string") then + f[#f+1] = r + else + error(string.format("list of targets contains a %s which isn't a target", + type(r))) end + end + return f +end + +local function dotocollection(files, callback) + if (#files == 1) and (type(files[1]) == "string") then return callback(files[1]) end local o = {} - for _, s in pairs(collection) do - if s.is then - for _, b in pairs(dotocollection(filenamesof(s), callback)) do - o[#o+1] = b - end - else - local b = callback(s) - if (b ~= "") then - o[#o+1] = b + local function process(files) + for _, s in ipairs(files) do + if (type(s) == "table") then + if s.is then + error("passed target to a filename manipulation function") + else + process(s) + end + else + local b = callback(s) + if (b ~= "") then + o[#o+1] = b + end end end end + process(files) return o end -local function abspath(collection) - return dotocollection(collection, + +local function abspath(...) + return dotocollection({...}, function(filename) + assertString(filename, 1) if not filename:find("^[/$]") then filename = concatpath(posix.getcwd(), filename) end @@ -176,9 +224,11 @@ local function abspath(collection) ) end -local function basename(collection) - return dotocollection(collection, + +local function basename(...) + return dotocollection({...}, function(filename) + assertString(filename, 1) local _, _, b = filename:find("^.*/([^/]*)$") if not b then return filename @@ -188,9 +238,11 @@ local function basename(collection) ) end -local function dirname(collection) - return dotocollection(collection, + +local function dirname(...) + return dotocollection({...}, function(filename) + assertString(filename, 1) local _, _, b = filename:find("^(.*)/[^/]*$") if not b then return "" @@ -200,25 +252,34 @@ local function dirname(collection) ) end -local function replace(collection, pattern, repl) - return dotocollection(collection, +local function replace(files, pattern, repl) + return dotocollection(files, function(filename) return filename:gsub(pattern, repl) end ) end -local function fpairs(collection) - if (type(collection) == "string") or collection.is then - return fpairs({collection}) - end - - return pairs(filenamesof(collection)) +local function fpairs(...) + return ipairs(filenamesof(...)) end +local function matching(collection, pattern) + local o = {} + dotocollection(collection, + function(filename) + if filename:find(pattern) then + o[#o+1] = filename + end + end + ) + return o +end + -- Selects all targets containing at least one output file that matches -- the pattern (or all, if the pattern is nil). local function selectof(targets, pattern) + local targets = targetsof(targets) local o = {} for k, v in pairs(targets) do if v.is and v.outs then @@ -237,16 +298,16 @@ local function selectof(targets, pattern) return o end -local function uniquify(collection) +local function uniquify(...) local s = {} - local o = {} - for _, v in pairs(collection) do - if not s[v] then - s[v] = true - o[#o+1] = v + return dotocollection({...}, + function(filename) + if not s[filename] then + s[filename] = true + return filename + end end - end - return o + ) end local function startswith(needle, haystack) @@ -274,13 +335,13 @@ local function templateexpand(list, vars) o[#o+1] = s:gsub("%%%b{}", function(expr) expr = expr:sub(3, -2) - local chunk, e = loadstring("return "..expr, expr, "text", vars) + local chunk, e = load("return ("..expr..")", expr, "text", vars) if e then error(string.format("error evaluating expression: %s", e)) end local value = chunk() if (value == nil) then - error(string.format("template expression expands to nil (probably an undefined variable)")) + error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr)) end return asstring(value) end @@ -302,7 +363,7 @@ local function loadbuildfile(filename) if not e then local thisglobals = {_G = thisglobals} setmetatable(thisglobals, {__index = globals}) - chunk, e = loadstring(data, filename, "text", thisglobals) + chunk, e = load(data, "@"..filename, "text", thisglobals) end end if e then @@ -316,7 +377,7 @@ local function loadbuildfile(filename) end end -local function loadtarget(targetname) +loadtarget = function(targetname) if targets[targetname] then return targets[targetname] end @@ -368,24 +429,7 @@ local typeconverters = { elseif (type(i) ~= "table") then error(string.format("property '%s' must be a target list", propname)) end - - local o = {} - for k, s in pairs(i) do - if (type(s) == "table") and s.is then - o[k] = s - elseif (type(s) == "string") then - if s:find("^%+") then - s = cwd..s - elseif s:find("^%./") then - s = concatpath(cwd, s) - end - o[k] = loadtarget(s) - else - error(string.format("member of target list '%s' is not a string or a target", - propname)) - end - end - return o + return targetsof(i) end, strings = function(propname, i) @@ -394,7 +438,7 @@ local typeconverters = { elseif (type(i) ~= "table") then error(string.format("property '%s' must be a string list", propname)) end - return i + return concat(i) end, boolean = function(propname, i) @@ -547,7 +591,7 @@ local function install_ninja_emitter() emit("\n") local function unmake(collection) - return dotocollection(collection, + return dotocollection({collection}, function(s) return s:gsub("%$%b()", function(expr) @@ -589,14 +633,12 @@ definerule("simplerule", vars = { type="table", default={} }, }, function (e) - emitter:rule(e.fullname, - concat(filenamesof(e.ins), filenamesof(e.deps)), - e.outs) + emitter:rule(e.fullname, filenamesof(e.ins, e.deps), e.outs) emitter:label(e.fullname, " ", e.label or "") local vars = inherit(e.vars, { - ins = e.ins, - outs = e.outs + ins = filenamesof(e.ins), + outs = filenamesof(e.outs) }) emitter:exec(templateexpand(e.commands, vars)) @@ -610,7 +652,7 @@ definerule("simplerule", definerule("installable", { - map = { type="targets", default={} }, + map = { type="table", default={} }, }, function (e) local deps = {} @@ -618,6 +660,12 @@ definerule("installable", local srcs = {} local dests = {} for dest, src in pairs(e.map) do + src = targetsof(src) + if (#src ~= 1) then + error("installable can only cope with one target at a time") + end + src = src[1] + if src.is.installable then if (type(dest) ~= "number") then error("can't specify a destination filename when installing an installable") @@ -631,7 +679,7 @@ definerule("installable", error("installable can only cope with targets emitting single files") end - deps[#deps+1] = src + deps[#deps+1] = src.fullname dests[#dests+1] = dest commands[#commands+1] = "cp "..f[1].." "..dest end @@ -717,9 +765,9 @@ globals = { inherit = inherit, print = print, replace = replace, + matching = matching, selectof = selectof, startswith = startswith, - targetnamesof = targetnamesof, uniquify = uniquify, vars = vars, } diff --git a/first/build.lua b/first/build.lua index 192f512e1..9bbb905a9 100644 --- a/first/build.lua +++ b/first/build.lua @@ -14,8 +14,8 @@ definerule("normalrule", function (e) local dir = e.objdir or objdir(e) local realouts = {} - for k, v in pairs(e.outleaves) do - realouts[k] = concatpath(dir, v) + for _, v in pairs(e.outleaves) do + realouts[#realouts+1] = concatpath(dir, v) end local vars = inherit(e.vars, { @@ -185,7 +185,7 @@ definerule("clibrary", cwd = e.cwd, ins = ins, deps = concat(e.hdrs, e.deps), - outleaves = { e.name..".a", unpack(basename(hdrs)) }, + outleaves = concat(e.name..".a", basename(hdrs)), label = e.label, commands = commands, vars = { @@ -207,19 +207,21 @@ definerule("cprogram", } }, function (e) - local libs = filenamesof(e.deps, "%.a$") + local libs = matching(filenamesof(e.deps), "%.a$") if (#e.srcs > 0) then - for _, f in pairs(filenamesof( - { - clibrary { - name = e.name .. "/main", - cwd = e.cwd, - srcs = e.srcs, - deps = e.deps, - } - }, - "%.a$" - )) do + for _, f in pairs( + matching( + filenamesof( + clibrary { + name = e.name .. "/main", + cwd = e.cwd, + srcs = e.srcs, + deps = e.deps, + } + ), + "%.a$" + ) + ) do libs[#libs+1] = f end end diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index f402bd697..bc3f33b3d 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -1,4 +1,3 @@ -local posix = require("posix") include("util/LLgen/build.lua") normalrule { @@ -13,7 +12,7 @@ normalrule { } } -local str_files = basename(posix.glob(cwd().."/*.str")) +local str_files = basename(filenamesof("./*.str")) local str_targets = {} for _, f in ipairs(str_files) do @@ -46,7 +45,7 @@ clibrary { hdrs = str_targets, deps = { "+parameters", - unpack(str_targets) + str_targets } } diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index 85d92b925..0cc57fe9f 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -9,9 +9,9 @@ local allocd_header = definerule(null, name = e.name, ins = { "./make.allocd", - unpack(e.srcs) + e.srcs }, - outleaves = replace(basename(e.srcs), "%.str$", ".h"), + outleaves = basename(filenamesof(e.srcs)[1]):gsub("%.str$", ".h"), commands = { "%{ins[1]} < %{ins[2]} > %{outs}" } @@ -82,7 +82,7 @@ cprogram { name = "cpp", srcs = concat( "./*.c", - filenamesof(llgen, "%.c$"), + matching(filenamesof(llgen), "%.c$"), "+next_c", "+symbol2str_c", "+tabgen_c" diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua index 89731351c..37f6cd336 100644 --- a/mach/proto/as/build.lua +++ b/mach/proto/as/build.lua @@ -32,7 +32,7 @@ definerule("build_as", name = e.name, srcs = concat( "mach/proto/as/*.c", - filenamesof(yaccfiles, "%.c$") + matching(filenamesof(yaccfiles), "%.c$") ), deps = { "h+emheaders", diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua index 1553d3975..e093f891e 100644 --- a/mach/proto/ncg/build.lua +++ b/mach/proto/ncg/build.lua @@ -35,7 +35,6 @@ definerule("build_ncg", "modules/src/flt_arith+lib", "modules/src/object+lib", "util/data+em_data", - archlib, -- for .h file headers, tables, -- for .h file } diff --git a/plat/build.lua b/plat/build.lua index 7febb9ada..67b8cd1d8 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -16,7 +16,7 @@ definerule("ackfile", "plat/"..plat.."+tools", "util/ack+pkg", "lang/cem/cpp.ansi+pkg", - unpack(e.deps) + e.deps }, commands = { "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -c -o %{outs} %{ins} %{hdrpaths} %{ackcflags}" @@ -38,10 +38,11 @@ definerule("acklibrary", hdrs = e.hdrs, deps = { "util/arch+pkg", - unpack(e.deps) + e.deps }, _cfile = ackfile, commands = { + "rm -f %{outs[1]}", "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal q %{outs[1]} %{ins}" } } diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua index 5939332d4..44abc871c 100644 --- a/util/LLgen/build.lua +++ b/util/LLgen/build.lua @@ -21,7 +21,7 @@ definerule("llgen", function(e) -- Remember this is executed from the caller's directory; local -- target names will resolve there - local fs = replace(basename(e.srcs), "%.g$", "") + local fs = replace(basename(filenamesof(e.srcs)), "%.g$", "") return normalrule { name = e.name, @@ -29,11 +29,11 @@ definerule("llgen", outleaves = { "Lpars.c", "Lpars.h", - unpack(replace(fs, "$", ".c")) + replace(fs, "$", ".c") }, ins = { "util/LLgen+llgen", - unpack(e.srcs), + e.srcs, }, commands = { "cd %{dir} && %{abspath(ins)}" diff --git a/util/cmisc/build.lua b/util/cmisc/build.lua index 8ffe24a36..b7c2b474a 100644 --- a/util/cmisc/build.lua +++ b/util/cmisc/build.lua @@ -8,13 +8,13 @@ definerule("tabgen", srcs = { type="targets" }, }, function(e) - local symname = replace(basename(e.srcs[1]), "%.tab$", "") + local symname = basename(filenamesof(e.srcs)[1]):gsub("%.tab$", "") return normalrule { name = e.name, ins = { "util/cmisc+tabgen", - unpack(e.srcs) + e.srcs }, outleaves = { symname..".c" }, commands = { diff --git a/util/data/build.lua b/util/data/build.lua index 5c9f0b3f8..aca670177 100644 --- a/util/data/build.lua +++ b/util/data/build.lua @@ -24,7 +24,7 @@ clibrary { name = "em_data", srcs = concat( "./em_ptyp.c", - filenamesof(generated, "%.c$") + matching(filenamesof(generated), "%.c$") ), hdrs = { "+generated" -- so we export the H files diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index 57d9e4753..787fd8c3a 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -12,11 +12,11 @@ local cgglexer = flex { normalrule { name = "keywords", - ins = concat( + ins = { "./cvtkeywords", "./keywords", - filenamesof({cggparser}, "%.h$") - ), + matching(filenamesof(cggparser), "%.h$") + }, outleaves = { "enterkeyw.c" }, commands = { "%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" @@ -27,8 +27,8 @@ cprogram { name = "ncgg", srcs = concat( "./*.c", - filenamesof({cggparser}, "%.c$"), - filenamesof({cgglexer}, "%.c$"), + matching(filenamesof(cggparser), "%.c$"), + matching(filenamesof(cgglexer), "%.c$"), "+keywords" ), deps = { From b50dc4214a477f106a20fd04d417c7d7488603fe Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 5 Aug 2016 00:01:55 +0200 Subject: [PATCH 170/231] Add check for undefined variables. Find undefined variables. Fix undefined variables. --- first/ackbuilder.lua | 15 ++++++++++++++- lang/cem/cpp.ansi/build.lua | 2 +- mach/proto/ncg/build.lua | 3 +-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 1a150cb4a..0f83c4936 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -361,7 +361,8 @@ local function loadbuildfile(filename) data, e = fp:read("*a") fp:close() if not e then - local thisglobals = {_G = thisglobals} + local thisglobals = {} + thisglobals._G = thisglobals setmetatable(thisglobals, {__index = globals}) chunk, e = load(data, "@"..filename, "text", thisglobals) end @@ -787,6 +788,18 @@ setmetatable(globals, vars.cflags = {} parente.vars = vars +setmetatable(_G, + { + __index = function(self, k) + local value = rawget(_G, k) + if not value then + error(string.format("access of undefined variable '%s'", k)) + end + return value + end + } +) + do local emitter_type = install_make_emitter parse_arguments( diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index 0cc57fe9f..1f22fe88f 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -1,6 +1,6 @@ include("util/cmisc/build.lua") -local allocd_header = definerule(null, +local allocd_header = definerule(nil, { srcs = { type="targets" } }, diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua index e093f891e..5245fd2a7 100644 --- a/mach/proto/ncg/build.lua +++ b/mach/proto/ncg/build.lua @@ -26,8 +26,7 @@ definerule("build_ncg", srcs = { "mach/proto/ncg/*.c", "mach/"..e.arch.."/ncg/mach.h", - archlib, -- for .c file - tables, -- for .c file + matching(filenamesof(tables), "%.c$") }, deps = { "h+emheaders", From 0d77cb827938776a5f86f0edf55dfb0cce2d21bb Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 7 Aug 2016 21:56:53 +0200 Subject: [PATCH 171/231] We can build our first C file. --- build.lua | 3 +- first/ackbuilder.lua | 2 +- lang/build.lua | 0 lang/cem/cemcom.ansi/build.lua | 35 ++++++++++++-- lang/cem/cemcom.ansi/char.tab | 2 - lang/cem/libcc.ansi/build.lua | 29 +++++++++++ mach/i86/libem/build.lua | 8 ++++ mach/i86/libsys/build.lua | 8 ++++ modules/src/assert/build.lua | 7 +++ modules/src/em_mes/build.lua | 11 +++++ modules/src/flt_arith/build.lua | 18 ++++++- modules/src/read_em/build.lua | 59 ++++++++++++----------- plat/build.lua | 11 +++-- plat/pc86/build.lua | 1 + util/misc/build.lua | 17 +++++++ util/opt/build.lua | 85 +++++++++++++++++++++++++++++++++ 16 files changed, 258 insertions(+), 38 deletions(-) create mode 100644 lang/build.lua create mode 100644 lang/cem/libcc.ansi/build.lua create mode 100644 mach/i86/libem/build.lua create mode 100644 mach/i86/libsys/build.lua create mode 100644 modules/src/assert/build.lua create mode 100644 modules/src/em_mes/build.lua create mode 100644 util/opt/build.lua diff --git a/build.lua b/build.lua index 200744a4c..373f195e3 100644 --- a/build.lua +++ b/build.lua @@ -12,11 +12,12 @@ installable { name = "ack", map = { "lang/cem/cemcom.ansi+pkg", + "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", "util/arch+pkg", "util/misc+pkg", - "plat/pc86+pkg", + "util/opt+pkg", } } diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 0f83c4936..7bbf2ee04 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -415,7 +415,7 @@ loadtarget = function(targetname) target = targets[targetname] if not target then - error(string.format("build file '%s' contains no rule '%s'", + error(string.format("build file '%s' contains no target '%s'", filename, targetpart)) end end diff --git a/lang/build.lua b/lang/build.lua new file mode 100644 index 000000000..e69de29bb diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index bc3f33b3d..fe0f70d25 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -1,4 +1,5 @@ include("util/LLgen/build.lua") +include("util/cmisc/build.lua") normalrule { name = "parameters", @@ -50,12 +51,24 @@ clibrary { } normalrule { - name = "tokenname-g", + name = "tokenfile-g", ins = { "./make.tokfile", "./tokenname.c", }, - outleaves = { "tokenname.g" }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}", + } +} + +normalrule { + name = "symbol2str-c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, commands = { "sh %{ins[1]} < %{ins[2]} > %{outs}", } @@ -64,14 +77,23 @@ normalrule { llgen { name = "llgen", srcs = { - "+tokenname-g", -- must be first + "+tokenfile-g", -- must be first "./*.g", }, } +tabgen { + name = "tabgen", + srcs = { "./char.tab" } +} + cprogram { name = "cemcom", srcs = { + "./LLlex.c", + "./LLmessage.c", + "./arith.c", + "./blocks.c", "./ch3.c", "./ch3bin.c", "./ch3mon.c", @@ -111,17 +133,24 @@ cprogram { "./tokenname.c", "./type.c", "./util.c", + "+symbol2str-c", + "+tabgen", + matching(filenamesof("+llgen"), "%.c$"), }, deps = { + "./*.h", "+parameters", "+nextlib", "+llgen", "h+emheaders", "modules/src/alloc+lib", "modules/src/em_code+lib_k", + "modules/src/em_mes+lib", "modules/src/flt_arith+lib", "modules/src/idf+lib", "modules/src/input+lib", + "modules/src/print+lib", + "modules/src/string+lib", "modules/src/system+lib", "modules+headers", "util/data+em_data", diff --git a/lang/cem/cemcom.ansi/char.tab b/lang/cem/cemcom.ansi/char.tab index 809f1c6ce..329178284 100644 --- a/lang/cem/cemcom.ansi/char.tab +++ b/lang/cem/cemcom.ansi/char.tab @@ -1,6 +1,4 @@ % -hdrs = { "./src/system/system.h" }, -hdrs = { "./src/system/system.h" }, % CHARACTER CLASSES % % some general settings: diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua new file mode 100644 index 000000000..a75526836 --- /dev/null +++ b/lang/cem/libcc.ansi/build.lua @@ -0,0 +1,29 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./assert/*.c", + }, + hdrs = { + }, + vars = { plat = plat } + } + + ackfile { + name = "crt_"..plat, + srcs = { "./head_ac.e" }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat, + --["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat, + } + } +end + diff --git a/mach/i86/libem/build.lua b/mach/i86/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i86/libsys/build.lua b/mach/i86/libsys/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libsys/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/modules/src/assert/build.lua b/modules/src/assert/build.lua new file mode 100644 index 000000000..bd1230bfe --- /dev/null +++ b/modules/src/assert/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./assert.h" }, +} + + diff --git a/modules/src/em_mes/build.lua b/modules/src/em_mes/build.lua new file mode 100644 index 000000000..a3c0173cc --- /dev/null +++ b/modules/src/em_mes/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/em_code+em_code_ek_h", + "util/data+em_data", + } +} + diff --git a/modules/src/flt_arith/build.lua b/modules/src/flt_arith/build.lua index 10ce7b8ce..a3da4b801 100644 --- a/modules/src/flt_arith/build.lua +++ b/modules/src/flt_arith/build.lua @@ -1,6 +1,22 @@ clibrary { name = "lib", - srcs = { "./*.c" }, + srcs = { + "./flt_ar2flt.c", + "./flt_div.c", + "./flt_flt2ar.c", + "./flt_modf.c", + "./flt_str2fl.c", + "./flt_cmp.c", + "./flt_add.c", + "./b64_add.c", + "./flt_mul.c", + "./flt_nrm.c", + "./b64_sft.c", + "./flt_umin.c", + "./flt_chk.c", + "./split.c", + "./ucmp.c", + }, hdrs = { "./flt_arith.h" }, deps = { "modules+headers" diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua index d80d0569c..45794bd91 100644 --- a/modules/src/read_em/build.lua +++ b/modules/src/read_em/build.lua @@ -25,34 +25,39 @@ normalrule { } } -clibrary { - name = "lib_ev", - vars = { - ["+cflags"] = { - "-DPRIVATE=static", - "-DEXPORT=", - "-DNDEBUG", - "-DCHECKING" +local function variant(name, cflags) + clibrary { + name = name, + vars = { + ["+cflags"] = { + "-DPRIVATE=static", + "-DEXPORT=", + "-DNDEBUG", + "-DCHECKING", + unpack(cflags) + }, }, - }, - srcs = { - "./EM_vars.c", - "./read_em.c", - "./mkcalls.c", - }, - hdrs = { - "./em_comp.h", - }, - deps = { - "+c_mnem_h", - "+c_mnem_narg_h", - "h+emheaders", - "modules+headers", - "modules/src/alloc+lib", - "modules/src/em_code+em_code_ek_h", - "modules/src/system+lib", - "util/data+em_data", + srcs = { + "./EM_vars.c", + "./read_em.c", + "./mkcalls.c", + }, + hdrs = { + "./em_comp.h", + }, + deps = { + "+c_mnem_h", + "+c_mnem_narg_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+em_code_ek_h", + "modules/src/system+lib", + "util/data+em_data", + } } -} +end +variant("lib_ev", {}) +variant("lib_kv", { "-DCOMPACT" }) diff --git a/plat/build.lua b/plat/build.lua index 67b8cd1d8..472e9ec3f 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -13,9 +13,10 @@ definerule("ackfile", name = e.name, srcs = e.srcs, deps = { + "lang/cem/cpp.ansi+pkg", "plat/"..plat.."+tools", "util/ack+pkg", - "lang/cem/cpp.ansi+pkg", + "util/misc+pkg", e.deps }, commands = { @@ -43,7 +44,7 @@ definerule("acklibrary", _cfile = ackfile, commands = { "rm -f %{outs[1]}", - "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal q %{outs[1]} %{ins}" + "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal qc %{outs[1]} %{ins}" } } end @@ -73,6 +74,7 @@ definerule("build_plat_tools", ["$(PLATDEP)/"..e.plat.."/as"] = as, ["$(PLATDEP)/"..e.plat.."/ncg"] = ncg, ["$(PLATIND)/descr/"..e.plat] = descr, + "util/opt+pkg", } } end @@ -87,7 +89,10 @@ definerule("build_plat_libs", return installable { name = e.name, map = { - ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat + ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat, + "lang/cem/libcc.ansi+pkg_"..e.plat, } } end diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua index c293a4ea6..6f68b1474 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build.lua @@ -1,4 +1,5 @@ include("plat/build.lua") +include("lang/build.lua") build_plat_tools { name = "tools", diff --git a/util/misc/build.lua b/util/misc/build.lua index ab0a26d7d..3b11c6018 100644 --- a/util/misc/build.lua +++ b/util/misc/build.lua @@ -19,10 +19,27 @@ cprogram { } } +cprogram { + name = "decode", + srcs = { "./convert.c" }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/print+lib", + "modules/src/read_em+lib_kv", + "modules/src/string+lib", + "modules/src/system+lib", + "util/data+em_data", + } +} + installable { name = "pkg", map = { ["$(PLATDEP)/em_encode"] = "+encode", + ["$(PLATDEP)/em_decode"] = "+decode", ["$(INSDIR)/bin/esize"] = "+esize", ["$(PLATIND)/man/man1/esize.1"] = "./esize.1", ["$(PLATIND)/man/man6/em_decode.6"] = "./em_decode.6" diff --git a/util/opt/build.lua b/util/opt/build.lua new file mode 100644 index 000000000..8a4dc6688 --- /dev/null +++ b/util/opt/build.lua @@ -0,0 +1,85 @@ +include("first/yacc.lua") + +yacc { + name = "yacc", + srcs = { "./mktab.y" } +} + +flex { + name = "flex", + srcs = { "./scan.l" } +} + +cprogram { + name = "mktab", + srcs = { + matching(filenamesof("+yacc"), "%.c$"), + matching(filenamesof("+flex"), "%.c$"), + }, + deps = { + "+flex", + "+yacc", + "util/data+em_data", + } +} + +normalrule { + name = "pattern_c", + ins = { + "+mktab", + "./patterns", + "lang/cem/cpp.ansi+cpp" + }, + outleaves = { "pattern.c" }, + commands = { + "%{ins[3]} < %{ins[2]} | %{ins[1]} > %{outs}" + } +} + +normalrule { + name = "pop_push_c", + ins = { + "./pop_push.awk", + "h/em_table" + }, + outleaves = { "pop_push.c" }, + commands = { + "awk -f %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +local function variant(name, cflags) + cprogram { + name = name, + srcs = { + "+pattern_c", + "+pop_push_c", + "./*.c", + }, + deps = { + "./*.h", + "h+emheaders", + "modules/src/alloc+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "util/data+em_data", + }, + vars = { + ["+cflags"] = cflags + } + } +end + +variant("em_opt", {}) +variant("em_opt2", {"-DGLOBAL_OPT"}) + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_opt"] = "+em_opt", + ["$(PLATDEP)/em_opt2"] = "+em_opt2", + ["$(INSDIR)/share/man/man6/em_opt.6"] = "./em_opt.6", + } +} + From c213602a0263a9e8b9f3eaf9bf0b9542fe2aa3b1 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 8 Aug 2016 23:55:23 +0200 Subject: [PATCH 172/231] Target lists can now have keyed items ({["foo"] = "+target"); this is used by both installable and by clibrary{} to allow headers to be installed into subdirectories. --- first/ackbuilder.lua | 32 +++++++++++++++++++++----------- first/build.lua | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 7bbf2ee04..c7798e6b8 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -114,13 +114,13 @@ local function concatpath(...) return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/")) end --- Turns a list of strings or targets into a list of targets, expanding --- recursive lists and wildcards. +-- Returns a list of the targets within the given collection; the keys of any +-- keyed items are lost. Lists and wildcards are expanded. local function targetsof(...) local o = {} local function process(items) - for _, item in ipairs(items) do + for _, item in pairs(items) do if (type(item) == "table") then if item.is then -- This is a target. @@ -430,7 +430,23 @@ local typeconverters = { elseif (type(i) ~= "table") then error(string.format("property '%s' must be a target list", propname)) end - return targetsof(i) + + local m = {} + for k, v in pairs(i) do + local ts = targetsof(v) + if (type(k) == "number") then + for _, t in ipairs(ts) do + m[#m+1] = t + end + else + if (#ts ~= 1) then + error(string.format("named target '%s' can only be assigned from a single target", k)) + else + m[k] = ts[1] + end + end + end + return m end, strings = function(propname, i) @@ -653,7 +669,7 @@ definerule("simplerule", definerule("installable", { - map = { type="table", default={} }, + map = { type="targets", default={} }, }, function (e) local deps = {} @@ -661,12 +677,6 @@ definerule("installable", local srcs = {} local dests = {} for dest, src in pairs(e.map) do - src = targetsof(src) - if (#src ~= 1) then - error("installable can only cope with one target at a time") - end - src = src[1] - if src.is.installable then if (type(dest) ~= "number") then error("can't specify a destination filename when installing an installable") diff --git a/first/build.lua b/first/build.lua index 9bbb905a9..0efdadb12 100644 --- a/first/build.lua +++ b/first/build.lua @@ -170,27 +170,44 @@ definerule("clibrary", } end - local hdrs = filenamesof(e.hdrs) - local commands = {} - for _, s in ipairs(e.commands) do - commands[#commands+1] = s + local outleaves = {} + if (#e.srcs > 0) then + for _, s in ipairs(e.commands) do + commands[#commands+1] = s + end + outleaves[#outleaves+1] = e.name..".a" end - if (#hdrs > 0) then - commands[#commands+1] = "cp %{hdrs} %{dir}" + + local hdrsin = {} + for dest, src in pairs(e.hdrs) do + if (type(dest) == "number") then + for _, f in ipairs(filenamesof(src)) do + hdrsin[#hdrsin+1] = f + outleaves[#outleaves+1] = basename(f) + commands[#commands+1] = "cp "..asstring(f).." %{dir}" + end + else + local fs = filenamesof(src) + if (#fs ~= 1) then + error(string.format("keyed header '%s' can only be a single file", dest)) + end + local f = fs[1] + + hdrsin[#hdrsin+1] = f + outleaves[#outleaves+1] = dest + commands[#commands+1] = "cp "..asstring(f).." %{dir}/"..dest + end end return normalrule { name = e.name, cwd = e.cwd, ins = ins, - deps = concat(e.hdrs, e.deps), - outleaves = concat(e.name..".a", basename(hdrs)), + deps = {hdrsin, e.deps}, + outleaves = outleaves, label = e.label, commands = commands, - vars = { - hdrs = hdrs - } } end ) From 3ce4e53aa9b425dd8180b6fa83f9eea5e1e6257b Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 8 Aug 2016 23:55:47 +0200 Subject: [PATCH 173/231] Most of libc builds now (missing malloc). --- lang/cem/libcc.ansi/build.lua | 68 ++++++++++++++++++++++++++++-- lang/cem/libcc.ansi/ctype/genfiles | 2 +- lang/cem/libcc.ansi/stdio/rename.c | 2 + plat/pc86/build.lua | 8 ++++ 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua index a75526836..ebc948871 100644 --- a/lang/cem/libcc.ansi/build.lua +++ b/lang/cem/libcc.ansi/build.lua @@ -1,11 +1,73 @@ +local headers = {} + +local function addheader(dir, list) + for _, f in ipairs(list) do + local b = basename(f) + headers[dir..b] = f + end +end + +addheader("", filenamesof("./headers/*.h")) +addheader("sys/", filenamesof("./headers/sys/*.h")) + +acklibrary { + name = "headers", + hdrs = headers +} + +tabgen { + name = "ctype_tab", + srcs = { "./ctype/char.tab" } +} + +normalrule { + name = "ctype_files", + ins = { "./ctype/genfiles" }, + outleaves = { + "isalnum.c", + "isalpha.c", + "isascii.c", + "iscntrl.c", + "isdigit.c", + "isgraph.c", + "islower.c", + "isprint.c", + "ispunct.c", + "isspace.c", + "isupper.c", + "isxdigit.c", + }, + commands = { + "sh %{ins[1]} %{dir}" + } +} + for _, plat in ipairs(vars.plats) do acklibrary { name = "lib_"..plat, srcs = { + "+ctype_files", + "+ctype_tab", + "./ctype/*.c", "./assert/*.c", + "./errno/*.c", + "./locale/*.c", + "./math/*.c", + "./misc/environ.c", -- don't build everything here as it's all obsolete + "./setjmp/*.c", + "./setjmp/*.e", + "./signal/*.c", + "./stdio/*.c", + "./stdlib/*.c", + "./string/*.c", + "./time/*.c", + }, - hdrs = { - }, + hdrs = {}, -- must be empty + deps = { + "+headers", + "plat/"..plat.."+headers", + }, vars = { plat = plat } } @@ -22,7 +84,7 @@ for _, plat in ipairs(vars.plats) do name = "pkg_"..plat, map = { ["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat, - --["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat, + ["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat, } } end diff --git a/lang/cem/libcc.ansi/ctype/genfiles b/lang/cem/libcc.ansi/ctype/genfiles index 061a214bc..96121a3cd 100644 --- a/lang/cem/libcc.ansi/ctype/genfiles +++ b/lang/cem/libcc.ansi/ctype/genfiles @@ -3,7 +3,7 @@ for i in isalnum isalpha iscntrl isdigit isgraph islower isprint \ ispunct isspace isupper isxdigit isascii do -sed "s/xxxx/$i/" > $i.c << 'EOF' +sed "s/xxxx/$i/" > $1/$i.c << 'EOF' #include int (xxxx)(int c) { diff --git a/lang/cem/libcc.ansi/stdio/rename.c b/lang/cem/libcc.ansi/stdio/rename.c index 08c5ae85d..ff177ccd5 100644 --- a/lang/cem/libcc.ansi/stdio/rename.c +++ b/lang/cem/libcc.ansi/stdio/rename.c @@ -7,6 +7,8 @@ #include #include +/* Disabled, dtrg: rename is a system call these days. */ +#if 0 int _link(const char *name1, const char *name2); int diff --git a/plat/pc86/build.lua b/plat/pc86/build.lua index 6f68b1474..002f66a54 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build.lua @@ -13,6 +13,14 @@ ackfile { vars = { plat = "pc86" } } +acklibrary { + name = "headers", + hdrs = { + ["ack/config.h"] = "./include/ack/config.h", + ["unistd.h"] = "./include/unistd.h", + } +} + build_plat_libs { name = "libs", arch = "i86", From a200a2fb53309c7c05421dc9c0c270b5227f5d68 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 11 Aug 2016 00:30:32 +0200 Subject: [PATCH 174/231] Replaced the funky and hard-to-compile ACK malloc with a much smaller and simpler one stolen from K&R. libc builds now. --- lang/cem/libcc.ansi/build.lua | 23 +- lang/cem/libcc.ansi/headers/build.lua | 26 ++ lang/cem/libcc.ansi/malloc/malloc.c | 151 +++++++ lang/cem/libcc.ansi/malloc/malloc.h | 25 ++ lang/cem/libcc.ansi/malloc/realloc.c | 41 ++ lang/cem/libcc.ansi/stdlib/malloc/.distr | 13 - lang/cem/libcc.ansi/stdlib/malloc/Makefile | 20 - lang/cem/libcc.ansi/stdlib/malloc/READ_ME | 27 -- lang/cem/libcc.ansi/stdlib/malloc/add_file | 15 - lang/cem/libcc.ansi/stdlib/malloc/check.c | 303 -------------- lang/cem/libcc.ansi/stdlib/malloc/check.h | 21 - lang/cem/libcc.ansi/stdlib/malloc/global.c | 11 - lang/cem/libcc.ansi/stdlib/malloc/impl.h | 84 ---- lang/cem/libcc.ansi/stdlib/malloc/log.c | 129 ------ lang/cem/libcc.ansi/stdlib/malloc/log.h | 26 -- lang/cem/libcc.ansi/stdlib/malloc/mal.c | 385 ------------------ lang/cem/libcc.ansi/stdlib/malloc/param.h | 56 --- lang/cem/libcc.ansi/stdlib/malloc/phys.c | 96 ----- lang/cem/libcc.ansi/stdlib/malloc/phys.h | 76 ---- lang/cem/libcc.ansi/stdlib/malloc/size_type.h | 8 - 20 files changed, 248 insertions(+), 1288 deletions(-) create mode 100644 lang/cem/libcc.ansi/headers/build.lua create mode 100644 lang/cem/libcc.ansi/malloc/malloc.c create mode 100644 lang/cem/libcc.ansi/malloc/malloc.h create mode 100644 lang/cem/libcc.ansi/malloc/realloc.c delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/.distr delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/Makefile delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/READ_ME delete mode 100755 lang/cem/libcc.ansi/stdlib/malloc/add_file delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/check.c delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/check.h delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/global.c delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/impl.h delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/log.c delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/log.h delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/mal.c delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/param.h delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/phys.c delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/phys.h delete mode 100644 lang/cem/libcc.ansi/stdlib/malloc/size_type.h diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua index ebc948871..60b72b0c5 100644 --- a/lang/cem/libcc.ansi/build.lua +++ b/lang/cem/libcc.ansi/build.lua @@ -1,19 +1,4 @@ -local headers = {} - -local function addheader(dir, list) - for _, f in ipairs(list) do - local b = basename(f) - headers[dir..b] = f - end -end - -addheader("", filenamesof("./headers/*.h")) -addheader("sys/", filenamesof("./headers/sys/*.h")) - -acklibrary { - name = "headers", - hdrs = headers -} +include("plat/build.lua") tabgen { name = "ctype_tab", @@ -49,14 +34,15 @@ for _, plat in ipairs(vars.plats) do "+ctype_files", "+ctype_tab", "./ctype/*.c", - "./assert/*.c", "./errno/*.c", "./locale/*.c", + "./malloc/*.c", "./math/*.c", "./misc/environ.c", -- don't build everything here as it's all obsolete "./setjmp/*.c", "./setjmp/*.e", "./signal/*.c", + "./assert/*.c", "./stdio/*.c", "./stdlib/*.c", "./string/*.c", @@ -65,7 +51,7 @@ for _, plat in ipairs(vars.plats) do }, hdrs = {}, -- must be empty deps = { - "+headers", + "lang/cem/libcc.ansi/headers+headers", "plat/"..plat.."+headers", }, vars = { plat = plat } @@ -83,6 +69,7 @@ for _, plat in ipairs(vars.plats) do installable { name = "pkg_"..plat, map = { + "lang/cem/libcc.ansi/headers+pkg", ["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat, ["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat, } diff --git a/lang/cem/libcc.ansi/headers/build.lua b/lang/cem/libcc.ansi/headers/build.lua new file mode 100644 index 000000000..601d383ec --- /dev/null +++ b/lang/cem/libcc.ansi/headers/build.lua @@ -0,0 +1,26 @@ +include("plat/build.lua") + +local headers = {} +local installmap = {} + +local function addheader(dir, list) + for _, f in ipairs(list) do + local b = basename(f) + headers[dir..b] = f + installmap[concatpath("$(PLATIND)/include/ansi/", dir, b)] = f + end +end + +addheader("", filenamesof("./*.h")) +addheader("sys/", filenamesof("./sys/*.h")) + +acklibrary { + name = "headers", + hdrs = headers +} + +installable { + name = "pkg", + map = installmap +} + diff --git a/lang/cem/libcc.ansi/malloc/malloc.c b/lang/cem/libcc.ansi/malloc/malloc.c new file mode 100644 index 000000000..7eaaacaba --- /dev/null +++ b/lang/cem/libcc.ansi/malloc/malloc.c @@ -0,0 +1,151 @@ +#include +#include +#include +#include "malloc.h" + +block_t __mem_root = {&__mem_root, 0}; +block_t* __mem_freelist = &__mem_root; + +/* Pulls more memory from the system. */ + +static block_t* brkmore(size_t nb) +{ + uintptr_t bytes; + block_t* p; + + if (nb < BRKSIZE) + nb = BRKSIZE; + bytes = nb * sizeof(block_t); + + /* Danger, will robinson! sbrk's parameter is *signed*... but malloc() takes a + * size_t. */ + + if (bytes > INTPTR_MAX) + return NULL; + + p = sbrk(bytes); + if (p == (block_t*)-1) + return NULL; + + /* Add it to the free list by pretending it's a used block and freeing it. */ + + p->size = nb; + free(p + 1); + return __mem_freelist; +} + +void* malloc(size_t size) +{ + block_t* p; + block_t* prev; + size_t nblocks; + + /* Add on space for the header; make sure we allocate a round number + * of blocks; avoid overflow. */ + nblocks = BLOCKCOUNT(size); + if (nblocks < size) + return NULL; + nblocks /= sizeof(block_t); + + prev = __mem_freelist; + p = prev->next; + for (;;) + { + if (p->size == nblocks) + { + /* We found a hole of exactly the right size. Unlink and return it. + * The size field is already set. */ + prev->next = p->next; + __mem_freelist = prev; + return (void*) (p+1); + } + else if (p->size > nblocks) + { + /* We found a hole bigger than we need. We shrink the hole and return + * what's left. */ + p->size -= nblocks; + p += p->size; /* p now points at our new block */ + p->size = nblocks; + __mem_freelist = prev; + return (void*) (p+1); + } + + if (p == __mem_freelist) + { + /* Uh-oh --- we've gone right round the ring and haven't found + * anything. Get more memory from the system and keep going. */ + p = brkmore(nblocks); + if (!p) + return NULL; + } + + prev = p; + p = p->next; + } +} + +void free(void *ptr) +{ + block_t* h = BLOCKOF(ptr); + block_t* p; + + if (!ptr) + return; + + /* __mem_freelist points into an ordered ring of free blocks. First, + * we run around the ring until we find the last block before this one. + */ + + p = __mem_freelist; + for (;;) + { + /* Is h between p and the block after p? If so, h needs to be inserted + * after p, so stop here. */ + if ((p < h) && (h < p->next)) + break; + + /* Is p the last block before the end of the address space? */ + if (p >= p->next) + { + /* Is h after p? (That is, will it become the new last block?) */ + if (p < h) + break; + + /* Is h going to become the new *first* block? */ + if (h < p->next) + break; + } + + p = p->next; + } + + /* If we can, merge the next block onto the end of h. */ + + if ((h + h->size) == p->next) + { + h->size += p->next->size; + h->next = p->next->next; + } + else + { + /* Otherwise, insert h before p->next. */ + h->next = p->next; + } + + /* Now try to merge h onto the end of p. */ + + if ((p + p->size) == h) + { + p->size += h->size; + p->next = h->next; + } + else + { + /* Okay, we couldn't do the merge. Fix up the linked list. */ + p->next = h; + } + + /* ...and update the ring pointer. */ + __mem_freelist = p; +} + diff --git a/lang/cem/libcc.ansi/malloc/malloc.h b/lang/cem/libcc.ansi/malloc/malloc.h new file mode 100644 index 000000000..d70e92ae0 --- /dev/null +++ b/lang/cem/libcc.ansi/malloc/malloc.h @@ -0,0 +1,25 @@ +/* This is an ANSI C version of the classic K&R memory allocator, with + * some improvements stolen from the Fuzix libc. + */ + +#ifndef MALLOC_H +#define MALLOC_H + +typedef struct block_s { + struct block_s* next; + size_t size; /* in sizeof(block_t) units */ +} block_t; + +extern block_t __mem_root; +extern block_t* __mem_first_free; + +#define BLOCKOF(p) (((block_t*)(p)) - 1) + +/* Smallest amount to allocate from brk */ +#define BRKSIZE (512 / sizeof(block_t)) + +#define BLOCKCOUNT(bytes) \ + (bytes + sizeof(block_t) + sizeof(block_t) - 1) + +#endif + diff --git a/lang/cem/libcc.ansi/malloc/realloc.c b/lang/cem/libcc.ansi/malloc/realloc.c new file mode 100644 index 000000000..7e6dfbb70 --- /dev/null +++ b/lang/cem/libcc.ansi/malloc/realloc.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include "malloc.h" + +void* realloc(void *ptr, size_t size) +{ + block_t* h; + size_t nblocks; + void* newptr; + + if (size == 0) + { + free(ptr); + return NULL; + } + + if (!ptr) + return malloc(size); + + h = BLOCKOF(ptr); + + nblocks = BLOCKCOUNT(size); + /* Overflow check. */ + if (nblocks < size) + return NULL; + + /* Shrinking the block? Don't bother doing anything (it's never worth it). */ + if (nblocks <= h->size) + return ptr; + + /* Allocate and copy. */ + + newptr = malloc(size); + if (!newptr) + return NULL; + memcpy(newptr, ptr, h->size * sizeof(block_t)); + free(ptr); + return newptr; +} diff --git a/lang/cem/libcc.ansi/stdlib/malloc/.distr b/lang/cem/libcc.ansi/stdlib/malloc/.distr deleted file mode 100644 index e23a0ee82..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/.distr +++ /dev/null @@ -1,13 +0,0 @@ -READ_ME -add_file -check.c -check.h -global.c -impl.h -log.c -log.h -mal.c -param.h -phys.c -phys.h -size_type.h diff --git a/lang/cem/libcc.ansi/stdlib/malloc/Makefile b/lang/cem/libcc.ansi/stdlib/malloc/Makefile deleted file mode 100644 index 11cf36765..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -DIR = . -MALLOC_C = $(DIR)/malloc.c -MALLOC_O = $(DIR)/malloc.o - -MALLOCSRC = READ_ME size_type.h param.h impl.h check.h log.h phys.h \ - mal.c log.c phys.c check.c - -$(MALLOC_C): $(MALLOCSRC) Makefile add_file - rm -f $(MALLOC_C) - for i in $(MALLOCSRC) ; do add_file $$i >> $(MALLOC_C) ; done - rm -f $(MALLOC_O) - -pr: - @pr Makefile add_file $(MALLOCSRC) - -opr: - make pr | opr - -clean: - rm -f *.o malloc.c diff --git a/lang/cem/libcc.ansi/stdlib/malloc/READ_ME b/lang/cem/libcc.ansi/stdlib/malloc/READ_ME deleted file mode 100644 index 2f0bd6f84..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/READ_ME +++ /dev/null @@ -1,27 +0,0 @@ -/* - PROGRAM - malloc(), free(), realloc() - AUTHOR - Dick Grune, Free University, Amsterdam - Modified by Ceriel Jacobs, Free University, Amsterdam, - to make it faster - VERSION - $Id$ - DESCRIPTION - This is an independent rewrite of the malloc/free package; it is - fast and efficient. Free blocks are kept in doubly linked lists, - list N holding blocks with sizes between 2**N and 2**(N+1)-1. - Consequently neither malloc nor free have to do any searching: - the cost of a call of malloc() (or free()) is constant, however - many blocks you have got. - - If you switch on the NON_STANDARD macro (see param.h) every block - costs 2 pointers overhead (otherwise it's 4). -*/ -/* - There is an organisational problem here: during devellopment - I want the package divided into modules, which implies external - names for the communication. The only external names I want in - the finished product are malloc, realloc and free. This requires - some hanky-panky. -*/ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/add_file b/lang/cem/libcc.ansi/stdlib/malloc/add_file deleted file mode 100755 index 58585bf05..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/add_file +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -echo "" -echo "/**********************************************************/" -echo "/* This was file $1 */" -echo "/**********************************************************/" -echo "" - -cat $1 | -sed ' - /#include[ ].*"/d - s/^public/private/ - s/^publicdata/static/ -' -echo '' diff --git a/lang/cem/libcc.ansi/stdlib/malloc/check.c b/lang/cem/libcc.ansi/stdlib/malloc/check.c deleted file mode 100644 index a0bfab331..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/check.c +++ /dev/null @@ -1,303 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include - -#ifdef CHECK /* otherwise this whole file is skipped */ - -/* ??? check these later */ -private acquire_malout(void), check_ml_last(const char *s); -private dump_all_mallinks(void), dump_free_list(int i); -private dump_mallink(const char *s, mallink *ml), print_loop(mallink *ml); -private working_on(mallink *ml); -private size_type checksum(mallink *ml); -static FILE *malout; - -private mallink *free_list_entry(int i); - -#define for_free_list(i,p) \ - for (p = free_list_entry(i); p; p = log_next_of(p)) - -#define for_all_mallinks(ml) /* backwards! */ \ - for (ml = ml_last; ml; \ - ml = first_mallink(ml) ? MAL_NULL : phys_prev_of(ml)) - -/* Maldump */ - -static int pr_cnt = 0; - -maldump(int n) { - /* Dump pertinent info in pseudo-readable format; - abort afterwards if n != 0. - */ - static int dumping = 0; - int i; - - if (dumping) - return; - dumping++; - acquire_malout(); - fprintf(malout, - ">>>>>>>>>>>>>>>> DUMP OF ALL MALLINKS <<<<<<<<<<<<<<<<"); - fprintf(malout, " ml_last = %p\n", ml_last); - if (++pr_cnt == 100) pr_cnt = 0; - dump_all_mallinks(); - fprintf(malout, - ">>>>>>>>>>>>>>>> DUMP OF FREE_LISTS <<<<<<<<<<<<<<<<\n"); - if (++pr_cnt == 100) pr_cnt = 0; - for (i = 0; i < MAX_FLIST; i++) - dump_free_list(i); - fprintf(malout, - ">>>>>>>>>>>>>>>> END OF DUMP <<<<<<<<<<<<<<<<\n"); - fclose(malout); - dumping--; - if (n) - abort(); -} - -private -acquire_malout(void) { - static char buf[BUFSIZ]; - - if (!malout) { - malout = freopen("mal.out", "w", stderr); - setbuf(malout, buf); - } -} - -private -dump_all_mallinks(void) { - mallink *ml; - - for_all_mallinks (ml) { - if (print_loop(ml)) - return; - dump_mallink((char *)0, ml); - } -} - -private -dump_free_list(int i) { - mallink *ml = free_list_entry(i); - - if (!ml) - return; - fprintf(malout, "%2d: ", i); - for_free_list(i, ml) { - if (print_loop(ml)) - return; - fprintf(malout, "%p ", ml); - } - fprintf(malout, "<\n"); -} - -private int -print_loop(mallink *ml) { - if (print_of(ml) == pr_cnt) { - fprintf(malout, "... PRINT LOOP\n"); - return 1; - } - set_print(ml, pr_cnt); - return 0; -} - -private -dump_mallink(const char *s, mallink *ml) { - acquire_malout(); - if (s) - fprintf(malout, "%s: ", s); - fprintf(malout, "@: %p;", ml); - if (ml && checksum_of(ml) != checksum(ml)) - fprintf(malout, ">>>> CORRUPTED <<<<"); - if (!ml) { - fprintf(malout, "\n"); - return; - } - if (free_of(ml)) { - fprintf(malout, " l_p: %p;", _log_prev_of(ml)); - fprintf(malout, " l_n: %p;", _log_next_of(ml)); - } - fprintf(malout, " p_s: %p;", prev_size_of(ml)); - fprintf(malout, " t_s: %p;", _this_size_of(ml)); - fprintf(malout, " sz: %lu;", (unsigned long) size_of(ml)); - fprintf(malout, " fr: %d;", free_of(ml)); - fprintf(malout, "\n"); -} - -/* Check_mallinks() checks the total data structure as accessible - through free_list[] and ml_last. All check_sums should be OK, - except those held in the small array off_colour. This is a - trick to allow to continue checking even when a few mallinks - are temporarily out of order. - Check_mallinks() tests for a lot of internal consistency. -*/ - -/* Some arbitrary constants */ -#define IN_ML_LAST 93 -#define IN_FREE_LIST 57 /* and in ml_last */ -#define CLEAR 21 - -#define VRIJ 1 -#define BEZET 2 - -private -check_mallinks(const char *s) { - mallink *ml; - size_type size; - int i; - char stat; - - check_ml_last(s); - stat = BEZET; - for_all_mallinks(ml) { - if (checksum_of(ml) != checksum(ml)) - Error("mallink info at %p corrupted", s, ml); - if (working_on(ml)) { - stat = BEZET; - continue; - } - if ( !last_mallink(ml) && - phys_prev_of(phys_next_of(ml)) != ml - ) - Error("upward chain bad at %p", s, ml); - if ( !first_mallink(ml) && - phys_next_of(phys_prev_of(ml)) != ml - ) - Error("downward chain bad at %p", s, ml); - if (free_of(ml)) { - if (stat == VRIJ) - Error("free mallink at %p follows free mallink", - s, ml); - stat = VRIJ; - } - else - stat = BEZET; - set_mark(ml, IN_ML_LAST); - } - - for (i = 0, size = MIN_SIZE; i < MAX_FLIST; i++, size *= 2) { - for_free_list(i, ml) { - if (working_on(ml)) - continue; - if (!free_of(ml)) - Error("occupied mallink %p occurs in free_list", s, ml); - switch (mark_of(ml)) { - case IN_ML_LAST: - set_mark(ml, IN_FREE_LIST); - break; - case IN_FREE_LIST: - Error("mallink %p occurs in 2 free_lists", - s, ml); - default: - Error("unknown mallink %p in free_list", - s, ml); - } - if (size_of(ml) < size) - Error("size of mallink %p too small", s, ml); - if (size_of(ml) >= 2*size) - Error("size of mallink %p too large", s, ml); - } - } - for_all_mallinks (ml) { - if (working_on(ml)) - continue; - if (free_of(ml) && mark_of(ml) != IN_FREE_LIST) - Error("free mallink %p is in no free_list", s, ml); - set_mark(ml, CLEAR); - } -} - -private -check_ml_last(const char *s) { - if (ml_last && _this_size_of(ml_last) == 0) - Error("size of ml_last == 0, at %p", s, ml_last); -} - -private size_type -checksum(mallink *ml) { - size_type sum = 0; - - if (free_of(ml)) { - sum += (size_type)_log_prev_of(ml); - sum += (size_type)_log_next_of(ml); - } - sum += (size_type)prev_size_of(ml); - sum += (size_type)_this_size_of(ml); - return sum; -} - -private -calc_checksum(mallink *ml) { - set_checksum(ml, checksum(ml)); -} - -#define N_COLOUR 10 -static mallink *off_colour[N_COLOUR]; - -private -started_working_on(mallink *ml) { - int i; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] == MAL_NULL) { - off_colour[i] = ml; - return; - } - Error("out of off_colour array at %p", "started_working_on", ml); -} - -private -stopped_working_on(mallink *ml) { - int i; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] == ml) { - off_colour[i] = MAL_NULL; - return; - } - Error("stopped working on mallink %p", "stopped_working_on", ml); -} - -private int -working_on(mallink *ml) { - int i; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] == ml) - return 1; - return 0; -} - -private -check_work_empty(const char *s) { - int i; - int cnt = 0; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] != MAL_NULL) - cnt++; - if (cnt != 0) - Error("off_colour not empty", s, MAL_NULL); -} - -private int -Error(const char *fmt, const char *s, mallink *ml) { - static int already_called = 0; - - if (already_called++) return 0; - setbuf(stdout, (char *) 0); - printf("%s: ", s); - printf(fmt, (long)ml); - printf("\n"); - acquire_malout(); - fprintf(malout, "%s: ", s); - fprintf(malout, fmt, (long)ml); - fprintf(malout, "\n"); - fflush(stdout); - maldump(1); - return 0; /* to satisfy lint */ -} - -#endif /* CHECK */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/check.h b/lang/cem/libcc.ansi/stdlib/malloc/check.h deleted file mode 100644 index bc6aafc4f..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/check.h +++ /dev/null @@ -1,21 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#ifdef CHECK - -public check_mallinks(const char *s), calc_checksum(mallink *ml); -public check_work_empty(const char *s); -public started_working_on(mallink *ml), stopped_working_on(mallink *ml); - -#else /* ifndef CHECK */ - -#define maldump(n) abort() -#define check_mallinks(s) 0 -#define calc_checksum(ml) 0 -#define started_working_on(ml) 0 -#define stopped_working_on(ml) 0 -#define check_work_empty(s) 0 - -#endif /* CHECK */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/global.c b/lang/cem/libcc.ansi/stdlib/malloc/global.c deleted file mode 100644 index 49cb459c0..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/global.c +++ /dev/null @@ -1,11 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include "param.h" -#include "impl.h" - -/* The only global data item: -*/ -mallink *ml_last; /* link to the world */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/impl.h b/lang/cem/libcc.ansi/stdlib/malloc/impl.h deleted file mode 100644 index bd454037c..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/impl.h +++ /dev/null @@ -1,84 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* This file essentially describes how the mallink info block - is implemented. -*/ - -#define MIN_SIZE (1<>= 1; - mlp++; - } - while (n >= MIN_SIZE); - - ml1 = *--mlp; - set_log_prev(ml, MAL_NULL); - set_log_next(ml, ml1); - calc_checksum(ml); - if (ml1) { - /* link backwards - */ - set_log_prev(ml1, ml); - calc_checksum(ml1); - } - *mlp = ml; -} - -public -unlink_free_chunk(register mallink *ml) -{ - /* Unlinks a free chunk from (the middle of) the - logical chain. - */ - register mallink *next = log_next_of(ml); - register mallink *prev = log_prev_of(ml); - - if (!prev) { - /* it is the first in the chain */ - register mallink **mlp = &free_list[-1]; - register size_type n = size_of(ml); - - assert(n < (1L << LOG_MAX_SIZE)); - do { - n >>= 1; - mlp++; - } - while (n >= MIN_SIZE); - *mlp = next; - } - else { - set_log_next(prev, next); - calc_checksum(prev); - } - if (next) { - set_log_prev(next, prev); - calc_checksum(next); - } -} - -public mallink * -search_free_list(int class, size_t n) -{ - /* Searches the free_list[class] for a chunk of at least size n; - since it is searching a slightly undersized list, - such a block may not be there. - */ - register mallink *ml; - - for (ml = free_list[class]; ml; ml = log_next_of(ml)) - if (size_of(ml) >= n) - return ml; - return MAL_NULL; /* nothing found */ -} - -public mallink * -first_present(int class) -{ - /* Find the index i in free_list[] such that: - i >= class && free_list[i] != MAL_NULL. - Return MAL_NULL if no such i exists; - Otherwise, return the first block of this list, after - unlinking it. - */ - register mallink **mlp, *ml; - - for (mlp = &free_list[class]; mlp < &free_list[MAX_FLIST]; mlp++) { - if ((ml = *mlp) != MAL_NULL) { - - *mlp = log_next_of(ml); /* may be MAL_NULL */ - if (*mlp) { - /* unhook backward link - */ - set_log_prev(*mlp, MAL_NULL); - calc_checksum(*mlp); - } - return ml; - } - } - return MAL_NULL; -} - -#ifdef CHECK -public mallink * -free_list_entry(int i) { - /* To allow maldump.c access to log.c's private data. - */ - return free_list[i]; -} -#endif /* CHECK */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/log.h b/lang/cem/libcc.ansi/stdlib/malloc/log.h deleted file mode 100644 index f2ba3c947..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/log.h +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* Algorithms to manipulate the doubly-linked lists of free - chunks. -*/ - -public link_free_chunk(mallink *ml), unlink_free_chunk(mallink *ml); -public mallink *first_present(int class); -public mallink *search_free_list(int class, size_t n); - -#ifdef STORE -#define in_store(ml) ((size_type)_phys_prev_of(ml) & STORE_BIT) -#define set_store(ml, e) \ - (_phys_prev_of(ml) = (mallink *) \ - ((e) ? (size_type) _phys_prev_of(ml) | STORE_BIT : \ - (size_type) _phys_prev_of(ml) & ~STORE_BIT)) -#endif -#define set_log_prev(ml,e) (_log_prev_of(ml) = (e)) -#define log_prev_of(ml) (mallink *) (_log_prev_of(ml)) - -#define set_log_next(ml,e) (_log_next_of(ml) = (e)) -#define log_next_of(ml) (mallink *) (_log_next_of(ml)) - diff --git a/lang/cem/libcc.ansi/stdlib/malloc/mal.c b/lang/cem/libcc.ansi/stdlib/malloc/mal.c deleted file mode 100644 index d523c9ad1..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/mal.c +++ /dev/null @@ -1,385 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include -#include -#include "param.h" -#include "impl.h" -#include "check.h" -#include "log.h" -#include "phys.h" - -/* Malloc space is traversed by N doubly-linked lists of chunks, each - containing a couple of house-keeping data addressed as a - 'mallink' and a piece of useful space, called the block. - The N lists are accessed through their starting pointers in - free_list[]. Free_list[n] points to a list of chunks between - 2**(n+LOG_MIN_SIZE) and 2**(n+LOG_MIN_SIZE+1)-1, which means - that the smallest chunk is 2**LOG_MIN_SIZE (== MIN_SIZE). -*/ - -#ifdef SYSTEM -#include -#define SBRK sys_break -extern void *SBRK(int incr); -#else -#include -#define SBRK sbrk -#define ILL_BREAK (void *)(-1) /* funny failure value */ -#endif -#ifdef STORE -#define MAX_STORE 32 -private do_free(mallink *ml), sell_out(void); -privatedata mallink *store[MAX_STORE]; -#endif /* STORE */ - -void * -malloc(register size_t n) -{check_mallinks("malloc entry");{ - register mallink *ml; - register int min_class; - - if (n == 0) { - return NULL; - } - if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); -#ifdef STORE - if (n <= MAX_STORE*MIN_SIZE) { - /* look in the store first */ - register mallink **stp = &store[(n >> LOG_MIN_SIZE) - 1]; - - if (ml = *stp) { - *stp = log_next_of(ml); - set_store(ml, 0); - check_mallinks("malloc fast exit"); - assert(! in_store(ml)); - return block_of_mallink(ml); - } - } -#endif /* STORE */ - - check_work_empty("malloc, entry"); - - /* Acquire a chunk of at least size n if at all possible; - Try everything. - */ - { - /* Inline substitution of "smallest". - */ - register size_t n1 = n; - - assert(n1 < (1L << LOG_MAX_SIZE)); - min_class = 0; - - do { - n1 >>= 1; - min_class++; - } while (n1 >= MIN_SIZE); - } - - if (min_class >= MAX_FLIST) - return NULL; /* we don't deal in blocks that big */ - ml = first_present(min_class); - if (ml == MAL_NULL) { - /* Try and extend */ - register void *p; -#define GRABSIZE 4096 /* Power of 2 */ - register size_t req = - ((MIN_SIZE<= 0) p = SBRK((int)req); - } - if (p == ILL_BREAK) { - /* Now this is bad. The system will not give us - more memory. We can only liquidate our store - and hope it helps. - */ -#ifdef STORE - sell_out(); - ml = first_present(min_class); - if (ml == MAL_NULL) { -#endif /* STORE */ - /* In this emergency we try to locate a suitable - chunk in the free_list just below the safe - one; some of these chunks may fit the job. - */ - ml = search_free_list(min_class - 1, n); - if (!ml) /* really out of space */ - return NULL; - started_working_on(ml); - unlink_free_chunk(ml); - check_mallinks("suitable_chunk, forced"); -#ifdef STORE - } - else started_working_on(ml); -#endif /* STORE */ - } - else { - assert((size_type)p == align((size_type)p)); - ml = create_chunk(p, req); - } - check_mallinks("suitable_chunk, extended"); - } - else started_working_on(ml); - - /* we have a chunk */ - set_free(ml, 0); - calc_checksum(ml); - check_mallinks("suitable_chunk, removed"); - n += mallink_size(); - if (n + MIN_SIZE <= size_of(ml)) { - truncate(ml, n); - } - stopped_working_on(ml); - check_mallinks("malloc exit"); - check_work_empty("malloc exit"); -#ifdef STORE - assert(! in_store(ml)); -#endif - return block_of_mallink(ml); -}} - -void -free(void *addr) -{check_mallinks("free entry");{ - register mallink *ml; - - if (addr == NULL) { - check_mallinks("free(0) very fast exit"); - return; - } - - ml = mallink_of_block(addr); -#ifdef STORE - - if (free_of(ml) || in_store(ml)) - return; /* user frees free block */ - if (size_of(ml) <= MAX_STORE*MIN_SIZE) { - /* return to store */ - mallink **stp = &store[(size_of(ml) >> LOG_MIN_SIZE) - 1]; - - set_log_next(ml, *stp); - *stp = ml; - set_store(ml, 1); - calc_checksum(ml); - check_mallinks("free fast exit"); - } - else { - do_free(ml); - check_mallinks("free exit"); - } -}} - -private -do_free(register mallink *ml) -{{ -#endif - -#ifndef STORE - if (free_of(ml)) return; -#endif /* STORE */ - started_working_on(ml); - set_free(ml, 1); - calc_checksum(ml); - if (! last_mallink(ml)) { - register mallink *next = phys_next_of(ml); - - if (free_of(next)) coalesce_forw(ml, next); - } - - if (! first_mallink(ml)) { - register mallink *prev = phys_prev_of(ml); - - if (free_of(prev)) { - coalesce_backw(ml, prev); - ml = prev; - } - } - link_free_chunk(ml); - stopped_working_on(ml); - check_work_empty("free"); - - /* Compile-time checks on param.h */ - switch (0) { - case MIN_SIZE < OFF_SET * sizeof(mallink): break; - case 1: break; - /* If this statement does not compile due to duplicate case - entry, the minimum size block cannot hold the links for - the free blocks. Either raise LOG_MIN_SIZE or switch - off NON_STANDARD. - */ - } - switch(0) { - case sizeof(void *) != sizeof(size_type): break; - case 1: break; - /* If this statement does not compile due to duplicate - case entry, size_type is not defined correctly. - Redefine and compile again. - */ - } -}} - -void * -realloc(void *addr, register size_t n) -{check_mallinks("realloc entry");{ - register mallink *ml, *ph_next; - register size_type size; - - if (addr == NULL) { - /* Behave like most Unix realloc's when handed a - null-pointer - */ - return malloc(n); - } - if (n == 0) { - free(addr); - return NULL; - } - ml = mallink_of_block(addr); - if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); -#ifdef STORE - if (in_store(ml)) { - register mallink *stp = store[(size_of(ml) >> LOG_MIN_SIZE) - 1]; - mallink *stp1 = NULL; - while (ml != stp) { - stp1 = stp; - stp = log_next_of(stp); - } - stp = log_next_of(stp); - if (! stp1) store[(size_of(ml) >> LOG_MIN_SIZE) - 1] = stp; - else set_log_next(stp1, stp); - set_store(ml, 0); - calc_checksum(ml); - } -#endif - if (free_of(ml)) { - unlink_free_chunk(ml); - set_free(ml, 0); /* user reallocs free block */ - } - started_working_on(ml); - size = size_of(ml); - if ( /* we can simplify the problem by adding the next chunk: */ - n > size && - !last_mallink(ml) && - (ph_next = phys_next_of(ml), free_of(ph_next)) && - n <= size + mallink_size() + size_of(ph_next) - ) { - /* add in the physically next chunk */ - unlink_free_chunk(ph_next); - combine_chunks(ml, ph_next); - size = size_of(ml); - check_mallinks("realloc, combining"); - } - if (n > size) { /* this didn't help */ - void *new; - register char *l1, *l2 = addr; - - stopped_working_on(ml); - if (!(new = l1 = malloc(n))) return NULL; /* no way */ - while (size--) *l1++ = *l2++; - free(addr); - check_work_empty("mv_realloc"); -#ifdef STORE - assert(! in_store(mallink_of_block(new))); -#endif - return new; - } - /* it helped, but maybe too well */ - n += mallink_size(); - if (n + MIN_SIZE <= size_of(ml)) { - truncate(ml, n); - } - stopped_working_on(ml); - check_mallinks("realloc exit"); - check_work_empty("realloc"); -#ifdef STORE - assert(! in_store(ml)); -#endif - return addr; -}} - -void * -calloc(size_t nmemb, size_t size) -{check_mallinks("calloc entry");{ - long *l1, *l2; - size_t n; - - if (size == 0) return NULL; - if (nmemb == 0) return NULL; - - /* Check for overflow on the multiplication. The peephole-optimizer - * will eliminate all but one of the possibilities. - */ - if (sizeof(size_t) == sizeof(int)) { - if (UINT_MAX / size < nmemb) return NULL; - } else if (sizeof(size_t) == sizeof(long)) { - if (ULONG_MAX / size < nmemb) return NULL; - } else return NULL; /* can't happen, can it ? */ - - n = size * nmemb; - if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); - if (n >= (1L << LOG_MAX_SIZE)) return NULL; - l1 = (long *) malloc(n); - l2 = l1 + (n / sizeof(long)); /* n is at least long aligned */ - while ( l2 != l1 ) *--l2 = 0; - check_mallinks("calloc exit"); - check_work_empty("calloc exit"); - return (void *)l1; -}} -/* Auxiliary routines */ - -#ifdef STORE -private -sell_out(void) { - /* Frees all block in store. - */ - register mallink **stp; - - for (stp = &store[0]; stp < &store[MAX_STORE]; stp++) { - register mallink *ml = *stp; - - while (ml) { - *stp = log_next_of(ml); - set_store(ml, 0); - do_free(ml); - ml = *stp; - } - } - -} -#endif /* STORE */ - -#ifdef ASSERT -public -m_assert(const char *fn, int ln) -{ - char ch; - - while (*fn) - write(2, fn++, 1); - write(2, ": malloc assert failed in line ", 31); - ch = (ln / 100) + '0'; write(2, &ch, 1); ln %= 100; - ch = (ln / 10) + '0'; write(2, &ch, 1); ln %= 10; - ch = (ln / 1) + '0'; write(2, &ch, 1); - write(2, "\n", 1); - maldump(1); -} -#endif /* ASSERT */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/param.h b/lang/cem/libcc.ansi/stdlib/malloc/param.h deleted file mode 100644 index b47c0d430..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/param.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include "size_type.h" - -# define NON_STANDARD /* If defined, the contents of a block - will NOT be left undisturbed after it - is freed, as opposed to what it says - in the manual (malloc(2)). - Setting this option reduces the memory - overhead considerably. I personally - consider the specified behaviour an - artefact of the original - implementation. - */ - -# undef ASSERT /* If defined, some inexpensive tests - will be made to ensure the - correctness of some sensitive data. - It often turns an uncontrolled crash - into a controlled one. - */ - -# undef CHECK /* If defined, extensive and expensive - tests will be done, inculding a - checksum on the mallinks (chunk - information blocks). The resulting - information will be printed on a file - called mal.out . - Additionally a function - maldump(n) int n; - will be defined, which will dump - pertinent info in pseudo-readable - form; it aborts afterwards if n != 0. - */ - -# undef EXTERN /* If defined, all static names will - become extern, which is a help in - using adb(1) or prof(1) - */ - -# define STORE /* If defined, separate free lists will - be kept of chunks with small sizes, - to speed things up a little. - */ - -# undef SYSTEM /* If defined, the system module is used. - Otherwise, "sbrk" is called directly. - */ - -#define ALIGNMENT 8 - /* alignment common to all types */ -#define LOG_MIN_SIZE 3 -#define LOG_MAX_SIZE 24 diff --git a/lang/cem/libcc.ansi/stdlib/malloc/phys.c b/lang/cem/libcc.ansi/stdlib/malloc/phys.c deleted file mode 100644 index 3d14fa35c..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/phys.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include -#include "param.h" -#include "impl.h" -#include "check.h" -#include "phys.h" - -/* Physical manipulations. - The blocks concerned are not in any logical chain. -*/ - -public mallink * -create_chunk(void *p, size_t n) -{ - /* The newly acquired piece of memory at p, of length n, - is turned into a free chunk, properly chained in the - physical chain. - The address of the chunk is returned. - */ - register mallink *ml; - /* All of malloc memory is followed by a virtual chunk, the - mallink of which starts mallink_size() bytes past the last - byte in memory. - Its use is prevented by testing for ml == ml_last first. - */ - register mallink *last = ml_last; - - assert(!last || p == (char *)phys_next_of(last) - mallink_size()); - ml = (mallink *)((char *)p + mallink_size()); /* bump ml */ - new_mallink(ml); - started_working_on(ml); - set_free(ml, 1); - set_phys_prev(ml, last); - ml_last = ml; - - set_phys_next(ml, (mallink *)((char *)ml + n)); - calc_checksum(ml); - assert(size_of(ml) + mallink_size() == n); - if (last && free_of(last)) { - coalesce_backw(ml, last); - ml = last; - } - check_mallinks("create_chunk, phys. linked"); - return ml; -} - -public -truncate(register mallink *ml, size_t size) -{ - /* The chunk ml is truncated. - The chunk at ml is split in two. - The remaining part is then freed. - */ - register mallink *new = (mallink *)((char *)ml + size); - register mallink *ph_next = phys_next_of(ml); - - new_mallink(new); - set_free(new, 1); - set_phys_prev(new, ml); - set_phys_next(new, ph_next); - calc_checksum(new); - if (! last_mallink(ml)) { - set_phys_prev(ph_next, new); - calc_checksum(ph_next); - if (free_of(ph_next)) coalesce_forw(new, ph_next); - } - else ml_last = new; - set_phys_next(ml, new); - calc_checksum(ml); - - started_working_on(new); - link_free_chunk(new); - stopped_working_on(new); - check_mallinks("truncate"); -} - -public -combine_chunks(register mallink *ml1, register mallink *ml2) -{ - /* The chunks ml1 and ml2 are combined. - */ - register mallink *ml3 = phys_next_of(ml2); - - set_phys_next(ml1, ml3); - calc_checksum(ml1); - if (!last_mallink(ml2)) { - set_phys_prev(ml3, ml1); - calc_checksum(ml3); - } - if (ml_last == ml2) - ml_last = ml1; -} diff --git a/lang/cem/libcc.ansi/stdlib/malloc/phys.h b/lang/cem/libcc.ansi/stdlib/malloc/phys.h deleted file mode 100644 index 67fb9838d..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/phys.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* Algorithms to manipulate the doubly-linked list of physical - chunks. -*/ -publicdata mallink *ml_last; - -#define FREE_BIT 01 -#ifdef STORE -#define STORE_BIT 02 -#define BITS (FREE_BIT|STORE_BIT) -#else -#define BITS (FREE_BIT) -#endif - -#define __bits(ml) ((int)((size_type)_phys_prev_of(ml) & BITS)) -#define __free_of(ml) ((int)((size_type)_phys_prev_of(ml) & FREE_BIT)) -#define __phys_prev_of(ml) ((mallink *)((size_type)_phys_prev_of(ml) & ~BITS)) -#define prev_size_of(ml) ((char *)(ml) - \ - (char *)__phys_prev_of(ml) - \ - mallink_size() \ - ) -#define set_phys_prev(ml,e) \ - (_phys_prev_of(ml) = (mallink *) ((char *)e + __bits(ml))) - -#ifdef CHECK -public Error(const char *fmt, const char *s, mallink *ml); -#define phys_prev_of(ml) (mallink *) \ - (first_mallink(ml) ? \ - (char *)Error("phys_prev_of first_mallink %p", "somewhere", ml) : \ - (char *)__phys_prev_of(ml) \ - ) -#else /* ndef CHECK */ -#define phys_prev_of(ml) __phys_prev_of(ml) -#endif /* CHECK */ - -#define first_mallink(ml) (int) (__phys_prev_of(ml) == 0) -#define last_mallink(ml) (int) ((ml) == ml_last) - -/* There is an ambiguity in the semantics of phys_next_of: sometimes - one wants it to return MAL_NULL if there is no next chunk, at - other times one wants the address of the virtual chunk at the - end of memory. The present version returns the address of the - (virtual) chunk and relies on the user to test last_mallink(ml) - first. -*/ -#define size_of(ml) (_this_size_of(ml) - mallink_size()) -#define set_phys_next(ml,e) \ - (_this_size_of(ml) = (size_type)((char *)(e) - (char *)(ml))) -#define phys_next_of(ml) (mallink *) ((char *)(ml) + _this_size_of(ml)) - -#define set_free(ml,e) \ - (_phys_prev_of(ml) = (mallink *) \ - ((e) ? (size_type) _phys_prev_of(ml) | FREE_BIT : \ - (size_type) _phys_prev_of(ml) & ~FREE_BIT)) -#define free_of(ml) (__free_of(ml)) - -#define coalesce_forw(ml,nxt) ( unlink_free_chunk(nxt), \ - combine_chunks((ml), (nxt))) - -#define coalesce_backw(ml,prv) ( unlink_free_chunk(prv), \ - stopped_working_on(ml), \ - combine_chunks((prv), (ml)), \ - started_working_on(prv)) - -#ifdef CHECK -#define set_print(ml,e) (_print_of(ml) = (e)) -#define print_of(ml) (_print_of(ml)) -#endif /* CHECK */ - -public truncate(mallink *ml, size_t size); -public combine_chunks(register mallink *ml1, register mallink *ml2); -public mallink *create_chunk(void *p, size_t n); diff --git a/lang/cem/libcc.ansi/stdlib/malloc/size_type.h b/lang/cem/libcc.ansi/stdlib/malloc/size_type.h deleted file mode 100644 index b39609ea1..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/size_type.h +++ /dev/null @@ -1,8 +0,0 @@ -#if _EM_WSIZE == _EM_PSIZE -typedef unsigned int size_type; -#elif _EM_LSIZE == _EM_PSIZE -typedef unsigned long size_type; -#else -#error funny pointer size -#endif -#include From b592c88bdfb468081e0402538b5bfc99b80f6165 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 12 Aug 2016 00:19:30 +0200 Subject: [PATCH 175/231] replace() gets confused if you give it a singleton list as its parameter. --- first/ackbuilder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index c7798e6b8..b59cb2a67 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -253,7 +253,7 @@ local function dirname(...) end local function replace(files, pattern, repl) - return dotocollection(files, + return dotocollection({files}, function(filename) return filename:gsub(pattern, repl) end From 7c60c27302a1fc023984c15052cc3a4212d3714e Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 12 Aug 2016 00:19:51 +0200 Subject: [PATCH 176/231] The Basic compiler works now. --- build.lua | 1 + lang/basic/src/basic.g | 4 +-- lang/basic/src/basic.lex | 2 -- lang/basic/src/build.lua | 47 +++++++++++++++++++++++++++ lang/basic/src/{llmess.c => llmess.h} | 0 lang/basic/src/maketokentab | 4 +-- lang/basic/src/{yylexp.c => yylexp.h} | 0 plat/build.lua | 1 + 8 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 lang/basic/src/build.lua rename lang/basic/src/{llmess.c => llmess.h} (100%) rename lang/basic/src/{yylexp.c => yylexp.h} (100%) diff --git a/build.lua b/build.lua index 373f195e3..0b1637f63 100644 --- a/build.lua +++ b/build.lua @@ -12,6 +12,7 @@ installable { name = "ack", map = { "lang/cem/cemcom.ansi+pkg", + "lang/basic/src+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/lang/basic/src/basic.g b/lang/basic/src/basic.g index 8f74a69f7..5c4f6978a 100644 --- a/lang/basic/src/basic.g +++ b/lang/basic/src/basic.g @@ -90,7 +90,7 @@ #include #include #include "bem.h" -#include "llmess.c" +#include "llmess.h" typedef union { int integer ; @@ -112,7 +112,7 @@ int in_data = 0; /* set if processing DATA statement */ char *formatstring; /* formatstring used for printing */ Symbol *s; /* Symbol dummy */ -#include "yylexp.c" +#include "yylexp.h" #include "basic.lex" } diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index 0f514c97d..4eb9e1659 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -235,8 +235,6 @@ File *stream; } } -extern char *strchr(); - getinputline() { /* get next input line */ diff --git a/lang/basic/src/build.lua b/lang/basic/src/build.lua new file mode 100644 index 000000000..001ca037a --- /dev/null +++ b/lang/basic/src/build.lua @@ -0,0 +1,47 @@ +include("util/LLgen/build.lua") + +llgen { + name = "llgen", + srcs = { "./*.g" } +} + +normalrule { + name = "tokentab_h", + ins = { + "./maketokentab", + matching(filenamesof("+llgen"), "/Lpars.h$"), + }, + outleaves = { "tokentab.h" }, + commands = { + "%{ins} %{outs}" + } +} + +cprogram { + name = "em_bem", + srcs = { + "./*.c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+llgen", + "+tokentab_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/em_mes+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "util/data+em_data", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_bem"] = "+em_bem" + } +} + diff --git a/lang/basic/src/llmess.c b/lang/basic/src/llmess.h similarity index 100% rename from lang/basic/src/llmess.c rename to lang/basic/src/llmess.h diff --git a/lang/basic/src/maketokentab b/lang/basic/src/maketokentab index 6ceee720d..777eb1402 100755 --- a/lang/basic/src/maketokentab +++ b/lang/basic/src/maketokentab @@ -1,6 +1,6 @@ #!/bin/sh -ed -s "${1:-Lpars.h}" <<'+' +ed -s "${1:-Lpars.h}" > $2 <<'+' 1d 1,$s/# *define // 1,$s/ ...$// @@ -13,6 +13,6 @@ char *tokentab[] = { $a }; . -w tokentab.h +1,$p q + diff --git a/lang/basic/src/yylexp.c b/lang/basic/src/yylexp.h similarity index 100% rename from lang/basic/src/yylexp.c rename to lang/basic/src/yylexp.h diff --git a/plat/build.lua b/plat/build.lua index 472e9ec3f..52c45fdd4 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -13,6 +13,7 @@ definerule("ackfile", name = e.name, srcs = e.srcs, deps = { + "lang/cem/cemcom.ansi+pkg", "lang/cem/cpp.ansi+pkg", "plat/"..plat.."+tools", "util/ack+pkg", From 08b7c4aaaeaf5fdc01c5f4d4f9d84d3601697d7b Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 12 Aug 2016 00:24:40 +0200 Subject: [PATCH 177/231] The Basic runtime builds now. --- lang/basic/lib/build.lua | 26 ++++++++++++++++++++++++++ plat/build.lua | 7 ++++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 lang/basic/lib/build.lua diff --git a/lang/basic/lib/build.lua b/lang/basic/lib/build.lua new file mode 100644 index 000000000..f0fe3724b --- /dev/null +++ b/lang/basic/lib/build.lua @@ -0,0 +1,26 @@ +include("plat/build.lua") + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.c", + "./*.e", + }, + hdrs = {}, -- must be empty + deps = { + "h+emheaders", + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."+headers", + }, + vars = { plat = plat } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/libbasic.a"] = "+lib_"..plat, + } + } +end + diff --git a/plat/build.lua b/plat/build.lua index 52c45fdd4..c6019d34a 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -90,10 +90,11 @@ definerule("build_plat_libs", return installable { name = e.name, map = { - ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, - ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, - ["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat, + "lang/basic/lib+pkg_"..e.plat, "lang/cem/libcc.ansi+pkg_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat, } } end From 8e869b56e7f61d1ff43ac17f3c6c16e4a97cd682 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 13 Aug 2016 00:02:21 +0200 Subject: [PATCH 178/231] The Modula-2 compiler now builds. --- build.lua | 3 +- lang/m2/comp/build.lua | 133 +++++++++++++++++++++++++++++++++++ lang/m2/comp/make.parameters | 7 ++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 lang/m2/comp/build.lua create mode 100755 lang/m2/comp/make.parameters diff --git a/build.lua b/build.lua index 0b1637f63..028e6f0ab 100644 --- a/build.lua +++ b/build.lua @@ -11,8 +11,9 @@ vars.plats = { installable { name = "ack", map = { - "lang/cem/cemcom.ansi+pkg", "lang/basic/src+pkg", + "lang/cem/cemcom.ansi+pkg", + "lang/m2/comp+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua new file mode 100644 index 000000000..b17eb31ff --- /dev/null +++ b/lang/m2/comp/build.lua @@ -0,0 +1,133 @@ +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c" + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +llgen { + name = "llgen", + srcs = { + -- order here is important + "+tokenfile_g", + "./*.g", + } +} + +normalrule { + name = "parameters_h", + ins = { + "./make.parameters", + "./BigPars", + }, + outleaves = { "parameters.h" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +for _, f in ipairs(filenamesof("./*.H")) do + local name = replace(basename(f), "%.H$", "") + normalrule { + name = name.."_h", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +for _, f in ipairs(filenamesof("./*.C")) do + local name = replace(basename(f), "%.C$", "") + normalrule { + name = name.."_c", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.H", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } +} + +tabgen { + name = "chartab_c", + srcs = { "./char.tab" }, +} + +cprogram { + name = "em_m2", + srcs = { + "./*.c", + "+casestat_c", + "+next_c", + "+scope_c", + "+symbol2str_c", + "+tmpvar_c", + "+chartab_c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+def_h", + "+llgen", + "+node_h", + "+parameters_h", + "+real_h", + "+type_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "modules/src/print+lib", + "modules/src/em_mes+lib", + "util/data+em_data", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_m2"] = "+em_m2", + ["$(INSDIR)/share/man/man6/em_m2.6"] = "./em_m2.6" + } +} diff --git a/lang/m2/comp/make.parameters b/lang/m2/comp/make.parameters new file mode 100755 index 000000000..3c9a515c5 --- /dev/null +++ b/lang/m2/comp/make.parameters @@ -0,0 +1,7 @@ +#!/bin/sh + +echo '#ifndef PARAMETERS_H' +echo '#define PARAMETERS_H' +grep -v '^!' +echo '#endif' + From dbf8332bf0aa136ba80a3d9db77d040696db9a21 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 13 Aug 2016 12:21:16 +0200 Subject: [PATCH 179/231] Fixed a small bug where two line number directives next to each other wouldn't be parsed properly (the second one would be treated as Modula-2 syntax). --- lang/m2/comp/LLlex.c | 78 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index c118e997a..1eacae76f 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -188,55 +188,57 @@ CheckForLineDirective() register char *c = buf; - if (ch != '#') { - PushBack(); - return; - } - do { /* - * Skip to next digit - * Do not skip newlines - */ - ch = getch(); - if (class(ch) == STNL || class(ch) == STEOI) { - LineNumber++; - error(s_error); + for (;;) { + if (ch != '#') { + PushBack(); return; } - } while (class(ch) != STNUM); - while (class(ch) == STNUM) { - i = i*10 + (ch - '0'); - ch = getch(); - } - while (ch != '"' && class(ch) != STNL && class(ch) != STEOI) - ch = getch(); - if (ch == '"') { - c = buf; - do { + do { /* + * Skip to next digit + * Do not skip newlines + */ ch = getch(); - if (c < &buf[IDFSIZE]) *c++ = ch; if (class(ch) == STNL || class(ch) == STEOI) { LineNumber++; error(s_error); return; } - } while (ch != '"'); - *--c = '\0'; - do { + } while (class(ch) != STNUM); + while (class(ch) == STNUM) { + i = i*10 + (ch - '0'); ch = getch(); - } while (class(ch) != STNL && class(ch) != STEOI); - /* - * Remember the file name - */ - if (class(ch) == STNL && strcmp(FileName,buf)) { - FileName = Salloc(buf,(unsigned) strlen(buf) + 1); - WorkingDir = getwdir(FileName); } + while (ch != '"' && class(ch) != STNL && class(ch) != STEOI) + ch = getch(); + if (ch == '"') { + c = buf; + do { + ch = getch(); + if (c < &buf[IDFSIZE]) *c++ = ch; + if (class(ch) == STNL || class(ch) == STEOI) { + LineNumber++; + error(s_error); + return; + } + } while (ch != '"'); + *--c = '\0'; + do { + ch = getch(); + } while (class(ch) != STNL && class(ch) != STEOI); + /* + * Remember the file name + */ + if (class(ch) == STNL && strcmp(FileName,buf)) { + FileName = Salloc(buf,(unsigned) strlen(buf) + 1); + WorkingDir = getwdir(FileName); + } + } + if (class(ch) == STEOI) { + error(s_error); + return; + } + LineNumber = i; } - if (class(ch) == STEOI) { - error(s_error); - return; - } - LineNumber = i; } STATIC From 00c67fcc0e0a0e17d918f06ce129cc4546df2ebd Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 13 Aug 2016 12:43:44 +0200 Subject: [PATCH 180/231] Modula-2 runtime library now builds. --- lang/m2/libm2/build.lua | 58 +++++++++++++++++++++++++++++++++++++++++ lang/m2/libm2/build.mk | 54 +++++++++++++++++++------------------- plat/build.lua | 2 ++ 3 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 lang/m2/libm2/build.lua diff --git a/lang/m2/libm2/build.lua b/lang/m2/libm2/build.lua new file mode 100644 index 000000000..f49a10a4c --- /dev/null +++ b/lang/m2/libm2/build.lua @@ -0,0 +1,58 @@ +include("plat/build.lua") + +local installmap = {} + +local function addheader(dir, list) + for _, f in ipairs(list) do + local b = basename(f) + installmap[concatpath("$(PLATIND)/include/modula2/", dir, b)] = f + end +end + +addheader("", filenamesof("./*.def")) + +installable { + name = "headers", + map = installmap +} + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.c", + "./*.mod", + "./EM.e", + "./LtoUset.e", + "./absf.e", + "./par_misc.e", + }, + hdrs = {}, -- must be empty + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."+headers", + "h+emheaders", + }, + vars = { plat = plat } + } + + ackfile { + name = "mrt_"..plat, + srcs = { "./head_m2.e" }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/modula2.o"] = "+mrt_"..plat, + ["$(PLATIND)/"..plat.."/libmodula2.a"] = "+lib_"..plat, + "+headers", + } + } +end + + diff --git a/lang/m2/libm2/build.mk b/lang/m2/libm2/build.mk index 1ebc89cc3..e7c27eac4 100644 --- a/lang/m2/libm2/build.mk +++ b/lang/m2/libm2/build.mk @@ -3,51 +3,51 @@ define build-runtime-libmodula2-impl $(call reset) $(eval objdir := $(PLATFORM)) -$(call ackfile, lang/m2/libm2/Termcap.mod) +$(call ackfile, lang/m2/libm2/Arguments.c) +$(call ackfile, lang/m2/libm2/ArraySort.mod) $(call ackfile, lang/m2/libm2/CSP.mod) -$(call ackfile, lang/m2/libm2/PascalIO.mod) -$(call ackfile, lang/m2/libm2/RealInOut.mod) +$(call ackfile, lang/m2/libm2/Conversion.mod) +$(call ackfile, lang/m2/libm2/EM.e) $(call ackfile, lang/m2/libm2/InOut.mod) -$(call ackfile, lang/m2/libm2/Streams.mod) +$(call ackfile, lang/m2/libm2/LtoUset.e) $(call ackfile, lang/m2/libm2/MathLib0.mod) $(call ackfile, lang/m2/libm2/Mathlib.mod) +$(call ackfile, lang/m2/libm2/PascalIO.mod) $(call ackfile, lang/m2/libm2/Processes.mod) $(call ackfile, lang/m2/libm2/RealConver.mod) -$(call ackfile, lang/m2/libm2/Storage.mod) -$(call ackfile, lang/m2/libm2/Conversion.mod) +$(call ackfile, lang/m2/libm2/RealInOut.mod) +$(call ackfile, lang/m2/libm2/SYSTEM.c) $(call ackfile, lang/m2/libm2/Semaphores.mod) -$(call ackfile, lang/m2/libm2/random.mod) +$(call ackfile, lang/m2/libm2/Storage.mod) +$(call ackfile, lang/m2/libm2/StrAss.c) +$(call ackfile, lang/m2/libm2/Streams.mod) $(call ackfile, lang/m2/libm2/Strings.mod) -$(call ackfile, lang/m2/libm2/ArraySort.mod) -$(call ackfile, lang/m2/libm2/catch.c) +$(call ackfile, lang/m2/libm2/Termcap.mod) $(call ackfile, lang/m2/libm2/Traps.mod) $(call ackfile, lang/m2/libm2/XXTermcap.c) -$(call ackfile, lang/m2/libm2/dvi.c) -$(call ackfile, lang/m2/libm2/Arguments.c) -$(call ackfile, lang/m2/libm2/LtoUset.e) -$(call ackfile, lang/m2/libm2/StrAss.c) -$(call ackfile, lang/m2/libm2/cap.c) $(call ackfile, lang/m2/libm2/absd.c) $(call ackfile, lang/m2/libm2/absf.e) $(call ackfile, lang/m2/libm2/absi.c) $(call ackfile, lang/m2/libm2/absl.c) -$(call ackfile, lang/m2/libm2/halt.c) -$(call ackfile, lang/m2/libm2/SYSTEM.c) -$(call ackfile, lang/m2/libm2/par_misc.e) -$(call ackfile, lang/m2/libm2/init.c) -$(call ackfile, lang/m2/libm2/sigtrp.c) -$(call ackfile, lang/m2/libm2/store.c) -$(call ackfile, lang/m2/libm2/confarray.c) -$(call ackfile, lang/m2/libm2/load.c) $(call ackfile, lang/m2/libm2/blockmove.c) -$(call ackfile, lang/m2/libm2/stackprio.c) -$(call ackfile, lang/m2/libm2/ucheck.c) +$(call ackfile, lang/m2/libm2/cap.c) +$(call ackfile, lang/m2/libm2/catch.c) +$(call ackfile, lang/m2/libm2/confarray.c) +$(call ackfile, lang/m2/libm2/dvi.c) +$(call ackfile, lang/m2/libm2/halt.c) +$(call ackfile, lang/m2/libm2/init.c) +$(call ackfile, lang/m2/libm2/load.c) +$(call ackfile, lang/m2/libm2/par_misc.e) +$(call ackfile, lang/m2/libm2/random.mod) $(call ackfile, lang/m2/libm2/rcka.c) -$(call ackfile, lang/m2/libm2/rcku.c) $(call ackfile, lang/m2/libm2/rcki.c) -$(call ackfile, lang/m2/libm2/rckul.c) $(call ackfile, lang/m2/libm2/rckil.c) -$(call ackfile, lang/m2/libm2/EM.e) +$(call ackfile, lang/m2/libm2/rcku.c) +$(call ackfile, lang/m2/libm2/rckul.c) +$(call ackfile, lang/m2/libm2/sigtrp.c) +$(call ackfile, lang/m2/libm2/stackprio.c) +$(call ackfile, lang/m2/libm2/store.c) +$(call ackfile, lang/m2/libm2/ucheck.c) $(eval $q: $(EM_M2)) diff --git a/plat/build.lua b/plat/build.lua index c6019d34a..64bccf89d 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -15,6 +15,7 @@ definerule("ackfile", deps = { "lang/cem/cemcom.ansi+pkg", "lang/cem/cpp.ansi+pkg", + "lang/m2/comp+pkg", "plat/"..plat.."+tools", "util/ack+pkg", "util/misc+pkg", @@ -91,6 +92,7 @@ definerule("build_plat_libs", name = e.name, map = { "lang/basic/lib+pkg_"..e.plat, + "lang/m2/libm2+pkg_"..e.plat, "lang/cem/libcc.ansi+pkg_"..e.plat, ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, From e770d09dc8d8909ea3c5d1886cc532031f3ffb4c Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 13 Aug 2016 13:03:06 +0200 Subject: [PATCH 181/231] Pascal compiler builds. --- build.lua | 1 + lang/m2/comp/build.lua | 1 + lang/pc/comp/build.lua | 137 +++++++++++++++++++++++++++++++++++ lang/pc/comp/make.parameters | 7 ++ plat/build.lua | 1 + 5 files changed, 147 insertions(+) create mode 100644 lang/pc/comp/build.lua create mode 100755 lang/pc/comp/make.parameters diff --git a/build.lua b/build.lua index 028e6f0ab..30da3e902 100644 --- a/build.lua +++ b/build.lua @@ -14,6 +14,7 @@ installable { "lang/basic/src+pkg", "lang/cem/cemcom.ansi+pkg", "lang/m2/comp+pkg", + "lang/pc/comp+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua index b17eb31ff..fde8442ae 100644 --- a/lang/m2/comp/build.lua +++ b/lang/m2/comp/build.lua @@ -66,6 +66,7 @@ normalrule { ins = { "./make.next", "./*.H", + "./*.C", }, outleaves = { "next.c" }, commands = { diff --git a/lang/pc/comp/build.lua b/lang/pc/comp/build.lua new file mode 100644 index 000000000..8b058345b --- /dev/null +++ b/lang/pc/comp/build.lua @@ -0,0 +1,137 @@ +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c" + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +llgen { + name = "llgen", + srcs = { + -- order here is important + "+tokenfile_g", + "./*.g", + } +} + +normalrule { + name = "parameters_h", + ins = { + "./make.parameters", + "./Parameters", + }, + outleaves = { "parameters.h" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +for _, f in ipairs(filenamesof("./*.H")) do + local name = replace(basename(f), "%.H$", "") + normalrule { + name = name.."_h", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +for _, f in ipairs(filenamesof("./*.C")) do + local name = replace(basename(f), "%.C$", "") + normalrule { + name = name.."_c", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.H", + "./*.C", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } +} + +tabgen { + name = "chartab_c", + srcs = { "./char.tab" }, +} + +cprogram { + name = "em_pc", + srcs = { + "./*.c", + "+casestat_c", + "+chartab_c", + "+next_c", + "+symbol2str_c", + "+tmpvar_c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+def_h", + "+desig_h", + "+llgen", + "+node_h", + "+parameters_h", + "+scope_h", + "+type_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "modules/src/print+lib", + "modules/src/em_mes+lib", + "util/data+em_data", + }, + vars = { + ["+cflags"] = "-DSTATIC=static" + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_pc"] = "+em_pc", + ["$(INSDIR)/share/man/man6/em_pc.6"] = "./em_pc.6" + } +} diff --git a/lang/pc/comp/make.parameters b/lang/pc/comp/make.parameters new file mode 100755 index 000000000..3c9a515c5 --- /dev/null +++ b/lang/pc/comp/make.parameters @@ -0,0 +1,7 @@ +#!/bin/sh + +echo '#ifndef PARAMETERS_H' +echo '#define PARAMETERS_H' +grep -v '^!' +echo '#endif' + diff --git a/plat/build.lua b/plat/build.lua index 64bccf89d..8802ce636 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -16,6 +16,7 @@ definerule("ackfile", "lang/cem/cemcom.ansi+pkg", "lang/cem/cpp.ansi+pkg", "lang/m2/comp+pkg", + "lang/pc/comp+pkg", "plat/"..plat.."+tools", "util/ack+pkg", "util/misc+pkg", From e0b8bd221d3e2b6ca355d212b9ca913e8ec22909 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 13 Aug 2016 13:07:19 +0200 Subject: [PATCH 182/231] Pascal runtime library now builds. --- lang/pc/libpc/build.lua | 46 +++++++++++++++++++++++++++++++++++++++++ plat/build.lua | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 lang/pc/libpc/build.lua diff --git a/lang/pc/libpc/build.lua b/lang/pc/libpc/build.lua new file mode 100644 index 000000000..a86ce616e --- /dev/null +++ b/lang/pc/libpc/build.lua @@ -0,0 +1,46 @@ +include("plat/build.lua") + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.c", + "./bts.e", + "./encaps.e", + "./fef.e", + "./fif.e", + "./gto.e", + "./hol0.e", + "./sav.e", + "./sig.e", + "./trap.e", + "./trp.e", + }, + hdrs = {}, -- must be empty + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."+headers", + "h+emheaders", + }, + vars = { plat = plat } + } + + ackfile { + name = "prt_"..plat, + srcs = { "./head_pc.e" }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/pascal.o"] = "+prt_"..plat, + ["$(PLATIND)/"..plat.."/libpascal.a"] = "+lib_"..plat, + } + } +end + + diff --git a/plat/build.lua b/plat/build.lua index 8802ce636..05f746fea 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -93,8 +93,9 @@ definerule("build_plat_libs", name = e.name, map = { "lang/basic/lib+pkg_"..e.plat, - "lang/m2/libm2+pkg_"..e.plat, "lang/cem/libcc.ansi+pkg_"..e.plat, + "lang/m2/libm2+pkg_"..e.plat, + "lang/pc/libpc+pkg_"..e.plat, ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, ["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat, From 10746f8b97864d34b14f1842edcff9dc28f1b145 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 01:38:36 +0200 Subject: [PATCH 183/231] Add cycle detection, because it was ruining my day. Allow targets to be stored in a file called build-.lua to allow better dividing up of build rules (to break cycles). --- first/ackbuilder.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index b59cb2a67..1c4aca339 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -17,6 +17,7 @@ local globals local cwd = "." local vars = {} local parente = {} +local loadingstack = {} -- Forward references local loadtarget @@ -66,6 +67,16 @@ local function concat(...) return r end +-- Test table membership (crudely). +local function contains(needle, haystack) + for _, k in ipairs(haystack) do + if (k == needle) then + return true + end + end + return false +end + local function inherit(high, low) local o = {} setmetatable(o, { @@ -351,6 +362,12 @@ local function templateexpand(list, vars) end local function loadbuildfile(filename) + if contains(filename, loadingstack) then + error(string.format("build file cycle; '%s' refers to itself indirectly; stack is: %s %s", + filename, asstring(loadingstack), filename)) + end + + loadingstack[#loadingstack+1] = filename if not buildfiles[filename] then buildfiles[filename] = true @@ -376,6 +393,7 @@ local function loadbuildfile(filename) chunk() cwd = oldcwd end + loadingstack[#loadingstack] = nil end loadtarget = function(targetname) @@ -411,7 +429,12 @@ loadtarget = function(targetname) filepart = cwd end local filename = concatpath(filepart, "/build.lua") - loadbuildfile(concatpath(filename)) + if posix.access(filename, "r") then + loadbuildfile(filename) + else + filename = concatpath(filepart, "/build-"..targetpart..".lua") + loadbuildfile(filename) + end target = targets[targetname] if not target then From 262c5fedcf72af4904baef131c4b8a7c0fe94048 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 01:39:40 +0200 Subject: [PATCH 184/231] Biggish refactor to break cycles; my build rules were full of them. cpm builds, which requires top and topgen. --- build.lua | 4 ++- lang/cem/cpp.ansi/build.lua | 1 + mach/i80/libem/build.lua | 8 +++++ mach/i80/libend/build.lua | 8 +++++ mach/proto/top/build.lua | 19 ++++++++++++ plat/build.lua | 39 +++-------------------- plat/cpm/build-headers.lua | 11 +++++++ plat/cpm/build-pkg.lua | 24 ++++++++++++++ plat/cpm/build-tools.lua | 27 ++++++++++++++++ plat/pc86/build-headers.lua | 10 ++++++ plat/pc86/{build.lua => build-pkg.lua} | 15 --------- plat/pc86/build-tools.lua | 21 +++++++++++++ util/topgen/build.lua | 43 ++++++++++++++++++++++++++ util/topgen/main.c | 8 +++-- 14 files changed, 185 insertions(+), 53 deletions(-) create mode 100644 mach/i80/libem/build.lua create mode 100644 mach/i80/libend/build.lua create mode 100644 mach/proto/top/build.lua create mode 100644 plat/cpm/build-headers.lua create mode 100644 plat/cpm/build-pkg.lua create mode 100644 plat/cpm/build-tools.lua create mode 100644 plat/pc86/build-headers.lua rename plat/pc86/{build.lua => build-pkg.lua} (54%) create mode 100644 plat/pc86/build-tools.lua create mode 100644 util/topgen/build.lua diff --git a/build.lua b/build.lua index 30da3e902..c5a59a135 100644 --- a/build.lua +++ b/build.lua @@ -5,7 +5,8 @@ vars.ackcflags = { "-O" } vars.plats = { - "pc86" + "pc86", + "cpm", } installable { @@ -15,6 +16,7 @@ installable { "lang/cem/cemcom.ansi+pkg", "lang/m2/comp+pkg", "lang/pc/comp+pkg", + "plat/cpm+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua index 1f22fe88f..be124530f 100644 --- a/lang/cem/cpp.ansi/build.lua +++ b/lang/cem/cpp.ansi/build.lua @@ -1,4 +1,5 @@ include("util/cmisc/build.lua") +include("util/LLgen/build.lua") local allocd_header = definerule(nil, { diff --git a/mach/i80/libem/build.lua b/mach/i80/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i80/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i80/libend/build.lua b/mach/i80/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i80/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/proto/top/build.lua b/mach/proto/top/build.lua new file mode 100644 index 000000000..56ee652b9 --- /dev/null +++ b/mach/proto/top/build.lua @@ -0,0 +1,19 @@ +include("util/topgen/build.lua") + +definerule("build_top", + { + arch = { type="string" }, + }, + function(e) + local t = topgen { + name = e.name.."_topgen", + srcs = { "mach/"..e.arch.."/top/table" } + } + + return cprogram { + name = e.name, + srcs = { "mach/proto/top/*.c", }, + deps = { t }, + } + end +) diff --git a/plat/build.lua b/plat/build.lua index 05f746fea..deb2e4647 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -1,5 +1,6 @@ include("mach/proto/as/build.lua") include("mach/proto/ncg/build.lua") +include("mach/proto/top/build.lua") definerule("ackfile", { @@ -53,36 +54,6 @@ definerule("acklibrary", end ) -definerule("build_plat_tools", - { - arch = { type="string" }, - plat = { type="string" }, - }, - function(e) - local descr = "plat/"..e.plat.."/descr" - - local as = build_as { - name = "as", - arch = e.arch - } - - local ncg = build_ncg { - name = "ncg", - arch = e.arch, - } - - return installable { - name = e.name, - map = { - ["$(PLATDEP)/"..e.plat.."/as"] = as, - ["$(PLATDEP)/"..e.plat.."/ncg"] = ncg, - ["$(PLATIND)/descr/"..e.plat] = descr, - "util/opt+pkg", - } - } - end -) - definerule("build_plat_libs", { arch = { type="string" }, @@ -93,15 +64,13 @@ definerule("build_plat_libs", name = e.name, map = { "lang/basic/lib+pkg_"..e.plat, - "lang/cem/libcc.ansi+pkg_"..e.plat, - "lang/m2/libm2+pkg_"..e.plat, - "lang/pc/libpc+pkg_"..e.plat, + --"lang/cem/libcc.ansi+pkg_"..e.plat, + --"lang/m2/libm2+pkg_"..e.plat, + --"lang/pc/libpc+pkg_"..e.plat, ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, - ["$(PLATIND)/"..e.plat.."/libsys.a"] = "mach/"..e.arch.."/libsys+lib_"..e.plat, } } end ) - diff --git a/plat/cpm/build-headers.lua b/plat/cpm/build-headers.lua new file mode 100644 index 000000000..eb3cc8fbb --- /dev/null +++ b/plat/cpm/build-headers.lua @@ -0,0 +1,11 @@ +include("plat/build.lua") + +acklibrary { + name = "headers", + hdrs = { + ["ack/config.h"] = "./include/ack/config.h", + ["unistd.h"] = "./include/unistd.h", + ["cpm.h"] = "./include/cpm.h", + } +} + diff --git a/plat/cpm/build-pkg.lua b/plat/cpm/build-pkg.lua new file mode 100644 index 000000000..1dace45f3 --- /dev/null +++ b/plat/cpm/build-pkg.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") +include("lang/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "cpm" } +} + +build_plat_libs { + name = "libs", + arch = "i80", + plat = "cpm", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + ["$(PLATIND)/cpm/boot.o"] = "+boot" + } +} + diff --git a/plat/cpm/build-tools.lua b/plat/cpm/build-tools.lua new file mode 100644 index 000000000..383cf8c17 --- /dev/null +++ b/plat/cpm/build-tools.lua @@ -0,0 +1,27 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "i80", +} + +build_ncg { + name = "ncg", + arch = "i80", +} + +build_top { + name = "top", + arch = "i80", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/cpm/as"] = "+as", + ["$(PLATDEP)/cpm/ncg"] = "+ncg", + ["$(PLATDEP)/cpm/top"] = "+top", + ["$(PLATIND)/descr/cpm"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/pc86/build-headers.lua b/plat/pc86/build-headers.lua new file mode 100644 index 000000000..8b326df8d --- /dev/null +++ b/plat/pc86/build-headers.lua @@ -0,0 +1,10 @@ +include("plat/build.lua") + +acklibrary { + name = "headers", + hdrs = { + ["ack/config.h"] = "./include/ack/config.h", + ["unistd.h"] = "./include/unistd.h", + } +} + diff --git a/plat/pc86/build.lua b/plat/pc86/build-pkg.lua similarity index 54% rename from plat/pc86/build.lua rename to plat/pc86/build-pkg.lua index 002f66a54..667d62f23 100644 --- a/plat/pc86/build.lua +++ b/plat/pc86/build-pkg.lua @@ -1,11 +1,4 @@ include("plat/build.lua") -include("lang/build.lua") - -build_plat_tools { - name = "tools", - arch = "i86", - plat = "pc86", -} ackfile { name = "boot", @@ -13,14 +6,6 @@ ackfile { vars = { plat = "pc86" } } -acklibrary { - name = "headers", - hdrs = { - ["ack/config.h"] = "./include/ack/config.h", - ["unistd.h"] = "./include/unistd.h", - } -} - build_plat_libs { name = "libs", arch = "i86", diff --git a/plat/pc86/build-tools.lua b/plat/pc86/build-tools.lua new file mode 100644 index 000000000..fbb34bd3a --- /dev/null +++ b/plat/pc86/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "i86", +} + +build_ncg { + name = "ncg", + arch = "i86", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/pc86/as"] = "+as", + ["$(PLATDEP)/pc86/ncg"] = "+ncg", + ["$(PLATIND)/descr/pc86"] = "./descr", + "util/opt+pkg", + } +} diff --git a/util/topgen/build.lua b/util/topgen/build.lua new file mode 100644 index 000000000..715632211 --- /dev/null +++ b/util/topgen/build.lua @@ -0,0 +1,43 @@ +include("util/LLgen/build.lua") + +llgen { + name = "llgen", + srcs = { "./*.g" } +} + +cprogram { + name = "topgen", + srcs = { + "./*.c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+llgen", + } +} + +definerule("topgen", + { + srcs = { type="targets" }, + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + + return normalrule { + name = e.name, + outleaves = { + "gen.c", + "gen.h", + }, + ins = { + "util/topgen+topgen", + e.srcs, + }, + commands = { + "%{ins[1]} %{ins[2]} %{dir}" + } + } + end +) + diff --git a/util/topgen/main.c b/util/topgen/main.c index dd6c4c8a2..2f211f837 100644 --- a/util/topgen/main.c +++ b/util/topgen/main.c @@ -22,13 +22,17 @@ char *inpfile; main(argc,argv) char *argv[]; { newline = 1; - if (argc != 2) { - fprintf(stderr,"Usage : %s targetoptimizerdescription\n",argv[0]); + if (argc != 3) { + fprintf(stderr,"Usage : %s targetoptimizerdescription outputdir\n",argv[0]); exit(1); } if ((input = fopen(argv[1],"r")) == NULL) { fprintf(stderr,"Fatal error : couldn't open %s\n",argv[1]); exit(1); + } + if (chdir(argv[2]) != 0) { + fprintf(stderr,"Fatal error : couldn't chdir to %s\n",argv[2]); + exit(1); } if ((genc = fopen("gen.c","w")) == NULL) { fputs("Fatal error : couldn't open gen.c\n",stderr); From f253b6a169d0e23d0c4bb4f899dae2718e0363f5 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 10:37:55 +0200 Subject: [PATCH 185/231] linux386 builds. Also, forgot to turn back on the language runtimes. --- Makefile | 2 +- build.lua | 4 +++- mach/i386/libem/build.lua | 8 ++++++++ mach/i386/libend/build.lua | 8 ++++++++ plat/build.lua | 6 +++--- plat/linux386/build-headers.lua | 11 +++++++++++ plat/linux386/build-pkg.lua | 23 +++++++++++++++++++++++ plat/linux386/build-tools.lua | 21 +++++++++++++++++++++ 8 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 mach/i386/libem/build.lua create mode 100644 mach/i386/libend/build.lua create mode 100644 plat/linux386/build-headers.lua create mode 100644 plat/linux386/build-pkg.lua create mode 100644 plat/linux386/build-tools.lua diff --git a/Makefile b/Makefile index 78d3f9c2b..0f6938b1e 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ PLATIND = $(INSDIR)/share/ack PLATDEP = $(INSDIR)/lib/ack MAKECMDGOALS ?= +ack -BUILD_FILES = $(shell find * -name build.lua) +BUILD_FILES = $(shell find * -name '*.lua') NINJA := $(shell which ninja) ifneq ($(findstring +, $(MAKECMDGOALS)),) diff --git a/build.lua b/build.lua index c5a59a135..98b381dc2 100644 --- a/build.lua +++ b/build.lua @@ -5,8 +5,9 @@ vars.ackcflags = { "-O" } vars.plats = { - "pc86", "cpm", + "linux386", + "pc86", } installable { @@ -17,6 +18,7 @@ installable { "lang/m2/comp+pkg", "lang/pc/comp+pkg", "plat/cpm+pkg", + "plat/linux386+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/mach/i386/libem/build.lua b/mach/i386/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i386/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i386/libend/build.lua b/mach/i386/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i386/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/plat/build.lua b/plat/build.lua index deb2e4647..f46db0bbe 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -64,9 +64,9 @@ definerule("build_plat_libs", name = e.name, map = { "lang/basic/lib+pkg_"..e.plat, - --"lang/cem/libcc.ansi+pkg_"..e.plat, - --"lang/m2/libm2+pkg_"..e.plat, - --"lang/pc/libpc+pkg_"..e.plat, + "lang/cem/libcc.ansi+pkg_"..e.plat, + "lang/m2/libm2+pkg_"..e.plat, + "lang/pc/libpc+pkg_"..e.plat, ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, } diff --git a/plat/linux386/build-headers.lua b/plat/linux386/build-headers.lua new file mode 100644 index 000000000..5b91bdc75 --- /dev/null +++ b/plat/linux386/build-headers.lua @@ -0,0 +1,11 @@ +include("plat/build.lua") + +acklibrary { + name = "headers", + hdrs = { + ["ack/config.h"] = "./include/ack/config.h", + ["sys/ioctl.h"] = "./include/sys/ioctl.h", + ["unistd.h"] = "./include/unistd.h", + } +} + diff --git a/plat/linux386/build-pkg.lua b/plat/linux386/build-pkg.lua new file mode 100644 index 000000000..47fb9ce43 --- /dev/null +++ b/plat/linux386/build-pkg.lua @@ -0,0 +1,23 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "linux386" } +} + +build_plat_libs { + name = "libs", + arch = "i386", + plat = "linux386", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + ["$(PLATIND)/linux386/boot.o"] = "+boot" + } +} + diff --git a/plat/linux386/build-tools.lua b/plat/linux386/build-tools.lua new file mode 100644 index 000000000..d711f85fd --- /dev/null +++ b/plat/linux386/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "i386", +} + +build_ncg { + name = "ncg", + arch = "i386", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/linux386/as"] = "+as", + ["$(PLATDEP)/linux386/ncg"] = "+ncg", + ["$(PLATIND)/descr/linux386"] = "./descr", + "util/opt+pkg", + } +} From b549980af22ce700430af5b7ef123be6c10408c1 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 11:01:36 +0200 Subject: [PATCH 186/231] Wasn't exporting the plat headers; refactor to make this a little cleaner. --- lang/basic/lib/build.lua | 2 +- lang/cem/libcc.ansi/build.lua | 2 +- lang/m2/libm2/build.lua | 2 +- lang/pc/libpc/build.lua | 2 +- plat/cpm/build-headers.lua | 11 ----------- plat/cpm/build-pkg.lua | 1 + plat/cpm/include/build.lua | 25 +++++++++++++++++++++++++ plat/linux386/build-headers.lua | 11 ----------- plat/linux386/build-pkg.lua | 1 + plat/linux386/include/build.lua | 24 ++++++++++++++++++++++++ plat/pc86/build-headers.lua | 10 ---------- plat/pc86/build-pkg.lua | 1 + plat/pc86/include/build.lua | 24 ++++++++++++++++++++++++ 13 files changed, 80 insertions(+), 36 deletions(-) delete mode 100644 plat/cpm/build-headers.lua create mode 100644 plat/cpm/include/build.lua delete mode 100644 plat/linux386/build-headers.lua create mode 100644 plat/linux386/include/build.lua delete mode 100644 plat/pc86/build-headers.lua create mode 100644 plat/pc86/include/build.lua diff --git a/lang/basic/lib/build.lua b/lang/basic/lib/build.lua index f0fe3724b..71710a542 100644 --- a/lang/basic/lib/build.lua +++ b/lang/basic/lib/build.lua @@ -11,7 +11,7 @@ for _, plat in ipairs(vars.plats) do deps = { "h+emheaders", "lang/cem/libcc.ansi/headers+headers", - "plat/"..plat.."+headers", + "plat/"..plat.."/include+headers", }, vars = { plat = plat } } diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua index 60b72b0c5..ca5c9c570 100644 --- a/lang/cem/libcc.ansi/build.lua +++ b/lang/cem/libcc.ansi/build.lua @@ -52,7 +52,7 @@ for _, plat in ipairs(vars.plats) do hdrs = {}, -- must be empty deps = { "lang/cem/libcc.ansi/headers+headers", - "plat/"..plat.."+headers", + "plat/"..plat.."/include+headers", }, vars = { plat = plat } } diff --git a/lang/m2/libm2/build.lua b/lang/m2/libm2/build.lua index f49a10a4c..d0861b966 100644 --- a/lang/m2/libm2/build.lua +++ b/lang/m2/libm2/build.lua @@ -30,7 +30,7 @@ for _, plat in ipairs(vars.plats) do hdrs = {}, -- must be empty deps = { "lang/cem/libcc.ansi/headers+headers", - "plat/"..plat.."+headers", + "plat/"..plat.."/include+headers", "h+emheaders", }, vars = { plat = plat } diff --git a/lang/pc/libpc/build.lua b/lang/pc/libpc/build.lua index a86ce616e..61c4f7a3e 100644 --- a/lang/pc/libpc/build.lua +++ b/lang/pc/libpc/build.lua @@ -19,7 +19,7 @@ for _, plat in ipairs(vars.plats) do hdrs = {}, -- must be empty deps = { "lang/cem/libcc.ansi/headers+headers", - "plat/"..plat.."+headers", + "plat/"..plat.."/include+headers", "h+emheaders", }, vars = { plat = plat } diff --git a/plat/cpm/build-headers.lua b/plat/cpm/build-headers.lua deleted file mode 100644 index eb3cc8fbb..000000000 --- a/plat/cpm/build-headers.lua +++ /dev/null @@ -1,11 +0,0 @@ -include("plat/build.lua") - -acklibrary { - name = "headers", - hdrs = { - ["ack/config.h"] = "./include/ack/config.h", - ["unistd.h"] = "./include/unistd.h", - ["cpm.h"] = "./include/cpm.h", - } -} - diff --git a/plat/cpm/build-pkg.lua b/plat/cpm/build-pkg.lua index 1dace45f3..35c288791 100644 --- a/plat/cpm/build-pkg.lua +++ b/plat/cpm/build-pkg.lua @@ -18,6 +18,7 @@ installable { map = { "+tools", "+libs", + "./include+pkg", ["$(PLATIND)/cpm/boot.o"] = "+boot" } } diff --git a/plat/cpm/include/build.lua b/plat/cpm/include/build.lua new file mode 100644 index 000000000..b6f713684 --- /dev/null +++ b/plat/cpm/include/build.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/cpm/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("cpm.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + diff --git a/plat/linux386/build-headers.lua b/plat/linux386/build-headers.lua deleted file mode 100644 index 5b91bdc75..000000000 --- a/plat/linux386/build-headers.lua +++ /dev/null @@ -1,11 +0,0 @@ -include("plat/build.lua") - -acklibrary { - name = "headers", - hdrs = { - ["ack/config.h"] = "./include/ack/config.h", - ["sys/ioctl.h"] = "./include/sys/ioctl.h", - ["unistd.h"] = "./include/unistd.h", - } -} - diff --git a/plat/linux386/build-pkg.lua b/plat/linux386/build-pkg.lua index 47fb9ce43..35b096f18 100644 --- a/plat/linux386/build-pkg.lua +++ b/plat/linux386/build-pkg.lua @@ -17,6 +17,7 @@ installable { map = { "+tools", "+libs", + "./include+pkg", ["$(PLATIND)/linux386/boot.o"] = "+boot" } } diff --git a/plat/linux386/include/build.lua b/plat/linux386/include/build.lua new file mode 100644 index 000000000..ce1f2adc6 --- /dev/null +++ b/plat/linux386/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/linux386/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("sys/ioctl.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + diff --git a/plat/pc86/build-headers.lua b/plat/pc86/build-headers.lua deleted file mode 100644 index 8b326df8d..000000000 --- a/plat/pc86/build-headers.lua +++ /dev/null @@ -1,10 +0,0 @@ -include("plat/build.lua") - -acklibrary { - name = "headers", - hdrs = { - ["ack/config.h"] = "./include/ack/config.h", - ["unistd.h"] = "./include/unistd.h", - } -} - diff --git a/plat/pc86/build-pkg.lua b/plat/pc86/build-pkg.lua index 667d62f23..f0f1653d5 100644 --- a/plat/pc86/build-pkg.lua +++ b/plat/pc86/build-pkg.lua @@ -17,6 +17,7 @@ installable { map = { "+tools", "+libs", + "./include+pkg", ["$(PLATIND)/pc86/boot.o"] = "+boot" } } diff --git a/plat/pc86/include/build.lua b/plat/pc86/include/build.lua new file mode 100644 index 000000000..6ae120358 --- /dev/null +++ b/plat/pc86/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/pc86/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + From 3df4906d52d508acf5a4ff5da4b36aeef367264a Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 11:23:57 +0200 Subject: [PATCH 187/231] Turns out I wasn't building the syscall libraries. Do so. --- plat/cpm/build-pkg.lua | 3 ++- plat/cpm/libsys/build.lua | 11 +++++++++++ plat/linux/{liblinux => libsys}/.distr | 0 plat/linux/{liblinux => libsys}/_exit.c | 0 plat/linux/{liblinux => libsys}/_hol0.s | 0 plat/linux/{liblinux => libsys}/brk.c | 0 plat/linux/{liblinux => libsys}/build.mk | 0 plat/linux/{liblinux => libsys}/close.c | 0 plat/linux/{liblinux => libsys}/creat.c | 0 plat/linux/{liblinux => libsys}/errno.s | 0 plat/linux/{liblinux => libsys}/getpid.c | 0 plat/linux/{liblinux => libsys}/gettimeofday.c | 0 plat/linux/{liblinux => libsys}/isatty.c | 0 plat/linux/{liblinux => libsys}/kill.c | 0 plat/linux/{liblinux => libsys}/libsys.h | 0 plat/linux/{liblinux => libsys}/lseek.c | 0 plat/linux/{liblinux => libsys}/open.c | 0 plat/linux/{liblinux => libsys}/read.c | 0 plat/linux/{liblinux => libsys}/sbrk.c | 0 plat/linux/{liblinux => libsys}/signal.c | 0 plat/linux/{liblinux => libsys}/syscalls.h | 0 plat/linux/{liblinux => libsys}/write.c | 0 plat/linux386/build-pkg.lua | 3 ++- plat/linux386/descr | 3 +-- plat/linux386/libsys/build.lua | 12 ++++++++++++ plat/pc86/build-pkg.lua | 3 ++- plat/pc86/libsys/build.lua | 11 +++++++++++ 27 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 plat/cpm/libsys/build.lua rename plat/linux/{liblinux => libsys}/.distr (100%) rename plat/linux/{liblinux => libsys}/_exit.c (100%) rename plat/linux/{liblinux => libsys}/_hol0.s (100%) rename plat/linux/{liblinux => libsys}/brk.c (100%) rename plat/linux/{liblinux => libsys}/build.mk (100%) rename plat/linux/{liblinux => libsys}/close.c (100%) rename plat/linux/{liblinux => libsys}/creat.c (100%) rename plat/linux/{liblinux => libsys}/errno.s (100%) rename plat/linux/{liblinux => libsys}/getpid.c (100%) rename plat/linux/{liblinux => libsys}/gettimeofday.c (100%) rename plat/linux/{liblinux => libsys}/isatty.c (100%) rename plat/linux/{liblinux => libsys}/kill.c (100%) rename plat/linux/{liblinux => libsys}/libsys.h (100%) rename plat/linux/{liblinux => libsys}/lseek.c (100%) rename plat/linux/{liblinux => libsys}/open.c (100%) rename plat/linux/{liblinux => libsys}/read.c (100%) rename plat/linux/{liblinux => libsys}/sbrk.c (100%) rename plat/linux/{liblinux => libsys}/signal.c (100%) rename plat/linux/{liblinux => libsys}/syscalls.h (100%) rename plat/linux/{liblinux => libsys}/write.c (100%) create mode 100644 plat/linux386/libsys/build.lua create mode 100644 plat/pc86/libsys/build.lua diff --git a/plat/cpm/build-pkg.lua b/plat/cpm/build-pkg.lua index 35c288791..0a4da3be0 100644 --- a/plat/cpm/build-pkg.lua +++ b/plat/cpm/build-pkg.lua @@ -19,7 +19,8 @@ installable { "+tools", "+libs", "./include+pkg", - ["$(PLATIND)/cpm/boot.o"] = "+boot" + ["$(PLATIND)/cpm/boot.o"] = "+boot", + ["$(PLATIND)/cpm/libsys.a"] = "./libsys+lib", } } diff --git a/plat/cpm/libsys/build.lua b/plat/cpm/libsys/build.lua new file mode 100644 index 000000000..fb3a3481d --- /dev/null +++ b/plat/cpm/libsys/build.lua @@ -0,0 +1,11 @@ +acklibrary { + name = "lib", + srcs = { + "./*.c", + "./*.s", + }, + vars = { + plat = "cpm" + } +} + diff --git a/plat/linux/liblinux/.distr b/plat/linux/libsys/.distr similarity index 100% rename from plat/linux/liblinux/.distr rename to plat/linux/libsys/.distr diff --git a/plat/linux/liblinux/_exit.c b/plat/linux/libsys/_exit.c similarity index 100% rename from plat/linux/liblinux/_exit.c rename to plat/linux/libsys/_exit.c diff --git a/plat/linux/liblinux/_hol0.s b/plat/linux/libsys/_hol0.s similarity index 100% rename from plat/linux/liblinux/_hol0.s rename to plat/linux/libsys/_hol0.s diff --git a/plat/linux/liblinux/brk.c b/plat/linux/libsys/brk.c similarity index 100% rename from plat/linux/liblinux/brk.c rename to plat/linux/libsys/brk.c diff --git a/plat/linux/liblinux/build.mk b/plat/linux/libsys/build.mk similarity index 100% rename from plat/linux/liblinux/build.mk rename to plat/linux/libsys/build.mk diff --git a/plat/linux/liblinux/close.c b/plat/linux/libsys/close.c similarity index 100% rename from plat/linux/liblinux/close.c rename to plat/linux/libsys/close.c diff --git a/plat/linux/liblinux/creat.c b/plat/linux/libsys/creat.c similarity index 100% rename from plat/linux/liblinux/creat.c rename to plat/linux/libsys/creat.c diff --git a/plat/linux/liblinux/errno.s b/plat/linux/libsys/errno.s similarity index 100% rename from plat/linux/liblinux/errno.s rename to plat/linux/libsys/errno.s diff --git a/plat/linux/liblinux/getpid.c b/plat/linux/libsys/getpid.c similarity index 100% rename from plat/linux/liblinux/getpid.c rename to plat/linux/libsys/getpid.c diff --git a/plat/linux/liblinux/gettimeofday.c b/plat/linux/libsys/gettimeofday.c similarity index 100% rename from plat/linux/liblinux/gettimeofday.c rename to plat/linux/libsys/gettimeofday.c diff --git a/plat/linux/liblinux/isatty.c b/plat/linux/libsys/isatty.c similarity index 100% rename from plat/linux/liblinux/isatty.c rename to plat/linux/libsys/isatty.c diff --git a/plat/linux/liblinux/kill.c b/plat/linux/libsys/kill.c similarity index 100% rename from plat/linux/liblinux/kill.c rename to plat/linux/libsys/kill.c diff --git a/plat/linux/liblinux/libsys.h b/plat/linux/libsys/libsys.h similarity index 100% rename from plat/linux/liblinux/libsys.h rename to plat/linux/libsys/libsys.h diff --git a/plat/linux/liblinux/lseek.c b/plat/linux/libsys/lseek.c similarity index 100% rename from plat/linux/liblinux/lseek.c rename to plat/linux/libsys/lseek.c diff --git a/plat/linux/liblinux/open.c b/plat/linux/libsys/open.c similarity index 100% rename from plat/linux/liblinux/open.c rename to plat/linux/libsys/open.c diff --git a/plat/linux/liblinux/read.c b/plat/linux/libsys/read.c similarity index 100% rename from plat/linux/liblinux/read.c rename to plat/linux/libsys/read.c diff --git a/plat/linux/liblinux/sbrk.c b/plat/linux/libsys/sbrk.c similarity index 100% rename from plat/linux/liblinux/sbrk.c rename to plat/linux/libsys/sbrk.c diff --git a/plat/linux/liblinux/signal.c b/plat/linux/libsys/signal.c similarity index 100% rename from plat/linux/liblinux/signal.c rename to plat/linux/libsys/signal.c diff --git a/plat/linux/liblinux/syscalls.h b/plat/linux/libsys/syscalls.h similarity index 100% rename from plat/linux/liblinux/syscalls.h rename to plat/linux/libsys/syscalls.h diff --git a/plat/linux/liblinux/write.c b/plat/linux/libsys/write.c similarity index 100% rename from plat/linux/liblinux/write.c rename to plat/linux/libsys/write.c diff --git a/plat/linux386/build-pkg.lua b/plat/linux386/build-pkg.lua index 35b096f18..14251ee8a 100644 --- a/plat/linux386/build-pkg.lua +++ b/plat/linux386/build-pkg.lua @@ -18,7 +18,8 @@ installable { "+tools", "+libs", "./include+pkg", - ["$(PLATIND)/linux386/boot.o"] = "+boot" + ["$(PLATIND)/linux386/boot.o"] = "+boot", + ["$(PLATIND)/linux386/libsys.a"] = "./libsys+lib", } } diff --git a/plat/linux386/descr b/plat/linux386/descr index 3bdd9d768..7fa809058 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -67,8 +67,7 @@ name led (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ {FLOATS?} \ - (.e:{TAIL}={PLATFORMDIR}/liblinux.a \ - {PLATFORMDIR}/libem.a \ + (.e:{TAIL}={PLATFORMDIR}/libem.a \ {PLATFORMDIR}/liblinux.a \ {PLATFORMDIR}/libsys.a \ {PLATFORMDIR}/libend.a) diff --git a/plat/linux386/libsys/build.lua b/plat/linux386/libsys/build.lua new file mode 100644 index 000000000..9608aab7b --- /dev/null +++ b/plat/linux386/libsys/build.lua @@ -0,0 +1,12 @@ +acklibrary { + name = "lib", + srcs = { + "./*.s", + "plat/linux/libsys/*.c", + "plat/linux/libsys/*.s", + }, + vars = { + plat = "linux386" + } +} + diff --git a/plat/pc86/build-pkg.lua b/plat/pc86/build-pkg.lua index f0f1653d5..b4ff7b767 100644 --- a/plat/pc86/build-pkg.lua +++ b/plat/pc86/build-pkg.lua @@ -18,7 +18,8 @@ installable { "+tools", "+libs", "./include+pkg", - ["$(PLATIND)/pc86/boot.o"] = "+boot" + ["$(PLATIND)/pc86/boot.o"] = "+boot", + ["$(PLATIND)/pc86/libsys.a"] = "./libsys+lib", } } diff --git a/plat/pc86/libsys/build.lua b/plat/pc86/libsys/build.lua new file mode 100644 index 000000000..909b02930 --- /dev/null +++ b/plat/pc86/libsys/build.lua @@ -0,0 +1,11 @@ +acklibrary { + name = "lib", + srcs = { + "./*.c", + "./*.s", + }, + vars = { + plat = "pc86" + } +} + From fb2a42a2db0fcd9bc3701a8a65074cfb5841ac4a Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 11:25:47 +0200 Subject: [PATCH 188/231] installables need to depend on their source files... --- first/ackbuilder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 1c4aca339..ea65161f1 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -713,7 +713,7 @@ definerule("installable", error("installable can only cope with targets emitting single files") end - deps[#deps+1] = src.fullname + deps[#deps+1] = f dests[#dests+1] = dest commands[#commands+1] = "cp "..f[1].." "..dest end From 38fa6941d53f1a52f6d9f7f6fe29ef050d03bad6 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 11:34:18 +0200 Subject: [PATCH 189/231] linux68k builds now. --- build.lua | 2 ++ mach/m68020/libem/build.lua | 8 ++++++++ mach/m68020/libend/build.lua | 8 ++++++++ mach/m68020/ncg/table | 2 +- mach/proto/ncg/build.lua | 4 ++-- plat/linux68k/build-pkg.lua | 25 +++++++++++++++++++++++++ plat/linux68k/build-tools.lua | 21 +++++++++++++++++++++ plat/linux68k/include/build.lua | 24 ++++++++++++++++++++++++ plat/linux68k/libsys/build.lua | 12 ++++++++++++ 9 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 mach/m68020/libem/build.lua create mode 100644 mach/m68020/libend/build.lua create mode 100644 plat/linux68k/build-pkg.lua create mode 100644 plat/linux68k/build-tools.lua create mode 100644 plat/linux68k/include/build.lua create mode 100644 plat/linux68k/libsys/build.lua diff --git a/build.lua b/build.lua index 98b381dc2..4b9bd2886 100644 --- a/build.lua +++ b/build.lua @@ -7,6 +7,7 @@ vars.ackcflags = { vars.plats = { "cpm", "linux386", + "linux68k", "pc86", } @@ -19,6 +20,7 @@ installable { "lang/pc/comp+pkg", "plat/cpm+pkg", "plat/linux386+pkg", + "plat/linux68k+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/mach/m68020/libem/build.lua b/mach/m68020/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/m68020/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/m68020/libend/build.lua b/mach/m68020/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/m68020/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/m68020/ncg/table b/mach/m68020/ncg/table index e771b3de8..9aede9929 100644 --- a/mach/m68020/ncg/table +++ b/mach/m68020/ncg/table @@ -12,7 +12,7 @@ rscid = "$Id$" * * ********************************/ -#include +#include "whichone.h" #if TBL68881 && ! TBL68020 Something very wrong here! diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua index 5245fd2a7..09b3b7385 100644 --- a/mach/proto/ncg/build.lua +++ b/mach/proto/ncg/build.lua @@ -12,7 +12,8 @@ definerule("build_ncg", srcs = {}, hdrs = { "mach/proto/ncg/*.h", - "mach/"..e.arch.."/ncg/mach*" + "mach/"..e.arch.."/ncg/mach.c", + "mach/"..e.arch.."/ncg/*.h", } } @@ -25,7 +26,6 @@ definerule("build_ncg", name = e.name, srcs = { "mach/proto/ncg/*.c", - "mach/"..e.arch.."/ncg/mach.h", matching(filenamesof(tables), "%.c$") }, deps = { diff --git a/plat/linux68k/build-pkg.lua b/plat/linux68k/build-pkg.lua new file mode 100644 index 000000000..34925f15c --- /dev/null +++ b/plat/linux68k/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "linux68k" } +} + +build_plat_libs { + name = "libs", + arch = "m68020", + plat = "linux68k", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/linux68k/boot.o"] = "+boot", + ["$(PLATIND)/linux68k/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/linux68k/build-tools.lua b/plat/linux68k/build-tools.lua new file mode 100644 index 000000000..944e57f47 --- /dev/null +++ b/plat/linux68k/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "m68020", +} + +build_ncg { + name = "ncg", + arch = "m68020", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/linux68k/as"] = "+as", + ["$(PLATDEP)/linux68k/ncg"] = "+ncg", + ["$(PLATIND)/descr/linux68k"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/linux68k/include/build.lua b/plat/linux68k/include/build.lua new file mode 100644 index 000000000..291fa0c36 --- /dev/null +++ b/plat/linux68k/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/linux68k/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("sys/ioctl.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + diff --git a/plat/linux68k/libsys/build.lua b/plat/linux68k/libsys/build.lua new file mode 100644 index 000000000..4a8729977 --- /dev/null +++ b/plat/linux68k/libsys/build.lua @@ -0,0 +1,12 @@ +acklibrary { + name = "lib", + srcs = { + "./*.s", + "plat/linux/libsys/*.c", + "plat/linux/libsys/*.s", + }, + vars = { + plat = "linux68k" + } +} + From 4d24666432a4a01a67ed9b993c912f44b4cfe0a8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 14:09:38 +0200 Subject: [PATCH 190/231] Move util/data into modules/src/em_data, for consistency with the other modules. --- lang/basic/src/build.lua | 2 +- lang/cem/cemcom.ansi/build.lua | 8 ++++---- lang/m2/comp/build.lua | 6 +++--- lang/pc/comp/build.lua | 6 +++--- mach/proto/ncg/build.lua | 2 +- modules/src/em_code/build.lua | 2 +- {util/data => modules/src/em_data}/.distr | 0 {util/data => modules/src/em_data}/build.lua | 2 +- {util/data => modules/src/em_data}/build.mk | 0 {util/data => modules/src/em_data}/em_ptyp.c | 0 {util/data => modules/src/em_data}/new_table | 0 {util/data => modules/src/em_data}/proto.make | 0 modules/src/em_mes/build.lua | 2 +- modules/src/read_em/build.lua | 2 +- util/misc/build.lua | 4 ++-- util/ncgg/build.lua | 2 +- util/opt/build.lua | 4 ++-- 17 files changed, 21 insertions(+), 21 deletions(-) rename {util/data => modules/src/em_data}/.distr (100%) rename {util/data => modules/src/em_data}/build.lua (96%) rename {util/data => modules/src/em_data}/build.mk (100%) rename {util/data => modules/src/em_data}/em_ptyp.c (100%) rename {util/data => modules/src/em_data}/new_table (100%) rename {util/data => modules/src/em_data}/proto.make (100%) diff --git a/lang/basic/src/build.lua b/lang/basic/src/build.lua index 001ca037a..f4d6b94a8 100644 --- a/lang/basic/src/build.lua +++ b/lang/basic/src/build.lua @@ -30,11 +30,11 @@ cprogram { "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+lib_k", + "modules/src/em_data+lib", "modules/src/em_mes+lib", "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", - "util/data+em_data", } } diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua index fe0f70d25..670c73abf 100644 --- a/lang/cem/cemcom.ansi/build.lua +++ b/lang/cem/cemcom.ansi/build.lua @@ -139,12 +139,14 @@ cprogram { }, deps = { "./*.h", - "+parameters", - "+nextlib", "+llgen", + "+nextlib", + "+parameters", "h+emheaders", + "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+lib_k", + "modules/src/em_data+lib", "modules/src/em_mes+lib", "modules/src/flt_arith+lib", "modules/src/idf+lib", @@ -152,8 +154,6 @@ cprogram { "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", - "modules+headers", - "util/data+em_data", }, } diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua index fde8442ae..95c4a30d7 100644 --- a/lang/m2/comp/build.lua +++ b/lang/m2/comp/build.lua @@ -114,14 +114,14 @@ cprogram { "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/em_mes+lib", "modules/src/flt_arith+lib", "modules/src/idf+lib", "modules/src/input+lib", + "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", - "modules/src/print+lib", - "modules/src/em_mes+lib", - "util/data+em_data", } } diff --git a/lang/pc/comp/build.lua b/lang/pc/comp/build.lua index 8b058345b..a2cb9accb 100644 --- a/lang/pc/comp/build.lua +++ b/lang/pc/comp/build.lua @@ -114,14 +114,14 @@ cprogram { "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/em_mes+lib", "modules/src/flt_arith+lib", "modules/src/idf+lib", "modules/src/input+lib", + "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", - "modules/src/print+lib", - "modules/src/em_mes+lib", - "util/data+em_data", }, vars = { ["+cflags"] = "-DSTATIC=static" diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua index 09b3b7385..e2345ca0c 100644 --- a/mach/proto/ncg/build.lua +++ b/mach/proto/ncg/build.lua @@ -33,7 +33,7 @@ definerule("build_ncg", "modules+headers", "modules/src/flt_arith+lib", "modules/src/object+lib", - "util/data+em_data", + "modules/src/em_data+lib", headers, tables, -- for .h file } diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua index b530f2a51..e0218c009 100644 --- a/modules/src/em_code/build.lua +++ b/modules/src/em_code/build.lua @@ -76,8 +76,8 @@ local function build_variant(code, cflags) "h+local", "modules+headers", "modules/src/alloc+lib", + "modules/src/em_data+lib", "modules/src/system+lib", - "util/data+em_data", }, vars = { ["+cflags"] = cflags diff --git a/util/data/.distr b/modules/src/em_data/.distr similarity index 100% rename from util/data/.distr rename to modules/src/em_data/.distr diff --git a/util/data/build.lua b/modules/src/em_data/build.lua similarity index 96% rename from util/data/build.lua rename to modules/src/em_data/build.lua index aca670177..20312201d 100644 --- a/util/data/build.lua +++ b/modules/src/em_data/build.lua @@ -21,7 +21,7 @@ local generated = normalrule { } clibrary { - name = "em_data", + name = "lib", srcs = concat( "./em_ptyp.c", matching(filenamesof(generated), "%.c$") diff --git a/util/data/build.mk b/modules/src/em_data/build.mk similarity index 100% rename from util/data/build.mk rename to modules/src/em_data/build.mk diff --git a/util/data/em_ptyp.c b/modules/src/em_data/em_ptyp.c similarity index 100% rename from util/data/em_ptyp.c rename to modules/src/em_data/em_ptyp.c diff --git a/util/data/new_table b/modules/src/em_data/new_table similarity index 100% rename from util/data/new_table rename to modules/src/em_data/new_table diff --git a/util/data/proto.make b/modules/src/em_data/proto.make similarity index 100% rename from util/data/proto.make rename to modules/src/em_data/proto.make diff --git a/modules/src/em_mes/build.lua b/modules/src/em_mes/build.lua index a3c0173cc..3c5b2f03e 100644 --- a/modules/src/em_mes/build.lua +++ b/modules/src/em_mes/build.lua @@ -5,7 +5,7 @@ clibrary { "h+emheaders", "modules+headers", "modules/src/em_code+em_code_ek_h", - "util/data+em_data", + "modules/src/em_data+lib", } } diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua index 45794bd91..767dc9f87 100644 --- a/modules/src/read_em/build.lua +++ b/modules/src/read_em/build.lua @@ -52,8 +52,8 @@ local function variant(name, cflags) "modules+headers", "modules/src/alloc+lib", "modules/src/em_code+em_code_ek_h", + "modules/src/em_data+lib", "modules/src/system+lib", - "util/data+em_data", } } end diff --git a/util/misc/build.lua b/util/misc/build.lua index 3b11c6018..556d56b99 100644 --- a/util/misc/build.lua +++ b/util/misc/build.lua @@ -15,7 +15,7 @@ cprogram { "modules/src/read_em+lib_ev", "modules/src/string+lib", "modules/src/system+lib", - "util/data+em_data", + "modules/src/em_data+lib", } } @@ -31,7 +31,7 @@ cprogram { "modules/src/read_em+lib_kv", "modules/src/string+lib", "modules/src/system+lib", - "util/data+em_data", + "modules/src/em_data+lib", } } diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua index 787fd8c3a..b82f3f340 100644 --- a/util/ncgg/build.lua +++ b/util/ncgg/build.lua @@ -35,7 +35,7 @@ cprogram { "+cggparser", -- for .h file "+cgglexer", -- for .h file "h+emheaders", - "util/data+em_data", + "modules/src/em_data+lib", } } diff --git a/util/opt/build.lua b/util/opt/build.lua index 8a4dc6688..9bcfdcb21 100644 --- a/util/opt/build.lua +++ b/util/opt/build.lua @@ -19,7 +19,7 @@ cprogram { deps = { "+flex", "+yacc", - "util/data+em_data", + "modules/src/em_data+lib", } } @@ -63,7 +63,7 @@ local function variant(name, cflags) "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib", - "util/data+em_data", + "modules/src/em_data+lib", }, vars = { ["+cflags"] = cflags From 2dab95eced1e10ebf184d9cf86de50afed51fb5b Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 14:17:35 +0200 Subject: [PATCH 191/231] Move the em_code headers into the em_code module. --- modules/src/em_code/build.lua | 15 +++++++++++++-- modules/{h => src/em_code}/em_code.h | 0 modules/{h => src/em_code}/em_codeCE.h | 0 modules/{h => src/em_code}/em_codeO.h | 0 modules/src/em_mes/build.lua | 2 +- modules/src/read_em/build.lua | 2 +- 6 files changed, 15 insertions(+), 4 deletions(-) rename modules/{h => src/em_code}/em_code.h (100%) rename modules/{h => src/em_code}/em_codeCE.h (100%) rename modules/{h => src/em_code}/em_codeO.h (100%) diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua index e0218c009..a1316df2f 100644 --- a/modules/src/em_code/build.lua +++ b/modules/src/em_code/build.lua @@ -12,6 +12,17 @@ normalrule { } } +clibrary { + name = "headers", + srcs = {}, + hdrs = { + "+em_code_ek_h", + "./em_code.h", + "./em_codeCE.h", + "./em_codeO.h", + } +} + local function build_variant(code, cflags) clibrary { name = "lib_"..code, @@ -68,10 +79,10 @@ local function build_variant(code, cflags) "./ucon.c", }, hdrs = { - "+em_code_ek_h" + "+headers" }, deps = { - "+em_code_ek_h", + "+headers", "h+emheaders", "h+local", "modules+headers", diff --git a/modules/h/em_code.h b/modules/src/em_code/em_code.h similarity index 100% rename from modules/h/em_code.h rename to modules/src/em_code/em_code.h diff --git a/modules/h/em_codeCE.h b/modules/src/em_code/em_codeCE.h similarity index 100% rename from modules/h/em_codeCE.h rename to modules/src/em_code/em_codeCE.h diff --git a/modules/h/em_codeO.h b/modules/src/em_code/em_codeO.h similarity index 100% rename from modules/h/em_codeO.h rename to modules/src/em_code/em_codeO.h diff --git a/modules/src/em_mes/build.lua b/modules/src/em_mes/build.lua index 3c5b2f03e..b094f4a84 100644 --- a/modules/src/em_mes/build.lua +++ b/modules/src/em_mes/build.lua @@ -4,7 +4,7 @@ clibrary { deps = { "h+emheaders", "modules+headers", - "modules/src/em_code+em_code_ek_h", + "modules/src/em_code+headers", "modules/src/em_data+lib", } } diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua index 767dc9f87..f559831bd 100644 --- a/modules/src/read_em/build.lua +++ b/modules/src/read_em/build.lua @@ -51,7 +51,7 @@ local function variant(name, cflags) "h+emheaders", "modules+headers", "modules/src/alloc+lib", - "modules/src/em_code+em_code_ek_h", + "modules/src/em_code+headers", "modules/src/em_data+lib", "modules/src/system+lib", } From a42939df50d607d0b5b04fe94620d5ebbd032cd8 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 14:40:01 +0200 Subject: [PATCH 192/231] LED builds now. --- build.lua | 1 + util/led/build.lua | 19 +++++++++++++++++++ util/led/{mach.c => mach.h} | 0 util/led/memory.c | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 util/led/build.lua rename util/led/{mach.c => mach.h} (100%) diff --git a/build.lua b/build.lua index 4b9bd2886..dc2178fb8 100644 --- a/build.lua +++ b/build.lua @@ -25,6 +25,7 @@ installable { "util/ack+pkg", "util/amisc+pkg", "util/arch+pkg", + "util/led+pkg", "util/misc+pkg", "util/opt+pkg", } diff --git a/util/led/build.lua b/util/led/build.lua new file mode 100644 index 000000000..ed84a79b3 --- /dev/null +++ b/util/led/build.lua @@ -0,0 +1,19 @@ +cprogram { + name = "led", + srcs = { "./*.c" }, + deps = { + "modules/src/string+lib", + "modules/src/object+lib", + "h+emheaders", + } +} + +installable { + name = "pkg", + map = { + ["$(INSDIR)/share/man/man5/ack.out.5"] = "./ack.out.5", + ["$(INSDIR)/share/man/man6/led.6"] = "./led.6", + ["$(PLATDEP)/em_led"] = "+led", + } +} + diff --git a/util/led/mach.c b/util/led/mach.h similarity index 100% rename from util/led/mach.c rename to util/led/mach.h diff --git a/util/led/memory.c b/util/led/memory.c index db5ad72ee..b99447172 100644 --- a/util/led/memory.c +++ b/util/led/memory.c @@ -73,7 +73,7 @@ init_core() register struct memory *mem; extern char *sbrk(); -#include "mach.c" +#include "mach.h" #define ALIGN 8 /* minimum alignment for pieces */ #define AT_LEAST (ind_t)2*ALIGN /* See comment about string areas. */ From 8b24b0247b7f040a51363ab545851fa6c0e924f1 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 14:44:00 +0200 Subject: [PATCH 193/231] Update Travis metadata. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd9fd3e0c..a8db9ac0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ before_install: - - sudo apt-get install ed + - sudo apt-get install ed lua5.2 ninja language: c script: - make PREFIX=/tmp/acki -j4 From 38c6a87ed5d9bdac0ee68efbd6df82c4ff9889d0 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 22:41:54 +0200 Subject: [PATCH 194/231] Add another Travis library. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8db9ac0a..d199d5076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ before_install: - - sudo apt-get install ed lua5.2 ninja + - sudo apt-get install ed lua5.2 lua-posix ninja language: c script: - make PREFIX=/tmp/acki -j4 From 53f043ff409f4f04e6493f6c93eefd966ade0040 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 22:52:57 +0200 Subject: [PATCH 195/231] Backport to Lua 5.1 (because 5.2 on Travis doesn't have luaposix...). --- .travis.yml | 2 +- Makefile | 2 +- first/ackbuilder.lua | 32 +++++++++++++++++++++++--------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index d199d5076..bcb505b6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ before_install: - - sudo apt-get install ed lua5.2 lua-posix ninja + - sudo apt-get install ed lua5.1 liblua5.1-posix1 ninja language: c script: - make PREFIX=/tmp/acki -j4 diff --git a/Makefile b/Makefile index 0f6938b1e..b3955ca40 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ endif $(BUILDDIR)/rules.ninja: first/ackbuilder.lua $(BUILD_FILES) @mkdir -p $(BUILDDIR) - @lua5.2 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja + @lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja $(BUILDDIR)/rules.mk: first/ackbuilder.lua $(BUILD_FILES) @mkdir -p $(BUILDDIR) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index ea65161f1..2333461ee 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -346,10 +346,11 @@ local function templateexpand(list, vars) o[#o+1] = s:gsub("%%%b{}", function(expr) expr = expr:sub(3, -2) - local chunk, e = load("return ("..expr..")", expr, "text", vars) + local chunk, e = loadstring("return ("..expr..")", expr) if e then error(string.format("error evaluating expression: %s", e)) end + setfenv(chunk, vars) local value = chunk() if (value == nil) then error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr)) @@ -381,7 +382,10 @@ local function loadbuildfile(filename) local thisglobals = {} thisglobals._G = thisglobals setmetatable(thisglobals, {__index = globals}) - chunk, e = load(data, "@"..filename, "text", thisglobals) + chunk, e = loadstring(data, "@"..filename) + if not e then + setfenv(chunk, thisglobals) + end end end if e then @@ -396,6 +400,22 @@ local function loadbuildfile(filename) loadingstack[#loadingstack] = nil end +local function loadbuildfilefor(filepart, targetpart) + local normalname = concatpath(filepart, "/build.lua") + if posix.access(normalname, "r") then + loadbuildfile(normalname) + return + end + + local extendedname = concatpath(filepart, "/build-"..targetpart..".lua") + if posix.access(extendedname, "r") then + loadbuildfile(extendedname) + return + end + + error(string.format("could not access either '%s' or '%s'", normalname, extendedname)) +end + loadtarget = function(targetname) if targets[targetname] then return targets[targetname] @@ -428,13 +448,7 @@ loadtarget = function(targetname) if (filepart == "") then filepart = cwd end - local filename = concatpath(filepart, "/build.lua") - if posix.access(filename, "r") then - loadbuildfile(filename) - else - filename = concatpath(filepart, "/build-"..targetpart..".lua") - loadbuildfile(filename) - end + loadbuildfilefor(filepart, targetpart) target = targets[targetname] if not target then From 870489c8b0c2f0881164bbf8eeefe25744767e2f Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 22:55:10 +0200 Subject: [PATCH 196/231] Er, oops; the ninja build system is in a package called ninja-build. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bcb505b6e..2852603af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ before_install: - - sudo apt-get install ed lua5.1 liblua5.1-posix1 ninja + - sudo apt-get install ed lua5.1 liblua5.1-posix1 ninja-build language: c script: - make PREFIX=/tmp/acki -j4 From 7b8d9e2d0e6baa36266fbf536fc308a105e5c031 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 14 Aug 2016 23:01:12 +0200 Subject: [PATCH 197/231] Fix compiler warnings and 64bitisms. --- util/amisc/aslod.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/amisc/aslod.c b/util/amisc/aslod.c index b761898d4..80c92d3c6 100644 --- a/util/amisc/aslod.c +++ b/util/amisc/aslod.c @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include #include "out.h" #define ASSERT(x) switch (2) { case 0: case (x): ; } @@ -300,11 +303,11 @@ int main(int argc, char* argv[]) { long ss = 0; - printf(" base : %08lX\n", outsect[TEXT].os_base) ; - printf(" text = %08lX\n", outsect[TEXT].os_size); - printf(" rom = %08lX\n", outsect[ROM].os_size); - printf(" data = %08lX\n", outsect[DATA].os_size); - printf(" bss = %08lX\n", outsect[BSS].os_size); + printf(" base : "PRIu32"\n", outsect[TEXT].os_base) ; + printf(" text = "PRIu32"\n", outsect[TEXT].os_size); + printf(" rom = "PRIu32"\n", outsect[ROM].os_size); + printf(" data = "PRIu32"\n", outsect[DATA].os_size); + printf(" bss = "PRIu32"\n", outsect[BSS].os_size); ss += outsect[TEXT].os_size; ss += outsect[ROM].os_size; ss += outsect[DATA].os_size; From 420c47c3864f8d7c9958fccb21c0317ff88111c6 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 15 Aug 2016 00:46:43 +0200 Subject: [PATCH 198/231] Fix dependency error (only shows up with make, not ninja. Odd). --- plat/cpm/libsys/build.lua | 4 ++++ plat/linux386/libsys/build.lua | 4 ++++ plat/linux68k/libsys/build.lua | 4 ++++ plat/pc86/libsys/build.lua | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/plat/cpm/libsys/build.lua b/plat/cpm/libsys/build.lua index fb3a3481d..c2a75a4c3 100644 --- a/plat/cpm/libsys/build.lua +++ b/plat/cpm/libsys/build.lua @@ -4,6 +4,10 @@ acklibrary { "./*.c", "./*.s", }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/cpm/include+headers", + }, vars = { plat = "cpm" } diff --git a/plat/linux386/libsys/build.lua b/plat/linux386/libsys/build.lua index 9608aab7b..a4d2d7447 100644 --- a/plat/linux386/libsys/build.lua +++ b/plat/linux386/libsys/build.lua @@ -5,6 +5,10 @@ acklibrary { "plat/linux/libsys/*.c", "plat/linux/libsys/*.s", }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/linux386/include+headers", + }, vars = { plat = "linux386" } diff --git a/plat/linux68k/libsys/build.lua b/plat/linux68k/libsys/build.lua index 4a8729977..ded71cdd1 100644 --- a/plat/linux68k/libsys/build.lua +++ b/plat/linux68k/libsys/build.lua @@ -5,6 +5,10 @@ acklibrary { "plat/linux/libsys/*.c", "plat/linux/libsys/*.s", }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/linux68k/include+headers", + }, vars = { plat = "linux68k" } diff --git a/plat/pc86/libsys/build.lua b/plat/pc86/libsys/build.lua index 909b02930..a30ecae9e 100644 --- a/plat/pc86/libsys/build.lua +++ b/plat/pc86/libsys/build.lua @@ -4,6 +4,10 @@ acklibrary { "./*.c", "./*.s", }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/pc86/include+headers", + }, vars = { plat = "pc86" } From 46bd70380c654d73a4464b60c0502c27b75940be Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 15 Aug 2016 00:47:08 +0200 Subject: [PATCH 199/231] Filename variables now get passed into ackbuilder on the command line. --- Makefile | 48 +++++++++++++++++++++----------------------- first/ackbuilder.lua | 28 +++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index b3955ca40..9dae29060 100644 --- a/Makefile +++ b/Makefile @@ -55,27 +55,21 @@ NINJA := $(shell which ninja) ifneq ($(findstring +, $(MAKECMDGOALS)),) ifneq ($(NINJA),) -$(MAKECMDGOALS): $(BUILDDIR)/build.ninja $(BUILDDIR)/rules.ninja +$(MAKECMDGOALS): $(BUILDDIR)/build.ninja @ninja -f $(BUILDDIR)/build.ninja $(MAKECMDGOALS) -$(BUILDDIR)/build.ninja: Makefile - @mkdir -p $(BUILDDIR) - @echo "OBJDIR = $(OBJDIR)" > $@ - @echo "BINDIR = $(BINDIR)" >> $@ - @echo "LIBDIR = $(LIBDIR)" >> $@ - @echo "INCDIR = $(INCDIR)" >> $@ - @echo "INSDIR = $(INSDIR)" >> $@ - @echo "PLATIND = $(PLATIND)" >> $@ - @echo "PLATDEP = $(PLATDEP)" >> $@ - @echo "AR = $(AR)" >> $@ - @echo "CC = $(CC)" >> $@ - @echo "subninja $(BUILDDIR)/rules.ninja" >> $@ - else $(MAKECMDGOALS): $(BUILDDIR)/rules.mk +@make -r -f $(BUILDDIR)/rules.mk $@ \ - $(MAKEFLAGS) \ + $(MAKEFLAGS) + +endif +endif + +$(BUILDDIR)/build.ninja: first/ackbuilder.lua Makefile $(BUILD_FILES) + @mkdir -p $(BUILDDIR) + @lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja \ OBJDIR=$(OBJDIR) \ BINDIR=$(BINDIR) \ LIBDIR=$(LIBDIR) \ @@ -84,18 +78,22 @@ $(MAKECMDGOALS): $(BUILDDIR)/rules.mk PLATIND=$(PLATIND) \ PLATDEP=$(PLATDEP) \ AR=$(AR) \ - CC=$(CC) + CC=$(CC) \ + > $(BUILDDIR)/build.ninja -endif -endif - -$(BUILDDIR)/rules.ninja: first/ackbuilder.lua $(BUILD_FILES) +$(BUILDDIR)/rules.mk: first/ackbuilder.lua Makefile $(BUILD_FILES) @mkdir -p $(BUILDDIR) - @lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja > $(BUILDDIR)/rules.ninja - -$(BUILDDIR)/rules.mk: first/ackbuilder.lua $(BUILD_FILES) - @mkdir -p $(BUILDDIR) - @lua5.2 first/ackbuilder.lua first/build.lua build.lua --make > $(BUILDDIR)/rules.mk + @lua5.1 first/ackbuilder.lua first/build.lua build.lua --make \ + OBJDIR=$(OBJDIR) \ + BINDIR=$(BINDIR) \ + LIBDIR=$(LIBDIR) \ + INCDIR=$(INCDIR) \ + INSDIR=$(INSDIR) \ + PLATIND=$(PLATIND) \ + PLATDEP=$(PLATDEP) \ + AR=$(AR) \ + CC=$(CC) \ + > $(BUILDDIR)/rules.mk clean: @rm -rf $(BUILDDIR) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 2333461ee..c90d1d021 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -602,6 +602,12 @@ end local function install_make_emitter() emit("hide = @\n") + + function emitter:var(name, value) + -- Don't let emit insert spaces. + emit(name.."="..value.."\n") + end + function emitter:rule(name, ins, outs) emit(".INTERMEDIATE:", name, "\n") for i = 1, #ins do @@ -656,6 +662,11 @@ local function install_ninja_emitter() ) end + function emitter:var(name, value) + -- Don't let emit insert spaces. + emit(name.."="..unmake(value).."\n") + end + function emitter:rule(name, ins, outs) if (#outs == 0) then emit("build", name, ": phony", unmake(ins), "\n") @@ -853,22 +864,33 @@ do { ["make"] = function() emitter_type = install_make_emitter - return 1 + return 0 end, ["ninja"] = function() emitter_type = install_ninja_emitter - return 1 + return 0 end, + [" unrecognised"] = function(arg) error(string.format("unrecognised argument '%s'", arg)) end, [" files"] = function(files) emitter_type() + for _, f in ipairs(files) do - loadbuildfile(f) + local _, _, name, value = f:find("^([%w_]+)=(.*)$") + if name then + emitter:var(name, value) + end + end + + for _, f in ipairs(files) do + if not f:find("=") then + loadbuildfile(f) + end end end }, From 23e8d5af5a0de59c89f5a1bfda165ebe975a2181 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 12:40:00 +0200 Subject: [PATCH 200/231] Wildcards are allowed to match no files now. --- first/ackbuilder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index c90d1d021..4b3e1bc6a 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -427,7 +427,7 @@ loadtarget = function(targetname) if targetname:find("[?*]") then files = posix.glob(targetname) if not files then - error(string.format("glob '%s' matches no files", targetname)) + files = {} end else files = {targetname} From 204f932ed276cd6abde0d03523d32fabc3fa3d26 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 12:40:13 +0200 Subject: [PATCH 201/231] Raspberry Pi backend now builds. --- build.lua | 2 ++ mach/proto/as/build.lua | 5 ++++- mach/vc4/libem/build.lua | 8 ++++++++ mach/vc4/libend/build.lua | 8 ++++++++ plat/rpi/build-pkg.lua | 25 +++++++++++++++++++++++++ plat/rpi/build-tools.lua | 21 +++++++++++++++++++++ plat/rpi/include/build.lua | 27 +++++++++++++++++++++++++++ plat/rpi/libsys/build.lua | 15 +++++++++++++++ 8 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 mach/vc4/libem/build.lua create mode 100644 mach/vc4/libend/build.lua create mode 100644 plat/rpi/build-pkg.lua create mode 100644 plat/rpi/build-tools.lua create mode 100644 plat/rpi/include/build.lua create mode 100644 plat/rpi/libsys/build.lua diff --git a/build.lua b/build.lua index dc2178fb8..24dcb39b4 100644 --- a/build.lua +++ b/build.lua @@ -9,6 +9,7 @@ vars.plats = { "linux386", "linux68k", "pc86", + "rpi", } installable { @@ -21,6 +22,7 @@ installable { "plat/cpm+pkg", "plat/linux386+pkg", "plat/linux68k+pkg", + "plat/rpi+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua index 37f6cd336..6d846682e 100644 --- a/mach/proto/as/build.lua +++ b/mach/proto/as/build.lua @@ -10,7 +10,10 @@ definerule("build_as", local archlib = clibrary { name = e.name.."/archlib", srcs = {}, - hdrs = { "mach/"..e.arch.."/as/mach*.c" } + hdrs = { + "mach/"..e.arch.."/as/mach*.c", + "mach/"..e.arch.."/as/*.h" + } } local preprocessedy = cppfile { diff --git a/mach/vc4/libem/build.lua b/mach/vc4/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/vc4/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/vc4/libend/build.lua b/mach/vc4/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/vc4/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/plat/rpi/build-pkg.lua b/plat/rpi/build-pkg.lua new file mode 100644 index 000000000..b6bc4ab56 --- /dev/null +++ b/plat/rpi/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "rpi" } +} + +build_plat_libs { + name = "libs", + arch = "vc4", + plat = "rpi", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/rpi/boot.o"] = "+boot", + ["$(PLATIND)/rpi/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/rpi/build-tools.lua b/plat/rpi/build-tools.lua new file mode 100644 index 000000000..eb3cbfef2 --- /dev/null +++ b/plat/rpi/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "vc4", +} + +build_ncg { + name = "ncg", + arch = "vc4", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/rpi/as"] = "+as", + ["$(PLATDEP)/rpi/ncg"] = "+ncg", + ["$(PLATIND)/descr/rpi"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/rpi/include/build.lua b/plat/rpi/include/build.lua new file mode 100644 index 000000000..4e6b8521b --- /dev/null +++ b/plat/rpi/include/build.lua @@ -0,0 +1,27 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/rpi/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("pi.h") +addheader("sys/select.h") +addheader("termios.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + diff --git a/plat/rpi/libsys/build.lua b/plat/rpi/libsys/build.lua new file mode 100644 index 000000000..db579d41b --- /dev/null +++ b/plat/rpi/libsys/build.lua @@ -0,0 +1,15 @@ +acklibrary { + name = "lib", + srcs = { + "./*.c", + "./*.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/rpi/include+headers", + }, + vars = { + plat = "rpi" + } +} + From f561b94b496bb74a846611562fd4381f07a6a77b Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:02:12 +0200 Subject: [PATCH 202/231] Print hex numbers actually properly this time. --- util/amisc/aelflod.c | 11 ++++++----- util/amisc/aslod.c | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c index d9a2ed6e0..398b223b2 100644 --- a/util/amisc/aelflod.c +++ b/util/amisc/aelflod.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "out.h" #define ASSERT(x) switch (2) { case 0: case (x): ; } @@ -453,11 +454,11 @@ int main(int argc, char* argv[]) { long ss = 0; printf(" address length\n"); - printf(" ehdr : %08lX %08lX\n", outsect[TEXT].os_base & ~0x1FFF, codeoffset); - printf(" text : %08lX %08lX\n", outsect[TEXT].os_base, outsect[TEXT].os_size); - printf(" rom : %08lX %08lX\n", outsect[ROM].os_base, outsect[ROM].os_size); - printf(" data : %08lX %08lX\n", outsect[DATA].os_base, outsect[DATA].os_size); - printf(" bss : %08lX %08lX\n", outsect[BSS].os_base, outsect[BSS].os_size); + printf(" ehdr : %08"PRIx32" %08"PRIx32"\n", outsect[TEXT].os_base & ~0x1FFF, codeoffset); + printf(" text : %08"PRIx32" %08"PRIx32"\n", outsect[TEXT].os_base, outsect[TEXT].os_size); + printf(" rom : %08"PRIx32" %08"PRIx32"\n", outsect[ROM].os_base, outsect[ROM].os_size); + printf(" data : %08"PRIx32" %08"PRIx32"\n", outsect[DATA].os_base, outsect[DATA].os_size); + printf(" bss : %08"PRIx32" %08"PRIx32"\n", outsect[BSS].os_base, outsect[BSS].os_size); ss += outsect[TEXT].os_size; ss += outsect[ROM].os_size; ss += outsect[DATA].os_size; diff --git a/util/amisc/aslod.c b/util/amisc/aslod.c index 80c92d3c6..307f72cb1 100644 --- a/util/amisc/aslod.c +++ b/util/amisc/aslod.c @@ -303,11 +303,11 @@ int main(int argc, char* argv[]) { long ss = 0; - printf(" base : "PRIu32"\n", outsect[TEXT].os_base) ; - printf(" text = "PRIu32"\n", outsect[TEXT].os_size); - printf(" rom = "PRIu32"\n", outsect[ROM].os_size); - printf(" data = "PRIu32"\n", outsect[DATA].os_size); - printf(" bss = "PRIu32"\n", outsect[BSS].os_size); + printf(" base : %08"PRIx32"\n", outsect[TEXT].os_base) ; + printf(" text = %08"PRIx32"\n", outsect[TEXT].os_size); + printf(" rom = %08"PRIx32"\n", outsect[ROM].os_size); + printf(" data = %08"PRIx32"\n", outsect[DATA].os_size); + printf(" bss = %08"PRIx32"\n", outsect[BSS].os_size); ss += outsect[TEXT].os_size; ss += outsect[ROM].os_size; ss += outsect[DATA].os_size; From 52eaf753b679568d15f4cf3c97040c2e807d1a3b Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:03:19 +0200 Subject: [PATCH 203/231] rpi has a time() function; don't try to call gettimeofday(). --- plat/rpi/include/ack/config.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plat/rpi/include/ack/config.h b/plat/rpi/include/ack/config.h index fd2c48cba..995673236 100644 --- a/plat/rpi/include/ack/config.h +++ b/plat/rpi/include/ack/config.h @@ -8,4 +8,9 @@ #ifndef _ACK_CONFIG_H #define _ACK_CONFIG_H +/* We're providing a time() system call rather than wanting a wrapper around + * gettimeofday() in the libc. */ + +#define ACKCONF_TIME_IS_A_SYSCALL + #endif From edee22510b4e12c1c828617704a54fb9b7e8edcc Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:03:49 +0200 Subject: [PATCH 204/231] liblinux is no more; its files are now in libsys. --- plat/linux386/descr | 1 - plat/linux68k/descr | 1 - 2 files changed, 2 deletions(-) diff --git a/plat/linux386/descr b/plat/linux386/descr index 7fa809058..32f5ea2e5 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -68,7 +68,6 @@ name led (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ {FLOATS?} \ (.e:{TAIL}={PLATFORMDIR}/libem.a \ - {PLATFORMDIR}/liblinux.a \ {PLATFORMDIR}/libsys.a \ {PLATFORMDIR}/libend.a) linker diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 997ec7154..2c7d57d50 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -68,7 +68,6 @@ name led (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ {FLOATS?} \ (.e:{TAIL}={PLATFORMDIR}/libem.a \ - {PLATFORMDIR}/liblinux.a \ {PLATFORMDIR}/libsys.a \ {PLATFORMDIR}/libend.a) linker From 856eb120b3189eb4288320b0cdd222c72acfffc4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:04:17 +0200 Subject: [PATCH 205/231] Add files which got missed in the initial build pass. --- lang/cem/libcc.ansi/build.lua | 1 + mach/m68020/libem/build.lua | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua index ca5c9c570..3ca95b629 100644 --- a/lang/cem/libcc.ansi/build.lua +++ b/lang/cem/libcc.ansi/build.lua @@ -38,6 +38,7 @@ for _, plat in ipairs(vars.plats) do "./locale/*.c", "./malloc/*.c", "./math/*.c", + "./math/*.e", "./misc/environ.c", -- don't build everything here as it's all obsolete "./setjmp/*.c", "./setjmp/*.e", diff --git a/mach/m68020/libem/build.lua b/mach/m68020/libem/build.lua index ca5a13c65..d17adcd92 100644 --- a/mach/m68020/libem/build.lua +++ b/mach/m68020/libem/build.lua @@ -1,8 +1,14 @@ for _, plat in ipairs(vars.plats) do acklibrary { name = "lib_"..plat, - srcs = { "./*.s" }, + srcs = { + "./*.s", + "./*.c" + }, vars = { plat = plat }, + deps = { + "h+emheaders" + } } end From 53c9731036e66e1b492d22780fb66143521cd728 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:04:46 +0200 Subject: [PATCH 206/231] aal doesn't build the ranlib table if you don't set -DAAL. --- util/arch/build.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/arch/build.lua b/util/arch/build.lua index ad207c60e..54b05f981 100644 --- a/util/arch/build.lua +++ b/util/arch/build.lua @@ -7,6 +7,9 @@ cprogram { "modules/src/print+lib", "modules/src/string+lib", "modules/src/system+lib" + }, + vars = { + ["+cflags"] = "-DAAL" } } From 1a7b4f872916c8271c76aa40630ced8902d2ca85 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 20 Aug 2016 14:05:24 +0200 Subject: [PATCH 207/231] Build the examples when doing a normal build; this exercises the compiler as a whole and is one step further towards a proper test suite. --- build.lua | 12 +++++++----- examples/build.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ first/build.lua | 3 ++- plat/build.lua | 24 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 examples/build.lua diff --git a/build.lua b/build.lua index 24dcb39b4..3c5e34c8d 100644 --- a/build.lua +++ b/build.lua @@ -12,6 +12,11 @@ vars.plats = { "rpi", } +local plat_packages = {} +for _, p in ipairs(vars.plats) do + plat_packages[#plat_packages+1] = "plat/"..p.."+pkg" +end + installable { name = "ack", map = { @@ -19,17 +24,14 @@ installable { "lang/cem/cemcom.ansi+pkg", "lang/m2/comp+pkg", "lang/pc/comp+pkg", - "plat/cpm+pkg", - "plat/linux386+pkg", - "plat/linux68k+pkg", - "plat/rpi+pkg", - "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", "util/arch+pkg", "util/led+pkg", "util/misc+pkg", "util/opt+pkg", + "examples+pkg", + plat_packages } } diff --git a/examples/build.lua b/examples/build.lua new file mode 100644 index 000000000..631752976 --- /dev/null +++ b/examples/build.lua @@ -0,0 +1,44 @@ +include("plat/build.lua") + +local conly = { + rpi = true +} + +local sourcefiles = filenamesof( + "./hilo.b", + "./hilo.c", + "./hilo.mod", + "./hilo.p", + "./mandelbrot.c", + "./paranoia.c", + "./startrek.c" +) + +local installmap = {} +for _, file in ipairs(sourcefiles) do + local b = basename(file) + local be = replace(b, "%.", "_") + local _, _, e = b:find("%.(%w*)$") + + for _, plat in ipairs(vars.plats) do + if (e == "c") or not conly[plat] then + local exe = ackprogram { + name = be.."_"..plat, + srcs = { file }, + vars = { + plat = plat, + lang = e, + } + } + + installmap["$(PLATIND)/examples/"..be.."."..plat] = exe + end + end + installmap["$(PLATIND)/examples/"..b] = file +end + +installable { + name = "pkg", + map = installmap +} + diff --git a/first/build.lua b/first/build.lua index 0efdadb12..3240f9f1a 100644 --- a/first/build.lua +++ b/first/build.lua @@ -216,6 +216,7 @@ definerule("cprogram", { srcs = { type="targets", default={} }, deps = { type="targets", default={} }, + _clibrary = { type="object", default=clibrary }, commands = { type="strings", default={ @@ -229,7 +230,7 @@ definerule("cprogram", for _, f in pairs( matching( filenamesof( - clibrary { + e._clibrary { name = e.name .. "/main", cwd = e.cwd, srcs = e.srcs, diff --git a/plat/build.lua b/plat/build.lua index f46db0bbe..d24e5d3f2 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -54,6 +54,30 @@ definerule("acklibrary", end ) +definerule("ackprogram", + { + srcs = { type="targets", default={} }, + deps = { type="targets", default={} }, + }, + function (e) + return cprogram { + name = e.name, + srcs = e.srcs, + deps = { + "plat/"..e.vars.plat.."+pkg", + "util/ack+pkg", + "util/led+pkg", + "util/amisc+pkg", + e.deps + }, + _clibrary = acklibrary, + commands = { + "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -.%{lang} -o %{outs} %{ins}" + } + } + end +) + definerule("build_plat_libs", { arch = { type="string" }, From 03a0b182c4bf4da9599bb658b6fc08fb5f012815 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 18:45:25 +0200 Subject: [PATCH 208/231] Push em_ego.c through clang-format before working on it. --- .clang-format | 11 + util/ego/em_ego/em_ego.c | 707 +++++++++++++++++++++------------------ 2 files changed, 390 insertions(+), 328 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..d5e0c3a16 --- /dev/null +++ b/.clang-format @@ -0,0 +1,11 @@ +--- +BasedOnStyle: WebKit +AllowShortLoopsOnASingleLine: 'false' +AlwaysBreakAfterDefinitionReturnType: false +BreakBeforeBraces: Allman +IndentCaseLabels: 'true' +PointerAlignment: Left +TabWidth: '4' +UseTab: ForIndentation + +... diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 9542b41e6..0d4bc06a3 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -8,414 +8,465 @@ #include #include -#define IC 1 -#define CF 2 -#define IL 3 -#define CS 4 -#define SR 5 -#define UD 6 -#define LV 7 -#define RA 8 -#define SP 9 -#define BO 10 -#define CJ 11 -#define CA 12 +#define IC 1 +#define CF 2 +#define IL 3 +#define CS 4 +#define SR 5 +#define UD 6 +#define LV 7 +#define RA 8 +#define SP 9 +#define BO 10 +#define CJ 11 +#define CA 12 -static char *phnames[] = { - 0, - "ic", - "cf", - "il", - "cs", - "sr", - "ud", - "lv", - "ra", - "sp", - "bo", - "cj", - "ca", - 0 +static char* phnames[] = { + 0, + "ic", + "cf", + "il", + "cs", + "sr", + "ud", + "lv", + "ra", + "sp", + "bo", + "cj", + "ca", + 0 }; -#define MAXUPHASES 64 /* max # of phases to be run */ -#define MAXARGS 1024 /* mar # of args */ -#define NTEMPS 4 /* # of temporary files; not tunable */ +#define MAXUPHASES 64 /* max # of phases to be run */ +#define MAXARGS 1024 /* mar # of args */ +#define NTEMPS 4 /* # of temporary files; not tunable */ -extern char *mktemp(); -extern char *strcpy(), *strcat(); -extern char *strrchr(); +extern char* mktemp(); +extern char* strcpy(), *strcat(); +extern char* strrchr(); -static char ddump[128] = TMP_DIR; /* data label dump file */ -static char pdump[128] = TMP_DIR; /* procedure name dump file */ -static char tmpbufs[NTEMPS*2][128] = { - TMP_DIR +static char ddump[128] = TMP_DIR; /* data label dump file */ +static char pdump[128] = TMP_DIR; /* procedure name dump file */ +static char tmpbufs[NTEMPS * 2][128] = { + TMP_DIR }; -static int O2phases[] = { /* Passes for -O2 */ - CJ, BO, SP, 0 +static int O2phases[] = { /* Passes for -O2 */ + CJ, BO, SP, 0 }; -static int O3phases[] = { /* Passes for -O3 */ - CS, SR, CJ, BO, SP, UD, LV, RA, 0 +static int O3phases[] = { /* Passes for -O3 */ + CS, SR, CJ, BO, SP, UD, LV, RA, 0 }; -static int O4phases[] = { /* Passes for -O4 */ - IL, CF, CS, SR, CJ, BO, SP, UD, LV, RA, 0 +static int O4phases[] = { /* Passes for -O4 */ + IL, CF, CS, SR, CJ, BO, SP, UD, LV, RA, 0 }; -static int *Ophase = &O2phases[0]; /* default : -O2 */ +static int* Ophase = &O2phases[0]; /* default : -O2 */ -static int nuphases; /* # of phases specified by user */ -static int uphases[MAXUPHASES+1]; /* phases to be run */ +static int nuphases; /* # of phases specified by user */ +static int uphases[MAXUPHASES + 1]; /* phases to be run */ -static int nfiles = NTEMPS*2+1; /* leave space for tempfilenames */ -static char *phargs[MAXARGS+1]; +static int nfiles = NTEMPS * 2 + 1; /* leave space for tempfilenames */ +static char* phargs[MAXARGS + 1]; -static int keeptemps = 0; +static int keeptemps = 0; -static char **phase_args; -static int nphase_args; +static char** phase_args; +static int nphase_args; -static char *opt_dir; -static char *prog_name; +static char* opt_dir; +static char* prog_name; -static int v_flag; +static int v_flag; static void cleanup() { - /* Cleanup temporaries */ + /* Cleanup temporaries */ - if (! keeptemps) { - register int i; + if (!keeptemps) + { + register int i; - for (i = NTEMPS*2; i > 0; i--) { - register char *f = phargs[i]; - if (f != 0 && *f != '\0' && *f != '-') (void) unlink(f); + for (i = NTEMPS * 2; i > 0; i--) + { + register char* f = phargs[i]; + if (f != 0 && *f != '\0' && *f != '-') + (void)unlink(f); + } + if (ddump[0] != '\0') + (void)unlink(ddump); + if (pdump[0] != '\0') + (void)unlink(pdump); } - if (ddump[0] != '\0') (void) unlink(ddump); - if (pdump[0] != '\0') (void) unlink(pdump); - } } /*VARARGS1*/ static void -fatal(s, s2) - char *s; - char *s2; + fatal(s, s2) char* s; +char* s2; { - /* A fatal error occurred; exit gracefully */ + /* A fatal error occurred; exit gracefully */ - fprint(STDERR, "%s: ", prog_name); - fprint(STDERR, s, s2); - fprint(STDERR, "\n"); - cleanup(); - sys_stop(S_EXIT); - /*NOTREACHED*/ + fprint(STDERR, "%s: ", prog_name); + fprint(STDERR, s, s2); + fprint(STDERR, "\n"); + cleanup(); + sys_stop(S_EXIT); + /*NOTREACHED*/ } static void -add_file(s) - char *s; + add_file(s) char* s; { - /* Add an input file to the list */ + /* Add an input file to the list */ - if (nfiles >= MAXARGS) fatal("too many files"); - phargs[nfiles++] = s; + if (nfiles >= MAXARGS) + fatal("too many files"); + phargs[nfiles++] = s; } static void -add_uphase(p) - int p; + add_uphase(p) int p; { - /* Add an optimizer phase to the list of phases to run */ + /* Add an optimizer phase to the list of phases to run */ - if (nuphases >= MAXUPHASES) fatal("too many phases"); - uphases[nuphases++] = p; + if (nuphases >= MAXUPHASES) + fatal("too many phases"); + uphases[nuphases++] = p; } -static void -catch() +static void catch () { - /* Catch interrupts and exit gracefully */ + /* Catch interrupts and exit gracefully */ - cleanup(); - sys_stop(S_EXIT); + cleanup(); + sys_stop(S_EXIT); } static void old_infiles() { - /* Remove old input files unless we have to keep them around. */ + /* Remove old input files unless we have to keep them around. */ - register int i; + register int i; - if (phargs[1] == pdump || keeptemps) return; + if (phargs[1] == pdump || keeptemps) + return; - for (i = 1; i <= NTEMPS; i++) (void) unlink(phargs[i]); + for (i = 1; i <= NTEMPS; i++) + (void)unlink(phargs[i]); } static void get_infiles() { - /* Make output temps from previous phase input temps of next phase. */ + /* Make output temps from previous phase input temps of next phase. */ - register int i; - register char **dst = &phargs[1]; - register char **src = &phargs[NTEMPS+1]; + register int i; + register char** dst = &phargs[1]; + register char** src = &phargs[NTEMPS + 1]; - for (i = 1; i <= NTEMPS; i++) { - *dst++ = *src++; - } + for (i = 1; i <= NTEMPS; i++) + { + *dst++ = *src++; + } } static void new_outfiles() { - static int tmpindex = 0; - static int Bindex = 0; - static char dig1 = '1'; - static char dig2 = '0'; - register int i; - register char **dst = &phargs[NTEMPS+1]; + static int tmpindex = 0; + static int Bindex = 0; + static char dig1 = '1'; + static char dig2 = '0'; + register int i; + register char** dst = &phargs[NTEMPS + 1]; - if (! Bindex) { - Bindex = strrchr(tmpbufs[0], 'B') - tmpbufs[0]; - } - for (i = 1; i <= NTEMPS; i++) { - *dst = tmpbufs[tmpindex]; - (*dst)[Bindex-1] = dig2; - (*dst)[Bindex] = dig1; - tmpindex++; - dst++; - } - if (tmpindex >= 2*NTEMPS) tmpindex = 0; - if (++dig1 > '9') { - ++dig2; - dig1 = '0'; - } + if (!Bindex) + { + Bindex = strrchr(tmpbufs[0], 'B') - tmpbufs[0]; + } + for (i = 1; i <= NTEMPS; i++) + { + *dst = tmpbufs[tmpindex]; + (*dst)[Bindex - 1] = dig2; + (*dst)[Bindex] = dig1; + tmpindex++; + dst++; + } + if (tmpindex >= 2 * NTEMPS) + tmpindex = 0; + if (++dig1 > '9') + { + ++dig2; + dig1 = '0'; + } } static void -run_phase(phase) - int phase; + run_phase(phase) int phase; { - /* Run one phase of the global optimizer; special cases are + /* Run one phase of the global optimizer; special cases are IC and CA. */ - static int flags_added; - register int argc; - register int i; - char buf[256]; - int pid, status; + static int flags_added; + register int argc; + register int i; + char buf[256]; + int pid, status; - phargs[0] = buf; - (void) strcpy(buf, opt_dir); - (void) strcat(buf, "/"); - (void) strcat(buf, phnames[phase]); + phargs[0] = buf; + (void)strcpy(buf, opt_dir); + (void)strcat(buf, "/"); + (void)strcat(buf, phnames[phase]); - switch(phase) { - case IC: - phargs[1] = pdump; - phargs[2] = ddump; - for (i = 3; i <= NTEMPS; i++) phargs[i] = "-"; - new_outfiles(); - argc = nfiles; - phargs[argc] = 0; - break; + switch (phase) + { + case IC: + phargs[1] = pdump; + phargs[2] = ddump; + for (i = 3; i <= NTEMPS; i++) + phargs[i] = "-"; + new_outfiles(); + argc = nfiles; + phargs[argc] = 0; + break; - case CA: - old_infiles(); - get_infiles(); - phargs[NTEMPS+1] = pdump; - phargs[NTEMPS+2] = ddump; - for (i = NTEMPS+3; i <= 2*NTEMPS; i++) phargs[i] = "-"; - argc = 2*NTEMPS+1; - phargs[argc] = 0; - break; + case CA: + old_infiles(); + get_infiles(); + phargs[NTEMPS + 1] = pdump; + phargs[NTEMPS + 2] = ddump; + for (i = NTEMPS + 3; i <= 2 * NTEMPS; i++) + phargs[i] = "-"; + argc = 2 * NTEMPS + 1; + phargs[argc] = 0; + break; - default: - old_infiles(); - get_infiles(); - new_outfiles(); - if (! flags_added) { - flags_added = 1; - argc = 2*NTEMPS+1; - while (--nphase_args >= 0) { - phargs[argc++] = *phase_args++; + default: + old_infiles(); + get_infiles(); + new_outfiles(); + if (!flags_added) + { + flags_added = 1; + argc = 2 * NTEMPS + 1; + while (--nphase_args >= 0) + { + phargs[argc++] = *phase_args++; + } + phargs[argc] = 0; + } + break; + } + if ((pid = fork()) < 0) + { + fatal("Could not fork"); + } + else if (pid == 0) + { + if (v_flag) + { + register int i = 0; + + while (phargs[i]) + { + fprint(STDERR, "%s ", phargs[i]); + i++; + } + fprint(STDERR, "\n"); } - phargs[argc] = 0; - } - break; - } - if ((pid = fork()) < 0) { - fatal("Could not fork"); - } - else if (pid == 0) { - if (v_flag) { - register int i = 0; - - while (phargs[i]) { - fprint(STDERR, "%s ", phargs[i]); - i++; - } - fprint(STDERR, "\n"); - } - (void) execv(phargs[0], phargs); - fatal("Could not exec %s", phargs[0]); - sys_stop(S_EXIT); - } - else { - while (wait(&status) != pid) /* nothing */ ; - if ((status & 0177) != 0) { - fatal("%s got a unix signal", phargs[0]); - } - if (((status >> 8) & 0377) != 0) { - cleanup(); + (void)execv(phargs[0], phargs); + fatal("Could not exec %s", phargs[0]); sys_stop(S_EXIT); } - } -} - -main(argc, argv) - int argc; - char *argv[]; -{ - register int i = 0; - - if (signal(SIGHUP, catch) == SIG_IGN) (void) signal(SIGHUP, SIG_IGN); - if (signal(SIGQUIT, catch) == SIG_IGN) (void) signal(SIGQUIT, SIG_IGN); - if (signal(SIGINT, catch) == SIG_IGN) (void) signal(SIGINT, SIG_IGN); - prog_name = argv[0]; - phase_args = &argv[1]; - while (--argc > 0) { - argv++; - if (argv[0][0] == '-') { - switch(argv[0][1]) { - case 'P': - if (argv[0][2] == '\0') { - opt_dir = argv[1]; - argc--; - argv++; - continue; - } - break; - case 't': - if (argv[0][2] == '\0') { - keeptemps = 1; - /* no continue; IL also needs this */ - } - break; - case 'v': - v_flag = 1; - break; - case 'O': - if (argv[0][2] == '2' || argv[0][2] == '\0') continue; - if (argv[0][2] == '3') { - Ophase = &O3phases[0]; - continue; - } - Ophase = &O4phases[0]; - continue; - case 'I': - if (! strcmp(&argv[0][1], "IL")) { - add_uphase(IL); - add_uphase(CF); - continue; - } - break; - case 'B': - if (! strcmp(&argv[0][1], "BO")) { - add_uphase(BO); - continue; - } - break; - case 'R': - if (! strcmp(&argv[0][1], "RA")) { - add_uphase(RA); - continue; - } - break; - case 'U': - if (! strcmp(&argv[0][1], "UD")) { - add_uphase(UD); - continue; - } - break; - case 'L': - if (! strcmp(&argv[0][1], "LV")) { - add_uphase(LV); - continue; - } - break; - case 'C': - if (! strcmp(&argv[0][1], "CS")) { - add_uphase(CS); - continue; - } - if (! strcmp(&argv[0][1], "CJ")) { - add_uphase(CJ); - continue; - } - break; - case 'S': - if (! strcmp(&argv[0][1], "SR")) { - add_uphase(SR); - continue; - } - if (! strcmp(&argv[0][1], "SP")) { - add_uphase(SP); - continue; - } - break; + else + { + while (wait(&status) != pid) /* nothing */ + ; + if ((status & 0177) != 0) + { + fatal("%s got a unix signal", phargs[0]); + } + if (((status >> 8) & 0377) != 0) + { + cleanup(); + sys_stop(S_EXIT); } - phase_args[i++] = argv[0]; } - else { - add_file(argv[0]); - } - } - phase_args[i] = 0; - nphase_args = i; - if (nuphases) Ophase = uphases; - - if (nfiles == 2*NTEMPS+1) { - /* 2*NTEMPS+1 was the starting value; nothing to do */ - sys_stop(S_END); - } - - if (! opt_dir) { - fatal("no correct -P flag given"); - } - - if (keeptemps) { - (void) strcpy(ddump, "."); - (void) strcpy(pdump, "."); - (void) strcpy(tmpbufs[0], "."); - } - (void) strcat(ddump, "/ego.dd.XXXXXX"); - (void) mktemp(ddump); - (void) strcat(pdump, "/ego.pd.XXXXXX"); - (void) mktemp(pdump); - - (void) strcat(tmpbufs[0], "/ego.A.BB.XXXXXX"); - (void) mktemp(tmpbufs[0]); - for (i = 2*NTEMPS-1; i >= 1; i--) { - (void) strcpy(tmpbufs[i], tmpbufs[0]); - } - i = strrchr(tmpbufs[0], 'A') - tmpbufs[0]; - tmpbufs[0][i] = 'p'; tmpbufs[NTEMPS+0][i] = 'p'; - tmpbufs[1][i] = 'd'; tmpbufs[NTEMPS+1][i] = 'd'; - tmpbufs[2][i] = 'l'; tmpbufs[NTEMPS+2][i] = 'l'; - tmpbufs[3][i] = 'b'; tmpbufs[NTEMPS+3][i] = 'b'; - run_phase(IC); - run_phase(CF); - while (*Ophase) { - run_phase(*Ophase++); - } - run_phase(CA); - cleanup(); - sys_stop(S_END); - /*NOTREACHED*/ +} + +main(argc, argv) int argc; +char* argv[]; +{ + register int i = 0; + + if (signal(SIGHUP, catch) == SIG_IGN) + (void)signal(SIGHUP, SIG_IGN); + if (signal(SIGQUIT, catch) == SIG_IGN) + (void)signal(SIGQUIT, SIG_IGN); + if (signal(SIGINT, catch) == SIG_IGN) + (void)signal(SIGINT, SIG_IGN); + prog_name = argv[0]; + phase_args = &argv[1]; + while (--argc > 0) + { + argv++; + if (argv[0][0] == '-') + { + switch (argv[0][1]) + { + case 'P': + if (argv[0][2] == '\0') + { + opt_dir = argv[1]; + argc--; + argv++; + continue; + } + break; + case 't': + if (argv[0][2] == '\0') + { + keeptemps = 1; + /* no continue; IL also needs this */ + } + break; + case 'v': + v_flag = 1; + break; + case 'O': + if (argv[0][2] == '2' || argv[0][2] == '\0') + continue; + if (argv[0][2] == '3') + { + Ophase = &O3phases[0]; + continue; + } + Ophase = &O4phases[0]; + continue; + case 'I': + if (!strcmp(&argv[0][1], "IL")) + { + add_uphase(IL); + add_uphase(CF); + continue; + } + break; + case 'B': + if (!strcmp(&argv[0][1], "BO")) + { + add_uphase(BO); + continue; + } + break; + case 'R': + if (!strcmp(&argv[0][1], "RA")) + { + add_uphase(RA); + continue; + } + break; + case 'U': + if (!strcmp(&argv[0][1], "UD")) + { + add_uphase(UD); + continue; + } + break; + case 'L': + if (!strcmp(&argv[0][1], "LV")) + { + add_uphase(LV); + continue; + } + break; + case 'C': + if (!strcmp(&argv[0][1], "CS")) + { + add_uphase(CS); + continue; + } + if (!strcmp(&argv[0][1], "CJ")) + { + add_uphase(CJ); + continue; + } + break; + case 'S': + if (!strcmp(&argv[0][1], "SR")) + { + add_uphase(SR); + continue; + } + if (!strcmp(&argv[0][1], "SP")) + { + add_uphase(SP); + continue; + } + break; + } + phase_args[i++] = argv[0]; + } + else + { + add_file(argv[0]); + } + } + phase_args[i] = 0; + nphase_args = i; + if (nuphases) + Ophase = uphases; + + if (nfiles == 2 * NTEMPS + 1) + { + /* 2*NTEMPS+1 was the starting value; nothing to do */ + sys_stop(S_END); + } + + if (!opt_dir) + { + fatal("no correct -P flag given"); + } + + if (keeptemps) + { + (void)strcpy(ddump, "."); + (void)strcpy(pdump, "."); + (void)strcpy(tmpbufs[0], "."); + } + (void)strcat(ddump, "/ego.dd.XXXXXX"); + (void)mktemp(ddump); + (void)strcat(pdump, "/ego.pd.XXXXXX"); + (void)mktemp(pdump); + + (void)strcat(tmpbufs[0], "/ego.A.BB.XXXXXX"); + (void)mktemp(tmpbufs[0]); + for (i = 2 * NTEMPS - 1; i >= 1; i--) + { + (void)strcpy(tmpbufs[i], tmpbufs[0]); + } + i = strrchr(tmpbufs[0], 'A') - tmpbufs[0]; + tmpbufs[0][i] = 'p'; + tmpbufs[NTEMPS + 0][i] = 'p'; + tmpbufs[1][i] = 'd'; + tmpbufs[NTEMPS + 1][i] = 'd'; + tmpbufs[2][i] = 'l'; + tmpbufs[NTEMPS + 2][i] = 'l'; + tmpbufs[3][i] = 'b'; + tmpbufs[NTEMPS + 3][i] = 'b'; + run_phase(IC); + run_phase(CF); + while (*Ophase) + { + run_phase(*Ophase++); + } + run_phase(CA); + cleanup(); + sys_stop(S_END); + /*NOTREACHED*/ } From a4f136f999a25276630a9a6c7580539724083c7e Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 18:51:36 +0200 Subject: [PATCH 209/231] Run through clang-format. --- util/ego/share/go.c | 104 ++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/util/ego/share/go.c b/util/ego/share/go.c index 07434e915..0e1879947 100644 --- a/util/ego/share/go.c +++ b/util/ego/share/go.c @@ -9,7 +9,6 @@ * */ - #include #include "types.h" #include "debug.h" @@ -22,54 +21,52 @@ #include "alloc.h" #include "go.h" - -STATIC bool report_flag = FALSE; /* report #optimizations found? */ +STATIC bool report_flag = FALSE; /* report #optimizations found? */ #ifdef DEBUG -STATIC bool core_flag = FALSE; /* report core usage? */ +STATIC bool core_flag = FALSE; /* report core usage? */ #endif - -STATIC mach_init(machfile,phase_machinit) - char *machfile; - int (*phase_machinit)(); +STATIC mach_init(machfile, phase_machinit) char* machfile; +int (*phase_machinit)(); { /* Read target machine dependent information */ - FILE *f; + FILE* f; - f = openfile(machfile,"r"); - fscanf(f,"%d",&ws); - fscanf(f,"%d",&ps); - if (ws != ps && ps != 2*ws) error("illegal pointer size"); + f = openfile(machfile, "r"); + fscanf(f, "%d", &ws); + fscanf(f, "%d", &ps); + if (ws != ps && ps != 2 * ws) + error("illegal pointer size"); (*phase_machinit)(f); fclose(f); } - - -go(argc,argv,initialize,optimize,phase_machinit,proc_flag) - int argc; - char *argv[]; - int (*initialize)(); - int (*optimize)(); - int (*phase_machinit)(); - int (*proc_flag)(); +go(argc, argv, initialize, optimize, phase_machinit, proc_flag) int argc; +char* argv[]; +int (*initialize)(); +int (*optimize)(); +int (*phase_machinit)(); +int (*proc_flag)(); { - FILE *f, *gf, *f2, *gf2; /* The EM input and output and + FILE* f, *gf, *f2, *gf2; /* The EM input and output and * the basic block graphs input and output */ bblock_p g; line_p l; short kind; int i; - char *p; + char* p; bool time_opt = TRUE; linecount = 0; - for (i = ARGSTART; i < argc; i++) { + for (i = ARGSTART; i < argc; i++) + { p = argv[i]; - if (*p++ != '-') error("illegal argument"); - switch(*p) { + if (*p++ != '-') + error("illegal argument"); + switch (*p) + { case 'S': time_opt = FALSE; break; @@ -78,7 +75,7 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag) break; case 'M': p++; - mach_init(p,phase_machinit); + mach_init(p, phase_machinit); break; case 'C': #ifdef DEBUG @@ -98,31 +95,34 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag) } time_space_ratio = (time_opt ? 100 : 0); fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fdblock = getdtable(dname); /* data block table */ (*initialize)(); - if (optimize == no_action) return; - f = openfile(lname,"r"); - gf = openfile(bname,"r"); - f2 = openfile(lname2,"w"); - gf2 = openfile(bname2,"w"); + if (optimize == no_action) + return; + f = openfile(lname, "r"); + gf = openfile(bname, "r"); + f2 = openfile(lname2, "w"); + gf2 = openfile(bname2, "w"); mesregs = Lempty_set(); - while (getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) { + while (getunit(gf, f, &kind, &g, &l, &curproc, TRUE)) + { /* Read the control flow graph and EM text of * one procedure and optimize it. */ - if (kind == LDATA) { - putunit(LDATA, (proc_p) 0, l, gf2, f2); + if (kind == LDATA) + { + putunit(LDATA, (proc_p)0, l, gf2, f2); continue; } - OUTTRACE("flow graph of proc %d read",curproc->p_id); + OUTTRACE("flow graph of proc %d read", curproc->p_id); curproc->p_start = g; /* The global variable curproc points to the * current procedure. It is set by getgraph */ (*optimize)(curproc); - putunit(LTEXT,curproc,(line_p) 0,gf2,f2); + putunit(LTEXT, curproc, (line_p)0, gf2, f2); /* output control flow graph + text */ - OUTTRACE("graph of proc %d outputted",curproc->p_id); + OUTTRACE("graph of proc %d outputted", curproc->p_id); Ldeleteset(mesregs); mesregs = Lempty_set(); } @@ -130,34 +130,34 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag) fclose(f2); fclose(gf); fclose(gf2); - f = openfile(dname2,"w"); - putdtable(fdblock,f); + f = openfile(dname2, "w"); + putdtable(fdblock, f); /* fclose(f); done by putdtable */ - f = openfile(pname2,"w"); - putptable(fproc,f,TRUE); + f = openfile(pname2, "w"); + putptable(fproc, f, TRUE); /* fclose(f); done by putptable */ core_usage(); } - -no_action() { } +no_action() {} core_usage() { #ifdef DEBUG - if (core_flag) { + if (core_flag) + { coreusage(); } #endif } -report(s,n) - char *s; - int n; +report(s, n) char* s; +int n; { /* Report number of optimizations found, if report_flag is set */ - if (report_flag) { - fprintf(stderr,"%s: %d\n",s,n); + if (report_flag) + { + fprintf(stderr, "%s: %d\n", s, n); } } From 3584ddb6e954f132701ebff68ba0a67f77ac7608 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 19:34:54 +0200 Subject: [PATCH 210/231] Push through clang-format. --- util/ego/cf/cf.c | 438 +++++++++++++++++++++++++---------------------- 1 file changed, 238 insertions(+), 200 deletions(-) diff --git a/util/ego/cf/cf.c b/util/ego/cf/cf.c index fe513ea8d..c36694daf 100644 --- a/util/ego/cf/cf.c +++ b/util/ego/cf/cf.c @@ -31,39 +31,37 @@ #include "cf_idom.h" #include "cf_loop.h" -#define newcfbx() (bext_p) newstruct(bext_cf) -#define oldcfbx(x) oldstruct(bext_cf,x) +#define newcfbx() (bext_p) newstruct(bext_cf) +#define oldcfbx(x) oldstruct(bext_cf, x) extern char em_flag[]; -STATIC cset lpi_set; /* set of procedures used in LPI instruction */ -STATIC cset cai_set; /* set of all procedures doing a CAI */ - +STATIC cset lpi_set; /* set of procedures used in LPI instruction */ +STATIC cset cai_set; /* set of all procedures doing a CAI */ /* The procedure getbblocks reads the EM textfile and * partitions every procedure into a number of basic blocks. */ -#define LABEL0 0 -#define LABEL 1 -#define NORMAL 2 -#define JUMP 3 -#define END 4 -#define AFTERPRO 5 -#define INIT 6 - +#define LABEL0 0 +#define LABEL 1 +#define NORMAL 2 +#define JUMP 3 +#define END 4 +#define AFTERPRO 5 +#define INIT 6 /* These global variables are used by getbblocks and nextblock. */ -STATIC bblock_p b, *bp; /* b is the current basic block, bp is +STATIC bblock_p b, *bp; /* b is the current basic block, bp is * the address where the next block has * to be linked. */ -STATIC line_p lnp, *lp; /* lnp is the current line, lp is +STATIC line_p lnp, *lp; /* lnp is the current line, lp is * the address where the next line * has to be linked. */ -STATIC short state; /* We use a finite state machine with the +STATIC short state; /* We use a finite state machine with the * following states: * LABEL0: after the first (successive) * instruction label. @@ -77,7 +75,6 @@ STATIC short state; /* We use a finite state machine with the * INIT: initial state */ - STATIC nextblock() { /* allocate a new basic block structure and @@ -94,40 +91,44 @@ STATIC nextblock() b->b_extend->bx_cf.bx_semi = 0; lp = &lnp->l_next; #ifdef TRACE - fprintf(stderr,"new basic block, id = %d\n",lastbid); + fprintf(stderr, "new basic block, id = %d\n", lastbid); #endif } - STATIC short kind(lnp) - line_p lnp; + line_p lnp; { /* determine if lnp is a label, branch, end or otherwise */ short instr; - byte flow; + byte flow; - if ((instr = INSTR(lnp)) == op_lab) return (short) LABEL; - if (instr == ps_end) return (short) END; - if (instr > sp_lmnem) return (short) NORMAL; /* pseudo */ - if ((flow = (em_flag[instr-sp_fmnem] & EM_FLO)) == FLO_C || - flow == FLO_T) return (short) JUMP; /* conditional/uncond. jump */ - return (short) NORMAL; + if ((instr = INSTR(lnp)) == op_lab) + return (short)LABEL; + if (instr == ps_end) + return (short)END; + if (instr > sp_lmnem) + return (short)NORMAL; /* pseudo */ + if ((flow = (em_flag[instr - sp_fmnem] & EM_FLO)) == FLO_C || flow == FLO_T) + return (short)JUMP; /* conditional/uncond. jump */ + return (short)NORMAL; } - STATIC line_p doread_line(p_out) - proc_p *p_out; + proc_p* p_out; { /* read a line, and check pseudos for procedure addresses */ register line_p lnp = read_line(p_out); - if (lnp && TYPE(lnp) == OPLIST && INSTR(lnp) != ps_mes) { + if (lnp && TYPE(lnp) == OPLIST && INSTR(lnp) != ps_mes) + { register arg_p arg = ARG(lnp); - - while (arg) { - if (arg->a_type == ARGPROC) { + + while (arg) + { + if (arg->a_type == ARGPROC) + { Cadd(arg->a_a.a_proc->p_id, &lpi_set); arg->a_a.a_proc->p_flags1 |= PF_LPI; } @@ -137,34 +138,36 @@ STATIC line_p doread_line(p_out) return lnp; } -STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) - FILE *fp; - short *kind_out; - short *n_out; - bblock_p *g_out; - line_p *l_out; +STATIC bool getbblocks(fp, kind_out, n_out, g_out, l_out) + FILE* fp; +short* kind_out; +short* n_out; +bblock_p* g_out; +line_p* l_out; { - bblock_p head = (bblock_p) 0; - line_p headl = (line_p) 0; + bblock_p head = (bblock_p)0; + line_p headl = (line_p)0; - curproc = (proc_p) 0; + curproc = (proc_p)0; /* curproc will get a value when we encounter a PRO pseudo. * If there is no such pseudo, we're reading only data * declarations or messages (outside any proc.). */ curinp = fp; - lastbid = (block_id) 0; /* block identier */ - state = INIT; /* initial state */ + lastbid = (block_id)0; /* block identier */ + state = INIT; /* initial state */ bp = &head; - for (;;) { + for (;;) + { #ifdef TRACE - fprintf(stderr,"state = %d\n",state); + fprintf(stderr, "state = %d\n", state); #endif - switch(state) { + switch (state) + { case LABEL0: nextblock(); - /* Fall through !! */ + /* Fall through !! */ case LABEL: lbmap[INSTRLAB(lnp)] = b; /* The lbmap table contains for each @@ -172,21 +175,26 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) */ lnp = doread_line(&curproc); state = kind(lnp); - if (state != END) { + if (state != END) + { *lp = lnp; lp = &lnp->l_next; } break; case NORMAL: lnp = doread_line(&curproc); - if ( (state = kind(lnp)) == LABEL) { + if ((state = kind(lnp)) == LABEL) + { /* If we come accross a label * here, it must be the beginning * of a new basic block. */ state = LABEL0; - } else { - if (state != END) { + } + else + { + if (state != END) + { *lp = lnp; lp = &lnp->l_next; } @@ -194,9 +202,10 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) break; case JUMP: lnp = doread_line(&curproc); - /* fall through ... */ + /* fall through ... */ case AFTERPRO: - switch(state = kind(lnp)) { + switch (state = kind(lnp)) + { case LABEL: state = LABEL0; break; @@ -209,24 +218,31 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) case END: *lp = lnp; #ifdef TRACE - fprintf(stderr,"at end of proc, %d blocks\n",lastbid); + fprintf(stderr, "at end of proc, %d blocks\n", lastbid); #endif - if (head == (bblock_p) 0) { + if (head == (bblock_p)0) + { *kind_out = LDATA; *l_out = headl; - } else { + } + else + { *kind_out = LTEXT; *g_out = head; - *n_out = (short) lastbid; + *n_out = (short)lastbid; /* number of basic blocks */ } return TRUE; case INIT: lnp = doread_line(&curproc); - if (feof(curinp)) return FALSE; - if (INSTR(lnp) == ps_pro) { + if (feof(curinp)) + return FALSE; + if (INSTR(lnp) == ps_pro) + { state = AFTERPRO; - } else { + } + else + { state = NORMAL; headl = lnp; lp = &lnp->l_next; @@ -236,9 +252,8 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) } } - STATIC interproc_analysis(p) - proc_p p; + proc_p p; { /* Interprocedural analysis of a procedure p determines: * - all procedures called by p (the 'call graph') @@ -255,7 +270,7 @@ STATIC interproc_analysis(p) */ bblock_p b; - line_p lnp; + line_p lnp; bool inloop; /* Allocate memory for structs and sets */ @@ -265,85 +280,90 @@ STATIC interproc_analysis(p) p->p_change->c_ext = Cempty_set(olength); p->p_calling = Cempty_set(plength); - for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) { - inloop = (Lnrelems(b->b_loops) > 0); - for (lnp = b->b_start; lnp != (line_p) 0; lnp = lnp->l_next) { - /* for all instructions of p do */ - switch(INSTR(lnp)) { - case op_cal: - Cadd(PROC(lnp)->p_id, &p->p_calling); - /* add called proc to p_calling */ - if (inloop) { - CALLED_IN_LOOP(PROC(lnp)); - } - break; - case op_cai: - Cadd(p->p_id,&cai_set); - break; - case op_lpi: - Cadd(PROC(lnp)->p_id, &lpi_set); - /* All procedures that have their names used + for (b = p->p_start; b != (bblock_p)0; b = b->b_next) + { + inloop = (Lnrelems(b->b_loops) > 0); + for (lnp = b->b_start; lnp != (line_p)0; lnp = lnp->l_next) + { + /* for all instructions of p do */ + switch (INSTR(lnp)) + { + case op_cal: + Cadd(PROC(lnp)->p_id, &p->p_calling); + /* add called proc to p_calling */ + if (inloop) + { + CALLED_IN_LOOP(PROC(lnp)); + } + break; + case op_cai: + Cadd(p->p_id, &cai_set); + break; + case op_lpi: + Cadd(PROC(lnp)->p_id, &lpi_set); + /* All procedures that have their names used * in an lpi instruction, may be called via * a cai instruction. */ - PROC(lnp)->p_flags1 |= PF_LPI; - break; - case op_ste: - case op_sde: - case op_ine: - case op_dee: - case op_zre: - Cadd(OBJ(lnp)->o_id, &p->p_change->c_ext); - /* Add changed object to c_ext */ - break; - case op_lil: - case op_lof: - case op_loi: - case op_los: - case op_lar: - p->p_use->u_flags |= UF_INDIR; - /* p does a load-indirect */ - break; - case op_sil: - case op_stf: - case op_sti: - case op_sts: - case op_sar: - p->p_change->c_flags |= CF_INDIR; - /* p does a store-indirect */ - break; - case op_blm: - case op_bls: - p->p_use->u_flags |= UF_INDIR; - p->p_change->c_flags |= CF_INDIR; - /* p does both */ - break; - case op_mon: - printf("mon not yet implemented\n"); - break; - case op_lxl: - case op_lxa: - curproc->p_flags1 |= PF_ENVIRON; - break; - case op_lor: - case op_str: - if (SHORT(lnp) == 0) { - curproc->p_flags1 |= PF_ENVIRON; + PROC(lnp)->p_flags1 |= PF_LPI; + break; + case op_ste: + case op_sde: + case op_ine: + case op_dee: + case op_zre: + Cadd(OBJ(lnp)->o_id, &p->p_change->c_ext); + /* Add changed object to c_ext */ + break; + case op_lil: + case op_lof: + case op_loi: + case op_los: + case op_lar: + p->p_use->u_flags |= UF_INDIR; + /* p does a load-indirect */ + break; + case op_sil: + case op_stf: + case op_sti: + case op_sts: + case op_sar: + p->p_change->c_flags |= CF_INDIR; + /* p does a store-indirect */ + break; + case op_blm: + case op_bls: + p->p_use->u_flags |= UF_INDIR; + p->p_change->c_flags |= CF_INDIR; + /* p does both */ + break; + case op_mon: + printf("mon not yet implemented\n"); + break; + case op_lxl: + case op_lxa: + curproc->p_flags1 |= PF_ENVIRON; + break; + case op_lor: + case op_str: + if (SHORT(lnp) == 0) + { + curproc->p_flags1 |= PF_ENVIRON; + } + break; + case ps_mes: + if (aoff(ARG(lnp), 0) == ms_gto) + { + ENTERED_WITH_GTO(curproc); + } + break; } - break; - case ps_mes: - if (aoff(ARG(lnp),0) == ms_gto) { - ENTERED_WITH_GTO(curproc); - } - break; } - } } } - STATIC cf_cleanproc(p) - proc_p p; + proc_p p; { /* Remove the extended data structures of p */ @@ -351,26 +371,26 @@ STATIC cf_cleanproc(p) register Lindex pi; loop_p lp; - for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) { + for (b = p->p_start; b != (bblock_p)0; b = b->b_next) + { oldcfbx(b->b_extend); } - for (pi = Lfirst(p->p_loops); pi != (Lindex) 0; pi = Lnext(pi, - p->p_loops)) { - lp = (loop_p) Lelem(pi); + for (pi = Lfirst(p->p_loops); pi != (Lindex)0; pi = Lnext(pi, + p->p_loops)) + { + lp = (loop_p)Lelem(pi); oldcflpx(lp->lp_extend); } } +#define CH_CHANGE_INDIR(ch) ((ch->c_flags & CF_INDIR) != 0) +#define USE_INDIR(us) ((us->u_flags & UF_INDIR) != 0) +#define CALLS_UNKNOWN(p) (p->p_flags1 & (byte)PF_CALUNKNOWN) +#define ENVIRON(p) (p->p_flags1 & (byte)PF_ENVIRON) - -#define CH_CHANGE_INDIR(ch) ((ch->c_flags & CF_INDIR) != 0) -#define USE_INDIR(us) ((us->u_flags & UF_INDIR) != 0) -#define CALLS_UNKNOWN(p) (p->p_flags1 & (byte) PF_CALUNKNOWN) -#define ENVIRON(p) (p->p_flags1 & (byte) PF_ENVIRON) - - -STATIC bool add_info(q,p) - proc_p q,p; +STATIC bool add_info(q, p) + proc_p q, + p; { /* Determine the consequences for used/changed variables info * of the fact that p calls q. If e.g. q changes a variable X @@ -381,40 +401,48 @@ STATIC bool add_info(q,p) */ change_p chp, chq; - use_p usp, usq; - bool diff = FALSE; + use_p usp, usq; + bool diff = FALSE; chp = p->p_change; chq = q->p_change; usp = p->p_use; usq = q->p_use; - if (!BODY_KNOWN(q)) { + if (!BODY_KNOWN(q)) + { /* q is a procedure of which the body is not available * as EM text. */ - if (CALLS_UNKNOWN(p)) { + if (CALLS_UNKNOWN(p)) + { return FALSE; /* p already called an unknown procedure */ - } else { + } + else + { p->p_flags1 |= PF_CALUNKNOWN; return TRUE; } } - if (CALLS_UNKNOWN(q)) { + if (CALLS_UNKNOWN(q)) + { /* q calls a procedure of which the body is not available * as EM text. */ - if (!CALLS_UNKNOWN(p)) { + if (!CALLS_UNKNOWN(p)) + { p->p_flags1 |= PF_CALUNKNOWN; diff = TRUE; } } - if (IS_CALLED_IN_LOOP(p) && !IS_CALLED_IN_LOOP(q)) { + if (IS_CALLED_IN_LOOP(p) && !IS_CALLED_IN_LOOP(q)) + { CALLED_IN_LOOP(q); diff = TRUE; } - if (!Cis_subset(chq->c_ext, chp->c_ext)) { + if (!Cis_subset(chq->c_ext, chp->c_ext)) + { /* q changes global variables (objects) that * p did not (yet) change. Add all variables * changed by q to the c_ext set of p. @@ -422,21 +450,24 @@ STATIC bool add_info(q,p) Cjoin(chq->c_ext, &chp->c_ext); diff = TRUE; } - if (CH_CHANGE_INDIR(chq) && !CH_CHANGE_INDIR(chp)) { + if (CH_CHANGE_INDIR(chq) && !CH_CHANGE_INDIR(chp)) + { /* q does a change-indirect (sil etc.) * and p did not (yet). */ chp->c_flags |= CF_INDIR; diff = TRUE; } - if (USE_INDIR(usq) && !USE_INDIR(usp)) { + if (USE_INDIR(usq) && !USE_INDIR(usp)) + { /* q does a use-indirect (lil etc.) * and p dis not (yet). */ usp->u_flags |= UF_INDIR; diff = TRUE; } - if (ENVIRON(q) && !ENVIRON(p)) { + if (ENVIRON(q) && !ENVIRON(p)) + { /* q uses or changes local variables in its * environment while p does not (yet). */ @@ -446,94 +477,99 @@ STATIC bool add_info(q,p) return diff; } - - STATIC trans_clos(head) - proc_p head; + proc_p head; { /* Compute the transitive closure of the used/changed * variable information. */ - register proc_p p,q; + register proc_p p, q; Cindex i; bool changes = TRUE; - while(changes) { + while (changes) + { changes = FALSE; - for (p = head; p != (proc_p) 0; p = p->p_next) { - if (!BODY_KNOWN(p)) continue; - for (i = Cfirst(p->p_calling); i != (Cindex) 0; - i = Cnext(i,p->p_calling)) { - q = pmap[Celem(i)]; - if (add_info(q,p)) { - changes = TRUE; + for (p = head; p != (proc_p)0; p = p->p_next) + { + if (!BODY_KNOWN(p)) + continue; + for (i = Cfirst(p->p_calling); i != (Cindex)0; + i = Cnext(i, p->p_calling)) + { + q = pmap[Celem(i)]; + if (add_info(q, p)) + { + changes = TRUE; + } } - } } } } - - - indir_calls() { Cindex i; proc_p p; - for (i = Cfirst(cai_set); i != (Cindex) 0; i = Cnext(i,cai_set)) { - p = pmap[Celem(i)]; /* p does a CAI */ + for (i = Cfirst(cai_set); i != (Cindex)0; i = Cnext(i, cai_set)) + { + p = pmap[Celem(i)]; /* p does a CAI */ Cjoin(lpi_set, &p->p_calling); } Cdeleteset(lpi_set); Cdeleteset(cai_set); } - - -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { - FILE *f, *f2, *gf2; /* The EM input, EM output, basic block output */ + FILE* f, *f2, *gf2; /* The EM input, EM output, basic block output */ bblock_p g; short n, kind; line_p l; linecount = 0; fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fdblock = getdtable(dname); /* data block table */ lpi_set = Cempty_set(plength); cai_set = Cempty_set(plength); - if ((f = fopen(lname,"r")) == NULL) { + if ((f = fopen(lname, "r")) == NULL) + { error("cannot open %s", lname); } - if ((f2 = fopen(lname2,"w")) == NULL) { + if ((f2 = fopen(lname2, "w")) == NULL) + { error("cannot open %s", lname2); } - if ((gf2 = fopen(bname2,"w")) == NULL) { - error("cannot open %s",bname2); + if ((gf2 = fopen(bname2, "w")) == NULL) + { + error("cannot open %s", bname2); } - while (getbblocks(f,&kind,&n,&g,&l)) { + while (getbblocks(f, &kind, &n, &g, &l)) + { /* read EM text of one unit and * (if it is a procedure) * partition it into n basic blocks. */ - if (kind == LDATA) { - putunit(LDATA,(proc_p) 0,l,gf2,f2); - } else { + if (kind == LDATA) + { + putunit(LDATA, (proc_p)0, l, gf2, f2); + } + else + { curproc->p_start = g; /* The global variable curproc points to the * current procedure. It is set by getbblocks */ control_flow(g); /* compute pred and succ */ - dominators(g,n); /* compute immediate dominators */ + dominators(g, n); /* compute immediate dominators */ loop_detection(curproc); /* compute loops */ interproc_analysis(curproc); /* Interprocedural analysis */ cf_cleanproc(curproc); - putunit(LTEXT,curproc,(line_p) 0,gf2,f2); + putunit(LTEXT, curproc, (line_p)0, gf2, f2); /* output control flow graph + text */ } } @@ -545,13 +581,15 @@ main(argc,argv) /* Compute transitive closure of used/changed * variables information for every procedure. */ - if ((f = fopen(dname2,"w")) == NULL) { - error("cannot open %s",dname2); + if ((f = fopen(dname2, "w")) == NULL) + { + error("cannot open %s", dname2); } - putdtable(fdblock,f); - if ((f = fopen(pname2,"w")) == NULL) { - error("cannot open %s",pname2); + putdtable(fdblock, f); + if ((f = fopen(pname2, "w")) == NULL) + { + error("cannot open %s", pname2); } - putptable(fproc,f,TRUE); + putptable(fproc, f, TRUE); exit(0); } From 1b66b63eae3312c6bf8fb9512ecda44e9ca63096 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 19:38:02 +0200 Subject: [PATCH 211/231] Run through clang-format. --- util/ego/ca/ca.c | 146 +++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 68 deletions(-) diff --git a/util/ego/ca/ca.c b/util/ego/ca/ca.c index 9b22599e3..a59cce0ae 100644 --- a/util/ego/ca/ca.c +++ b/util/ego/ca/ca.c @@ -8,7 +8,6 @@ * */ - #include #include #include @@ -25,26 +24,22 @@ #include "../share/get.h" #include "ca_put.h" - /* This phase transforms the Intermediate Code of the global optimizer * to 'standard' compact assembly language, which will be processed * by the code generator. */ +short dlength; +dblock_p* dmap; -short dlength; -dblock_p *dmap; - -char **dnames, **pnames; /* Dynamically allocated arrays of strings. +char** dnames, **pnames; /* Dynamically allocated arrays of strings. * pnames[i] contains a pointer to the name * of the procedure with proc_id i. */ - - -STATIC line_p get_ca_lines(lf,p_out) - FILE *lf; - proc_p *p_out; +STATIC line_p get_ca_lines(lf, p_out) + FILE* lf; +proc_p* p_out; { /* Read lines of EM text and link them. * Register messages are outputted immediately after the PRO. @@ -57,35 +52,46 @@ STATIC line_p get_ca_lines(lf,p_out) curinp = lf; /* EM input file */ pp = &head; mp = &headm; - headm = (line_p) 0; - while (TRUE) { + headm = (line_p)0; + while (TRUE) + { l = read_line(p_out); - if (feof(curinp)) break; - assert (l != (line_p) 0); - if (INSTR(l) == ps_end && INSTR(head) != ps_pro) { + if (feof(curinp)) + break; + assert(l != (line_p)0); + if (INSTR(l) == ps_end && INSTR(head) != ps_pro) + { /* Delete end pseudo after data-unit */ oldline(l); break; } - if (INSTR(l) == ps_mes && l->l_a.la_arg->a_a.a_offset == ms_reg) { + if (INSTR(l) == ps_mes && l->l_a.la_arg->a_a.a_offset == ms_reg) + { /* l is a register message */ - if (l->l_a.la_arg->a_next == (arg_p) 0) { + if (l->l_a.la_arg->a_next == (arg_p)0) + { /* register message without arguments */ oldline(l); - } else { + } + else + { *mp = l; mp = &l->l_next; } - } else { + } + else + { *pp = l; pp = &l->l_next; } - if (INSTR(l) == ps_end) { + if (INSTR(l) == ps_end) + { break; } } - *pp = (line_p) 0; - if (head != (line_p) 0 && INSTR(head) == ps_pro) { + *pp = (line_p)0; + if (head != (line_p)0 && INSTR(head) == ps_pro) + { /* append register message without arguments to list */ l = newline(OPLIST); l->l_instr = ps_mes; @@ -94,14 +100,16 @@ STATIC line_p get_ca_lines(lf,p_out) *mp = l; l->l_next = head->l_next; head->l_next = headm; - } else { - assert(headm == (line_p) 0); + } + else + { + assert(headm == (line_p)0); } return head; } STATIC int makedmap(dbl) - dblock_p dbl; + dblock_p dbl; { /* construct the dmap table */ @@ -111,76 +119,75 @@ STATIC int makedmap(dbl) /* determine the length of the table */ cnt = 0; - for (d = dbl; d != (dblock_p) 0; d = d->d_next) cnt++; - dmap = (dblock_p *) newmap(cnt); - for (d = dbl; d != (dblock_p) 0; d = d->d_next) { + for (d = dbl; d != (dblock_p)0; d = d->d_next) + cnt++; + dmap = (dblock_p*)newmap(cnt); + for (d = dbl; d != (dblock_p)0; d = d->d_next) + { assert(d->d_id <= cnt); dmap[d->d_id] = d; } return cnt; } - - STATIC getdnames(dumpd) - FILE *dumpd; + FILE* dumpd; { /* Read the names of the datalabels from * the dump file. */ - char str[IDL+1]; + char str[IDL + 1]; int id; - dnames = (char **) newmap(dlength); - for (;;) { - if (fscanf(dumpd,"%d %s",&id,str) == EOF) return; + dnames = (char**)newmap(dlength); + for (;;) + { + if (fscanf(dumpd, "%d %s", &id, str) == EOF) + return; assert(id <= dlength); - dnames[id] = (char *) newcore(strlen(str)+1); + dnames[id] = (char*)newcore(strlen(str) + 1); strcpy(dnames[id], str); } } STATIC getpnames(dumpp) - FILE *dumpp; + FILE* dumpp; { /* Read the names of the procedures from * the dump file. */ - char str[IDL+1]; + char str[IDL + 1]; int id; - pnames = (char **) newmap(plength); - for (;;) { - if (fscanf(dumpp,"%d %s",&id,str) == EOF) return; + pnames = (char**)newmap(plength); + for (;;) + { + if (fscanf(dumpp, "%d %s", &id, str) == EOF) + return; assert(id <= plength); - pnames[id] = (char *) newcore(strlen(str)+1); + pnames[id] = (char*)newcore(strlen(str) + 1); strcpy(pnames[id], str); } } - - -STATIC new_name(s) - char **s; +STATIC new_name(s) char** s; { static int nn = 0; char buf[20]; int len = strlen(*s); - oldcore(*s, len+1); + oldcore(*s, len + 1); buf[0] = '_'; buf[1] = 'I'; buf[2] = 'I'; - sprintf(&buf[3],"%d",nn); + sprintf(&buf[3], "%d", nn); nn++; - *s = (char *) newcore(strlen(buf)+1); + *s = (char*)newcore(strlen(buf) + 1); strcpy(*s, buf); } - - STATIC uniq_names() { /* The names of all internal procedures and data blocks @@ -193,46 +200,49 @@ STATIC uniq_names() proc_p p; dblock_p d; - for (p = fproc; p != (proc_p) 0; p = p->p_next) { - if (!(p->p_flags1 & PF_EXTERNAL)) { + for (p = fproc; p != (proc_p)0; p = p->p_next) + { + if (!(p->p_flags1 & PF_EXTERNAL)) + { new_name(&(pnames[p->p_id])); } } - for (d = fdblock; d != (dblock_p) 0; d = d->d_next) { - if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id]) { + for (d = fdblock; d != (dblock_p)0; d = d->d_next) + { + if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id]) + { new_name(&(dnames[d->d_id])); } } } - -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { /* CA does not output proctable etc. files. Instead, its * pname2 and dname2 arguments contain the names of the * dump files created by IC. */ - FILE *f, *f2; /* The EM input and output. */ - FILE *df, *pf; /* The dump files */ + FILE* f, *f2; /* The EM input and output. */ + FILE* df, *pf; /* The dump files */ line_p lnp; fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fdblock = getdtable(dname); /* data block table */ dlength = makedmap(fdblock); /* allocate dmap table */ - df = openfile(dname2,"r"); + df = openfile(dname2, "r"); getdnames(df); fclose(df); - pf = openfile(pname2,"r"); + pf = openfile(pname2, "r"); getpnames(pf); fclose(pf); uniq_names(); - f = openfile(lname,"r"); + f = openfile(lname, "r"); f2 = stdout; cputmagic(f2); /* write magic number */ - while ((lnp = get_ca_lines(f,&curproc)) != (line_p) 0) { - cputlines(lnp,f2); + while ((lnp = get_ca_lines(f, &curproc)) != (line_p)0) + { + cputlines(lnp, f2); } fclose(f); fclose(f2); From 918f30051320a2708e0bb13ed224b3956424b703 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 19:38:54 +0200 Subject: [PATCH 212/231] Run through clang-format. --- util/ego/il/il.c | 274 +++++++++++++++++++++++++---------------------- 1 file changed, 146 insertions(+), 128 deletions(-) diff --git a/util/ego/il/il.c b/util/ego/il/il.c index 6ec2a8af2..d16ffce3f 100644 --- a/util/ego/il/il.c +++ b/util/ego/il/il.c @@ -29,7 +29,7 @@ int calnr; int complete_program; -calcnt_p cchead; /* call-count info of current proc */ +calcnt_p cchead; /* call-count info of current proc */ STATIC long space = 0; STATIC long total_size = 0; @@ -42,8 +42,8 @@ STATIC int kp_temps = 0; int Ssubst; #ifdef VERBOSE -int Senv,Srecursive,Slocals,Sinstrlab,Sparsefails,Spremoved,Scals; -int Sbig_caller,Sdispensable,Schangedcallee,Sbigcallee,Sspace,Szeroratio; +int Senv, Srecursive, Slocals, Sinstrlab, Sparsefails, Spremoved, Scals; +int Sbig_caller, Sdispensable, Schangedcallee, Sbigcallee, Sspace, Szeroratio; #endif /* P A S S 1 @@ -56,10 +56,9 @@ int Sbig_caller,Sdispensable,Schangedcallee,Sbigcallee,Sspace,Szeroratio; * The call descriptors are put in a file (calfile). */ -pass1(lnam,bnam,cnam) - char *lnam, *bnam, *cnam; +pass1(lnam, bnam, cnam) char* lnam, *bnam, *cnam; { - FILE *f, *gf, *cf, *ccf; /* The EM input, the basic block graph, + FILE* f, *gf, *cf, *ccf; /* The EM input, the basic block graph, * the call-list file and the calcnt file. */ long laddr; @@ -67,26 +66,29 @@ pass1(lnam,bnam,cnam) short kind; line_p l; - f = openfile(lnam,"r"); - gf = openfile(bnam,"r"); - cf = openfile(cnam,"w"); - ccf = openfile(ccname,"w"); + f = openfile(lnam, "r"); + gf = openfile(bnam, "r"); + cf = openfile(cnam, "w"); + ccf = openfile(ccname, "w"); mesregs = Lempty_set(); apriori(fproc); /* use information from the procedure table to * see which calls certainly cannot be expanded. */ - while(TRUE) { + while (TRUE) + { laddr = ftell(f); - if (!getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) break; + if (!getunit(gf, f, &kind, &g, &l, &curproc, TRUE)) + break; /* Read the control flow graph and EM text of * one procedure and analyze it. */ - if (kind == LDATA) { - remunit(LDATA,(proc_p) 0,l); + if (kind == LDATA) + { + remunit(LDATA, (proc_p)0, l); continue; } - OUTTRACE("flow graph of proc %d read",curproc->p_id); + OUTTRACE("flow graph of proc %d read", curproc->p_id); assert(INSTR(g->b_start) == ps_pro); curproc->p_start = g; curproc->P_LADDR = laddr; @@ -94,74 +96,78 @@ pass1(lnam,bnam,cnam) /* address of graph in basic block file */ curproc->P_SIZE = proclength(curproc); /* #instructions */ total_size += curproc->P_SIZE; - if (BIG_PROC(curproc)) { + if (BIG_PROC(curproc)) + { /* curproc is too large to be expanded in line */ UNSUITABLE(curproc); } calnr = 0; - anal_proc(curproc,cf,ccf); - OUTTRACE("proc %d processed",curproc->p_id); - remunit(LTEXT,curproc,(line_p) 0); + anal_proc(curproc, cf, ccf); + OUTTRACE("proc %d processed", curproc->p_id); + remunit(LTEXT, curproc, (line_p)0); /* remove control flow graph + text */ - OUTTRACE("graph of proc %d removed",curproc->p_id); + OUTTRACE("graph of proc %d removed", curproc->p_id); Ldeleteset(mesregs); mesregs = Lempty_set(); } fclose(f); fclose(gf); fclose(cf); - fclose(ccf); + fclose(ccf); } - - /* P A S S 2 * * Pass 2 reads the calfile and determines which calls should * be expanded in line. It does not use the EM text. */ - - STATIC char cname2[128] = TMP_DIR; -pass2(cnam,space) - char *cnam; - long space; +pass2(cnam, space) char* cnam; +long space; { - FILE *cf, *cf2, *ccf; - call_p c,a; + FILE* cf, *cf2, *ccf; + call_p c, a; - cf = openfile(cnam,"r"); - cf2 = openfile(cname2,"w"); - ccf = openfile(ccname,"r"); - while ((c = getcall(cf)) != (call_p) 0) { + cf = openfile(cnam, "r"); + cf2 = openfile(cname2, "w"); + ccf = openfile(ccname, "r"); + while ((c = getcall(cf)) != (call_p)0) + { /* process all calls */ - if (SUITABLE(c->cl_proc) && anal_params(c)) { + if (SUITABLE(c->cl_proc) && anal_params(c)) + { /* called proc. may be put in line */ /* see which parameters may be put in line */ assign_ratio(c); /* assign a rank */ a = abstract(c); /* abstract essential info */ - append_abstract(a,a->cl_caller); + append_abstract(a, a->cl_caller); /* put it in call-list of calling proc. */ - putcall(c,cf2,(short) 0); - } else { + putcall(c, cf2, (short)0); + } + else + { rem_call(c); } } - select_calls(fproc,ccf,space); - fclose(cf); if (! kp_temps) unlink(cnam); + select_calls(fproc, ccf, space); + fclose(cf); + if (!kp_temps) + unlink(cnam); fclose(cf2); - fclose(ccf); if (! kp_temps) unlink(ccname); - cf2 = openfile(cname2,"r"); - add_actuals(fproc,cf2); + fclose(ccf); + if (!kp_temps) + unlink(ccname); + cf2 = openfile(cname2, "r"); + add_actuals(fproc, cf2); cleancals(fproc); /* remove calls that were not selected */ /* add actual parameters to each selected call */ - fclose(cf2); if (! kp_temps) unlink(cname2); + fclose(cf2); + if (!kp_temps) + unlink(cname2); } - - /* P A S S 3 * * pass 3 reads the substitution file and performs all @@ -170,67 +176,76 @@ pass2(cnam,space) * EM textfile. */ - -pass3(lnam,lnam2) - char *lnam,*lnam2; +pass3(lnam, lnam2) char* lnam, *lnam2; { bool verbose = TRUE; - FILE *lfile, *lfilerand, *lfile2, *sfile; - call_p c,next; - line_p l,startscan,cal; + FILE* lfile, *lfilerand, *lfile2, *sfile; + call_p c, next; + line_p l, startscan, cal; short lastcid; /* last call-id seen */ lfile = openfile(lnam, "r"); lfilerand = openfile(lnam, "r"); - lfile2 = openfile(lnam2,"w"); - if (verbose) { - sfile = openfile(sname,"w"); + lfile2 = openfile(lnam2, "w"); + if (verbose) + { + sfile = openfile(sname, "w"); } mesregs = Lempty_set(); - while ((l = get_text(lfile,&curproc)) != (line_p) 0) { - if (curproc == (proc_p) 0) { + while ((l = get_text(lfile, &curproc)) != (line_p)0) + { + if (curproc == (proc_p)0) + { /* Just a data-unit; no real instructions */ - putlines(l->l_next,lfile2); + putlines(l->l_next, lfile2); oldline(l); continue; } - if (IS_DISPENSABLE(curproc)) { - liquidate(curproc,l->l_next); - } else { + if (IS_DISPENSABLE(curproc)) + { + liquidate(curproc, l->l_next); + } + else + { startscan = l->l_next; lastcid = 0; - for (c = curproc->P_CALS; c != (call_p) 0; c = next) { + for (c = curproc->P_CALS; c != (call_p)0; c = next) + { next = c->cl_cdr; - cal = scan_to_cal(startscan,c->cl_id - lastcid); - assert (cal != (line_p) 0); - startscan = scan_to_cal(cal->l_next,1); + cal = scan_to_cal(startscan, c->cl_id - lastcid); + assert(cal != (line_p)0); + startscan = scan_to_cal(cal->l_next, 1); /* next CAL */ lastcid = c->cl_id; /* next CAL after current one */ - substitute(lfilerand,c,cal,l->l_next); - if (verbose) { - putcall(c,sfile,0); - } else { + substitute(lfilerand, c, cal, l->l_next); + if (verbose) + { + putcall(c, sfile, 0); + } + else + { rem_call(c); } } } - putlines(l->l_next,lfile2); + putlines(l->l_next, lfile2); Ldeleteset(mesregs); mesregs = Lempty_set(); oldline(l); } fclose(lfile); fclose(lfile2); - if (verbose) { + if (verbose) + { fclose(sfile); - if (! kp_temps) unlink(sname); + if (!kp_temps) + unlink(sname); } } - STATIC il_extptab(ptab) - proc_p ptab; + proc_p ptab; { /* Allocate space for extension of proctable entries. * Also, initialise some of the fields just allocated. @@ -238,7 +253,8 @@ STATIC il_extptab(ptab) register proc_p p; - for (p = ptab; p != (proc_p) 0; p = p->p_next) { + for (p = ptab; p != (proc_p)0; p = p->p_next) + { p->p_extend = newilpx(); p->P_ORGLABELS = p->p_nrlabels; p->P_ORGLOCALS = p->p_localbytes; @@ -246,13 +262,14 @@ STATIC il_extptab(ptab) } STATIC il_cleanptab(ptab) - proc_p ptab; + proc_p ptab; { /* De-allocate space for extensions */ register proc_p p; - for (p = ptab; p != (proc_p) 0; p = p->p_next) { + for (p = ptab; p != (proc_p)0; p = p->p_next) + { oldilpx(p->p_extend); } } @@ -262,55 +279,55 @@ Sdiagnostics() { /* print statictical information */ - fprintf(stderr,"STATISTICS:\n"); - fprintf(stderr,"Info about procedures:\n"); - fprintf(stderr,"environment accessed: %d\n",Senv); - fprintf(stderr,"recursive: %d\n",Srecursive); - fprintf(stderr,"too many locals: %d\n",Slocals); - fprintf(stderr,"instr. lab in data block: %d\n",Sinstrlab); - fprintf(stderr,"procedures removed: %d\n",Spremoved); - fprintf(stderr,"\nInfo about calls:\n"); - fprintf(stderr,"total number of calls: %d\n",Scals); - fprintf(stderr,"total number of calls substituted: %d\n",Ssubst); - fprintf(stderr,"parser failed: %d\n",Sparsefails); - fprintf(stderr,"caller too big: %d\n",Sbig_caller); - fprintf(stderr,"caller dispensable: %d\n",Sdispensable); - fprintf(stderr,"callee is changed: %d\n",Schangedcallee); - fprintf(stderr,"callee too big: %d\n",Sbigcallee); - fprintf(stderr,"no space available: %d\n",Sspace); - fprintf(stderr,"zero ratio: %d\n",Szeroratio); + fprintf(stderr, "STATISTICS:\n"); + fprintf(stderr, "Info about procedures:\n"); + fprintf(stderr, "environment accessed: %d\n", Senv); + fprintf(stderr, "recursive: %d\n", Srecursive); + fprintf(stderr, "too many locals: %d\n", Slocals); + fprintf(stderr, "instr. lab in data block: %d\n", Sinstrlab); + fprintf(stderr, "procedures removed: %d\n", Spremoved); + fprintf(stderr, "\nInfo about calls:\n"); + fprintf(stderr, "total number of calls: %d\n", Scals); + fprintf(stderr, "total number of calls substituted: %d\n", Ssubst); + fprintf(stderr, "parser failed: %d\n", Sparsefails); + fprintf(stderr, "caller too big: %d\n", Sbig_caller); + fprintf(stderr, "caller dispensable: %d\n", Sdispensable); + fprintf(stderr, "callee is changed: %d\n", Schangedcallee); + fprintf(stderr, "callee too big: %d\n", Sbigcallee); + fprintf(stderr, "no space available: %d\n", Sspace); + fprintf(stderr, "zero ratio: %d\n", Szeroratio); } #endif -il_flags(p) - char *p; +il_flags(p) char* p; { - switch(*p++) { - case 's': - while (*p != '\0') { - space = 10*space +*p++ -'0'; - } - break; - case 'a': - complete_program = 1; - break; - case 't': - strcpy(cname, "."); - strcpy(ccname, "."); - strcpy(sname, "."); - strcpy(cname2, "."); - kp_temps = 1; - break; + switch (*p++) + { + case 's': + while (*p != '\0') + { + space = 10 * space + *p++ - '0'; + } + break; + case 'a': + complete_program = 1; + break; + case 't': + strcpy(cname, "."); + strcpy(ccname, "."); + strcpy(sname, "."); + strcpy(cname2, "."); + kp_temps = 1; + break; } } -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { - FILE *f; - - go(argc,argv,no_action,no_action,no_action,il_flags); + FILE* f; + + go(argc, argv, no_action, no_action, no_action, il_flags); il_extptab(fproc); /* add extended data structures */ strcat(cname, "/ego.i1.XXXXXX"); strcat(ccname, "/ego.i2.XXXXXX"); @@ -320,18 +337,19 @@ main(argc,argv) mktemp(ccname); mktemp(sname); mktemp(cname2); - pass1(lname,bname,cname); /* grep calls, analyse procedures */ - space = total_size * space / 100 ; - pass2(cname,space); /* select calls to be expanded */ - pass3(lname,lname2); /* do substitutions */ - f = openfile(dname2,"w"); + pass1(lname, bname, cname); /* grep calls, analyse procedures */ + space = total_size * space / 100; + pass2(cname, space); /* select calls to be expanded */ + pass3(lname, lname2); /* do substitutions */ + f = openfile(dname2, "w"); il_cleanptab(fproc); /* remove extended data structures */ - putdtable(fdblock,f); - f = openfile(pname2,"w"); - putptable(fproc,f,FALSE); - report("inline substitutions",Ssubst); + putdtable(fdblock, f); + f = openfile(pname2, "w"); + putptable(fproc, f, FALSE); + report("inline substitutions", Ssubst); #ifdef VERBOSE - if (verbose_flag) { + if (verbose_flag) + { Sdiagnostics(); } #endif From 671bf250f5f08fbb9e8a9fd2d7fb5c7a63dd00c3 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 19:46:19 +0200 Subject: [PATCH 213/231] Run through clang-format. --- util/ego/share/go.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/util/ego/share/go.h b/util/ego/share/go.h index 86c56f246..9e07bdb89 100644 --- a/util/ego/share/go.h +++ b/util/ego/share/go.h @@ -9,8 +9,7 @@ * */ - -extern go(); /* ( int argc; char *argv[]; +extern go(); /* ( int argc; char *argv[]; * int (*initialize)(); int (*optimize)(); * int (*phase_machinit)(); int (*proc_flag)() ) * This is the main driving routine of the optimizer. @@ -26,14 +25,14 @@ extern go(); /* ( int argc; char *argv[]; * and 'optimize' is called with the current procedure * as parameter. */ -extern no_action(); /* () +extern no_action(); /* () * Parameter to be supplied for e.g. 'initialize' if * no action is required. */ -extern core_usage(); /* () +extern core_usage(); /* () * Report core usage, if core_flag is set. */ -extern report(); /* ( char *s; int n) +extern report(); /* ( char *s; int n) * Report number of optimizations found, if * report_flag is set */ From 44b64215196b2221a98eb56c14bfe11218d28b9f Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 19:53:14 +0200 Subject: [PATCH 214/231] Run through clang-format. --- util/ego/ic/ic.c | 362 ++++++++++++++++++++++++----------------------- 1 file changed, 184 insertions(+), 178 deletions(-) diff --git a/util/ego/ic/ic.c b/util/ego/ic/ic.c index 00eb717fd..42faf5ebe 100644 --- a/util/ego/ic/ic.c +++ b/util/ego/ic/ic.c @@ -29,41 +29,36 @@ #include "../share/put.h" #include "../share/aux.h" - /* Global variables */ +dblock_p db; +dblock_p hol0_db; /* dblock for ABS block */ +char* curhol; /* name of hol block in current scope */ +dblock_p ldblock; /* last dblock */ +proc_p lproc; /* last proc */ +short tabval; /* used by table1, table2 and table3 */ +offset tabval2; +char string[IDL + 1]; +line_p firstline; /* first line of current procedure */ +line_p lastline; /* last line read */ +int labelcount; /* # labels in current procedure */ +short fragm_type = DUNKNOWN; /* fragm. type: DCON, DROM or DUNKNOWN */ +short fragm_nr = 0; /* fragment number */ +obj_id lastoid = 0; +proc_id lastpid = 0; +dblock_id lastdid = 0; +lab_id lastlid = 0; -dblock_p db; -dblock_p hol0_db; /* dblock for ABS block */ -char *curhol; /* name of hol block in current scope */ -dblock_p ldblock; /* last dblock */ -proc_p lproc; /* last proc */ -short tabval; /* used by table1, table2 and table3 */ -offset tabval2; -char string[IDL+1]; -line_p firstline; /* first line of current procedure */ -line_p lastline; /* last line read */ -int labelcount; /* # labels in current procedure */ -short fragm_type = DUNKNOWN; /* fragm. type: DCON, DROM or DUNKNOWN */ -short fragm_nr = 0; /* fragment number */ -obj_id lastoid = 0; -proc_id lastpid = 0; -dblock_id lastdid = 0; -lab_id lastlid = 0; +offset mespar = UNKNOWN_SIZE; +/* argumument of ps_par message of current procedure */ -offset mespar = UNKNOWN_SIZE; - /* argumument of ps_par message of current procedure */ +extern process_lines(); +extern int readline(); +extern line_p readoperand(); +extern line_p inpseudo(); - -extern process_lines(); -extern int readline(); -extern line_p readoperand(); -extern line_p inpseudo(); - - -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { /* The input files must be legal EM Compact * Assembly Language files, as produced by the EM Peephole @@ -77,25 +72,26 @@ main(argc,argv) * - ddump: the names of all data blocks */ - FILE *lfile, *dfile, *pfile, *pdump, *ddump; + FILE* lfile, *dfile, *pfile, *pdump, *ddump; - lfile = openfile(lname2,"w"); - pdump = openfile(argv[1],"w"); - ddump = openfile(argv[2],"w"); - hol0_db = block_of_lab((char *) 0); - while (next_file(argc,argv) != NULL) { + lfile = openfile(lname2, "w"); + pdump = openfile(argv[1], "w"); + ddump = openfile(argv[2], "w"); + hol0_db = block_of_lab((char*)0); + while (next_file(argc, argv) != NULL) + { /* Read all EM input files, process the code * and concatenate all output. */ - curhol = (char *) 0; + curhol = (char*)0; process_lines(lfile); - dump_procnames(prochash,NPROCHASH,pdump); - dump_dblocknames(symhash,NSYMHASH,ddump); + dump_procnames(prochash, NPROCHASH, pdump); + dump_dblocknames(symhash, NSYMHASH, ddump); /* Save the names of all procedures that were * first come accross in this file. */ - cleanprocs(prochash,NPROCHASH,PF_EXTERNAL); - cleandblocks(symhash,NSYMHASH,DF_EXTERNAL); + cleanprocs(prochash, NPROCHASH, PF_EXTERNAL); + cleandblocks(symhash, NSYMHASH, DF_EXTERNAL); /* Make all procedure names that were internal * in this input file invisible. */ @@ -104,29 +100,25 @@ main(argc,argv) fclose(pdump); fclose(ddump); - /* remove the remainder of the hashing tables */ - cleanprocs(prochash,NPROCHASH,0); - cleandblocks(symhash,NSYMHASH,0); + cleanprocs(prochash, NPROCHASH, 0); + cleandblocks(symhash, NSYMHASH, 0); /* Now write the datablock table and the proctable */ - dfile = openfile(dname2,"w"); + dfile = openfile(dname2, "w"); putdtable(fdblock, dfile); - pfile = openfile(pname2,"w"); - putptable(fproc, pfile,FALSE); + pfile = openfile(pname2, "w"); + putptable(fproc, pfile, FALSE); exit(0); } - - /* Value returned by readline */ -#define NORMAL 0 -#define WITH_OPERAND 1 -#define EOFILE 2 -#define PRO_INSTR 3 -#define END_INSTR 4 -#define DELETED_INSTR 5 - +#define NORMAL 0 +#define WITH_OPERAND 1 +#define EOFILE 2 +#define PRO_INSTR 3 +#define END_INSTR 4 +#define DELETED_INSTR 5 STATIC add_end() { @@ -137,13 +129,12 @@ STATIC add_end() lastline->l_instr = ps_end; } - process_lines(fout) - FILE *fout; + FILE* fout; { line_p lnp; - short instr; - bool eof; + short instr; + bool eof; /* Read and process the code contained in the current file, * on a per procedure basis. @@ -162,20 +153,23 @@ process_lines(fout) */ eof = FALSE; - firstline = (line_p) 0; - lastline = (line_p) 0; - while (!eof) { - linecount++; /* for error messages */ - switch(readline(&instr, &lnp)) { + firstline = (line_p)0; + lastline = (line_p)0; + while (!eof) + { + linecount++; /* for error messages */ + switch (readline(&instr, &lnp)) + { /* read one line, see what kind it is */ case WITH_OPERAND: /* instruction with operand, e.g. LOL 10 */ lnp = readoperand(instr); lnp->l_instr = instr; - /* Fall through! */ + /* Fall through! */ case NORMAL: VL(lnp); - if (lastline != (line_p) 0) { + if (lastline != (line_p)0) + { lastline->l_next = lnp; } lastline = lnp; @@ -183,21 +177,23 @@ process_lines(fout) case EOFILE: eof = TRUE; fragm_type = DUNKNOWN; - if (firstline != (line_p) 0) { + if (firstline != (line_p)0) + { add_end(); - putlines(firstline,fout); - firstline = (line_p) 0; + putlines(firstline, fout); + firstline = (line_p)0; } break; case PRO_INSTR: VL(lnp); labelcount = 0; - if (firstline != lnp) { + if (firstline != lnp) + { /* If PRO is not the first * instruction: */ add_end(); - putlines(firstline,fout); + putlines(firstline, fout); firstline = lnp; } lastline = lnp; @@ -205,12 +201,12 @@ process_lines(fout) case END_INSTR: curproc->p_nrformals = mespar; mespar = UNKNOWN_SIZE; - assert(lastline != (line_p) 0); + assert(lastline != (line_p)0); lastline->l_next = lnp; - putlines(firstline,fout); + putlines(firstline, fout); /* write and delete code */ - firstline = (line_p) 0; - lastline = (line_p) 0; + firstline = (line_p)0; + lastline = (line_p)0; cleaninstrlabs(); /* scope of instruction labels ends here, * so forget about them. @@ -226,11 +222,8 @@ process_lines(fout) } } - - -int readline(instr_out, lnp_out) - short *instr_out; - line_p *lnp_out; +int readline(instr_out, lnp_out) short* instr_out; +line_p* lnp_out; { register line_p lnp; short n; @@ -241,9 +234,10 @@ int readline(instr_out, lnp_out) * return the instruction code via instr_out. */ - VA((short *) instr_out); - VA((short *) lnp_out); - switch(table1()) { + VA((short*)instr_out); + VA((short*)lnp_out); + switch (table1()) + { /* table1 sets string, tabval or tabval2 and * returns an indication of what was read. */ @@ -259,10 +253,11 @@ int readline(instr_out, lnp_out) db = block_of_lab(string); /* global variable, used by inpseudo */ lnp = newline(OPSHORT); - SHORT(lnp) = (short) db->d_id; + SHORT(lnp) = (short)db->d_id; lnp->l_instr = ps_sym; *lnp_out = lnp; - if (firstline == (line_p) 0) { + if (firstline == (line_p)0) + { firstline = lnp; /* only a pseudo (e.g. PRO) or data label * can be the first instruction. @@ -280,43 +275,47 @@ int readline(instr_out, lnp_out) case PSEU: n = tabval; lnp = inpseudo(n); /* read a pseudo */ - if (n == ps_hol) n = ps_bss; - if (lnp == (line_p) 0) return DELETED_INSTR; + if (n == ps_hol) + n = ps_bss; + if (lnp == (line_p)0) + return DELETED_INSTR; *lnp_out = lnp; lnp->l_instr = n; - if (firstline == (line_p) 0) { + if (firstline == (line_p)0) + { firstline = lnp; /* only a pseudo (e.g. PRO) or data label * can be the first instruction. */ } - if (n == ps_end) return END_INSTR; - if (n == ps_pro) return PRO_INSTR; + if (n == ps_end) + return END_INSTR; + if (n == ps_pro) + return PRO_INSTR; return NORMAL; } /* NOTREACHED */ } - -line_p readoperand(instr) - short instr; +line_p readoperand(instr) short instr; { /* Read the operand of the given instruction. * Create a line struct and return a pointer to it. */ - register line_p lnp; short flag; VI(instr); - flag = em_flag[ instr - sp_fmnem] & EM_PAR; - if (flag == PAR_NO) { + flag = em_flag[instr - sp_fmnem] & EM_PAR; + if (flag == PAR_NO) + { return (newline(OPNO)); } - switch(table2()) { + switch (table2()) + { case sp_cend: - return(newline(OPNO)); + return (newline(OPNO)); case CSTX1: /* constant */ /* If the instruction has the address @@ -327,31 +326,31 @@ line_p readoperand(instr) * Similarly, the instruction may have * an instruction label as argument. */ - switch(flag) { - case PAR_G: - lnp = newline(OPOBJECT); - OBJ(lnp) = - object(curhol,(offset) tabval, - opr_size(instr)); - break; - case PAR_B: - lnp = newline(OPINSTRLAB); - INSTRLAB(lnp) = instr_lab(tabval); - break; - default: - lnp = newline(OPSHORT); - SHORT(lnp) = tabval; - break; + switch (flag) + { + case PAR_G: + lnp = newline(OPOBJECT); + OBJ(lnp) = object(curhol, (offset)tabval, + opr_size(instr)); + break; + case PAR_B: + lnp = newline(OPINSTRLAB); + INSTRLAB(lnp) = instr_lab(tabval); + break; + default: + lnp = newline(OPSHORT); + SHORT(lnp) = tabval; + break; } break; #ifdef LONGOFF case CSTX2: /* double constant */ - if (flag == PAR_G) { + if (flag == PAR_G) + { lnp = newline(OPOBJECT); - OBJ(lnp) = - object(curhol, tabval2, - opr_size(instr)); + OBJ(lnp) = object(curhol, tabval2, + opr_size(instr)); break; } lnp = newline(OPOFFSET); @@ -366,24 +365,24 @@ line_p readoperand(instr) case DLBX: /* applied occurrence data label */ lnp = newline(OPOBJECT); - OBJ(lnp) = object(string, (offset) 0, - opr_size(instr) ); + OBJ(lnp) = object(string, (offset)0, + opr_size(instr)); break; case VALX1: lnp = newline(OPOBJECT); - OBJ(lnp) = object(string, (offset) tabval, - opr_size(instr) ); + OBJ(lnp) = object(string, (offset)tabval, + opr_size(instr)); break; #ifdef LONGOFF case VALX2: lnp = newline(OPOBJECT); - OBJ(lnp) = object(string,tabval2, - opr_size(instr) ); + OBJ(lnp) = object(string, tabval2, + opr_size(instr)); break; #endif case sp_pnam: lnp = newline(OPPROC); - PROC(lnp) = proclookup(string,OCCURRING); + PROC(lnp) = proclookup(string, OCCURRING); VP(PROC(lnp)); break; default: @@ -392,36 +391,35 @@ line_p readoperand(instr) return lnp; } - -static char *hol_label() +static char* hol_label() { static int holno; line_p lnp; - extern char *lastname; + extern char* lastname; /* Create a label for a hol pseudo, so that it can be converted * into a bss. The label is appended to the list of instructions. */ sprintf(string, "_HH%d", ++holno); - symlookup(string, OCCURRING); /* to make it exa */ + symlookup(string, OCCURRING); /* to make it exa */ db = block_of_lab(string); lnp = newline(OPSHORT); - SHORT(lnp) = (short) db->d_id; + SHORT(lnp) = (short)db->d_id; lnp->l_instr = ps_sym; - if (firstline == (line_p) 0) { + if (firstline == (line_p)0) + { firstline = lnp; } - if (lastline != (line_p) 0) { + if (lastline != (line_p)0) + { lastline->l_next = lnp; } lastline = lnp; return lastname; } - -line_p inpseudo(n) - short n; +line_p inpseudo(n) short n; { int m; line_p lnp; @@ -436,45 +434,50 @@ line_p inpseudo(n) * be recorded in the datablock or procedure table. */ - - switch(n) { + switch (n) + { case ps_hol: /* hol pseudos are carefully converted into bss * pseudos, so that the IL phase will not be * bothered by this. Also, references to the ABS * block will still work when passed through EGO. */ - - if (lastline != (line_p) 0 && is_datalabel(lastline)) { - extern char *lastname; + + if (lastline != (line_p)0 && is_datalabel(lastline)) + { + extern char* lastname; curhol = lastname; } - else { + else + { curhol = hol_label(); } n = ps_bss; - /* fall through */ + /* fall through */ case ps_bss: case ps_rom: case ps_con: - if (lastline == (line_p) 0 || !is_datalabel(lastline)) { - assert(lastline != (line_p) 0); + if (lastline == (line_p)0 || !is_datalabel(lastline)) + { + assert(lastline != (line_p)0); nlast = INSTR(lastline); - if (n == nlast && - (n == ps_rom || n == ps_con)) { + if (n == nlast && (n == ps_rom || n == ps_con)) + { /* Two successive roms/cons are * combined into one data block * if the second is not preceded by * a data label. */ lnp = arglist(0); - pseu = (byte) (n == ps_rom?DROM:DCON); - combine(db,lastline,lnp,pseu); + pseu = (byte)(n == ps_rom ? DROM : DCON); + combine(db, lastline, lnp, pseu); oldline(lnp); - return (line_p) 0; - } else { - error("datablock without label"); + return (line_p)0; + } + else + { + error("datablock without label"); } } VD(db); @@ -483,14 +486,16 @@ line_p inpseudo(n) /* Read the arguments, 3 for hol or bss and a list * of undetermined length for rom and con. */ - dblockdef(db,n,lnp); + dblockdef(db, n, lnp); /* Fill in d_pseudo, d_size and d_values fields of db */ - if (fragm_type != db->d_pseudo) { + if (fragm_type != db->d_pseudo) + { /* Keep track of fragment numbers, * enter a new fragment. */ fragm_nr++; - switch(db->d_pseudo) { + switch (db->d_pseudo) + { case DCON: case DROM: fragm_type = db->d_pseudo; @@ -511,16 +516,16 @@ line_p inpseudo(n) * the EM visibility rules). * The result (a dblock pointer) is voided. */ - return (line_p) 0; + return (line_p)0; case ps_inp: - getproc(DEFINING); /* same idea */ - return (line_p) 0; + getproc(DEFINING); /* same idea */ + return (line_p)0; case ps_exa: getsym(OCCURRING); - return (line_p) 0; + return (line_p)0; case ps_exp: getproc(OCCURRING); - return (line_p) 0; + return (line_p)0; case ps_pro: curproc = getproc(DEFINING); /* This is a real defining occurrence of a proc */ @@ -531,7 +536,7 @@ line_p inpseudo(n) */ lnp = newline(OPPROC); PROC(lnp) = curproc; - lnp->l_instr = (byte) ps_pro; + lnp->l_instr = (byte)ps_pro; return lnp; case ps_end: curproc->p_nrlabels = labelcount; @@ -543,27 +548,28 @@ line_p inpseudo(n) return lnp; case ps_mes: lnp = arglist(0); - switch((int) aoff(ARG(lnp),0)) { - case ms_err: - error("ms_err encountered"); - case ms_opt: - error("ms_opt encountered"); - case ms_emx: - ws = aoff(ARG(lnp),1); - ps = aoff(ARG(lnp),2); - break; - case ms_ext: + switch ((int)aoff(ARG(lnp), 0)) + { + case ms_err: + error("ms_err encountered"); + case ms_opt: + error("ms_opt encountered"); + case ms_emx: + ws = aoff(ARG(lnp), 1); + ps = aoff(ARG(lnp), 2); + break; + case ms_ext: /* this message was already processed * by the lib package */ - case ms_src: - /* Don't bother about linecounts */ - oldline(lnp); - return (line_p) 0; - case ms_par: - mespar = aoff(ARG(lnp),1); - /* #bytes of parameters of current proc */ - break; + case ms_src: + /* Don't bother about linecounts */ + oldline(lnp); + return (line_p)0; + case ms_par: + mespar = aoff(ARG(lnp), 1); + /* #bytes of parameters of current proc */ + break; } return lnp; default: From 2b2bd93e44155d1fb64593deebc629f0b145557e Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 20:08:05 +0200 Subject: [PATCH 215/231] Run through clang-format. --- util/ego/ic/ic_lib.c | 185 ++++++++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 83 deletions(-) diff --git a/util/ego/ic/ic_lib.c b/util/ego/ic/ic_lib.c index e23bdd5d9..aa86a5d0a 100644 --- a/util/ego/ic/ic_lib.c +++ b/util/ego/ic/ic_lib.c @@ -8,7 +8,6 @@ * I C _ L I B . C */ - #include #include #include @@ -23,29 +22,30 @@ #include "../share/files.h" #include "ic_lib.h" - STATIC skip_string(n) - offset n; + offset n; { /* Read a string of length n and void it */ - while (n--) { + while (n--) + { readchar(); } } - STATIC skip_arguments() { /* Skip the arguments of a MES pseudo. The argument * list is terminated by a sp_cend byte. */ - for (;;) { - switch(table2()) { + for (;;) + { + switch (table2()) + { case sp_scon: get_off(); /* void */ - /* fall through !!! */ + /* fall through !!! */ case sp_icon: case sp_ucon: case sp_fcon: @@ -60,10 +60,7 @@ STATIC skip_arguments() } } - - -STATIC bool proc_wanted(name) - char *name; +STATIC bool proc_wanted(name) char* name; { /* See if 'name' is the name of an external procedure * that has been used before, but for which no body @@ -72,18 +69,17 @@ STATIC bool proc_wanted(name) proc_p p; - if (( p = proclookup(name,IMPORTING)) != (proc_p) 0 && - !(p->p_flags1 & PF_BODYSEEN)) { + if ((p = proclookup(name, IMPORTING)) != (proc_p)0 && !(p->p_flags1 & PF_BODYSEEN)) + { return TRUE; - } else { + } + else + { return FALSE; } } - - -STATIC bool data_wanted(name) - char *name; +STATIC bool data_wanted(name) char* name; { /* See if 'name' is the name of an externally visible * data block that has been used before, but for which @@ -92,16 +88,16 @@ STATIC bool data_wanted(name) dblock_p db; - if ((db = symlookup(name,IMPORTING)) != (dblock_p) 0 && - db->d_pseudo == DUNKNOWN) { + if ((db = symlookup(name, IMPORTING)) != (dblock_p)0 && db->d_pseudo == DUNKNOWN) + { return TRUE; - } else { + } + else + { return FALSE; } } - - STATIC bool wanted_names() { /* Read the names of procedures and data labels, @@ -114,10 +110,13 @@ STATIC bool wanted_names() * no defining occurrence has been met. */ - for (;;) { - switch(table2()) { + for (;;) + { + switch (table2()) + { case DLBX: - if (data_wanted(string)) { + if (data_wanted(string)) + { return TRUE; } /* A data entity with the name @@ -125,7 +124,8 @@ STATIC bool wanted_names() */ break; case sp_pnam: - if (proc_wanted(string)) { + if (proc_wanted(string)) + { return TRUE; } break; @@ -137,9 +137,7 @@ STATIC bool wanted_names() } } - - -STATIC FILE *curfile = NULL; +STATIC FILE* curfile = NULL; STATIC bool useful() { /* Determine if any entity imported by the current @@ -150,43 +148,45 @@ STATIC bool useful() * of the entities imported. */ - for (;;) { - if (table1() != PSEU || tabval != ps_mes) { - error("cannot find MES %d in library file",ms_ext); + for (;;) + { + if (table1() != PSEU || tabval != ps_mes) + { + error("cannot find MES %d in library file", ms_ext); } - if (table2() != CSTX1) { + if (table2() != CSTX1) + { error("message number expected"); } - if (tabval == ms_ext) { + if (tabval == ms_ext) + { /* This is the one we searched */ return wanted_names(); /* Read the names of the imported entities * and check if any of them is wanted. */ - } else { + } + else + { skip_arguments(); /* skip remainder of this MES */ } } } - - -STATIC bool is_archive(name) - char *name; +STATIC bool is_archive(name) char* name; { /* See if 'name' is the name of an archive file, i.e. it * should end on ".ma" and should at least be four characters * long (i.e. the name ".ma" is not accepted as an archive name!). */ - register char *p; + register char* p; - for (p = name; *p; p++); - return (p > name+3) && (*--p == 'a') && (*--p == 'm') && (*--p == '.'); + for (p = name; *p; p++) + ; + return (p > name + 3) && (*--p == 'a') && (*--p == 'm') && (*--p == '.'); } - - STATIC struct ar_hdr hdr; STATIC bool read_hdr() @@ -194,39 +194,41 @@ STATIC bool read_hdr() /* Read the header of an archive module */ char buf[AR_TOTAL]; - register char *c = buf; - register char *p = hdr.ar_name; + register char* c = buf; + register char* p = hdr.ar_name; register int i; fread(c, AR_TOTAL, 1, curfile); - if (feof(curfile)) return 0; + if (feof(curfile)) + return 0; i = 14; - while (i--) { + while (i--) + { *p++ = *c++; } -#define get2(c) (((c)[0]&0377) | ((unsigned) ((c)[1]&0377) << 8)) +#define get2(c) (((c)[0] & 0377) | ((unsigned)((c)[1] & 0377) << 8)) - hdr.ar_date = ((long) get2(c)) << 16; c += 2; - hdr.ar_date |= ((long) get2(c)) & 0xffff; c += 2; + hdr.ar_date = ((long)get2(c)) << 16; + c += 2; + hdr.ar_date |= ((long)get2(c)) & 0xffff; + c += 2; hdr.ar_uid = *c++; hdr.ar_gid = *c++; - hdr.ar_mode = get2(c); c += 2; - hdr.ar_size = (long) get2(c) << 16; c += 2; - hdr.ar_size |= (long) get2(c) & 0xffff; + hdr.ar_mode = get2(c); + c += 2; + hdr.ar_size = (long)get2(c) << 16; + c += 2; + hdr.ar_size |= (long)get2(c) & 0xffff; return 1; } - - STATIC int argcnt = ARGSTART - 1; STATIC short arstate = NO_ARCHIVE; - -FILE *next_file(argc,argv) - int argc; - char *argv[]; +FILE* next_file(argc, argv) int argc; +char* argv[]; { /* See if there are more EM input files. The file names * are given via argv. If a file is an archive file @@ -237,61 +239,78 @@ FILE *next_file(argc,argv) * occurrence, although we have seen a used occurrence. */ - long ptr; + long ptr; - for (;;) { + for (;;) + { /* This loop is only exited via a return */ - if (arstate == ARCHIVE) { + if (arstate == ARCHIVE) + { /* We were reading an archive file */ - if (ftell(curfile) & 1) { + if (ftell(curfile) & 1) + { /* modules in an archive file always * begin on a word boundary, i.e. at * an even address. */ - fseek(curfile,1L,1); + fseek(curfile, 1L, 1); } - if (read_hdr()) { /* read header of next module */ + if (read_hdr()) + { /* read header of next module */ ptr = ftell(curfile); /* file position */ - file_init(curfile,ARCHIVE,hdr.ar_size); + file_init(curfile, ARCHIVE, hdr.ar_size); /* tell i/o package that we're reading * an archive module of given length. */ - if (useful()) { + if (useful()) + { /* re-initialize file, because 'useful' * has read some bytes too. */ - fseek(curfile,ptr,0); /* start module */ - file_init(curfile,ARCHIVE,hdr.ar_size); + fseek(curfile, ptr, 0); /* start module */ + file_init(curfile, ARCHIVE, hdr.ar_size); return curfile; - } else { + } + else + { /* skip this module */ fseek(curfile, - ptr+hdr.ar_size,0); + ptr + hdr.ar_size, 0); } - } else { + } + else + { /* done with this archive */ arstate = NO_ARCHIVE; } - } else { + } + else + { /* open next file, close old */ - if (curfile != NULL) { + if (curfile != NULL) + { fclose(curfile); } argcnt++; - if (argcnt >= argc) { + if (argcnt >= argc) + { /* done with all arguments */ return NULL; } filename = argv[argcnt]; - if ((curfile = fopen(filename,"r")) == NULL) { - error("cannot open %s",filename); + if ((curfile = fopen(filename, "r")) == NULL) + { + error("cannot open %s", filename); } - if (is_archive(filename)) { + if (is_archive(filename)) + { /* ends on '.ma' */ arstate = ARCHIVE; arch_init(curfile); /* read magic ar number */ - } else { - file_init(curfile,NO_ARCHIVE,0L); + } + else + { + file_init(curfile, NO_ARCHIVE, 0L); return curfile; } } From 84ee7c9cc4f46dc52fa8a0f73c0d5aebd3dc9553 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 20:27:52 +0200 Subject: [PATCH 216/231] Fix linking bug where em_decode would generate binary data instead of text. --- util/misc/build.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/misc/build.lua b/util/misc/build.lua index 556d56b99..dd207bbbc 100644 --- a/util/misc/build.lua +++ b/util/misc/build.lua @@ -26,7 +26,7 @@ cprogram { "h+emheaders", "modules+headers", "modules/src/alloc+lib", - "modules/src/em_code+lib_k", + "modules/src/em_code+lib_e", "modules/src/print+lib", "modules/src/read_em+lib_kv", "modules/src/string+lib", From 08823a172c8174154c702e334c5658e7510646ee Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 21:55:21 +0200 Subject: [PATCH 217/231] filenamesof() an installable now returns all installed files, not just the ones at the top level (necessary to make a lot of the dependency stuff work when using tools which depend on installables). --- first/ackbuilder.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 4b3e1bc6a..25bfd02c0 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -723,6 +723,7 @@ definerule("installable", local deps = {} local commands = {} local srcs = {} + local outs = {} local dests = {} for dest, src in pairs(e.map) do if src.is.installable then @@ -730,6 +731,7 @@ definerule("installable", error("can't specify a destination filename when installing an installable") end deps[#deps+1] = src.fullname + outs = concat(outs, filenamesof(src)) elseif (type(dest) == "number") then error("only references to other installables can be missing a destination") else @@ -740,6 +742,7 @@ definerule("installable", deps[#deps+1] = f dests[#dests+1] = dest + outs[#outs+1] = dest commands[#commands+1] = "cp "..f[1].." "..dest end end @@ -752,7 +755,7 @@ definerule("installable", emitter:endrule() return { - outs = dests + outs = outs } end ) From 5bae29a00c4ca6f6dbd3d8dafde3e4eeecb131a3 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 21 Aug 2016 22:01:19 +0200 Subject: [PATCH 218/231] ego now builds and is used. This needed lots of refactoring to ego --- not all platforms have ego descr files, and ego will just crash if you invoke it without one. I think originally it was never intended that these platforms would be used at -O2 or above. Plats now only specify the ego descr file if they have one. --- build.lua | 3 +- lib/descr/fe | 15 +-- plat/build.lua | 2 +- plat/linux386/descr | 1 + plat/linux68k/descr | 1 + plat/pc86/descr | 1 + util/ego/build.lua | 58 +++++++++ util/ego/ca/ca.c | 38 +++++- util/ego/cf/cf.c | 48 +++++-- util/ego/descr/build.lua | 30 +++++ util/ego/em_ego/em_ego.c | 266 ++++++++++++++++++--------------------- util/ego/ic/ic.c | 27 ++-- util/ego/ic/ic_lib.c | 2 +- util/ego/il/il.c | 9 +- util/ego/ra/build.lua | 32 +++++ util/ego/share/files.c | 40 +++++- util/ego/share/files.h | 30 +++-- util/ego/share/go.c | 63 +++++----- util/ego/share/go.h | 57 +++++---- 19 files changed, 461 insertions(+), 262 deletions(-) create mode 100644 util/ego/build.lua create mode 100644 util/ego/descr/build.lua create mode 100644 util/ego/ra/build.lua diff --git a/build.lua b/build.lua index 3c5e34c8d..b5de879c8 100644 --- a/build.lua +++ b/build.lua @@ -2,7 +2,7 @@ vars.cflags = { "-g", "-O" } vars.ackcflags = { - "-O" + "-O6" } vars.plats = { "cpm", @@ -27,6 +27,7 @@ installable { "util/ack+pkg", "util/amisc+pkg", "util/arch+pkg", + "util/ego+pkg", "util/led+pkg", "util/misc+pkg", "util/opt+pkg", diff --git a/lib/descr/fe b/lib/descr/fe index 4e85c64b3..e88663a6d 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -206,19 +206,6 @@ name ego to .gk program {EM}/lib/ack/em_ego mapflag -EGO-* EGO_F={EGO_F?} -* -# The following lines are obsolete, but here for backwards compatibility. -# They should be removed some day. - mapflag -IL* EGO_F={EGO_F?} -IL* - mapflag -CS* EGO_F={EGO_F?} -CS* - mapflag -SR* EGO_F={EGO_F?} -SR* - mapflag -UD* EGO_F={EGO_F?} -UD* - mapflag -LV* EGO_F={EGO_F?} -LV* - mapflag -SA* EGO_F={EGO_F?} -RA* - mapflag -SP* EGO_F={EGO_F?} -SP* - mapflag -BO* EGO_F={EGO_F?} -BO* - mapflag -CJ* EGO_F={EGO_F?} -CJ* - mapflag -EV EGO_F={EGO_F?} -V -# End of obsolete lines mapflag -Q* EGO_F={EGO_F?} -Q* mapflag -T* EGO_F={EGO_F?} -T* mapflag -S* EGO_F={EGO_F?} -S* @@ -227,7 +214,7 @@ name ego mapflag -O* EGO_F={EGO_F?} -O* args \ {EGO_F?} -P {EM}/lib/ack/ego \ - -M{EM}/share/ack/ego/{ARCH}.descr < + {EGO_PLAT_FLAGS?} < optimizer 2 stdout combiner diff --git a/plat/build.lua b/plat/build.lua index d24e5d3f2..dc0e87c5e 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -20,6 +20,7 @@ definerule("ackfile", "lang/pc/comp+pkg", "plat/"..plat.."+tools", "util/ack+pkg", + "util/ego+pkg", "util/misc+pkg", e.deps }, @@ -67,7 +68,6 @@ definerule("ackprogram", "plat/"..e.vars.plat.."+pkg", "util/ack+pkg", "util/led+pkg", - "util/amisc+pkg", e.deps }, _clibrary = acklibrary, diff --git a/plat/linux386/descr b/plat/linux386/descr index 32f5ea2e5..611e96e44 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -26,6 +26,7 @@ var C_LIB={PLATFORMDIR}/libc-ansi.a var CC_ALIGN=-Vr var OLD_C_LIB={C_LIB} var MACHOPT_F=-m10 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr # Override the setting in fe so that files compiled for linux386 can see # the platform-specific headers. diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 2c7d57d50..9347ad2b2 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -26,6 +26,7 @@ var C_LIB={PLATFORMDIR}/libc-ansi.a var CC_ALIGN=-Vr var OLD_C_LIB={C_LIB} var MACHOPT_F=-ml10 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr # Override the setting in fe so that files compiled for linux68k can see # the platform-specific headers. diff --git a/plat/pc86/descr b/plat/pc86/descr index c282e9cc7..d8cb006e6 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -22,6 +22,7 @@ var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 var MACHOPT_F=-m8 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr # Override the setting in fe so that files compiled for this platform can see # the platform-specific headers. diff --git a/util/ego/build.lua b/util/ego/build.lua new file mode 100644 index 000000000..864447550 --- /dev/null +++ b/util/ego/build.lua @@ -0,0 +1,58 @@ +local function build_ego(name) + cprogram { + name = name, + srcs = { "./"..name.."/*.c" }, + deps = { + "util/ego/share+lib", + "modules/src/em_data+lib", + "h+emheaders", + }, + vars = { + ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} + } + } +end + +build_ego("bo") +build_ego("ca") +build_ego("cf") +build_ego("cj") +build_ego("cs") +build_ego("ic") +build_ego("il") +build_ego("lv") +build_ego("sp") +build_ego("sr") +build_ego("ud") + +cprogram { + name = "em_ego", + srcs = { "./em_ego/em_ego.c" }, + deps = { + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "modules+headers", + "h+emheaders", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_ego"] = "+em_ego", + ["$(PLATDEP)/ego/bo"] = "+bo", + ["$(PLATDEP)/ego/ca"] = "+ca", + ["$(PLATDEP)/ego/cf"] = "+cf", + ["$(PLATDEP)/ego/cj"] = "+cj", + ["$(PLATDEP)/ego/cs"] = "+cs", + ["$(PLATDEP)/ego/ic"] = "+ic", + ["$(PLATDEP)/ego/il"] = "+il", + ["$(PLATDEP)/ego/lv"] = "+lv", + ["$(PLATDEP)/ego/ra"] = "./ra+ra", + ["$(PLATDEP)/ego/sp"] = "+sp", + ["$(PLATDEP)/ego/sr"] = "+sr", + ["$(PLATDEP)/ego/ud"] = "+ud", + "./descr+pkg", + } +} diff --git a/util/ego/ca/ca.c b/util/ego/ca/ca.c index a59cce0ae..acfba4829 100644 --- a/util/ego/ca/ca.c +++ b/util/ego/ca/ca.c @@ -220,24 +220,50 @@ main(argc, argv) int argc; char* argv[]; { /* CA does not output proctable etc. files. Instead, its - * pname2 and dname2 arguments contain the names of the + * pname_out and dname_out arguments contain the names of the * dump files created by IC. */ + struct files* files = findfiles(argc, argv); + FILE* f, *f2; /* The EM input and output. */ FILE* df, *pf; /* The dump files */ line_p lnp; - fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + /* The names of the input files of every phase are passed as + * arguments to the phase. First come the input file names, + * then the output file names. We use a one-letter convention + * to denote the type of file: + * p: procedure table file + * d: data table file + * l: EM text file (lines of EM instructions) + * b: basic block file (Control Flow Graph file) + */ + + /* The input file names */ + + char* pname_in = argv[1]; + char* dname_in = argv[2]; + char* lname_in = argv[3]; + char* bname_in = argv[4]; + + /* The output file names */ + + char* pname_out = argv[5]; + char* dname_out = argv[6]; + char* lname_out = argv[7]; + char* bname_out = argv[8]; + + fproc = getptable(pname_in); /* proc table */ + fdblock = getdtable(dname_in); /* data block table */ dlength = makedmap(fdblock); /* allocate dmap table */ - df = openfile(dname2, "r"); + df = openfile(dname_out, "r"); getdnames(df); fclose(df); - pf = openfile(pname2, "r"); + pf = openfile(pname_out, "r"); getpnames(pf); fclose(pf); uniq_names(); - f = openfile(lname, "r"); + f = openfile(lname_in, "r"); f2 = stdout; cputmagic(f2); /* write magic number */ while ((lnp = get_ca_lines(f, &curproc)) != (line_p)0) diff --git a/util/ego/cf/cf.c b/util/ego/cf/cf.c index c36694daf..f695aa237 100644 --- a/util/ego/cf/cf.c +++ b/util/ego/cf/cf.c @@ -530,22 +530,46 @@ char* argv[]; short n, kind; line_p l; + /* The names of the input files of every phase are passed as + * arguments to the phase. First come the input file names, + * then the output file names. We use a one-letter convention + * to denote the type of file: + * p: procedure table file + * d: data table file + * l: EM text file (lines of EM instructions) + * b: basic block file (Control Flow Graph file) + */ + + /* The input file names */ + + char* pname_in = argv[1]; + char* dname_in = argv[2]; + char* lname_in = argv[3]; + char* bname_in = argv[4]; + + /* The output file names */ + + char* pname_out = argv[5]; + char* dname_out = argv[6]; + char* lname_out = argv[7]; + char* bname_out = argv[8]; + linecount = 0; - fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fproc = getptable(pname_in); /* proc table */ + fdblock = getdtable(dname_in); /* data block table */ lpi_set = Cempty_set(plength); cai_set = Cempty_set(plength); - if ((f = fopen(lname, "r")) == NULL) + if ((f = fopen(lname_in, "r")) == NULL) { - error("cannot open %s", lname); + error("cannot open %s", lname_in); } - if ((f2 = fopen(lname2, "w")) == NULL) + if ((f2 = fopen(lname_out, "w")) == NULL) { - error("cannot open %s", lname2); + error("cannot open %s", lname_out); } - if ((gf2 = fopen(bname2, "w")) == NULL) + if ((gf2 = fopen(bname_out, "w")) == NULL) { - error("cannot open %s", bname2); + error("cannot open %s", bname_out); } while (getbblocks(f, &kind, &n, &g, &l)) { @@ -581,14 +605,14 @@ char* argv[]; /* Compute transitive closure of used/changed * variables information for every procedure. */ - if ((f = fopen(dname2, "w")) == NULL) + if ((f = fopen(dname_out, "w")) == NULL) { - error("cannot open %s", dname2); + error("cannot open %s", dname_out); } putdtable(fdblock, f); - if ((f = fopen(pname2, "w")) == NULL) + if ((f = fopen(pname_out, "w")) == NULL) { - error("cannot open %s", pname2); + error("cannot open %s", pname_out); } putptable(fproc, f, TRUE); exit(0); diff --git a/util/ego/descr/build.lua b/util/ego/descr/build.lua new file mode 100644 index 000000000..034ffa3ce --- /dev/null +++ b/util/ego/descr/build.lua @@ -0,0 +1,30 @@ +local installmap = {} + +local function build_descr(name) + local descr = normalrule { + name = name, + ins = { + "lang/cem/cpp.ansi+cpp", + "./"..name..".descr", + "./descr.sed", + matching(filenamesof("modules/src/em_data+lib"), "em_mnem%.h$"), + }, + outleaves = { name..".descr" }, + commands = { + "%{ins[1]} -P -I%{dirname(ins[4])} %{ins[2]} > %{dir}/temp", + "sed -f %{ins[3]} < %{dir}/temp > %{outs}" + } + } + + installmap["$(PLATIND)/ego/"..name..".descr"] = descr +end + +build_descr("i386") +build_descr("i86") +build_descr("m68020") + +installable { + name = "pkg", + map = installmap +} + diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 0d4bc06a3..5475618b1 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -4,38 +4,54 @@ optimizer itself one day ... */ -#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include "em_path.h" +#include "system.h" +#include "print.h" -#define IC 1 -#define CF 2 -#define IL 3 -#define CS 4 -#define SR 5 -#define UD 6 -#define LV 7 -#define RA 8 -#define SP 9 -#define BO 10 -#define CJ 11 -#define CA 12 +enum +{ + NONE = 0, + IC, + CF, + IL, + CS, + SR, + UD, + LV, + RA, + SP, + BO, + CJ, + CA +}; -static char* phnames[] = { - 0, - "ic", - "cf", - "il", - "cs", - "sr", - "ud", - "lv", - "ra", - "sp", - "bo", - "cj", - "ca", - 0 +static const struct +{ + const char* name; + bool needsdescr; + +} phase_data[] = { + {}, + { "ic" }, + { "cf" }, + { "il" }, + { "cs", true }, + { "sr" }, + { "ud", true }, + { "lv" }, + { "ra" }, + { "sp" }, + { "bo" }, + { "cj" }, + { "ca" }, }; #define MAXUPHASES 64 /* max # of phases to be run */ @@ -77,8 +93,9 @@ static int keeptemps = 0; static char** phase_args; static int nphase_args; -static char* opt_dir; -static char* prog_name; +static const char* descr_file; +static const char* opt_dir; +static const char* prog_name; static int v_flag; @@ -93,7 +110,7 @@ cleanup() for (i = NTEMPS * 2; i > 0; i--) { - register char* f = phargs[i]; + const char* f = phargs[i]; if (f != 0 && *f != '\0' && *f != '-') (void)unlink(f); } @@ -167,8 +184,8 @@ get_infiles() /* Make output temps from previous phase input temps of next phase. */ register int i; - register char** dst = &phargs[1]; - register char** src = &phargs[NTEMPS + 1]; + char** dst = &phargs[1]; + char** src = &phargs[NTEMPS + 1]; for (i = 1; i <= NTEMPS; i++) { @@ -184,7 +201,7 @@ new_outfiles() static char dig1 = '1'; static char dig2 = '0'; register int i; - register char** dst = &phargs[NTEMPS + 1]; + char** dst = &phargs[NTEMPS + 1]; if (!Bindex) { @@ -219,14 +236,21 @@ static void char buf[256]; int pid, status; + /* Skip this phase if it requires a descr file and one hasn't been + * provided. */ + + if (phase_data[phase].needsdescr && !descr_file) + return; + phargs[0] = buf; (void)strcpy(buf, opt_dir); (void)strcat(buf, "/"); - (void)strcat(buf, phnames[phase]); + (void)strcat(buf, phase_data[phase].name); switch (phase) { case IC: + /* always first */ phargs[1] = pdump; phargs[2] = ddump; for (i = 3; i <= NTEMPS; i++) @@ -237,6 +261,7 @@ static void break; case CA: + /* always last */ old_infiles(); get_infiles(); phargs[NTEMPS + 1] = pdump; @@ -248,20 +273,24 @@ static void break; default: + { old_infiles(); get_infiles(); new_outfiles(); - if (!flags_added) + + argc = 2 * NTEMPS + 1; + if (descr_file) { - flags_added = 1; - argc = 2 * NTEMPS + 1; - while (--nphase_args >= 0) - { - phargs[argc++] = *phase_args++; - } - phargs[argc] = 0; + phargs[argc++] = "-M"; + phargs[argc++] = descr_file; } + + for (i=0; i 0) + + opterr = 0; + for (;;) { - argv++; - if (argv[0][0] == '-') + int opt = getopt(argc, argv, "-M:P:O:vt"); + if (opt == -1) + break; + + switch (opt) { - switch (argv[0][1]) + case 'M': + descr_file = optarg; + break; + + case 'P': + opt_dir = optarg; + break; + + case 'O': { - case 'P': - if (argv[0][2] == '\0') - { - opt_dir = argv[1]; - argc--; - argv++; - continue; - } - break; - case 't': - if (argv[0][2] == '\0') - { - keeptemps = 1; - /* no continue; IL also needs this */ - } - break; - case 'v': - v_flag = 1; - break; - case 'O': - if (argv[0][2] == '2' || argv[0][2] == '\0') - continue; - if (argv[0][2] == '3') - { - Ophase = &O3phases[0]; - continue; - } - Ophase = &O4phases[0]; - continue; - case 'I': - if (!strcmp(&argv[0][1], "IL")) - { - add_uphase(IL); - add_uphase(CF); - continue; - } - break; - case 'B': - if (!strcmp(&argv[0][1], "BO")) - { - add_uphase(BO); - continue; - } - break; - case 'R': - if (!strcmp(&argv[0][1], "RA")) - { - add_uphase(RA); - continue; - } - break; - case 'U': - if (!strcmp(&argv[0][1], "UD")) - { - add_uphase(UD); - continue; - } - break; - case 'L': - if (!strcmp(&argv[0][1], "LV")) - { - add_uphase(LV); - continue; - } - break; - case 'C': - if (!strcmp(&argv[0][1], "CS")) - { - add_uphase(CS); - continue; - } - if (!strcmp(&argv[0][1], "CJ")) - { - add_uphase(CJ); - continue; - } - break; - case 'S': - if (!strcmp(&argv[0][1], "SR")) - { - add_uphase(SR); - continue; - } - if (!strcmp(&argv[0][1], "SP")) - { - add_uphase(SP); - continue; - } + int o = atoi(optarg); + if (o <= 2) break; + if (o <= 3) + Ophase = &O3phases[0]; + Ophase = &O4phases[0]; + break; } - phase_args[i++] = argv[0]; - } - else - { - add_file(argv[0]); + + case 1: + add_file(optarg); + break; + + case 't': + keeptemps = 1; + goto addopt; + + case 'v': + v_flag = 1; + goto addopt; + + case '?': + addopt: + phase_args[nphase_args++] = argv[optind - 1]; + break; } } - phase_args[i] = 0; - nphase_args = i; + + phase_args[nphase_args] = 0; if (nuphases) Ophase = uphases; diff --git a/util/ego/ic/ic.c b/util/ego/ic/ic.c index 42faf5ebe..b1d356303 100644 --- a/util/ego/ic/ic.c +++ b/util/ego/ic/ic.c @@ -72,13 +72,26 @@ char* argv[]; * - ddump: the names of all data blocks */ - FILE* lfile, *dfile, *pfile, *pdump, *ddump; + /* The input file names */ + + const char* pdump_out = argv[1]; + const char* ddump_out = argv[2]; + + /* The output file names */ + + const char* pname_out = argv[5]; + const char* dname_out = argv[6]; + const char* lname_out = argv[7]; + + FILE* lfile = openfile(lname_out, "w"); + FILE* pdump = openfile(pdump_out, "w"); + FILE* ddump = openfile(ddump_out, "w"); + + FILE* dfile; + FILE* pfile; - lfile = openfile(lname2, "w"); - pdump = openfile(argv[1], "w"); - ddump = openfile(argv[2], "w"); hol0_db = block_of_lab((char*)0); - while (next_file(argc, argv) != NULL) + while (next_file(argc-8, argv+8) != NULL) { /* Read all EM input files, process the code * and concatenate all output. @@ -104,9 +117,9 @@ char* argv[]; cleanprocs(prochash, NPROCHASH, 0); cleandblocks(symhash, NSYMHASH, 0); /* Now write the datablock table and the proctable */ - dfile = openfile(dname2, "w"); + dfile = openfile(dname_out, "w"); putdtable(fdblock, dfile); - pfile = openfile(pname2, "w"); + pfile = openfile(pname_out, "w"); putptable(fproc, pfile, FALSE); exit(0); } diff --git a/util/ego/ic/ic_lib.c b/util/ego/ic/ic_lib.c index aa86a5d0a..638038afc 100644 --- a/util/ego/ic/ic_lib.c +++ b/util/ego/ic/ic_lib.c @@ -224,7 +224,7 @@ STATIC bool read_hdr() return 1; } -STATIC int argcnt = ARGSTART - 1; +STATIC int argcnt = 0; STATIC short arstate = NO_ARCHIVE; FILE* next_file(argc, argv) int argc; diff --git a/util/ego/il/il.c b/util/ego/il/il.c index d16ffce3f..938dfa3cc 100644 --- a/util/ego/il/il.c +++ b/util/ego/il/il.c @@ -325,6 +325,7 @@ il_flags(p) char* p; main(argc, argv) int argc; char* argv[]; { + struct files* files = findfiles(argc, argv); FILE* f; go(argc, argv, no_action, no_action, no_action, il_flags); @@ -337,14 +338,14 @@ char* argv[]; mktemp(ccname); mktemp(sname); mktemp(cname2); - pass1(lname, bname, cname); /* grep calls, analyse procedures */ + pass1(files->lname_in, files->bname_in, cname); /* grep calls, analyse procedures */ space = total_size * space / 100; pass2(cname, space); /* select calls to be expanded */ - pass3(lname, lname2); /* do substitutions */ - f = openfile(dname2, "w"); + pass3(files->lname_in, files->lname_out); /* do substitutions */ + f = openfile(files->dname_out, "w"); il_cleanptab(fproc); /* remove extended data structures */ putdtable(fdblock, f); - f = openfile(pname2, "w"); + f = openfile(files->pname_out, "w"); putptable(fproc, f, FALSE); report("inline substitutions", Ssubst); #ifdef VERBOSE diff --git a/util/ego/ra/build.lua b/util/ego/ra/build.lua new file mode 100644 index 000000000..4b934de56 --- /dev/null +++ b/util/ego/ra/build.lua @@ -0,0 +1,32 @@ +cprogram { + name = "makeitems", + srcs = { "./makeitems.c" } +} + +normalrule { + name = "itemtab_h", + ins = { + "+makeitems", + matching(filenamesof("modules/src/em_data+lib"), "em_mnem%.h$"), + "./itemtab.src" + }, + outleaves = { "itemtab.h" }, + commands = { + "%{ins} > %{outs}" + } +} + +cprogram { + name = "ra", + srcs = { "./ra*.c" }, + deps = { + "util/ego/share+lib", + "modules/src/em_data+lib", + "h+emheaders", + "+itemtab_h", + }, + vars = { + ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} + } +} + diff --git a/util/ego/share/files.c b/util/ego/share/files.c index 8641b353f..644819307 100644 --- a/util/ego/share/files.c +++ b/util/ego/share/files.c @@ -9,9 +9,45 @@ */ #include +#include "files.h" -FILE *openfile(name,mode) - char *name,*mode; +struct files* findfiles(int argc, const char** argv) +{ + static struct files files; + + /* The names of the input files of every phase are passed as + * arguments to the phase. First come the input file names, + * then the output file names. We use a one-letter convention + * to denote the type of file: + * p: procedure table file + * d: data table file + * l: EM text file (lines of EM instructions) + * b: basic block file (Control Flow Graph file) + */ + + /* The input file names */ + + files.pname_in = argv[1]; + files.dname_in = argv[2]; + files.lname_in = argv[3]; + files.bname_in = argv[4]; + + /* The output file names */ + + files.pname_out = argv[5]; + files.dname_out = argv[6]; + files.lname_out = argv[7]; + files.bname_out = argv[8]; + + /* The rest of the arguments. */ + + files.argv = argv + 8; + files.argc = argc - 8; + + return &files; +} + +FILE *openfile(char* name, char* mode) { FILE *f; diff --git a/util/ego/share/files.h b/util/ego/share/files.h index 350bb01ee..72deae081 100644 --- a/util/ego/share/files.h +++ b/util/ego/share/files.h @@ -15,21 +15,29 @@ * b: basic block file (Control Flow Graph file) */ -/* The input file names */ +struct files +{ + /* Input files */ -#define pname argv[1] -#define dname argv[2] -#define lname argv[3] -#define bname argv[4] + const char* pname_in; + const char* dname_in; + const char* lname_in; + const char* bname_in; -/* The output file names */ + /* Output files */ -#define pname2 argv[5] -#define dname2 argv[6] -#define lname2 argv[7] -#define bname2 argv[8] + const char* pname_out; + const char* dname_out; + const char* lname_out; + const char* bname_out; -#define ARGSTART 9 + /* The rest of the arguments. */ + + const char** argv; + int argc; +}; + +extern struct files* findfiles(int argc, const char** argv); extern FILE *openfile(); /* (char *name, *mode) * Open a file with the given name diff --git a/util/ego/share/go.c b/util/ego/share/go.c index 0e1879947..53c6bb456 100644 --- a/util/ego/share/go.c +++ b/util/ego/share/go.c @@ -10,24 +10,24 @@ */ #include +#include #include "types.h" #include "debug.h" #include "global.h" -#include "files.h" #include "get.h" #include "put.h" #include "lset.h" #include "map.h" #include "alloc.h" #include "go.h" +#include "files.h" STATIC bool report_flag = FALSE; /* report #optimizations found? */ #ifdef DEBUG STATIC bool core_flag = FALSE; /* report core usage? */ #endif -STATIC mach_init(machfile, phase_machinit) char* machfile; -int (*phase_machinit)(); +static mach_init(char* machfile, int (*phase_machinit)()) { /* Read target machine dependent information */ @@ -42,13 +42,10 @@ int (*phase_machinit)(); fclose(f); } -go(argc, argv, initialize, optimize, phase_machinit, proc_flag) int argc; -char* argv[]; -int (*initialize)(); -int (*optimize)(); -int (*phase_machinit)(); -int (*proc_flag)(); +void go(int argc, const char** argv, + int (*initialize)(), int (*optimize)(), int (*phase_machinit)(), int (*proc_flag)()) { + struct files* files = findfiles(argc, argv); FILE* f, *gf, *f2, *gf2; /* The EM input and output and * the basic block graphs input and output */ @@ -60,49 +57,56 @@ int (*proc_flag)(); bool time_opt = TRUE; linecount = 0; - for (i = ARGSTART; i < argc; i++) + opterr = 0; + for (;;) { - p = argv[i]; - if (*p++ != '-') - error("illegal argument"); - switch (*p) + int opt = getopt(files->argc, files->argv, "STM:CQV"); + if (opt == -1) + break; + + switch (opt) { case 'S': time_opt = FALSE; break; + case 'T': time_opt = TRUE; break; + case 'M': - p++; - mach_init(p, phase_machinit); + mach_init(optarg, phase_machinit); break; + case 'C': #ifdef DEBUG core_flag = TRUE; #endif break; + case 'Q': report_flag = TRUE; break; + case 'V': verbose_flag = TRUE; break; - default: - (*proc_flag)(p); + + case '?': + proc_flag(argv[optind - 1]); break; } } time_space_ratio = (time_opt ? 100 : 0); - fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fproc = getptable(files->pname_in); /* proc table */ + fdblock = getdtable(files->dname_in); /* data block table */ (*initialize)(); if (optimize == no_action) return; - f = openfile(lname, "r"); - gf = openfile(bname, "r"); - f2 = openfile(lname2, "w"); - gf2 = openfile(bname2, "w"); + f = openfile(files->lname_in, "r"); + gf = openfile(files->bname_in, "r"); + f2 = openfile(files->lname_out, "w"); + gf2 = openfile(files->bname_out, "w"); mesregs = Lempty_set(); while (getunit(gf, f, &kind, &g, &l, &curproc, TRUE)) { @@ -130,18 +134,18 @@ int (*proc_flag)(); fclose(f2); fclose(gf); fclose(gf2); - f = openfile(dname2, "w"); + f = openfile(files->dname_out, "w"); putdtable(fdblock, f); /* fclose(f); done by putdtable */ - f = openfile(pname2, "w"); + f = openfile(files->pname_out, "w"); putptable(fproc, f, TRUE); /* fclose(f); done by putptable */ core_usage(); } -no_action() {} +int no_action() {} -core_usage() +void core_usage(void) { #ifdef DEBUG if (core_flag) @@ -151,8 +155,7 @@ core_usage() #endif } -report(s, n) char* s; -int n; +void report(char* s, int n) { /* Report number of optimizations found, if report_flag is set */ diff --git a/util/ego/share/go.h b/util/ego/share/go.h index 9e07bdb89..8657c0d67 100644 --- a/util/ego/share/go.h +++ b/util/ego/share/go.h @@ -9,30 +9,33 @@ * */ -extern go(); /* ( int argc; char *argv[]; - * int (*initialize)(); int (*optimize)(); - * int (*phase_machinit)(); int (*proc_flag)() ) - * This is the main driving routine of the optimizer. - * It first processes the flags given as argument; - * for every flag it does not recognize itself, it - * calls 'proc_flag'; as soon as the -M flag is seen, - * it opens the machine descriptor file and - * reads phase-independend information (notably the - * wordsize and pointersize of the target machine); - * next it calls 'phase_machinit' with this file as - * parameter. Subsequently it calls 'initialize'. - * Finally, all procedures are read, one at a time, - * and 'optimize' is called with the current procedure - * as parameter. - */ -extern no_action(); /* () - * Parameter to be supplied for e.g. 'initialize' if - * no action is required. - */ -extern core_usage(); /* () - * Report core usage, if core_flag is set. - */ -extern report(); /* ( char *s; int n) - * Report number of optimizations found, if - * report_flag is set - */ +/* This is the main driving routine of the optimizer. + * It first processes the flags given as argument; + * for every flag it does not recognize itself, it + * calls 'proc_flag'; as soon as the -M flag is seen, + * it opens the machine descriptor file and + * reads phase-independend information (notably the + * wordsize and pointersize of the target machine); + * next it calls 'phase_machinit' with this file as + * parameter. Subsequently it calls 'initialize'. + * Finally, all procedures are read, one at a time, + * and 'optimize' is called with the current procedure + * as parameter. + */ +extern void go(int argc, const char** argv, + int (*initialize)(), int (*optimize)(), + int (*phase_machinit)(), int (*proc_flag)()); + +/* + * Parameter to be supplied for e.g. 'initialize' if + * no action is required. + */ +extern int no_action(); + +/* Report core usage, if core_flag is set. */ +extern void core_usage(void); + +/* Report number of optimizations found, if + * report_flag is set + */ +extern void report(char* s, int n); From 2a95b1c5e390a40bd838584a6ee87dc26440d958 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 22 Aug 2016 22:45:32 +0200 Subject: [PATCH 219/231] Forgot to check a file in. --- util/ego/share/build.lua | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 util/ego/share/build.lua diff --git a/util/ego/share/build.lua b/util/ego/share/build.lua new file mode 100644 index 000000000..ab1068d2c --- /dev/null +++ b/util/ego/share/build.lua @@ -0,0 +1,61 @@ +cprogram { + name = "makecldef", + srcs = { "./makecldef.c" } +} + +normalrule { + name = "classdefs_h", + ins = { + "+makecldef", + matching(filenamesof("modules/src/em_data+lib"), "em_mnem%.h$"), + "./cldefs.src" + }, + outleaves = { "classdefs.h" }, + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "pop_push_h", + ins = { + "./pop_push.awk", + "h/em_table", + }, + outleaves = { "pop_push.h" }, + commands = { + "awk -f %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +clibrary { + name = "lib", + srcs = { + "./debug.c", + "./global.c", + "./files.c", + "./go.c", + "./map.c", + "./aux.c", + "./get.c", + "./put.c", + "./alloc.c", + "./lset.c", + "./cset.c", + "./parser.c", + "./stack_chg.c", + "./locals.c", + "./init_glob.c", + }, + deps = { + "+classdefs_h", + "+pop_push_h", + "h+emheaders", + "modules/src/em_data+lib", + }, + vars = { + ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} + } +} + + From 2b6d251dec7854902adfaf45e461bb29ce753312 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 22 Aug 2016 23:53:01 +0200 Subject: [PATCH 220/231] Fix a fun bug where, every now again, ego would get its temporary files mangled and generate invalid calls to the optimisers. Previously ego would generate a temporary file template that looked like /tmp/ego.A.BB.XXXXXX, call mktemp() on it to randomise the XXXXXX, and then replace A and BB with data. However, it used strrchr to find the A and B. Which would fine, except when mktemp produced an A or a B in the randomised part... This code was written on 4 March 1991. I was 16. --- util/ego/em_ego/em_ego.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 5475618b1..60a99ea5d 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -418,8 +418,9 @@ int main(int argc, char* argv[]) (void)strcat(pdump, "/ego.pd.XXXXXX"); (void)mktemp(pdump); - (void)strcat(tmpbufs[0], "/ego.A.BB.XXXXXX"); + (void)strcat(tmpbufs[0], "/ego.XXXXXX"); (void)mktemp(tmpbufs[0]); + (void)strcat(tmpbufs[0], ".A.BB"); for (i = 2 * NTEMPS - 1; i >= 1; i--) { (void)strcpy(tmpbufs[i], tmpbufs[0]); From 96e7447bfa303293c0861104bdbdecd8627d73ec Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 1 Sep 2016 23:36:39 +0200 Subject: [PATCH 221/231] Clean up the top level makefile. --- Makefile | 60 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 9dae29060..33362a470 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,19 @@ LDFLAGS = AR = ar CC = gcc +# Which build system to use; use 'ninja' or 'make' (in lower case). Leave +# blank to autodetect. + +BUILDSYSTEM = + +# Build flags for ninja. + +NINJAFLAGS = + +# Build flags for make. + +MAKEFLAGS = -r + # ======================================================================= # # END OF CONFIGURATION # # ======================================================================= # @@ -51,25 +64,26 @@ PLATDEP = $(INSDIR)/lib/ack MAKECMDGOALS ?= +ack BUILD_FILES = $(shell find * -name '*.lua') -NINJA := $(shell which ninja) -ifneq ($(findstring +, $(MAKECMDGOALS)),) -ifneq ($(NINJA),) - -$(MAKECMDGOALS): $(BUILDDIR)/build.ninja - @ninja -f $(BUILDDIR)/build.ninja $(MAKECMDGOALS) - +ifneq ($(shell which ninja),) +BUILDSYSTEM = ninja +BUILDFLAGS = $(NINJAFLAGS) else - -$(MAKECMDGOALS): $(BUILDDIR)/rules.mk - +@make -r -f $(BUILDDIR)/rules.mk $@ \ - $(MAKEFLAGS) - -endif +BUILDSYSTEM = make +BUILDFLAGS = $(MAKEFLAGS) endif -$(BUILDDIR)/build.ninja: first/ackbuilder.lua Makefile $(BUILD_FILES) +ifneq ($(findstring +, $(MAKECMDGOALS)),) + +$(MAKECMDGOALS): $(BUILDDIR)/build.$(BUILDSYSTEM) + @$(BUILDSYSTEM) $(BUILDFLAGS) -f $^ $(MAKECMDGOALS) + +endif + +$(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES) @mkdir -p $(BUILDDIR) - @lua5.1 first/ackbuilder.lua first/build.lua build.lua --ninja \ + @lua5.1 first/ackbuilder.lua \ + first/build.lua build.lua \ + --$(BUILDSYSTEM) \ OBJDIR=$(OBJDIR) \ BINDIR=$(BINDIR) \ LIBDIR=$(LIBDIR) \ @@ -79,21 +93,7 @@ $(BUILDDIR)/build.ninja: first/ackbuilder.lua Makefile $(BUILD_FILES) PLATDEP=$(PLATDEP) \ AR=$(AR) \ CC=$(CC) \ - > $(BUILDDIR)/build.ninja - -$(BUILDDIR)/rules.mk: first/ackbuilder.lua Makefile $(BUILD_FILES) - @mkdir -p $(BUILDDIR) - @lua5.1 first/ackbuilder.lua first/build.lua build.lua --make \ - OBJDIR=$(OBJDIR) \ - BINDIR=$(BINDIR) \ - LIBDIR=$(LIBDIR) \ - INCDIR=$(INCDIR) \ - INSDIR=$(INSDIR) \ - PLATIND=$(PLATIND) \ - PLATDEP=$(PLATDEP) \ - AR=$(AR) \ - CC=$(CC) \ - > $(BUILDDIR)/rules.mk + > $(BUILDDIR)/build.$(BUILDSYSTEM) clean: @rm -rf $(BUILDDIR) From 612e38f1c6c6cda325c4082fe4f4396168fab142 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 2 Sep 2016 22:17:51 +0200 Subject: [PATCH 222/231] Remove the old make-based build system, plus some big chunks of horribly obsolete protomake build system. --- Makefile | 105 ----------- first/core.mk | 219 ---------------------- first/cp_dir | 18 -- first/create_dir | 13 -- first/em_path.h.src | 11 -- first/first | 208 --------------------- first/get_answer | 7 - first/get_makepars | 106 ----------- first/get_sys | 157 ---------------- first/get_sysvax | 23 --- first/install_tail | 93 ---------- first/limit_enquire | 209 --------------------- first/limit_impl | 208 --------------------- first/lint_params | 19 -- first/local.h.src | 19 -- first/mk_config | 133 -------------- first/mk_makefile | 35 ---- first/mk_target | 41 ----- first/target_comp | 28 --- first/util_comp | 23 --- lang/basic/build.mk | 3 - lang/basic/lib/build.mk | 48 ----- lang/basic/src/build.mk | 44 ----- lang/cem/build.mk | 6 - lang/cem/cemcom.ansi/build.mk | 156 ---------------- lang/cem/cpp.ansi/build.mk | 104 ----------- lang/cem/libcc.ansi/build.mk | 275 ---------------------------- lang/m2/build.mk | 3 - lang/m2/comp/build.mk | 129 ------------- lang/m2/libm2/build.mk | 103 ----------- lang/pc/build.mk | 3 - lang/pc/comp/build.mk | 132 -------------- lang/pc/libpc/build.mk | 92 ---------- mach/i386/build.mk | 53 ------ mach/i80/build.mk | 47 ----- mach/i86/build.mk | 68 ------- mach/m68020/build.mk | 33 ---- mach/powerpc/build.mk | 0 mach/proto/as/build.mk | 43 ----- mach/proto/cg/build.mk | 46 ----- mach/proto/ncg/build.mk | 48 ----- mach/proto/top/build.mk | 15 -- mach/vc4/build.mk | 11 -- modules/h/proto.make | 33 ---- modules/src/alloc/build.mk | 23 --- modules/src/alloc/proto.make | 87 --------- modules/src/assert/proto.make | 43 ----- modules/src/em_code/build.mk | 92 ---------- modules/src/em_code/proto.make | 128 ------------- modules/src/em_data/build.mk | 34 ---- modules/src/em_data/proto.make | 49 ----- modules/src/em_mes/build.mk | 26 --- modules/src/em_mes/proto.make | 110 ------------ modules/src/em_opt/proto.make | 241 ------------------------- modules/src/flt_arith/build.mk | 29 --- modules/src/flt_arith/proto.make | 117 ------------ modules/src/idf/build.mk | 14 -- modules/src/idf/proto.make | 29 --- modules/src/input/build.mk | 20 --- modules/src/input/proto.make | 52 ------ modules/src/malloc/proto.make | 53 ------ modules/src/object/build.mk | 27 --- modules/src/object/proto.make | 95 ---------- modules/src/print/build.mk | 22 --- modules/src/print/proto.make | 62 ------- modules/src/read_em/build.mk | 54 ------ modules/src/read_em/proto.make | 123 ------------- modules/src/string/build.mk | 19 -- modules/src/string/proto.make | 110 ------------ modules/src/system/build.mk | 29 --- modules/src/system/proto.make | 109 ----------- plat/build.mk | 68 ------- plat/cpm/build.mk | 42 ----- plat/linux/libsys/build.mk | 27 --- plat/linux386/build.mk | 28 --- plat/linux68k/build.mk | 25 --- plat/linuxppc/build.mk | 31 ---- plat/pc86/build.mk | 38 ---- plat/rpi/build.mk | 52 ------ util/LLgen/build.mk | 56 ------ util/ack/build.mk | 57 ------ util/ack/proto.make | 187 ------------------- util/amisc/build.mk | 23 --- util/amisc/proto.make | 48 ----- util/arch/build.mk | 24 --- util/arch/proto.make | 62 ------- util/cgg/build.mk | 25 --- util/cmisc/build.mk | 32 ---- util/cmisc/proto.make | 69 ------- util/ego/bo/proto.make | 77 -------- util/ego/build.mk | 205 --------------------- util/ego/ca/proto.make | 89 --------- util/ego/cf/proto.make | 117 ------------ util/ego/cj/proto.make | 76 -------- util/ego/cs/proto.make | 251 -------------------------- util/ego/descr/proto.make | 79 -------- util/ego/em_ego/proto.make | 43 ----- util/ego/ic/proto.make | 137 -------------- util/ego/il/proto.make | 223 ----------------------- util/ego/lv/proto.make | 84 --------- util/ego/ra/proto.make | 234 ------------------------ util/ego/share/proto.make | 241 ------------------------- util/ego/sp/proto.make | 75 -------- util/ego/sr/proto.make | 176 ------------------ util/ego/ud/proto.make | 158 ---------------- util/led/build.mk | 34 ---- util/misc/build.mk | 49 ----- util/ncgg/build.mk | 43 ----- util/ncgg/proto.make | 255 -------------------------- util/opt/build.mk | 84 --------- util/opt/proto.make | 300 ------------------------------- util/topgen/build.mk | 50 ------ util/topgen/proto.make | 60 ------- 113 files changed, 9001 deletions(-) delete mode 100644 first/core.mk delete mode 100755 first/cp_dir delete mode 100755 first/create_dir delete mode 100644 first/em_path.h.src delete mode 100755 first/first delete mode 100755 first/get_answer delete mode 100755 first/get_makepars delete mode 100755 first/get_sys delete mode 100755 first/get_sysvax delete mode 100644 first/install_tail delete mode 100644 first/limit_enquire delete mode 100755 first/limit_impl delete mode 100644 first/lint_params delete mode 100644 first/local.h.src delete mode 100755 first/mk_config delete mode 100755 first/mk_makefile delete mode 100755 first/mk_target delete mode 100644 first/target_comp delete mode 100644 first/util_comp delete mode 100644 lang/basic/build.mk delete mode 100644 lang/basic/lib/build.mk delete mode 100644 lang/basic/src/build.mk delete mode 100644 lang/cem/build.mk delete mode 100644 lang/cem/cemcom.ansi/build.mk delete mode 100644 lang/cem/cpp.ansi/build.mk delete mode 100644 lang/cem/libcc.ansi/build.mk delete mode 100644 lang/m2/build.mk delete mode 100644 lang/m2/comp/build.mk delete mode 100644 lang/m2/libm2/build.mk delete mode 100644 lang/pc/build.mk delete mode 100644 lang/pc/comp/build.mk delete mode 100644 lang/pc/libpc/build.mk delete mode 100644 mach/i386/build.mk delete mode 100644 mach/i80/build.mk delete mode 100644 mach/i86/build.mk delete mode 100644 mach/m68020/build.mk delete mode 100644 mach/powerpc/build.mk delete mode 100644 mach/proto/as/build.mk delete mode 100644 mach/proto/cg/build.mk delete mode 100644 mach/proto/ncg/build.mk delete mode 100644 mach/proto/top/build.mk delete mode 100644 mach/vc4/build.mk delete mode 100644 modules/h/proto.make delete mode 100644 modules/src/alloc/build.mk delete mode 100644 modules/src/alloc/proto.make delete mode 100644 modules/src/assert/proto.make delete mode 100644 modules/src/em_code/build.mk delete mode 100644 modules/src/em_code/proto.make delete mode 100644 modules/src/em_data/build.mk delete mode 100644 modules/src/em_data/proto.make delete mode 100644 modules/src/em_mes/build.mk delete mode 100644 modules/src/em_mes/proto.make delete mode 100644 modules/src/em_opt/proto.make delete mode 100644 modules/src/flt_arith/build.mk delete mode 100644 modules/src/flt_arith/proto.make delete mode 100644 modules/src/idf/build.mk delete mode 100644 modules/src/idf/proto.make delete mode 100644 modules/src/input/build.mk delete mode 100644 modules/src/input/proto.make delete mode 100644 modules/src/malloc/proto.make delete mode 100644 modules/src/object/build.mk delete mode 100644 modules/src/object/proto.make delete mode 100644 modules/src/print/build.mk delete mode 100644 modules/src/print/proto.make delete mode 100644 modules/src/read_em/build.mk delete mode 100644 modules/src/read_em/proto.make delete mode 100644 modules/src/string/build.mk delete mode 100644 modules/src/string/proto.make delete mode 100644 modules/src/system/build.mk delete mode 100644 modules/src/system/proto.make delete mode 100644 plat/build.mk delete mode 100644 plat/cpm/build.mk delete mode 100644 plat/linux/libsys/build.mk delete mode 100644 plat/linux386/build.mk delete mode 100644 plat/linux68k/build.mk delete mode 100644 plat/linuxppc/build.mk delete mode 100644 plat/pc86/build.mk delete mode 100644 plat/rpi/build.mk delete mode 100644 util/LLgen/build.mk delete mode 100644 util/ack/build.mk delete mode 100644 util/ack/proto.make delete mode 100644 util/amisc/build.mk delete mode 100644 util/amisc/proto.make delete mode 100644 util/arch/build.mk delete mode 100644 util/arch/proto.make delete mode 100644 util/cgg/build.mk delete mode 100644 util/cmisc/build.mk delete mode 100644 util/cmisc/proto.make delete mode 100644 util/ego/bo/proto.make delete mode 100644 util/ego/build.mk delete mode 100644 util/ego/ca/proto.make delete mode 100644 util/ego/cf/proto.make delete mode 100644 util/ego/cj/proto.make delete mode 100644 util/ego/cs/proto.make delete mode 100644 util/ego/descr/proto.make delete mode 100644 util/ego/em_ego/proto.make delete mode 100644 util/ego/ic/proto.make delete mode 100644 util/ego/il/proto.make delete mode 100644 util/ego/lv/proto.make delete mode 100644 util/ego/ra/proto.make delete mode 100644 util/ego/share/proto.make delete mode 100644 util/ego/sp/proto.make delete mode 100644 util/ego/sr/proto.make delete mode 100644 util/ego/ud/proto.make delete mode 100644 util/led/build.mk delete mode 100644 util/misc/build.mk delete mode 100644 util/ncgg/build.mk delete mode 100644 util/ncgg/proto.make delete mode 100644 util/opt/build.mk delete mode 100644 util/opt/proto.make delete mode 100644 util/topgen/build.mk delete mode 100644 util/topgen/proto.make diff --git a/Makefile b/Makefile index 33362a470..db2297cb7 100644 --- a/Makefile +++ b/Makefile @@ -98,108 +98,3 @@ $(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES) clean: @rm -rf $(BUILDDIR) -# -#CC = gcc -#AR = ar -#RM = rm -f -#CP = cp -# -#hide = @ -# -#CFLAGS += \ -# -I$(INCDIR) \ -# -Imodules/h \ -# -Ih -# -#LDFLAGS += -# -#ACKFLAGS = -Ih -# -#all: installables -# -#.DELETE_ON_ERROR: -# -#include first/core.mk -# -#include modules/src/object/build.mk -#include modules/src/alloc/build.mk -#include modules/src/input/build.mk -#include modules/src/idf/build.mk -#include modules/src/system/build.mk -#include modules/src/string/build.mk -#include modules/src/print/build.mk -#include modules/src/flt_arith/build.mk -#include modules/src/em_code/build.mk -#include modules/src/em_mes/build.mk -#include modules/src/read_em/build.mk -# -#include util/amisc/build.mk -#include util/cmisc/build.mk -#include util/ack/build.mk -#include util/LLgen/build.mk -#include util/data/build.mk -#include util/opt/build.mk -#include util/ncgg/build.mk -#include util/arch/build.mk -#include util/misc/build.mk -#include util/led/build.mk -#include util/topgen/build.mk -#include util/ego/build.mk -# -#include lang/cem/build.mk -#include lang/basic/build.mk -#include lang/pc/build.mk -#include lang/m2/build.mk -# -#include mach/proto/as/build.mk -#include mach/proto/ncg/build.mk -#include mach/proto/top/build.mk -# -#include plat/linux/liblinux/build.mk -# -#include mach/i80/build.mk -#include mach/i386/build.mk -#include mach/i86/build.mk -#include mach/m68020/build.mk -## include mach/powerpc/build.mk -#include mach/vc4/build.mk -# -#include plat/build.mk -#include plat/pc86/build.mk -#include plat/cpm/build.mk -#include plat/linux386/build.mk -#include plat/linux68k/build.mk -## include plat/linuxppc/build.mk -#include plat/rpi/build.mk -# -#.PHONY: installables -#installables: $(INSTALLABLES) -# @echo "" -# @echo "Build completed successfully." -# -#.PHONY: install -#install: installables -# @echo INSTALLING into $(PREFIX) -# $(hide) tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) -# -#.PHONY: clean -#clean: -# @echo CLEAN -# $(hide) $(RM) $(CLEANABLES) -# -#$(INCDIR)/local.h: -# @echo LOCAL -# @mkdir -p $(dir $@) -# $(hide) echo '#define VERSION 3' > $@ -# $(hide) echo '#define ACKM "$(DEFAULT_PLATFORM)"' >> $@ -# $(hide) echo '#define BIGMACHINE 1' >> $@ -# $(hide) echo '#define SYS_5' >> $@ -# -#$(INCDIR)/em_path.h: -# @echo EM_PATH -# @mkdir -p $(dir $@) -# $(hide) echo '#define TMP_DIR "$(ACK_TEMP_DIR)"' > $@ -# $(hide) echo '#define EM_DIR "$(PREFIX)"' >> $@ -# $(hide) echo '#define ACK_PATH "share/ack/descr"' >> $@ -# -#-include $(DEPENDS) diff --git a/first/core.mk b/first/core.mk deleted file mode 100644 index 6c386d0f5..000000000 --- a/first/core.mk +++ /dev/null @@ -1,219 +0,0 @@ -define reset - $(eval q :=) - $(eval o :=) - $(eval s :=) - $(eval cflags :=) - $(eval ackflags :=) - $(eval ldflags :=) - $(eval objdir :=) -endef - -# --- Host compiler - -define cfile-rule -$o: $s - @echo CC $o - @mkdir -p $(dir $o) - @$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d $s - $(hide) $(CC) $(CFLAGS) $(cflags) -c -o $o $s -endef - -define cfile - $(eval s := $1) - $(eval o := $(OBJDIR)/$(objdir)/$(1:.c=.o)) - $(eval d := $(OBJDIR)/$(objdir)/$(1:.c=.d)) - $(eval DEPENDS += $d) - $(eval CLEANABLES += $o $d) - $(eval q += $o) - $(eval $(cfile-rule)) -endef - -# --- Host preprocessor - -define cppfile-rule -$o: $s - @echo CPP $o - @mkdir -p $(dir $o) - @$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d -x c $s - $(hide) $(CC) $(CFLAGS) $(cflags) -E -P -o $o -x c $s -endef - -define cppfile - $(eval s := $1) - $(eval o := $(OBJDIR)/$(objdir)/$(1:=.m)) - $(eval d := $(OBJDIR)/$(objdir)/$(1:=.d)) - $(eval DEPENDS += $d) - $(eval CLEANABLES += $o $d) - $(eval q += $o) - $(eval $(cppfile-rule)) -endef - -# --- ACK compiler - -define ackfile-rule -$o: $s $(ACK) \ - $(CCOMPILER) \ - $(PLATFORM_$(PLATFORM)) \ - $(ACK_CORE_TOOLS) - @echo ACK $o - @mkdir -p $(dir $o) - $(hide) ACKDIR=$(INSDIR) $(ACK) $(ACKFLAGS) $(ackflags) -m$(PLATFORM) -c -o $o $s -endef - -define ackfile - $(eval s := $1) - $(eval o := $(OBJDIR)/$(objdir)/$(basename $1).o) - $(eval d := $(OBJDIR)/$(objdir)/$(basename $1).d) - $(eval DEPENDS += $d) - $(eval CLEANABLES += $o $d) - $(eval q += $o) - $(eval $(ackfile-rule)) -endef - -# --- Add a raw to the queue - -define rawfile - $(eval q += $1) -endef - -# --- Host compiler linking - -define cprogram-rule -$o: $s - @echo CPROGRAM $o - @mkdir -p $(dir $o) - $(hide) $(CC) $(CFLAGS) $(cflags) $(LDFLAGS) $(ldflags) -o $o $s -endef - -define cprogram - $(eval o := $1) - $(eval s := $q) - $(eval CLEANABLES += $o) - $(eval q := $o) - $(eval $(cprogram-rule)) -endef - -# --- Host library linking - -define clibrary-rule -$o: $s - @echo CLIBRARY $o - @mkdir -p $(dir $o) - @$(RM) $o - $(hide) $(AR) qsc $o $s -endef - -define clibrary - $(eval o := $1) - $(eval s := $q) - $(eval CLEANABLES += $o) - $(eval q := $o) - $(eval $(clibrary-rule)) -endef - -# --- ACK library linking - -define acklibrary-rule -$o: $s $(AAL) - @echo ACKLIBRARY $o - @mkdir -p $(dir $o) - @$(RM) $o - $(hide) $(AAL) q $o $s -endef - -define acklibrary - $(eval o := $1) - $(eval s := $q) - $(eval CLEANABLES += $o) - $(eval q := $o) - $(eval $(acklibrary-rule)) -endef - -# --- Copies a file. - -define copyto-rule -$o: $s - @echo CP $o - @mkdir -p $(dir $o) - $(hide) $(CP) $s $o -endef - -define copyto - $(eval o := $1) - $(eval s := $q) - $(eval CLEANABLES += $o) - $(eval q := $o) - $(eval $(copyto-rule)) -endef - -# --- Installs a file (copies it and adds it to INSTALLABLES). - -define installto-rule -$o: $s - @echo INSTALL $o - @mkdir -p $(dir $o) - $(hide) $(CP) $s $o -endef - -define installto - $(eval o := $1) - $(eval s := $q) - $(eval CLEANABLES += $o) - $(eval INSTALLABLES += $o) - $(eval q := $o) - $(eval $(installto-rule)) -endef - -# --- Adds a dependency for the last object file - -define dependson - $(eval $o: $1) -endef - -# --- Runs yacc. - -# $1: directory to put output files -# $2: input files -# -# Output files are compiled via cfile and queued. - -define yacc-impl - $(eval o := $1/y.tab.c) - $(eval CLEANABLES += $o $1/y.tab.h) - -$o: $2 - @echo YACC $o - @mkdir -p $(dir $o) - $(hide) yacc -t -b $1/y -d $2 - - $(call cfile, $o) - -$1/y.tab.h: $o - -endef - -yacc = $(eval $(call yacc-impl,$1,$2)) - -# --- Runs flex. - -# $1: directory to put output files -# $2: input files -# -# Output files are compiled via cfile and queued. - -define flex-impl - -$(eval o := $1/lex.yy.c) -$(eval CLEANABLES += $o) - -$o: $2 - @echo FLEX $o - @mkdir -p $(dir $o) - $(hide) flex -s -t $2 > $o - -$(call cfile, $o) - -endef - -flex = $(eval $(call flex-impl,$1,$2)) - diff --git a/first/cp_dir b/first/cp_dir deleted file mode 100755 index a5c66906f..000000000 --- a/first/cp_dir +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e -trap "rm -f /tmp/xx$$" 0 1 2 3 15 -case $2 in -/*) target_dir=$2 - ;; -*) target_dir=`pwd`/$2 - ;; -esac -cd $1 -tar cf /tmp/xx$$ . -if [ -d $target_dir ] -then : -else mkdir $target_dir -fi -cd $target_dir -tar xf /tmp/xx$$ diff --git a/first/create_dir b/first/create_dir deleted file mode 100755 index 4f60bfba0..000000000 --- a/first/create_dir +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -if ( cd $1 ) 2>/dev/null -then - : -elif mkdir $1 2>/dev/null -then - : -else - echo $0: could not create directory $1 1>&2 - exit 1 -fi -exit 0 diff --git a/first/em_path.h.src b/first/em_path.h.src deleted file mode 100644 index 3da9a8acc..000000000 --- a/first/em_path.h.src +++ /dev/null @@ -1,11 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* Intended as a common directory for ALL temporary files */ -#define TMP_DIR "/tmp" - -/* Access to the ACK tree and parts thereof */ -#define EM_DIR "/usr/em" /* The root directory for EM stuff */ -#define ACK_PATH "lib/descr" diff --git a/first/first b/first/first deleted file mode 100755 index 0d06efba0..000000000 --- a/first/first +++ /dev/null @@ -1,208 +0,0 @@ -#! /bin/sh - -case $0 in -*/first) - FDIR=`expr $0 : '\(.*\)/first'` - ;; -first) FDIR=. - ;; -esac - -if echo 'a\c' | grep 'c' >/dev/null ; then - : We have BSD-like echo command. - E_FLAG='-n' - E_SFX='' -else - : We have SystemV-like echo command. - E_FLAG='' - E_SFX='\c' -fi -export E_FLAG E_SFX - -echo check write-ability of /tmp ... -if ( >/tmp/aaax.$$ ) -then - rm /tmp/aaax.$$ -else - echo /tmp must exist and be writable. - exit 2 -fi -echo "/tmp ok" - -if [ -f macros ] -then - . macros -fi - -: "Now get system name and directories" -. $FDIR/get_sys - -: "Take action according to the system used" -BM=1 -OLDACM=$ACM -OLDSYS=$SYS -case $SYSNAME in -vax_bsd4_1a) ACM=vax4 ; SYS=BSD4_1 ; BYTE_ORDER=0123 ; MACH=vax4 ;; -vax_bsd4_2) ACM=vax4 ; SYS=BSD4_2 ; BYTE_ORDER=0123 ; MACH=vax4 ;; -vax_sysV_2) ACM=vax4 ; SYS=SYS_5 ; BYTE_ORDER=0123 ; MACH=vax4 ;; -i386) ACM=i386 ; SYS=SYS_5 ; BYTE_ORDER=0123 ; MACH=i386 ;; -sun3) ACM=sun3 ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=m68020 ;; -sun2) ACM=sun2 ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=m68k4 ;; -m68_unisoft|m68k2) ACM=m68k2 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;; -m68_sysV_0|mantra) ACM=mantra ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=m68k4 ;; -m68020) ACM=m68020 ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=m68020 ;; -sparc) ACM=sparc ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=sparc ;; -sparc_solaris) ACM=sparc_solaris ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=sparc_solaris ;; -i86) ACM=i86 ; SYS=SYS_5; BYTE_ORDER=0123 ; MACH=i86 ;; -xenix3) ACM=xenix3 ; SYS=SYS_5; BYTE_ORDER=0123 ; MACH=i86 ;; -minix) ACM=minix ; SYS=V7; BYTE_ORDER=0123 ; MACH=i86 ;; -pmds) ACM=pmds ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;; -pmds4) ACM=pmds4 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k4 ;; -minixST) ACM=minixST ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;; -m68k4) ACM=m68k4 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k4 ;; -*) ACM=XXX ; SYS=XXX ; BYTE_ORDER=XXX ; MACH=XXX ;; -esac - -: do not change the order in MACH_LIST. check limit_enquire first. -MACH_LIST="i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z80 z8000 arm" - -while : -do - for i in $MACH_LIST - do - if [ $i = "$ACM" ] - then break - fi - done - if [ $i = "$ACM" ] - then break - fi - echo "This installation script has no knowledge about $SYSNAME. -You will have to specify the default machine that you want ACK to -compile for. Choices:" - l= - x= - for i in $MACH_LIST - do - l="$l $i" - x=x$x - case $x in - xxxxxxxxxx) echo $l - x= - l= - ;; - esac - done - ACM=$OLDACM - echo $l - echo $E_FLAG "Your choice: [$OLDACM] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$ACM";; - esac - ACM="$ANS" -done -while : -do -case $SYS in -V7|BSD4_1|BSD4_2|SYS_5) - break - ;; -*) - SYS=$OLDSYS - echo 'What kind of Unix is the target system running? -Choices: - V7 for Unix V7, BSD 2.* - BSD4_1 for Berkeley 4.1 - BSD4_2 for Berkeley 4.2, 4.3, SunOs 3, SunOs 4 - SYS_5 for Xenix, System III, System V, SunOs 5' - echo $E_FLAG "Your choice (V7|BSD4_1|BSD4_2|SYS_5): [$OLDSYS] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$SYS";; - esac - SYS="$ANS" - ;; -esac -done -rm -f local.h -sed -e /ACKM/s/'".*"'/'"'$ACM'"'/ -e /BIGMACH/s/'[01]'/$BM/ -e /SYSTEM/s/'^#[ ]*define[ ]*[a-zA-Z_][a-zA-Z0-9_]*'/"# define $SYS"/ < $FDIR/local.h.src >local.h -case $BYTE_ORDER in -XXX) ;; -*) echo '/* Optional definition of BYTE_ORDER: */' >> local.h - echo "#define BYTE_ORDER 0x$BYTE_ORDER" >> local.h - ;; -esac - -echo "Your default machine to compile for is $ACM" - -echo "Installation of the complete ACK takes a long time. Limiting the -number of languages, runtime libraries, back-ends, and assemblers to be -installed may save a lot of time. If you want to install everything, -answer no to the next question. Otherwise, answer yes, and you will be -prompted for details" -while : -do - echo $E_FLAG "Do you want to limit the installation in any way? (y/n) [$LIMIT] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$LIMIT";; - esac - case X$ANS in - Xj*|Xy|X) - LIMIT=y - . $FDIR/limit_enquire - break - ;; - Xn*) . $FDIR/get_sysvax - LIMIT=n - DO_MACHINE_INDEP=y - DO_FAST=n - DISABLE_LANG= - DISABLE_SUP= - if [ $TARGET_HOME = $UTIL_HOME ] - then - case $ACM in - sun3|m68020|i386|vax*) - DO_FAST=y - ;; - esac - fi - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac -done - -. $FDIR/get_makepars - -echo "TARGET_HOME=\"$TARGET_HOME\"; export TARGET_HOME" > macros -echo "UTIL_HOME=\"$UTIL_HOME\"; export UTIL_HOME" >> macros -echo "SRC_HOME=\"$SRC_HOME\"; export SRC_HOME" >> macros -echo "SYSNAME=\"$SYSNAME\"; export SYSNAME" >> macros -echo "ACM=\"$ACM\"; export ACM" >> macros -echo "CURRENT=\"$CURRENT\"; export CURRENT" >> macros -echo "SYS=\"$SYS\"; export SYS" >> macros -echo "LIMIT=\"$LIMIT\"; export LIMIT" >> macros -echo "CONFIG=\"$CONFIG\"; export CONFIG" >> macros -echo "DISABLE_LANG=\"$DISABLE_LANG\"; export DISABLE_LANG" >> macros -echo "DISABLE_SUP=\"$DISABLE_SUP\"; export DISABLE_SUP" >> macros -echo "DO_MACHINE_INDEP=\"$DO_MACHINE_INDEP\"; export DO_MACHINE_INDEP" >> macros -echo "MACH_LIST=\"$MACH_LIST\"; export MACH_LIST" >> macros -echo "SYSVAX=\"$SYSVAX\"; export SYSVAX" >> macros -echo "MACH=\"$MACH\"; export MACH" >> macros -echo "WS=\"$WS\"; export WS" >> macros -echo "PS=\"$PS\"; export PS" >> macros -echo "DO_FAST=\"$DO_FAST\"; export DO_FAST" >> macros - -cat macros $FDIR/install_tail > INSTALL -chmod +x INSTALL - -echo " -A shell-script called 'INSTALL' has been created. Running it -installs ACK. Note that this may take a (very) long time, so run it -in the background, with its output redirected, f.i.: - sh INSTALL > INSTALL.out 2>&1 & -" -exit 0 diff --git a/first/get_answer b/first/get_answer deleted file mode 100755 index 672deccd2..000000000 --- a/first/get_answer +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -if read ANS -then echo -else echo "Sorry, got EOF when reading your answer" - exit 1 -fi diff --git a/first/get_makepars b/first/get_makepars deleted file mode 100755 index cadbf31c9..000000000 --- a/first/get_makepars +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -know_target=0 -case $SYSNAME in -vax*|i386|sun*|sparc*|m68_sysV_0|m68020|mantra|pmds4|m68k4) - WS=4 ; PS=4 - know_target=1 - ;; -m68_unisoft|m68k2|minixST|pmds) - WS=2 ; PS=4 - know_target=1 - ;; -i86|minix|xenix3) - WS=2 ; PS=2 - know_target=1 - ;; -*) trap "rm -f ws.c ws.o a.out t$$" 0 1 2 3 15 - cat > ws.c <<'EOF' -#include -main() -{ - printf("WS=%d ; PS=%d\n", sizeof(int), sizeof(char *)); - exit(0); -} -EOF - if [ $TARGET_HOME = $UTIL_HOME ] && cc ws.c 2>/dev/null - then - : We can find out ourselves what the word-size and - : the pointer-size of the target machine is. - cc ws.c 2>/dev/null - ./a.out > t$$ - . t$$ - rm -f t$$ a.out ws.[co] - else - : we will have to ask installer. - echo $E_FLAG "Please give the word-size of the target-machine (sizeof(int)) in bytes: [$WS] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$WS";; - esac - WS="$ANS" - echo $E_FLAG "Please give the pointer-size of the target-machine (sizeof(char *)) in bytes: [$PS] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$PS";; - esac - PS="$ANS" - fi - ;; -esac - -echo "# Paths: -SRC_HOME = $SRC_HOME -TARGET_HOME = $TARGET_HOME -UTIL_HOME = $UTIL_HOME - -# Machine independent part created? -DO_MACHINE_INDEP = $DO_MACHINE_INDEP - -# Target machine, only needed for fast compilers -MACH = $MACH -" > make_macros - -if [ $TARGET_HOME = $UTIL_HOME ] -then - if [ -f /bin/ranlib -o -f /usr/bin/ranlib -o -f /usr/ucb/ranlib ] - then - sed "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" < $FDIR/target_comp >> make_macros - else - sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros - fi - case $ACM in - sun3|sparc) - ed -s make_macros <<'EOF' -/cc-and-mkdep.sun/s/^..// -w -q -EOF - ;; - esac - cat $FDIR/util_comp >> make_macros -else - case $know_target in - 1) sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "/cc-and-mkdep.ack/s/^..//" -e "s/^CC=cc/CC=acc -m$ACM/" -e "s/^# AR=aal/AR=aal/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros - ;; - *) if [ -f /bin/ranlib -o -f /usr/bin/ranlib -o -f /usr/ucb/ranlib ] - then - sed "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" < $FDIR/target_comp >> make_macros - else - sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros - fi - ;; - esac - sed "s/^#U/U/" < $FDIR/util_comp >> make_macros -fi - -cat $FDIR/lint_params >> make_macros - -echo "A file called 'make_macros' has been created. This file defines some -'make' variables that parameterize all Makefiles in ACK. You may want -to check it before attempting to actually install ACK." -case $know_target in -0) echo "In fact, this installation script does not know much about -your target machine, so expect some things to be wrong" - ;; -esac diff --git a/first/get_sys b/first/get_sys deleted file mode 100755 index c2358e4d2..000000000 --- a/first/get_sys +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/sh - -rm -f em_path.h -echo "You will now be asked for the root directory of the ACK sources. -This directory will not be changed by the installation process. -" -while : -do - echo $E_FLAG "Please give the root of the ACK source tree, -an absolute path: [$SRC_HOME] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$SRC_HOME" ;; - esac - SRC_HOME="$ANS" - case $SRC_HOME in - /*) break; - ;; - *) echo "$SRC_HOME is not an absolute path; try again" - ;; - esac -done -echo "You will now be asked for a configuration directory. This is -the directory in which the compilations will take place. The tree that -resides in it will have the same structure as the ACK source tree, but -the directories will usually only contain Makefiles and .o files. -" -while : -do - echo $E_FLAG "Please give the root of the configuration tree, -an absolute path: [$CONFIG] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$CONFIG";; - esac - CONFIG="$ANS" - case $CONFIG in - /*) break; - ;; - *) echo "$CONFIG is not an absolute path; try again" - ;; - esac -done -echo "You will now be asked for the root directory of the ACK binaries. After -installation, this directory will have subdirectories bin, lib, lib.bin, -man, h, config, include, modules, doc. -Four of these directories will contain stuff that depends on the machine -for which the ACK binaries are made: bin, modules, config, and lib.bin. The -other sub-directories (lib, man, h, include and doc) will contain -machine-independent stuff. -This information may be useful if you want to use ACK on different platforms -and you have a shared file system. See the installation manual. -" -while : -do - echo $E_FLAG "Please give the root of the ACK binaries, -an absolute path: [$TARGET_HOME] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$TARGET_HOME";; - esac - TARGET_HOME="$ANS" - case $TARGET_HOME in - /*) break; - ;; - *) echo "$TARGET_HOME is not an absolute path; try again" - ;; - esac -done -sed -e "/^#define[ ]*EM_DIR/s@\".*\"@\"$TARGET_HOME\"@" <$FDIR/em_path.h.src >em_path.h - -echo "You will now be asked for the type of the system that you want -ACK binaries produced for. This is not neccessarily the system you -run this program on. In this case, if you have not done so already, -you will have to install ACK on the current machine first. -" -echo "Give me the type of the system, the current choice is: -vax_bsd4_1a VAX11 with BSD4.1a -vax_bsd4_2 VAX11 with BSD4.2 -vax_sysV_2 VAX11 with System V.2 -i386 Intel 80386 system running Xenix System V -sun3 Sun 3 M68020 workstation -sun2 Sun 2 M68000 workstation -m68_sysV_0 Motorola 68000 with Uniplus System V.0 Unix -m68020 Motorola M68020 VME131 running Unix System V/68 R2V2.1 -sparc SUN SPARC workstation running SunOs 4 -sparc_solaris SUN SPARC workstation running solaris 2 -ANY Neither of the above -" -echo $E_FLAG "system type: [$SYSNAME] $E_SFX" -. $FDIR/get_answer -case $ANS in -'') ANS="$SYSNAME";; -esac -SYSNAME="$ANS" - -while : -do -echo $E_FLAG "Is this the system you are running on? (y/n) [$CURRENT] $E_SFX" -. $FDIR/get_answer -case $ANS in -'') ANS="$CURRENT";; -esac -case X$ANS in -Xj*|Xy*|X) UTIL_HOME=$TARGET_HOME - CURRENT=y - break - ;; -Xn*) CURRENT=n - echo "You will now be asked for the root directory of ACK on the current machine. -This tree will not be changed by the installation process. -" - while : - do - echo $E_FLAG "Please give the root of a runnable ACK tree, -an absolute path: [$UTIL_HOME] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$UTIL_HOME" ;; - esac - UTIL_HOME="$ANS" - case $UTIL_HOME in - /*) break; - ;; - *) echo "$UTIL_HOME is not an absolute path; try again" - ;; - esac - done - break - ;; -*) echo "I do not understand your answer ($ANS). Try again." - ;; -esac -done - -while : -do -echo "The system to install ACK for is $SYSNAME, -the root of the ACK source tree is $SRC_HOME, -the root of the configuration tree is $CONFIG, -the root of the ACK binary tree to be created is $TARGET_HOME, -and the root of a runnable ACK binary tree is $UTIL_HOME. -If the machine to compile ACK for is the current machine, the last two names -may be identical." -echo $E_FLAG "Are you satisfied with all this? (y/n) $E_SFX" -. $FDIR/get_answer -case X$ANS in -Xj*|Xy*|X) break - ;; -Xn*) echo Ok, I will give you another chance.... - . $0 - break - ;; -*) echo "I do not understand your answer ($ANS). Try again." - ;; -esac -done diff --git a/first/get_sysvax b/first/get_sysvax deleted file mode 100755 index ed92a123c..000000000 --- a/first/get_sysvax +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -while : -do - echo $E_FLAG "Which system-call library do you want to install for the VAX? -You can choose between - libbsd4_1a for Berkeley Unix 4.1 - libbsd4_2 for Berkeley Unix 4.2 or newer, or Ultrix - libsysV_2 for Unix System V -Your choice: [$SYSVAX] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$SYSVAX";; - esac - SYSVAX="$ANS" - case $SYSVAX in - libbsd4_1a|libbsd4_2|libsysV_2) - break - ;; - *) echo "I do not understand your answer ($SYSVAX). Try again" - ;; - esac -done diff --git a/first/install_tail b/first/install_tail deleted file mode 100644 index bcd6d3957..000000000 --- a/first/install_tail +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh - -set -e - -PATH=::$CONFIG/bin:$UTIL_HOME/bin:/usr/ccs/bin:/usr/ucb:$PATH -export PATH - -$SRC_HOME/first/create_dir $CONFIG -$SRC_HOME/first/create_dir $CONFIG/bin - -( - # Slight complication here to ensure that the #! magic at the - # beginning of TakeAction is preserved correctly. - - head -1 $SRC_HOME/TakeAction - echo "PATH=:$CONFIG/bin:$UTIL_HOME/bin:$PATH; export PATH" - tail +2 $SRC_HOME/TakeAction -) > $CONFIG/bin/TakeAction - -sed '/^#PARAMS/r make_macros' < $SRC_HOME/first/mk_makefile > $CONFIG/bin/mk_makefile -cp $SRC_HOME/first/create_dir $CONFIG/bin/create_dir -cp $SRC_HOME/first/cp_dir $CONFIG/bin/cp_dir -chmod +x $CONFIG/bin/* - -$SRC_HOME/first/mk_config - -$SRC_HOME/first/mk_target - -$SRC_HOME/first/limit_impl - -case $SYSNAME in -i386) - ed -s $TARGET_HOME/lib/descr/fe << 'ABC' -1,$s/-D{NAME}/-D{NAME} -DNO_PROTOTYPE/ -w -q -ABC - ;; -esac - -: find varargs include file -: if not present use our own - -if test -f /usr/include/varargs.h -then - : -else - cp $SRC_HOME/include/_tail_cc/varargs.h $TARGET_HOME/modules/h -fi - -case X$SYSVAX in -Xvax_sysV_2) - ed -s $TARGET_HOME/lib/vax4/descr << 'ABC' -/CPP_F/s/$/ -D__USG/ -w -q -ABC - ed -s $CONFIG/mach/vax4/Action << 'ABC' -/libbsd4_2/s/libbsd4_2/libsysV_2/ -w -q -ABC - ( cd $CONFIG/mach/vax4 - for i in libcc libcc.ansi - do - ed -s $i/Makefile << 'ABC' -/BFS/s/BFS/UFS/ -w -q -ABC - done - ) - ;; -Xvax_bsd4_2) - ed -s $TARGET_HOME/lib/vax4/descr << 'ABC' -/CPP_F/s/$/ -D__BSD4_2/ -w -q -ABC - ;; -Xvax_bsd4_1a) - ed -s $CONFIG/mach/vax4/Action << 'ABC' -/libbsd4_2/s/libbsd4_2/libbsd4_1a/ -w -q -ABC - ;; -esac - -: and finally installing ... -cd $CONFIG -set +e -exec TakeAction diff --git a/first/limit_enquire b/first/limit_enquire deleted file mode 100644 index e93e19db3..000000000 --- a/first/limit_enquire +++ /dev/null @@ -1,209 +0,0 @@ -#!/bin/sh - -while : -do - echo "The libraries will end up in the machine-independent part of the -ACK binary tree. You may already have them from a previous ACK installation -on a different machine, in particular if you have an NFS file system. -Therefore, it may not be neccessary to install them again. As this part -of the ACK installation takes the most time, you are given the opportunity -to disable installation of the machine-independent part" - echo $E_FLAG \ - "Do you want to install the machine-independent part? (y/n) [$DO_MACHINE_INDEP] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DO_MACHINE_INDEP" ;; - esac - case X$ANS in - Xj*|Xy*|X) DO_MACHINE_INDEP=y - echo "machine-independent part will be installed" - echo - break - ;; - Xn*) DO_MACHINE_INDEP=n - echo "machine-independent part will not be installed" - echo - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac -done -OLD_DIS_LANG="$DISABLE_LANG" -DISABLE_LANG= -case X$OLD_DIS_LANG in -X) ;; -*) set $OLD_DIS_LANG - ;; -esac -for i in Modula-2 Pascal Occam Basic ANSI-C C Fortran -do - DEF=y - if [ $# != 0 -a X$i = X$1 ] - then - DEF=n - shift - fi - while : - do - echo $E_FLAG "Do you want to install $i? (y/n) [$DEF] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DEF";; - esac - case X$ANS in - Xj*|Xy*) - echo "$i will be installed" - echo - break - ;; - Xn*) DISABLE_LANG=$DISABLE_LANG" $i" - echo "$i will not be installed" - echo - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac - done -done -OLD_DIS_SUP="$DISABLE_SUP" -DISABLE_SUP= -set $MACH_LIST -while test $# != 0 -do - DEF=y - for i in $OLD_DIS_SUP - do - if [ X$i = X$1 ] - then - DEF=n - break - fi - done - while : - do - case $1 in - i86) echo "not installing i86 will disable installation of xenix3 and minix." - ;; - m68k2) echo "not installing m68k2 will disable installation of pmds, minixST, -m68k4, pmds4, sun2, and mantra." - ;; - m68k4) echo "not installing m68k4 will disable installation of pmds4, sun2, and mantra." - ;; - m68020) echo "not installing m68020 will disable installation of sun3." - ;; - esac - echo $E_FLAG "Do you want to install the $1 support? (y/n) [$DEF] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DEF";; - esac - case X$ANS in - Xj*|Xy*) - echo "The $1 support will be installed" - echo - case $1 in - vax4) case $SYSNAME in - vax_bsd4_1a) SYSVAX=libbsd4_1a - ;; - vax_bsd4_2) SYSVAX=libbsd4_2 - ;; - vax_sysV_2) SYSVAX=libsysV_2 - ;; - *) if [ $DO_MACHINE_INDEP = y ] - then - . $FDIR/get_sysvax - fi - ;; - esac - ;; - sparc) shift - ;; - esac - break - ;; - Xn*) DISABLE_SUP=$DISABLE_SUP" $1" - echo "The $1 support will not be installed" - echo - case $1 in - i86) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - m68k2) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - m68k4) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - sparc) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - m68020) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - esac - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac - done - shift -done - -if [ $TARGET_HOME = $UTIL_HOME ] -then - case $ACM in - sun3|m68020|i386|vax*) - while : - do - echo $E_FLAG "Do you want to install the fast compilers? (y/n) [$DO_FAST] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DO_FAST" ;; - esac - case X$ANS in - Xj*|Xy*) - DO_FAST=y - echo "The fast compilers will be installed" - break - ;; - Xn*) - DO_FAST=n - echo "The fast compilers will not be installed" - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac - done - ;; - *) - DO_FAST=n - ;; - esac -else - DO_FAST=n -fi diff --git a/first/limit_impl b/first/limit_impl deleted file mode 100755 index 284f2c15e..000000000 --- a/first/limit_impl +++ /dev/null @@ -1,208 +0,0 @@ -#!/bin/sh - -for i in $DISABLE_LANG -do - ed -s $CONFIG/Action <> Action <> Action < $CONFIG/bin/ack_sys -echo "echo $SYSNAME" >> $CONFIG/bin/ack_sys -chmod +x $CONFIG/bin/ack_sys - -cd $SRC_HOME -find . -type d -perm -555 -print > $CONFIG/dir_list - -cd $CONFIG -for i in mach/*/libsys -do - rm -rf $i -done - -for i in `cat dir_list` -do - create_dir $i - rm -f $i/No* - if [ -f $i/Makefile ] - then - ( cd $i ; if make clean ; then exit 0 ; else exit 0 ; fi ) > /dev/null 2>&1 - fi - if [ -f $SRC_HOME/$i/proto.make ] - then mk_makefile $SRC_HOME/$i/proto.make > $i/Makefile - fi - if [ -f $SRC_HOME/$i/Action ] - then - cd $SRC_HOME/$i - cp Action* $CONFIG/$i - chmod +w $CONFIG/$i/Action* - cd $CONFIG - fi -done - -cd $CONFIG - -for i in lang/cem/cemcom.ansi lang/cem/cemcom lang/m2/comp -do - cp $SRC_HOME/$i/BigPars $CONFIG/$i/Parameters - chmod +w $CONFIG/$i/Parameters -done -for i in lang/pc/comp lang/cem/cpp.ansi -do - cp $SRC_HOME/$i/Parameters $CONFIG/$i/Parameters - chmod +w $CONFIG/$i/Parameters -done - -cd $CONFIG/mach -for i in * -do - if [ -d $i ] - then - if [ -d $i/as ] - then - cd $i/as - mk_makefile $SRC_HOME/mach/proto/as/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - cd ../.. - fi - if [ -d $i/top ] - then - cd $i/top - mk_makefile $SRC_HOME/mach/proto/top/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - cd ../.. - fi - if [ -d $i/cg ] - then - cd $i/cg - mk_makefile $SRC_HOME/mach/proto/cg/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - cd ../.. - fi - if [ -d $i/ncg ] - then - cd $i/ncg - mk_makefile $SRC_HOME/mach/proto/ncg/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - if [ -f $SRC_HOME/mach/$i/ncg/table_dir ] - then - ed -s Makefile < Makefile - cd ../.. - fi - done - for j in libbsd4_1a libbsd4_2 libsysV_2 - do - if [ -d $i/$j ] - then - cd $i/$j - mk_makefile $SRC_HOME/mach/proto/libg/proto.libsys | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" -e "s/libsys/$j/g" > Makefile - cd ../.. - fi - done - for j in libcc libcc.ansi libm2 libpc libbc liboc libf77 - do - create_dir $i/$j - rm -f $i/$j/No* - cd $i/$j - mk_makefile $SRC_HOME/mach/proto/libg/proto.$j | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile - cd ../.. - done - if [ $i = vax4 ] - then : - elif [ -d $i/libsys ] - then : - else - create_dir $i/libsys - rm -f $i/libsys/No* - cd $i/libsys - mk_makefile $SRC_HOME/mach/proto/libg/proto.sysmon | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile - cd ../.. - fi - fi -done diff --git a/first/mk_makefile b/first/mk_makefile deleted file mode 100755 index ae0946bf1..000000000 --- a/first/mk_makefile +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -: '$Id$' - -: This shell script inserts make macros after a line -: starting with #PARAMS in "make_proto", and produces the result on -: standard output. - -trap "rm -f /tmp/mk_mak$$" 0 1 2 3 15 -case $# in -1) ;; -*) echo "Usage: $0 " 1>&2 - exit 1 - ;; -esac - -cp $1 /tmp/mk_mak$$ - -ed -s /tmp/mk_mak$$ << 'EOF' -/^#PARAMS/c -#PARAMS do not remove this line! -. -w -q -EOF -case `ack_sys` in -sparc_solaris) - ed -s /tmp/mk_mak$$ << 'EOF' -g/^EXTRALIB/s/=/= -lelf/ -w -q -EOF - ;; -esac -cat /tmp/mk_mak$$ -exit 0 diff --git a/first/mk_target b/first/mk_target deleted file mode 100755 index 8ab62a4b6..000000000 --- a/first/mk_target +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -set -e - -: machine-dependant stuff - -create_dir $TARGET_HOME -create_dir $TARGET_HOME/config -create_dir $TARGET_HOME/lib.bin -create_dir $TARGET_HOME/modules -create_dir $TARGET_HOME/modules/h -create_dir $TARGET_HOME/bin - -cp local.h em_path.h $TARGET_HOME/config -cp_dir $SRC_HOME/bin $TARGET_HOME/bin -cp $CONFIG/bin/cp_dir $TARGET_HOME/bin/cp_dir -echo "echo $SYSNAME" > $TARGET_HOME/bin/ack_sys -chmod +x $TARGET_HOME/bin/ack_sys - -: machine-independant stuff - -if [ $DO_MACHINE_INDEP = n ] -then - exit 0 -fi - -create_dir $TARGET_HOME/lib -create_dir $TARGET_HOME/etc -create_dir $TARGET_HOME/h -create_dir $TARGET_HOME/include -create_dir $TARGET_HOME/doc - -cp $SRC_HOME/etc/ip_spec.t $TARGET_HOME/etc/ip_spec.t -cp_dir $SRC_HOME/lib $TARGET_HOME/lib -cp_dir $SRC_HOME/h $TARGET_HOME/h -cp_dir $SRC_HOME/include $TARGET_HOME/include - -cd $TARGET_HOME -find . -type f -exec chmod +w {} \; - -exit 0 diff --git a/first/target_comp b/first/target_comp deleted file mode 100644 index db980dcfc..000000000 --- a/first/target_comp +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# compiler set for target machine - -CC=cc# # compiler to be used for compiling ACK - -# always passed to $(CC) -c. -COPTIONS=-O -D_EM_WSIZE=4 -D_EM_PSIZE=4 - -# passed to $(CC) -c when compiling modules. -LIBOPTIONS=# -# LIBOPTIONS=-LIB -L # when $(CC) is ACK - -CC_AND_MKDEP=cc-and-mkdep.all# # when $(CC) is neither ACK or SUN, -# CC_AND_MKDEP=cc-and-mkdep.ack## when $(CC) is an ACK-derived C compiler, -# CC_AND_MKDEP=cc-and-mkdep.sun## when $(CC) is a SUN C compiler - -LDOPTIONS=# # always passed to $(CC) when linking - -SUF=o# # suffix of files produced with $(CC) -c - -AR=ar# # archiver for Unix format objects -# AR=aal# # archiver for ACK .o format objects -# AR=arch# # archiver for ACK .s format objects - -RANLIB=ranlib# # when ranlib required -# RANLIB=:# # when ranlib not required - -LIBSUF=a# # suffix of object libraries diff --git a/first/util_comp b/first/util_comp deleted file mode 100644 index 8f046f627..000000000 --- a/first/util_comp +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# compiler set for producing runnable binaries (possibly using $(UTIL_HOME)). -# This must describe the compiler with which $(UTIL_HOME) has been compiled. -# If $(TARGET_HOME) is identical to $(UTIL_HOME), which usually will be -# the case, this part does not have to be changed. Otherwise (when you are -# cross-compiling ACK), you will have to change this part. Probable -# replacements are given in comments. Maybe the installation script -# has already changed them, but they should be checked to be sure. - -UCC=$(CC) -#UCC=cc# # compiler to be used - -UCOPTIONS=$(COPTIONS) -#UCOPTIONS=-O# # always passed to $(UCC) -c. - -ULDOPTIONS=$(LDOPTIONS) -#ULDOPTIONS=# # always passed to $(UCC) when linking - -USUF=$(SUF) -#USUF=o# # suffix of files produced with $(UCC) -c - -ULIBSUF=$(LIBSUF) -#ULIBSUF=a# # suffix of object libraries for $(UCC) diff --git a/lang/basic/build.mk b/lang/basic/build.mk deleted file mode 100644 index c14c7f358..000000000 --- a/lang/basic/build.mk +++ /dev/null @@ -1,3 +0,0 @@ -include lang/basic/lib/build.mk -include lang/basic/src/build.mk - diff --git a/lang/basic/lib/build.mk b/lang/basic/lib/build.mk deleted file mode 100644 index 9f54a4b4e..000000000 --- a/lang/basic/lib/build.mk +++ /dev/null @@ -1,48 +0,0 @@ -define build-runtime-libbasic-impl - -$(call reset) -$(eval objdir := $(PLATFORM)) - -$(call ackfile, lang/basic/lib/fif.e) -$(call ackfile, lang/basic/lib/fef.e) -$(call ackfile, lang/basic/lib/setline.e) -$(call ackfile, lang/basic/lib/abs.c) -$(call ackfile, lang/basic/lib/asc.c) -$(call ackfile, lang/basic/lib/asrt.c) -$(call ackfile, lang/basic/lib/atn.c) -$(call ackfile, lang/basic/lib/chr.c) -$(call ackfile, lang/basic/lib/conversion.c) -$(call ackfile, lang/basic/lib/error.c) -$(call ackfile, lang/basic/lib/exp.c) -$(call ackfile, lang/basic/lib/file.c) -$(call ackfile, lang/basic/lib/hlt.c) -$(call ackfile, lang/basic/lib/io.c) -$(call ackfile, lang/basic/lib/log.c) -$(call ackfile, lang/basic/lib/mki.c) -$(call ackfile, lang/basic/lib/oct.c) -$(call ackfile, lang/basic/lib/peek.c) -$(call ackfile, lang/basic/lib/power.c) -$(call ackfile, lang/basic/lib/print.c) -$(call ackfile, lang/basic/lib/random.c) -$(call ackfile, lang/basic/lib/read.c) -$(call ackfile, lang/basic/lib/return.c) -$(call ackfile, lang/basic/lib/salloc.c) -$(call ackfile, lang/basic/lib/sgn.c) -$(call ackfile, lang/basic/lib/sin.c) -$(call ackfile, lang/basic/lib/sqt.c) -$(call ackfile, lang/basic/lib/stop.c) -$(call ackfile, lang/basic/lib/string.c) -$(call ackfile, lang/basic/lib/swap.c) -$(call ackfile, lang/basic/lib/trace.c) -$(call ackfile, lang/basic/lib/trap.c) -$(call ackfile, lang/basic/lib/write.c) - -$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libbasic.a) -$(call installto, $(PLATIND)/$(PLATFORM)/libbasic.a) - -endef - -build-runtime-libbasic = $(eval $(build-runtime-libbasic-impl)) - -$(eval RUNTIMES += libbasic) - diff --git a/lang/basic/src/build.mk b/lang/basic/src/build.mk deleted file mode 100644 index 95019babd..000000000 --- a/lang/basic/src/build.mk +++ /dev/null @@ -1,44 +0,0 @@ -D := lang/basic/src - -define build-bem-impl - -$(call reset) -$(eval cflags += -I$(OBJDIR)/$D -I$D) - -$(call cfile, $D/bem.c) -$(call cfile, $D/symbols.c) -$(call cfile, $D/initialize.c) -$(call cfile, $D/compile.c) -$(call cfile, $D/parsepar.c) -$(call cfile, $D/gencode.c) -$(call cfile, $D/util.c) -$(call cfile, $D/graph.c) -$(call cfile, $D/eval.c) -$(call cfile, $D/func.c) - -$(call llgen, $(OBJDIR)/$D, $D/basic.g) - -$(eval g := $(OBJDIR)/$D/tokentab.h) -$(eval $q: $g) -$(eval CLEANABLES += $g) -$g: $D/maketokentab $(OBJDIR)/$D/Lpars.h - @echo TOKENTAB $$@ - @mkdir -p $$(dir $$@) - $(hide) cd $(OBJDIR)/$D && $(abspath $$^) - -$(eval $q: $(OBJDIR)/$D/Lpars.h) -$(eval $q: $(INCDIR)/print.h) - -$(call rawfile, $(LIBEM_MES)) -$(call rawfile, $(LIBEMK)) -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBALLOC)) -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBSTRING)) -$(call rawfile, $(LIBSYSTEM)) -$(call cprogram, $(BINDIR)/em_bem) -$(call installto, $(PLATDEP)/em_bem) - -endef - -$(eval $(build-bem-impl)) diff --git a/lang/cem/build.mk b/lang/cem/build.mk deleted file mode 100644 index 23e0dba95..000000000 --- a/lang/cem/build.mk +++ /dev/null @@ -1,6 +0,0 @@ -include lang/cem/cpp.ansi/build.mk -include lang/cem/cemcom.ansi/build.mk -include lang/cem/libcc.ansi/build.mk - -$(eval CCOMPILER := $(CPPANSI) $(CEMCOMANSI) $(LIBCCANSIHEADERS)) - diff --git a/lang/cem/cemcom.ansi/build.mk b/lang/cem/cemcom.ansi/build.mk deleted file mode 100644 index 1f2b483ec..000000000 --- a/lang/cem/cemcom.ansi/build.mk +++ /dev/null @@ -1,156 +0,0 @@ -D := lang/cem/cemcom.ansi - -define build-cemcom-ansi-allocd-header -$(eval g := $(OBJDIR)/$D/$(strip $1).h) -$g: $D/$(strip $1).str $D/make.allocd - @echo ALLOCD $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.allocd < $$^ > $$@ - -$(eval CLEANABLES += $g) -$(eval $q: $g) -endef - -define build-cemcom-ansi-next -$(eval CLEANABLES += $(OBJDIR)/$D/next.c) -$(OBJDIR)/$D/next.c: $D/make.next $1 - @echo NEXT $$@ - @mkdir -p $$(dir $$@) - $(hide) $$^ > $$@ -$(call cfile, $(OBJDIR)/$D/next.c) - -$(foreach f, $1, $(call build-cemcom-ansi-allocd-header, \ - $(basename $(notdir $f)))) -endef - -define build-cemcom-ansi-impl - -$(call reset) -$(eval cflags += -I$(OBJDIR)/$D -I$D) - -$(call cfile, $D/arith.c) -$(call dependson, $(INCDIR)/flt_arith.h) - -$(call cfile, $D/blocks.c) -$(call dependson, $(INCDIR)/em_codeEK.h) - -$(call cfile, $D/LLlex.c) -$(call cfile, $D/LLmessage.c) - -$(call cfile, $D/ch3.c) -$(call cfile, $D/ch3bin.c) -$(call cfile, $D/ch3mon.c) -$(call cfile, $D/code.c) -$(call cfile, $D/conversion.c) -$(call cfile, $D/cstoper.c) -$(call cfile, $D/dataflow.c) -$(call cfile, $D/declarator.c) -$(call cfile, $D/decspecs.c) -$(call cfile, $D/domacro.c) -$(call cfile, $D/dumpidf.c) -$(call cfile, $D/error.c) -$(call cfile, $D/eval.c) -$(call cfile, $D/expr.c) -$(call cfile, $D/field.c) -$(call cfile, $D/fltcstoper.c) -$(call cfile, $D/idf.c) -$(call cfile, $D/init.c) -$(call cfile, $D/input.c) -$(call cfile, $D/l_comment.c) -$(call cfile, $D/l_ev_ord.c) -$(call cfile, $D/l_lint.c) -$(call cfile, $D/l_misc.c) -$(call cfile, $D/l_outdef.c) -$(call cfile, $D/l_states.c) -$(call cfile, $D/label.c) -$(call cfile, $D/main.c) -$(call cfile, $D/options.c) -$(call cfile, $D/pragma.c) -$(call cfile, $D/proto.c) -$(call cfile, $D/replace.c) -$(call cfile, $D/skip.c) -$(call cfile, $D/stab.c) -$(call cfile, $D/stack.c) -$(call cfile, $D/struct.c) -$(call cfile, $D/switch.c) -$(call cfile, $D/tokenname.c) -$(call cfile, $D/type.c) -$(call cfile, $D/util.c) - -$(call llgen, $(OBJDIR)/$D, \ - $(OBJDIR)/$D/tokenfile.g \ - $D/program.g \ - $D/declar.g \ - $D/expression.g \ - $D/statement.g \ - $D/ival.g) - -$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) -$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c - @echo TOKENFILE $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ - -$(call tabgen, $D/char.tab) - -$(eval $q: $(OBJDIR)/$D/parameters.h) - -$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) -$(OBJDIR)/$D/parameters.h: $D/BigPars - @echo PARAMETERS $$@ - @mkdir -p $$(dir $$@) - $(hide) echo '#ifndef PARAMETERS_H' > $$@ - $(hide) echo '#define PARAMETERS_H' >> $$@ - $(hide) grep -v '^!' < $D/BigPars >> $$@ - $(hide) echo '#endif' >> $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) -$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c - @echo TOKCASE $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.tokcase < $D/tokenname.c > $$@ -$(call cfile, $(OBJDIR)/$D/symbol2str.c) - -$(call build-cemcom-ansi-next, \ - $D/code.str \ - $D/declar.str \ - $D/def.str \ - $D/expr.str \ - $D/field.str \ - $D/estack.str \ - $D/util.str \ - $D/proto.str \ - $D/replace.str \ - $D/idf.str \ - $D/macro.str \ - $D/stack.str \ - $D/stmt.str \ - $D/struct.str \ - $D/switch.str \ - $D/type.str \ - $D/l_brace.str \ - $D/l_state.str \ - $D/l_outdef.str) - -$(eval $q: $(OBJDIR)/$D/Lpars.h) - -$(call rawfile, $(LIBEM_MES)) -$(call rawfile, $(LIBEMK)) -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBINPUT)) -$(call rawfile, $(LIBASSERT)) -$(call rawfile, $(LIBALLOC)) -$(call rawfile, $(LIBFLT_ARITH)) -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBSYSTEM)) -$(call rawfile, $(LIBSTRING)) -$(call cprogram, $(BINDIR)/cemcom.ansi) -$(call installto, $(PLATDEP)/em_cemcom.ansi) -$(eval CEMCOMANSI := $o) - -$(call reset) -$(eval q := $D/cemcom.ansi.1) -$(call installto, $(INSDIR)/share/man/man1/cemcom.6) -endef - -$(eval $(build-cemcom-ansi-impl)) diff --git a/lang/cem/cpp.ansi/build.mk b/lang/cem/cpp.ansi/build.mk deleted file mode 100644 index be03bc958..000000000 --- a/lang/cem/cpp.ansi/build.mk +++ /dev/null @@ -1,104 +0,0 @@ -D := lang/cem/cpp.ansi - -define build-cpp-ansi-allocd-header -$1: $2 $D/make.allocd - @echo ALLOCD $1 - @mkdir -p $(dir $1) - $(hide) $D/make.allocd < $2 > $1 - -$(eval CLEANABLES += $1) -endef - -define build-cpp-ansi-tokfile -$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c - @echo TOKENFILE $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) -endef - -define build-cpp-ansi-tokcase -$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c - @echo TOKCASE $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.tokcase < $D/tokenname.c > $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) -endef - -define build-cpp-ansi-next -$(OBJDIR)/$D/next.c: $D/make.next $D/macro.str $D/replace.str - @echo NEXT $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.next $D/macro.str $D/replace.str > $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/next.c) -endef - -define build-cpp-ansi-impl - $(eval $(call build-cpp-ansi-next)) - $(eval $(call build-cpp-ansi-tokcase)) - $(eval $(call build-cpp-ansi-tokfile)) - $(eval $(call build-cpp-ansi-allocd-header, \ - $(OBJDIR)/$D/macro.h, $D/macro.str \ - )) - $(eval $(call build-cpp-ansi-allocd-header, \ - $(OBJDIR)/$D/replace.h, $D/replace.str \ - )) - - $(call reset) - $(eval cflags += -I$(OBJDIR)/$D -I$D) - - $(call cfile, $D/LLlex.c) - $(call cfile, $D/LLmessage.c) - $(call cfile, $D/ch3bin.c) - $(call cfile, $D/ch3mon.c) - $(call cfile, $D/domacro.c) - $(call cfile, $D/error.c) - $(call cfile, $D/idf.c) - $(call cfile, $D/init.c) - $(call cfile, $D/input.c) - $(call cfile, $D/main.c) - $(call cfile, $D/options.c) - $(call cfile, $D/preprocess.c) - $(call cfile, $D/replace.c) - $(call cfile, $D/skip.c) - $(call cfile, $D/tokenname.c) - $(call cfile, $D/expr.c) - $(call cfile, $(OBJDIR)/$D/symbol2str.c) - $(call cfile, $(OBJDIR)/$D/next.c) - - $(call llgen, $(OBJDIR)/$D, $(OBJDIR)/$D/tokenfile.g $D/expression.g) - - $(call rawfile, $(LIBINPUT)) - $(call rawfile, $(LIBASSERT)) - $(call rawfile, $(LIBALLOC)) - $(call rawfile, $(LIBPRINT)) - $(call rawfile, $(LIBSYSTEM)) - $(call rawfile, $(LIBSTRING)) - - $(call tabgen, $D/char.tab) - - $(eval $q: \ - $(OBJDIR)/$D/macro.h \ - $(OBJDIR)/$D/Lpars.h \ - $(INCDIR)/alloc.h \ - $(INCDIR)/inp_pkg.spec \ - $(INCDIR)/idf_pkg.spec \ - $(OBJDIR)/$D/replace.h \ - $(INCDIR)/system.h \ - $(INCDIR)/inp_pkg.body \ - $(INCDIR)/inp_pkg.spec \ - $(INCDIR)/idf_pkg.body) - - $(call cprogram, $(BINDIR)/cpp.ansi) - $(call installto, $(PLATDEP)/cpp.ansi) - $(eval CPPANSI := $o) - - $(call reset) - $(eval q := $D/ncpp.6) - $(call installto, $(INSDIR)/share/man/man6/cpp.ansi.6) -endef - -$(eval $(build-cpp-ansi-impl)) diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk deleted file mode 100644 index d4300311d..000000000 --- a/lang/cem/libcc.ansi/build.mk +++ /dev/null @@ -1,275 +0,0 @@ -define build-libcc-ansi-headers-install-one-impl - $(call reset) - $(eval q := lang/cem/libcc.ansi/headers/$(strip $1)) - $(call installto, $(PLATIND)/include/ansi/$(strip $1)) - $(eval LIBCCANSIHEADERS += $o) -endef - -define build-libcc-ansi-headers-impl - $(eval g := \ - sys/time.h \ - sys/ioctl.h \ - assert.h \ - ctype.h \ - errno.h \ - fcntl.h \ - float.h \ - limits.h \ - math.h \ - malloc.h \ - setjmp.h \ - signal.h \ - stdarg.h \ - stddef.h \ - stdint.h \ - stdio.h \ - stdlib.h \ - string.h \ - time.h \ - iso646.h \ - stdbool.h \ - locale.h \ - tgmath.h) - - $(eval LIBCCANSIHEADERS :=) - $(foreach f,$g,$(call build-libcc-ansi-headers-install-one-impl,$f)) -endef - -$(eval $(build-libcc-ansi-headers-impl)) - -define build-runtime-libcc-ansi-impl - -$(call reset) -$(eval objdir := $(PLATFORM)) - -# Assert - -$(call ackfile, lang/cem/libcc.ansi/assert/assert.c) - -# CType - -$(call ackfile, lang/cem/libcc.ansi/ctype/tolower.c) -$(call ackfile, lang/cem/libcc.ansi/ctype/toupper.c) -$(call acktabgen, lang/cem/libcc.ansi/ctype/char.tab) - -$(eval g := \ - isalnum.c \ - isalpha.c \ - iscntrl.c \ - isdigit.c \ - isgraph.c \ - islower.c \ - isprint.c \ - ispunct.c \ - isspace.c \ - isupper.c \ - isxdigit.c \ - isascii.c) -$(eval g := $(addprefix $(OBJDIR)/$(objdir)/ctype/, $g)) - -$(wordlist 2, $(words $g), $g): $(firstword $g) -$(firstword $g): lang/cem/libcc.ansi/ctype/genfiles - @echo GENFILES $$@ - @mkdir -p $$(dir $$@) - $(hide) cd $$(dir $$@) && sh $$(abspath $$^) - -$(eval CLEANABLES += $g) -$(foreach f, $g, $(call ackfile, $f)) - -# errno - -$(call ackfile, lang/cem/libcc.ansi/errno/errlist.c) - -# locale - -$(call ackfile, lang/cem/libcc.ansi/locale/localeconv.c) -$(call ackfile, lang/cem/libcc.ansi/locale/setlocale.c) - -# math - -$(call ackfile, lang/cem/libcc.ansi/math/asin.c) -$(call ackfile, lang/cem/libcc.ansi/math/atan2.c) -$(call ackfile, lang/cem/libcc.ansi/math/atan.c) -$(call ackfile, lang/cem/libcc.ansi/math/ceil.c) -$(call ackfile, lang/cem/libcc.ansi/math/fabs.c) -$(call ackfile, lang/cem/libcc.ansi/math/pow.c) -$(call ackfile, lang/cem/libcc.ansi/math/log10.c) -$(call ackfile, lang/cem/libcc.ansi/math/log.c) -$(call ackfile, lang/cem/libcc.ansi/math/sin.c) -$(call ackfile, lang/cem/libcc.ansi/math/sinh.c) -$(call ackfile, lang/cem/libcc.ansi/math/sqrt.c) -$(call ackfile, lang/cem/libcc.ansi/math/tan.c) -$(call ackfile, lang/cem/libcc.ansi/math/tanh.c) -$(call ackfile, lang/cem/libcc.ansi/math/exp.c) -$(call ackfile, lang/cem/libcc.ansi/math/ldexp.c) -$(call ackfile, lang/cem/libcc.ansi/math/fmod.c) -$(call ackfile, lang/cem/libcc.ansi/math/floor.c) -$(call ackfile, lang/cem/libcc.ansi/math/hugeval.c) -$(call ackfile, lang/cem/libcc.ansi/math/frexp.e) -$(call ackfile, lang/cem/libcc.ansi/math/modf.e) -$(call ackfile, lang/cem/libcc.ansi/math/isnan.c) - -# Misc - -$(call ackfile, lang/cem/libcc.ansi/misc/environ.c) -# (lots of stuff missing here, as not being appropriate on modern systems) - -# setjmp - -$(call ackfile, lang/cem/libcc.ansi/setjmp/setjmp.e) - -# signal - -$(call ackfile, lang/cem/libcc.ansi/signal/raise.c) - -# stdio - -$(call ackfile, lang/cem/libcc.ansi/stdio/tmpfile.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/tmpnam.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fopen.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/freopen.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/setbuf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/setvbuf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/perror.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/printf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/sprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/snprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/vfprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/vprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/vsprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/vsnprintf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/doprnt.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/icompute.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fscanf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/scanf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/sscanf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/doscan.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fgetc.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fgets.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/getc.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/getchar.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/gets.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/putc.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/putchar.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fputc.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/puts.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fputs.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/ungetc.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fread.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fwrite.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fgetpos.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fsetpos.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/rewind.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fseek.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/ftell.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/clearerr.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/feof.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/ferror.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fileno.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fltpr.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/ecvt.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fillbuf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fclose.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/flushbuf.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/fflush.c) -$(call ackfile, lang/cem/libcc.ansi/stdio/data.c) - -# stdlib - -$(call ackfile, lang/cem/libcc.ansi/stdlib/abort.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/abs.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/atof.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/atoi.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/atol.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/bsearch.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/div.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/atexit.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/exit.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/getenv.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/setenv.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/labs.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/ldiv.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/mblen.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/mbstowcs.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/mbtowc.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/qsort.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/rand.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/strtod.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/strtol.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/wcstombs.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/wctomb.c) -$(call ackfile, lang/cem/libcc.ansi/stdlib/ext_comp.c) - -$(eval g := $(OBJDIR)/$(objdir)/malloc.c) -$(eval CLEANABLES += $g) -$(eval srcs := \ - READ_ME size_type.h param.h impl.h check.h \ - log.h phys.h mal.c log.c phys.c check.c) -$(eval srcs := $(addprefix lang/cem/libcc.ansi/stdlib/malloc/, $(srcs))) - -$g: lang/cem/libcc.ansi/stdlib/malloc/add_file $(srcs) - @echo MALLOC $g - @mkdir -p $(dir $g) - $(hide) $(RM) $g && for i in $(srcs); do \ - lang/cem/libcc.ansi/stdlib/malloc/add_file $$$$i >> $g; done - -$(call ackfile, $g) - -# String - -$(call ackfile, lang/cem/libcc.ansi/string/memchr.c) -$(call ackfile, lang/cem/libcc.ansi/string/memcmp.c) -$(call ackfile, lang/cem/libcc.ansi/string/memcpy.c) -$(call ackfile, lang/cem/libcc.ansi/string/memmove.c) -$(call ackfile, lang/cem/libcc.ansi/string/memset.c) -$(call ackfile, lang/cem/libcc.ansi/string/strcat.c) -$(call ackfile, lang/cem/libcc.ansi/string/strchr.c) -$(call ackfile, lang/cem/libcc.ansi/string/strcmp.c) -$(call ackfile, lang/cem/libcc.ansi/string/strcoll.c) -$(call ackfile, lang/cem/libcc.ansi/string/strcpy.c) -$(call ackfile, lang/cem/libcc.ansi/string/strcspn.c) -$(call ackfile, lang/cem/libcc.ansi/string/strerror.c) -$(call ackfile, lang/cem/libcc.ansi/string/strncat.c) -$(call ackfile, lang/cem/libcc.ansi/string/strncpy.c) -$(call ackfile, lang/cem/libcc.ansi/string/strrchr.c) -$(call ackfile, lang/cem/libcc.ansi/string/strstr.c) -$(call ackfile, lang/cem/libcc.ansi/string/strlen.c) -$(call ackfile, lang/cem/libcc.ansi/string/strtok.c) -$(call ackfile, lang/cem/libcc.ansi/string/strpbrk.c) -$(call ackfile, lang/cem/libcc.ansi/string/strspn.c) -$(call ackfile, lang/cem/libcc.ansi/string/strncmp.c) -$(call ackfile, lang/cem/libcc.ansi/string/strxfrm.c) -$(call ackfile, lang/cem/libcc.ansi/string/strdup.c) - -# Time - -$(call ackfile, lang/cem/libcc.ansi/time/ctime.c) -$(call ackfile, lang/cem/libcc.ansi/time/asctime.c) -$(call ackfile, lang/cem/libcc.ansi/time/localtime.c) -$(call ackfile, lang/cem/libcc.ansi/time/clock.c) -$(call ackfile, lang/cem/libcc.ansi/time/difftime.c) -$(call ackfile, lang/cem/libcc.ansi/time/gmtime.c) -$(call ackfile, lang/cem/libcc.ansi/time/mktime.c) -$(call ackfile, lang/cem/libcc.ansi/time/strftime.c) -$(call ackfile, lang/cem/libcc.ansi/time/time.c) -$(call ackfile, lang/cem/libcc.ansi/time/tzset.c) -$(call ackfile, lang/cem/libcc.ansi/time/misc.c) - -$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libc.a) -$(call installto, $(PLATIND)/$(PLATFORM)/libc.a) - -# CRT - -$(call reset) -$(eval objdir := $(PLATFORM)) -$(eval ackflags += -Ih) -$(call ackfile, lang/cem/libcc.ansi/head_ac.e) -$(call installto, $(PLATIND)/$(PLATFORM)/c-ansi.o) - -endef - -build-runtime-libcc-ansi = $(eval $(build-runtime-libcc-ansi-impl)) - -$(eval RUNTIMES += libcc-ansi) - diff --git a/lang/m2/build.mk b/lang/m2/build.mk deleted file mode 100644 index 9d3f87be8..000000000 --- a/lang/m2/build.mk +++ /dev/null @@ -1,3 +0,0 @@ -include lang/m2/libm2/build.mk -include lang/m2/comp/build.mk - diff --git a/lang/m2/comp/build.mk b/lang/m2/comp/build.mk deleted file mode 100644 index 18ca8b7dd..000000000 --- a/lang/m2/comp/build.mk +++ /dev/null @@ -1,129 +0,0 @@ -D := lang/m2/comp - -define build-m2-allocd-header -$2: $1 $D/make.allocd - @echo ALLOCD $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.allocd < $$^ > $$@ - -$(eval CLEANABLES += $2) -$(eval $q: $2) -endef - -define build-m2-next -$(eval CLEANABLES += $(OBJDIR)/$D/next.c) -$(OBJDIR)/$D/next.c: $D/make.next $1 - @echo NEXT $$@ - @mkdir -p $$(dir $$@) - $(hide) $$^ > $$@ -$(call cfile, $(OBJDIR)/$D/next.c) - -$(foreach f, $1, $(call build-m2-allocd-header, \ - $f, $(OBJDIR)/$(basename $f).h)) -endef - -define build-m2-impl - -$(call reset) -$(eval cflags += -I$(OBJDIR)/$D -I$D) - -$(call cfile, $D/LLlex.c) -$(call cfile, $D/LLmessage.c) -$(call cfile, $D/chk_expr.c) -$(call cfile, $D/code.c) -$(call cfile, $D/cstoper.c) -$(call cfile, $D/def.c) -$(call cfile, $D/defmodule.c) -$(call cfile, $D/desig.c) -$(call cfile, $D/enter.c) -$(call cfile, $D/error.c) -$(call cfile, $D/idf.c) -$(call cfile, $D/input.c) -$(call cfile, $D/lookup.c) -$(call cfile, $D/main.c) -$(call cfile, $D/misc.c) -$(call cfile, $D/node.c) -$(call cfile, $D/options.c) -$(call cfile, $D/stab.c) -$(call cfile, $D/tokenname.c) -$(call cfile, $D/type.c) -$(call cfile, $D/typequiv.c) -$(call cfile, $D/walk.c) - -$(call llgen, $(OBJDIR)/$D, \ - $(OBJDIR)/$D/tokenfile.g \ - $D/program.g \ - $D/declar.g \ - $D/expression.g \ - $D/statement.g) - -$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) -$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c - @echo TOKENFILE $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ - -$(call tabgen, $D/char.tab) - -$(eval $q: $(OBJDIR)/$D/parameters.h) - -$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) -$(OBJDIR)/$D/parameters.h: $D/BigPars - @echo PARAMETERS $$@ - @mkdir -p $$(dir $$@) - $(hide) echo '#ifndef PARAMETERS_H' > $$@ - $(hide) echo '#define PARAMETERS_H' >> $$@ - $(hide) grep -v '^!' < $$^ >> $$@ - $(hide) echo '#endif' >> $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) -$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c - @echo TOKCASE $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.tokcase < $D/tokenname.c > $$@ -$(call cfile, $(OBJDIR)/$D/symbol2str.c) - -$(call build-m2-next, \ - $D/def.H \ - $D/type.H \ - $D/real.H \ - $D/node.H) - -$(call build-m2-allocd-header, $D/tmpvar.C, $(OBJDIR)/$D/tmpvar.c) -$(call cfile, $(OBJDIR)/$D/tmpvar.c) - -$(call build-m2-allocd-header, $D/casestat.C, $(OBJDIR)/$D/casestat.c) -$(call cfile, $(OBJDIR)/$D/casestat.c) - -$(call build-m2-allocd-header, $D/scope.C, $(OBJDIR)/$D/scope.c) -$(call cfile, $(OBJDIR)/$D/scope.c) - -$(eval $q: $(OBJDIR)/$D/Lpars.h) -$(eval $q: $(INCDIR)/idf_pkg.spec) -$(eval $q: $(INCDIR)/idf_pkg.body) -$(eval $q: $(INCDIR)/inp_pkg.spec) -$(eval $q: $(INCDIR)/inp_pkg.body) -$(eval $q: $(INCDIR)/alloc.h) -$(eval $q: $(INCDIR)/em_codeEK.h) -$(eval $q: $(INCDIR)/print.h) -$(eval $q: $(INCDIR)/system.h) - -$(call rawfile, $(LIBEM_MES)) -$(call rawfile, $(LIBEMK)) -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBINPUT)) -$(call rawfile, $(LIBASSERT)) -$(call rawfile, $(LIBALLOC)) -$(call rawfile, $(LIBFLT_ARITH)) -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBSYSTEM)) -$(call rawfile, $(LIBSTRING)) -$(call cprogram, $(BINDIR)/em_m2) -$(call installto, $(PLATDEP)/em_m2) - -$(call reset) -$(eval q := $D/em_m2.6) -$(call installto, $(INSDIR)/share/man/man6/em_m2.6) -endef - -$(eval $(build-m2-impl)) diff --git a/lang/m2/libm2/build.mk b/lang/m2/libm2/build.mk deleted file mode 100644 index e7c27eac4..000000000 --- a/lang/m2/libm2/build.mk +++ /dev/null @@ -1,103 +0,0 @@ -define build-runtime-libmodula2-impl - -$(call reset) -$(eval objdir := $(PLATFORM)) - -$(call ackfile, lang/m2/libm2/Arguments.c) -$(call ackfile, lang/m2/libm2/ArraySort.mod) -$(call ackfile, lang/m2/libm2/CSP.mod) -$(call ackfile, lang/m2/libm2/Conversion.mod) -$(call ackfile, lang/m2/libm2/EM.e) -$(call ackfile, lang/m2/libm2/InOut.mod) -$(call ackfile, lang/m2/libm2/LtoUset.e) -$(call ackfile, lang/m2/libm2/MathLib0.mod) -$(call ackfile, lang/m2/libm2/Mathlib.mod) -$(call ackfile, lang/m2/libm2/PascalIO.mod) -$(call ackfile, lang/m2/libm2/Processes.mod) -$(call ackfile, lang/m2/libm2/RealConver.mod) -$(call ackfile, lang/m2/libm2/RealInOut.mod) -$(call ackfile, lang/m2/libm2/SYSTEM.c) -$(call ackfile, lang/m2/libm2/Semaphores.mod) -$(call ackfile, lang/m2/libm2/Storage.mod) -$(call ackfile, lang/m2/libm2/StrAss.c) -$(call ackfile, lang/m2/libm2/Streams.mod) -$(call ackfile, lang/m2/libm2/Strings.mod) -$(call ackfile, lang/m2/libm2/Termcap.mod) -$(call ackfile, lang/m2/libm2/Traps.mod) -$(call ackfile, lang/m2/libm2/XXTermcap.c) -$(call ackfile, lang/m2/libm2/absd.c) -$(call ackfile, lang/m2/libm2/absf.e) -$(call ackfile, lang/m2/libm2/absi.c) -$(call ackfile, lang/m2/libm2/absl.c) -$(call ackfile, lang/m2/libm2/blockmove.c) -$(call ackfile, lang/m2/libm2/cap.c) -$(call ackfile, lang/m2/libm2/catch.c) -$(call ackfile, lang/m2/libm2/confarray.c) -$(call ackfile, lang/m2/libm2/dvi.c) -$(call ackfile, lang/m2/libm2/halt.c) -$(call ackfile, lang/m2/libm2/init.c) -$(call ackfile, lang/m2/libm2/load.c) -$(call ackfile, lang/m2/libm2/par_misc.e) -$(call ackfile, lang/m2/libm2/random.mod) -$(call ackfile, lang/m2/libm2/rcka.c) -$(call ackfile, lang/m2/libm2/rcki.c) -$(call ackfile, lang/m2/libm2/rckil.c) -$(call ackfile, lang/m2/libm2/rcku.c) -$(call ackfile, lang/m2/libm2/rckul.c) -$(call ackfile, lang/m2/libm2/sigtrp.c) -$(call ackfile, lang/m2/libm2/stackprio.c) -$(call ackfile, lang/m2/libm2/store.c) -$(call ackfile, lang/m2/libm2/ucheck.c) - -$(eval $q: $(EM_M2)) - -$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libmodula2.a) -$(call installto, $(PLATIND)/$(PLATFORM)/libmodula2.a) - -$(call reset) -$(eval objdir := $(PLATFORM)) -$(call ackfile, lang/m2/libm2/head_m2.e) -$(call installto, $(PLATIND)/$(PLATFORM)/modula2.o) - -endef - -build-runtime-libmodula2 = $(eval $(build-runtime-libmodula2-impl)) - -$(eval RUNTIMES += libmodula2) - -define build-headers-libmodula2-impl - -$(eval g := \ - Arguments.def \ - ArraySort.def \ - ASCII.def \ - Conversion.def \ - CSP.def \ - EM.def \ - Epilogue.def \ - InOut.def \ - MathLib0.def \ - Mathlib.def \ - PascalIO.def \ - Processes.def \ - random.def \ - RealConver.def \ - RealInOut.def \ - Semaphores.def \ - Storage.def \ - Streams.def \ - Strings.def \ - StripUnix.def \ - Termcap.def \ - Traps.def \ - Unix.def \ - XXTermcap.def) - -$(foreach f, $g, \ - $(call reset) \ - $(call rawfile, lang/m2/libm2/$f) \ - $(call installto, $(PLATIND)/include/modula2/$f)) - -endef - -$(eval $(build-headers-libmodula2-impl)) diff --git a/lang/pc/build.mk b/lang/pc/build.mk deleted file mode 100644 index 82b8f2d5f..000000000 --- a/lang/pc/build.mk +++ /dev/null @@ -1,3 +0,0 @@ -include lang/pc/libpc/build.mk -include lang/pc/comp/build.mk - diff --git a/lang/pc/comp/build.mk b/lang/pc/comp/build.mk deleted file mode 100644 index c3b4dd918..000000000 --- a/lang/pc/comp/build.mk +++ /dev/null @@ -1,132 +0,0 @@ -D := lang/pc/comp - -define build-pc-allocd-header -$2: $1 $D/make.allocd - @echo ALLOCD $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.allocd < $$^ > $$@ - -$(eval CLEANABLES += $2) -$(eval $q: $2) -endef - -define build-pc-next -$(eval CLEANABLES += $(OBJDIR)/$D/next.c) -$(OBJDIR)/$D/next.c: $D/make.next $1 - @echo NEXT $$@ - @mkdir -p $$(dir $$@) - $(hide) $$^ > $$@ -$(call cfile, $(OBJDIR)/$D/next.c) - -$(foreach f, $1, $(call build-pc-allocd-header, \ - $f, $(OBJDIR)/$(basename $f).h)) -endef - -define build-pc-impl - -$(call reset) -$(eval cflags += -I$(OBJDIR)/$D -I$D -DSTATIC=static) - -$(call cfile, $D/LLlex.c) -$(call cfile, $D/LLmessage.c) -$(call cfile, $D/body.c) -$(call cfile, $D/chk_expr.c) -$(call cfile, $D/code.c) -$(call cfile, $D/cstoper.c) -$(call cfile, $D/def.c) -$(call cfile, $D/desig.c) -$(call cfile, $D/enter.c) -$(call cfile, $D/error.c) -$(call cfile, $D/idf.c) -$(call cfile, $D/input.c) -$(call cfile, $D/label.c) -$(call cfile, $D/lookup.c) -$(call cfile, $D/main.c) -$(call cfile, $D/misc.c) -$(call cfile, $D/node.c) -$(call cfile, $D/options.c) -$(call cfile, $D/progs.c) -$(call cfile, $D/readwrite.c) -$(call cfile, $D/scope.c) -$(call cfile, $D/stab.c) -$(call cfile, $D/tokenname.c) -$(call cfile, $D/type.c) -$(call cfile, $D/typequiv.c) - -$(call llgen, $(OBJDIR)/$D, \ - $(OBJDIR)/$D/tokenfile.g \ - $D/program.g \ - $D/declar.g \ - $D/expression.g \ - $D/statement.g) - -$(eval CLEANABLES += $(OBJDIR)/$D/tokenfile.g) -$(OBJDIR)/$D/tokenfile.g: $D/make.tokfile $D/tokenname.c - @echo TOKENFILE $$@ - @mkdir -p $$(dir $$@) - $(hide) sh $D/make.tokfile < $D/tokenname.c > $$@ - -$(call tabgen, $D/char.tab) - -$(eval $q: $(OBJDIR)/$D/parameters.h) - -$(eval CLEANABLES += $(OBJDIR)/$D/parameters.h) -$(OBJDIR)/$D/parameters.h: $D/Parameters - @echo PARAMETERS $$@ - @mkdir -p $$(dir $$@) - $(hide) echo '#ifndef PARAMETERS_H' > $$@ - $(hide) echo '#define PARAMETERS_H' >> $$@ - $(hide) grep -v '^!' < $$^ >> $$@ - $(hide) echo '#endif' >> $$@ - -$(eval CLEANABLES += $(OBJDIR)/$D/symbol2str.c) -$(OBJDIR)/$D/symbol2str.c: $D/make.tokcase $D/tokenname.c - @echo TOKCASE $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.tokcase < $D/tokenname.c > $$@ -$(call cfile, $(OBJDIR)/$D/symbol2str.c) - -$(call build-pc-next, \ - $D/def.H \ - $D/type.H \ - $D/node.H \ - $D/scope.H \ - $D/desig.H \ - $D/tmpvar.C \ - $D/casestat.C) - -$(call build-pc-allocd-header, $D/tmpvar.C, $(OBJDIR)/$D/tmpvar.c) -$(call cfile, $(OBJDIR)/$D/tmpvar.c) - -$(call build-pc-allocd-header, $D/casestat.C, $(OBJDIR)/$D/casestat.c) -$(call cfile, $(OBJDIR)/$D/casestat.c) - -$(eval $q: $(OBJDIR)/$D/Lpars.h) -$(eval $q: $(INCDIR)/idf_pkg.spec) -$(eval $q: $(INCDIR)/idf_pkg.body) -$(eval $q: $(INCDIR)/inp_pkg.spec) -$(eval $q: $(INCDIR)/inp_pkg.body) -$(eval $q: $(INCDIR)/alloc.h) -$(eval $q: $(INCDIR)/em_codeEK.h) -$(eval $q: $(INCDIR)/print.h) -$(eval $q: $(INCDIR)/system.h) - -$(call rawfile, $(LIBEM_MES)) -$(call rawfile, $(LIBEMK)) -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBINPUT)) -$(call rawfile, $(LIBASSERT)) -$(call rawfile, $(LIBALLOC)) -$(call rawfile, $(LIBFLT_ARITH)) -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBSYSTEM)) -$(call rawfile, $(LIBSTRING)) -$(call cprogram, $(BINDIR)/em_pc) -$(call installto, $(PLATDEP)/em_pc) - -$(call reset) -$(eval q := $D/em_pc.6) -$(call installto, $(INSDIR)/share/man/man6/em_pc.6) -endef - -$(eval $(build-pc-impl)) diff --git a/lang/pc/libpc/build.mk b/lang/pc/libpc/build.mk deleted file mode 100644 index bfb9d545f..000000000 --- a/lang/pc/libpc/build.mk +++ /dev/null @@ -1,92 +0,0 @@ -define build-runtime-libpascal-impl - -$(call reset) -$(eval objdir := $(PLATFORM)) - -$(call ackfile, lang/pc/libpc/abi.c) -$(call ackfile, lang/pc/libpc/abl.c) -$(call ackfile, lang/pc/libpc/abr.c) -$(call ackfile, lang/pc/libpc/arg.c) -$(call ackfile, lang/pc/libpc/ass.c) -$(call ackfile, lang/pc/libpc/asz.c) -$(call ackfile, lang/pc/libpc/atn.c) -$(call ackfile, lang/pc/libpc/bcp.c) -$(call ackfile, lang/pc/libpc/bts.e) -$(call ackfile, lang/pc/libpc/buff.c) -$(call ackfile, lang/pc/libpc/catch.c) -$(call ackfile, lang/pc/libpc/clock.c) -$(call ackfile, lang/pc/libpc/cls.c) -$(call ackfile, lang/pc/libpc/cvt.c) -$(call ackfile, lang/pc/libpc/diag.c) -$(call ackfile, lang/pc/libpc/dis.c) -$(call ackfile, lang/pc/libpc/efl.c) -$(call ackfile, lang/pc/libpc/eln.c) -$(call ackfile, lang/pc/libpc/encaps.e) -$(call ackfile, lang/pc/libpc/exp.c) -$(call ackfile, lang/pc/libpc/fef.e) -$(call ackfile, lang/pc/libpc/fif.e) -$(call ackfile, lang/pc/libpc/get.c) -$(call ackfile, lang/pc/libpc/gto.e) -$(call ackfile, lang/pc/libpc/hlt.c) -$(call ackfile, lang/pc/libpc/hol0.e) -$(call ackfile, lang/pc/libpc/incpt.c) -$(call ackfile, lang/pc/libpc/ini.c) -$(call ackfile, lang/pc/libpc/log.c) -$(call ackfile, lang/pc/libpc/mdi.c) -$(call ackfile, lang/pc/libpc/mdl.c) -$(call ackfile, lang/pc/libpc/new.c) -$(call ackfile, lang/pc/libpc/nfa.c) -$(call ackfile, lang/pc/libpc/nobuff.c) -$(call ackfile, lang/pc/libpc/notext.c) -$(call ackfile, lang/pc/libpc/opn.c) -$(call ackfile, lang/pc/libpc/outcpt.c) -$(call ackfile, lang/pc/libpc/pac.c) -$(call ackfile, lang/pc/libpc/pclose.c) -$(call ackfile, lang/pc/libpc/pcreat.c) -$(call ackfile, lang/pc/libpc/pentry.c) -$(call ackfile, lang/pc/libpc/perrno.c) -$(call ackfile, lang/pc/libpc/pexit.c) -$(call ackfile, lang/pc/libpc/popen.c) -$(call ackfile, lang/pc/libpc/put.c) -$(call ackfile, lang/pc/libpc/rcka.c) -$(call ackfile, lang/pc/libpc/rdc.c) -$(call ackfile, lang/pc/libpc/rdi.c) -$(call ackfile, lang/pc/libpc/rdl.c) -$(call ackfile, lang/pc/libpc/rdr.c) -$(call ackfile, lang/pc/libpc/rf.c) -$(call ackfile, lang/pc/libpc/rln.c) -$(call ackfile, lang/pc/libpc/rnd.c) -$(call ackfile, lang/pc/libpc/sav.e) -$(call ackfile, lang/pc/libpc/sig.e) -$(call ackfile, lang/pc/libpc/sin.c) -$(call ackfile, lang/pc/libpc/sqt.c) -$(call ackfile, lang/pc/libpc/string.c) -$(call ackfile, lang/pc/libpc/trap.e) -$(call ackfile, lang/pc/libpc/trp.e) -$(call ackfile, lang/pc/libpc/unp.c) -$(call ackfile, lang/pc/libpc/uread.c) -$(call ackfile, lang/pc/libpc/uwrite.c) -$(call ackfile, lang/pc/libpc/wdw.c) -$(call ackfile, lang/pc/libpc/wf.c) -$(call ackfile, lang/pc/libpc/wrc.c) -$(call ackfile, lang/pc/libpc/wrf.c) -$(call ackfile, lang/pc/libpc/wri.c) -$(call ackfile, lang/pc/libpc/wrl.c) -$(call ackfile, lang/pc/libpc/wrr.c) -$(call ackfile, lang/pc/libpc/wrs.c) -$(call ackfile, lang/pc/libpc/wrz.c) - -$(call acklibrary, $(LIBDIR)/$(PLATFORM)/libpascal.a) -$(call installto, $(PLATIND)/$(PLATFORM)/libpascal.a) - -$(call reset) -$(eval objdir := $(PLATFORM)) -$(call ackfile, lang/pc/libpc/head_pc.e) -$(call installto, $(PLATIND)/$(PLATFORM)/pascal.o) - -endef - -build-runtime-libpascal = $(eval $(build-runtime-libpascal-impl)) - -$(eval RUNTIMES += libpascal) - diff --git a/mach/i386/build.mk b/mach/i386/build.mk deleted file mode 100644 index acd5e51eb..000000000 --- a/mach/i386/build.mk +++ /dev/null @@ -1,53 +0,0 @@ -arch-libem-i386 = \ - adi.s \ - and.s \ - blm.s \ - cii.s \ - cms.s \ - com.s \ - csa4.s \ - csb4.s \ - cuu.s \ - dup.s \ - dvi.s \ - dvu.s \ - error.s \ - exg.s \ - fp8087.s \ - fat.s \ - gto.s \ - iaar.s \ - ilar.s \ - inn.s \ - ior.s \ - isar.s \ - lar4.s \ - loi.s \ - mli.s \ - mon.s \ - ngi.s \ - nop.s \ - print.s \ - rck.s \ - rmi.s \ - rmu.s \ - rol.s \ - ror.s \ - sar4.s \ - sbi.s \ - set.s \ - sli.s \ - sri.s \ - sti.s \ - strhp.s \ - trp.s \ - unknown.s \ - xor.s - -arch-libend-i386 = \ - edata.s \ - em_end.s \ - end.s \ - etext.s - - diff --git a/mach/i80/build.mk b/mach/i80/build.mk deleted file mode 100644 index ce9b07c67..000000000 --- a/mach/i80/build.mk +++ /dev/null @@ -1,47 +0,0 @@ -arch-libem-i80 = \ - aar2.s \ - adi4.s \ - and.s \ - blm.s \ - cii.s \ - cmi4.s \ - cms.s \ - com.s \ - csa.s \ - csb.s \ - dup.s \ - dvi2.s \ - exg.s \ - flp.s \ - inn.s \ - ior.s \ - lar2.s \ - mli2.s \ - mli4.s \ - mlu2.s \ - ngi4.s \ - nop.s \ - rol4.s \ - ror4.s \ - sar2.s \ - sbi4.s \ - set.s \ - set2.s \ - sli2.s \ - sli4.s \ - sri2.s \ - sri4.s \ - xor.s \ - loi.s \ - sti.s \ - dvi4.s \ - rck.s - -arch-libend-i80 = \ - edata.s \ - em_end.s \ - end.s \ - etext.s - -arch-top-i80 = yes - diff --git a/mach/i86/build.mk b/mach/i86/build.mk deleted file mode 100644 index 1613b651f..000000000 --- a/mach/i86/build.mk +++ /dev/null @@ -1,68 +0,0 @@ -arch-libem-i86 := \ - adi.s \ - and.s \ - cii.s \ - cms.s \ - cmi4.s \ - cmu4.s \ - com.s \ - csa2.s \ - csb2.s \ - csa4.s \ - csb4.s \ - cuu.s \ - dup.s \ - dvi.s \ - dvi4.s \ - dvu.s \ - dvu4.s \ - exg.s \ - fp8087.s \ - gto.s \ - iaar.s \ - ilar.s \ - inn.s \ - ior.s \ - isar.s \ - lar2.s \ - loi.s \ - mli.s \ - mli4.s \ - mon.s \ - ngi.s \ - nop.s \ - rck.s \ - rmi.s \ - rmi4.s \ - rmu.s \ - rmu4.s \ - rol.s \ - ror.s \ - sar2.s \ - sbi.s \ - set.s \ - sli.s \ - sri.s \ - sti.s \ - strhp.s \ - xor.s \ - error.s \ - unknown.s \ - fat.s \ - trp.s \ - print.s \ - ret6.s \ - ret8.s \ - lfr6.s \ - lfr8.s \ - retarea.s \ - blm.s \ - return.s - -arch-libend-i86 = \ - edata.s \ - em_end.s \ - end.s \ - etext.s - - diff --git a/mach/m68020/build.mk b/mach/m68020/build.mk deleted file mode 100644 index 5dac37653..000000000 --- a/mach/m68020/build.mk +++ /dev/null @@ -1,33 +0,0 @@ -arch-libem-m68020 = \ - fp68881.s \ - aar.s \ - lar.s \ - sar.s \ - csa.s \ - csb.s \ - shp.s \ - set.s \ - inn.s \ - fat.s \ - trp.s \ - trpstr.c \ - mon.s \ - nop.s \ - dia.s \ - cii.s \ - cuu.s \ - cmi.s \ - cms.s \ - cmu.s \ - cvf.s \ - exg.s \ - los.s \ - sts.s - -arch-libend-m68020 = \ - edata.s \ - em_end.s \ - end.s \ - etext.s - - diff --git a/mach/powerpc/build.mk b/mach/powerpc/build.mk deleted file mode 100644 index e69de29bb..000000000 diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk deleted file mode 100644 index 64c75cf91..000000000 --- a/mach/proto/as/build.mk +++ /dev/null @@ -1,43 +0,0 @@ -define build-as-impl - $(call reset) - - $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D) - $(eval objdir := $(ARCH)) - - $(call cfile, mach/proto/as/comm3.c) - $(call dependson, $(OBJDIR)/$D/y.tab.h) - - $(call cfile, mach/proto/as/comm4.c) - $(call dependson, $(OBJDIR)/$D/y.tab.h) - - $(call cfile, mach/proto/as/comm5.c) - $(call dependson, $(OBJDIR)/$D/y.tab.h) - - $(call cfile, mach/proto/as/comm6.c) - $(call dependson, $(OBJDIR)/$D/y.tab.h) - - $(call cfile, mach/proto/as/comm7.c) - $(call dependson, $(OBJDIR)/$D/y.tab.h) - - $(call cfile, mach/proto/as/comm8.c) - $(call dependson, $(OBJDIR)/$D/y.tab.h) - - $(call yacc, $(OBJDIR)/$D, $(OBJDIR)/$D/preprocessed-comm2.y) - - $(call rawfile, $(LIBOBJECT)) - $(call cprogram, $(BINDIR)/$(PLATFORM)/as) - $(call installto, $(PLATDEP)/$(PLATFORM)/as) - - $(call reset) - $(eval cflags += -Imach/$(ARCH)/as -I$(OBJDIR)/$D) - $(eval objdir := $(ARCH)) - $(call cppfile, mach/proto/as/comm2.y) - $(call installto, $(OBJDIR)/$D/preprocessed-comm2.y) - - $(call reset) - $(call rawfile, man/$(ARCH)_as.6) - $(call installto, $(INSDIR)/share/man/man6/$(ARCH)_as.6) -endef - -build-as = $(eval $(build-as-impl)) - diff --git a/mach/proto/cg/build.mk b/mach/proto/cg/build.mk deleted file mode 100644 index 2327009e0..000000000 --- a/mach/proto/cg/build.mk +++ /dev/null @@ -1,46 +0,0 @@ -define build-cg-impl - -$(call reset) - -$(eval cflags += -Imach/$(ARCH)/cg -I$(OBJDIR)/$D -Imach/proto/cg) -$(eval objdir := $(ARCH)) - -$(call cfile, mach/proto/cg/codegen.c) -$(call cfile, mach/proto/cg/compute.c) -$(call cfile, mach/proto/cg/equiv.c) -$(call cfile, mach/proto/cg/fillem.c) -$(call cfile, mach/proto/cg/gencode.c) -$(call cfile, mach/proto/cg/glosym.c) -$(call cfile, mach/proto/cg/main.c) -$(call cfile, mach/proto/cg/move.c) -$(call cfile, mach/proto/cg/nextem.c) -$(call cfile, mach/proto/cg/reg.c) -$(call cfile, mach/proto/cg/regvar.c) -$(call cfile, mach/proto/cg/salloc.c) -$(call cfile, mach/proto/cg/state.c) -$(call cfile, mach/proto/cg/subr.c) -$(call cfile, mach/proto/cg/var.c) - -$(eval $q: $(OBJDIR)/$D/tables.h) -$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.c) -$(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h -$(OBJDIR)/$D/tables.h: $(CGG) $(CPPANSI) mach/$(ARCH)/cg/table - @echo CGG $$@ - @mkdir -p $$(dir $$@) - $(hide) cd $$(dir $$@) && \ - $(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/cg) $(abspath mach/$(ARCH)/cg/table) | $(abspath $(CGG)) - -$(call cfile, $(OBJDIR)/$D/tables.c) - -$(eval $q: $(INCDIR)/flt_arith.h) - -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBFLT_ARITH)) - -$(call cprogram, $(BINDIR)/$(PLATFORM)/cg) -$(call installto, $(PLATDEP)/$(PLATFORM)/cg) - -endef - -build-cg = $(eval $(build-cg-impl)) - diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk deleted file mode 100644 index 0056452c1..000000000 --- a/mach/proto/ncg/build.mk +++ /dev/null @@ -1,48 +0,0 @@ -define build-ncg-impl - -$(call reset) - -$(eval cflags += -Imach/$(ARCH)/ncg -I$(OBJDIR)/$D -Imach/proto/ncg) -$(eval objdir := $(ARCH)) - -$(call cfile, mach/proto/ncg/codegen.c) -$(call cfile, mach/proto/ncg/compute.c) -$(call cfile, mach/proto/ncg/equiv.c) -$(call cfile, mach/proto/ncg/fillem.c) -$(call cfile, mach/proto/ncg/gencode.c) -$(call cfile, mach/proto/ncg/glosym.c) -$(call cfile, mach/proto/ncg/label.c) -$(call cfile, mach/proto/ncg/main.c) -$(call cfile, mach/proto/ncg/move.c) -$(call cfile, mach/proto/ncg/nextem.c) -$(call cfile, mach/proto/ncg/reg.c) -$(call cfile, mach/proto/ncg/regvar.c) -$(call cfile, mach/proto/ncg/salloc.c) -$(call cfile, mach/proto/ncg/state.c) -$(call cfile, mach/proto/ncg/subr.c) -$(call cfile, mach/proto/ncg/var.c) - -$(eval $q: $(OBJDIR)/$D/tables.h) -$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.c) -$(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h -$(OBJDIR)/$D/tables.h: $(NCGG) $(CPPANSI) mach/$(ARCH)/ncg/table - @echo NCGG $$@ - @mkdir -p $$(dir $$@) - $(hide) cd $$(dir $$@) && \ - $(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/ncg) $(abspath mach/$(ARCH)/ncg/table) | $(abspath $(NCGG)) - $(hide) mv $(OBJDIR)/$D/tables.H $(OBJDIR)/$D/tables.h - -$(call cfile, $(OBJDIR)/$D/tables.c) - -$(eval $q: $(INCDIR)/flt_arith.h) - -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBFLT_ARITH)) - -$(call cprogram, $(BINDIR)/$(PLATFORM)/ncg) -$(call installto, $(PLATDEP)/$(PLATFORM)/ncg) - -endef - -build-ncg = $(eval $(build-ncg-impl)) - diff --git a/mach/proto/top/build.mk b/mach/proto/top/build.mk deleted file mode 100644 index 56f41c276..000000000 --- a/mach/proto/top/build.mk +++ /dev/null @@ -1,15 +0,0 @@ -define build-top-impl - $(call reset) - $(eval cflags += -I$(OBJDIR)/$(PLATFORM)/top) - - $(call cfile, mach/proto/top/queue.c) - $(call cfile, mach/proto/top/top.c) - $(eval $q: $(OBJDIR)/$(PLATFORM)/top/gen.h) - - $(call topgen, $(OBJDIR)/$(PLATFORM)/top, mach/$(ARCH)/top/table) - - $(call cprogram, $(OBJDIR)/$(PLATFORM)/top/top) - $(call installto, $(PLATDEP)/$(PLATFORM)/top) -endef - -build-top = $(eval $(build-top-impl)) diff --git a/mach/vc4/build.mk b/mach/vc4/build.mk deleted file mode 100644 index b7ca860d8..000000000 --- a/mach/vc4/build.mk +++ /dev/null @@ -1,11 +0,0 @@ -arch-libem-vc4 := \ - csa.s \ - csb.s - -arch-libend-vc4 = \ - edata.s \ - em_end.s \ - end.s \ - etext.s - - diff --git a/modules/h/proto.make b/modules/h/proto.make deleted file mode 100644 index 48f61cdc4..000000000 --- a/modules/h/proto.make +++ /dev/null @@ -1,33 +0,0 @@ -# $Id$ - -#PARAMS do not delete this line! - -SRC_DIR = $(SRC_HOME)/modules/h -MOD_DIR = $(TARGET_HOME)/modules -FILES = \ - $(SRC_DIR)/ansi.h \ - $(SRC_DIR)/em.h \ - $(SRC_DIR)/em_arith.h \ - $(SRC_DIR)/em_code.h \ - $(SRC_DIR)/em_label.h \ - $(SRC_DIR)/em_codeCE.h \ - $(SRC_DIR)/emO_code.h \ - $(SRC_DIR)/em_codeO.h \ - $(SRC_DIR)/em_mesX.h - -all: - -install: all - -mkdir $(MOD_DIR)/h - cp $(FILES) $(MOD_DIR)/h - -cmp: all - -pr: - @pr $(SRC_DIR)/proto.make $(FILES) - -opr: - make pr | opr - -clean: -lintlib: diff --git a/modules/src/alloc/build.mk b/modules/src/alloc/build.mk deleted file mode 100644 index 808dcca4a..000000000 --- a/modules/src/alloc/build.mk +++ /dev/null @@ -1,23 +0,0 @@ -D := modules/src/alloc - -define build-liballoc-impl - $(call reset) - $(call cfile, $D/Malloc.c) - $(call cfile, $D/Salloc.c) - $(call cfile, $D/Srealloc.c) - $(call cfile, $D/Realloc.c) - $(call cfile, $D/botch.c) - $(call cfile, $D/clear.c) - $(call cfile, $D/st_alloc.c) - $(call cfile, $D/std_alloc.c) - $(call cfile, $D/No_Mem.c) - $(call clibrary, $(LIBDIR)/liballoc.a) - LIBALLOC := $o - - $(call reset) - $(eval q := $D/alloc.h) - $(call copyto, $(INCDIR)/alloc.h) -endef - -$(eval $(build-liballoc-impl)) - diff --git a/modules/src/alloc/proto.make b/modules/src/alloc/proto.make deleted file mode 100644 index bd419ce71..000000000 --- a/modules/src/alloc/proto.make +++ /dev/null @@ -1,87 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/alloc -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) - -CSRC = $(SRC_DIR)/Malloc.c\ - $(SRC_DIR)/Salloc.c\ - $(SRC_DIR)/Srealloc.c\ - $(SRC_DIR)/Realloc.c\ - $(SRC_DIR)/botch.c\ - $(SRC_DIR)/clear.c\ - $(SRC_DIR)/st_alloc.c\ - $(SRC_DIR)/std_alloc.c \ - $(SRC_DIR)/No_Mem.c -SOURCES = $(SRC_DIR)/alloc.h\ - $(CSRC) - -OBJECTS = botch.$(SUF) clear.$(SUF) st_alloc.$(SUF) Malloc.$(SUF) \ - Salloc.$(SUF) \ - Srealloc.$(SUF) Realloc.$(SUF) std_alloc.$(SUF) No_Mem.$(SUF) - - -LIBALLOC = liballoc.$(LIBSUF) - -all: $(LIBALLOC) - -$(LIBALLOC): $(OBJECTS) - rm -f $(LIBALLOC) - $(AR) r $(LIBALLOC) $(OBJECTS) - $(RANLIB) $(LIBALLOC) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBALLOC) $(MOD_DIR)/lib/$(LIBALLOC) - $(RANLIB) $(MOD_DIR)/lib/$(LIBALLOC) - cp $(SRC_DIR)/alloc.h $(MOD_DIR)/h/alloc.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/alloc.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBALLOC) $(MOD_DIR)/lib/$(LIBALLOC) - -cmp $(SRC_DIR)/alloc.h $(MOD_DIR)/h/alloc.h - -pr: - @pr $(SRC_DIR)/proto.make $(SOURCES) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) alloc $(MOD_DIR)/lib $(INCLUDES) $(CSRC) - -st_alloc.$(SUF): $(SRC_DIR)/alloc.h $(SRC_DIR)/st_alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/st_alloc.c - -std_alloc.$(SUF): $(SRC_DIR)/alloc.h $(SRC_DIR)/std_alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/std_alloc.c - -Malloc.$(SUF): $(SRC_DIR)/alloc.h $(SRC_DIR)/Malloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Malloc.c - -No_Mem.$(SUF): $(SRC_DIR)/No_Mem.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/No_Mem.c - -Realloc.$(SUF): $(SRC_DIR)/Realloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Realloc.c - -Salloc.$(SUF): $(SRC_DIR)/Salloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Salloc.c - -Srealloc.$(SUF): $(SRC_DIR)/Srealloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Srealloc.c - -botch.$(SUF): $(SRC_DIR)/botch.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/botch.c - -clear.$(SUF): $(SRC_DIR)/clear.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/clear.c diff --git a/modules/src/assert/proto.make b/modules/src/assert/proto.make deleted file mode 100644 index cf63c41f2..000000000 --- a/modules/src/assert/proto.make +++ /dev/null @@ -1,43 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/assert -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -all: libassert.$(LIBSUF) - -libassert.$(LIBSUF): BadAssert.$(SUF) - $(AR) r libassert.$(LIBSUF) BadAssert.$(SUF) - $(RANLIB) libassert.$(LIBSUF) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp libassert.$(LIBSUF) $(MOD_DIR)/lib/libassert.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libassert.$(LIBSUF) - cp $(SRC_DIR)/assert.h $(MOD_DIR)/h/assert.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/assert.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libassert.$(LIBSUF) $(MOD_DIR)/lib/libassert.$(LIBSUF) - -cmp $(SRC_DIR)/assert.h $(MOD_DIR)/h/assert.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/assert.h $(SRC_DIR)/BadAssert.c - -opr: - make pr | opr - -clean: - rm -f *.$(LIBSUF) *.$(SUF) - -lintlib: - $(MK_LINT_LIB) assert $(MOD_DIR)/lib $(INCLUDES) $(SRC_DIR)/BadAssert.c - -BadAssert.$(SUF): $(SRC_DIR)/BadAssert.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/BadAssert.c diff --git a/modules/src/em_code/build.mk b/modules/src/em_code/build.mk deleted file mode 100644 index 0fca5191c..000000000 --- a/modules/src/em_code/build.mk +++ /dev/null @@ -1,92 +0,0 @@ -D := modules/src/em_code - -# $1 = capital letter for library specialisation (E or K) -# $2 = lowercase letter for library specialisation (e or k) -# $3 = cflags that specalise this library - -define build-em_code-impl - $(call reset) - $(eval cflags += $3) - $(eval objdir := $1) - $(call cfile, $D/bhcst.c) - $(call cfile, $D/bhdlb.c) - $(call cfile, $D/bhdnam.c) - $(call cfile, $D/bhfcon.c) - $(call cfile, $D/bhicon.c) - $(call cfile, $D/bhilb.c) - $(call cfile, $D/bhpnam.c) - $(call cfile, $D/bhucon.c) - $(call cfile, $D/crcst.c) - $(call cfile, $D/crdlb.c) - $(call cfile, $D/crdnam.c) - $(call cfile, $D/crxcon.c) - $(call cfile, $D/crilb.c) - $(call cfile, $D/crpnam.c) - $(call cfile, $D/crscon.c) - $(call cfile, $D/cst.c) - $(call cfile, $D/dfdlb.c) - $(call cfile, $D/dfdnam.c) - $(call cfile, $D/dfilb.c) - $(call cfile, $D/dlb.c) - $(call cfile, $D/dnam.c) - $(call cfile, $D/end.c) - $(call cfile, $D/endarg.c) - $(call cfile, $D/exc.c) - $(call cfile, $D/fcon.c) - $(call cfile, $D/getid.c) - $(call cfile, $D/icon.c) - $(call cfile, $D/ilb.c) - $(call cfile, $D/insert.c) - $(call cfile, $D/internerr.c) - $(call cfile, $D/msend.c) - $(call cfile, $D/op.c) - $(call cfile, $D/opcst.c) - $(call cfile, $D/opdlb.c) - $(call cfile, $D/opdnam.c) - $(call cfile, $D/opilb.c) - $(call cfile, $D/opnarg.c) - $(call cfile, $D/oppnam.c) - $(call cfile, $D/pnam.c) - $(call cfile, $D/pro.c) - $(call cfile, $D/pronarg.c) - $(call cfile, $D/msstart.c) - $(call cfile, $D/psdlb.c) - $(call cfile, $D/psdnam.c) - $(call cfile, $D/pspnam.c) - $(call cfile, $D/scon.c) - $(call cfile, $D/ucon.c) - $(call cfile, $D/C_out.c) - $(call cfile, $D/failed.c) - $(call cfile, $D/em.c) - - $(eval $q: $(INCDIR)/em_codeEK.h) - $(eval $q: $(INCDIR)/em_path.h) - $(eval $q: $(INCDIR)/system.h) - $(eval $q: $(INCDIR)/local.h) - - $(call clibrary, $(LIBDIR)/libem$2.a) - $(eval LIBEM$1 := $o) -endef - -define build-em_code-header-impl -$(OBJDIR)/$D/em_codeEK.h: $D/make.em.gen $D/em.nogen h/em_table - @echo MAKE_EM_GEN $$@ - @mkdir -p $$(dir $$@) - $(hide) $D/make.em.gen h/em_table > $$@ - $(hide) cat $D/em.nogen >> $$@ - -$(call reset) -$(eval q := $(OBJDIR)/$D/em_codeEK.h) -$(eval CLEANABLES += $q) -$(call copyto, $(INCDIR)/em_codeEK.h) - -$(eval CLEANABLES += $o) -$(eval $o: $(INCDIR)/em_pseu.h) - -endef - -$(eval $(call build-em_code-header-impl)) -$(eval $(call build-em_code-impl,E,e, -DREADABLE_EM)) -$(eval $(call build-em_code-impl,K,k, )) - - diff --git a/modules/src/em_code/proto.make b/modules/src/em_code/proto.make deleted file mode 100644 index 60c0bda9b..000000000 --- a/modules/src/em_code/proto.make +++ /dev/null @@ -1,128 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -ETC = $(SRC_HOME)/etc -SRC_DIR = $(SRC_HOME)/modules/src/em_code -MOD_DIR = $(TARGET_HOME)/modules - -INCLUDES = -I. -I$(TARGET_HOME)/h -I$(TARGET_HOME)/config -I$(MOD_DIR)/h -I$(SRC_HOME)/modules/src/read_em -I$(SRC_DIR) -CFLAGS = $(INCLUDES) $(COPTIONS) -SRC = $(SRC_DIR)/bhcst.c\ - $(SRC_DIR)/bhdlb.c\ - $(SRC_DIR)/bhdnam.c\ - $(SRC_DIR)/bhfcon.c\ - $(SRC_DIR)/bhicon.c\ - $(SRC_DIR)/bhilb.c\ - $(SRC_DIR)/bhpnam.c\ - $(SRC_DIR)/bhucon.c\ - $(SRC_DIR)/crcst.c\ - $(SRC_DIR)/crdlb.c\ - $(SRC_DIR)/crdnam.c\ - $(SRC_DIR)/crxcon.c\ - $(SRC_DIR)/crilb.c\ - $(SRC_DIR)/crpnam.c\ - $(SRC_DIR)/crscon.c \ - $(SRC_DIR)/cst.c\ - $(SRC_DIR)/dfdlb.c\ - $(SRC_DIR)/dfdnam.c\ - $(SRC_DIR)/dfilb.c\ - $(SRC_DIR)/dlb.c\ - $(SRC_DIR)/dnam.c\ - $(SRC_DIR)/end.c\ - $(SRC_DIR)/endarg.c \ - $(SRC_DIR)/exc.c\ - $(SRC_DIR)/fcon.c\ - $(SRC_DIR)/getid.c\ - $(SRC_DIR)/icon.c\ - $(SRC_DIR)/ilb.c\ - $(SRC_DIR)/insert.c\ - $(SRC_DIR)/internerr.c \ - $(SRC_DIR)/msend.c\ - $(SRC_DIR)/op.c\ - $(SRC_DIR)/opcst.c\ - $(SRC_DIR)/opdlb.c\ - $(SRC_DIR)/opdnam.c\ - $(SRC_DIR)/opilb.c\ - $(SRC_DIR)/opnarg.c\ - $(SRC_DIR)/oppnam.c\ - $(SRC_DIR)/pnam.c \ - $(SRC_DIR)/pro.c\ - $(SRC_DIR)/pronarg.c\ - $(SRC_DIR)/msstart.c\ - $(SRC_DIR)/psdlb.c\ - $(SRC_DIR)/psdnam.c\ - $(SRC_DIR)/pspnam.c\ - $(SRC_DIR)/scon.c\ - $(SRC_DIR)/ucon.c \ - $(SRC_DIR)/C_out.c\ - $(SRC_DIR)/failed.c\ - $(SRC_DIR)/em.c - -OBS = failed.$(SUF) insert.$(SUF) internerr.$(SUF) getid.$(SUF) - -all: em_codeEK.h libeme.$(LIBSUF) libemk.$(LIBSUF) em_code.3 - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp libeme.$(LIBSUF) $(MOD_DIR)/lib/libeme.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libeme.$(LIBSUF) - cp libemk.$(LIBSUF) $(MOD_DIR)/lib/libemk.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libemk.$(LIBSUF) - cp em_codeEK.h $(MOD_DIR)/h/em_codeEK.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage em_code.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libeme.$(LIBSUF) $(MOD_DIR)/lib/libeme.$(LIBSUF) - -cmp libemk.$(LIBSUF) $(MOD_DIR)/lib/libemk.$(LIBSUF) - -cmp em_codeEK.h $(MOD_DIR)/h/em_codeEK.h - -em_code.3: $(SRC_DIR)/em_code.3X - -sh -c 'tbl < $(SRC_DIR)/em_code.3X > em_code.3' - -sh -c 'if test -s em_code.3 ; then : ; else cp $(SRC_DIR)/em_code.3X em_code.3 ; fi ' - -libeme.$(LIBSUF): $(SRC_DIR)/em_private.h $(SRC) $(OBS) - cc="$(CC)"; suf="$(SUF)"; libsuf="$(LIBSUF)"; cflags="-c -DREADABLE_EM $(CFLAGS)"; ar="$(AR)"; export cc ar suf libsuf cflags; sh $(SRC_DIR)/make.sh e $(SRC) - $(RANLIB) libeme.$(LIBSUF) - -libemk.$(LIBSUF): $(SRC_DIR)/em_private.h $(SRC) $(OBS) - cc="$(CC)"; suf="$(SUF)"; libsuf="$(LIBSUF)"; cflags="-c $(CFLAGS)"; ar="$(AR)"; export cc ar suf libsuf cflags; sh $(SRC_DIR)/make.sh k $(SRC) - $(RANLIB) libemk.$(LIBSUF) - -em_codeEK.h: $(SRC_DIR)/make.em.gen $(ETC)/em_table $(SRC_DIR)/em.nogen - $(SRC_DIR)/make.em.gen $(ETC)/em_table > em_codeEK.h - cat $(SRC_DIR)/em.nogen >> em_codeEK.h - -pr: - @pr $(SRC_DIR)/proto.make \ - $(SRC_DIR)/em.nogen \ - $(SRC_DIR)/make.em.gen \ - $(SRC_DIR)/make.sh \ - $(SRC_DIR)/insert.h \ - $(SRC) \ - $(SRC_DIR)/em_private.h - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) em_code.3 em_codeEK.h - -lintlib: $(SRC_DIR)/make.sh - $(MK_LINT_LIB) eme $(MOD_DIR)/lib $(INCLUDES) -DREADABLE_EM $(SRC) - $(MK_LINT_LIB) emk $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -insert.$(SUF): $(SRC_DIR)/insert.c $(SRC_DIR)/insert.h - $(CC) $(CFLAGS) -c $(SRC_DIR)/insert.c - -failed.$(SUF): $(SRC_DIR)/failed.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/failed.c - -internerr.$(SUF): $(SRC_DIR)/internerr.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/internerr.c - -getid.$(SUF): $(SRC_DIR)/getid.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/getid.c diff --git a/modules/src/em_data/build.mk b/modules/src/em_data/build.mk deleted file mode 100644 index b6b5c7cea..000000000 --- a/modules/src/em_data/build.mk +++ /dev/null @@ -1,34 +0,0 @@ -D := util/data - -define util-data-impl - -$(eval g := \ - $(OBJDIR)/$D/em_flag.c \ - $(OBJDIR)/$D/em_pseu.c \ - $(OBJDIR)/$D/em_mnem.c \ - $(INCDIR)/em_spec.h \ - $(INCDIR)/em_pseu.h \ - $(INCDIR)/em_mnem.h \ -) - -$(eval CLEANABLES += $g) -$(wordlist 2, $(words $g), $g): $(firstword $g) -$(firstword $g): $D/new_table h/em_table - @echo DATA - @mkdir -p $(dir $g) - $(hide) $D/new_table h/em_table $(INCDIR) $(OBJDIR)/$D - -$(call reset) -$(call cfile, $(OBJDIR)/$D/em_flag.c) -$(call cfile, $(OBJDIR)/$D/em_pseu.c) -$(call cfile, $(OBJDIR)/$D/em_mnem.c) -$(call cfile, $D/em_ptyp.c) - -$(eval $q: $g) - -$(call clibrary, $(LIBDIR)/libem_data.a) -$(eval LIBEM_DATA := $q) - -endef - -$(eval $(util-data-impl)) diff --git a/modules/src/em_data/proto.make b/modules/src/em_data/proto.make deleted file mode 100644 index 35f0bf8d6..000000000 --- a/modules/src/em_data/proto.make +++ /dev/null @@ -1,49 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/data -OBJ = em_mnem.$(SUF) em_pseu.$(SUF) em_flag.$(SUF) em_ptyp.$(SUF) - -DATA_PATH = em_data.$(LIBSUF) - -INCLUDES = -I$(TARGET_HOME)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -$(DATA_PATH): $(OBJ) - $(AR) rv $(DATA_PATH) $(OBJ) - $(RANLIB) $(DATA_PATH) - -install: $(DATA_PATH) - cp $(DATA_PATH) $(TARGET_HOME)/lib.bin/$(DATA_PATH) - $(RANLIB) $(TARGET_HOME)/lib.bin/$(DATA_PATH) - - -cmp: $(DATA_PATH) - -cmp $(DATA_PATH) $(TARGET_HOME)/lib.bin/$(DATA_PATH) - -clean: - rm -f $(OBJ) $(DATA_PATH) *.old - -opr: - make pr ^ opr - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/em_mnem.c $(SRC_DIR)/em_pseu.c $(SRC_DIR)/em_flag.c $(SRC_DIR)/em_ptyp.c - -em_flag.$(SUF): $(SRC_DIR)/em_flag.c $(TARGET_HOME)/h/em_flag.h - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_flag.c - -em_mnem.$(SUF): $(SRC_DIR)/em_mnem.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_mnem.c - -em_pseu.$(SUF): $(SRC_DIR)/em_pseu.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_pseu.c - -em_ptyp.$(SUF): $(SRC_DIR)/em_ptyp.c $(TARGET_HOME)/h/em_spec.h $(TARGET_HOME)/h/em_ptyp.h - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_ptyp.c - -lintlib: - $(MK_LINT_LIB) em_data $(TARGET_HOME)/lib.bin $(INCLUDES) \ - $(SRC_DIR)/em_flag.c $(SRC_DIR)/em_mnem.c \ - $(SRC_DIR)/em_pseu.c $(SRC_DIR)/em_ptyp.c diff --git a/modules/src/em_mes/build.mk b/modules/src/em_mes/build.mk deleted file mode 100644 index 7ae262114..000000000 --- a/modules/src/em_mes/build.mk +++ /dev/null @@ -1,26 +0,0 @@ -D := modules/src/em_mes - -define build-em_mes-impl - $(call reset) - $(call cfile, $D/C_ms_err.c) - $(call cfile, $D/C_ms_opt.c) - $(call cfile, $D/C_ms_emx.c) - $(call cfile, $D/C_ms_reg.c) - $(call cfile, $D/C_ms_src.c) - $(call cfile, $D/C_ms_flt.c) - $(call cfile, $D/C_ms_com.c) - $(call cfile, $D/C_ms_par.c) - $(call cfile, $D/C_ms_ego.c) - $(call cfile, $D/C_ms_gto.c) - $(call cfile, $D/C_ms_stb.c) - $(call cfile, $D/C_ms_std.c) - - $(eval $q: $(INCDIR)/em_codeEK.h) - - $(call clibrary, $(LIBDIR)/libem_mes.a) - $(eval LIBEM_MES := $o) -endef - -$(eval $(call build-em_mes-impl)) - - diff --git a/modules/src/em_mes/proto.make b/modules/src/em_mes/proto.make deleted file mode 100644 index 005e63bd9..000000000 --- a/modules/src/em_mes/proto.make +++ /dev/null @@ -1,110 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/em_mes -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES=-I$(TARGET_HOME)/h -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) - -SRC = $(SRC_DIR)/C_ms_err.c \ - $(SRC_DIR)/C_ms_opt.c \ - $(SRC_DIR)/C_ms_emx.c \ - $(SRC_DIR)/C_ms_reg.c \ - $(SRC_DIR)/C_ms_src.c \ - $(SRC_DIR)/C_ms_flt.c \ - $(SRC_DIR)/C_ms_com.c \ - $(SRC_DIR)/C_ms_par.c \ - $(SRC_DIR)/C_ms_ego.c \ - $(SRC_DIR)/C_ms_gto.c \ - $(SRC_DIR)/C_ms_stb.c \ - $(SRC_DIR)/C_ms_std.c -OBJ = C_ms_err.$(SUF) C_ms_opt.$(SUF) C_ms_emx.$(SUF) C_ms_reg.$(SUF) \ - C_ms_src.$(SUF) C_ms_flt.$(SUF) C_ms_com.$(SUF) C_ms_par.$(SUF) \ - C_ms_ego.$(SUF) C_ms_gto.$(SUF) C_ms_stb.$(SUF) C_ms_std.$(SUF) - -all: libem_mes.$(LIBSUF) libem_mesCE.$(LIBSUF) libem_mesO.$(LIBSUF) - -libem_mes.$(LIBSUF): $(OBJ) - rm -f libem_mes.$(LIBSUF) - $(AR) r libem_mes.$(LIBSUF) $(OBJ) - $(RANLIB) libem_mes.$(LIBSUF) - -libem_mesO.$(LIBSUF): - rm -f *.$(SUF) libem_mesO.$(LIBSUF) - $(CC) -c $(CFLAGS) -DPEEPHOLE $(SRC) - $(AR) r libem_mesO.$(LIBSUF) $(OBJ) - $(RANLIB) libem_mesO.$(LIBSUF) - rm -f *.$(SUF) - -libem_mesCE.$(LIBSUF): - rm -f *.$(SUF) libem_mesCE.$(LIBSUF) - $(CC) -c $(CFLAGS) -DCODE_EXPANDER $(SRC) - $(AR) r libem_mesCE.$(LIBSUF) $(OBJ) - $(RANLIB) libem_mesCE.$(LIBSUF) - rm -f *.$(SUF) - -install: all - -mkdir $(MOD_DIR)/lib - cp libem_mes.$(LIBSUF) $(MOD_DIR)/lib/libem_mes.$(LIBSUF) - cp libem_mesCE.$(LIBSUF) $(MOD_DIR)/lib/libem_mesCE.$(LIBSUF) - cp libem_mesO.$(LIBSUF) $(MOD_DIR)/lib/libem_mesO.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libem_mes.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libem_mesCE.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libem_mesO.$(LIBSUF) - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/em_mes.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libem_mes.$(LIBSUF) $(MOD_DIR)/lib/libem_mes.$(LIBSUF) - -cmp libem_mesCE.$(LIBSUF) $(MOD_DIR)/lib/libem_mesCE.$(LIBSUF) - -cmp libem_mesO.$(LIBSUF) $(MOD_DIR)/lib/libem_mesO.$(LIBSUF) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) em_mes $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -C_ms_err.$(SUF): $(SRC_DIR)/C_ms_err.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_err.c - -C_ms_opt.$(SUF): $(SRC_DIR)/C_ms_opt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_opt.c - -C_ms_emx.$(SUF): $(SRC_DIR)/C_ms_emx.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_emx.c - -C_ms_reg.$(SUF): $(SRC_DIR)/C_ms_reg.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_reg.c - -C_ms_src.$(SUF): $(SRC_DIR)/C_ms_src.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_src.c - -C_ms_flt.$(SUF): $(SRC_DIR)/C_ms_flt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_flt.c - -C_ms_com.$(SUF): $(SRC_DIR)/C_ms_com.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_com.c - -C_ms_par.$(SUF): $(SRC_DIR)/C_ms_par.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_par.c - -C_ms_ego.$(SUF): $(SRC_DIR)/C_ms_ego.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_ego.c - -C_ms_gto.$(SUF): $(SRC_DIR)/C_ms_gto.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_gto.c - -C_ms_stb.$(SUF): $(SRC_DIR)/C_ms_stb.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_stb.c - -C_ms_std.$(SUF): $(SRC_DIR)/C_ms_std.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_std.c diff --git a/modules/src/em_opt/proto.make b/modules/src/em_opt/proto.make deleted file mode 100644 index 68327cb98..000000000 --- a/modules/src/em_opt/proto.make +++ /dev/null @@ -1,241 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/em_opt -MOD_DIR = $(TARGET_HOME)/modules - -# set HOWMUCH to head -20 to limit number of patterns used -#HOWMUCH = head -20 -HOWMUCH = cat - -INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h \ - -I$(MOD_DIR)/pkg -I$(SRC_DIR) -I. -UINCLUDES = -I$(UTIL_HOME)/h -I$(UTIL_HOME)/modules/h \ - -I$(UTIL_HOME)/modules/pkg -I$(SRC_DIR) -I. -PREFLAGS = $(INCLUDES) -DPRIVATE=static# -DDEBUG -UPREFLAGS = $(UINCLUDES) -DPRIVATE=static# -DDEBUG - -# Enable the next line to produce a version that output's the line number -# from the patterns file each time an optimization is performed. -#PREFLAGS = $(PREFLAGS) -DSTATS - -CFLAGS = $(PREFLAGS) $(COPTIONS) -LINTFLAGS = $(PREFLAGS) -DNORCSID -LDFLAGS = $(LDOPTIONS) -UCFLAGS = $(UPREFLAGS) $(UCOPTIONS) -ULDFLAGS = $(ULDOPTIONS) -LLOPT = -CMD = '$(CC) -c $(CFLAGS)' - -LIBOPT = libemopt.$(LIBSUF) -LIBCEOPT = libCEopt.$(LIBSUF) - -.SUFFIXES: .d .r - -.r.d: ; CMD=$(CMD); export CMD; awk -f $(SRC_DIR)/makefuns.awk prototypes=/dev/null $*.r | sh -x - touch $@ - -.SUFFIXES: .$(SUF) -.c.$(SUF): - $(CC) -c $(CFLAGS) $*.c - -CSRC = $(SRC_DIR)/main.c $(SRC_DIR)/nopt.c $(SRC_DIR)/mkstrct.c \ - $(SRC_DIR)/aux.c $(SRC_DIR)/outputdfa.c $(SRC_DIR)/outcalls.c\ - $(SRC_DIR)/findworst.c $(SRC_DIR)/initlex.c - -SRCS = $(SRC_DIR)/proto.make $(SRC_DIR)/nopt.h $(SRC_DIR)/parser.h \ - $(SRC_DIR)/parser.g $(SRC_DIR)/syntax.l $(SRC_DIR)/pseudo.r\ - $(SRC_DIR)/patterns $(CSRC) - -NOFILES = nopt.$(SUF) dfa.$(SUF) trans.$(SUF) aux.$(SUF) mkstrct.$(SUF) - -POFILES = parser.$(USUF) syntax.$(USUF) outputdfa.$(USUF) outcalls.$(USUF)\ - findworst.$(USUF) initlex.$(USUF) Lpars.$(USUF) - -GENFILES = Lpars.h Lpars.c parserdummy parser.c syntax.c \ - dfa.c dfa.c.new trans.c trans.c.new\ - incalls.d incalls.r incalls.r.new pseudo.d pseudo.r - -all: em_nopt $(LIBOPT) $(LIBCEOPT) prototypes - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBOPT) $(MOD_DIR)/lib/$(LIBOPT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBOPT) - cp $(LIBCEOPT) $(MOD_DIR)/lib/$(LIBCEOPT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBCEOPT) - cp em_nopt $(TARGET_HOME)/lib.bin/em_nopt - cp prototypes $(MOD_DIR)/h/em_codeO.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/em_opt.3 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/em_nopt.6 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBOPT) $(MOD_DIR)/lib/$(LIBOPT) - -cmp $(LIBCEOPT) $(MOD_DIR)/lib/$(LIBCEOPT) - -cmp em_nopt $(TARGET_HOME)/lib.bin/em_nopt - -cmp prototypes $(MOD_DIR)/h/em_codeO.h - - -pr: - @pr $(SRCS) - -opr: - make pr | opr - -lint: lintparser lintnopt - -clean: - rm -f O_*.$(SUF) - rm -f O_*.c - rm -f $(NOFILES) main.$(SUF) $(POFILES) prototypes - rm -f $(GENFILES) parser em_nopt $(LIBOPT) $(LIBCEOPT) - -# How to build stand alone version of the optimizer - -NOPTLIB = $(MOD_DIR)/lib/libread_emk.$(LIBSUF)\ - $(MOD_DIR)/lib/libemk.$(LIBSUF)\ - $(MOD_DIR)/lib/liballoc.$(LIBSUF)\ - $(MOD_DIR)/lib/malloc.$(SUF)\ - $(MOD_DIR)/lib/libprint.$(LIBSUF)\ - $(MOD_DIR)/lib/libstring.$(LIBSUF)\ - $(MOD_DIR)/lib/libsystem.$(LIBSUF)\ - $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) - -em_nopt: incalls.r main.$(SUF) $(NOFILES) - $(CC) $(LDFLAGS) -o em_nopt main.$(SUF) $(NOFILES) $(NOPTLIB) - -OLINT = $(SRC_DIR)/main.c $(SRC_DIR)/mkstrct.c $(SRC_DIR)/nopt.c $(SRC_DIR)/aux.c dfa.c trans.c - -OLINTLIB = $(UTIL_HOME)/modules/lib/$(LINTPREF)read_emkV.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)emk.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)system.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)alloc.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)print.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)string.$(LINTSUF) - -lintnopt: incalls.r $(OLINT) - $(LINT) $(LINTFLAGS) $(OLINT) $(OLINTLIB) - -# How to build the library version of the optimizer - -$(LIBOPT): $(NOFILES) pseudo.d incalls.d - rm -f $(LIBOPT) - $(AR) r $(LIBOPT) O_*.$(SUF) $(NOFILES) - $(RANLIB) $(LIBOPT) - -$(LIBCEOPT): incalls.r - rm -f O_*.$(SUF) $(NOFILES) pseudo.d incalls.d - -mv $(LIBOPT) $(LIBOPT).saved - make PREFLAGS='$(INCLUDES) -DPRIVATE=static -DCODE_EXPANDER' $(LIBOPT) - mv $(LIBOPT) $(LIBCEOPT) - -mv $(LIBOPT).saved $(LIBOPT) - rm -f O_*.$(SUF) $(NOFILES) - -prototypes: pseudo.r incalls.r - cp $(SRC_DIR)/em_codeO.h prototypes - echo >> prototypes - awk -f $(SRC_DIR)/makefuns.awk pseudo.r incalls.r > /dev/null - -incalls.r: $(SRC_DIR)/patterns parser - -$(UTIL_HOME)/lib.bin/cpp $(SRC_DIR)/patterns | $(HOWMUCH) >/tmp/patts - parser syntax.c - -parserdummy: $(SRC_DIR)/parser.g - LLgen $(LLOPT) $(SRC_DIR)/parser.g - touch parserdummy - -PLINT = parser.c syntax.c $(SRC_DIR)/outputdfa.c $(SRC_DIR)/outcalls.c\ - $(SRC_DIR)/findworst.c $(SRC_DIR)/initlex.c Lpars.c - -PLINTLIB = $(UTIL_HOME)/modules/lib/$(LINTPREF)alloc.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)string.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)system.$(LINTSUF) - -LINTFLAGS = $(LINTOPTIONS) - -lintparser: parserdummy $(PLINT) - $(LINT) $(LINTFLAGS) $(PLINT) $(PLINTLIB) - -# Dependancies - -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -main.$(SUF): $(SRC_DIR)/nopt.h - -nopt.$(SUF): $(SRC_DIR)/nopt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/nopt.c -nopt.$(SUF): $(SRC_DIR)/nopt.h - -mkstrct.$(SUF): $(SRC_DIR)/mkstrct.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/mkstrct.c -mkstrct.$(SUF): $(SRC_DIR)/nopt.h - -aux.$(SUF): $(SRC_DIR)/aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/aux.c -aux.$(SUF): $(SRC_DIR)/nopt.h - -dfa.$(SUF): dfa.c - $(CC) -c $(CFLAGS) dfa.c -dfa.$(SUF): $(SRC_DIR)/nopt.h - -trans.$(SUF): trans.c - $(CC) -c $(CFLAGS) trans.c -trans.$(SUF): $(SRC_DIR)/nopt.h - -incalls.d: $(SRC_DIR)/nopt.h $(SRC_DIR)/makefuns.awk -pseudo.d: $(SRC_DIR)/nopt.h $(SRC_DIR)/makefuns.awk -pseudo.r: $(SRC_DIR)/pseudo.r - cp $(SRC_DIR)/pseudo.r pseudo.r - -parser.$(USUF): parser.c - $(UCC) -c $(UCFLAGS) parser.c -parser.$(USUF): Lpars.h $(SRC_DIR)/parser.h - -Lpars.$(USUF): Lpars.c - $(UCC) -c $(UCFLAGS) Lpars.c -Lpars.$(USUF): Lpars.h - -syntax.$(USUF): syntax.c - $(UCC) -c $(UCFLAGS) syntax.c -sybtax.$(USUF): $(SRC_DIR)/parser.h Lpars.h - -outputdfa.$(USUF): $(SRC_DIR)/outputdfa.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/outputdfa.c -outputdfa.$(USUF): $(SRC_DIR)/parser.h Lpars.h - -outcalls.$(USUF): $(SRC_DIR)/outcalls.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/outcalls.c -outcalls.$(USUF): $(SRC_DIR)/parser.h - -findworst.$(USUF): $(SRC_DIR)/findworst.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/findworst.c -findworst.$(USUF): $(SRC_DIR)/parser.h - -initlex.$(USUF): $(SRC_DIR)/initlex.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/initlex.c -initlex.$(USUF): $(SRC_DIR)/parser.h diff --git a/modules/src/flt_arith/build.mk b/modules/src/flt_arith/build.mk deleted file mode 100644 index 6a34b7d46..000000000 --- a/modules/src/flt_arith/build.mk +++ /dev/null @@ -1,29 +0,0 @@ -D := modules/src/flt_arith - -define build-libflt_arith-impl - $(call reset) - $(call cfile, $D/flt_ar2flt.c) - $(call cfile, $D/flt_div.c) - $(call cfile, $D/flt_flt2ar.c) - $(call cfile, $D/flt_modf.c) - $(call cfile, $D/flt_str2fl.c) - $(call cfile, $D/flt_cmp.c) - $(call cfile, $D/flt_add.c) - $(call cfile, $D/b64_add.c) - $(call cfile, $D/flt_mul.c) - $(call cfile, $D/flt_nrm.c) - $(call cfile, $D/b64_sft.c) - $(call cfile, $D/flt_umin.c) - $(call cfile, $D/flt_chk.c) - $(call cfile, $D/split.c) - $(call cfile, $D/ucmp.c) - $(call clibrary, $(LIBDIR)/libflt_arith.a) - LIBFLT_ARITH := $o - - $(call reset) - $(eval q := $D/flt_arith.h) - $(call copyto, $(INCDIR)/flt_arith.h) -endef - -$(eval $(build-libflt_arith-impl)) - diff --git a/modules/src/flt_arith/proto.make b/modules/src/flt_arith/proto.make deleted file mode 100644 index c0fb20517..000000000 --- a/modules/src/flt_arith/proto.make +++ /dev/null @@ -1,117 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/flt_arith -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) -LDFLAGS = $(LDOPTIONS) - -LIBFLT = libflt.$(LIBSUF) - -SRC = $(SRC_DIR)/flt_ar2flt.c \ - $(SRC_DIR)/flt_div.c \ - $(SRC_DIR)/flt_flt2ar.c \ - $(SRC_DIR)/flt_modf.c \ - $(SRC_DIR)/flt_str2fl.c \ - $(SRC_DIR)/flt_cmp.c \ - $(SRC_DIR)/flt_add.c \ - $(SRC_DIR)/b64_add.c \ - $(SRC_DIR)/flt_mul.c \ - $(SRC_DIR)/flt_nrm.c \ - $(SRC_DIR)/b64_sft.c \ - $(SRC_DIR)/flt_umin.c \ - $(SRC_DIR)/flt_chk.c \ - $(SRC_DIR)/split.c \ - $(SRC_DIR)/ucmp.c - -OBJ = flt_ar2flt.$(SUF) flt_div.$(SUF) flt_flt2ar.$(SUF) flt_modf.$(SUF) \ - flt_str2fl.$(SUF) flt_cmp.$(SUF) flt_add.$(SUF) b64_add.$(SUF) \ - flt_mul.$(SUF) flt_nrm.$(SUF) b64_sft.$(SUF) flt_umin.$(SUF) \ - flt_chk.$(SUF) split.$(SUF) ucmp.$(SUF) - -all: $(LIBFLT) - -test: $(LIBFLT) test.$(SUF) - $(CC) $(LDFLAGS) -o tst test.$(SUF) $(LIBFLT) - ./tst - -$(LIBFLT): $(OBJ) - rm -f $(LIBFLT) - $(AR) r $(LIBFLT) $(OBJ) - $(RANLIB) $(LIBFLT) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBFLT) $(MOD_DIR)/lib/$(LIBFLT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBFLT) - cp $(SRC_DIR)/flt_arith.h $(MOD_DIR)/h/flt_arith.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/flt_arith.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBFLT) $(MOD_DIR)/lib/$(LIBFLT) - -cmp $(SRC_DIR)/flt_arith.h $(MOD_DIR)/h/flt_arith.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) $(LIBFLT) tst - -lintlib: - $(MK_LINT_LIB) flt $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -b64_add.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/b64_add.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/b64_add.c - -flt_ar2flt.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_ar2flt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_ar2flt.c - -flt_div.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_div.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_div.c - -flt_nrm.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_nrm.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_nrm.c - -b64_sft.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/b64_sft.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/b64_sft.c - -flt_chk.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_chk.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_chk.c - -flt_flt2ar.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_flt2ar.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_flt2ar.c - -flt_str2fl.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_str2fl.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_str2fl.c - -flt_add.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_add.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_add.c - -flt_cmp.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_cmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_cmp.c - -flt_mul.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_mul.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_mul.c - -flt_modf.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_modf.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_modf.c - -flt_umin.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_umin.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_umin.c - -ucmp.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/ucmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ucmp.c - -split.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/split.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/split.c - -test.$(SUF): $(SRC_DIR)/flt_arith.h $(SRC_DIR)/test.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/test.c diff --git a/modules/src/idf/build.mk b/modules/src/idf/build.mk deleted file mode 100644 index b8dee6f79..000000000 --- a/modules/src/idf/build.mk +++ /dev/null @@ -1,14 +0,0 @@ -D := modules/src/idf - -define build-libidf-impl - $(call reset) - $(eval q := $D/idf_pkg.body) - $(call copyto, $(INCDIR)/idf_pkg.body) - - $(call reset) - $(eval q := $D/idf_pkg.spec) - $(call copyto, $(INCDIR)/idf_pkg.spec) -endef - -$(eval $(build-libidf-impl)) - diff --git a/modules/src/idf/proto.make b/modules/src/idf/proto.make deleted file mode 100644 index 259c2df41..000000000 --- a/modules/src/idf/proto.make +++ /dev/null @@ -1,29 +0,0 @@ -# $Id$ - -#PARAMS do not delete this line! - -SRC_DIR = $(SRC_HOME)/modules/src/idf -MOD_DIR = $(TARGET_HOME)/modules - -all: - -install: all - -mkdir $(MOD_DIR)/pkg - cp $(SRC_DIR)/idf_pkg.body $(MOD_DIR)/pkg/idf_pkg.body - cp $(SRC_DIR)/idf_pkg.spec $(MOD_DIR)/pkg/idf_pkg.spec - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/idf.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(SRC_DIR)/idf_pkg.body $(MOD_DIR)/pkg/idf_pkg.body - -cmp $(SRC_DIR)/idf_pkg.spec $(MOD_DIR)/pkg/idf_pkg.spec - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/idf_pkg.spec $(SRC_DIR)/idf_pkg.body - -opr: - make pr | opr - -clean: -lintlib: diff --git a/modules/src/input/build.mk b/modules/src/input/build.mk deleted file mode 100644 index ef6e1aac0..000000000 --- a/modules/src/input/build.mk +++ /dev/null @@ -1,20 +0,0 @@ -D := modules/src/input - -define build-libinput-impl - $(call reset) - $(call cfile, $D/AtEoIF.c) - $(call cfile, $D/AtEoIT.c) - $(call clibrary, $(LIBDIR)/libinput.a) - $(eval LIBINPUT := $o) - - $(call reset) - $(eval q := $D/inp_pkg.body) - $(call copyto, $(INCDIR)/inp_pkg.body) - - $(call reset) - $(eval q := $D/inp_pkg.spec) - $(call copyto, $(INCDIR)/inp_pkg.spec) -endef - -$(eval $(build-libinput-impl)) - diff --git a/modules/src/input/proto.make b/modules/src/input/proto.make deleted file mode 100644 index d8e542d81..000000000 --- a/modules/src/input/proto.make +++ /dev/null @@ -1,52 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/input -MOD_DIR = $(TARGET_HOME)/modules - -OBJECTS = AtEoIF.$(SUF)\ - AtEoIT.$(SUF) - -CFLAGS = $(COPTIONS) - -all: libinput.$(LIBSUF) - -libinput.$(LIBSUF): $(OBJECTS) - rm -f libinput.$(LIBSUF) - $(AR) r libinput.$(LIBSUF) $(OBJECTS) - $(RANLIB) libinput.$(LIBSUF) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/pkg - cp libinput.$(LIBSUF) $(MOD_DIR)/lib/libinput.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libinput.$(LIBSUF) - cp $(SRC_DIR)/inp_pkg.body $(MOD_DIR)/pkg/inp_pkg.body - cp $(SRC_DIR)/inp_pkg.spec $(MOD_DIR)/pkg/inp_pkg.spec - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/input.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libinput.$(LIBSUF) $(MOD_DIR)/lib/libinput.$(LIBSUF) - -cmp $(SRC_DIR)/inp_pkg.body $(MOD_DIR)/pkg/inp_pkg.body - -cmp $(SRC_DIR)/inp_pkg.spec $(MOD_DIR)/pkg/inp_pkg.spec - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/inp_pkg.spec $(SRC_DIR)/inp_pkg.body $(SRC_DIR)/AtEoIF.c $(SRC_DIR)/AtEoIT.c - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) input $(MOD_DIR)/lib $(SRC_DIR)/AtEoIF.c $(SRC_DIR)/AtEoIT.c - -AtEoIT.$(SUF): $(SRC_DIR)/AtEoIT.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/AtEoIT.c - -AtEoIF.$(SUF): $(SRC_DIR)/AtEoIF.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/AtEoIF.c diff --git a/modules/src/malloc/proto.make b/modules/src/malloc/proto.make deleted file mode 100644 index ad4eae7c6..000000000 --- a/modules/src/malloc/proto.make +++ /dev/null @@ -1,53 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/malloc -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) - -MALLOCSRC = $(SRC_DIR)/READ_ME $(SRC_DIR)/size_type.h \ - gensize_type.h $(SRC_DIR)/param.h $(SRC_DIR)/impl.h \ - $(SRC_DIR)/check.h $(SRC_DIR)/log.h $(SRC_DIR)/phys.h \ - $(SRC_DIR)/mal.c $(SRC_DIR)/log.c $(SRC_DIR)/phys.c \ - $(SRC_DIR)/check.c - -all: malloc.$(SUF) - -install: all - -mkdir $(MOD_DIR)/lib - cp malloc.$(SUF) $(MOD_DIR)/lib/malloc.$(SUF) - -cmp: all - -cmp malloc.$(SUF) $(MOD_DIR)/lib/malloc.$(SUF) - -malloc1.c: $(MALLOCSRC) $(SRC_DIR)/add_file - rm -f malloc1.c - for i in $(MALLOCSRC) ; do $(SRC_DIR)/add_file $$i >> malloc1.c ; done - -malloc.c: malloc1.c - cclash -l7 -c malloc1.c > clashes - cid -Fclashes < malloc1.c > malloc.c - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/add_file $(MALLOCSRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) clashes malloc1.c gensize_type.h getsize malloc.c - -gensize_type.h: getsize - getsize > gensize_type.h - -getsize: $(SRC_DIR)/getsize.c - $(UCC) -o getsize $(SRC_DIR)/getsize.c -# use $(UCC), not $(CC) as this must produce runnable binary. - -malloc.$(SUF): malloc.c - $(CC) -c $(CFLAGS) malloc.c -# to avoid options that the SUN make adds. - -lintlib: diff --git a/modules/src/object/build.mk b/modules/src/object/build.mk deleted file mode 100644 index d256cba92..000000000 --- a/modules/src/object/build.mk +++ /dev/null @@ -1,27 +0,0 @@ -D := modules/src/object - -define build-libobject-impl - $(call reset) - $(call cfile, $D/rd.c) - $(call cfile, $D/rd_arhdr.c) - $(call cfile, $D/rd_bytes.c) - $(call cfile, $D/rd_int2.c) - $(call cfile, $D/rd_long.c) - $(call cfile, $D/rd_ranlib.c) - $(call cfile, $D/rd_unsig2.c) - $(call cfile, $D/wr.c) - $(call cfile, $D/wr_arhdr.c) - $(call cfile, $D/wr_bytes.c) - $(call cfile, $D/wr_int2.c) - $(call cfile, $D/wr_long.c) - $(call cfile, $D/wr_putc.c) - $(call cfile, $D/wr_ranlib.c) - - $(eval $q: $(INCDIR)/local.h) - - $(call clibrary, $(LIBDIR)/libobject.a) - LIBOBJECT := $o -endef - -$(eval $(build-libobject-impl)) - diff --git a/modules/src/object/proto.make b/modules/src/object/proto.make deleted file mode 100644 index 3fbc17260..000000000 --- a/modules/src/object/proto.make +++ /dev/null @@ -1,95 +0,0 @@ -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/object -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h -I$(TARGET_HOME)/config -I$(SRC_DIR) -CFLAGS = $(INCLUDES) $(COPTIONS) - -CFILES = $(SRC_DIR)/rd_arhdr.c $(SRC_DIR)/wr_arhdr.c \ - $(SRC_DIR)/rd_ranlib.c $(SRC_DIR)/wr_ranlib.c \ - $(SRC_DIR)/rd_bytes.c $(SRC_DIR)/wr_bytes.c \ - $(SRC_DIR)/rd.c $(SRC_DIR)/wr.c \ - $(SRC_DIR)/wr_putc.c \ - $(SRC_DIR)/rd_int2.c $(SRC_DIR)/wr_int2.c \ - $(SRC_DIR)/rd_unsig2.c \ - $(SRC_DIR)/rd_long.c $(SRC_DIR)/wr_long.c -# do not change the order in OFILES -OFILES = rd.$(SUF) rd_arhdr.$(SUF) rd_int2.$(SUF) rd_long.$(SUF) \ - rd_ranlib.$(SUF) rd_unsig2.$(SUF) rd_bytes.$(SUF) \ - wr_arhdr.$(SUF) wr_int2.$(SUF) wr_long.$(SUF) wr_putc.$(SUF) \ - wr.$(SUF) wr_ranlib.$(SUF) wr_bytes.$(SUF) - -all: libobject.$(LIBSUF) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp libobject.$(LIBSUF) $(MOD_DIR)/lib/libobject.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libobject.$(LIBSUF) - cp $(SRC_DIR)/object.h $(MOD_DIR)/h/object.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/object.3 $(TARGET_HOME) ; \ - fi - -compare: all - -cmp libobject.$(LIBSUF) $(MOD_DIR)/lib/libobject.$(LIBSUF) - -cmp $(SRC_DIR)/object.h $(MOD_DIR)/h/object.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/object.h $(CFILES) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) nohup.out Out - -libobject.$(LIBSUF): $(OFILES) - rm -f libobject.$(LIBSUF) - $(AR) r libobject.$(LIBSUF) $(OFILES) - $(RANLIB) libobject.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) object $(MOD_DIR)/lib $(INCLUDES) $(CFILES) - -rd_arhdr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_arhdr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_arhdr.c - -wr_arhdr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_arhdr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_arhdr.c - -rd_ranlib.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_ranlib.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_ranlib.c - -wr_ranlib.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_ranlib.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_ranlib.c - -rd.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd.c - -wr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr.c - -wr_putc.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_putc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_putc.c - -rd_int2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_int2.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_int2.c - -wr_int2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_int2.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_int2.c - -rd_unsig2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_unsig2.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_unsig2.c - -rd_long.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_long.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_long.c - -wr_long.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_long.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_long.c - -rd_bytes.$(SUF): $(SRC_DIR)/rd_bytes.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_bytes.c - -wr_bytes.$(SUF): $(SRC_DIR)/wr_bytes.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_bytes.c diff --git a/modules/src/print/build.mk b/modules/src/print/build.mk deleted file mode 100644 index 17974b4d6..000000000 --- a/modules/src/print/build.mk +++ /dev/null @@ -1,22 +0,0 @@ -D := modules/src/print - -define build-libprint-impl - $(call reset) - $(call cfile, $D/doprnt.c) - $(call cfile, $D/fprint.c) - $(call cfile, $D/print.c) - $(call cfile, $D/sprint.c) - $(call cfile, $D/format.c) - - $(eval $q: $(INCDIR)/system.h) - - $(call clibrary, $(LIBDIR)/libprint.a) - LIBPRINT := $o - - $(call reset) - $(eval q := $D/print.h) - $(call copyto, $(INCDIR)/print.h) -endef - -$(eval $(build-libprint-impl)) - diff --git a/modules/src/print/proto.make b/modules/src/print/proto.make deleted file mode 100644 index 61004de70..000000000 --- a/modules/src/print/proto.make +++ /dev/null @@ -1,62 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/print -MOD_DIR = $(TARGET_HOME)/modules -LIBPRINT = libprint.$(LIBSUF) -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h - -CFLAGS = $(COPTIONS) $(INCLUDES) - -SRC = $(SRC_DIR)/doprnt.c $(SRC_DIR)/fprint.c $(SRC_DIR)/print.c \ - $(SRC_DIR)/sprint.c $(SRC_DIR)/format.c -OBJ = doprnt.$(SUF) fprint.$(SUF) print.$(SUF) sprint.$(SUF) format.$(SUF) - -all: $(LIBPRINT) - -$(LIBPRINT): $(OBJ) - rm -f $(LIBPRINT) - $(AR) r $(LIBPRINT) $(OBJ) - $(RANLIB) $(LIBPRINT) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBPRINT) - cp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/print.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT) - -cmp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) $(LIBPRINT) - -lintlib: - $(MK_LINT_LIB) print $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -doprnt.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/doprnt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/doprnt.c - -fprint.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/fprint.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/fprint.c - -print.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/print.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/print.c - -sprint.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/sprint.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sprint.c - -format.$(SUF): $(SRC_DIR)/format.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/format.c diff --git a/modules/src/read_em/build.mk b/modules/src/read_em/build.mk deleted file mode 100644 index 17606718c..000000000 --- a/modules/src/read_em/build.mk +++ /dev/null @@ -1,54 +0,0 @@ -D := modules/src/read_em - -define build-read_em-headers-impl - -$(eval g := $(OBJDIR)/$D/C_mnem_narg.h) -$(eval CLEANABLES += $g) -$g: $D/m_C_mnem_na h/em_table - @echo M_C_MNEM_NA $g - @mkdir -p $(dir $g) - $(hide) cd $D && $(abspath $D/m_C_mnem_na) $(abspath h/em_table) > $(abspath $g) - -$(eval g := $(OBJDIR)/$D/C_mnem.h) -$(eval CLEANABLES += $g) -$g: $D/m_C_mnem h/em_table - @echo M_C_MNEM $g - @mkdir -p $(dir $g) - $(hide) cd $D && $(abspath $D/m_C_mnem) $(abspath h/em_table) > $(abspath $g) - -endef - -define build-read_em-impl - -$(call reset) -$(eval objdir := emev) -$(eval cflags += -I$(OBJDIR)/$D -DPRIVATE=static -DEXPORT= -DNDEBUG -DCHECKING) -$(call cfile, $D/EM_vars.c) -$(call cfile, $D/read_em.c) -$(call cfile, $D/mkcalls.c) -$(eval $q: $(OBJDIR)/$D/C_mnem_narg.h) -$(eval $q: $(OBJDIR)/$D/C_mnem.h) -$(call clibrary, $(LIBDIR)/lib_read_emeV.a) -$(eval LIBREAD_EMEV := $q) - -$(call reset) -$(eval objdir := emkv) -$(eval cflags += -I$(OBJDIR)/$D -DPRIVATE=static -DEXPORT= -DNDEBUG -DCHECKING -DCOMPACT) -$(call cfile, $D/EM_vars.c) -$(call cfile, $D/read_em.c) -$(call cfile, $D/mkcalls.c) -$(eval $q: $(OBJDIR)/$D/C_mnem_narg.h) -$(eval $q: $(OBJDIR)/$D/C_mnem.h) -$(call clibrary, $(LIBDIR)/lib_read_emkV.a) -$(eval LIBREAD_EMKV := $q) - -$(call reset) -$(eval q := $D/em_comp.h) -$(call installto, $(INCDIR)/em_comp.h) - -endef - -$(eval $(call build-read_em-headers-impl)) -$(eval $(call build-read_em-impl)) - - diff --git a/modules/src/read_em/proto.make b/modules/src/read_em/proto.make deleted file mode 100644 index 07b38cf16..000000000 --- a/modules/src/read_em/proto.make +++ /dev/null @@ -1,123 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/read_em -MOD_DIR = $(TARGET_HOME)/modules -EM_TABLE = $(SRC_HOME)/etc/em_table -INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h -I$(SRC_DIR) -I. -DEFINES = -DPRIVATE=static -DEXPORT= -DNDEBUG -CFLAGS = $(INCLUDES) $(DEFINES) $(COPTIONS) - -TARGETS = libread_emk.$(LIBSUF) \ - libread_emkV.$(LIBSUF) \ - libread_emeV.$(LIBSUF) - -ESRCFILES = $(SRC_DIR)/read_em.c\ - $(SRC_DIR)/mkcalls.c\ - $(SRC_DIR)/EM_vars.c - -KSRCFILES = $(SRC_DIR)/read_em.c\ - $(SRC_DIR)/mkcalls.c\ - $(SRC_DIR)/EM_vars.c - -SRCFILES = $(SRC_DIR)/em_comp.h\ - $(SRC_DIR)/read_em.c\ - $(SRC_DIR)/reade.c\ - $(SRC_DIR)/readk.c \ - $(SRC_DIR)/mkcalls.c\ - $(SRC_DIR)/EM_vars.c - -EV_OFILES = read_emeV.$(SUF) makecallsV.$(SUF) EM_vars.$(SUF) -KV_OFILES = read_emkV.$(SUF) makecallsV.$(SUF) EM_vars.$(SUF) -K_OFILES = read_emk.$(SUF) makecalls.$(SUF) EM_vars.$(SUF) - -all: $(TARGETS) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(SRC_DIR)/em_comp.h $(MOD_DIR)/h/em_comp.h - cp libread_emk.$(LIBSUF) $(MOD_DIR)/lib/libread_emk.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libread_emk.$(LIBSUF) - cp libread_emkV.$(LIBSUF) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF) - cp libread_emeV.$(LIBSUF) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF) - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/read_em.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(SRC_DIR)/em_comp.h $(MOD_DIR)/h/em_comp.h - -cmp libread_emk.$(LIBSUF) $(MOD_DIR)/lib/libread_emk.$(LIBSUF) - -cmp libread_emkV.$(LIBSUF) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF) - -cmp libread_emeV.$(LIBSUF) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/m_C_mnem $(SRC_DIR)/m_C_mnem_na $(SRC_DIR)/argtype $(SRCFILES) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) C_mnem C_mnem_narg - -libread_emk.$(LIBSUF): $(K_OFILES) - rm -f libread_emk.$(LIBSUF) - $(AR) r libread_emk.$(LIBSUF) $(K_OFILES) - $(RANLIB) libread_emk.$(LIBSUF) - -libread_emkV.$(LIBSUF): $(KV_OFILES) - rm -f libread_emkV.$(LIBSUF) - $(AR) r libread_emkV.$(LIBSUF) $(KV_OFILES) - $(RANLIB) libread_emkV.$(LIBSUF) - -libread_emeV.$(LIBSUF): $(EV_OFILES) - rm -f libread_emeV.$(LIBSUF) - $(AR) r libread_emeV.$(LIBSUF) $(EV_OFILES) - $(RANLIB) libread_emeV.$(LIBSUF) - -read_emk.$(SUF): $(SRC_DIR)/read_em.c $(SRC_DIR)/em_comp.h $(SRC_DIR)/readk.c - $(CC) -c $(CFLAGS) -DCOMPACT $(SRC_DIR)/read_em.c - mv read_em.$(SUF) read_emk.$(SUF) - -read_emkV.$(SUF): $(SRC_DIR)/read_em.c $(SRC_DIR)/em_comp.h $(SRC_DIR)/readk.c - $(CC) -c $(CFLAGS) -DCOMPACT -DCHECKING $(SRC_DIR)/read_em.c - mv read_em.$(SUF) read_emkV.$(SUF) - -read_emeV.$(SUF): $(SRC_DIR)/read_em.c $(SRC_DIR)/em_comp.h $(SRC_DIR)/reade.c - $(CC) -c $(CFLAGS) -DCHECKING $(SRC_DIR)/read_em.c - mv read_em.$(SUF) read_emeV.$(SUF) - -makecalls.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecalls.$(SUF) - -makecallsV.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c $(CFLAGS) -DCHECKING $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecallsV.$(SUF) - -makecallsO.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c -DPEEPHOLE $(CFLAGS) $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecallsO.$(SUF) - -makecallsCE.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c -DCODE_EXPANDER $(CFLAGS) $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecallsCE.$(SUF) - -C_mnem: $(SRC_DIR)/m_C_mnem argtype $(EM_TABLE) - sh $(SRC_DIR)/m_C_mnem $(EM_TABLE) > C_mnem - -C_mnem_narg: $(SRC_DIR)/m_C_mnem_na argtype $(EM_TABLE) - sh $(SRC_DIR)/m_C_mnem_na $(EM_TABLE) > C_mnem_narg - -argtype: $(SRC_DIR)/argtype - cp $(SRC_DIR)/argtype argtype - -lintlib: C_mnem C_mnem_narg - $(MK_LINT_LIB) read_emkV $(MOD_DIR)/lib $(INCLUDES) $(DEFINES) -DCOMPACT -DCHECKING $(KSRCFILES) - $(MK_LINT_LIB) read_emeV $(MOD_DIR)/lib $(INCLUDES) $(DEFINES) -DCHECKING $(ESRCFILES) - -EM_vars.$(SUF): $(SRC_DIR)/EM_vars.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/EM_vars.c diff --git a/modules/src/string/build.mk b/modules/src/string/build.mk deleted file mode 100644 index 7139f1e8e..000000000 --- a/modules/src/string/build.mk +++ /dev/null @@ -1,19 +0,0 @@ -D := modules/src/string - -define build-libstring-impl - $(call reset) - $(call cfile, $D/bts2str.c) - $(call cfile, $D/btscat.c) - $(call cfile, $D/btscmp.c) - $(call cfile, $D/btscpy.c) - $(call cfile, $D/btszero.c) - $(call cfile, $D/long2str.c) - $(call cfile, $D/str2bts.c) - $(call cfile, $D/str2long.c) - $(call cfile, $D/strzero.c) - $(call clibrary, $(LIBDIR)/libstring.a) - LIBSTRING := $o -endef - -$(eval $(build-libstring-impl)) - diff --git a/modules/src/string/proto.make b/modules/src/string/proto.make deleted file mode 100644 index 58184e7c5..000000000 --- a/modules/src/string/proto.make +++ /dev/null @@ -1,110 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/string -MOD_DIR = $(TARGET_HOME)/modules - -SRC = $(SRC_DIR)/bts2str.c $(SRC_DIR)/btscat.c $(SRC_DIR)/btscmp.c \ - $(SRC_DIR)/btscpy.c $(SRC_DIR)/btszero.c $(SRC_DIR)/long2str.c \ - $(SRC_DIR)/str2bts.c $(SRC_DIR)/str2long.c $(SRC_DIR)/strcat.c \ - $(SRC_DIR)/strcmp.c $(SRC_DIR)/strcpy.c $(SRC_DIR)/strindex.c \ - $(SRC_DIR)/strlen.c $(SRC_DIR)/strncat.c $(SRC_DIR)/strncmp.c \ - $(SRC_DIR)/strncpy.c $(SRC_DIR)/strrindex.c $(SRC_DIR)/strzero.c - -OBJ = bts2str.$(SUF) btscat.$(SUF) btscmp.$(SUF) btscpy.$(SUF) \ - btszero.$(SUF) long2str.$(SUF) str2bts.$(SUF) str2long.$(SUF) \ - strcat.$(SUF) strcmp.$(SUF) strcpy.$(SUF) strindex.$(SUF) \ - strlen.$(SUF) strncat.$(SUF) strncmp.$(SUF) strncpy.$(SUF) \ - strrindex.$(SUF) strzero.$(SUF) - -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -LIBSTRING = libstring.$(LIBSUF) - -all: $(LIBSTRING) - -$(LIBSTRING): $(OBJ) - $(AR) r $(LIBSTRING) $(OBJ) - $(RANLIB) $(LIBSTRING) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBSTRING) $(MOD_DIR)/lib/$(LIBSTRING) - $(RANLIB) $(MOD_DIR)/lib/$(LIBSTRING) - cp $(SRC_DIR)/ack_string.h $(MOD_DIR)/h/ack_string.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/string.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBSTRING) $(MOD_DIR)/lib/$(LIBSTRING) - -cmp $(SRC_DIR)/ack_string.h $(MOD_DIR)/h/ack_string.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) string $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -bts2str.$(SUF): $(SRC_DIR)/bts2str.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/bts2str.c - -btscat.$(SUF): $(SRC_DIR)/btscat.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btscat.c - -btscmp.$(SUF): $(SRC_DIR)/btscmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btscmp.c - -btscpy.$(SUF): $(SRC_DIR)/btscpy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btscpy.c - -btszero.$(SUF): $(SRC_DIR)/btszero.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btszero.c - -long2str.$(SUF): $(SRC_DIR)/long2str.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/long2str.c - -str2bts.$(SUF): $(SRC_DIR)/str2bts.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/str2bts.c - -str2long.$(SUF): $(SRC_DIR)/str2long.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/str2long.c - -strcat.$(SUF): $(SRC_DIR)/strcat.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strcat.c - -strcmp.$(SUF): $(SRC_DIR)/strcmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strcmp.c - -strcpy.$(SUF): $(SRC_DIR)/strcpy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strcpy.c - -strindex.$(SUF): $(SRC_DIR)/strindex.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strindex.c - -strlen.$(SUF): $(SRC_DIR)/strlen.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strlen.c - -strncat.$(SUF): $(SRC_DIR)/strncat.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strncat.c - -strncmp.$(SUF): $(SRC_DIR)/strncmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strncmp.c - -strncpy.$(SUF): $(SRC_DIR)/strncpy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strncpy.c - -strrindex.$(SUF): $(SRC_DIR)/strrindex.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strrindex.c - -strzero.$(SUF): $(SRC_DIR)/strzero.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strzero.c diff --git a/modules/src/system/build.mk b/modules/src/system/build.mk deleted file mode 100644 index e76b5c5e3..000000000 --- a/modules/src/system/build.mk +++ /dev/null @@ -1,29 +0,0 @@ -D := modules/src/system - -define build-libsystem-impl - $(call reset) - $(call cfile, $D/access.c) - $(call cfile, $D/break.c) - $(call cfile, $D/chmode.c) - $(call cfile, $D/close.c) - $(call cfile, $D/create.c) - $(call cfile, $D/filesize.c) - $(call cfile, $D/open.c) - $(call cfile, $D/read.c) - $(call cfile, $D/remove.c) - $(call cfile, $D/stop.c) - $(call cfile, $D/system.c) - $(call cfile, $D/time.c) - $(call cfile, $D/write.c) - $(call cfile, $D/seek.c) - $(call cfile, $D/rename.c) - $(call clibrary, $(LIBDIR)/libsystem.a) - LIBSYSTEM := $o - - $(call reset) - $(eval q := $D/system.h) - $(call copyto, $(INCDIR)/system.h) -endef - -$(eval $(build-libsystem-impl)) - diff --git a/modules/src/system/proto.make b/modules/src/system/proto.make deleted file mode 100644 index 50d21ccfc..000000000 --- a/modules/src/system/proto.make +++ /dev/null @@ -1,109 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/system -MOD_DIR = $(TARGET_HOME)/modules - -LIBSYS = libsystem.$(LIBSUF) -OBJ = access.$(SUF) break.$(SUF) chmode.$(SUF) close.$(SUF) create.$(SUF) \ - filesize.$(SUF) modtime.$(SUF) lock.$(SUF) open.$(SUF) read.$(SUF) \ - remove.$(SUF) stop.$(SUF) system.$(SUF) time.$(SUF) unlock.$(SUF) \ - write.$(SUF) seek.$(SUF) rename.$(SUF) -CSRC = $(SRC_DIR)/access.c $(SRC_DIR)/break.c $(SRC_DIR)/chmode.c \ - $(SRC_DIR)/close.c $(SRC_DIR)/create.c $(SRC_DIR)/filesize.c \ - $(SRC_DIR)/modtime.c $(SRC_DIR)/lock.c $(SRC_DIR)/open.c \ - $(SRC_DIR)/read.c $(SRC_DIR)/remove.c $(SRC_DIR)/stop.c \ - $(SRC_DIR)/system.c $(SRC_DIR)/time.c $(SRC_DIR)/unlock.c \ - $(SRC_DIR)/write.c $(SRC_DIR)/seek.c $(SRC_DIR)/rename.c -SRC = $(SRC_DIR)/proto.make $(SRC_DIR)/system.h $(CSRC) - -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -all: $(LIBSYS) - -$(LIBSYS): $(OBJ) - rm -f $(LIBSYS) - $(AR) r $(LIBSYS) $(OBJ) - $(RANLIB) $(LIBSYS) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBSYS) $(MOD_DIR)/lib/$(LIBSYS) - $(RANLIB) $(MOD_DIR)/lib/$(LIBSYS) - cp $(SRC_DIR)/system.h $(MOD_DIR)/h/system.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/system.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBSYS) $(MOD_DIR)/lib/$(LIBSYS) - -cmp $(SRC_DIR)/system.h $(MOD_DIR)/h/system.h - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -pr: - @pr $(SRC) - -opr: - make pr | opr - -lintlib: - $(MK_LINT_LIB) system $(MOD_DIR)/lib $(INCLUDES) $(CSRC) - -access.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/access.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/access.c - -break.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/break.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/break.c - -chmode.$(SUF): $(SRC_DIR)/chmode.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/chmode.c - -close.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/close.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/close.c - -create.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/create.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/create.c - -filesize.$(SUF): $(SRC_DIR)/filesize.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/filesize.c - -lock.$(SUF): $(SRC_DIR)/lock.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lock.c - -modtime.$(SUF): $(SRC_DIR)/modtime.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/modtime.c - -open.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/open.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/open.c - -read.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/read.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/read.c - -remove.$(SUF): $(SRC_DIR)/remove.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/remove.c - -rename.$(SUF): $(SRC_DIR)/rename.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rename.c - -seek.$(SUF): $(SRC_DIR)/seek.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/seek.c - -stop.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/stop.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/stop.c - -system.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/system.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/system.c - -time.$(SUF): $(SRC_DIR)/time.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/time.c - -unlock.$(SUF): $(SRC_DIR)/unlock.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/unlock.c - -write.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/write.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/write.c diff --git a/plat/build.mk b/plat/build.mk deleted file mode 100644 index 623658b07..000000000 --- a/plat/build.mk +++ /dev/null @@ -1,68 +0,0 @@ - -define build-platform-headers -$(call reset) -$(eval q := $D/include/$(strip $1)) -$(call installto, $(PLATIND)/$(PLATFORM)/include/$(strip $1)) -$(eval PLATFORM_HEADERS_$(PLATFORM) += $q) -endef - -define build-platform-impl - $(call reset) - $(eval q := $D/descr) - $(call installto, $(PLATIND)/descr/$(PLATFORM)) - - $(foreach f, $(platform-headers), $(call build-platform-headers, $f)) - - $(eval PLATFORM_$(PLATFORM) := \ - $(PLATIND)/descr/$(PLATFORM) \ - $(PLATFORM_HEADERS_$(PLATFORM)) \ - $(PLATDEP)/$(PLATFORM)/as \ - $(if $(arch-cg-$(ARCH)), $(PLATDEP)/$(PLATFORM)/cg, $(PLATDEP)/$(PLATFORM)/ncg) \ - $(ARCHITECTURE_$(ARCH))) - - # libsys - - $(call reset) - $(foreach f, $(platform-libsys), $(call ackfile, $D/libsys/$f)) - $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libsys.a) - $(call installto, $(PLATIND)/$(PLATFORM)/libsys.a) - - # libem - - $(call reset) - $(eval objdir := $(PLATFORM)) - $(eval ackflags += -Ih) - $(foreach f, $(arch-libem-$(ARCH)), $(call ackfile, mach/$(ARCH)/libem/$f)) - $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libem.a) - $(call installto, $(PLATIND)/$(PLATFORM)/libem.a) - - # libend - - $(call reset) - $(eval objdir := $(PLATFORM)) - $(eval ackflags += -Ih) - $(foreach f, $(arch-libend-$(ARCH)), $(call ackfile, mach/$(ARCH)/libend/$f)) - $(call acklibrary, $(LIBDIR)/$(PLATFORM)/libend.a) - $(call installto, $(PLATIND)/$(PLATFORM)/libend.a) - - # The tools themselves - - $(call build-as) - $(if $(arch-cg-$(ARCH)), $(call build-cg), $(call build-ncg)) - - # Build top only if the architecture asks for it. - - $(if $(arch-top-$(ARCH)), $(call build-top)) - - # Language runtimes - - $(foreach runtime, $(RUNTIMES), $(build-runtime-$(runtime))) - - # Install the ego descr file for this architecture - - $(call build-ego-descr) -endef - -build-platform = $(eval $(call build-platform-impl, $1)) - - diff --git a/plat/cpm/build.mk b/plat/cpm/build.mk deleted file mode 100644 index 54ed3d839..000000000 --- a/plat/cpm/build.mk +++ /dev/null @@ -1,42 +0,0 @@ -ARCH := i80 -PLATFORM := cpm -OPTIMISATION := -O - -D := plat/cpm - -platform-headers := \ - ack/config.h \ - cpm.h \ - unistd.h - -platform-libsys := \ - _bdos.s \ - _hol0.s \ - _inn2.s \ - _trap.s \ - brk.c \ - close.c \ - creat.c \ - errno.s \ - getpid.c \ - isatty.c \ - kill.c \ - lseek.c \ - open.c \ - read.c \ - signal.c \ - time.c \ - write.c - -$(eval $(call build-platform)) - -define build-cpm-boot-impl - $(call reset) - $(call ackfile, $D/boot.s) - $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) -endef - -$(eval $(build-cpm-boot-impl)) - - - diff --git a/plat/linux/libsys/build.mk b/plat/linux/libsys/build.mk deleted file mode 100644 index 3cff634f9..000000000 --- a/plat/linux/libsys/build.mk +++ /dev/null @@ -1,27 +0,0 @@ -define build-liblinux-impl - -$(call reset) -$(eval objdir := $(PLATFORM)) -$(call ackfile, plat/linux/liblinux/_exit.c) -$(call ackfile, plat/linux/liblinux/_hol0.s) -$(call ackfile, plat/linux/liblinux/brk.c) -$(call ackfile, plat/linux/liblinux/close.c) -$(call ackfile, plat/linux/liblinux/creat.c) -$(call ackfile, plat/linux/liblinux/errno.s) -$(call ackfile, plat/linux/liblinux/getpid.c) -$(call ackfile, plat/linux/liblinux/gettimeofday.c) -$(call ackfile, plat/linux/liblinux/isatty.c) -$(call ackfile, plat/linux/liblinux/kill.c) -$(call ackfile, plat/linux/liblinux/lseek.c) -$(call ackfile, plat/linux/liblinux/open.c) -$(call ackfile, plat/linux/liblinux/read.c) -$(call ackfile, plat/linux/liblinux/sbrk.c) -$(call ackfile, plat/linux/liblinux/signal.c) -$(call ackfile, plat/linux/liblinux/write.c) - -$(call acklibrary, $(OBJDIR)/$D/liblinux.a) -$(call installto, $(PLATIND)/$(PLATFORM)/liblinux.a) - -endef - -build-liblinux = $(eval $(build-liblinux-impl)) diff --git a/plat/linux386/build.mk b/plat/linux386/build.mk deleted file mode 100644 index f35fa6be7..000000000 --- a/plat/linux386/build.mk +++ /dev/null @@ -1,28 +0,0 @@ -ARCH := i386 -PLATFORM := linux386 -OPTIMISATION := -O - -D := plat/linux386/ - -platform-headers := \ - ack/config.h \ - sys/ioctl.h \ - unistd.h - -platform-libsys := \ - _syscall.s - -$(eval $(call build-platform)) -$(eval $(call build-liblinux)) - -define build-linux386-boot-impl - $(call reset) - $(call ackfile, $D/boot.s) - $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) -endef - -$(eval $(build-linux386-boot-impl)) - - - - diff --git a/plat/linux68k/build.mk b/plat/linux68k/build.mk deleted file mode 100644 index 7a1e7223b..000000000 --- a/plat/linux68k/build.mk +++ /dev/null @@ -1,25 +0,0 @@ -ARCH := m68020 -PLATFORM := linux68k -OPTIMISATION := -O6 - -D := plat/linux68k/ - -platform-headers := \ - ack/config.h \ - sys/ioctl.h \ - unistd.h - -platform-libsys := \ - _syscall.s - -$(eval $(call build-platform)) -$(eval $(call build-liblinux)) - -define build-linux68k-boot-impl - $(call reset) - $(call ackfile, $D/boot.s) - $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) -endef - -$(eval $(build-linux68k-boot-impl)) - diff --git a/plat/linuxppc/build.mk b/plat/linuxppc/build.mk deleted file mode 100644 index d19fa5aa3..000000000 --- a/plat/linuxppc/build.mk +++ /dev/null @@ -1,31 +0,0 @@ -ARCH := powerpc -PLATFORM := linuxppc -OPTIMISATION := -O6 - -D := plat/linuxppc/ - -platform-headers := \ - ack/config.h \ - sys/ioctl.h \ - unistd.h - -platform-libsys := \ - _syscall.s \ - trap.s - -$(eval $(call build-platform)) -$(eval $(call build-liblinux)) - -define build-linuxppc-boot-impl - $(call reset) - $(call ackfile, $D/boot.s) - $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) -endef - -$(eval $(build-linuxppc-boot-impl)) - - - - - - diff --git a/plat/pc86/build.mk b/plat/pc86/build.mk deleted file mode 100644 index 1ae9e5f49..000000000 --- a/plat/pc86/build.mk +++ /dev/null @@ -1,38 +0,0 @@ -ARCH := i86 -PLATFORM := pc86 -OPTIMISATION := -O - -D := plat/pc86/ - -platform-headers := \ - ack/config.h \ - unistd.h - -platform-libsys := \ - errno.s \ - _hol0.s \ - _sys_rawread.s \ - _sys_rawwrite.s \ - open.c \ - creat.c \ - close.c \ - read.c \ - write.c \ - brk.c \ - getpid.c \ - kill.c \ - isatty.c \ - lseek.c \ - time.c \ - signal.c - -$(eval $(call build-platform)) - -define build-pc86-boot-impl - $(call reset) - $(call ackfile, $D/boot.s) - $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) -endef - -$(eval $(build-pc86-boot-impl)) - diff --git a/plat/rpi/build.mk b/plat/rpi/build.mk deleted file mode 100644 index c89847607..000000000 --- a/plat/rpi/build.mk +++ /dev/null @@ -1,52 +0,0 @@ -# Build script for Raspberry Pi bare-metal executables (using the -# VideoCore IV processor, not the ARM). -# -# © 2013 David Given -# This file is redistributable under the terms of the 3-clause BSD license. -# See the file 'Copying' in the root of the distribution for the full text. - -ARCH := vc4 -PLATFORM := rpi -OPTIMISATION := -O - -D := plat/rpi/ - -platform-headers := \ - unistd.h \ - termios.h \ - pi.h \ - ack/config.h - -platform-libsys := \ - _hol0.s \ - errno.s \ - pi_phys_to_user.s \ - pi_user_to_phys.s \ - pi_uart.s \ - pi_fast_mode.s \ - creat.c \ - close.c \ - open.c \ - read.c \ - write.c \ - isatty.c \ - brk.c \ - getpid.c \ - kill.c \ - lseek.c \ - time.c \ - signal.c \ - tcgetattr.c \ - tcsetattr.c \ - select.c - -$(eval $(call build-platform)) - -define build-rpi-boot-impl - $(call reset) - $(call ackfile, $D/boot.s) - $(call installto, $(PLATIND)/$(PLATFORM)/boot.o) -endef - -$(eval $(build-rpi-boot-impl)) - diff --git a/util/LLgen/build.mk b/util/LLgen/build.mk deleted file mode 100644 index 28da2d715..000000000 --- a/util/LLgen/build.mk +++ /dev/null @@ -1,56 +0,0 @@ -D := util/LLgen - -# Rule to build LLgen. - -define build-llgen-impl - $(call reset) - $(eval cflags += -DNON_CORRECTING -DLIBDIR=\"$(abspath $D/lib)\") - $(call cfile, $D/src/main.c) - $(call cfile, $D/src/gencode.c) - $(call cfile, $D/src/compute.c) - $(call cfile, $D/src/check.c) - $(call cfile, $D/src/reach.c) - $(call cfile, $D/src/global.c) - $(call cfile, $D/src/name.c) - $(call cfile, $D/src/sets.c) - $(call cfile, $D/src/alloc.c) - $(call cfile, $D/src/machdep.c) - $(call cfile, $D/src/cclass.c) - $(call cfile, $D/src/savegram.c) - - # These use pre-LLgen'd version of the files. If LLgen.g gets updated, - # they need rebuilding. Use the bootstrap script to do this. - - $(call cfile, $D/src/LLgen.c) - $(call cfile, $D/src/Lpars.c) - $(call cfile, $D/src/tokens.c) - - $(call cprogram, $(BINDIR)/LLgen) - LLGEN := $o -endef - -$(eval $(build-llgen-impl)) - -# Rule to invoke to *use* LLgen. -# -# $1: directory to put output files -# $2: input files -# -# Output files are compiled via cfile and queued. - -define llgen-impl -$(eval o := $1/Lpars.c $(patsubst %.g, $(strip $1)/%.c, $(notdir $2))) -$(eval CLEANABLES += $o $1/Lpars.h) - -$o: $1/Lpars.h -$1/Lpars.h: $2 $(LLGEN) - @echo LLGEN $1/Lpars.c - @mkdir -p $1 - $(hide) $(RM) $o $1/Lpars.h - $(hide) cd $1 && $(LLGEN) $(abspath $2) - -$(foreach f,$o,$(call cfile,$f)) - -endef - -llgen = $(eval $(call llgen-impl,$1,$2)) diff --git a/util/ack/build.mk b/util/ack/build.mk deleted file mode 100644 index 36e505c12..000000000 --- a/util/ack/build.mk +++ /dev/null @@ -1,57 +0,0 @@ -D := util/ack - -define util-ack-makeheaders-rule -$(eval g := $(OBJDIR)/$D/dmach.c $(OBJDIR)/$D/intable.c) -$(wordlist 2, $(words $g), $g): $(firstword $g) -$(firstword $g): $(util-ack-mktables) - @echo MKTABLES - @mkdir -p $(OBJDIR)/$D - $(hide) cd $(OBJDIR)/$D && $(util-ack-mktables) $(INSDIR)/share - -$(eval CLEANABLES += $g) -endef - -define build-ack-impl - $(call reset) - $(call cfile, $D/mktables.c) - $(call cprogram, $(OBJDIR)/$D/mktables) - $(eval util-ack-mktables := $o) - - $(call reset) - $(eval cflags += -I$D) - $(call cfile, $D/list.c) - $(call cfile, $D/data.c) - $(call cfile, $D/main.c) - $(call cfile, $D/scan.c) - $(call cfile, $D/svars.c) - $(call cfile, $D/trans.c) - $(call cfile, $D/util.c) - - $(call cfile, $D/rmach.c) - $(call dependson, $(INCDIR)/em_path.h) - - $(call cfile, $D/run.c) - $(call cfile, $D/grows.c) - - $(call cfile, $D/files.c) - $(call dependson, $(INCDIR)/em_path.h) - - $(eval $(util-ack-makeheaders-rule)) - $(call cfile, $(OBJDIR)/$D/dmach.c) - $(call cfile, $(OBJDIR)/$D/intable.c) - - $(call cprogram, $(BINDIR)/ack) - $(call installto, $(INSDIR)/bin/ack) - $(eval ACK := $o) - - $(call reset) - $(eval q := lib/descr/fe) - $(call installto, $(PLATIND)/descr/fe) - $(eval $(ACK): $o) - - $(call reset) - $(eval q := $D/ack.1.X) - $(call installto, $(INSDIR)/share/man/man1/ack.1) -endef - -$(eval $(build-ack-impl)) diff --git a/util/ack/proto.make b/util/ack/proto.make deleted file mode 100644 index 1c4356059..000000000 --- a/util/ack/proto.make +++ /dev/null @@ -1,187 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ack - -HFILES=\ - $(SRC_DIR)/ack.h \ - $(SRC_DIR)/list.h \ - $(SRC_DIR)/trans.h \ - $(SRC_DIR)/data.h \ - $(SRC_DIR)/dmach.h \ - $(SRC_DIR)/grows.h - -DSRC=\ - $(SRC_DIR)/list.c \ - $(SRC_DIR)/data.c \ - $(SRC_DIR)/main.c \ - $(SRC_DIR)/scan.c \ - $(SRC_DIR)/svars.c \ - $(SRC_DIR)/trans.c \ - $(SRC_DIR)/util.c \ - $(SRC_DIR)/rmach.c \ - $(SRC_DIR)/run.c \ - $(SRC_DIR)/grows.c \ - $(SRC_DIR)/files.c - -ISRC=\ - dmach.c \ - intable.c - -CFILES = $(DSRC) $(ISRC) - -OBJ=\ - list.$(SUF) \ - data.$(SUF) \ - main.$(SUF) \ - scan.$(SUF) \ - svars.$(SUF) \ - trans.$(SUF) \ - util.$(SUF) \ - rmach.$(SUF) \ - run.$(SUF) \ - dmach.$(SUF) \ - intable.$(SUF) \ - grows.$(SUF) \ - files.$(SUF) - -ACKDIR=$(TARGET_HOME)/lib -FE=fe -INTABLES=sun3 -LNTABLES=acc apc abc ocm m2 f2c vax4 i86 i386 m68k2 m68k4 pmds pmds4 mantra \ - m68020 z8000 pdp em22 em24 em44 6500 6800 6805 6809 i80 ns s2650 z80 \ - sun2 xenix3 minix minixST sparc sparc_solaris arm -INCLUDES=-I$(TARGET_HOME)/h -I$(TARGET_HOME)/config -I$(SRC_DIR) -CFLAGS= $(INCLUDES) $(COPTIONS) -UCFLAGS= $(INCLUDES) $(UCOPTIONS) -LINTFLAGS= $(INCLUDES) $(LINTOPTIONS) -LDFLAGS= $(LDOPTIONS) -ULDFLAGS= $(ULDOPTIONS) -BINDIR=$(TARGET_HOME)/bin -HDIR=$(TARGET_HOME)/h -MODDIR=$(TARGET_HOME)/modules/lib - -all: ack ack.1 - -install: ack ack.1 - cp ack $(BINDIR)/ack - -cd $(BINDIR) ; \ - for i in $(INTABLES) $(LNTABLES) ; do rm -f $$i ; ln ack $$i ; done - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage ack.1 $(TARGET_HOME) ; \ - fi - -cmp: ack - -cmp ack $(BINDIR)/ack - -ack.1: $(SRC_DIR)/ack.1.X - -sh -c 'tbl < $(SRC_DIR)/ack.1.X > ack.1' - -sh -c 'if test -s ack.1 ; then : ; else cp $(SRC_DIR)/ack.1.X ack.1 ; fi' - -clean: - -rm -f *.old *.$(SUF) mktables *.$(USUF) ack ack.1 $(ISRC) - -ack: $(OBJ) - $(CC) $(LDFLAGS) -o ack $(OBJ) $(MODDIR)/libstring.$(LIBSUF) - -depend: $(ISRC) - rm_deps Makefile > Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -dmach.c intable.c: mktables $(SRC_DIR)/dmach.h - : mktables $(ACKDIR) # $(FE) $(INTABLES) - mktables $(ACKDIR) - -mktables: mktables.$(USUF) - $(UCC) -o mktables $(ULDFLAGS) mktables.$(USUF) - -mktables.$(USUF): $(SRC_DIR)/mktables.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/mktables.c - -pr: - @pr $(SRC_DIR)/proto.make $(HFILES) $(DSRC) - -opr: - make pr | opr - -lint: $(ISRC) - $(LINT) $(LINTFLAGS) $(CFILES) $(UTIL_HOME)/modules/lib/$(LINTPREF)string.$(LINTSUF) - -# do not remove the next line -#DEPENDENCIES -list.$(SUF): $(SRC_DIR)/list.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/list.c -list.$(SUF): $(SRC_DIR)/list.h -list.$(SUF): $(SRC_DIR)/ack.h -data.$(SUF): $(SRC_DIR)/data.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/data.c -data.$(SUF): $(SRC_DIR)/data.h -data.$(SUF): $(SRC_DIR)/trans.h -data.$(SUF): $(SRC_DIR)/list.h -data.$(SUF): $(SRC_DIR)/ack.h -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -main.$(SUF): $(SRC_DIR)/data.h -main.$(SUF): $(TARGET_HOME)/config/local.h -main.$(SUF): $(SRC_DIR)/trans.h -main.$(SUF): $(SRC_DIR)/list.h -main.$(SUF): $(SRC_DIR)/ack.h -scan.$(SUF): $(SRC_DIR)/scan.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/scan.c -scan.$(SUF): $(SRC_DIR)/data.h -scan.$(SUF): $(SRC_DIR)/trans.h -scan.$(SUF): $(SRC_DIR)/list.h -scan.$(SUF): $(SRC_DIR)/ack.h -svars.$(SUF): $(SRC_DIR)/svars.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/svars.c -svars.$(SUF): $(SRC_DIR)/ack.h -trans.$(SUF): $(SRC_DIR)/trans.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/trans.c -trans.$(SUF): $(SRC_DIR)/data.h -trans.$(SUF): $(SRC_DIR)/grows.h -trans.$(SUF): $(SRC_DIR)/trans.h -trans.$(SUF): $(SRC_DIR)/list.h -trans.$(SUF): $(SRC_DIR)/ack.h -util.$(SUF): $(SRC_DIR)/util.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/util.c -util.$(SUF): $(SRC_DIR)/ack.h -rmach.$(SUF): $(SRC_DIR)/rmach.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rmach.c -rmach.$(SUF): $(SRC_DIR)/data.h -rmach.$(SUF): $(SRC_DIR)/dmach.h -rmach.$(SUF): $(SRC_DIR)/grows.h -rmach.$(SUF): $(SRC_DIR)/trans.h -rmach.$(SUF): $(SRC_DIR)/list.h -rmach.$(SUF): $(TARGET_HOME)/config/em_path.h -rmach.$(SUF): $(SRC_DIR)/ack.h -run.$(SUF): $(SRC_DIR)/run.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/run.c -run.$(SUF): $(SRC_DIR)/data.h -run.$(SUF): $(SRC_DIR)/grows.h -run.$(SUF): $(SRC_DIR)/trans.h -run.$(SUF): $(SRC_DIR)/list.h -run.$(SUF): $(SRC_DIR)/ack.h -grows.$(SUF): $(SRC_DIR)/grows.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/grows.c -grows.$(SUF): $(SRC_DIR)/grows.h -grows.$(SUF): $(SRC_DIR)/ack.h -files.$(SUF): $(SRC_DIR)/files.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/files.c -files.$(SUF): $(TARGET_HOME)/config/em_path.h -files.$(SUF): $(SRC_DIR)/data.h -files.$(SUF): $(SRC_DIR)/grows.h -files.$(SUF): $(SRC_DIR)/trans.h -files.$(SUF): $(SRC_DIR)/list.h -files.$(SUF): $(SRC_DIR)/ack.h -dmach.$(SUF): dmach.c - $(CC) -c $(CFLAGS) dmach.c -dmach.$(SUF): $(SRC_DIR)/dmach.h -intable.$(SUF): intable.c - $(CC) -c $(CFLAGS) intable.c diff --git a/util/amisc/build.mk b/util/amisc/build.mk deleted file mode 100644 index 286b8f305..000000000 --- a/util/amisc/build.mk +++ /dev/null @@ -1,23 +0,0 @@ - -define build-simple-tool-impl - $(call reset) - $(call cfile, util/amisc/$1.c) - $(call rawfile, $(LIBOBJECT)) - $(call cprogram, $(BINDIR)/$1) - $(eval INSTALLABLES += $o) - $(call installto, $(INSDIR)/bin/$1) - - $(call reset) - $(eval q := util/amisc/$1.1) - $(call installto, $(INSDIR)/share/man/man1/$1.1) -endef - -build-simple-tool = $(eval $(build-simple-tool-impl)) - -$(call build-simple-tool,anm) -$(call build-simple-tool,ashow) -$(call build-simple-tool,asize) -$(call build-simple-tool,aslod) -$(call build-simple-tool,astrip) -$(call build-simple-tool,aelflod) - diff --git a/util/amisc/proto.make b/util/amisc/proto.make deleted file mode 100644 index 64bbcc27e..000000000 --- a/util/amisc/proto.make +++ /dev/null @@ -1,48 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/amisc -BINDIR = $(TARGET_HOME)/bin -LDFLAGS = $(LDOPTIONS) -INCLUDES = -I$(TARGET_HOME)/h -CFLAGS = $(INCLUDES) $(COPTIONS) -LINTFLAGS = $(INCLUDES) $(LINTOPTIONS) - -ALL = anm asize astrip ashow -LIBS = $(TARGET_HOME)/modules/lib/libobject.$(LIBSUF) -LINTLIBS = $(UTIL_HOME)/modules/lib/$(LINTPREF)object.$(LINTSUF) - -all: $(ALL) - -anm: $(SRC_DIR)/anm.c - $(CC) $(CFLAGS) $(LDFLAGS) -o anm $(SRC_DIR)/anm.c $(LIBS) -asize: $(SRC_DIR)/asize.c - $(CC) $(CFLAGS) $(LDFLAGS) -o asize $(SRC_DIR)/asize.c $(LIBS) -astrip: $(SRC_DIR)/astrip.c - $(CC) $(CFLAGS) $(LDFLAGS) -o astrip $(SRC_DIR)/astrip.c $(LIBS) -ashow: $(SRC_DIR)/ashow.c - $(CC) $(CFLAGS) $(LDFLAGS) -o ashow $(SRC_DIR)/ashow.c $(LIBS) - -install: all - for i in $(ALL); do rm -f $(BINDIR)/$$i; cp $$i $(BINDIR)/$$i; done - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then for i in anm.1 asize.1 astrip.1; do mk_manpage $(SRC_DIR)/$$i $(TARGET_HOME) ; done ; \ - fi - -cmp: all - -for i in $(ALL); do cmp $$i $(BINDIR)/$$i; done - -clean: ; rm -f $(ALL) *.$(SUF) - -lint: - $(LINT) $(LINTFLAGS) $(SRC_DIR)/anm.c $(LINTLIBS) - $(LINT) $(LINTFLAGS) $(SRC_DIR)/asize.c $(LINTLIBS) - $(LINT) $(LINTFLAGS) $(SRC_DIR)/astrip.c $(LINTLIBS) - $(LINT) $(LINTFLAGS) $(SRC_DIR)/ashow.c $(LINTLIBS) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/anm.c $(SRC_DIR)/astrip.c $(SRC_DIR)/asize.c $(SRC_DIR)/ashow.c - -opr: - make pr | opr diff --git a/util/arch/build.mk b/util/arch/build.mk deleted file mode 100644 index 11851f5c9..000000000 --- a/util/arch/build.mk +++ /dev/null @@ -1,24 +0,0 @@ -D := util/arch - -define build-aal-impl - $(call reset) - $(eval cflags += -DAAL) - - $(call cfile, $D/archiver.c) - - $(call rawfile, $(LIBOBJECT)) - $(call rawfile, $(LIBPRINT)) - $(call rawfile, $(LIBSTRING)) - $(call rawfile, $(LIBSYSTEM)) - - $(call cprogram, $(BINDIR)/aal) - $(call installto, $(INSDIR)/bin/aal) - $(eval AAL := $o) - $(eval ACK_CORE_TOOLS += $o) - - $(call reset) - $(eval q := $D/aal.1) - $(call installto, $(INSDIR)/share/man/man1/aal.1) -endef - -$(eval $(build-aal-impl)) diff --git a/util/arch/proto.make b/util/arch/proto.make deleted file mode 100644 index 3290869ce..000000000 --- a/util/arch/proto.make +++ /dev/null @@ -1,62 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/arch -EMH = $(TARGET_HOME)/h -EMBIN = $(TARGET_HOME)/bin -LIB = $(TARGET_HOME)/modules/lib -ULIB = $(UTIL_HOME)/modules/lib - -LIBS = $(LIB)/libobject.$(LIBSUF) $(LIB)/libprint.$(LIBSUF) \ - $(LIB)/libstring.$(LIBSUF) $(LIB)/libsystem.$(LIBSUF) -LINTLIBS = \ - $(ULIB)/$(LINTPREF)object.$(LINTSUF) \ - $(ULIB)/$(LINTPREF)print.$(LINTSUF) \ - $(ULIB)/$(LINTPREF)string.$(LINTSUF) \ - $(ULIB)/$(LINTPREF)system.$(LINTSUF) - -INCLUDES = -I$(EMH) -CFLAGS= $(INCLUDES) -DDISTRIBUTION $(COPTIONS) -LDFLAGS = $(LDOPTIONS) -LINTFLAGS= $(INCLUDES) -DDISTRIBUTION $(LINTOPTIONS) - -all: arch aal - -arch: arch.$(SUF) - $(CC) $(LDFLAGS) -o arch arch.$(SUF) $(LIBS) - -aal: aal.$(SUF) - $(CC) $(LDFLAGS) -o aal aal.$(SUF) $(LIBS) - -arch.$(SUF): $(EMH)/arch.h $(SRC_DIR)/archiver.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/archiver.c - mv archiver.$(SUF) arch.$(SUF) - -aal.$(SUF): $(EMH)/arch.h $(SRC_DIR)/archiver.c $(EMH)/ranlib.h $(EMH)/out.h - $(CC) -DAAL $(CFLAGS) -c $(SRC_DIR)/archiver.c - mv archiver.$(SUF) aal.$(SUF) - -clean: - rm -f aal arch *.$(SUF) *.old - -lint: - $(LINT) $(LINTFLAGS) -DAAL $(SRC_DIR)/archiver.c $(LINTLIBS) - -install : all - cp aal $(EMBIN)/aal - cp arch $(EMBIN)/arch - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/aal.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/arch.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/arch.5 $(TARGET_HOME) ; \ - fi - -cmp : all - -cmp aal $(EMBIN)/aal - -cmp arch $(EMBIN)/arch - -opr: - make pr ^ opr -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/archiver.c diff --git a/util/cgg/build.mk b/util/cgg/build.mk deleted file mode 100644 index 4fc8532b2..000000000 --- a/util/cgg/build.mk +++ /dev/null @@ -1,25 +0,0 @@ -D := util/cgg - -define build-cgg-impl - -$(call reset) -$(eval cflags += -I$D) - -$(call yacc, $(OBJDIR)/$D, $D/bootgram.y) - -$(call flex, $(OBJDIR)/$D, $D/bootlex.l) -$(call dependson, $(OBJDIR)/$D/y.tab.h) - -$(call cfile, $D/main.c) - -$(eval $q: $(INCDIR)/em_spec.h) - -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBASSERT)) -$(call rawfile, $(LIBSYSTEM)) -$(call cprogram, $(BINDIR)/cgg) -$(eval CGG := $o) - -endef - -$(eval $(build-cgg-impl)) diff --git a/util/cmisc/build.mk b/util/cmisc/build.mk deleted file mode 100644 index ae4b7fb2c..000000000 --- a/util/cmisc/build.mk +++ /dev/null @@ -1,32 +0,0 @@ -# Building tabgen. - -define build-tabgen-impl - $(call reset) - $(call cfile, util/cmisc/tabgen.c) - $(call cprogram, $(BINDIR)/tabgen) - $(eval TABGEN := $o) -endef - -$(eval $(build-tabgen-impl)) - -# Using tabgen. -# -# $1 = input file -# -# Output file is compiled with cfile and queued. - -define tabgen-impl -$(eval g := $(OBJDIR)/$(objdir)/$(strip $1).c) - -$g: $1 $(TABGEN) - @echo TABGEN $g - @mkdir -p $(dir $g) - $(hide) $(TABGEN) -f$(strip $1) > $g || $(RM) $g - -$(eval CLEANABLES += $g) -$(call $2,$g) -endef - -tabgen = $(eval $(call tabgen-impl,$1,cfile)) -acktabgen = $(eval $(call tabgen-impl,$1,ackfile)) - diff --git a/util/cmisc/proto.make b/util/cmisc/proto.make deleted file mode 100644 index d8ede4483..000000000 --- a/util/cmisc/proto.make +++ /dev/null @@ -1,69 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/cmisc -TARGET_BIN = $(TARGET_HOME)/bin -CFLAGS = $(COPTIONS) -LDFLAGS = $(LDOPTIONS) -LINTFLAGS = $(LINTOPTIONS) - -all: cid cclash prid tabgen - -install: all - cp cid cclash prid tabgen $(TARGET_BIN) - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/cid.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/cclash.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/prid.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/tabgen.1 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp cid $(TARGET_BIN)/cid - -cmp cclash $(TARGET_BIN)/cclash - -cmp prid $(TARGET_BIN)/prid - -cmp tabgen $(TARGET_BIN)/tabgen - -clean: - rm -f *.$(SUF) cid cclash prid tabgen - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/cclash.c $(SRC_DIR)/cid.c \ - $(SRC_DIR)/prid.c $(SRC_DIR)/GCIPM.c $(SRC_DIR)/tabgen.c - -opr: - make pr | opr - -tabgen: tabgen.$(SUF) - $(CC) $(LDFLAGS) -o tabgen tabgen.$(SUF) - -cid: cid.$(SUF) GCIPM.$(SUF) - $(CC) $(LDFLAGS) -o cid cid.$(SUF) GCIPM.$(SUF) - -cclash: cclash.$(SUF) GCIPM.$(SUF) - $(CC) $(LDFLAGS) -o cclash cclash.$(SUF) GCIPM.$(SUF) - -prid: prid.$(SUF) GCIPM.$(SUF) - $(CC) $(LDFLAGS) -o prid prid.$(SUF) GCIPM.$(SUF) - -lint: - $(LINT) $(LINTFLAGS) $(SRC_DIR)/cid.c $(SRC_DIR)/GCIPM.c - $(LINT) $(LINTFLAGS) $(SRC_DIR)/prid.c $(SRC_DIR)/GCIPM.c - $(LINT) $(LINTFLAGS) $(SRC_DIR)/cclash.c $(SRC_DIR)/GCIPM.c - $(LINT) $(LINTFLAGS) $(SRC_DIR)/tabgen.c - -tabgen.$(SUF): $(SRC_DIR)/tabgen.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/tabgen.c - -cid.$(SUF): $(SRC_DIR)/cid.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cid.c - -prid.$(SUF): $(SRC_DIR)/prid.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/prid.c - -cclash.$(SUF): $(SRC_DIR)/cclash.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cclash.c - -GCIPM.$(SUF): $(SRC_DIR)/GCIPM.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/GCIPM.c diff --git a/util/ego/bo/proto.make b/util/ego/bo/proto.make deleted file mode 100644 index 214015a99..000000000 --- a/util/ego/bo/proto.make +++ /dev/null @@ -1,77 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/bo -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/bo.c - -OFILES=\ -bo.$(SUF) - -HFILES= - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: bo - -bo: $(OFILES) - $(CC) -o bo $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp bo $(EMLIB)/ego/bo - -cmp: all - -cmp bo $(EMLIB)/ego/bo - -clean: - rm -f *.$(SUF) bo Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -bo.$(SUF): $(SRC_DIR)/bo.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/bo.c -bo.$(SUF): $(SRC_DIR)/../share/go.h -bo.$(SUF): $(SRC_DIR)/../share/def.h -bo.$(SUF): $(SRC_DIR)/../share/aux.h -bo.$(SUF): $(SRC_DIR)/../share/alloc.h -bo.$(SUF): $(SRC_DIR)/../share/map.h -bo.$(SUF): $(SRC_DIR)/../share/lset.h -bo.$(SUF): $(SRC_DIR)/../share/put.h -bo.$(SUF): $(SRC_DIR)/../share/get.h -bo.$(SUF): $(SRC_DIR)/../share/files.h -bo.$(SUF): $(SRC_DIR)/../share/global.h -bo.$(SUF): $(SRC_DIR)/../share/debug.h -bo.$(SUF): $(SRC_DIR)/../share/types.h -bo.$(SUF): $(EMH)/em_flag.h -bo.$(SUF): $(EMH)/em_spec.h -bo.$(SUF): $(EMH)/em_pseu.h -bo.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/build.mk b/util/ego/build.mk deleted file mode 100644 index 2fba61ff3..000000000 --- a/util/ego/build.mk +++ /dev/null @@ -1,205 +0,0 @@ -D := util/ego - -define build-ego-backend-impl - -$(call reset) -$(eval cflags += -DVERBOSE -DNOTCOMPACT) -$(eval cflags += -I$D/share -I$(OBJDIR)/$D) -$(foreach f, $2, $(call cfile, $f)) -$(call rawfile, $(LIBDIR)/libegocore.a) -$(call rawfile, $(LIBEM_DATA)) -$(call cprogram, $(BINDIR)/ego/$(strip $1)) -$(call installto, $(PLATDEP)/ego/$(strip $1)) -$(eval EGO_MODULES += $q) - -endef - -define build-ego-impl - -# Generated files that egocore needs. - -$(call reset) -$(call cfile, $D/share/makecldef.c) -$(call cprogram, $(OBJDIR)/$D/makecldef) - -$(eval g := $(OBJDIR)/$D/classdefs.h) -$(eval CLEANABLES += $g) -$g: $(OBJDIR)/$D/makecldef $(INCDIR)/em_mnem.h $D/share/cldefs.src - @echo MAKECLDEF $g - @mkdir -p $(dir $g) - $(hide) $$^ > $g - -$(eval g := $(OBJDIR)/$D/pop_push.h) -$(eval CLEANABLES += $g) -$g: $D/share/pop_push.awk h/em_table - @echo POP_PUSH $g - @mkdir -p $(dir $g) - $(hide) awk -f $D/share/pop_push.awk < h/em_table > $g - -# Build the egocore library. - -$(call reset) -$(eval cflags += -I$D/share -I$(OBJDIR)/$D) -$(eval cflags += -DVERBOSE -DNOTCOMPACT) - -$(call cfile, $D/share/debug.c) -$(call cfile, $D/share/global.c) -$(call cfile, $D/share/files.c) -$(call cfile, $D/share/go.c) -$(call cfile, $D/share/map.c) -$(call cfile, $D/share/aux.c) -$(call cfile, $D/share/get.c) -$(call cfile, $D/share/put.c) -$(call cfile, $D/share/alloc.c) -$(call cfile, $D/share/lset.c) -$(call cfile, $D/share/cset.c) -$(call cfile, $D/share/parser.c) -$(call cfile, $D/share/stack_chg.c) -$(call cfile, $D/share/locals.c) -$(call cfile, $D/share/init_glob.c) -$(eval $q: $(OBJDIR)/$D/classdefs.h $(OBJDIR)/$D/pop_push.h) - -$(call clibrary, $(LIBDIR)/libegocore.a) -$(eval CLEANABLES += $q) - -# Now build each of the back ends. - -$(call build-ego-backend-impl, bo, \ - $D/bo/bo.c) - -$(call build-ego-backend-impl, ca, \ - $D/ca/ca.c \ - $D/ca/ca_put.c) - -$(call build-ego-backend-impl, cf, \ - $D/cf/cf.c \ - $D/cf/cf_idom.c \ - $D/cf/cf_loop.c \ - $D/cf/cf_succ.c) - -$(call build-ego-backend-impl, cj, \ - $D/cj/cj.c) - -$(call build-ego-backend-impl, cs, \ - $D/cs/cs.c \ - $D/cs/cs_alloc.c \ - $D/cs/cs_aux.c \ - $D/cs/cs_avail.c \ - $D/cs/cs_debug.c \ - $D/cs/cs_elim.c \ - $D/cs/cs_entity.c \ - $D/cs/cs_getent.c \ - $D/cs/cs_kill.c \ - $D/cs/cs_partit.c \ - $D/cs/cs_profit.c \ - $D/cs/cs_stack.c \ - $D/cs/cs_vnm.c) - -$(call build-ego-backend-impl, ic, \ - $D/ic/ic.c \ - $D/ic/ic_aux.c \ - $D/ic/ic_io.c \ - $D/ic/ic_lib.c \ - $D/ic/ic_lookup.c) - -$(call build-ego-backend-impl, il, \ - $D/il/il.c \ - $D/il/il1_anal.c \ - $D/il/il1_aux.c \ - $D/il/il1_cal.c \ - $D/il/il1_formal.c \ - $D/il/il2_aux.c \ - $D/il/il3_aux.c \ - $D/il/il3_change.c \ - $D/il/il3_subst.c \ - $D/il/il_aux.c) - -$(call build-ego-backend-impl, lv, \ - $D/lv/lv.c) - -$(call build-ego-backend-impl, ra, \ - $D/ra/ra.c \ - $D/ra/ra_allocl.c \ - $D/ra/ra_aux.c \ - $D/ra/ra_interv.c \ - $D/ra/ra_lifet.c \ - $D/ra/ra_pack.c \ - $D/ra/ra_profits.c \ - $D/ra/ra_xform.c \ - $D/ra/ra_items.c) - -$(eval g := $(OBJDIR)/$D/itemtab.h) -$(eval CLEANABLES += $g) -$D/ra/ra_items.c: $g -$g: $(OBJDIR)/$D/makeitems $(INCDIR)/em_mnem.h $D/ra/itemtab.src - @echo MAKEITEMS $g - @mkdir -p $(dir $g) - $(hide) $$^ > $g - -$(call reset) -$(call cfile, $D/ra/makeitems.c) -$(call cprogram, $(OBJDIR)/$D/makeitems) - -$(call build-ego-backend-impl, sp, \ - $D/sp/sp.c) - -$(call build-ego-backend-impl, sr, \ - $D/sr/sr.c \ - $D/sr/sr_aux.c \ - $D/sr/sr_cand.c \ - $D/sr/sr_expr.c \ - $D/sr/sr_iv.c \ - $D/sr/sr_reduce.c \ - $D/sr/sr_xform.c) - -$(call build-ego-backend-impl, ud, \ - $D/ud/ud.c \ - $D/ud/ud_aux.c \ - $D/ud/ud_const.c \ - $D/ud/ud_copy.c \ - $D/ud/ud_defs.c) - -# ...and now the front end, which depends on all the backends. - -$(call reset) -$(call cfile, $D/em_ego/em_ego.c) -$(eval $q: $(INCDIR)/print.h $(INCDIR)/system.h) -$(eval $q: $(INCDIR)/em_path.h) - -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBSTRING)) -$(call rawfile, $(LIBSYSTEM)) - -$(call cprogram, $(BINDIR)/em_ego) -$(call installto, $(PLATDEP)/em_ego) -$(eval EM_EGO := $q) -$(eval $q: $(EGO_MODULES)) -$(eval ACK_CORE_TOOLS += $q) - -endef - -$(eval $(build-ego-impl)) - -# Install the ego descr file for the current architecture, if one exists. -# This is a bit annoying because it's called by each platform, so we need -# to protect against the architecture being seen more than once. And some -# architectures don't get descr files. - -define build-ego-descr-impl - -$(eval EGO_DESCR_$(ARCH) := 1) - -$(eval g := $(PLATIND)/ego/$(ARCH).descr) -$(eval CLEANABLES += $g) -$(eval $(EM_EGO): $g) -$g: util/ego/descr/descr.sed util/ego/descr/$(ARCH).descr $(CPPANSI) \ - $(INCDIR)/em_mnem.h - @echo EGODESCR $g - @mkdir -p $(dir $g) - $(hide) $(CPPANSI) -P -I$(INCDIR) util/ego/descr/$(ARCH).descr | sed -f util/ego/descr/descr.sed > $g - -endef - -build-ego-descr = $(if $(EGO_DESCR_$(ARCH)),, \ - $(if $(wildcard util/ego/descr/$(ARCH).descr), \ - $(eval $(call build-ego-descr-impl, $1)))) \ No newline at end of file diff --git a/util/ego/ca/proto.make b/util/ego/ca/proto.make deleted file mode 100644 index 49986c9e8..000000000 --- a/util/ego/ca/proto.make +++ /dev/null @@ -1,89 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ca -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ca.c \ - $(SRC_DIR)/ca_put.c - -OFILES=\ -ca.$(SUF) ca_put.$(SUF) - -HFILES=\ - $(SRC_DIR)/ca.h \ - $(SRC_DIR)/ca_put.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ca - -ca: $(OFILES) - $(CC) -o ca $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp ca $(EMLIB)/ego/ca - -cmp: all - -cmp ca $(EMLIB)/ego/ca - -clean: - rm -f *.$(SUF) ca Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ca.$(SUF): $(SRC_DIR)/ca.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ca.c -ca.$(SUF): $(SRC_DIR)/ca_put.h -ca.$(SUF): $(SRC_DIR)/../share/get.h -ca.$(SUF): $(SRC_DIR)/../share/alloc.h -ca.$(SUF): $(SRC_DIR)/../share/map.h -ca.$(SUF): $(SRC_DIR)/../share/files.h -ca.$(SUF): $(SRC_DIR)/../share/lset.h -ca.$(SUF): $(SRC_DIR)/../share/global.h -ca.$(SUF): $(SRC_DIR)/../share/debug.h -ca.$(SUF): $(SRC_DIR)/ca.h -ca.$(SUF): $(SRC_DIR)/../share/types.h -ca.$(SUF): $(EMH)/em_mes.h -ca.$(SUF): $(EMH)/em_pseu.h -ca_put.$(SUF): $(SRC_DIR)/ca_put.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ca_put.c -ca_put.$(SUF): $(SRC_DIR)/../share/alloc.h -ca_put.$(SUF): $(SRC_DIR)/../share/map.h -ca_put.$(SUF): $(SRC_DIR)/../share/def.h -ca_put.$(SUF): $(SRC_DIR)/../share/debug.h -ca_put.$(SUF): $(SRC_DIR)/ca.h -ca_put.$(SUF): $(SRC_DIR)/../share/types.h -ca_put.$(SUF): $(EMH)/em_mes.h -ca_put.$(SUF): $(EMH)/em_flag.h -ca_put.$(SUF): $(EMH)/em_mnem.h -ca_put.$(SUF): $(EMH)/em_pseu.h -ca_put.$(SUF): $(EMH)/em_spec.h diff --git a/util/ego/cf/proto.make b/util/ego/cf/proto.make deleted file mode 100644 index e8d49eab1..000000000 --- a/util/ego/cf/proto.make +++ /dev/null @@ -1,117 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/cf -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/cf.c \ - $(SRC_DIR)/cf_succ.c \ - $(SRC_DIR)/cf_idom.c \ - $(SRC_DIR)/cf_loop.c - -OFILES=\ -cf.$(SUF) cf_succ.$(SUF) cf_idom.$(SUF) cf_loop.$(SUF) - -HFILES=\ - $(SRC_DIR)/cf.h \ - $(SRC_DIR)/cf_succ.h \ - $(SRC_DIR)/cf_idom.h \ - $(SRC_DIR)/cf_loop.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: cf - -cf: $(OFILES) - $(CC) -o cf $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp cf $(EMLIB)/ego/cf - -cmp: all - -cmp cf $(EMLIB)/ego/cf - -clean: - rm -f *.$(SUF) cf Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -cf.$(SUF): $(SRC_DIR)/cf.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf.c -cf.$(SUF): $(SRC_DIR)/cf_loop.h -cf.$(SUF): $(SRC_DIR)/cf_idom.h -cf.$(SUF): $(SRC_DIR)/cf_succ.h -cf.$(SUF): $(SRC_DIR)/cf.h -cf.$(SUF): $(SRC_DIR)/../share/def.h -cf.$(SUF): $(SRC_DIR)/../share/put.h -cf.$(SUF): $(SRC_DIR)/../share/get.h -cf.$(SUF): $(SRC_DIR)/../share/cset.h -cf.$(SUF): $(SRC_DIR)/../share/lset.h -cf.$(SUF): $(SRC_DIR)/../share/alloc.h -cf.$(SUF): $(SRC_DIR)/../share/global.h -cf.$(SUF): $(SRC_DIR)/../share/files.h -cf.$(SUF): $(SRC_DIR)/../share/map.h -cf.$(SUF): $(SRC_DIR)/../share/debug.h -cf.$(SUF): $(SRC_DIR)/../share/types.h -cf.$(SUF): $(EMH)/em_mes.h -cf.$(SUF): $(EMH)/em_flag.h -cf.$(SUF): $(EMH)/em_spec.h -cf.$(SUF): $(EMH)/em_pseu.h -cf.$(SUF): $(EMH)/em_mnem.h -cf_succ.$(SUF): $(SRC_DIR)/cf_succ.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf_succ.c -cf_succ.$(SUF): $(SRC_DIR)/../share/map.h -cf_succ.$(SUF): $(SRC_DIR)/cf.h -cf_succ.$(SUF): $(SRC_DIR)/../share/cset.h -cf_succ.$(SUF): $(SRC_DIR)/../share/lset.h -cf_succ.$(SUF): $(SRC_DIR)/../share/global.h -cf_succ.$(SUF): $(SRC_DIR)/../share/debug.h -cf_succ.$(SUF): $(SRC_DIR)/../share/def.h -cf_succ.$(SUF): $(SRC_DIR)/../share/types.h -cf_succ.$(SUF): $(EMH)/em_mnem.h -cf_succ.$(SUF): $(EMH)/em_flag.h -cf_succ.$(SUF): $(EMH)/em_pseu.h -cf_succ.$(SUF): $(EMH)/em_spec.h -cf_idom.$(SUF): $(SRC_DIR)/cf_idom.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf_idom.c -cf_idom.$(SUF): $(SRC_DIR)/cf.h -cf_idom.$(SUF): $(SRC_DIR)/../share/alloc.h -cf_idom.$(SUF): $(SRC_DIR)/../share/lset.h -cf_idom.$(SUF): $(SRC_DIR)/../share/debug.h -cf_idom.$(SUF): $(SRC_DIR)/../share/types.h -cf_loop.$(SUF): $(SRC_DIR)/cf_loop.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf_loop.c -cf_loop.$(SUF): $(SRC_DIR)/cf.h -cf_loop.$(SUF): $(SRC_DIR)/../share/aux.h -cf_loop.$(SUF): $(SRC_DIR)/../share/alloc.h -cf_loop.$(SUF): $(SRC_DIR)/../share/lset.h -cf_loop.$(SUF): $(SRC_DIR)/../share/debug.h -cf_loop.$(SUF): $(SRC_DIR)/../share/types.h diff --git a/util/ego/cj/proto.make b/util/ego/cj/proto.make deleted file mode 100644 index cb8e71bcd..000000000 --- a/util/ego/cj/proto.make +++ /dev/null @@ -1,76 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/cj -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/cj.c - -OFILES=\ -cj.$(SUF) - -HFILES= - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: cj - -cj: $(OFILES) - $(CC) -o cj $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp cj $(EMLIB)/ego/cj - -cmp: all - -cmp cj $(EMLIB)/ego/cj - -clean: - rm -f *.$(SUF) cj Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -cj.$(SUF): $(SRC_DIR)/cj.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cj.c -cj.$(SUF): $(SRC_DIR)/../share/go.h -cj.$(SUF): $(SRC_DIR)/../share/stack_chg.h -cj.$(SUF): $(SRC_DIR)/../share/def.h -cj.$(SUF): $(SRC_DIR)/../share/aux.h -cj.$(SUF): $(SRC_DIR)/../share/alloc.h -cj.$(SUF): $(SRC_DIR)/../share/map.h -cj.$(SUF): $(SRC_DIR)/../share/lset.h -cj.$(SUF): $(SRC_DIR)/../share/put.h -cj.$(SUF): $(SRC_DIR)/../share/get.h -cj.$(SUF): $(SRC_DIR)/../share/files.h -cj.$(SUF): $(SRC_DIR)/../share/global.h -cj.$(SUF): $(SRC_DIR)/../share/debug.h -cj.$(SUF): $(SRC_DIR)/../share/types.h -cj.$(SUF): $(EMH)/em_spec.h -cj.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/cs/proto.make b/util/ego/cs/proto.make deleted file mode 100644 index 0cfb537bc..000000000 --- a/util/ego/cs/proto.make +++ /dev/null @@ -1,251 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/cs -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/cs.c \ - $(SRC_DIR)/cs_alloc.c \ - $(SRC_DIR)/cs_aux.c \ - $(SRC_DIR)/cs_avail.c \ - $(SRC_DIR)/cs_debug.c \ - $(SRC_DIR)/cs_elim.c \ - $(SRC_DIR)/cs_entity.c \ - $(SRC_DIR)/cs_kill.c \ - $(SRC_DIR)/cs_partit.c \ - $(SRC_DIR)/cs_profit.c \ - $(SRC_DIR)/cs_getent.c \ - $(SRC_DIR)/cs_stack.c \ - $(SRC_DIR)/cs_vnm.c - -OFILES=\ - cs.$(SUF) \ - cs_alloc.$(SUF) \ - cs_aux.$(SUF) \ - cs_avail.$(SUF) \ - cs_debug.$(SUF) \ - cs_elim.$(SUF) \ - cs_entity.$(SUF) \ - cs_kill.$(SUF) \ - cs_partit.$(SUF) \ - cs_profit.$(SUF) \ - cs_getent.$(SUF) \ - cs_stack.$(SUF) \ - cs_vnm.$(SUF) - -HFILES=\ - $(SRC_DIR)/cs.h \ - $(SRC_DIR)/cs_alloc.h \ - $(SRC_DIR)/cs_aux.h \ - $(SRC_DIR)/cs_avail.h \ - $(SRC_DIR)/cs_debug.h \ - $(SRC_DIR)/cs_elim.h \ - $(SRC_DIR)/cs_entity.h \ - $(SRC_DIR)/cs_kill.h \ - $(SRC_DIR)/cs_partit.h \ - $(SRC_DIR)/cs_profit.h \ - $(SRC_DIR)/cs_getent.h \ - $(SRC_DIR)/cs_stack.h \ - $(SRC_DIR)/cs_vnm.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: cs - -cs: $(OFILES) - $(CC) -o cs $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp cs $(EMLIB)/ego/cs - -cmp: all - -cmp cs $(EMLIB)/ego/cs - -clean: - rm -f *.$(SUF) cs Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -cs.$(SUF): $(SRC_DIR)/cs.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs.c -cs.$(SUF): $(SRC_DIR)/cs_vnm.h -cs.$(SUF): $(SRC_DIR)/cs_stack.h -cs.$(SUF): $(SRC_DIR)/cs_profit.h -cs.$(SUF): $(SRC_DIR)/cs_entity.h -cs.$(SUF): $(SRC_DIR)/cs_elim.h -cs.$(SUF): $(SRC_DIR)/cs_debug.h -cs.$(SUF): $(SRC_DIR)/cs_avail.h -cs.$(SUF): $(SRC_DIR)/cs_aux.h -cs.$(SUF): $(SRC_DIR)/cs.h -cs.$(SUF): $(SRC_DIR)/../share/go.h -cs.$(SUF): $(SRC_DIR)/../share/debug.h -cs.$(SUF): $(SRC_DIR)/../share/lset.h -cs.$(SUF): $(SRC_DIR)/../share/types.h -cs_alloc.$(SUF): $(SRC_DIR)/cs_alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_alloc.c -cs_alloc.$(SUF): $(SRC_DIR)/cs.h -cs_alloc.$(SUF): $(SRC_DIR)/../share/alloc.h -cs_alloc.$(SUF): $(SRC_DIR)/../share/types.h -cs_aux.$(SUF): $(SRC_DIR)/cs_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_aux.c -cs_aux.$(SUF): $(SRC_DIR)/cs_entity.h -cs_aux.$(SUF): $(SRC_DIR)/cs.h -cs_aux.$(SUF): $(SRC_DIR)/../share/lset.h -cs_aux.$(SUF): $(SRC_DIR)/../share/global.h -cs_aux.$(SUF): $(SRC_DIR)/../share/aux.h -cs_aux.$(SUF): $(SRC_DIR)/../share/debug.h -cs_aux.$(SUF): $(SRC_DIR)/../share/types.h -cs_avail.$(SUF): $(SRC_DIR)/cs_avail.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_avail.c -cs_avail.$(SUF): $(SRC_DIR)/cs_getent.h -cs_avail.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_avail.$(SUF): $(SRC_DIR)/cs_debug.h -cs_avail.$(SUF): $(SRC_DIR)/cs_aux.h -cs_avail.$(SUF): $(SRC_DIR)/cs.h -cs_avail.$(SUF): $(SRC_DIR)/../share/global.h -cs_avail.$(SUF): $(SRC_DIR)/../share/lset.h -cs_avail.$(SUF): $(SRC_DIR)/../share/aux.h -cs_avail.$(SUF): $(SRC_DIR)/../share/debug.h -cs_avail.$(SUF): $(SRC_DIR)/../share/types.h -cs_avail.$(SUF): $(EMH)/em_mnem.h -cs_debug.$(SUF): $(SRC_DIR)/cs_debug.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_debug.c -cs_debug.$(SUF): $(SRC_DIR)/cs_entity.h -cs_debug.$(SUF): $(SRC_DIR)/cs_avail.h -cs_debug.$(SUF): $(SRC_DIR)/cs_aux.h -cs_debug.$(SUF): $(SRC_DIR)/cs.h -cs_debug.$(SUF): $(SRC_DIR)/../share/lset.h -cs_debug.$(SUF): $(SRC_DIR)/../share/debug.h -cs_debug.$(SUF): $(SRC_DIR)/../share/types.h -cs_debug.$(SUF): $(EMH)/em_spec.h -cs_elim.$(SUF): $(SRC_DIR)/cs_elim.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_elim.c -cs_elim.$(SUF): $(SRC_DIR)/cs_partit.h -cs_elim.$(SUF): $(SRC_DIR)/cs_profit.h -cs_elim.$(SUF): $(SRC_DIR)/cs_debug.h -cs_elim.$(SUF): $(SRC_DIR)/cs_aux.h -cs_elim.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_elim.$(SUF): $(SRC_DIR)/cs_avail.h -cs_elim.$(SUF): $(SRC_DIR)/cs.h -cs_elim.$(SUF): $(SRC_DIR)/../share/debug.h -cs_elim.$(SUF): $(SRC_DIR)/../share/global.h -cs_elim.$(SUF): $(SRC_DIR)/../share/aux.h -cs_elim.$(SUF): $(SRC_DIR)/../share/lset.h -cs_elim.$(SUF): $(SRC_DIR)/../share/alloc.h -cs_elim.$(SUF): $(SRC_DIR)/../share/types.h -cs_elim.$(SUF): $(EMH)/em_mnem.h -cs_elim.$(SUF): $(EMH)/em_reg.h -cs_entity.$(SUF): $(SRC_DIR)/cs_entity.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_entity.c -cs_entity.$(SUF): $(SRC_DIR)/cs_aux.h -cs_entity.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_entity.$(SUF): $(SRC_DIR)/cs.h -cs_entity.$(SUF): $(SRC_DIR)/../share/debug.h -cs_entity.$(SUF): $(SRC_DIR)/../share/lset.h -cs_entity.$(SUF): $(SRC_DIR)/../share/global.h -cs_entity.$(SUF): $(SRC_DIR)/../share/types.h -cs_kill.$(SUF): $(SRC_DIR)/cs_kill.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_kill.c -cs_kill.$(SUF): $(SRC_DIR)/cs_entity.h -cs_kill.$(SUF): $(SRC_DIR)/cs_avail.h -cs_kill.$(SUF): $(SRC_DIR)/cs_debug.h -cs_kill.$(SUF): $(SRC_DIR)/cs_aux.h -cs_kill.$(SUF): $(SRC_DIR)/cs.h -cs_kill.$(SUF): $(SRC_DIR)/../share/map.h -cs_kill.$(SUF): $(SRC_DIR)/../share/aux.h -cs_kill.$(SUF): $(SRC_DIR)/../share/cset.h -cs_kill.$(SUF): $(SRC_DIR)/../share/lset.h -cs_kill.$(SUF): $(SRC_DIR)/../share/global.h -cs_kill.$(SUF): $(SRC_DIR)/../share/debug.h -cs_kill.$(SUF): $(SRC_DIR)/../share/types.h -cs_kill.$(SUF): $(EMH)/em_mnem.h -cs_partit.$(SUF): $(SRC_DIR)/cs_partit.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_partit.c -cs_partit.$(SUF): $(SRC_DIR)/cs_stack.h -cs_partit.$(SUF): $(SRC_DIR)/cs.h -cs_partit.$(SUF): $(SRC_DIR)/../share/global.h -cs_partit.$(SUF): $(SRC_DIR)/../share/debug.h -cs_partit.$(SUF): $(SRC_DIR)/../share/aux.h -cs_partit.$(SUF): $(SRC_DIR)/../share/types.h -cs_partit.$(SUF): $(EMH)/em_spec.h -cs_partit.$(SUF): $(EMH)/em_reg.h -cs_partit.$(SUF): $(EMH)/em_pseu.h -cs_partit.$(SUF): $(EMH)/em_mnem.h -cs_profit.$(SUF): $(SRC_DIR)/cs_profit.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_profit.c -cs_profit.$(SUF): $(SRC_DIR)/cs_partit.h -cs_profit.$(SUF): $(SRC_DIR)/cs_avail.h -cs_profit.$(SUF): $(SRC_DIR)/cs_debug.h -cs_profit.$(SUF): $(SRC_DIR)/cs_aux.h -cs_profit.$(SUF): $(SRC_DIR)/cs.h -cs_profit.$(SUF): $(SRC_DIR)/../share/lset.h -cs_profit.$(SUF): $(SRC_DIR)/../share/cset.h -cs_profit.$(SUF): $(SRC_DIR)/../share/aux.h -cs_profit.$(SUF): $(SRC_DIR)/../share/global.h -cs_profit.$(SUF): $(SRC_DIR)/../share/debug.h -cs_profit.$(SUF): $(SRC_DIR)/../share/types.h -cs_profit.$(SUF): $(EMH)/em_spec.h -cs_profit.$(SUF): $(EMH)/em_mnem.h -cs_getent.$(SUF): $(SRC_DIR)/cs_getent.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_getent.c -cs_getent.$(SUF): $(SRC_DIR)/cs_stack.h -cs_getent.$(SUF): $(SRC_DIR)/cs_entity.h -cs_getent.$(SUF): $(SRC_DIR)/cs_aux.h -cs_getent.$(SUF): $(SRC_DIR)/cs.h -cs_getent.$(SUF): $(SRC_DIR)/../share/global.h -cs_getent.$(SUF): $(SRC_DIR)/../share/debug.h -cs_getent.$(SUF): $(SRC_DIR)/../share/aux.h -cs_getent.$(SUF): $(SRC_DIR)/../share/types.h -cs_getent.$(SUF): $(EMH)/em_mnem.h -cs_stack.$(SUF): $(SRC_DIR)/cs_stack.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_stack.c -cs_stack.$(SUF): $(SRC_DIR)/cs_aux.h -cs_stack.$(SUF): $(SRC_DIR)/cs.h -cs_stack.$(SUF): $(SRC_DIR)/../share/aux.h -cs_stack.$(SUF): $(SRC_DIR)/../share/debug.h -cs_stack.$(SUF): $(SRC_DIR)/../share/global.h -cs_stack.$(SUF): $(SRC_DIR)/../share/types.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_vnm.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_vnm.c -cs_vnm.$(SUF): $(SRC_DIR)/cs_getent.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_partit.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_kill.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_stack.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_avail.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_entity.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_aux.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_vnm.$(SUF): $(SRC_DIR)/cs.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/aux.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/debug.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/global.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/types.h -cs_vnm.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/descr/proto.make b/util/ego/descr/proto.make deleted file mode 100644 index 1a7c6b344..000000000 --- a/util/ego/descr/proto.make +++ /dev/null @@ -1,79 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/descr -CPP = $(UTIL_HOME)/lib.bin/cpp -EMH = $(TARGET_HOME)/h - -SOURCES = \ - $(SRC_DIR)/i86.descr \ - $(SRC_DIR)/i386.descr \ - $(SRC_DIR)/m68k2.descr \ - $(SRC_DIR)/pdp.descr \ - $(SRC_DIR)/vax4.descr \ - $(SRC_DIR)/m68k4.descr \ - $(SRC_DIR)/m68020.descr \ - $(SRC_DIR)/sparc.descr \ - $(SRC_DIR)/em22.descr \ - $(SRC_DIR)/em24.descr \ - $(SRC_DIR)/em44.descr - -TARGETS = i86descr m68k2descr vax4descr pdpdescr m68k4descr m68020descr \ - em22descr em24descr em44descr sparcdescr sparc_solarisdescr i386descr - -PRFILES = $(SRC_DIR)/proto.make $(SRC_DIR)/descr.sed $(SOURCES) - -all: $(TARGETS) - -install: all - for i in $(TARGETS) ; do cp $$i $(TARGET_HOME)/lib.bin/ego/$$i ; done - -cmp: all - -for i in $(TARGETS) ; do cmp $$i $(TARGET_HOME)/lib.bin/ego/$$i ; done - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -clean: - rm -f $(TARGETS) *.o Out out nohup.out - -i86descr: $(SRC_DIR)/i86.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/i86.descr | sed -f $(SRC_DIR)/descr.sed > i86descr - -pdpdescr: $(SRC_DIR)/pdp.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/pdp.descr | sed -f $(SRC_DIR)/descr.sed > pdpdescr - -m68k2descr: $(SRC_DIR)/m68k2.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/m68k2.descr | sed -f $(SRC_DIR)/descr.sed > m68k2descr - -m68k4descr: $(SRC_DIR)/m68k4.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/m68k4.descr | sed -f $(SRC_DIR)/descr.sed > m68k4descr - -m68020descr: $(SRC_DIR)/m68020.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/m68020.descr | sed -f $(SRC_DIR)/descr.sed > m68020descr - -vax4descr: $(SRC_DIR)/vax4.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/vax4.descr | sed -f $(SRC_DIR)/descr.sed > vax4descr - -em22descr: $(SRC_DIR)/em22.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/em22.descr | sed -f $(SRC_DIR)/descr.sed > em22descr - -em24descr: $(SRC_DIR)/em24.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/em24.descr | sed -f $(SRC_DIR)/descr.sed > em24descr - -em44descr: $(SRC_DIR)/em44.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/em44.descr | sed -f $(SRC_DIR)/descr.sed > em44descr - -sparcdescr: $(SRC_DIR)/sparc.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/sparc.descr | sed -f $(SRC_DIR)/descr.sed > sparcdescr - -sparc_solarisdescr: $(SRC_DIR)/sparc.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/sparc.descr | sed -f $(SRC_DIR)/descr.sed > sparc_solarisdescr - -i386descr: $(SRC_DIR)/i386.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/i386.descr | sed -f $(SRC_DIR)/descr.sed > i386descr - diff --git a/util/ego/em_ego/proto.make b/util/ego/em_ego/proto.make deleted file mode 100644 index b1f6d2952..000000000 --- a/util/ego/em_ego/proto.make +++ /dev/null @@ -1,43 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line - -SRC_DIR = $(SRC_HOME)/util/ego/em_ego -EMH=$(TARGET_HOME)/h -EMCONFIG=$(TARGET_HOME)/config -EMLIB=$(TARGET_HOME)/lib.bin -MODLIB=$(TARGET_HOME)/modules/lib -MODH=$(TARGET_HOME)/modules/h -MODS=$(MODLIB)/libprint.$(LIBSUF) $(MODLIB)/libstring.$(LIBSUF) $(MODLIB)/libsystem.$(LIBSUF) - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(EMCONFIG) -I$(MODH) -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -all: em_ego - -em_ego: em_ego.$(SUF) - $(CC) $(LDFLAGS) -o em_ego em_ego.$(SUF) $(MODS) - -em_ego.$(SUF): $(SRC_DIR)/em_ego.c $(EMCONFIG)/em_path.h $(MODH)/system.h - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_ego.c - -install: all - rm -f $(EMLIB)/em_ego - cp em_ego $(EMLIB)/em_ego - -cmp: all - -cmp em_ego $(EMLIB)/em_ego - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/em_ego.c - -opr: - make pr | opr - -lint: - $(LINT) $(LINTFLAGS) $(SRC_DIR)/em_ego.c - -clean: - rm -f *.$(SUF) em_ego diff --git a/util/ego/ic/proto.make b/util/ego/ic/proto.make deleted file mode 100644 index aae64cd14..000000000 --- a/util/ego/ic/proto.make +++ /dev/null @@ -1,137 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ic -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ic.c \ - $(SRC_DIR)/ic_aux.c \ - $(SRC_DIR)/ic_lib.c \ - $(SRC_DIR)/ic_lookup.c \ - $(SRC_DIR)/ic_io.c - -OFILES=\ -ic.$(SUF) ic_aux.$(SUF) ic_lookup.$(SUF) ic_io.$(SUF) ic_lib.$(SUF) - -HFILES=\ - $(SRC_DIR)/ic.h \ - $(SRC_DIR)/ic_aux.h \ - $(SRC_DIR)/ic_lib.h \ - $(SRC_DIR)/ic_lookup.h \ - $(SRC_DIR)/ic_io.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ic - -ic: $(OFILES) - $(CC) -o ic $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp ic $(EMLIB)/ego/ic - -cmp: all - -cmp ic $(EMLIB)/ego/ic - -clean: - rm -f *.$(SUF) ic Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ic.$(SUF): $(SRC_DIR)/ic.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic.c -ic.$(SUF): $(SRC_DIR)/../share/aux.h -ic.$(SUF): $(SRC_DIR)/../share/put.h -ic.$(SUF): $(SRC_DIR)/../share/files.h -ic.$(SUF): $(SRC_DIR)/../share/global.h -ic.$(SUF): $(SRC_DIR)/../share/alloc.h -ic.$(SUF): $(SRC_DIR)/ic_lib.h -ic.$(SUF): $(SRC_DIR)/ic_io.h -ic.$(SUF): $(SRC_DIR)/ic_aux.h -ic.$(SUF): $(SRC_DIR)/ic_lookup.h -ic.$(SUF): $(SRC_DIR)/ic.h -ic.$(SUF): $(SRC_DIR)/../share/map.h -ic.$(SUF): $(SRC_DIR)/../share/def.h -ic.$(SUF): $(SRC_DIR)/../share/debug.h -ic.$(SUF): $(SRC_DIR)/../share/types.h -ic.$(SUF): $(EMH)/em_mes.h -ic.$(SUF): $(EMH)/em_flag.h -ic.$(SUF): $(EMH)/em_pseu.h -ic.$(SUF): $(EMH)/em_spec.h -ic_aux.$(SUF): $(SRC_DIR)/ic_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_aux.c -ic_aux.$(SUF): $(SRC_DIR)/ic_aux.h -ic_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -ic_aux.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_aux.$(SUF): $(SRC_DIR)/ic_io.h -ic_aux.$(SUF): $(SRC_DIR)/ic.h -ic_aux.$(SUF): $(SRC_DIR)/../share/aux.h -ic_aux.$(SUF): $(SRC_DIR)/../share/def.h -ic_aux.$(SUF): $(SRC_DIR)/../share/debug.h -ic_aux.$(SUF): $(SRC_DIR)/../share/global.h -ic_aux.$(SUF): $(SRC_DIR)/../share/types.h -ic_aux.$(SUF): $(EMH)/em_mnem.h -ic_aux.$(SUF): $(EMH)/em_spec.h -ic_aux.$(SUF): $(EMH)/em_pseu.h -ic_lib.$(SUF): $(SRC_DIR)/ic_lib.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_lib.c -ic_lib.$(SUF): $(SRC_DIR)/ic_lib.h -ic_lib.$(SUF): $(SRC_DIR)/../share/files.h -ic_lib.$(SUF): $(SRC_DIR)/../share/global.h -ic_lib.$(SUF): $(SRC_DIR)/ic_io.h -ic_lib.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_lib.$(SUF): $(SRC_DIR)/ic.h -ic_lib.$(SUF): $(SRC_DIR)/../share/debug.h -ic_lib.$(SUF): $(SRC_DIR)/../share/types.h -ic_lib.$(SUF): $(EMH)/arch.h -ic_lib.$(SUF): $(EMH)/em_mes.h -ic_lib.$(SUF): $(EMH)/em_pseu.h -ic_lib.$(SUF): $(EMH)/em_spec.h -ic_lookup.$(SUF): $(SRC_DIR)/ic_lookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_lookup.c -ic_lookup.$(SUF): $(SRC_DIR)/../share/alloc.h -ic_lookup.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_lookup.$(SUF): $(SRC_DIR)/ic.h -ic_lookup.$(SUF): $(SRC_DIR)/../share/map.h -ic_lookup.$(SUF): $(SRC_DIR)/../share/debug.h -ic_lookup.$(SUF): $(SRC_DIR)/../share/types.h -ic_lookup.$(SUF): $(EMH)/em_spec.h -ic_io.$(SUF): $(SRC_DIR)/ic_io.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_io.c -ic_io.$(SUF): $(SRC_DIR)/ic_io.h -ic_io.$(SUF): $(SRC_DIR)/../share/alloc.h -ic_io.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_io.$(SUF): $(SRC_DIR)/ic.h -ic_io.$(SUF): $(SRC_DIR)/../share/debug.h -ic_io.$(SUF): $(SRC_DIR)/../share/types.h -ic_io.$(SUF): $(EMH)/arch.h -ic_io.$(SUF): $(EMH)/em_spec.h -ic_io.$(SUF): $(EMH)/em_pseu.h diff --git a/util/ego/il/proto.make b/util/ego/il/proto.make deleted file mode 100644 index dfeae7ba1..000000000 --- a/util/ego/il/proto.make +++ /dev/null @@ -1,223 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/il -EMH=$(TARGET_HOME)/h -EMCONFIG=$(TARGET_HOME)/config -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(EMCONFIG) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/il.c \ - $(SRC_DIR)/il1_anal.c \ - $(SRC_DIR)/il1_cal.c \ - $(SRC_DIR)/il1_formal.c \ - $(SRC_DIR)/il1_aux.c \ - $(SRC_DIR)/il2_aux.c \ - $(SRC_DIR)/il3_change.c \ - $(SRC_DIR)/il3_subst.c \ - $(SRC_DIR)/il3_aux.c \ - $(SRC_DIR)/il_aux.c - -OFILES=\ - il.$(SUF) il1_anal.$(SUF) il1_cal.$(SUF) il1_formal.$(SUF) \ - il1_aux.$(SUF) il2_aux.$(SUF) il3_change.$(SUF) il3_subst.$(SUF) \ - il3_aux.$(SUF) il_aux.$(SUF) - -HFILES=\ - $(SRC_DIR)/il.h \ - $(SRC_DIR)/il1_anal.h \ - $(SRC_DIR)/il1_cal.h \ - $(SRC_DIR)/il1_formal.h \ - $(SRC_DIR)/il1_aux.h \ - $(SRC_DIR)/il2_aux.h \ - $(SRC_DIR)/il3_change.h \ - $(SRC_DIR)/il3_subst.h \ - $(SRC_DIR)/il3_aux.h \ - $(SRC_DIR)/il_aux.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: il - -il: $(OFILES) - $(CC) -o il $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp il $(EMLIB)/ego/il - -cmp: all - -cmp il $(EMLIB)/ego/il - -clean: - rm -f *.$(SUF) il Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -il.$(SUF): $(SRC_DIR)/il.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il.c -il.$(SUF): $(SRC_DIR)/../share/go.h -il.$(SUF): $(SRC_DIR)/../share/put.h -il.$(SUF): $(SRC_DIR)/../share/get.h -il.$(SUF): $(SRC_DIR)/il3_subst.h -il.$(SUF): $(SRC_DIR)/il2_aux.h -il.$(SUF): $(SRC_DIR)/il1_anal.h -il.$(SUF): $(SRC_DIR)/il_aux.h -il.$(SUF): $(SRC_DIR)/../share/map.h -il.$(SUF): $(SRC_DIR)/../share/files.h -il.$(SUF): $(SRC_DIR)/../share/lset.h -il.$(SUF): $(SRC_DIR)/../share/global.h -il.$(SUF): $(SRC_DIR)/../share/alloc.h -il.$(SUF): $(SRC_DIR)/../share/debug.h -il.$(SUF): $(SRC_DIR)/il.h -il.$(SUF): $(SRC_DIR)/../share/types.h -il.$(SUF): $(EMH)/em_pseu.h -il.$(SUF): $(EMH)/em_mnem.h -il.$(SUF): $(EMCONFIG)/em_path.h -il1_anal.$(SUF): $(SRC_DIR)/il1_anal.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_anal.c -il1_anal.$(SUF): $(SRC_DIR)/../share/put.h -il1_anal.$(SUF): $(SRC_DIR)/il_aux.h -il1_anal.$(SUF): $(SRC_DIR)/il1_anal.h -il1_anal.$(SUF): $(SRC_DIR)/il1_cal.h -il1_anal.$(SUF): $(SRC_DIR)/il1_formal.h -il1_anal.$(SUF): $(SRC_DIR)/il1_aux.h -il1_anal.$(SUF): $(SRC_DIR)/../share/aux.h -il1_anal.$(SUF): $(SRC_DIR)/../share/lset.h -il1_anal.$(SUF): $(SRC_DIR)/../share/global.h -il1_anal.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_anal.$(SUF): $(SRC_DIR)/../share/debug.h -il1_anal.$(SUF): $(SRC_DIR)/il.h -il1_anal.$(SUF): $(SRC_DIR)/../share/types.h -il1_anal.$(SUF): $(EMH)/em_pseu.h -il1_anal.$(SUF): $(EMH)/em_mnem.h -il1_cal.$(SUF): $(SRC_DIR)/il1_cal.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_cal.c -il1_cal.$(SUF): $(SRC_DIR)/../share/parser.h -il1_cal.$(SUF): $(SRC_DIR)/il1_aux.h -il1_cal.$(SUF): $(SRC_DIR)/../share/lset.h -il1_cal.$(SUF): $(SRC_DIR)/../share/global.h -il1_cal.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_cal.$(SUF): $(SRC_DIR)/../share/debug.h -il1_cal.$(SUF): $(SRC_DIR)/il1_cal.h -il1_cal.$(SUF): $(SRC_DIR)/il.h -il1_cal.$(SUF): $(SRC_DIR)/../share/types.h -il1_cal.$(SUF): $(EMH)/em_mnem.h -il1_cal.$(SUF): $(EMH)/em_spec.h -il1_formal.$(SUF): $(SRC_DIR)/il1_formal.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_formal.c -il1_formal.$(SUF): $(SRC_DIR)/il1_formal.h -il1_formal.$(SUF): $(SRC_DIR)/il1_aux.h -il1_formal.$(SUF): $(SRC_DIR)/../share/lset.h -il1_formal.$(SUF): $(SRC_DIR)/../share/global.h -il1_formal.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_formal.$(SUF): $(SRC_DIR)/../share/debug.h -il1_formal.$(SUF): $(SRC_DIR)/il.h -il1_formal.$(SUF): $(SRC_DIR)/../share/types.h -il1_aux.$(SUF): $(SRC_DIR)/il1_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_aux.c -il1_aux.$(SUF): $(SRC_DIR)/il1_aux.h -il1_aux.$(SUF): $(SRC_DIR)/il_aux.h -il1_aux.$(SUF): $(SRC_DIR)/../share/lset.h -il1_aux.$(SUF): $(SRC_DIR)/../share/global.h -il1_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il1_aux.$(SUF): $(SRC_DIR)/il.h -il1_aux.$(SUF): $(SRC_DIR)/../share/types.h -il1_aux.$(SUF): $(EMH)/em_spec.h -il2_aux.$(SUF): $(SRC_DIR)/il2_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il2_aux.c -il2_aux.$(SUF): $(SRC_DIR)/../share/aux.h -il2_aux.$(SUF): $(SRC_DIR)/../share/get.h -il2_aux.$(SUF): $(SRC_DIR)/il2_aux.h -il2_aux.$(SUF): $(SRC_DIR)/il_aux.h -il2_aux.$(SUF): $(SRC_DIR)/../share/lset.h -il2_aux.$(SUF): $(SRC_DIR)/../share/global.h -il2_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il2_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il2_aux.$(SUF): $(SRC_DIR)/il.h -il2_aux.$(SUF): $(SRC_DIR)/../share/types.h -il2_aux.$(SUF): $(EMH)/em_mnem.h -il2_aux.$(SUF): $(EMH)/em_spec.h -il3_change.$(SUF): $(SRC_DIR)/il3_change.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il3_change.c -il3_change.$(SUF): $(SRC_DIR)/il3_aux.h -il3_change.$(SUF): $(SRC_DIR)/il3_change.h -il3_change.$(SUF): $(SRC_DIR)/il_aux.h -il3_change.$(SUF): $(SRC_DIR)/../share/put.h -il3_change.$(SUF): $(SRC_DIR)/../share/get.h -il3_change.$(SUF): $(SRC_DIR)/../share/aux.h -il3_change.$(SUF): $(SRC_DIR)/../share/lset.h -il3_change.$(SUF): $(SRC_DIR)/../share/def.h -il3_change.$(SUF): $(SRC_DIR)/../share/global.h -il3_change.$(SUF): $(SRC_DIR)/../share/alloc.h -il3_change.$(SUF): $(SRC_DIR)/../share/debug.h -il3_change.$(SUF): $(SRC_DIR)/il.h -il3_change.$(SUF): $(SRC_DIR)/../share/types.h -il3_change.$(SUF): $(EMH)/em_mes.h -il3_change.$(SUF): $(EMH)/em_spec.h -il3_change.$(SUF): $(EMH)/em_pseu.h -il3_change.$(SUF): $(EMH)/em_mnem.h -il3_subst.$(SUF): $(SRC_DIR)/il3_subst.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il3_subst.c -il3_subst.$(SUF): $(SRC_DIR)/il3_subst.h -il3_subst.$(SUF): $(SRC_DIR)/il3_change.h -il3_subst.$(SUF): $(SRC_DIR)/il3_aux.h -il3_subst.$(SUF): $(SRC_DIR)/il_aux.h -il3_subst.$(SUF): $(SRC_DIR)/../share/get.h -il3_subst.$(SUF): $(SRC_DIR)/../share/lset.h -il3_subst.$(SUF): $(SRC_DIR)/../share/global.h -il3_subst.$(SUF): $(SRC_DIR)/../share/alloc.h -il3_subst.$(SUF): $(SRC_DIR)/../share/debug.h -il3_subst.$(SUF): $(SRC_DIR)/il.h -il3_subst.$(SUF): $(SRC_DIR)/../share/types.h -il3_subst.$(SUF): $(EMH)/em_mnem.h -il3_aux.$(SUF): $(SRC_DIR)/il3_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il3_aux.c -il3_aux.$(SUF): $(SRC_DIR)/il3_aux.h -il3_aux.$(SUF): $(SRC_DIR)/il_aux.h -il3_aux.$(SUF): $(SRC_DIR)/../share/global.h -il3_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il3_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il3_aux.$(SUF): $(SRC_DIR)/il.h -il3_aux.$(SUF): $(SRC_DIR)/../share/types.h -il_aux.$(SUF): $(SRC_DIR)/il_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il_aux.c -il_aux.$(SUF): $(SRC_DIR)/il_aux.h -il_aux.$(SUF): $(SRC_DIR)/../share/map.h -il_aux.$(SUF): $(SRC_DIR)/../share/lset.h -il_aux.$(SUF): $(SRC_DIR)/../share/global.h -il_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il_aux.$(SUF): $(SRC_DIR)/../share/put.h -il_aux.$(SUF): $(SRC_DIR)/../share/get.h -il_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il_aux.$(SUF): $(SRC_DIR)/il.h -il_aux.$(SUF): $(SRC_DIR)/../share/types.h -il_aux.$(SUF): $(EMH)/em_pseu.h -il_aux.$(SUF): $(EMH)/em_mnem.h -il_aux.$(SUF): $(EMH)/em_spec.h diff --git a/util/ego/lv/proto.make b/util/ego/lv/proto.make deleted file mode 100644 index 94e2bc407..000000000 --- a/util/ego/lv/proto.make +++ /dev/null @@ -1,84 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/lv -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/lv.c - -OFILES=\ -lv.$(SUF) - -HFILES=\ - $(SRC_DIR)/lv.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: lv - -lv: $(OFILES) - $(CC) -o lv $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp lv $(EMLIB)/ego/lv - -cmp: all - -cmp lv $(EMLIB)/ego/lv - -clean: - rm -f *.$(SUF) lv Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -lv.$(SUF): $(SRC_DIR)/lv.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lv.c -lv.$(SUF): $(SRC_DIR)/../share/parser.h -lv.$(SUF): $(SRC_DIR)/../share/go.h -lv.$(SUF): $(SRC_DIR)/../share/locals.h -lv.$(SUF): $(SRC_DIR)/../share/init_glob.h -lv.$(SUF): $(SRC_DIR)/../share/aux.h -lv.$(SUF): $(SRC_DIR)/../share/put.h -lv.$(SUF): $(SRC_DIR)/../share/get.h -lv.$(SUF): $(SRC_DIR)/../share/map.h -lv.$(SUF): $(SRC_DIR)/../share/alloc.h -lv.$(SUF): $(SRC_DIR)/../share/files.h -lv.$(SUF): $(SRC_DIR)/../share/def.h -lv.$(SUF): $(SRC_DIR)/../share/cset.h -lv.$(SUF): $(SRC_DIR)/../share/lset.h -lv.$(SUF): $(SRC_DIR)/../share/global.h -lv.$(SUF): $(SRC_DIR)/../share/debug.h -lv.$(SUF): $(SRC_DIR)/lv.h -lv.$(SUF): $(SRC_DIR)/../share/types.h -lv.$(SUF): $(EMH)/em_ego.h -lv.$(SUF): $(EMH)/em_mes.h -lv.$(SUF): $(EMH)/em_spec.h -lv.$(SUF): $(EMH)/em_pseu.h -lv.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/ra/proto.make b/util/ego/ra/proto.make deleted file mode 100644 index 24c5576c3..000000000 --- a/util/ego/ra/proto.make +++ /dev/null @@ -1,234 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ra -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -ULDFLAGS=$(ULDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -I. -CFLAGS=$(CPPFLAGS) $(COPTIONS) -UCFLAGS=$(CPPFLAGS) $(UCOPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ra.c \ - $(SRC_DIR)/ra_items.c \ - $(SRC_DIR)/ra_lifet.c \ - $(SRC_DIR)/ra_allocl.c \ - $(SRC_DIR)/ra_profits.c \ - $(SRC_DIR)/ra_interv.c \ - $(SRC_DIR)/ra_pack.c \ - $(SRC_DIR)/ra_xform.c \ - $(SRC_DIR)/ra_aux.c - -OFILES=\ - ra.$(SUF) \ - ra_items.$(SUF) \ - ra_lifet.$(SUF) \ - ra_allocl.$(SUF) \ - ra_profits.$(SUF) \ - ra_interv.$(SUF) \ - ra_pack.$(SUF) \ - ra_xform.$(SUF) \ - ra_aux.$(SUF) - -HFILES=\ - $(SRC_DIR)/ra.h \ - $(SRC_DIR)/ra_items.h \ - $(SRC_DIR)/ra_lifet.h \ - $(SRC_DIR)/ra_allocl.h \ - $(SRC_DIR)/ra_profits.h \ - $(SRC_DIR)/ra_interv.h \ - $(SRC_DIR)/ra_pack.h \ - $(SRC_DIR)/ra_xform.h \ - $(SRC_DIR)/ra_aux.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ra - -ra: $(OFILES) - $(CC) -o ra $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -./itemtab.h: $(SRC_DIR)/itemtab.src $(EMH)/em_mnem.h makeitems - makeitems $(EMH)/em_mnem.h $(SRC_DIR)/itemtab.src > ./itemtab.h - -makeitems: $(SRC_DIR)/makeitems.c - $(UCC) $(UCFLAGS) $(ULDFLAGS) -o makeitems $(SRC_DIR)/makeitems.c - -install: all - cp ra $(EMLIB)/ego/ra - -cmp: all - -cmp ra $(EMLIB)/ego/ra - -clean: - rm -f *.$(SUF) ra Out out nohup.out makeitems ./itemtab.h - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: ./itemtab.h - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ra.$(SUF): $(SRC_DIR)/ra.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra.c -ra.$(SUF): $(SRC_DIR)/ra_xform.h -ra.$(SUF): $(SRC_DIR)/ra_pack.h -ra.$(SUF): $(SRC_DIR)/ra_profits.h -ra.$(SUF): $(SRC_DIR)/ra_allocl.h -ra.$(SUF): $(SRC_DIR)/ra_items.h -ra.$(SUF): $(SRC_DIR)/ra.h -ra.$(SUF): $(SRC_DIR)/../share/go.h -ra.$(SUF): $(SRC_DIR)/../share/alloc.h -ra.$(SUF): $(SRC_DIR)/../share/map.h -ra.$(SUF): $(SRC_DIR)/../share/lset.h -ra.$(SUF): $(SRC_DIR)/../share/put.h -ra.$(SUF): $(SRC_DIR)/../share/get.h -ra.$(SUF): $(SRC_DIR)/../share/files.h -ra.$(SUF): $(SRC_DIR)/../share/global.h -ra.$(SUF): $(SRC_DIR)/../share/debug.h -ra.$(SUF): $(SRC_DIR)/../share/types.h -ra.$(SUF): $(EMH)/em_reg.h -ra_items.$(SUF): $(SRC_DIR)/ra_items.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_items.c -ra_items.$(SUF): ./itemtab.h -ra_items.$(SUF): $(SRC_DIR)/ra_items.h -ra_items.$(SUF): $(SRC_DIR)/ra_aux.h -ra_items.$(SUF): $(SRC_DIR)/ra.h -ra_items.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_items.$(SUF): $(SRC_DIR)/../share/aux.h -ra_items.$(SUF): $(SRC_DIR)/../share/lset.h -ra_items.$(SUF): $(SRC_DIR)/../share/global.h -ra_items.$(SUF): $(SRC_DIR)/../share/def.h -ra_items.$(SUF): $(SRC_DIR)/../share/debug.h -ra_items.$(SUF): $(SRC_DIR)/../share/types.h -ra_items.$(SUF): $(EMH)/em_reg.h -ra_items.$(SUF): $(EMH)/em_pseu.h -ra_items.$(SUF): $(EMH)/em_spec.h -ra_items.$(SUF): $(EMH)/em_mnem.h -ra_lifet.$(SUF): $(SRC_DIR)/ra_lifet.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_lifet.c -ra_lifet.$(SUF): $(SRC_DIR)/ra_lifet.h -ra_lifet.$(SUF): $(SRC_DIR)/ra_items.h -ra_lifet.$(SUF): $(SRC_DIR)/ra_aux.h -ra_lifet.$(SUF): $(SRC_DIR)/ra.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/aux.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/lset.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/global.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/def.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/debug.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/types.h -ra_lifet.$(SUF): $(EMH)/em_ego.h -ra_lifet.$(SUF): $(EMH)/em_mes.h -ra_lifet.$(SUF): $(EMH)/em_reg.h -ra_lifet.$(SUF): $(EMH)/em_pseu.h -ra_lifet.$(SUF): $(EMH)/em_spec.h -ra_lifet.$(SUF): $(EMH)/em_mnem.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_allocl.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_allocl.c -ra_allocl.$(SUF): $(SRC_DIR)/ra_interv.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_allocl.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_items.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_aux.h -ra_allocl.$(SUF): $(SRC_DIR)/ra.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/map.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/aux.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/cset.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/lset.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/global.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/def.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/debug.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/types.h -ra_allocl.$(SUF): $(EMH)/em_reg.h -ra_allocl.$(SUF): $(EMH)/em_pseu.h -ra_allocl.$(SUF): $(EMH)/em_spec.h -ra_allocl.$(SUF): $(EMH)/em_mnem.h -ra_profits.$(SUF): $(SRC_DIR)/ra_profits.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_profits.c -ra_profits.$(SUF): $(SRC_DIR)/ra_profits.h -ra_profits.$(SUF): $(SRC_DIR)/ra_aux.h -ra_profits.$(SUF): $(SRC_DIR)/ra.h -ra_profits.$(SUF): $(SRC_DIR)/../share/global.h -ra_profits.$(SUF): $(SRC_DIR)/../share/lset.h -ra_profits.$(SUF): $(SRC_DIR)/../share/debug.h -ra_profits.$(SUF): $(SRC_DIR)/../share/types.h -ra_profits.$(SUF): $(EMH)/em_reg.h -ra_interv.$(SUF): $(SRC_DIR)/ra_interv.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_interv.c -ra_interv.$(SUF): $(SRC_DIR)/ra_interv.h -ra_interv.$(SUF): $(SRC_DIR)/ra.h -ra_interv.$(SUF): $(SRC_DIR)/../share/lset.h -ra_interv.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_interv.$(SUF): $(SRC_DIR)/../share/global.h -ra_interv.$(SUF): $(SRC_DIR)/../share/debug.h -ra_interv.$(SUF): $(SRC_DIR)/../share/types.h -ra_interv.$(SUF): $(EMH)/em_reg.h -ra_pack.$(SUF): $(SRC_DIR)/ra_pack.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_pack.c -ra_pack.$(SUF): $(SRC_DIR)/ra_interv.h -ra_pack.$(SUF): $(SRC_DIR)/ra_aux.h -ra_pack.$(SUF): $(SRC_DIR)/ra.h -ra_pack.$(SUF): $(SRC_DIR)/../share/aux.h -ra_pack.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_pack.$(SUF): $(SRC_DIR)/../share/cset.h -ra_pack.$(SUF): $(SRC_DIR)/../share/lset.h -ra_pack.$(SUF): $(SRC_DIR)/../share/global.h -ra_pack.$(SUF): $(SRC_DIR)/../share/def.h -ra_pack.$(SUF): $(SRC_DIR)/../share/debug.h -ra_pack.$(SUF): $(SRC_DIR)/../share/types.h -ra_pack.$(SUF): $(EMH)/em_reg.h -ra_xform.$(SUF): $(SRC_DIR)/ra_xform.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_xform.c -ra_xform.$(SUF): $(SRC_DIR)/ra_items.h -ra_xform.$(SUF): $(SRC_DIR)/ra_xform.h -ra_xform.$(SUF): $(SRC_DIR)/ra_interv.h -ra_xform.$(SUF): $(SRC_DIR)/ra.h -ra_xform.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_xform.$(SUF): $(SRC_DIR)/../share/aux.h -ra_xform.$(SUF): $(SRC_DIR)/../share/lset.h -ra_xform.$(SUF): $(SRC_DIR)/../share/global.h -ra_xform.$(SUF): $(SRC_DIR)/../share/def.h -ra_xform.$(SUF): $(SRC_DIR)/../share/debug.h -ra_xform.$(SUF): $(SRC_DIR)/../share/types.h -ra_xform.$(SUF): $(EMH)/em_reg.h -ra_xform.$(SUF): $(EMH)/em_ego.h -ra_xform.$(SUF): $(EMH)/em_mes.h -ra_xform.$(SUF): $(EMH)/em_pseu.h -ra_xform.$(SUF): $(EMH)/em_spec.h -ra_xform.$(SUF): $(EMH)/em_mnem.h -ra_aux.$(SUF): $(SRC_DIR)/ra_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_aux.c -ra_aux.$(SUF): $(SRC_DIR)/ra_aux.h -ra_aux.$(SUF): $(SRC_DIR)/ra.h -ra_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_aux.$(SUF): $(SRC_DIR)/../share/lset.h -ra_aux.$(SUF): $(SRC_DIR)/../share/global.h -ra_aux.$(SUF): $(SRC_DIR)/../share/def.h -ra_aux.$(SUF): $(SRC_DIR)/../share/debug.h -ra_aux.$(SUF): $(SRC_DIR)/../share/types.h -ra_aux.$(SUF): $(EMH)/em_reg.h -ra_aux.$(SUF): $(EMH)/em_pseu.h -ra_aux.$(SUF): $(EMH)/em_spec.h -ra_aux.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/share/proto.make b/util/ego/share/proto.make deleted file mode 100644 index 7f67c8bf0..000000000 --- a/util/ego/share/proto.make +++ /dev/null @@ -1,241 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line - -SRC_DIR = $(SRC_HOME)/util/ego/share -EMH=$(TARGET_HOME)/h - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I. -CFLAGS=$(CPPFLAGS) $(COPTIONS) -UCFLAGS=$(CPPFLAGS) $(UCOPTIONS) -ULDFLAGS=$(ULDOPTIONS) - -CFILES=\ - $(SRC_DIR)/debug.c \ - $(SRC_DIR)/global.c \ - $(SRC_DIR)/files.c \ - $(SRC_DIR)/go.c \ - $(SRC_DIR)/map.c \ - $(SRC_DIR)/aux.c \ - $(SRC_DIR)/get.c \ - $(SRC_DIR)/put.c \ - $(SRC_DIR)/alloc.c \ - $(SRC_DIR)/lset.c \ - $(SRC_DIR)/cset.c \ - $(SRC_DIR)/parser.c \ - $(SRC_DIR)/stack_chg.c \ - $(SRC_DIR)/locals.c \ - $(SRC_DIR)/init_glob.c -SRC=\ - $(SRC_DIR)/types.h \ - $(SRC_DIR)/def.h \ - $(SRC_DIR)/debug.h \ - $(SRC_DIR)/global.h \ - $(SRC_DIR)/files.h \ - $(SRC_DIR)/go.h \ - $(SRC_DIR)/map.h \ - $(SRC_DIR)/aux.h \ - $(SRC_DIR)/get.h \ - $(SRC_DIR)/put.h \ - $(SRC_DIR)/alloc.h\ - $(SRC_DIR)/lset.h \ - $(SRC_DIR)/cset.h \ - $(SRC_DIR)/parser.h \ - $(SRC_DIR)/stack_chg.h \ - $(SRC_DIR)/locals.h \ - $(SRC_DIR)/init_glob.h \ - $(CFILES) - -PRFILES=$(SRC) - -OBS = alloc.$(SUF) cset.$(SUF) debug.$(SUF) \ - files.$(SUF) go.$(SUF) global.$(SUF) lset.$(SUF) map.$(SUF) \ - parser.$(SUF) get.$(SUF) put.$(SUF) aux.$(SUF) stack_chg.$(SUF) \ - locals.$(SUF) init_glob.$(SUF) - -all: classdefs.h $(SRC_DIR)/pop_push.h $(OBS) - $(AR) r share.$(LIBSUF) $(OBS) - $(RANLIB) share.$(LIBSUF) - -install: all - -mkdir $(TARGET_HOME)/lib.bin/ego - cp share.$(LIBSUF) $(TARGET_HOME)/lib.bin/ego/share.$(LIBSUF) - $(RANLIB) $(TARGET_HOME)/lib.bin/ego/share.$(LIBSUF) - cp classdefs.h $(TARGET_HOME)/lib.bin/ego/classdefs.h - cp $(SRC_DIR)/pop_push.h $(TARGET_HOME)/lib.bin/ego/pop_push.h - -cmp: all - -cmp share.$(LIBSUF) $(TARGET_HOME)/lib.bin/ego/share.$(LIBSUF) - -cmp classdefs.h $(TARGET_HOME)/lib.bin/ego/classdefs.h - -cmp $(SRC_DIR)/pop_push.h $(TARGET_HOME)/lib.bin/ego/pop_push.h - -classdefs.h: \ - makeclassdef \ - $(SRC_DIR)/cldefs.src - makeclassdef $(EMH)/em_mnem.h $(SRC_DIR)/cldefs.src > classdefs.h - -makeclassdef: \ - $(SRC_DIR)/makecldef.c - $(UCC) $(UCFLAGS) $(ULDFLAGS) -o makeclassdef $(SRC_DIR)/makecldef.c - -$(SRC_DIR)/pop_push.h: \ - $(SRC_HOME)/etc/em_table $(SRC_DIR)/pop_push.awk - awk -f $(SRC_DIR)/pop_push.awk < $(SRC_HOME)/etc/em_table > $(SRC_DIR)/pop_push.h - -show: \ - $(SRC_DIR)/show.c - $(UCC) $(UCFLAGS) $(ULDFLAGS) -o show $(SRC_DIR)/show.c $(UTIL_HOME)/lib.bin/em_data.$(ULIBSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -clean: - rm -f makeclassdef classdefs.h *.$(SUF) Out out nohup.out *.$(LIBSUF) - -lintlib: classdefs.h - -mkdir $(TARGET_HOME)/lib.bin/ego - $(MK_LINT_LIB) share $(TARGET_HOME)/lib.bin/ego $(CPPFLAGS) $(CFILES) - -depend: $(SRC_DIR)/pop_push.h classdefs.h - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line. -#DEPENDENCIES -debug.$(SUF): $(SRC_DIR)/debug.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/debug.c -debug.$(SUF): $(SRC_DIR)/global.h -debug.$(SUF): $(SRC_DIR)/debug.h -debug.$(SUF): $(SRC_DIR)/def.h -debug.$(SUF): $(SRC_DIR)/types.h -debug.$(SUF): $(EMH)/em_spec.h -global.$(SUF): $(SRC_DIR)/global.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/global.c -global.$(SUF): $(SRC_DIR)/types.h -files.$(SUF): $(SRC_DIR)/files.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/files.c -go.$(SUF): $(SRC_DIR)/go.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/go.c -go.$(SUF): $(SRC_DIR)/go.h -go.$(SUF): $(SRC_DIR)/alloc.h -go.$(SUF): $(SRC_DIR)/map.h -go.$(SUF): $(SRC_DIR)/lset.h -go.$(SUF): $(SRC_DIR)/put.h -go.$(SUF): $(SRC_DIR)/get.h -go.$(SUF): $(SRC_DIR)/files.h -go.$(SUF): $(SRC_DIR)/global.h -go.$(SUF): $(SRC_DIR)/debug.h -go.$(SUF): $(SRC_DIR)/types.h -map.$(SUF): $(SRC_DIR)/map.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/map.c -map.$(SUF): $(SRC_DIR)/map.h -map.$(SUF): $(SRC_DIR)/types.h -aux.$(SUF): $(SRC_DIR)/aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/aux.c -aux.$(SUF): $(SRC_DIR)/lset.h -aux.$(SUF): $(SRC_DIR)/map.h -aux.$(SUF): $(SRC_DIR)/aux.h -aux.$(SUF): $(SRC_DIR)/alloc.h -aux.$(SUF): $(SRC_DIR)/global.h -aux.$(SUF): $(SRC_DIR)/debug.h -aux.$(SUF): $(SRC_DIR)/types.h -aux.$(SUF): $(EMH)/em_pseu.h -aux.$(SUF): $(EMH)/em_mes.h -get.$(SUF): $(SRC_DIR)/get.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/get.c -get.$(SUF): $(SRC_DIR)/aux.h -get.$(SUF): $(SRC_DIR)/map.h -get.$(SUF): $(SRC_DIR)/alloc.h -get.$(SUF): $(SRC_DIR)/get.h -get.$(SUF): $(SRC_DIR)/cset.h -get.$(SUF): $(SRC_DIR)/lset.h -get.$(SUF): $(SRC_DIR)/global.h -get.$(SUF): $(SRC_DIR)/debug.h -get.$(SUF): $(SRC_DIR)/def.h -get.$(SUF): $(SRC_DIR)/types.h -get.$(SUF): $(EMH)/em_mes.h -get.$(SUF): $(EMH)/em_pseu.h -get.$(SUF): $(EMH)/em_mnem.h -get.$(SUF): $(EMH)/em_spec.h -put.$(SUF): $(SRC_DIR)/put.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/put.c -put.$(SUF): $(SRC_DIR)/put.h -put.$(SUF): $(SRC_DIR)/alloc.h -put.$(SUF): $(SRC_DIR)/lset.h -put.$(SUF): $(SRC_DIR)/map.h -put.$(SUF): $(SRC_DIR)/def.h -put.$(SUF): $(SRC_DIR)/debug.h -put.$(SUF): $(SRC_DIR)/global.h -put.$(SUF): $(SRC_DIR)/types.h -put.$(SUF): $(EMH)/em_spec.h -put.$(SUF): $(EMH)/em_pseu.h -alloc.$(SUF): $(SRC_DIR)/alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/alloc.c -alloc.$(SUF): $(SRC_DIR)/alloc.h -alloc.$(SUF): $(SRC_DIR)/debug.h -alloc.$(SUF): $(SRC_DIR)/types.h -lset.$(SUF): $(SRC_DIR)/lset.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lset.c -lset.$(SUF): $(SRC_DIR)/debug.h -lset.$(SUF): $(SRC_DIR)/alloc.h -lset.$(SUF): $(SRC_DIR)/lset.h -lset.$(SUF): $(SRC_DIR)/types.h -cset.$(SUF): $(SRC_DIR)/cset.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cset.c -cset.$(SUF): $(SRC_DIR)/global.h -cset.$(SUF): $(SRC_DIR)/debug.h -cset.$(SUF): $(SRC_DIR)/alloc.h -cset.$(SUF): $(SRC_DIR)/cset.h -cset.$(SUF): $(SRC_DIR)/types.h -parser.$(SUF): $(SRC_DIR)/parser.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/parser.c -parser.$(SUF): ./classdefs.h -parser.$(SUF): $(SRC_DIR)/aux.h -parser.$(SUF): $(SRC_DIR)/lset.h -parser.$(SUF): $(SRC_DIR)/global.h -parser.$(SUF): $(SRC_DIR)/alloc.h -parser.$(SUF): $(SRC_DIR)/debug.h -parser.$(SUF): $(SRC_DIR)/types.h -parser.$(SUF): $(EMH)/em_mnem.h -parser.$(SUF): $(EMH)/em_spec.h -stack_chg.$(SUF): $(SRC_DIR)/stack_chg.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/stack_chg.c -stack_chg.$(SUF): $(SRC_DIR)/pop_push.h -stack_chg.$(SUF): $(SRC_DIR)/global.h -stack_chg.$(SUF): $(SRC_DIR)/debug.h -stack_chg.$(SUF): $(SRC_DIR)/types.h -stack_chg.$(SUF): $(EMH)/em_mnem.h -stack_chg.$(SUF): $(EMH)/em_spec.h -locals.$(SUF): $(SRC_DIR)/locals.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/locals.c -locals.$(SUF): $(SRC_DIR)/locals.h -locals.$(SUF): $(SRC_DIR)/alloc.h -locals.$(SUF): $(SRC_DIR)/aux.h -locals.$(SUF): $(SRC_DIR)/get.h -locals.$(SUF): $(SRC_DIR)/def.h -locals.$(SUF): $(SRC_DIR)/cset.h -locals.$(SUF): $(SRC_DIR)/lset.h -locals.$(SUF): $(SRC_DIR)/global.h -locals.$(SUF): $(SRC_DIR)/debug.h -locals.$(SUF): $(SRC_DIR)/types.h -locals.$(SUF): $(EMH)/em_mes.h -locals.$(SUF): $(EMH)/em_pseu.h -locals.$(SUF): $(EMH)/em_spec.h -locals.$(SUF): $(EMH)/em_mnem.h -init_glob.$(SUF): $(SRC_DIR)/init_glob.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/init_glob.c -init_glob.$(SUF): $(SRC_DIR)/map.h -init_glob.$(SUF): $(SRC_DIR)/alloc.h -init_glob.$(SUF): $(SRC_DIR)/global.h -init_glob.$(SUF): $(SRC_DIR)/debug.h -init_glob.$(SUF): $(SRC_DIR)/types.h diff --git a/util/ego/sp/proto.make b/util/ego/sp/proto.make deleted file mode 100644 index 358ff7d06..000000000 --- a/util/ego/sp/proto.make +++ /dev/null @@ -1,75 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/sp -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/sp.c - -OFILES=\ -sp.$(SUF) - -HFILES= - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: sp - -sp: $(OFILES) - $(CC) -o sp $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp sp $(EMLIB)/ego/sp - -cmp: all - -cmp sp $(EMLIB)/ego/sp - -clean: - rm -f *.$(SUF) sp Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -sp.$(SUF): $(SRC_DIR)/sp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sp.c -sp.$(SUF): $(SRC_DIR)/../share/stack_chg.h -sp.$(SUF): $(SRC_DIR)/../share/go.h -sp.$(SUF): $(SRC_DIR)/../share/aux.h -sp.$(SUF): $(SRC_DIR)/../share/alloc.h -sp.$(SUF): $(SRC_DIR)/../share/map.h -sp.$(SUF): $(SRC_DIR)/../share/lset.h -sp.$(SUF): $(SRC_DIR)/../share/put.h -sp.$(SUF): $(SRC_DIR)/../share/get.h -sp.$(SUF): $(SRC_DIR)/../share/files.h -sp.$(SUF): $(SRC_DIR)/../share/global.h -sp.$(SUF): $(SRC_DIR)/../share/debug.h -sp.$(SUF): $(SRC_DIR)/../share/types.h -sp.$(SUF): $(EMH)/em_spec.h -sp.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/sr/proto.make b/util/ego/sr/proto.make deleted file mode 100644 index 2c8665c03..000000000 --- a/util/ego/sr/proto.make +++ /dev/null @@ -1,176 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/sr -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/sr.c \ - $(SRC_DIR)/sr_aux.c \ - $(SRC_DIR)/sr_cand.c \ - $(SRC_DIR)/sr_expr.c \ - $(SRC_DIR)/sr_iv.c \ - $(SRC_DIR)/sr_reduce.c \ - $(SRC_DIR)/sr_xform.c - -OFILES=\ - sr.$(SUF) sr_aux.$(SUF) sr_cand.$(SUF) sr_expr.$(SUF) sr_iv.$(SUF) \ - sr_reduce.$(SUF) sr_xform.$(SUF) - -HFILES=\ - $(SRC_DIR)/sr.h \ - $(SRC_DIR)/sr_aux.h \ - $(SRC_DIR)/sr_cand.h \ - $(SRC_DIR)/sr_expr.h \ - $(SRC_DIR)/sr_iv.h \ - $(SRC_DIR)/sr_reduce.h \ - $(SRC_DIR)/sr_xform.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: sr - -sr: $(OFILES) - $(CC) -o sr $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp sr $(EMLIB)/ego/sr - -cmp: all - -cmp sr $(EMLIB)/ego/sr - -clean: - rm -f *.$(SUF) sr Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -sr.$(SUF): $(SRC_DIR)/sr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr.c -sr.$(SUF): $(SRC_DIR)/sr_iv.h -sr.$(SUF): $(SRC_DIR)/sr_aux.h -sr.$(SUF): $(SRC_DIR)/../share/aux.h -sr.$(SUF): $(SRC_DIR)/../share/go.h -sr.$(SUF): $(SRC_DIR)/../share/alloc.h -sr.$(SUF): $(SRC_DIR)/../share/map.h -sr.$(SUF): $(SRC_DIR)/../share/lset.h -sr.$(SUF): $(SRC_DIR)/../share/put.h -sr.$(SUF): $(SRC_DIR)/../share/get.h -sr.$(SUF): $(SRC_DIR)/../share/files.h -sr.$(SUF): $(SRC_DIR)/../share/global.h -sr.$(SUF): $(SRC_DIR)/../share/debug.h -sr.$(SUF): $(SRC_DIR)/sr.h -sr.$(SUF): $(SRC_DIR)/../share/types.h -sr_aux.$(SUF): $(SRC_DIR)/sr_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_aux.c -sr_aux.$(SUF): $(SRC_DIR)/sr_xform.h -sr_aux.$(SUF): $(SRC_DIR)/sr_aux.h -sr_aux.$(SUF): $(SRC_DIR)/../share/aux.h -sr_aux.$(SUF): $(SRC_DIR)/../share/lset.h -sr_aux.$(SUF): $(SRC_DIR)/../share/global.h -sr_aux.$(SUF): $(SRC_DIR)/../share/debug.h -sr_aux.$(SUF): $(SRC_DIR)/sr.h -sr_aux.$(SUF): $(SRC_DIR)/../share/types.h -sr_aux.$(SUF): $(EMH)/em_pseu.h -sr_aux.$(SUF): $(EMH)/em_mnem.h -sr_cand.$(SUF): $(SRC_DIR)/sr_cand.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_cand.c -sr_cand.$(SUF): $(SRC_DIR)/sr_cand.h -sr_cand.$(SUF): $(SRC_DIR)/sr_aux.h -sr_cand.$(SUF): $(SRC_DIR)/sr.h -sr_cand.$(SUF): $(SRC_DIR)/../share/aux.h -sr_cand.$(SUF): $(SRC_DIR)/../share/map.h -sr_cand.$(SUF): $(SRC_DIR)/../share/global.h -sr_cand.$(SUF): $(SRC_DIR)/../share/debug.h -sr_cand.$(SUF): $(SRC_DIR)/../share/cset.h -sr_cand.$(SUF): $(SRC_DIR)/../share/lset.h -sr_cand.$(SUF): $(SRC_DIR)/../share/types.h -sr_cand.$(SUF): $(EMH)/em_pseu.h -sr_cand.$(SUF): $(EMH)/em_mnem.h -sr_expr.$(SUF): $(SRC_DIR)/sr_expr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_expr.c -sr_expr.$(SUF): $(SRC_DIR)/sr_iv.h -sr_expr.$(SUF): $(SRC_DIR)/../share/lset.h -sr_expr.$(SUF): $(SRC_DIR)/sr_aux.h -sr_expr.$(SUF): $(SRC_DIR)/../share/aux.h -sr_expr.$(SUF): $(SRC_DIR)/../share/global.h -sr_expr.$(SUF): $(SRC_DIR)/../share/debug.h -sr_expr.$(SUF): $(SRC_DIR)/sr.h -sr_expr.$(SUF): $(SRC_DIR)/../share/types.h -sr_expr.$(SUF): $(EMH)/em_mnem.h -sr_iv.$(SUF): $(SRC_DIR)/sr_iv.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_iv.c -sr_iv.$(SUF): $(SRC_DIR)/sr_iv.h -sr_iv.$(SUF): $(SRC_DIR)/sr_cand.h -sr_iv.$(SUF): $(SRC_DIR)/sr_aux.h -sr_iv.$(SUF): $(SRC_DIR)/../share/aux.h -sr_iv.$(SUF): $(SRC_DIR)/../share/alloc.h -sr_iv.$(SUF): $(SRC_DIR)/../share/global.h -sr_iv.$(SUF): $(SRC_DIR)/../share/debug.h -sr_iv.$(SUF): $(SRC_DIR)/../share/cset.h -sr_iv.$(SUF): $(SRC_DIR)/../share/lset.h -sr_iv.$(SUF): $(SRC_DIR)/sr.h -sr_iv.$(SUF): $(SRC_DIR)/../share/types.h -sr_iv.$(SUF): $(EMH)/em_pseu.h -sr_iv.$(SUF): $(EMH)/em_mnem.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_reduce.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_reduce.c -sr_reduce.$(SUF): $(SRC_DIR)/sr_expr.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_reduce.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_xform.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/lset.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_aux.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/aux.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/global.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/def.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/alloc.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/debug.h -sr_reduce.$(SUF): $(SRC_DIR)/sr.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/types.h -sr_reduce.$(SUF): $(EMH)/em_spec.h -sr_reduce.$(SUF): $(EMH)/em_mnem.h -sr_reduce.$(SUF): $(EMH)/em_mes.h -sr_reduce.$(SUF): $(EMH)/em_reg.h -sr_reduce.$(SUF): $(EMH)/em_pseu.h -sr_xform.$(SUF): $(SRC_DIR)/sr_xform.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_xform.c -sr_xform.$(SUF): $(SRC_DIR)/sr_xform.h -sr_xform.$(SUF): $(SRC_DIR)/../share/aux.h -sr_xform.$(SUF): $(SRC_DIR)/../share/lset.h -sr_xform.$(SUF): $(SRC_DIR)/sr_aux.h -sr_xform.$(SUF): $(SRC_DIR)/../share/get.h -sr_xform.$(SUF): $(SRC_DIR)/../share/def.h -sr_xform.$(SUF): $(SRC_DIR)/../share/alloc.h -sr_xform.$(SUF): $(SRC_DIR)/../share/global.h -sr_xform.$(SUF): $(SRC_DIR)/../share/debug.h -sr_xform.$(SUF): $(SRC_DIR)/sr.h -sr_xform.$(SUF): $(SRC_DIR)/../share/types.h -sr_xform.$(SUF): $(EMH)/em_spec.h -sr_xform.$(SUF): $(EMH)/em_pseu.h -sr_xform.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/ud/proto.make b/util/ego/ud/proto.make deleted file mode 100644 index 5beb264da..000000000 --- a/util/ego/ud/proto.make +++ /dev/null @@ -1,158 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ud -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ud.c \ - $(SRC_DIR)/ud_defs.c \ - $(SRC_DIR)/ud_const.c \ - $(SRC_DIR)/ud_copy.c \ - $(SRC_DIR)/ud_aux.c - -OFILES=\ - ud.$(SUF) ud_defs.$(SUF) ud_const.$(SUF) ud_copy.$(SUF) \ - ud_aux.$(SUF) - -HFILES=\ - $(SRC_DIR)/ud.h \ - $(SRC_DIR)/ud_defs.h \ - $(SRC_DIR)/ud_const.h \ - $(SRC_DIR)/ud_copy.h \ - $(SRC_DIR)/ud_aux.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ud - -ud: $(OFILES) - $(CC) -o ud $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp ud $(EMLIB)/ego/ud - -cmp: all - -cmp ud $(EMLIB)/ego/ud - -clean: - rm -f *.$(SUF) ud Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ud.$(SUF): $(SRC_DIR)/ud.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud.c -ud.$(SUF): $(SRC_DIR)/ud_copy.h -ud.$(SUF): $(SRC_DIR)/ud_const.h -ud.$(SUF): $(SRC_DIR)/ud_defs.h -ud.$(SUF): $(SRC_DIR)/../share/go.h -ud.$(SUF): $(SRC_DIR)/../share/locals.h -ud.$(SUF): $(SRC_DIR)/../share/init_glob.h -ud.$(SUF): $(SRC_DIR)/../share/aux.h -ud.$(SUF): $(SRC_DIR)/../share/alloc.h -ud.$(SUF): $(SRC_DIR)/../share/put.h -ud.$(SUF): $(SRC_DIR)/../share/get.h -ud.$(SUF): $(SRC_DIR)/../share/map.h -ud.$(SUF): $(SRC_DIR)/../share/files.h -ud.$(SUF): $(SRC_DIR)/../share/def.h -ud.$(SUF): $(SRC_DIR)/../share/cset.h -ud.$(SUF): $(SRC_DIR)/../share/lset.h -ud.$(SUF): $(SRC_DIR)/../share/global.h -ud.$(SUF): $(SRC_DIR)/../share/debug.h -ud.$(SUF): $(SRC_DIR)/ud.h -ud.$(SUF): $(SRC_DIR)/../share/types.h -ud.$(SUF): $(EMH)/em_spec.h -ud_defs.$(SUF): $(SRC_DIR)/ud_defs.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_defs.c -ud_defs.$(SUF): $(SRC_DIR)/../share/aux.h -ud_defs.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_defs.$(SUF): $(SRC_DIR)/ud_defs.h -ud_defs.$(SUF): $(SRC_DIR)/../share/locals.h -ud_defs.$(SUF): $(SRC_DIR)/../share/map.h -ud_defs.$(SUF): $(SRC_DIR)/../share/cset.h -ud_defs.$(SUF): $(SRC_DIR)/../share/lset.h -ud_defs.$(SUF): $(SRC_DIR)/../share/global.h -ud_defs.$(SUF): $(SRC_DIR)/../share/debug.h -ud_defs.$(SUF): $(SRC_DIR)/ud.h -ud_defs.$(SUF): $(SRC_DIR)/../share/types.h -ud_defs.$(SUF): $(EMH)/em_mnem.h -ud_const.$(SUF): $(SRC_DIR)/ud_const.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_const.c -ud_const.$(SUF): $(SRC_DIR)/ud_aux.h -ud_const.$(SUF): $(SRC_DIR)/ud_const.h -ud_const.$(SUF): $(SRC_DIR)/ud_defs.h -ud_const.$(SUF): $(SRC_DIR)/../share/locals.h -ud_const.$(SUF): $(SRC_DIR)/../share/aux.h -ud_const.$(SUF): $(SRC_DIR)/../share/def.h -ud_const.$(SUF): $(SRC_DIR)/../share/cset.h -ud_const.$(SUF): $(SRC_DIR)/../share/lset.h -ud_const.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_const.$(SUF): $(SRC_DIR)/../share/global.h -ud_const.$(SUF): $(SRC_DIR)/../share/debug.h -ud_const.$(SUF): $(SRC_DIR)/ud.h -ud_const.$(SUF): $(SRC_DIR)/../share/types.h -ud_const.$(SUF): $(EMH)/em_spec.h -ud_const.$(SUF): $(EMH)/em_pseu.h -ud_const.$(SUF): $(EMH)/em_mnem.h -ud_copy.$(SUF): $(SRC_DIR)/ud_copy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_copy.c -ud_copy.$(SUF): $(SRC_DIR)/ud_aux.h -ud_copy.$(SUF): $(SRC_DIR)/ud_const.h -ud_copy.$(SUF): $(SRC_DIR)/ud_copy.h -ud_copy.$(SUF): $(SRC_DIR)/../ud/ud_defs.h -ud_copy.$(SUF): $(SRC_DIR)/../share/locals.h -ud_copy.$(SUF): $(SRC_DIR)/../share/aux.h -ud_copy.$(SUF): $(SRC_DIR)/../share/def.h -ud_copy.$(SUF): $(SRC_DIR)/../share/cset.h -ud_copy.$(SUF): $(SRC_DIR)/../share/lset.h -ud_copy.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_copy.$(SUF): $(SRC_DIR)/../share/global.h -ud_copy.$(SUF): $(SRC_DIR)/../share/debug.h -ud_copy.$(SUF): $(SRC_DIR)/ud.h -ud_copy.$(SUF): $(SRC_DIR)/../share/types.h -ud_copy.$(SUF): $(EMH)/em_spec.h -ud_copy.$(SUF): $(EMH)/em_pseu.h -ud_copy.$(SUF): $(EMH)/em_mnem.h -ud_aux.$(SUF): $(SRC_DIR)/ud_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_aux.c -ud_aux.$(SUF): $(SRC_DIR)/ud_defs.h -ud_aux.$(SUF): $(SRC_DIR)/../share/aux.h -ud_aux.$(SUF): $(SRC_DIR)/../share/locals.h -ud_aux.$(SUF): $(SRC_DIR)/../share/def.h -ud_aux.$(SUF): $(SRC_DIR)/../share/cset.h -ud_aux.$(SUF): $(SRC_DIR)/../share/lset.h -ud_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_aux.$(SUF): $(SRC_DIR)/../share/global.h -ud_aux.$(SUF): $(SRC_DIR)/../share/debug.h -ud_aux.$(SUF): $(SRC_DIR)/ud.h -ud_aux.$(SUF): $(SRC_DIR)/../share/types.h -ud_aux.$(SUF): $(EMH)/em_spec.h -ud_aux.$(SUF): $(EMH)/em_pseu.h -ud_aux.$(SUF): $(EMH)/em_mnem.h diff --git a/util/led/build.mk b/util/led/build.mk deleted file mode 100644 index 419948a13..000000000 --- a/util/led/build.mk +++ /dev/null @@ -1,34 +0,0 @@ -D := util/led - -define build-led-impl - $(call reset) - $(call cfile, $D/archive.c) - $(call cfile, $D/error.c) - $(call cfile, $D/extract.c) - $(call cfile, $D/finish.c) - $(call cfile, $D/main.c) - $(call cfile, $D/memory.c) - $(call cfile, $D/output.c) - $(call cfile, $D/read.c) - $(call cfile, $D/relocate.c) - $(call cfile, $D/save.c) - $(call cfile, $D/scan.c) - $(call cfile, $D/sym.c) - $(call cfile, $D/write.c) - - $(call rawfile, $(LIBSTRING)) - $(call rawfile, $(LIBOBJECT)) - - $(call cprogram, $(BINDIR)/em_led) - $(call installto, $(PLATDEP)/em_led) - - $(call reset) - $(eval q := $D/ack.out.5) - $(call installto, $(INSDIR)/share/man/man5/ack.out.5) - - $(call reset) - $(eval q := $D/led.6) - $(call installto, $(INSDIR)/share/man/man6/led.6) -endef - -$(eval $(build-led-impl)) diff --git a/util/misc/build.mk b/util/misc/build.mk deleted file mode 100644 index 95b6fb2d9..000000000 --- a/util/misc/build.mk +++ /dev/null @@ -1,49 +0,0 @@ -D := util/misc - -define build-misc-impl - $(call reset) - $(call cfile, $D/esize.c) - $(call cprogram, $(BINDIR)/esize) - $(call installto, $(INSDIR)/bin/esize) - - $(call reset) - $(eval q := $D/esize.1) - $(call installto, $(INSDIR)/share/man/man1/esize.1) - - $(call reset) - $(eval objdir := encode) - $(call cfile, $D/convert.c) - $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) - $(call rawfile, $(LIBREAD_EMEV)) - $(call rawfile, $(LIBEMK)) - $(call rawfile, $(LIBEM_DATA)) - $(call rawfile, $(LIBALLOC)) - $(call rawfile, $(LIBPRINT)) - $(call rawfile, $(LIBSTRING)) - $(call rawfile, $(LIBSYSTEM)) - $(call cprogram, $(BINDIR)/em_encode) - $(call installto, $(PLATDEP)/em_encode) - $(eval EM_ENCODE := $o) - $(eval ACK_CORE_TOOLS += $o) - - $(call reset) - $(eval objdir := decode) - $(call cfile, $D/convert.c) - $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) - $(call rawfile, $(LIBREAD_EMKV)) - $(call rawfile, $(LIBEME)) - $(call rawfile, $(LIBEM_DATA)) - $(call rawfile, $(LIBALLOC)) - $(call rawfile, $(LIBPRINT)) - $(call rawfile, $(LIBSTRING)) - $(call rawfile, $(LIBSYSTEM)) - $(call cprogram, $(BINDIR)/em_decode) - $(call installto, $(PLATDEP)/em_decode) - $(eval EM_DECODE := $o) - - $(call reset) - $(eval q := $D/em_decode.6) - $(call installto, $(INSDIR)/share/man/man6/em_decode.6) -endef - -$(eval $(build-misc-impl)) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk deleted file mode 100644 index 9c3eef3da..000000000 --- a/util/ncgg/build.mk +++ /dev/null @@ -1,43 +0,0 @@ -D := util/ncgg - -define build-ncgg-impl - -$(call reset) -$(eval cflags += -I$D) - -$(call yacc, $(OBJDIR)/$D, $D/cgg.y) - -$(call flex, $(OBJDIR)/$D, $D/scan.l) -$(call dependson, $(OBJDIR)/$D/y.tab.h) - -$(call cfile, $D/subr.c) -$(call cfile, $D/main.c) -$(call cfile, $D/coerc.c) -$(call cfile, $D/error.c) -$(call cfile, $D/emlookup.c) -$(call cfile, $D/expr.c) -$(call cfile, $D/instruct.c) -$(call cfile, $D/iocc.c) -$(call cfile, $D/lookup.c) -$(call cfile, $D/output.c) -$(call cfile, $D/set.c) -$(call cfile, $D/strlookup.c) -$(call cfile, $D/var.c) -$(call cfile, $D/hall.c) - -$(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c) -$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(OBJDIR)/$D/y.tab.h - @echo KEYWORDS $$@ - @mkdir -p $$(dir $$@) - $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) -$(call cfile, $(OBJDIR)/$D/enterkeyw.c) - -$(eval $q: $(INCDIR)/em_spec.h) - -$(call rawfile, $(LIBEM_DATA)) -$(call cprogram, $(BINDIR)/ncgg) -$(eval NCGG := $o) - -endef - -$(eval $(build-ncgg-impl)) diff --git a/util/ncgg/proto.make b/util/ncgg/proto.make deleted file mode 100644 index 9adc5cd46..000000000 --- a/util/ncgg/proto.make +++ /dev/null @@ -1,255 +0,0 @@ -# Header: Makefile,v 0.8 87/11/16 10:35:32 ceriel Exp $ - -#PARAMS do not remove this line! - -CFILES= cgg.c $(SRC_DIR)/subr.c $(SRC_DIR)/main.c $(SRC_DIR)/coerc.c \ - enterkeyw.c $(SRC_DIR)/error.c $(SRC_DIR)/emlookup.c $(SRC_DIR)/expr.c \ - $(SRC_DIR)/instruct.c $(SRC_DIR)/iocc.c $(SRC_DIR)/lookup.c \ - $(SRC_DIR)/output.c $(SRC_DIR)/set.c $(SRC_DIR)/strlookup.c \ - $(SRC_DIR)/var.c $(SRC_DIR)/hall.c -OFILES= cgg.$(SUF) subr.$(SUF) main.$(SUF) coerc.$(SUF) enterkeyw.$(SUF) \ - error.$(SUF) emlookup.$(SUF) expr.$(SUF) instruct.$(SUF) iocc.$(SUF) \ - lookup.$(SUF) set.$(SUF) strlookup.$(SUF) var.$(SUF) hall.$(SUF) -SOURCES=$(SRC_DIR)/*.h $(SRC_DIR)/cgg.y $(SRC_DIR)/scan.l \ - $(SRC_DIR)/cvtkeywords $(SRC_DIR)/keywords $(SRC_DIR)/coerc.c \ - $(SRC_DIR)/emlookup.c $(SRC_DIR)/error.c $(SRC_DIR)/expr.c \ - $(SRC_DIR)/hall.c $(SRC_DIR)/instruct.c $(SRC_DIR)/iocc.c \ - $(SRC_DIR)/lookup.c $(SRC_DIR)/main.c $(SRC_DIR)/output.c \ - $(SRC_DIR)/set.c $(SRC_DIR)/strlookup.c $(SRC_DIR)/subr.c \ - $(SRC_DIR)/var.c - -SRC_DIR=$(SRC_HOME)/util/ncgg -EMH=$(TARGET_HOME)/h -INCLUDES=-I$(EMH) -I$(TARGET_HOME)/config -I$(SRC_DIR) -I. -CFLAGS=$(INCLUDES) $(COPTIONS) -DNDEBUG -YFLAGS=-d -LDFLAGS=$(LDOPTIONS) -LINTFLAGS=$(INCLUDES) $(LINTOPTIONS) - - -cgg: cgg.$(SUF) $(OFILES) output.$(SUF) - $(CC) $(LDFLAGS) $(OFILES) output.$(SUF) $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) -o cgg - -install: cgg - cp cgg $(TARGET_HOME)/lib.bin/ncgg - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/ncgg.6 $(TARGET_HOME) ; \ - fi - -cmp: cgg - -cmp cgg $(TARGET_HOME)/lib.bin/ncgg - -debugcgg: cgg.$(SUF) $(OFILES) debugoutput.$(SUF) - $(CC) $(LDFLAGS) $(OFILES) debugoutput.$(SUF) $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) -o cgg - -cgg.c: $(SRC_DIR)/cgg.y - yacc $(YFLAGS) $(SRC_DIR)/cgg.y && mv y.tab.c cgg.c - -enterkeyw.c: $(SRC_DIR)/cvtkeywords $(SRC_DIR)/keywords y.tab.h - $(SRC_DIR)/cvtkeywords $(SRC_DIR)/keywords - -debugoutput.$(SUF): debugoutput.c - $(CC) $(CFLAGS) -DCODEDEBUG -c debugoutput.c - -debugoutput.c: $(SRC_DIR)/output.c - cp $(SRC_DIR)/output.c debugoutput.c - -lint: $(CFILES) - $(LINT) $(LINTFLAGS) $(CFILES) - -clean: - rm -f cgg.c scan.c y.output y.tab.h enterkeyw.c debugoutput.c - rm -f $(OFILES) output.$(SUF) debugoutput.$(SUF) cgg lint - -scan.c: $(SRC_DIR)/scan.l - flex -st $(SRC_DIR)/scan.l > scan.c - -pr: - @pr $(SOURCES) - -opr: - -make pr|opr - -depend: $(CFILES) scan.c - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -#DEPENDENCIES -cgg.$(SUF): cgg.c - $(CC) -c $(CFLAGS) cgg.c -cgg.$(SUF): scan.c -cgg.$(SUF): $(TARGET_HOME)/h/em_reg.h -cgg.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -cgg.$(SUF): $(SRC_DIR)/extern.h -cgg.$(SUF): $(SRC_DIR)/expr.h -cgg.$(SUF): $(SRC_DIR)/cost.h -cgg.$(SUF): $(SRC_DIR)/instruct.h -cgg.$(SUF): $(SRC_DIR)/iocc.h -cgg.$(SUF): $(SRC_DIR)/set.h -cgg.$(SUF): $(SRC_DIR)/lookup.h -cgg.$(SUF): $(SRC_DIR)/varinfo.h -cgg.$(SUF): $(TARGET_HOME)/h/em_spec.h -cgg.$(SUF): $(TARGET_HOME)/config/local.h -cgg.$(SUF): $(SRC_DIR)/param.h -subr.$(SUF): $(SRC_DIR)/subr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/subr.c -subr.$(SUF): $(SRC_DIR)/extern.h -subr.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -subr.$(SUF): $(SRC_DIR)/regvar.h -subr.$(SUF): $(SRC_DIR)/token.h -subr.$(SUF): $(SRC_DIR)/cost.h -subr.$(SUF): $(SRC_DIR)/instruct.h -subr.$(SUF): $(SRC_DIR)/varinfo.h -subr.$(SUF): $(SRC_DIR)/set.h -subr.$(SUF): $(SRC_DIR)/expr.h -subr.$(SUF): $(SRC_DIR)/property.h -subr.$(SUF): $(SRC_DIR)/lookup.h -subr.$(SUF): $(SRC_DIR)/reg.h -subr.$(SUF): $(TARGET_HOME)/h/em_spec.h -subr.$(SUF): $(TARGET_HOME)/config/local.h -subr.$(SUF): $(SRC_DIR)/param.h -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -coerc.$(SUF): $(SRC_DIR)/coerc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/coerc.c -coerc.$(SUF): $(SRC_DIR)/extern.h -coerc.$(SUF): $(SRC_DIR)/pseudo.h -coerc.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -coerc.$(SUF): $(SRC_DIR)/iocc.h -coerc.$(SUF): $(SRC_DIR)/varinfo.h -coerc.$(SUF): $(SRC_DIR)/cost.h -coerc.$(SUF): $(SRC_DIR)/token.h -coerc.$(SUF): $(SRC_DIR)/reg.h -coerc.$(SUF): $(SRC_DIR)/property.h -coerc.$(SUF): $(SRC_DIR)/set.h -coerc.$(SUF): $(TARGET_HOME)/h/em_spec.h -coerc.$(SUF): $(TARGET_HOME)/config/local.h -coerc.$(SUF): $(SRC_DIR)/param.h -coerc.$(SUF): $(SRC_DIR)/assert.h -enterkeyw.$(SUF): enterkeyw.c - $(CC) -c $(CFLAGS) enterkeyw.c -enterkeyw.$(SUF): $(SRC_DIR)/lookup.h -error.$(SUF): $(SRC_DIR)/error.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/error.c -emlookup.$(SUF): $(SRC_DIR)/emlookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/emlookup.c -emlookup.$(SUF): $(TARGET_HOME)/h/em_flag.h -emlookup.$(SUF): $(SRC_DIR)/expr.h -emlookup.$(SUF): $(TARGET_HOME)/h/em_spec.h -emlookup.$(SUF): $(TARGET_HOME)/config/local.h -emlookup.$(SUF): $(SRC_DIR)/param.h -expr.$(SUF): $(SRC_DIR)/expr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/expr.c -expr.$(SUF): $(SRC_DIR)/extern.h -expr.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -expr.$(SUF): $(SRC_DIR)/regvar.h -expr.$(SUF): $(SRC_DIR)/expr.h -expr.$(SUF): $(SRC_DIR)/property.h -expr.$(SUF): $(SRC_DIR)/cost.h -expr.$(SUF): $(SRC_DIR)/token.h -expr.$(SUF): $(SRC_DIR)/lookup.h -expr.$(SUF): $(SRC_DIR)/reg.h -expr.$(SUF): $(SRC_DIR)/set.h -expr.$(SUF): $(TARGET_HOME)/h/em_spec.h -expr.$(SUF): $(TARGET_HOME)/config/local.h -expr.$(SUF): $(SRC_DIR)/param.h -expr.$(SUF): $(SRC_DIR)/assert.h -instruct.$(SUF): $(SRC_DIR)/instruct.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/instruct.c -instruct.$(SUF): $(SRC_DIR)/extern.h -instruct.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -instruct.$(SUF): $(SRC_DIR)/iocc.h -instruct.$(SUF): $(SRC_DIR)/expr.h -instruct.$(SUF): $(SRC_DIR)/set.h -instruct.$(SUF): $(SRC_DIR)/varinfo.h -instruct.$(SUF): $(SRC_DIR)/pseudo.h -instruct.$(SUF): $(SRC_DIR)/cost.h -instruct.$(SUF): $(SRC_DIR)/instruct.h -instruct.$(SUF): $(TARGET_HOME)/h/em_spec.h -instruct.$(SUF): $(TARGET_HOME)/config/local.h -instruct.$(SUF): $(SRC_DIR)/param.h -iocc.$(SUF): $(SRC_DIR)/iocc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/iocc.c -iocc.$(SUF): $(SRC_DIR)/extern.h -iocc.$(SUF): $(SRC_DIR)/regvar.h -iocc.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -iocc.$(SUF): $(SRC_DIR)/iocc.h -iocc.$(SUF): $(SRC_DIR)/property.h -iocc.$(SUF): $(SRC_DIR)/cost.h -iocc.$(SUF): $(SRC_DIR)/token.h -iocc.$(SUF): $(SRC_DIR)/lookup.h -iocc.$(SUF): $(SRC_DIR)/expr.h -iocc.$(SUF): $(SRC_DIR)/set.h -iocc.$(SUF): $(TARGET_HOME)/h/em_spec.h -iocc.$(SUF): $(TARGET_HOME)/config/local.h -iocc.$(SUF): $(SRC_DIR)/param.h -iocc.$(SUF): $(SRC_DIR)/assert.h -lookup.$(SUF): $(SRC_DIR)/lookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lookup.c -lookup.$(SUF): $(SRC_DIR)/lookup.h -lookup.$(SUF): $(TARGET_HOME)/h/em_spec.h -lookup.$(SUF): $(TARGET_HOME)/config/local.h -lookup.$(SUF): $(SRC_DIR)/param.h -lookup.$(SUF): $(SRC_DIR)/assert.h -output.$(SUF): $(SRC_DIR)/output.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/output.c -output.$(SUF): $(SRC_DIR)/extern.h -output.$(SUF): $(SRC_DIR)/regvar.h -output.$(SUF): $(SRC_DIR)/pseudo.h -output.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -output.$(SUF): $(SRC_DIR)/lookup.h -output.$(SUF): $(SRC_DIR)/instruct.h -output.$(SUF): $(SRC_DIR)/set.h -output.$(SUF): $(SRC_DIR)/cost.h -output.$(SUF): $(SRC_DIR)/token.h -output.$(SUF): $(SRC_DIR)/property.h -output.$(SUF): $(SRC_DIR)/reg.h -output.$(SUF): $(TARGET_HOME)/h/em_spec.h -output.$(SUF): $(TARGET_HOME)/config/local.h -output.$(SUF): $(SRC_DIR)/param.h -output.$(SUF): $(SRC_DIR)/varinfo.h -output.$(SUF): $(SRC_DIR)/assert.h -set.$(SUF): $(SRC_DIR)/set.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/set.c -set.$(SUF): $(SRC_DIR)/extern.h -set.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -set.$(SUF): $(SRC_DIR)/reg.h -set.$(SUF): $(SRC_DIR)/lookup.h -set.$(SUF): $(SRC_DIR)/cost.h -set.$(SUF): $(SRC_DIR)/token.h -set.$(SUF): $(SRC_DIR)/set.h -set.$(SUF): $(SRC_DIR)/property.h -set.$(SUF): $(TARGET_HOME)/h/em_spec.h -set.$(SUF): $(TARGET_HOME)/config/local.h -set.$(SUF): $(SRC_DIR)/param.h -strlookup.$(SUF): $(SRC_DIR)/strlookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strlookup.c -strlookup.$(SUF): $(TARGET_HOME)/h/em_spec.h -strlookup.$(SUF): $(TARGET_HOME)/config/local.h -strlookup.$(SUF): $(SRC_DIR)/param.h -var.$(SUF): $(SRC_DIR)/var.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/var.c -var.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -var.$(SUF): $(SRC_DIR)/lookup.h -var.$(SUF): $(SRC_DIR)/instruct.h -var.$(SUF): $(SRC_DIR)/set.h -var.$(SUF): $(SRC_DIR)/cost.h -var.$(SUF): $(SRC_DIR)/token.h -var.$(SUF): $(SRC_DIR)/property.h -var.$(SUF): $(SRC_DIR)/reg.h -var.$(SUF): $(TARGET_HOME)/h/em_spec.h -var.$(SUF): $(TARGET_HOME)/config/local.h -var.$(SUF): $(SRC_DIR)/param.h -hall.$(SUF): $(SRC_DIR)/hall.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/hall.c -hall.$(SUF): $(SRC_DIR)/set.h -hall.$(SUF): $(TARGET_HOME)/h/em_spec.h -hall.$(SUF): $(TARGET_HOME)/config/local.h -hall.$(SUF): $(SRC_DIR)/param.h -hall.$(SUF): $(SRC_DIR)/assert.h diff --git a/util/opt/build.mk b/util/opt/build.mk deleted file mode 100644 index a4e62ced7..000000000 --- a/util/opt/build.mk +++ /dev/null @@ -1,84 +0,0 @@ -D := util/opt - -define build-opt-mktab-impl - -$(call reset) -$(eval cflags += -I$D) - -$(call yacc, $(OBJDIR)/$D, $D/mktab.y) - -$(call flex, $(OBJDIR)/$D, $D/scan.l) -$(call dependson, $(OBJDIR)/$D/y.tab.h) - -$(call rawfile, $(LIBEM_DATA)) -$(call cprogram, $(OBJDIR)/$D/mktab) - -endef - -.PHONY: -lfl --lfl: - -define build-opt-impl - -$(call reset) -$(eval objdir := $1) - -$(eval cflags += -I$D $2) -$(call cfile, $D/main.c) -$(call cfile, $D/getline.c) -$(call cfile, $D/lookup.c) -$(call cfile, $D/var.c) -$(call cfile, $D/process.c) -$(call cfile, $D/backward.c) -$(call cfile, $D/util.c) -$(call cfile, $D/alloc.c) -$(call cfile, $D/putline.c) -$(call cfile, $D/cleanup.c) -$(call cfile, $D/peephole.c) -$(call cfile, $D/flow.c) -$(call cfile, $D/tes.c) -$(call cfile, $D/reg.c) - -$(eval g := $(OBJDIR)/$D/$(objdir)/pop_push.c) -$(eval CLEANABLES += $g) -$g: $D/pop_push.awk h/em_table - @echo POP_PUSH $$@ - @mkdir -p $$(dir $$@) - $(hide) awk -f $D/pop_push.awk < h/em_table > $$@ -$(call cfile, $g) - -$(eval g := $(OBJDIR)/$D/$(objdir)/pattern.c) -$(eval CLEANABLES += $g) -$g: $(OBJDIR)/$D/mktab $D/patterns $(BINDIR)/cpp.ansi - @echo PATTERNS $$@ - @mkdir -p $$(dir $$@) - $(hide) $(BINDIR)/cpp.ansi < $D/patterns | $(OBJDIR)/$D/mktab > $$@ -$(call cfile, $g) - -$(call rawfile, $(LIBEM_DATA)) -$(call rawfile, $(LIBASSERT)) -$(call rawfile, $(LIBPRINT)) -$(call rawfile, $(LIBALLOC)) -$(call rawfile, $(LIBSYSTEM)) -$(call rawfile, $(LIBSTRING)) - -$(eval $q: $(INCDIR)/em_spec.h) - -$(call cprogram, $(BINDIR)/$(strip $1)) -$(call installto, $(PLATDEP)/$(strip $1)) -$(eval ACK_CORE_TOOLS += $o) - -endef - -define build-opt-manpage-impl - -$(call reset) -$(eval q := $D/em_opt.6) -$(call installto, $(INSDIR)/share/man/man6/em_opt.6) - -endef - -$(eval $(build-opt-mktab-impl)) -$(eval $(call build-opt-impl, em_opt,)) -$(eval $(call build-opt-impl, em_opt2, -DGLOBAL_OPT)) -$(eval $(build-opt-manpage-impl)) diff --git a/util/opt/proto.make b/util/opt/proto.make deleted file mode 100644 index 04107146f..000000000 --- a/util/opt/proto.make +++ /dev/null @@ -1,300 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/opt - -CFILES= $(SRC_DIR)/main.c $(SRC_DIR)/getline.c $(SRC_DIR)/lookup.c \ - $(SRC_DIR)/var.c $(SRC_DIR)/process.c $(SRC_DIR)/backward.c \ - $(SRC_DIR)/util.c $(SRC_DIR)/alloc.c $(SRC_DIR)/putline.c \ - $(SRC_DIR)/cleanup.c $(SRC_DIR)/peephole.c $(SRC_DIR)/flow.c \ - $(SRC_DIR)/reg.c $(SRC_DIR)/tes.c pop_push.c - -OFILES= main.$(SUF) getline.$(SUF) lookup.$(SUF) var.$(SUF) process.$(SUF) backward.$(SUF) util.$(SUF)\ - alloc.$(SUF) putline.$(SUF) cleanup.$(SUF) peephole.$(SUF) flow.$(SUF) tes.$(SUF) pop_push.$(SUF) -ONOGLOB=regnoglob.$(SUF) -OGLOB=regglob.$(SUF) - -LIBS= $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) -ULIBS= $(UTIL_HOME)/lib.bin/em_data.$(ULIBSUF) -INCLUDES=-I$(TARGET_HOME)/h -I$(SRC_DIR) -I. -UINCLUDES=-I$(TARGET_HOME)/h -I$(SRC_DIR) -I. -CFLAGS= -DNDEBUG $(INCLUDES) $(COPTIONS) -UCFLAGS= -DNDEBUG $(INCLUDES) $(UCOPTIONS) -LDFLAGS=$(LDOPTIONS) -ULDFLAGS=$(ULDOPTIONS) -LINTFLAGS=$(INCLUDES) -DNDEBUG -DNORCSID $(LINTOPTIONS) -CPP=$(UTIL_HOME)/lib.bin/cpp - -all: opt opt2 - -opt: $(OFILES) $(ONOGLOB) pattern.$(SUF) $(LIBS) - $(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(ONOGLOB) pattern.$(SUF) $(LIBS) -o opt - -opt2: $(OFILES) $(OGLOB) pattern.$(SUF) $(LIBS) - $(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(OGLOB) pattern.$(SUF) $(LIBS) -o opt2 - -test: opt testopt - testopt - -cmp: all - -cmp opt $(TARGET_HOMTARGET_HOME)/lib.bin/em_opt - -cmp opt2 $(TARGET_HOME)/lib.bin/em_opt2 - -install:all - cp opt $(TARGET_HOME)/lib.bin/em_opt - cp opt2 $(TARGET_HOME)/lib.bin/em_opt2 - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/em_opt.6 $(TARGET_HOME) ; \ - fi - -pattern.c: $(SRC_DIR)/patterns mktab - $(CPP) $(SRC_DIR)/patterns | mktab > pattern.c - -mktab: mktab.$(USUF) $(ULIBS) - $(UCC) $(ULDFLAGS) mktab.$(USUF) $(ULIBS) -o mktab - -mktab.$(USUF): scan.c $(SRC_DIR)/optim.h $(SRC_DIR)/param.h $(SRC_DIR)/pattern.h $(SRC_DIR)/types.h mktab.c - $(UCC) -c $(UCFLAGS) mktab.c - -mktab.c: $(SRC_DIR)/mktab.y - yacc $(SRC_DIR)/mktab.y && mv y.tab.c mktab.c - -pop_push.c: $(SRC_HOME)/etc/em_table $(SRC_DIR)/pop_push.awk - awk -f $(SRC_DIR)/pop_push.awk < $(SRC_HOME)/etc/em_table > pop_push.c - -regglob.c: $(SRC_DIR)/reg.c - echo '#define GLOBAL_OPT' > regglob.c - cat $(SRC_DIR)/reg.c >> regglob.c - -regnoglob.c: $(SRC_DIR)/reg.c - cp $(SRC_DIR)/reg.c regnoglob.c - -depend: pattern.c pop_push.c regglob.c regnoglob.c - rm_deps Makefile >Makefile.new - for i in $(CFILES) pattern.c regglob.c regnoglob.c ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -lint: $(CFILES) pattern.c - $(LINT) $(LINTFLAGS) $(CFILES) pattern.c $(UTIL_HOME)/lib.bin/$(LINTPREF)em_data.$(LINTSUF) - -opr: - make pr | opr - -pr: - @pr -n $(SRC_DIR)/proto.make $(SRC_DIR)/*.h $(CFILES) $(SRC_DIR)/mktab.y $(SRC_DIR)/scan.l $(SRC_DIR)/patterns - -clean: - rm -f *.$(SUF) opt mktab mktab.c scan.c pattern.c opt2 Out \ - pop_push.c regglob.c regnoglob.c *.old - -scan.c: $(SRC_DIR)/scan.l - flex -st $(SRC_DIR)/scan.l > scan.c - -# the next lines are generated automatically -#DEPENDENCIES -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -main.$(SUF): $(SRC_DIR)/ext.h -main.$(SUF): $(TARGET_HOME)/h/em_spec.h -main.$(SUF): $(SRC_DIR)/alloc.h -main.$(SUF): $(SRC_DIR)/tes.h -main.$(SUF): $(SRC_DIR)/types.h -main.$(SUF): $(SRC_DIR)/param.h -getline.$(SUF): $(SRC_DIR)/getline.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/getline.c -getline.$(SUF): $(SRC_DIR)/ext.h -getline.$(SUF): $(TARGET_HOME)/h/em_mes.h -getline.$(SUF): $(TARGET_HOME)/h/em_flag.h -getline.$(SUF): $(TARGET_HOME)/h/em_pseu.h -getline.$(SUF): $(TARGET_HOME)/h/em_spec.h -getline.$(SUF): $(SRC_DIR)/proinf.h -getline.$(SUF): $(SRC_DIR)/alloc.h -getline.$(SUF): $(SRC_DIR)/lookup.h -getline.$(SUF): $(SRC_DIR)/line.h -getline.$(SUF): $(SRC_DIR)/tes.h -getline.$(SUF): $(SRC_DIR)/types.h -getline.$(SUF): $(SRC_DIR)/param.h -lookup.$(SUF): $(SRC_DIR)/lookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lookup.c -lookup.$(SUF): $(SRC_DIR)/proinf.h -lookup.$(SUF): $(SRC_DIR)/alloc.h -lookup.$(SUF): $(SRC_DIR)/lookup.h -lookup.$(SUF): $(SRC_DIR)/tes.h -lookup.$(SUF): $(SRC_DIR)/types.h -lookup.$(SUF): $(SRC_DIR)/param.h -var.$(SUF): $(SRC_DIR)/var.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/var.c -var.$(SUF): $(SRC_DIR)/proinf.h -var.$(SUF): $(SRC_DIR)/lookup.h -var.$(SUF): $(SRC_DIR)/tes.h -var.$(SUF): $(SRC_DIR)/types.h -var.$(SUF): $(SRC_DIR)/param.h -process.$(SUF): $(SRC_DIR)/process.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/process.c -process.$(SUF): $(SRC_DIR)/ext.h -process.$(SUF): $(SRC_DIR)/proinf.h -process.$(SUF): $(SRC_DIR)/lookup.h -process.$(SUF): $(SRC_DIR)/line.h -process.$(SUF): $(SRC_DIR)/alloc.h -process.$(SUF): $(TARGET_HOME)/h/em_pseu.h -process.$(SUF): $(TARGET_HOME)/h/em_spec.h -process.$(SUF): $(SRC_DIR)/assert.h -process.$(SUF): $(SRC_DIR)/tes.h -process.$(SUF): $(SRC_DIR)/types.h -process.$(SUF): $(SRC_DIR)/param.h -backward.$(SUF): $(SRC_DIR)/backward.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/backward.c -backward.$(SUF): $(SRC_DIR)/ext.h -backward.$(SUF): $(TARGET_HOME)/h/em_mes.h -backward.$(SUF): $(TARGET_HOME)/h/em_mnem.h -backward.$(SUF): $(TARGET_HOME)/h/em_pseu.h -backward.$(SUF): $(TARGET_HOME)/h/em_spec.h -backward.$(SUF): $(SRC_DIR)/proinf.h -backward.$(SUF): $(SRC_DIR)/alloc.h -backward.$(SUF): $(SRC_DIR)/lookup.h -backward.$(SUF): $(SRC_DIR)/line.h -backward.$(SUF): $(SRC_DIR)/assert.h -backward.$(SUF): $(SRC_DIR)/tes.h -backward.$(SUF): $(SRC_DIR)/types.h -backward.$(SUF): $(SRC_DIR)/param.h -util.$(SUF): $(SRC_DIR)/util.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/util.c -util.$(SUF): $(SRC_DIR)/ext.h -util.$(SUF): $(SRC_DIR)/optim.h -util.$(SUF): $(SRC_DIR)/proinf.h -util.$(SUF): $(SRC_DIR)/lookup.h -util.$(SUF): $(SRC_DIR)/assert.h -util.$(SUF): $(SRC_DIR)/tes.h -util.$(SUF): $(SRC_DIR)/types.h -util.$(SUF): $(SRC_DIR)/param.h -alloc.$(SUF): $(SRC_DIR)/alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/alloc.c -alloc.$(SUF): $(SRC_DIR)/proinf.h -alloc.$(SUF): $(SRC_DIR)/lookup.h -alloc.$(SUF): $(SRC_DIR)/line.h -alloc.$(SUF): $(SRC_DIR)/alloc.h -alloc.$(SUF): $(SRC_DIR)/assert.h -alloc.$(SUF): $(SRC_DIR)/tes.h -alloc.$(SUF): $(SRC_DIR)/types.h -alloc.$(SUF): $(SRC_DIR)/param.h -putline.$(SUF): $(SRC_DIR)/putline.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/putline.c -putline.$(SUF): $(SRC_DIR)/ext.h -putline.$(SUF): $(SRC_DIR)/optim.h -putline.$(SUF): $(SRC_DIR)/proinf.h -putline.$(SUF): $(SRC_DIR)/lookup.h -putline.$(SUF): $(SRC_DIR)/line.h -putline.$(SUF): $(SRC_DIR)/alloc.h -putline.$(SUF): $(TARGET_HOME)/h/em_flag.h -putline.$(SUF): $(TARGET_HOME)/h/em_mnem.h -putline.$(SUF): $(TARGET_HOME)/h/em_pseu.h -putline.$(SUF): $(TARGET_HOME)/h/em_spec.h -putline.$(SUF): $(SRC_DIR)/assert.h -putline.$(SUF): $(SRC_DIR)/tes.h -putline.$(SUF): $(SRC_DIR)/types.h -putline.$(SUF): $(SRC_DIR)/param.h -cleanup.$(SUF): $(SRC_DIR)/cleanup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cleanup.c -cleanup.$(SUF): $(SRC_DIR)/ext.h -cleanup.$(SUF): $(SRC_DIR)/lookup.h -cleanup.$(SUF): $(TARGET_HOME)/h/em_mes.h -cleanup.$(SUF): $(TARGET_HOME)/h/em_spec.h -cleanup.$(SUF): $(TARGET_HOME)/h/em_pseu.h -cleanup.$(SUF): $(SRC_DIR)/assert.h -cleanup.$(SUF): $(SRC_DIR)/types.h -cleanup.$(SUF): $(SRC_DIR)/param.h -peephole.$(SUF): $(SRC_DIR)/peephole.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/peephole.c -peephole.$(SUF): $(SRC_DIR)/ext.h -peephole.$(SUF): $(SRC_DIR)/optim.h -peephole.$(SUF): $(TARGET_HOME)/h/em_mnem.h -peephole.$(SUF): $(TARGET_HOME)/h/em_spec.h -peephole.$(SUF): $(SRC_DIR)/pattern.h -peephole.$(SUF): $(SRC_DIR)/alloc.h -peephole.$(SUF): $(SRC_DIR)/proinf.h -peephole.$(SUF): $(SRC_DIR)/lookup.h -peephole.$(SUF): $(SRC_DIR)/line.h -peephole.$(SUF): $(SRC_DIR)/assert.h -peephole.$(SUF): $(SRC_DIR)/tes.h -peephole.$(SUF): $(SRC_DIR)/types.h -peephole.$(SUF): $(SRC_DIR)/param.h -flow.$(SUF): $(SRC_DIR)/flow.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flow.c -flow.$(SUF): $(SRC_DIR)/ext.h -flow.$(SUF): $(SRC_DIR)/optim.h -flow.$(SUF): $(SRC_DIR)/proinf.h -flow.$(SUF): $(SRC_DIR)/line.h -flow.$(SUF): $(SRC_DIR)/alloc.h -flow.$(SUF): $(TARGET_HOME)/h/em_mnem.h -flow.$(SUF): $(TARGET_HOME)/h/em_spec.h -flow.$(SUF): $(TARGET_HOME)/h/em_flag.h -flow.$(SUF): $(SRC_DIR)/tes.h -flow.$(SUF): $(SRC_DIR)/types.h -flow.$(SUF): $(SRC_DIR)/param.h -reg.$(SUF): $(SRC_DIR)/reg.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/reg.c -reg.$(SUF): $(SRC_DIR)/ext.h -reg.$(SUF): $(TARGET_HOME)/h/em_mes.h -reg.$(SUF): $(TARGET_HOME)/h/em_pseu.h -reg.$(SUF): $(TARGET_HOME)/h/em_spec.h -reg.$(SUF): $(SRC_DIR)/alloc.h -reg.$(SUF): $(SRC_DIR)/proinf.h -reg.$(SUF): $(SRC_DIR)/tes.h -reg.$(SUF): $(SRC_DIR)/line.h -reg.$(SUF): $(SRC_DIR)/types.h -reg.$(SUF): $(SRC_DIR)/param.h -reg.$(SUF): $(SRC_DIR)/assert.h -tes.$(SUF): $(SRC_DIR)/tes.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/tes.c -tes.$(SUF): $(SRC_DIR)/pop_push.h -tes.$(SUF): $(SRC_DIR)/ext.h -tes.$(SUF): $(SRC_DIR)/line.h -tes.$(SUF): $(SRC_DIR)/proinf.h -tes.$(SUF): $(SRC_DIR)/alloc.h -tes.$(SUF): $(SRC_DIR)/tes.h -tes.$(SUF): $(SRC_DIR)/types.h -tes.$(SUF): $(SRC_DIR)/assert.h -tes.$(SUF): $(SRC_DIR)/param.h -tes.$(SUF): $(TARGET_HOME)/h/em_pseu.h -tes.$(SUF): $(TARGET_HOME)/h/em_mnem.h -tes.$(SUF): $(TARGET_HOME)/h/em_spec.h -pop_push.$(SUF): pop_push.c - $(CC) -c $(CFLAGS) pop_push.c -pop_push.$(SUF): $(SRC_DIR)/pop_push.h -pattern.$(SUF): pattern.c - $(CC) -c $(CFLAGS) pattern.c -pattern.$(SUF): $(SRC_DIR)/pattern.h -pattern.$(SUF): $(SRC_DIR)/types.h -pattern.$(SUF): $(SRC_DIR)/param.h -regglob.$(SUF): regglob.c - $(CC) -c $(CFLAGS) regglob.c -regglob.$(SUF): $(SRC_DIR)/ext.h -regglob.$(SUF): $(TARGET_HOME)/h/em_mes.h -regglob.$(SUF): $(TARGET_HOME)/h/em_pseu.h -regglob.$(SUF): $(TARGET_HOME)/h/em_spec.h -regglob.$(SUF): $(SRC_DIR)/alloc.h -regglob.$(SUF): $(SRC_DIR)/proinf.h -regglob.$(SUF): $(SRC_DIR)/tes.h -regglob.$(SUF): $(SRC_DIR)/line.h -regglob.$(SUF): $(SRC_DIR)/types.h -regglob.$(SUF): $(SRC_DIR)/param.h -regglob.$(SUF): $(SRC_DIR)/assert.h -regnoglob.$(SUF): regnoglob.c - $(CC) -c $(CFLAGS) regnoglob.c -regnoglob.$(SUF): $(SRC_DIR)/ext.h -regnoglob.$(SUF): $(TARGET_HOME)/h/em_mes.h -regnoglob.$(SUF): $(TARGET_HOME)/h/em_pseu.h -regnoglob.$(SUF): $(TARGET_HOME)/h/em_spec.h -regnoglob.$(SUF): $(SRC_DIR)/alloc.h -regnoglob.$(SUF): $(SRC_DIR)/proinf.h -regnoglob.$(SUF): $(SRC_DIR)/tes.h -regnoglob.$(SUF): $(SRC_DIR)/line.h -regnoglob.$(SUF): $(SRC_DIR)/types.h -regnoglob.$(SUF): $(SRC_DIR)/param.h -regnoglob.$(SUF): $(SRC_DIR)/assert.h diff --git a/util/topgen/build.mk b/util/topgen/build.mk deleted file mode 100644 index 9bf48a4d3..000000000 --- a/util/topgen/build.mk +++ /dev/null @@ -1,50 +0,0 @@ -D := util/topgen - -# Rule to build topgen. - -define build-topgen-impl - $(call reset) - $(eval cflags += -I$(OBJDIR)/$D -I$D) - - $(call cfile, $D/LLlex.c) - $(call cfile, $D/hash.c) - $(call cfile, $D/main.c) - $(call cfile, $D/pattern.c) - $(call cfile, $D/symtab.c) - $(eval $q: $(OBJDIR)/$D/Lpars.h) - - $(call llgen, $(OBJDIR)/$D, $D/topgen.g) - - $(call rawfile, $(LIBASSERT)) - $(call rawfile, $(LIBPRINT)) - $(call rawfile, $(LIBALLOC)) - $(call rawfile, $(LIBSYSTEM)) - $(call rawfile, $(LIBSTRING)) - - $(call cprogram, $(BINDIR)/topgen) - TOPGEN := $o -endef - -$(eval $(build-topgen-impl)) - -# Rule to invoke to *use* LLgen. -# -# $1: directory to put output files -# $2: input files -# -# Output files are *not* compiled (gen.c is expected to be included by -# something). - -define topgen-impl -$(eval CLEANABLES += $1/gen.h $1/gen.c) - -$1/gen.h: $1/gen.c -$1/gen.c: $2 $(TOPGEN) - @echo TOPGEN $$@ - @mkdir -p $$(dir $$@) - $(hide) $(RM) $1/gen.h $1/gen.c - $(hide) cd $$(dir $$@) && $(abspath $(TOPGEN)) $(abspath $2) - -endef - -topgen = $(eval $(call topgen-impl,$1,$2)) diff --git a/util/topgen/proto.make b/util/topgen/proto.make deleted file mode 100644 index c06b5e90f..000000000 --- a/util/topgen/proto.make +++ /dev/null @@ -1,60 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/topgen -INCLUDES = -I$(SRC_DIR) -I. -CFLAGS = $(COPTIONS) $(INCLUDES) -LDFLAGS = $(LDOPTIONS) -LINTFLAGS = $(LINTOPTIONS) $(INCLUDES) -SOURCE = $(SRC_DIR)/token.h $(SRC_DIR)/symtab.h $(SRC_DIR)/misc.h \ - $(SRC_DIR)/tunable.h $(SRC_DIR)/main.c $(SRC_DIR)/topgen.g \ - $(SRC_DIR)/LLlex.c $(SRC_DIR)/symtab.c $(SRC_DIR)/pattern.c \ - $(SRC_DIR)/hash.c -CFILES = $(SRC_DIR)/main.c topgen.c Lpars.c $(SRC_DIR)/LLlex.c \ - $(SRC_DIR)/symtab.c $(SRC_DIR)/pattern.c $(SRC_DIR)/hash.c -OFILES = main.$(SUF) topgen.$(SUF) Lpars.$(SUF) LLlex.$(SUF) \ - symtab.$(SUF) pattern.$(SUF) hash.$(SUF) - -all: parser - @make topgen - -cmp: all - cmp topgen $(TARGET_HOME)/lib.bin/topgen - -install: all - cp topgen $(TARGET_HOME)/lib.bin/topgen - -clean: - rm -f topgen *.$(SUF) Lpars.c Lpars.h topgen.c parser - -parser: $(SRC_DIR)/topgen.g - $(UTIL_HOME)/bin/LLgen $(SRC_DIR)/topgen.g - touch parser - -topgen.$(SUF): $(SRC_DIR)/token.h Lpars.h $(SRC_DIR)/symtab.h $(SRC_DIR)/misc.h topgen.c - $(CC) -c $(CFLAGS) topgen.c -Lpars.$(SUF): Lpars.h Lpars.c - $(CC) -c $(CFLAGS) Lpars.c -LLlex.$(SUF): $(SRC_DIR)/token.h Lpars.h $(SRC_DIR)/tunable.h $(SRC_DIR)/LLlex.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/LLlex.c -symtab.$(SUF): $(SRC_DIR)/symtab.h $(SRC_DIR)/symtab.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/symtab.c -hash.$(SUF): $(SRC_DIR)/misc.h $(SRC_DIR)/hash.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/hash.c -pattern.$(SUF): $(SRC_DIR)/misc.h $(SRC_DIR)/symtab.h $(SRC_DIR)/pattern.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/pattern.c -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c - -topgen: $(OFILES) - $(CC) $(LDFLAGS) $(OFILES) -o topgen - -lint: parser - $(LINT) $(LINTFLAGS) $(CFILES) - -pr: - @pr $(SOURCE) $(SRC_DIR)/proto.make - -opr: - make pr ^ opr From f67c98e2397481dc2a7ce4cc290de00bce7e7b61 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 2 Sep 2016 23:00:38 +0200 Subject: [PATCH 223/231] Distributions are a pain --- let's not bother any more. Instead, we just tag the repository and download a complete snapshot, old and ancient stuff and all. --- README | 29 ++-- bin/.distr | 9 -- distr/Exceptions | 15 --- distr/How_To | 90 ------------- distr/dwalk | 26 ---- distr/echod | 1 - distr/listall | 10 -- distr/listall.d | 2 - distr/listdirs | 10 -- distr/mk_distr_syms | 40 ------ distr/mka | 11 -- distr/mkd | 0 distr/mkdist | 175 ------------------------- distr/mkf | 19 --- distr/mktree | 42 ------ distr/todistr | 26 ---- distr/ts | 2 - doc/.distr | 32 ----- doc/LLgen/.distr | 4 - doc/ceg/.distr | 3 - doc/ego/.distr | 18 --- doc/ego/bo/.distr | 1 - doc/ego/ca/.distr | 1 - doc/ego/cf/.distr | 6 - doc/ego/cj/.distr | 1 - doc/ego/cs/.distr | 5 - doc/ego/ic/.distr | 5 - doc/ego/il/.distr | 6 - doc/ego/intro/.distr | 3 - doc/ego/lv/.distr | 1 - doc/ego/ov/.distr | 1 - doc/ego/ra/.distr | 4 - doc/ego/sp/.distr | 1 - doc/ego/sr/.distr | 4 - doc/ego/ud/.distr | 5 - doc/em/.distr | 28 ---- doc/em/int/.distr | 5 - doc/lint/.distr | 15 --- doc/occam/.distr | 12 -- doc/pascal/.distr | 20 --- doc/sparc/.distr | 15 --- doc/sparc/pics/.distr | 12 -- doc/top/.distr | 3 - emtest/.distr | 6 - etc/.distr | 7 - examples/.distr | 10 -- fast/.distr | 6 - fast/driver/.distr | 5 - fast/f_c.ansi/.distr | 3 - fast/f_c/.distr | 3 - fast/f_m2/.distr | 3 - fast/f_pc/.distr | 3 - fcc/.distr | 3 - fcc/cemcom/.distr | 4 - fcc/driver/.distr | 3 - first/.distr | 19 --- h/.distr | 29 ---- include/.distr | 3 - include/_tail_mon/.distr | 4 - include/_tail_mon/sys/.distr | 2 - lang/.distr | 6 - lang/a68s/.distr | 8 -- lang/a68s/aem/.distr | 26 ---- lang/a68s/cpem/.distr | 3 - lang/a68s/liba68s/.distr | 127 ------------------ lang/a68s/util/.distr | 7 - lang/basic/.distr | 3 - lang/basic/lib/.distr | 34 ----- lang/basic/src/.distr | 19 --- lang/basic/test/.distr | 100 -------------- lang/basic/test/tst/.distr | 2 - lang/cem/.distr | 6 - lang/cem/cemcom.ansi/.distr | 99 -------------- lang/cem/cemcom/.distr | 97 -------------- lang/cem/cpp.ansi/.distr | 34 ----- lang/cem/ctest/.distr | 24 ---- lang/cem/ctest/ctconv/.distr | 3 - lang/cem/ctest/ctdecl/.distr | 3 - lang/cem/ctest/ctdivers/.distr | 3 - lang/cem/ctest/cterr/.distr | 3 - lang/cem/ctest/ctest1/.distr | 3 - lang/cem/ctest/ctest2/.distr | 3 - lang/cem/ctest/ctest3/.distr | 3 - lang/cem/ctest/ctest5/.distr | 3 - lang/cem/ctest/ctgen/.distr | 37 ------ lang/cem/ctest/ctill/.distr | 3 - lang/cem/ctest/ctinit/.distr | 3 - lang/cem/ctest/ctmargt/.distr | 3 - lang/cem/ctest/ctprof/.distr | 5 - lang/cem/ctest/ctsetjmp/.distr | 3 - lang/cem/ctest/ctstruct/.distr | 3 - lang/cem/ctest/ctsys/.distr | 4 - lang/cem/libcc.ansi/.distr | 15 --- lang/cem/libcc.ansi/assert/.distr | 1 - lang/cem/libcc.ansi/ctype/.distr | 4 - lang/cem/libcc.ansi/errno/.distr | 1 - lang/cem/libcc.ansi/headers/.distr | 23 ---- lang/cem/libcc.ansi/headers/sys/.distr | 2 - lang/cem/libcc.ansi/locale/.distr | 2 - lang/cem/libcc.ansi/math/.distr | 22 ---- lang/cem/libcc.ansi/misc/.distr | 1 - lang/cem/libcc.ansi/setjmp/.distr | 1 - lang/cem/libcc.ansi/signal/.distr | 1 - lang/cem/libcc.ansi/stdio/.distr | 51 ------- lang/cem/libcc.ansi/stdlib/.distr | 26 ---- lang/cem/libcc.ansi/string/.distr | 23 ---- lang/cem/libcc.ansi/time/.distr | 12 -- lang/cem/libcc/.distr | 6 - lang/cem/libcc/gen/.distr | 75 ----------- lang/cem/libcc/headers/.distr | 19 --- lang/cem/libcc/math/.distr | 21 --- lang/cem/libcc/mon/.distr | 92 ------------- lang/cem/libcc/stdio/.distr | 48 ------- lang/cem/lint/.distr | 6 - lang/cem/lint/llib/.distr | 9 -- lang/cem/lint/lpass1.ansi/.distr | 3 - lang/cem/lint/lpass1/.distr | 3 - lang/cem/lint/lpass2/.distr | 13 -- lang/fortran/.distr | 7 - lang/fortran/comp/.distr | 61 --------- lang/fortran/lib/.distr | 3 - lang/fortran/lib/libF77/.distr | 118 ----------------- lang/fortran/lib/libI77/.distr | 42 ------ lang/m2/.distr | 3 - lang/m2/comp/.distr | 61 --------- lang/m2/libm2/.distr | 74 ----------- lang/m2/m2mm/.distr | 30 ----- lang/m2/test/.distr | 5 - lang/m2/test/Thalmann/.distr | 5 - lang/m2/test/Wirth/.distr | 4 - lang/occam/.distr | 5 - lang/occam/comp/.distr | 16 --- lang/occam/headers/.distr | 3 - lang/occam/lib/.distr | 11 -- lang/occam/test/.distr | 11 -- lang/pc/.distr | 3 - lang/pc/comp/.distr | 58 -------- lang/pc/libpc/.distr | 75 ----------- lang/pc/test/.distr | 12 -- lib/.distr | 31 ----- lib/6500/.distr | 1 - lib/6800/.distr | 1 - lib/6805/.distr | 1 - lib/6809/.distr | 1 - lib/arm/.distr | 1 - lib/descr/.distr | 2 - lib/em22/.distr | 1 - lib/em24/.distr | 1 - lib/em44/.distr | 1 - lib/i386/.distr | 1 - lib/i80/.distr | 1 - lib/i86/.distr | 1 - lib/m68020/.distr | 1 - lib/m68k2/.distr | 1 - lib/m68k4/.distr | 1 - lib/mantra/.distr | 1 - lib/minix/.distr | 2 - lib/minix/include/.distr | 13 -- lib/minix/include/minix/.distr | 5 - lib/minix/include/sys/.distr | 5 - lib/minixST/.distr | 2 - lib/minixST/include/.distr | 2 - lib/minixST/include/minix/.distr | 1 - lib/ns/.distr | 1 - lib/pdp/.distr | 1 - lib/pmds/.distr | 1 - lib/pmds4/.distr | 1 - lib/s2650/.distr | 1 - lib/sparc/.distr | 1 - lib/sparc_solaris/.distr | 1 - lib/sun2/.distr | 1 - lib/sun3/.distr | 1 - lib/vax4/.distr | 1 - lib/xenix3/.distr | 1 - lib/z80/.distr | 1 - lib/z8000/.distr | 1 - mach/.distr | 33 ----- mach/6500/.distr | 8 -- mach/6500/as/.distr | 7 - mach/6500/cg/.distr | 3 - mach/6500/dl/.distr | 2 - mach/6500/libem/.distr | 2 - mach/6500/libend/.distr | 2 - mach/6500/libmon/.distr | 3 - mach/6800/.distr | 2 - mach/6800/as/.distr | 6 - mach/6805/.distr | 2 - mach/6805/as/.distr | 6 - mach/6809/.distr | 2 - mach/6809/as/.distr | 6 - mach/arm/.distr | 11 -- mach/arm/as/.distr | 6 - mach/arm/cv/.distr | 3 - mach/arm/libem/.distr | 2 - mach/arm/libend/.distr | 2 - mach/arm/libfp/.distr | 1 - mach/arm/libmon/.distr | 3 - mach/arm/ncg/.distr | 3 - mach/arm/top/.distr | 1 - mach/em22/.distr | 3 - mach/em22/libend/.distr | 2 - mach/em24/.distr | 3 - mach/em24/libend/.distr | 2 - mach/em44/.distr | 3 - mach/em44/libend/.distr | 2 - mach/i386/.distr | 5 - mach/i386/as/.distr | 6 - mach/i386/ce/.distr | 7 - mach/i386/cv/.distr | 2 - mach/i386/libdb/.distr | 1 - mach/i386/libem/.distr | 44 ------- mach/i386/libend/.distr | 4 - mach/i386/libfp/.distr | 1 - mach/i386/libsys/.distr | 3 - mach/i386/ncg/.distr | 3 - mach/i80/.distr | 6 - mach/i80/as/.distr | 6 - mach/i80/dl/.distr | 4 - mach/i80/libem/.distr | 37 ------ mach/i80/libend/.distr | 4 - mach/i80/libmon/.distr | 5 - mach/i80/ncg/.distr | 3 - mach/i80/top/.distr | 1 - mach/i86/.distr | 5 - mach/i86/as/.distr | 6 - mach/i86/ce/.distr | 7 - mach/i86/cv/.distr | 2 - mach/i86/libem/.distr | 59 --------- mach/i86/libend/.distr | 4 - mach/i86/libfp/.distr | 1 - mach/i86/libsys/.distr | 3 - mach/i86/ncg/.distr | 3 - mach/m68020/.distr | 5 - mach/m68020/as/.distr | 7 - mach/m68020/ce/.distr | 7 - mach/m68020/cv/.distr | 2 - mach/m68020/libdb/.distr | 1 - mach/m68020/libem/.distr | 25 ---- mach/m68020/libend/.distr | 4 - mach/m68020/libfp/.distr | 1 - mach/m68020/libsys/.distr | 4 - mach/m68020/ncg/.distr | 6 - mach/m68020/top/.distr | 1 - mach/m68k2/.distr | 13 -- mach/m68k2/as/.distr | 6 - mach/m68k2/cv/.distr | 2 - mach/m68k2/dl/.distr | 2 - mach/m68k2/libem/.distr | 3 - mach/m68k2/libend/.distr | 2 - mach/m68k2/libfp/.distr | 1 - mach/m68k2/libsys/.distr | 3 - mach/m68k2/ncg/.distr | 2 - mach/m68k2/top/.distr | 1 - mach/m68k4/.distr | 7 - mach/m68k4/libem/.distr | 2 - mach/m68k4/libend/.distr | 2 - mach/m68k4/libfp/.distr | 1 - mach/m68k4/libsys/.distr | 3 - mach/m68k4/ncg/.distr | 2 - mach/mantra/.distr | 5 - mach/mantra/cv/.distr | 3 - mach/mantra/int/.distr | 19 --- mach/mantra/libsys/.distr | 3 - mach/minix/.distr | 3 - mach/minix/libsys/.distr | 3 - mach/minixST/.distr | 4 - mach/minixST/cv/.distr | 2 - mach/minixST/libsys/.distr | 3 - mach/moon3/ncg/.distr | 2 - mach/ns/.distr | 7 - mach/ns/as/.distr | 6 - mach/ns/libem/.distr | 2 - mach/ns/libend/.distr | 2 - mach/ns/libmon/.distr | 3 - mach/ns/ncg/.distr | 3 - mach/pdp/.distr | 10 -- mach/pdp/as/.distr | 6 - mach/pdp/cg/.distr | 3 - mach/pdp/cv/.distr | 2 - mach/pdp/int/.distr | 15 --- mach/pdp/libem/.distr | 2 - mach/pdp/libend/.distr | 2 - mach/pdp/libsys/.distr | 4 - mach/pdp/ncg/.distr | 3 - mach/pdp/top/.distr | 1 - mach/pmds/.distr | 4 - mach/pmds/cv/.distr | 2 - mach/pmds/libsys/.distr | 3 - mach/pmds4/.distr | 3 - mach/pmds4/libsys/.distr | 3 - mach/powerpc/as/.distr | 6 - mach/powerpc/libem/.distr | 2 - mach/powerpc/libend/.distr | 5 - mach/powerpc/ncg/.distr | 3 - mach/powerpc/top/.distr | 1 - mach/proto/.distr | 4 - mach/proto/as/.distr | 10 -- mach/proto/cg/.distr | 25 ---- mach/proto/fp/.distr | 44 ------- mach/proto/grind/.distr | 4 - mach/proto/libg/.distr | 17 --- mach/proto/ncg/.distr | 28 ---- mach/proto/top/.distr | 5 - mach/s2650/.distr | 2 - mach/s2650/as/.distr | 6 - mach/sparc/.distr | 9 -- mach/sparc/ce/.distr | 15 --- mach/sparc/ce/back.src/.distr | 9 -- mach/sparc/ce/ce.src/.distr | 14 -- mach/sparc/ce_cg/.distr | 2 - mach/sparc/libdb/.distr | 1 - mach/sparc/libem/.distr | 2 - mach/sparc/libend/.distr | 2 - mach/sparc/libsys/.distr | 5 - mach/sparc/top/.distr | 1 - mach/sparc_solaris/.distr | 8 -- mach/sparc_solaris/ce/.distr | 1 - mach/sparc_solaris/ce_cg/.distr | 1 - mach/sparc_solaris/libdb/.distr | 1 - mach/sparc_solaris/libem/.distr | 4 - mach/sparc_solaris/libend/.distr | 2 - mach/sparc_solaris/libsys/.distr | 4 - mach/sun2/.distr | 4 - mach/sun2/cv/.distr | 1 - mach/sun2/libsys/.distr | 4 - mach/sun3/.distr | 6 - mach/sun3/ce/.distr | 14 -- mach/sun3/cv/.distr | 3 - mach/sun3/liba68s/.distr | 2 - mach/sun3/libce/.distr | 23 ---- mach/sun3/libsys/.distr | 4 - mach/vax4/.distr | 14 -- mach/vax4/as/.distr | 6 - mach/vax4/ce/.distr | 13 -- mach/vax4/cg/.distr | 3 - mach/vax4/cv/.distr | 2 - mach/vax4/libbsd4_1a/.distr | 3 - mach/vax4/libbsd4_2/.distr | 4 - mach/vax4/libce/.distr | 2 - mach/vax4/libdb/.distr | 1 - mach/vax4/libem/.distr | 2 - mach/vax4/libend/.distr | 2 - mach/vax4/libsysV_2/.distr | 3 - mach/vax4/top/.distr | 1 - mach/vc4/.distr | 5 - mach/vc4/as/.distr | 7 - mach/vc4/libem/.distr | 3 - mach/vc4/libend/.distr | 4 - mach/vc4/ncg/.distr | 3 - mach/xenix3/.distr | 4 - mach/xenix3/cv/.distr | 3 - mach/xenix3/libsys/.distr | 3 - mach/z80/.distr | 8 -- mach/z80/as/.distr | 6 - mach/z80/cg/.distr | 3 - mach/z80/int/.distr | 13 -- mach/z80/libem/.distr | 2 - mach/z80/libend/.distr | 2 - mach/z80/libmon/.distr | 8 -- mach/z80/libsys/.distr | 8 -- mach/z80/top/.distr | 1 - mach/z8000/.distr | 7 - mach/z8000/as/.distr | 7 - mach/z8000/cg/.distr | 3 - mach/z8000/libem/.distr | 2 - mach/z8000/libend/.distr | 2 - mach/z8000/libmon/.distr | 3 - man/.distr | 13 -- modules/.distr | 2 - modules/h/.distr | 10 -- modules/src/.distr | 16 --- modules/src/Xmalloc/.distr | 2 - modules/src/alloc/.distr | 12 -- modules/src/assert/.distr | 3 - modules/src/em_code/.distr | 58 -------- modules/src/em_data/.distr | 3 - modules/src/em_mes/.distr | 14 -- modules/src/em_opt/.distr | 19 --- modules/src/flt_arith/.distr | 20 --- modules/src/idf/.distr | 4 - modules/src/input/.distr | 6 - modules/src/malloc/.distr | 15 --- modules/src/object/.distr | 18 --- modules/src/print/.distr | 9 -- modules/src/read_em/.distr | 11 -- modules/src/string/.distr | 21 --- modules/src/system/.distr | 21 --- plat/.distr | 2 - plat/cpm/.distr | 24 ---- plat/linux/.distr | 2 - plat/linux/libsys/.distr | 20 --- plat/linux386/.distr | 8 -- plat/linux68k/.distr | 8 -- plat/linuxppc/.distr | 26 ---- plat/pc86/.distr | 23 ---- plat/rpi/.distr | 32 ----- util/.distr | 20 --- util/LLgen/.distr | 26 ---- util/ack/.distr | 20 --- util/amisc/.distr | 13 -- util/arch/.distr | 5 - util/ass/.distr | 17 --- util/byacc/.distr | 19 --- util/ceg/.distr | 7 - util/ceg/EM_parser/.distr | 3 - util/ceg/EM_parser/as_EM_pars/.distr | 6 - util/ceg/EM_parser/common/.distr | 12 -- util/ceg/EM_parser/obj_EM_pars/.distr | 4 - util/ceg/as_parser/.distr | 9 -- util/ceg/as_parser/eval/.distr | 3 - util/ceg/assemble/.distr | 3 - util/ceg/assemble/as_assemble/.distr | 3 - util/ceg/assemble/obj_assemble/.distr | 4 - util/ceg/ce_back/.distr | 3 - util/ceg/ce_back/as_back/.distr | 30 ----- util/ceg/ce_back/obj_back/.distr | 36 ----- util/ceg/defaults/.distr | 13 -- util/ceg/defaults/message/.distr | 11 -- util/ceg/defaults/not_impl/.distr | 2 - util/ceg/defaults/pseudo/.distr | 19 --- util/ceg/defaults/storage/.distr | 22 ---- util/ceg/util/.distr | 8 -- util/cgg/.distr | 4 - util/cmisc/.distr | 12 -- util/cpp/.distr | 34 ----- util/ego/.distr | 16 --- util/ego/bo/.distr | 1 - util/ego/ca/.distr | 4 - util/ego/cf/.distr | 8 -- util/ego/cj/.distr | 1 - util/ego/cs/.distr | 26 ---- util/ego/descr/.distr | 12 -- util/ego/em_ego/.distr | 1 - util/ego/ic/.distr | 10 -- util/ego/il/.distr | 20 --- util/ego/lv/.distr | 2 - util/ego/ra/.distr | 20 --- util/ego/share/.distr | 36 ----- util/ego/sp/.distr | 1 - util/ego/sr/.distr | 14 -- util/ego/ud/.distr | 10 -- util/flex/.distr | 24 ---- util/grind/.distr | 54 -------- util/int/.distr | 70 ---------- util/int/switch/.distr | 4 - util/int/test/.distr | 9 -- util/led/.distr | 25 ---- util/make/.distr | 10 -- util/misc/.distr | 5 - util/ncgg/.distr | 35 ----- util/opt/.distr | 34 ----- util/shf/.distr | 2 - util/topgen/.distr | 11 -- 453 files changed, 19 insertions(+), 5003 deletions(-) delete mode 100644 bin/.distr delete mode 100644 distr/Exceptions delete mode 100644 distr/How_To delete mode 100755 distr/dwalk delete mode 100755 distr/echod delete mode 100755 distr/listall delete mode 100755 distr/listall.d delete mode 100755 distr/listdirs delete mode 100755 distr/mk_distr_syms delete mode 100755 distr/mka delete mode 100755 distr/mkd delete mode 100755 distr/mkdist delete mode 100755 distr/mkf delete mode 100644 distr/mktree delete mode 100644 distr/todistr delete mode 100755 distr/ts delete mode 100644 doc/.distr delete mode 100644 doc/LLgen/.distr delete mode 100644 doc/ceg/.distr delete mode 100644 doc/ego/.distr delete mode 100644 doc/ego/bo/.distr delete mode 100644 doc/ego/ca/.distr delete mode 100644 doc/ego/cf/.distr delete mode 100644 doc/ego/cj/.distr delete mode 100644 doc/ego/cs/.distr delete mode 100644 doc/ego/ic/.distr delete mode 100644 doc/ego/il/.distr delete mode 100644 doc/ego/intro/.distr delete mode 100644 doc/ego/lv/.distr delete mode 100644 doc/ego/ov/.distr delete mode 100644 doc/ego/ra/.distr delete mode 100644 doc/ego/sp/.distr delete mode 100644 doc/ego/sr/.distr delete mode 100644 doc/ego/ud/.distr delete mode 100644 doc/em/.distr delete mode 100644 doc/em/int/.distr delete mode 100644 doc/lint/.distr delete mode 100644 doc/occam/.distr delete mode 100644 doc/pascal/.distr delete mode 100644 doc/sparc/.distr delete mode 100644 doc/sparc/pics/.distr delete mode 100644 doc/top/.distr delete mode 100644 emtest/.distr delete mode 100644 etc/.distr delete mode 100644 examples/.distr delete mode 100644 fast/.distr delete mode 100644 fast/driver/.distr delete mode 100644 fast/f_c.ansi/.distr delete mode 100644 fast/f_c/.distr delete mode 100644 fast/f_m2/.distr delete mode 100644 fast/f_pc/.distr delete mode 100644 fcc/.distr delete mode 100644 fcc/cemcom/.distr delete mode 100644 fcc/driver/.distr delete mode 100644 first/.distr delete mode 100644 h/.distr delete mode 100644 include/.distr delete mode 100644 include/_tail_mon/.distr delete mode 100644 include/_tail_mon/sys/.distr delete mode 100644 lang/.distr delete mode 100644 lang/a68s/.distr delete mode 100644 lang/a68s/aem/.distr delete mode 100644 lang/a68s/cpem/.distr delete mode 100644 lang/a68s/liba68s/.distr delete mode 100644 lang/a68s/util/.distr delete mode 100644 lang/basic/.distr delete mode 100644 lang/basic/lib/.distr delete mode 100644 lang/basic/src/.distr delete mode 100644 lang/basic/test/.distr delete mode 100644 lang/basic/test/tst/.distr delete mode 100644 lang/cem/.distr delete mode 100644 lang/cem/cemcom.ansi/.distr delete mode 100644 lang/cem/cemcom/.distr delete mode 100644 lang/cem/cpp.ansi/.distr delete mode 100644 lang/cem/ctest/.distr delete mode 100644 lang/cem/ctest/ctconv/.distr delete mode 100644 lang/cem/ctest/ctdecl/.distr delete mode 100644 lang/cem/ctest/ctdivers/.distr delete mode 100644 lang/cem/ctest/cterr/.distr delete mode 100644 lang/cem/ctest/ctest1/.distr delete mode 100644 lang/cem/ctest/ctest2/.distr delete mode 100644 lang/cem/ctest/ctest3/.distr delete mode 100644 lang/cem/ctest/ctest5/.distr delete mode 100644 lang/cem/ctest/ctgen/.distr delete mode 100644 lang/cem/ctest/ctill/.distr delete mode 100644 lang/cem/ctest/ctinit/.distr delete mode 100644 lang/cem/ctest/ctmargt/.distr delete mode 100644 lang/cem/ctest/ctprof/.distr delete mode 100644 lang/cem/ctest/ctsetjmp/.distr delete mode 100644 lang/cem/ctest/ctstruct/.distr delete mode 100644 lang/cem/ctest/ctsys/.distr delete mode 100644 lang/cem/libcc.ansi/.distr delete mode 100644 lang/cem/libcc.ansi/assert/.distr delete mode 100644 lang/cem/libcc.ansi/ctype/.distr delete mode 100644 lang/cem/libcc.ansi/errno/.distr delete mode 100644 lang/cem/libcc.ansi/headers/.distr delete mode 100644 lang/cem/libcc.ansi/headers/sys/.distr delete mode 100644 lang/cem/libcc.ansi/locale/.distr delete mode 100644 lang/cem/libcc.ansi/math/.distr delete mode 100644 lang/cem/libcc.ansi/misc/.distr delete mode 100644 lang/cem/libcc.ansi/setjmp/.distr delete mode 100644 lang/cem/libcc.ansi/signal/.distr delete mode 100644 lang/cem/libcc.ansi/stdio/.distr delete mode 100644 lang/cem/libcc.ansi/stdlib/.distr delete mode 100644 lang/cem/libcc.ansi/string/.distr delete mode 100644 lang/cem/libcc.ansi/time/.distr delete mode 100644 lang/cem/libcc/.distr delete mode 100644 lang/cem/libcc/gen/.distr delete mode 100644 lang/cem/libcc/headers/.distr delete mode 100644 lang/cem/libcc/math/.distr delete mode 100644 lang/cem/libcc/mon/.distr delete mode 100644 lang/cem/libcc/stdio/.distr delete mode 100644 lang/cem/lint/.distr delete mode 100644 lang/cem/lint/llib/.distr delete mode 100644 lang/cem/lint/lpass1.ansi/.distr delete mode 100644 lang/cem/lint/lpass1/.distr delete mode 100644 lang/cem/lint/lpass2/.distr delete mode 100644 lang/fortran/.distr delete mode 100644 lang/fortran/comp/.distr delete mode 100644 lang/fortran/lib/.distr delete mode 100644 lang/fortran/lib/libF77/.distr delete mode 100644 lang/fortran/lib/libI77/.distr delete mode 100644 lang/m2/.distr delete mode 100644 lang/m2/comp/.distr delete mode 100644 lang/m2/libm2/.distr delete mode 100644 lang/m2/m2mm/.distr delete mode 100644 lang/m2/test/.distr delete mode 100644 lang/m2/test/Thalmann/.distr delete mode 100644 lang/m2/test/Wirth/.distr delete mode 100644 lang/occam/.distr delete mode 100644 lang/occam/comp/.distr delete mode 100644 lang/occam/headers/.distr delete mode 100644 lang/occam/lib/.distr delete mode 100644 lang/occam/test/.distr delete mode 100644 lang/pc/.distr delete mode 100644 lang/pc/comp/.distr delete mode 100644 lang/pc/libpc/.distr delete mode 100644 lang/pc/test/.distr delete mode 100644 lib/.distr delete mode 100644 lib/6500/.distr delete mode 100644 lib/6800/.distr delete mode 100644 lib/6805/.distr delete mode 100644 lib/6809/.distr delete mode 100644 lib/arm/.distr delete mode 100644 lib/descr/.distr delete mode 100644 lib/em22/.distr delete mode 100644 lib/em24/.distr delete mode 100644 lib/em44/.distr delete mode 100644 lib/i386/.distr delete mode 100644 lib/i80/.distr delete mode 100644 lib/i86/.distr delete mode 100644 lib/m68020/.distr delete mode 100644 lib/m68k2/.distr delete mode 100644 lib/m68k4/.distr delete mode 100644 lib/mantra/.distr delete mode 100644 lib/minix/.distr delete mode 100644 lib/minix/include/.distr delete mode 100644 lib/minix/include/minix/.distr delete mode 100644 lib/minix/include/sys/.distr delete mode 100644 lib/minixST/.distr delete mode 100644 lib/minixST/include/.distr delete mode 100644 lib/minixST/include/minix/.distr delete mode 100644 lib/ns/.distr delete mode 100644 lib/pdp/.distr delete mode 100644 lib/pmds/.distr delete mode 100644 lib/pmds4/.distr delete mode 100644 lib/s2650/.distr delete mode 100644 lib/sparc/.distr delete mode 100644 lib/sparc_solaris/.distr delete mode 100644 lib/sun2/.distr delete mode 100644 lib/sun3/.distr delete mode 100644 lib/vax4/.distr delete mode 100644 lib/xenix3/.distr delete mode 100644 lib/z80/.distr delete mode 100644 lib/z8000/.distr delete mode 100644 mach/.distr delete mode 100644 mach/6500/.distr delete mode 100644 mach/6500/as/.distr delete mode 100644 mach/6500/cg/.distr delete mode 100644 mach/6500/dl/.distr delete mode 100644 mach/6500/libem/.distr delete mode 100644 mach/6500/libend/.distr delete mode 100644 mach/6500/libmon/.distr delete mode 100644 mach/6800/.distr delete mode 100644 mach/6800/as/.distr delete mode 100644 mach/6805/.distr delete mode 100644 mach/6805/as/.distr delete mode 100644 mach/6809/.distr delete mode 100644 mach/6809/as/.distr delete mode 100644 mach/arm/.distr delete mode 100644 mach/arm/as/.distr delete mode 100644 mach/arm/cv/.distr delete mode 100644 mach/arm/libem/.distr delete mode 100644 mach/arm/libend/.distr delete mode 100644 mach/arm/libfp/.distr delete mode 100644 mach/arm/libmon/.distr delete mode 100644 mach/arm/ncg/.distr delete mode 100644 mach/arm/top/.distr delete mode 100644 mach/em22/.distr delete mode 100644 mach/em22/libend/.distr delete mode 100644 mach/em24/.distr delete mode 100644 mach/em24/libend/.distr delete mode 100644 mach/em44/.distr delete mode 100644 mach/em44/libend/.distr delete mode 100644 mach/i386/.distr delete mode 100644 mach/i386/as/.distr delete mode 100644 mach/i386/ce/.distr delete mode 100644 mach/i386/cv/.distr delete mode 100644 mach/i386/libdb/.distr delete mode 100644 mach/i386/libem/.distr delete mode 100644 mach/i386/libend/.distr delete mode 100644 mach/i386/libfp/.distr delete mode 100644 mach/i386/libsys/.distr delete mode 100644 mach/i386/ncg/.distr delete mode 100644 mach/i80/.distr delete mode 100644 mach/i80/as/.distr delete mode 100644 mach/i80/dl/.distr delete mode 100644 mach/i80/libem/.distr delete mode 100644 mach/i80/libend/.distr delete mode 100644 mach/i80/libmon/.distr delete mode 100644 mach/i80/ncg/.distr delete mode 100644 mach/i80/top/.distr delete mode 100644 mach/i86/.distr delete mode 100644 mach/i86/as/.distr delete mode 100644 mach/i86/ce/.distr delete mode 100644 mach/i86/cv/.distr delete mode 100644 mach/i86/libem/.distr delete mode 100644 mach/i86/libend/.distr delete mode 100644 mach/i86/libfp/.distr delete mode 100644 mach/i86/libsys/.distr delete mode 100644 mach/i86/ncg/.distr delete mode 100644 mach/m68020/.distr delete mode 100644 mach/m68020/as/.distr delete mode 100644 mach/m68020/ce/.distr delete mode 100644 mach/m68020/cv/.distr delete mode 100644 mach/m68020/libdb/.distr delete mode 100644 mach/m68020/libem/.distr delete mode 100644 mach/m68020/libend/.distr delete mode 100644 mach/m68020/libfp/.distr delete mode 100644 mach/m68020/libsys/.distr delete mode 100644 mach/m68020/ncg/.distr delete mode 100644 mach/m68020/top/.distr delete mode 100644 mach/m68k2/.distr delete mode 100644 mach/m68k2/as/.distr delete mode 100644 mach/m68k2/cv/.distr delete mode 100644 mach/m68k2/dl/.distr delete mode 100644 mach/m68k2/libem/.distr delete mode 100644 mach/m68k2/libend/.distr delete mode 100644 mach/m68k2/libfp/.distr delete mode 100644 mach/m68k2/libsys/.distr delete mode 100644 mach/m68k2/ncg/.distr delete mode 100644 mach/m68k2/top/.distr delete mode 100644 mach/m68k4/.distr delete mode 100644 mach/m68k4/libem/.distr delete mode 100644 mach/m68k4/libend/.distr delete mode 100644 mach/m68k4/libfp/.distr delete mode 100644 mach/m68k4/libsys/.distr delete mode 100644 mach/m68k4/ncg/.distr delete mode 100644 mach/mantra/.distr delete mode 100644 mach/mantra/cv/.distr delete mode 100644 mach/mantra/int/.distr delete mode 100644 mach/mantra/libsys/.distr delete mode 100644 mach/minix/.distr delete mode 100644 mach/minix/libsys/.distr delete mode 100644 mach/minixST/.distr delete mode 100644 mach/minixST/cv/.distr delete mode 100644 mach/minixST/libsys/.distr delete mode 100644 mach/moon3/ncg/.distr delete mode 100644 mach/ns/.distr delete mode 100644 mach/ns/as/.distr delete mode 100644 mach/ns/libem/.distr delete mode 100644 mach/ns/libend/.distr delete mode 100644 mach/ns/libmon/.distr delete mode 100644 mach/ns/ncg/.distr delete mode 100644 mach/pdp/.distr delete mode 100644 mach/pdp/as/.distr delete mode 100644 mach/pdp/cg/.distr delete mode 100644 mach/pdp/cv/.distr delete mode 100644 mach/pdp/int/.distr delete mode 100644 mach/pdp/libem/.distr delete mode 100644 mach/pdp/libend/.distr delete mode 100644 mach/pdp/libsys/.distr delete mode 100644 mach/pdp/ncg/.distr delete mode 100644 mach/pdp/top/.distr delete mode 100644 mach/pmds/.distr delete mode 100644 mach/pmds/cv/.distr delete mode 100644 mach/pmds/libsys/.distr delete mode 100644 mach/pmds4/.distr delete mode 100644 mach/pmds4/libsys/.distr delete mode 100644 mach/powerpc/as/.distr delete mode 100644 mach/powerpc/libem/.distr delete mode 100644 mach/powerpc/libend/.distr delete mode 100644 mach/powerpc/ncg/.distr delete mode 100644 mach/powerpc/top/.distr delete mode 100644 mach/proto/.distr delete mode 100644 mach/proto/as/.distr delete mode 100644 mach/proto/cg/.distr delete mode 100644 mach/proto/fp/.distr delete mode 100644 mach/proto/grind/.distr delete mode 100644 mach/proto/libg/.distr delete mode 100644 mach/proto/ncg/.distr delete mode 100644 mach/proto/top/.distr delete mode 100644 mach/s2650/.distr delete mode 100644 mach/s2650/as/.distr delete mode 100644 mach/sparc/.distr delete mode 100644 mach/sparc/ce/.distr delete mode 100644 mach/sparc/ce/back.src/.distr delete mode 100644 mach/sparc/ce/ce.src/.distr delete mode 100644 mach/sparc/ce_cg/.distr delete mode 100644 mach/sparc/libdb/.distr delete mode 100644 mach/sparc/libem/.distr delete mode 100644 mach/sparc/libend/.distr delete mode 100644 mach/sparc/libsys/.distr delete mode 100644 mach/sparc/top/.distr delete mode 100644 mach/sparc_solaris/.distr delete mode 100644 mach/sparc_solaris/ce/.distr delete mode 100644 mach/sparc_solaris/ce_cg/.distr delete mode 100644 mach/sparc_solaris/libdb/.distr delete mode 100644 mach/sparc_solaris/libem/.distr delete mode 100644 mach/sparc_solaris/libend/.distr delete mode 100644 mach/sparc_solaris/libsys/.distr delete mode 100644 mach/sun2/.distr delete mode 100644 mach/sun2/cv/.distr delete mode 100644 mach/sun2/libsys/.distr delete mode 100644 mach/sun3/.distr delete mode 100644 mach/sun3/ce/.distr delete mode 100644 mach/sun3/cv/.distr delete mode 100644 mach/sun3/liba68s/.distr delete mode 100644 mach/sun3/libce/.distr delete mode 100644 mach/sun3/libsys/.distr delete mode 100644 mach/vax4/.distr delete mode 100644 mach/vax4/as/.distr delete mode 100644 mach/vax4/ce/.distr delete mode 100644 mach/vax4/cg/.distr delete mode 100644 mach/vax4/cv/.distr delete mode 100644 mach/vax4/libbsd4_1a/.distr delete mode 100644 mach/vax4/libbsd4_2/.distr delete mode 100644 mach/vax4/libce/.distr delete mode 100644 mach/vax4/libdb/.distr delete mode 100644 mach/vax4/libem/.distr delete mode 100644 mach/vax4/libend/.distr delete mode 100644 mach/vax4/libsysV_2/.distr delete mode 100644 mach/vax4/top/.distr delete mode 100644 mach/vc4/.distr delete mode 100644 mach/vc4/as/.distr delete mode 100644 mach/vc4/libem/.distr delete mode 100644 mach/vc4/libend/.distr delete mode 100644 mach/vc4/ncg/.distr delete mode 100644 mach/xenix3/.distr delete mode 100644 mach/xenix3/cv/.distr delete mode 100644 mach/xenix3/libsys/.distr delete mode 100644 mach/z80/.distr delete mode 100644 mach/z80/as/.distr delete mode 100644 mach/z80/cg/.distr delete mode 100644 mach/z80/int/.distr delete mode 100644 mach/z80/libem/.distr delete mode 100644 mach/z80/libend/.distr delete mode 100644 mach/z80/libmon/.distr delete mode 100644 mach/z80/libsys/.distr delete mode 100644 mach/z80/top/.distr delete mode 100644 mach/z8000/.distr delete mode 100644 mach/z8000/as/.distr delete mode 100644 mach/z8000/cg/.distr delete mode 100644 mach/z8000/libem/.distr delete mode 100644 mach/z8000/libend/.distr delete mode 100644 mach/z8000/libmon/.distr delete mode 100644 man/.distr delete mode 100644 modules/.distr delete mode 100644 modules/h/.distr delete mode 100644 modules/src/.distr delete mode 100644 modules/src/Xmalloc/.distr delete mode 100644 modules/src/alloc/.distr delete mode 100644 modules/src/assert/.distr delete mode 100644 modules/src/em_code/.distr delete mode 100644 modules/src/em_data/.distr delete mode 100644 modules/src/em_mes/.distr delete mode 100644 modules/src/em_opt/.distr delete mode 100644 modules/src/flt_arith/.distr delete mode 100644 modules/src/idf/.distr delete mode 100644 modules/src/input/.distr delete mode 100644 modules/src/malloc/.distr delete mode 100644 modules/src/object/.distr delete mode 100644 modules/src/print/.distr delete mode 100644 modules/src/read_em/.distr delete mode 100644 modules/src/string/.distr delete mode 100644 modules/src/system/.distr delete mode 100644 plat/.distr delete mode 100644 plat/cpm/.distr delete mode 100644 plat/linux/.distr delete mode 100644 plat/linux/libsys/.distr delete mode 100644 plat/linux386/.distr delete mode 100644 plat/linux68k/.distr delete mode 100644 plat/linuxppc/.distr delete mode 100644 plat/pc86/.distr delete mode 100644 plat/rpi/.distr delete mode 100644 util/.distr delete mode 100644 util/LLgen/.distr delete mode 100644 util/ack/.distr delete mode 100644 util/amisc/.distr delete mode 100644 util/arch/.distr delete mode 100644 util/ass/.distr delete mode 100644 util/byacc/.distr delete mode 100644 util/ceg/.distr delete mode 100644 util/ceg/EM_parser/.distr delete mode 100644 util/ceg/EM_parser/as_EM_pars/.distr delete mode 100644 util/ceg/EM_parser/common/.distr delete mode 100644 util/ceg/EM_parser/obj_EM_pars/.distr delete mode 100644 util/ceg/as_parser/.distr delete mode 100644 util/ceg/as_parser/eval/.distr delete mode 100644 util/ceg/assemble/.distr delete mode 100644 util/ceg/assemble/as_assemble/.distr delete mode 100644 util/ceg/assemble/obj_assemble/.distr delete mode 100644 util/ceg/ce_back/.distr delete mode 100644 util/ceg/ce_back/as_back/.distr delete mode 100644 util/ceg/ce_back/obj_back/.distr delete mode 100644 util/ceg/defaults/.distr delete mode 100644 util/ceg/defaults/message/.distr delete mode 100644 util/ceg/defaults/not_impl/.distr delete mode 100644 util/ceg/defaults/pseudo/.distr delete mode 100644 util/ceg/defaults/storage/.distr delete mode 100644 util/ceg/util/.distr delete mode 100644 util/cgg/.distr delete mode 100644 util/cmisc/.distr delete mode 100644 util/cpp/.distr delete mode 100644 util/ego/.distr delete mode 100644 util/ego/bo/.distr delete mode 100644 util/ego/ca/.distr delete mode 100644 util/ego/cf/.distr delete mode 100644 util/ego/cj/.distr delete mode 100644 util/ego/cs/.distr delete mode 100644 util/ego/descr/.distr delete mode 100644 util/ego/em_ego/.distr delete mode 100644 util/ego/ic/.distr delete mode 100644 util/ego/il/.distr delete mode 100644 util/ego/lv/.distr delete mode 100644 util/ego/ra/.distr delete mode 100644 util/ego/share/.distr delete mode 100644 util/ego/sp/.distr delete mode 100644 util/ego/sr/.distr delete mode 100644 util/ego/ud/.distr delete mode 100644 util/flex/.distr delete mode 100644 util/grind/.distr delete mode 100644 util/int/.distr delete mode 100644 util/int/switch/.distr delete mode 100644 util/int/test/.distr delete mode 100644 util/led/.distr delete mode 100644 util/make/.distr delete mode 100644 util/misc/.distr delete mode 100644 util/ncgg/.distr delete mode 100644 util/opt/.distr delete mode 100644 util/shf/.distr delete mode 100644 util/topgen/.distr diff --git a/README b/README index 956e25360..701581f17 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ - THE AMSTERDAM COMPILER KIT V6.0pre5 + THE AMSTERDAM COMPILER KIT V6.1pre1 =================================== © 1987-2005 Vrije Universiteit, Amsterdam - 2016-06-02 + 2016-08-02 INTRODUCTION @@ -13,10 +13,10 @@ front end compilers for a number of different languages, code generators, support libraries, and all the tools necessary to go from source code to executable on any of the platforms it supports. -This is an early prerelease of the apocryphal version 6.0 release. Not a +This is an early prerelease of the apocryphal version 6.1 release. Not a lot is supported, the build mechanism needs work, and a lot of things are probably broken. However, what's there should be sufficient to get things -done and to evaluate how the full 6.0 release should work. +done and to evaluate how the full 6.1 release should work. SUPPORT @@ -50,6 +50,11 @@ Requirements: - GNU make. +- Lua 5.1 and the luaposix library (used by the build system). + +- (optionally) ninja; if you've got this, this will be autodetected and give + you faster builds. + - about 40MB free in /tmp (or some other temporary directory). - about 6MB in the target directory. @@ -62,17 +67,17 @@ Instructions: - Run: - make # or gmake + make ...from the command line. This will do the build. The make system is fully parallelisable. If you have a multicore system, - you probably want to do: + install ninja and it'll use all your cores. If you don't have ninja, you + can still use make for parallel builds with: - make -j8 # or gmake -j8 + make MAKEFLAGS='-r -j8' # or however many cores you have - ...instead (substituting the right number of cores, of course). You can - also shave a few seconds of the build time by using the -r flag. + ...but frankly, I recommend ninja. - Run: @@ -145,6 +150,10 @@ There are some things you should be aware of. - The ACK uses its own .o format. You won't be able to mix the ACK's object files and another compiler's. +- The distribution contains *everything*, including the weird, ancient, + archaic stuff that doesn't work any more and never will, such as the int EM + interpreter and the assembler-linkers. Only some of it builds. Look for + build.lua files. DISCLAIMER ========== @@ -170,4 +179,4 @@ Please enjoy. David Given (dtrg on Sourceforge) dg@cowlark.com -2016-06-02 +2016-08-02 diff --git a/bin/.distr b/bin/.distr deleted file mode 100644 index 96768b1ae..000000000 --- a/bin/.distr +++ /dev/null @@ -1,9 +0,0 @@ -cc-and-mkdep.ack -cc-and-mkdep.all -cc-and-mkdep.sun -do_deps -do_resolve -lint-lib.ack -lint-lib.unix -mk_manpage -rm_deps diff --git a/distr/Exceptions b/distr/Exceptions deleted file mode 100644 index edd5a5724..000000000 --- a/distr/Exceptions +++ /dev/null @@ -1,15 +0,0 @@ -++ ./doc/install.pr made -++ ./doc/int/.distr made -++ ./etc/new_table_done made -++ ./lang/cem/cemcom.ansi/Version.c made -++ ./lang/cem/libcc.ansi/stdlib/malloc.c made -++ ./lang/cem/cemcom/Version.c made -++ ./lang/pc/comp/Version.c made -++ ./lang/m2/comp/Version.c made -++ ./lang/m2/m2mm/Version.c made -++ ./mach/sparc/ce/EM_table made -++ ./mach/sparc_solaris/libem/LIST made -++ ./util/LLgen/src/LLgen.c.dist made -++ ./util/cpp/Version.c made -++ ./util/ego/share/pop_push.h made -++ ./util/grind/ops.c made diff --git a/distr/How_To b/distr/How_To deleted file mode 100644 index 17ec1ad39..000000000 --- a/distr/How_To +++ /dev/null @@ -1,90 +0,0 @@ -How to make a distribution --------------------------- - -I have written a new tool to generate the distributions that does not rely on -having a local CVS server --- distr/mkdist. - -To use it, you need to specify your CVS work tree, the destination directory -that the distribution will be written to, plus flags. It should be self- -documenting; use: - - mkdist --help - -...to get documentation. - -It uses .distr files in exactly the same way as the previous mechanism. - -The documentation for the old distribution tools follows. - -David Given -dg@cowlark.com -2005-06-25 - ------------------------------------------------------------------------------ - -How to make a fresh distribution: -For a distribution you need ".distr" files and RCS files. -The EM home directory contains a file called ".distr". It contains -the names of all the files and directories you want to have in the distribution. -The directories should contain .distr files, the other files should -be placed under CVS. -There are files that derive from other files and yet should be placed -in the distribution. -These files should not be placed under RCS or CVS. -The file "Exceptions" in this directory contains the current list of -these files. - -When all this is correct, use the shell script mktree the extract -the distribution from the EM tree. - sh mktree destination_tree repository_tree 2>f.attf -Use the "cvs rtag" command to give the distribution a name first! -Make sure that the destination tree exists and is empty! -Failing to do that will almost certainly result in a welter of -error messages. -The file f.attf contains mktree error messages and should be compared -to Exceptions. -The actions of mktree are quite complicated. It starts in the current -directory creating a version in the destination directory. -Then it reads the .distr file. -For each file mentioned there it performes certain actions: -1- Directory Change to that directory and call yourself recursively. -2- File - a- Does a file LIST exist in this directory AND - is the first line of LIST equal to the name of the - destination file? If so, try to extract all the files - named in the rest of the LIST file and call the program - arch to create a library "arch cDr `cat LIST`". - In this manner libraries can be distributed whose members - have their own RCS file. - else - b- Try to run 'make distr' - else - c- Try to run 'make ' - else - d- give message that says "not present" (or some such). - -Now, the tree contains all the files in the distribution, but it also contains -files that should not be in the distribution, especially the files created -by CVS. -That is why we now give the command: - dtar cdf distr . -The file distr is the one you should put on tape! -But,.... before doing that: Try it out! -Repeat the process described in the installation manual. -Only if that succeeds you are sure that you included the files needed. - Good Luck, - Ed Keizer, 85/4/15. - -Updated for 3rd distribution by Ceriel Jacobs, 87/3/11. -And again, - Good Luck! - -Updated for 4th distribution by Ceriel Jacobs, 88/4/08. -And again, - Good Luck! -Updated for 5th distribution by Ceriel Jacobs, 91/19/12. -And again, - Good Luck! -Updated for 1st upgrade to 5th distribution by Ceriel Jacobs, 91/12/11. -And again, - Good Luck! diff --git a/distr/dwalk b/distr/dwalk deleted file mode 100755 index 1a869f105..000000000 --- a/distr/dwalk +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -: ${CDIR=.} -${DF-:} $CDIR .distr -if test ! -r $DESTDIR/$CDIR/.distr -then - echo ++ no .distr in $CDIR 1>&2 - exit 0 -fi -for i in `cat $DESTDIR/$CDIR/.distr` -do - if test -d $i - then - ( if cd $i - then - CDIR=$CDIR/$i - export CDIR - exec $DDIR/dwalk $* - else - echo ++ Could not access $CDIR/$i 1>&2 - fi - ) - else - ${DF-:} $CDIR $i - fi -done diff --git a/distr/echod b/distr/echod deleted file mode 100755 index 9fb9840d0..000000000 --- a/distr/echod +++ /dev/null @@ -1 +0,0 @@ -echo $1 diff --git a/distr/listall b/distr/listall deleted file mode 100755 index 0bacb4932..000000000 --- a/distr/listall +++ /dev/null @@ -1,10 +0,0 @@ -case $# in -0) DESTDIR=. ;; -1) DESTDIR=$1 ;; -*) echo $0 [directory] ; exit 1 ;; -esac -DD=`pwd`/listall.d -DW=`pwd`/dwalk -export DD DESTDIR -cd $DESTDIR -$DW diff --git a/distr/listall.d b/distr/listall.d deleted file mode 100755 index d66cf179c..000000000 --- a/distr/listall.d +++ /dev/null @@ -1,2 +0,0 @@ -echo "<$1>" -ls -bCdx `cat .distr` diff --git a/distr/listdirs b/distr/listdirs deleted file mode 100755 index 9d5d3c1f1..000000000 --- a/distr/listdirs +++ /dev/null @@ -1,10 +0,0 @@ -case $# in -0) DIR=. ;; -1) DIR=$1 ;; -*) echo $0 [directory] ; exit 1 ;; -esac -DD=`pwd`/echod -DW=`pwd`/dwalk -export DD -cd $DIR -$DW diff --git a/distr/mk_distr_syms b/distr/mk_distr_syms deleted file mode 100755 index 8263c1181..000000000 --- a/distr/mk_distr_syms +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -: Utility to make a tree of symbolic links to source tree. -: Mount the source tree read-only, use this script, and then try installation. -case $# in -2) ;; -*) echo "Usage: $0 " 1>&2 - exit 1 - ;; -esac -if [ -f $1/.distr ] -then - for i in `cat $1/.distr` - do - if [ -d $1/$i ] - then - if mkdir $2/$i && $0 $1/$i $2/$i - then - : - else - exit 2 - fi - else - if [ -f $1/$i ] - then - if ln -s $1/$i $2/$i - then - : - else - exit 3 - fi - else - echo "Missing file $1/$i" 1>&2 - exit 4 - fi - fi - done -else - echo "No .distr file in $1" 1>&2 - exit 5 -fi diff --git a/distr/mka b/distr/mka deleted file mode 100755 index 1581e662b..000000000 --- a/distr/mka +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e -for i in `tail +2 $DESTDIR/$1/LIST` -do - ${DF-false} $1 $i -done -cd $DESTDIR/$1 -arch cDr `cat LIST` -: I do not remove the files constituating the library, because -: they might be present in .distr diff --git a/distr/mkd b/distr/mkd deleted file mode 100755 index e69de29bb..000000000 diff --git a/distr/mkdist b/distr/mkdist deleted file mode 100755 index 1e302dc19..000000000 --- a/distr/mkdist +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/sh -# $Source$ -# $State$ - -# Set up default variables. - -destdir= -srcdir=`pwd` -aal=/usr/local/bin/aal -delete=no -copy="ln" - -# --- Options parsing ------------------------------------------------------- - -while [ "$1" != "" ]; do - case "$1" in - -s|--srcdir) - srcdir="$2" - shift - ;; - - -d|--destdir) - destdir="$2" - shift - ;; - - -x|--delete) - delete=yes - ;; - - -c|--copy) - copy="cp -Rp" - ;; - - -S|--symlink) - copy="ln -s" - ;; - - -a|--aal) - aal="$2" - shift - ;; - - -h|--help) - echo "mkdist [options]" - echo "Options are:" - echo " -s --srcdir The CVS tree to read from. (default: CWD)" - echo " -d --destdir The directory to create the distribution in." - echo " -x --delete Erase the destination directory first." - echo " -c --copy Make physical copies of the files. (default: hardlink)" - echo " -S --symlink Make symbolic links instead of copying or hardlinking." - echo " -a --aal Where the ACK 'aal' tool is." - echo " -h --help Display this message." - exit 0 - ;; - - *) - echo "Unrecognised option. Try --help for help." - exit 1 - esac - shift -done - -if [ "$destdir" = "" ]; then - echo "You must specify a destination directory. (Try --help for help.)" - exit 1 -fi - -# --- Main routines --------------------------------------------------------- - -# These two routines do the work of traversing the source tree and building -# the distribution tree. - -addfile() { - local f - f="${1##$srcdir/}" - mkdir -p $destdir/`dirname $f` - $copy "$1" "$destdir/$f" -} - -process_dir() { - local path - local archivename - - path=$1 - cd $path - echo $PWD - - # Look for a LIST file and cache the first line. - - archivename= - if [ -f LIST ]; then - archivename=`head -1 LIST` - fi - - for i in `cat $path/.distr`; do - case "$i" in - \#*) # Comment. Do nothing. - ;; - - *) - if [ -d $i ]; then - # This is a directory. Recurse into it. - - ( process_dir $path/$i ) - elif [ -f $i ]; then - # This is a file. - - addfile $path/$i - elif [ "$i" = "$archivename" ]; then - # Build the named archive. - - $aal cDr `cat LIST` - addfile $path/$archivename - else - echo "Don't know what to do with $i, listed in $PWD/.distr." - exit 1 - fi - ;; - esac - done -} - -# --- Main program ---------------------------------------------------------- - -# Test to make sure that $aal points to the right thing. - -if !(strings $aal | grep archiver > /dev/null); then - echo "$aal does not seem to point at the ACK archiver tool." - echo "" - echo "Press RETURN to go ahead anyway, or CTRL+C to abort." - read ignored -fi - -# Actually do the work. - -echo "Creating distribution from CVS tree: $srcdir" -echo " into destination tree: $destdir" -echo "" - -if [ -e $destdir ]; then - if [ "$delete" = "yes" ]; then - echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort." - read _ _ - echo "Erasing..." - rm -rf "$destdir" - else - echo "$destdir exists. Aborting." - exit 1 - fi -fi - -echo "Working..." -mkdir -p $destdir -process_dir $srcdir -echo "Done." - -# Revision history -# $Log$ -# Revision 1.5 2007-04-24 19:48:41 dtrg -# Removed bashish. -# -# Revision 1.4 2007/02/25 20:56:41 dtrg -# Performed major renovations to make the script work on OpenBSD. -# -# Revision 1.3 2007/02/24 02:05:56 dtrg -# Removed some bashish; added comment support; removed the make -# distr functionality, as nothing was using it any more and it was -# causing problems. -# -# Revision 1.2 2005/06/24 23:19:23 dtrg -# Added new mkdist tool. -# -# Revision 1.1 2005/06/24 22:13:57 dtrg -# Created new tool to generate distributions. diff --git a/distr/mkf b/distr/mkf deleted file mode 100755 index c7f572f91..000000000 --- a/distr/mkf +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -if [ -f $DESTDIR/$1/$2 ] -then - : -elif grep LIST $DESTDIR/$1/.distr >/dev/null 2>&1 && - (test "$2" = "`head -1 $DESTDIR/$1/LIST`") >/dev/null 2>&1 && - ${DA-false} "$1" "$2" -then -: Fetched library contents one by one and put them together -elif ( cd $DESTDIR/$1 ; make distr ) > /dev/null 2>&1 -then - echo ++ $1/$2 made 1>&2 -elif ( cd $DESTDIR/$1 ; make $2 ) > /dev/null 2>&1 -then - echo ++ $1/$2 made 1>&2 -else - echo ++ $1/$2 not present 1>&2 -fi diff --git a/distr/mktree b/distr/mktree deleted file mode 100644 index 037fa4086..000000000 --- a/distr/mktree +++ /dev/null @@ -1,42 +0,0 @@ -case $# in -2|3) ;; -*) echo Usage: $0 directory repdir [ SVrecord ] 1>&2 ; exit 1 ;; -esac -case $0 in -/*) DDIR=`dirname $0` - ;; -*) DDIR=`pwd`/`dirname $0` - ;; -esac -case $1 in -/*) DESTDIR=$1 ;; -*) DESTDIR=`pwd`/$1 ;; -esac -case $2 in -/*) REPDIR=$2 ;; -*) REPDIR=`pwd`/$2 ;; -esac -# DD=$DDIR/mkd -# export DD -mkdir -p $DESTDIR -CVSROOT=/usr/proj/em/Repositories -export CVSROOT -cd $DESTDIR -case $# in -3) - cvs checkout world -r $3 - ;; -2) - cvs checkout world - ;; -esac -cd $REPDIR -DF=$DDIR/mkf -DA=$DDIR/mka -export DDIR DESTDIR DF DA REPDIR - -$DDIR/dwalk - -cd $DESTDIR -find . -type d -print | xargs chmod "uog+rx" -chmod -R "og-w,u+w,uog+r" . diff --git a/distr/todistr b/distr/todistr deleted file mode 100644 index 5b171453b..000000000 --- a/distr/todistr +++ /dev/null @@ -1,26 +0,0 @@ -REV= -FILE= -while : -do - case $# in - 0) break ;; - esac - ARG="$1" - shift - case "$ARG" in - -r*) REV=`echo "$ARG"| sed s/-r//` ;; - -*) FLAGS="$FLAGS $ARG" ;; - *) case x$FILE in - x) FILE="$ARG" ;; - *) echo todistr can only be done on one file at the time - exit 1 ;; - esac - esac -done -case x$REV in -x) REV=`rlog -h "$FILE"|sed -n -e '/head/s/^head:[ ]*//p'` ;; -esac -case x$REV in -x) exit 2 ;; -esac -rcs -ndistr4:$REV $FLAGS $FILE diff --git a/distr/ts b/distr/ts deleted file mode 100755 index 8350341b2..000000000 --- a/distr/ts +++ /dev/null @@ -1,2 +0,0 @@ -DD=`pwd`/ts -echo OK diff --git a/doc/.distr b/doc/.distr deleted file mode 100644 index ba9928276..000000000 --- a/doc/.distr +++ /dev/null @@ -1,32 +0,0 @@ -READ_ME -Makefile -proto.make -ack.doc -basic.doc -cg.doc -crefman.doc -ansi_C.doc -em -install.doc -install.pr -ncg.doc -pcref.doc -peep.doc -regadd.doc -toolkit.doc -v7bugs.doc -val.doc -6500.doc -i80.doc -z80.doc -m68020.doc -m2ref.doc -nopt.doc -top -ego -occam -int -ceg -sparc -lint -pascal diff --git a/doc/LLgen/.distr b/doc/LLgen/.distr deleted file mode 100644 index 5215a59c7..000000000 --- a/doc/LLgen/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LLgen.n -LLgen_NCER.n -LLgen.refs -proto.make diff --git a/doc/ceg/.distr b/doc/ceg/.distr deleted file mode 100644 index 92c3fa3af..000000000 --- a/doc/ceg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -ceg.ref -ceg.tr diff --git a/doc/ego/.distr b/doc/ego/.distr deleted file mode 100644 index 17d03f8d5..000000000 --- a/doc/ego/.distr +++ /dev/null @@ -1,18 +0,0 @@ -proto.make -bo -ca -cf -cj -cs -ic -il -intro -lv -ov -ra -refs.gen -refs.opt -refs.stat -sp -sr -ud diff --git a/doc/ego/bo/.distr b/doc/ego/bo/.distr deleted file mode 100644 index 8f41f100d..000000000 --- a/doc/ego/bo/.distr +++ /dev/null @@ -1 +0,0 @@ -bo1 diff --git a/doc/ego/ca/.distr b/doc/ego/ca/.distr deleted file mode 100644 index 4723880e2..000000000 --- a/doc/ego/ca/.distr +++ /dev/null @@ -1 +0,0 @@ -ca1 diff --git a/doc/ego/cf/.distr b/doc/ego/cf/.distr deleted file mode 100644 index 6aff9ca72..000000000 --- a/doc/ego/cf/.distr +++ /dev/null @@ -1,6 +0,0 @@ -cf1 -cf2 -cf3 -cf4 -cf5 -cf6 diff --git a/doc/ego/cj/.distr b/doc/ego/cj/.distr deleted file mode 100644 index a92acc3b1..000000000 --- a/doc/ego/cj/.distr +++ /dev/null @@ -1 +0,0 @@ -cj1 diff --git a/doc/ego/cs/.distr b/doc/ego/cs/.distr deleted file mode 100644 index 99b8c7793..000000000 --- a/doc/ego/cs/.distr +++ /dev/null @@ -1,5 +0,0 @@ -cs1 -cs2 -cs3 -cs4 -cs5 diff --git a/doc/ego/ic/.distr b/doc/ego/ic/.distr deleted file mode 100644 index eabb41472..000000000 --- a/doc/ego/ic/.distr +++ /dev/null @@ -1,5 +0,0 @@ -ic1 -ic2 -ic3 -ic4 -ic5 diff --git a/doc/ego/il/.distr b/doc/ego/il/.distr deleted file mode 100644 index 2aac56865..000000000 --- a/doc/ego/il/.distr +++ /dev/null @@ -1,6 +0,0 @@ -il1 -il2 -il3 -il4 -il5 -il6 diff --git a/doc/ego/intro/.distr b/doc/ego/intro/.distr deleted file mode 100644 index 45de40776..000000000 --- a/doc/ego/intro/.distr +++ /dev/null @@ -1,3 +0,0 @@ -head -intro1 -tail diff --git a/doc/ego/lv/.distr b/doc/ego/lv/.distr deleted file mode 100644 index b82f3da53..000000000 --- a/doc/ego/lv/.distr +++ /dev/null @@ -1 +0,0 @@ -lv1 diff --git a/doc/ego/ov/.distr b/doc/ego/ov/.distr deleted file mode 100644 index 9170d50dc..000000000 --- a/doc/ego/ov/.distr +++ /dev/null @@ -1 +0,0 @@ -ov1 diff --git a/doc/ego/ra/.distr b/doc/ego/ra/.distr deleted file mode 100644 index d9cbc6df4..000000000 --- a/doc/ego/ra/.distr +++ /dev/null @@ -1,4 +0,0 @@ -ra1 -ra2 -ra3 -ra4 diff --git a/doc/ego/sp/.distr b/doc/ego/sp/.distr deleted file mode 100644 index fb3527e1b..000000000 --- a/doc/ego/sp/.distr +++ /dev/null @@ -1 +0,0 @@ -sp1 diff --git a/doc/ego/sr/.distr b/doc/ego/sr/.distr deleted file mode 100644 index 6de854118..000000000 --- a/doc/ego/sr/.distr +++ /dev/null @@ -1,4 +0,0 @@ -sr1 -sr2 -sr3 -sr4 diff --git a/doc/ego/ud/.distr b/doc/ego/ud/.distr deleted file mode 100644 index f64dc1145..000000000 --- a/doc/ego/ud/.distr +++ /dev/null @@ -1,5 +0,0 @@ -ud1 -ud2 -ud3 -ud4 -ud5 diff --git a/doc/em/.distr b/doc/em/.distr deleted file mode 100644 index 76d9cae6b..000000000 --- a/doc/em/.distr +++ /dev/null @@ -1,28 +0,0 @@ -proto.make -READ_ME -app.codes.nr -app.exam.nr -assem.nr -cont.nr -descr.nr -dspace.nr -em.i -env.nr -even.c -exam.e -exam.p -int -intro.nr -ip.awk -ispace.nr -mach.nr -macr.nr -mapping.nr -mem.nr -title.nr -traps.nr -types.nr -mkdispatch.c -dispat1.sed -dispat2.sed -dispat3.sed diff --git a/doc/em/int/.distr b/doc/em/int/.distr deleted file mode 100644 index 8fb14befa..000000000 --- a/doc/em/int/.distr +++ /dev/null @@ -1,5 +0,0 @@ -proto.make -READ_ME -em.p -emdmp.c -mktables.c diff --git a/doc/lint/.distr b/doc/lint/.distr deleted file mode 100644 index 9c1cf0954..000000000 --- a/doc/lint/.distr +++ /dev/null @@ -1,15 +0,0 @@ -proto.make -abstract -appendix_A -appendix_B -chap1 -chap2 -chap3 -chap4 -chap5 -chap6 -chap7 -chap8 -chap9 -contents -frontpage diff --git a/doc/occam/.distr b/doc/occam/.distr deleted file mode 100644 index 08cf9cf3b..000000000 --- a/doc/occam/.distr +++ /dev/null @@ -1,12 +0,0 @@ -proto.make -ctot -p0 -p1 -p2 -p3 -p4 -p5 -p6 -p7 -p8 -p9 diff --git a/doc/pascal/.distr b/doc/pascal/.distr deleted file mode 100644 index 44bb76092..000000000 --- a/doc/pascal/.distr +++ /dev/null @@ -1,20 +0,0 @@ -ab+intro.doc -compar.doc -conf.doc -contents.doc -deviations.doc -example.doc -extensions.doc -hints.doc -his.doc -improv.doc -internal.doc -options.doc -proto.make -reference.doc -rtl.doc -syntax.doc -test.doc -titlepg.doc -transpem.doc -vrk.doc diff --git a/doc/sparc/.distr b/doc/sparc/.distr deleted file mode 100644 index bed3d274f..000000000 --- a/doc/sparc/.distr +++ /dev/null @@ -1,15 +0,0 @@ -1 -2 -3 -4 -5 -A -B -init -intro -note_on_reg_wins -refs -timing -title -proto.make -pics diff --git a/doc/sparc/pics/.distr b/doc/sparc/pics/.distr deleted file mode 100644 index 32d6efca8..000000000 --- a/doc/sparc/pics/.distr +++ /dev/null @@ -1,12 +0,0 @@ -EM_stack.orig -EM_stack.ours -compile_bars -mem_config -perf -perf.comp -perf.d -perf.dhry -reg_layout -run-time_bars -run-time_bars.bup -signal_stack diff --git a/doc/top/.distr b/doc/top/.distr deleted file mode 100644 index 32161cf4b..000000000 --- a/doc/top/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -refs.top -top.n diff --git a/emtest/.distr b/emtest/.distr deleted file mode 100644 index 3d60866ba..000000000 --- a/emtest/.distr +++ /dev/null @@ -1,6 +0,0 @@ -Makefile -READ_ME -ok -select.c -test.h -tests diff --git a/etc/.distr b/etc/.distr deleted file mode 100644 index b9c5d3c85..000000000 --- a/etc/.distr +++ /dev/null @@ -1,7 +0,0 @@ -proto.make -em_table -new_table -new_table_done -pop_push -traps -ip_spec.t diff --git a/examples/.distr b/examples/.distr deleted file mode 100644 index 3469c16ff..000000000 --- a/examples/.distr +++ /dev/null @@ -1,10 +0,0 @@ -hilo.b -hilo.c -hilo.mod -hilo.ocm -hilo.p -mandelbrot.c -paranoia.c -startrek.c -startrek.doc -README diff --git a/fast/.distr b/fast/.distr deleted file mode 100644 index 08ea893ed..000000000 --- a/fast/.distr +++ /dev/null @@ -1,6 +0,0 @@ -Action -driver -f_c.ansi -f_c -f_m2 -f_pc diff --git a/fast/driver/.distr b/fast/driver/.distr deleted file mode 100644 index 467369b36..000000000 --- a/fast/driver/.distr +++ /dev/null @@ -1,5 +0,0 @@ -afcc.1 -afm2.1 -afpc.1 -driver.c -proto.make diff --git a/fast/f_c.ansi/.distr b/fast/f_c.ansi/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_c.ansi/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fast/f_c/.distr b/fast/f_c/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_c/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fast/f_m2/.distr b/fast/f_m2/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_m2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fast/f_pc/.distr b/fast/f_pc/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_pc/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fcc/.distr b/fcc/.distr deleted file mode 100644 index 04696d0c4..000000000 --- a/fcc/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -cemcom -driver diff --git a/fcc/cemcom/.distr b/fcc/cemcom/.distr deleted file mode 100644 index 7f00154bd..000000000 --- a/fcc/cemcom/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Parameters.sun3 -Parameters.vax4 -proto.main -proto.make diff --git a/fcc/driver/.distr b/fcc/driver/.distr deleted file mode 100644 index ebc669f71..000000000 --- a/fcc/driver/.distr +++ /dev/null @@ -1,3 +0,0 @@ -fcc.1 -fcc.c -proto.make diff --git a/first/.distr b/first/.distr deleted file mode 100644 index e8f7adb1e..000000000 --- a/first/.distr +++ /dev/null @@ -1,19 +0,0 @@ -core.mk -#create_dir -#cp_dir -#em_path.h.src -#first -#get_answer -#get_makepars -#get_sys -#get_sysvax -#install_tail -#limit_enquire -#limit_impl -#lint_params -#local.h.src -#mk_config -#mk_makefile -#mk_target -#target_comp -#util_comp diff --git a/h/.distr b/h/.distr deleted file mode 100644 index 7ab9a7094..000000000 --- a/h/.distr +++ /dev/null @@ -1,29 +0,0 @@ -#Makefile -arch.h -bc_io.h -bc_string.h -#as_spec.h -cg_pattern.h -cgg_cg.h -em_abs.h -em_ego.h -em_flag.h -em_mes.h -#em_mnem.h -#em_pseu.h -em_ptyp.h -em_reg.h -#em_spec.h -out.h -stb.h -pc_err.h -pc_file.h -pc_math.h -ranlib.h -ocm_chan.h -ocm_parco.h -ocm_proc.h -m2_traps.h -#ip_spec.h -em_table -con_float diff --git a/include/.distr b/include/.distr deleted file mode 100644 index b13b150f1..000000000 --- a/include/.distr +++ /dev/null @@ -1,3 +0,0 @@ -_tail_mon -_tail_cc -occam diff --git a/include/_tail_mon/.distr b/include/_tail_mon/.distr deleted file mode 100644 index 0411643ee..000000000 --- a/include/_tail_mon/.distr +++ /dev/null @@ -1,4 +0,0 @@ -errno.h -signal.h -sgtty.h -sys diff --git a/include/_tail_mon/sys/.distr b/include/_tail_mon/sys/.distr deleted file mode 100644 index 2d8e3de02..000000000 --- a/include/_tail_mon/sys/.distr +++ /dev/null @@ -1,2 +0,0 @@ -types.h -timeb.h diff --git a/lang/.distr b/lang/.distr deleted file mode 100644 index 3f75d8944..000000000 --- a/lang/.distr +++ /dev/null @@ -1,6 +0,0 @@ -basic -cem -occam -pc -m2 -fortran diff --git a/lang/a68s/.distr b/lang/a68s/.distr deleted file mode 100644 index 2e474efe9..000000000 --- a/lang/a68s/.distr +++ /dev/null @@ -1,8 +0,0 @@ -COPYRIGHT -README -a68s.1 -aem -cpem -liba68s -test -util diff --git a/lang/a68s/aem/.distr b/lang/a68s/aem/.distr deleted file mode 100644 index 6a1ee1489..000000000 --- a/lang/a68s/aem/.distr +++ /dev/null @@ -1,26 +0,0 @@ -Makefile -a68s1ce.p -a68s1cg.p -a68s1int.p -a68s1lx.p -a68s1md.p -a68s1pa.p -a68s1s1.p -a68s1s2.p -a68scod.p -a68sdec.p -a68sdum.p -a68sin.p -a68sint.p -a68spar.p -a68ssp.p -cmpdum.p -cybcod.p -dec_main.p -dec_main_s1.p -getaddr.e -make -pcalls.e -perqce.p -perqcod.p -syntax diff --git a/lang/a68s/cpem/.distr b/lang/a68s/cpem/.distr deleted file mode 100644 index 5106cc94c..000000000 --- a/lang/a68s/cpem/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -READ_ME -cpem.p diff --git a/lang/a68s/liba68s/.distr b/lang/a68s/liba68s/.distr deleted file mode 100644 index b05416159..000000000 --- a/lang/a68s/liba68s/.distr +++ /dev/null @@ -1,127 +0,0 @@ -LIST -Makefile -aclose.c -aopen.c -arctan.c -associate.p -bytespack.p -calls.e -catpl.p -cfstr.p -chains.e -cleanup.c -collp.p -colltm.p -collts.p -complex.p -cos.c -crmult.p -crrefn.p -dclpsn.p -div.e -drefm.p -drefs.p -dumbacch.p -duminch.p -dummy.p -dumoutch.p -e.h -ensure.p -entier.c -errorr.p -exit.c -exp.c -fixed.p -float.p -genrec.p -get.e -getaddr.e -getmult.p -getout.p -gett.p -global.p -globale.e -gtot.p -gtotref.p -gvasstx.p -gvscope.p -heapmul.p -heapstr.p -hoist.e -is.p -linit2.p -linit34.p -linitinc.p -ln.c -lpb.s -make -maxr.c -mod.c -mulis.p -nassp.p -nassts.p -newline.p -onend.p -openclose.p -pcollmul.p -pcollst.p -posenq.p -powi.c -powneg.p -powr.c -put.e -putt.p -random.p -rangent.p -rangext.p -reset.p -rnstart.p -routn.p -routnp.p -rowm.p -rownm.p -run68g.p -rundecs.p -safeaccess.p -scopext.p -selectr.p -selecttsn.p -setcc.p -sett.p -shl.c -shr.c -signi.c -signr.c -sin.c -skip.p -slice12.p -slicen.p -space.p -sqrt.c -standass.p -standback.e -standin.p -standout.p -stbacch.p -stinch.p -stopen.p -stoutch.p -strsubtrim.p -structscope.p -swap.e -tassp.p -tasstm.p -tassts.p -temp.c -time.c -timesten.c -trace.e -trig.p -trim.p -uplwb.p -uplwbm.p -uplwbmstr.p -whole.p -widchar.p -widen.p -wrs.e diff --git a/lang/a68s/util/.distr b/lang/a68s/util/.distr deleted file mode 100644 index e2e34cc5c..000000000 --- a/lang/a68s/util/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -checkseq.p -indent.p -reseq.p -tailor.p -xref.c -pascal.ign diff --git a/lang/basic/.distr b/lang/basic/.distr deleted file mode 100644 index c01dd4ce8..000000000 --- a/lang/basic/.distr +++ /dev/null @@ -1,3 +0,0 @@ -build.mk -src -lib diff --git a/lang/basic/lib/.distr b/lang/basic/lib/.distr deleted file mode 100644 index 958e508d9..000000000 --- a/lang/basic/lib/.distr +++ /dev/null @@ -1,34 +0,0 @@ -build.mk -abs.c -asc.c -asrt.c -atn.c -chr.c -conversion.c -hlt.c -mki.c -oct.c -peek.c -power.c -exp.c -log.c -print.c -io.c -random.c -read.c -return.c -sgn.c -sin.c -fif.e -sqt.c -fef.e -stop.c -string.c -salloc.c -swap.c -trace.c -write.c -file.c -error.c -trap.c -setline.e diff --git a/lang/basic/src/.distr b/lang/basic/src/.distr deleted file mode 100644 index 0056c149f..000000000 --- a/lang/basic/src/.distr +++ /dev/null @@ -1,19 +0,0 @@ -build.mk -basic.g -basic.lex -bem.c -bem.h -compile.c -eval.c -func.c -gencode.c -graph.c -graph.h -initialize.c -llmess.c -maketokentab -parsepar.c -symbols.c -symbols.h -util.c -yylexp.c diff --git a/lang/basic/test/.distr b/lang/basic/test/.distr deleted file mode 100644 index 7d139dfa6..000000000 --- a/lang/basic/test/.distr +++ /dev/null @@ -1,100 +0,0 @@ -Makefile -Out.std -bull.b -bull.b.g -buzzword.b -buzzword.b.g -checker.b -checker.b.g -creator.b -grafiek.b -grafiek.b.g -gunner.b -gunner.b.g -learn.b -learn.b.g -opg1.b -opg1.b.g -opg2.b -opg2.b.g -opg3.b -opg3.b.g -opg4.b -opg4.b.g -opg5.b -opg5.b.g -opg6.b -opg6.b.g -runcmp -som4.b -som4.b.g -test01.b -test01.b.g -test02.b -test02.b.g -test03.b -test03.b.g -test04.b -test04.b.g -test05.b -test05.b.g -test06.b -test06.b.g -test07.b -test07.b.g -test08.b -test08.b.g -test09.b -test09.b.g -test10.b -test10.b.g -test11.b -test11.b.g -test12.b -test12.b.g -test13.b -test13.b.g -test14.b -test14.b.g -test15.b -test15.b.g -test16.b -test16.b.g -test17.b -test17.b.g -test18.b -test18.b.g -test19.b -test19.b.g -test20.b -test20.b.g -test21.b -test21.b.g -test22.b -test22.b.g -test23.b -test23.b.g -test24.b -test24.b.g -test25.b -test25.b.g -test26.b -test26.b.g -test27.b -test27.b.g -test28.b -test28.b.g -test29.b -test29.b.g -test30.b -test30.b.g -test31.b -test31.b.g -test32.b -test32.b.g -test33.b -test33.b.g -test34.b -test35.b -test35.b.g -tst diff --git a/lang/basic/test/tst/.distr b/lang/basic/test/tst/.distr deleted file mode 100644 index 43fe24f68..000000000 --- a/lang/basic/test/tst/.distr +++ /dev/null @@ -1,2 +0,0 @@ -data -data1 diff --git a/lang/cem/.distr b/lang/cem/.distr deleted file mode 100644 index 21f8f8d1b..000000000 --- a/lang/cem/.distr +++ /dev/null @@ -1,6 +0,0 @@ -build.mk -cemcom.ansi -cpp.ansi -libcc.ansi -#cemcom -#libcc diff --git a/lang/cem/cemcom.ansi/.distr b/lang/cem/cemcom.ansi/.distr deleted file mode 100644 index 13a214f16..000000000 --- a/lang/cem/cemcom.ansi/.distr +++ /dev/null @@ -1,99 +0,0 @@ -build.mk -LLlex.c -LLlex.h -LLmessage.c -SmallPars -BigPars -align.h -arith.c -arith.h -assert.h -atw.h -blocks.c -cemcom.ansi.1 -ch3.c -ch3bin.c -ch3mon.c -char.tab -class.h -code.c -code.str -conversion.c -cstoper.c -dataflow.c -declar.g -declar.str -declarator.c -decspecs.c -decspecs.h -def.str -domacro.c -dumpidf.c -error.c -estack.str -eval.c -expr.c -expr.str -expression.g -field.c -field.str -file_info.h -fltcstoper.c -idf.c -idf.str -init.c -input.c -input.h -interface.h -ival.g -l_brace.str -l_class.h -l_comment.h -l_comment.c -l_em.h -l_ev_ord.c -l_lint.c -l_lint.h -l_misc.c -l_outdef.c -l_outdef.str -l_state.str -l_states.c -label.c -label.h -level.h -macro.str -main.c -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -mes.h -options -options.c -pragma.c -program.g -proto.c -proto.str -replace.c -replace.str -sizes.h -skip.c -specials.h -stab.c -stack.c -stack.str -statement.g -stb.c -stmt.str -struct.c -struct.str -switch.c -switch.str -tokenname.c -tokenname.h -type.c -type.str -util.str -util.c diff --git a/lang/cem/cemcom/.distr b/lang/cem/cemcom/.distr deleted file mode 100644 index cde313abc..000000000 --- a/lang/cem/cemcom/.distr +++ /dev/null @@ -1,97 +0,0 @@ -build.mk -LLlex.c -LLlex.h -LLmessage.c -SmallPars -BigPars -align.h -arith.c -arith.h -asm.c -assert.h -atw.h -blocks.c -cemcom.1 -ch7.c -ch7bin.c -ch7mon.c -char.tab -class.h -code.c -code.str -conversion.c -cstoper.c -dataflow.c -declar.g -declar.str -declarator.c -decspecs.c -decspecs.str -def.str -domacro.c -dumpidf.c -error.c -estack.str -eval.c -expr.c -expr.str -expression.g -field.c -field.str -file_info.h -idf.c -idf.str -init.c -input.c -input.h -interface.h -ival.g -l_brace.str -l_class.h -l_comment.h -l_comment.c -l_em.h -l_ev_ord.c -l_lint.c -l_lint.h -l_misc.c -l_outdef.c -l_outdef.str -l_state.str -l_states.c -label.c -label.h -level.h -macro.str -main.c -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -mcomm.c -mes.h -options -options.c -program.g -replace.c -scan.c -sizes.h -skip.c -specials.h -stack.c -stack.str -statement.g -stb.c -stmt.str -struct.c -struct.str -switch.c -switch.str -tokenname.c -tokenname.h -type.c -type.str -util.str -util.c -stab.c diff --git a/lang/cem/cpp.ansi/.distr b/lang/cem/cpp.ansi/.distr deleted file mode 100644 index e858a9344..000000000 --- a/lang/cem/cpp.ansi/.distr +++ /dev/null @@ -1,34 +0,0 @@ -build.mk -LLlex.c -LLlex.h -LLmessage.c -parameters.h -arith.h -bits.h -ch3bin.c -ch3mon.c -char.tab -class.h -domacro.c -error.c -expr.c -expression.g -file_info.h -idf.c -idf.h -init.c -input.c -input.h -macro.str -main.c -make.allocd -make.next -make.tokcase -make.tokfile -ncpp.6 -options.c -preprocess.c -replace.c -replace.str -skip.c -tokenname.c diff --git a/lang/cem/ctest/.distr b/lang/cem/ctest/.distr deleted file mode 100644 index 4d16951b4..000000000 --- a/lang/cem/ctest/.distr +++ /dev/null @@ -1,24 +0,0 @@ -READ_ME -Out2.std -Out2.nf.std -Out4.std -Out4.nf.std -ctconv -ctdecl -ctdivers -cterr -ctest1 -ctest2 -ctest3 -ctest5 -ctgen -ctill -ctinit -ctmargt -ctprof -ctstruct -ctsys -ctsetjmp -local.h -makefile.std -run diff --git a/lang/cem/ctest/ctconv/.distr b/lang/cem/ctest/ctconv/.distr deleted file mode 100644 index 27a2e123d..000000000 --- a/lang/cem/ctest/ctconv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -conv.c -conv.cem.g -run diff --git a/lang/cem/ctest/ctdecl/.distr b/lang/cem/ctest/ctdecl/.distr deleted file mode 100644 index 91583322f..000000000 --- a/lang/cem/ctest/ctdecl/.distr +++ /dev/null @@ -1,3 +0,0 @@ -decl.c -decl.cem.g -run diff --git a/lang/cem/ctest/ctdivers/.distr b/lang/cem/ctest/ctdivers/.distr deleted file mode 100644 index fd657769c..000000000 --- a/lang/cem/ctest/ctdivers/.distr +++ /dev/null @@ -1,3 +0,0 @@ -ops.c -ops.cem.g -run diff --git a/lang/cem/ctest/cterr/.distr b/lang/cem/ctest/cterr/.distr deleted file mode 100644 index e70e0e390..000000000 --- a/lang/cem/ctest/cterr/.distr +++ /dev/null @@ -1,3 +0,0 @@ -bugs.c -bugs.cem.g -run diff --git a/lang/cem/ctest/ctest1/.distr b/lang/cem/ctest/ctest1/.distr deleted file mode 100644 index bd848c069..000000000 --- a/lang/cem/ctest/ctest1/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -test.c -test.cem.g diff --git a/lang/cem/ctest/ctest2/.distr b/lang/cem/ctest/ctest2/.distr deleted file mode 100644 index 4bfd3f775..000000000 --- a/lang/cem/ctest/ctest2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -t7.c -t7.cem.g diff --git a/lang/cem/ctest/ctest3/.distr b/lang/cem/ctest/ctest3/.distr deleted file mode 100644 index 116b88196..000000000 --- a/lang/cem/ctest/ctest3/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -test2.c -test2.cem.g diff --git a/lang/cem/ctest/ctest5/.distr b/lang/cem/ctest/ctest5/.distr deleted file mode 100644 index d9c45d565..000000000 --- a/lang/cem/ctest/ctest5/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -test1.c -test1.cem.g diff --git a/lang/cem/ctest/ctgen/.distr b/lang/cem/ctest/ctgen/.distr deleted file mode 100644 index 224da4cb7..000000000 --- a/lang/cem/ctest/ctgen/.distr +++ /dev/null @@ -1,37 +0,0 @@ -OPS -bf.cem.g -bf.sed -bfu.cem.g -bfu.sed -cel.cem.g -cel.sed -clu.cem.g -clu.sed -ec.cem.g -ec.sed -ef.cem.g -ef.sed -ei.cem.g -ei.sed -el.cem.g -el.sed -eu.cem.g -eu.sed -id.cem.g -id.sed -lc.cem.g -lc.sed -ld.cem.g -ld.sed -lf.cem.g -lf.sed -li.cem.g -li.sed -ll.cem.g -ll.sed -lu.cem.g -lu.sed -makefile -mkc -run -run1 diff --git a/lang/cem/ctest/ctill/.distr b/lang/cem/ctest/ctill/.distr deleted file mode 100644 index ee4a5b9eb..000000000 --- a/lang/cem/ctest/ctill/.distr +++ /dev/null @@ -1,3 +0,0 @@ -noarg.c -noarg.cem.g -run diff --git a/lang/cem/ctest/ctinit/.distr b/lang/cem/ctest/ctinit/.distr deleted file mode 100644 index 5b5a7cb78..000000000 --- a/lang/cem/ctest/ctinit/.distr +++ /dev/null @@ -1,3 +0,0 @@ -init.c -init.cem.g -run diff --git a/lang/cem/ctest/ctmargt/.distr b/lang/cem/ctest/ctmargt/.distr deleted file mode 100644 index 7565930b0..000000000 --- a/lang/cem/ctest/ctmargt/.distr +++ /dev/null @@ -1,3 +0,0 @@ -margt.c -margt.cem.g -run diff --git a/lang/cem/ctest/ctprof/.distr b/lang/cem/ctest/ctprof/.distr deleted file mode 100644 index da82c143d..000000000 --- a/lang/cem/ctest/ctprof/.distr +++ /dev/null @@ -1,5 +0,0 @@ -makefile -procentry.c -run -tp.c -tp.cem.g diff --git a/lang/cem/ctest/ctsetjmp/.distr b/lang/cem/ctest/ctsetjmp/.distr deleted file mode 100644 index 4c0526736..000000000 --- a/lang/cem/ctest/ctsetjmp/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -stjmp.c -stjmp.cem.g diff --git a/lang/cem/ctest/ctstruct/.distr b/lang/cem/ctest/ctstruct/.distr deleted file mode 100644 index 3f25919f1..000000000 --- a/lang/cem/ctest/ctstruct/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -str.c -str.cem.g diff --git a/lang/cem/ctest/ctsys/.distr b/lang/cem/ctest/ctsys/.distr deleted file mode 100644 index ca4fdc76a..000000000 --- a/lang/cem/ctest/ctsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -run -signal.c -tfork.c -tfork.cem.g diff --git a/lang/cem/libcc.ansi/.distr b/lang/cem/libcc.ansi/.distr deleted file mode 100644 index cc07e6720..000000000 --- a/lang/cem/libcc.ansi/.distr +++ /dev/null @@ -1,15 +0,0 @@ -build.mk -head_ac.e -assert -ctype -errno -headers -locale -math -misc -setjmp -signal -stdio -stdlib -string -time diff --git a/lang/cem/libcc.ansi/assert/.distr b/lang/cem/libcc.ansi/assert/.distr deleted file mode 100644 index 87515cc41..000000000 --- a/lang/cem/libcc.ansi/assert/.distr +++ /dev/null @@ -1 +0,0 @@ -assert.c diff --git a/lang/cem/libcc.ansi/ctype/.distr b/lang/cem/libcc.ansi/ctype/.distr deleted file mode 100644 index 63a07fcf4..000000000 --- a/lang/cem/libcc.ansi/ctype/.distr +++ /dev/null @@ -1,4 +0,0 @@ -toupper.c -tolower.c -char.tab -genfiles diff --git a/lang/cem/libcc.ansi/errno/.distr b/lang/cem/libcc.ansi/errno/.distr deleted file mode 100644 index fd69e9793..000000000 --- a/lang/cem/libcc.ansi/errno/.distr +++ /dev/null @@ -1 +0,0 @@ -errlist.c diff --git a/lang/cem/libcc.ansi/headers/.distr b/lang/cem/libcc.ansi/headers/.distr deleted file mode 100644 index 22ee8d0c4..000000000 --- a/lang/cem/libcc.ansi/headers/.distr +++ /dev/null @@ -1,23 +0,0 @@ -sys/time.h -sys/ioctl.h -assert.h -ctype.h -errno.h -float.h -limits.h -math.h -setjmp.h -signal.h -stdarg.h -stddef.h -stdint.h -stdio.h -stdlib.h -string.h -time.h -iso646.h -stdbool.h -fcntl.h -tgmath.h -locale.h -malloc.h diff --git a/lang/cem/libcc.ansi/headers/sys/.distr b/lang/cem/libcc.ansi/headers/sys/.distr deleted file mode 100644 index c2d82be22..000000000 --- a/lang/cem/libcc.ansi/headers/sys/.distr +++ /dev/null @@ -1,2 +0,0 @@ -dirent.h -errno.h diff --git a/lang/cem/libcc.ansi/locale/.distr b/lang/cem/libcc.ansi/locale/.distr deleted file mode 100644 index 6ec7d31e6..000000000 --- a/lang/cem/libcc.ansi/locale/.distr +++ /dev/null @@ -1,2 +0,0 @@ -localeconv.c -setlocale.c diff --git a/lang/cem/libcc.ansi/math/.distr b/lang/cem/libcc.ansi/math/.distr deleted file mode 100644 index 39e542930..000000000 --- a/lang/cem/libcc.ansi/math/.distr +++ /dev/null @@ -1,22 +0,0 @@ -asin.c -atan.c -atan2.c -ceil.c -exp.c -fabs.c -floor.c -fmod.c -frexp.e -hugeval.c -ldexp.c -localmath.h -log.c -log10.c -modf.e -pow.c -sin.c -sinh.c -sqrt.c -tan.c -tanh.c -isnan.c diff --git a/lang/cem/libcc.ansi/misc/.distr b/lang/cem/libcc.ansi/misc/.distr deleted file mode 100644 index db3c72199..000000000 --- a/lang/cem/libcc.ansi/misc/.distr +++ /dev/null @@ -1 +0,0 @@ -environ.c diff --git a/lang/cem/libcc.ansi/setjmp/.distr b/lang/cem/libcc.ansi/setjmp/.distr deleted file mode 100644 index 305ef0b22..000000000 --- a/lang/cem/libcc.ansi/setjmp/.distr +++ /dev/null @@ -1 +0,0 @@ -setjmp.e diff --git a/lang/cem/libcc.ansi/signal/.distr b/lang/cem/libcc.ansi/signal/.distr deleted file mode 100644 index ff77f128d..000000000 --- a/lang/cem/libcc.ansi/signal/.distr +++ /dev/null @@ -1 +0,0 @@ -raise.c diff --git a/lang/cem/libcc.ansi/stdio/.distr b/lang/cem/libcc.ansi/stdio/.distr deleted file mode 100644 index 4206946e7..000000000 --- a/lang/cem/libcc.ansi/stdio/.distr +++ /dev/null @@ -1,51 +0,0 @@ -clearerr.c -data.c -doprnt.c -doscan.c -ecvt.c -fclose.c -feof.c -ferror.c -fflush.c -fgetc.c -fgetpos.c -fgets.c -fileno.c -fillbuf.c -fltpr.c -flushbuf.c -fopen.c -fprintf.c -fputc.c -fputs.c -fread.c -freopen.c -fscanf.c -fseek.c -fsetpos.c -ftell.c -fwrite.c -getc.c -getchar.c -gets.c -icompute.c -loc_incl.h -perror.c -printf.c -putc.c -putchar.c -puts.c -rewind.c -scanf.c -setbuf.c -setvbuf.c -snprintf.c -sprintf.c -sscanf.c -tmpfile.c -tmpnam.c -ungetc.c -vfprintf.c -vprintf.c -vsprintf.c -vsnprintf.c diff --git a/lang/cem/libcc.ansi/stdlib/.distr b/lang/cem/libcc.ansi/stdlib/.distr deleted file mode 100644 index dd4a54186..000000000 --- a/lang/cem/libcc.ansi/stdlib/.distr +++ /dev/null @@ -1,26 +0,0 @@ -abort.c -abs.c -atexit.c -atof.c -atoi.c -atol.c -bsearch.c -div.c -exit.c -ext_comp.c -ext_fmt.h -getenv.c -labs.c -ldiv.c -mblen.c -mbstowcs.c -mbtowc.c -qsort.c -rand.c -setenv.c -strtod.c -strtol.c -system.c -wcstombs.c -wctomb.c -malloc diff --git a/lang/cem/libcc.ansi/string/.distr b/lang/cem/libcc.ansi/string/.distr deleted file mode 100644 index ef6a1164e..000000000 --- a/lang/cem/libcc.ansi/string/.distr +++ /dev/null @@ -1,23 +0,0 @@ -memchr.c -memcmp.c -memcpy.c -memmove.c -memset.c -strcat.c -strchr.c -strcmp.c -strcoll.c -strcpy.c -strcspn.c -strdup.c -strerror.c -strlen.c -strncat.c -strncmp.c -strncpy.c -strpbrk.c -strrchr.c -strspn.c -strstr.c -strtok.c -strxfrm.c diff --git a/lang/cem/libcc.ansi/time/.distr b/lang/cem/libcc.ansi/time/.distr deleted file mode 100644 index b53265c96..000000000 --- a/lang/cem/libcc.ansi/time/.distr +++ /dev/null @@ -1,12 +0,0 @@ -asctime.c -clock.c -ctime.c -difftime.c -gmtime.c -loc_time.h -localtime.c -misc.c -mktime.c -strftime.c -time.c -tzset.c diff --git a/lang/cem/libcc/.distr b/lang/cem/libcc/.distr deleted file mode 100644 index dea372b8f..000000000 --- a/lang/cem/libcc/.distr +++ /dev/null @@ -1,6 +0,0 @@ -build.mk -gen -headers -math -mon -stdio diff --git a/lang/cem/libcc/gen/.distr b/lang/cem/libcc/gen/.distr deleted file mode 100644 index b834f7890..000000000 --- a/lang/cem/libcc/gen/.distr +++ /dev/null @@ -1,75 +0,0 @@ -build.mk -head_cc.e -abs.c -atof.c -strtod.c -atoi.c -atol.c -strtol.c -bcmp.c -bfill.c -bmove.c -bzero.c -calloc.c -crypt.c -ctime.c -asctime.c -execvp.c -ffc.c -ffs.c -gcvt.c -ecvt.c -ext_comp.c -getlogin.c -index.c -l3.c -ldexp.c -localtime.c -gmtime.c -memccpy.c -memchr.c -memcmp.c -memcpy.c -memset.c -mktemp.c -monitor.c -perror.c -procentry.c -qsort.c -bsearch.c -rand.c -seekdir.c -sleep.c -stb.c -strstr.c -strchr.c -strcmp.c -strcspn.c -strncat.c -strrchr.c -strtok.c -strpbrk.c -strspn.c -swab.c -telldir.c -ttyslot.c -rindex.c -strncmp.c -ttyname.c -closedir.c -isatty.c -opendir.c -malloc.c -bcopy.c -readdir.c -strcat.c -strcpy.c -strlen.c -tzset.c -getenv.c -strncpy.c -_c2type.c -abort.e -frexp.e -modf.e -setjmp.e diff --git a/lang/cem/libcc/headers/.distr b/lang/cem/libcc/headers/.distr deleted file mode 100644 index a415c0dd7..000000000 --- a/lang/cem/libcc/headers/.distr +++ /dev/null @@ -1,19 +0,0 @@ -assert.h -ctype.h -errno.h -fcntl.h -grp.h -math.h -pwd.h -setjmp.h -sgtty.h -signal.h -stdio.h -time.h -varargs.h -sys/dir.h -sys/errno.h -sys/stat.h -sys/stdtypes.h -sys/types.h -sys/timeb.h diff --git a/lang/cem/libcc/math/.distr b/lang/cem/libcc/math/.distr deleted file mode 100644 index e9ee68785..000000000 --- a/lang/cem/libcc/math/.distr +++ /dev/null @@ -1,21 +0,0 @@ -build.mk -asin.c -atan2.c -atan.c -ceil.c -fabs.c -gamma.c -hypot.c -jn.c -j0.c -j1.c -log10.c -pow.c -log.c -sin.c -sinh.c -sqrt.c -tan.c -tanh.c -exp.c -floor.c diff --git a/lang/cem/libcc/mon/.distr b/lang/cem/libcc/mon/.distr deleted file mode 100644 index 7312104df..000000000 --- a/lang/cem/libcc/mon/.distr +++ /dev/null @@ -1,92 +0,0 @@ -build.mk -exit.c -gtty.c -signal.c -stty.c -tell.c -time.c -cleanup.c -access.e -acct.e -alarm.e -brk.e -chdir.e -chmod.e -chown.e -chroot.e -close.e -creat.e -dup.e -dup2.e -execl.e -execle.e -execv.e -execve.e -fork.e -fstat.e -ftime.e -getegid.e -geteuid.e -getgid.e -getpid.e -getuid.e -ioctl.e -kill.e -link.e -lock.e -lseek.e -mknod.e -mount.e -mpxcall.e -nice.e -open.e -pause.e -pipe.e -prof.e -ptrace.e -read.e -sbrk.e -setgid.e -setuid.e -setsig.e -sigtrp.e -stat.e -stime.e -sync.e -times.e -umask.e -umount.e -unlink.e -utime.e -wait.e -write.e -errno.e -_alarm.e -_brk.e -_close.e -_creat.e -_dup.e -_dup2.e -_execl.e -_execve.e -_exit.e -_fork.e -_fstat.e -_ftime.e -_getpid.e -_gtty.c -_stty.c -_ioctl.e -_kill.e -_link.e -_lseek.e -_open.e -_pause.e -_pipe.e -_read.e -_sbrk.e -_times.e -_unlink.e -_wait.e -_write.e -types diff --git a/lang/cem/libcc/stdio/.distr b/lang/cem/libcc/stdio/.distr deleted file mode 100644 index fceca8663..000000000 --- a/lang/cem/libcc/stdio/.distr +++ /dev/null @@ -1,48 +0,0 @@ -build.mk -vsprintf.c -vfprintf.c -vprintf.c -termcap.c -getopt.c -clearerr.c -fgetc.c -fgets.c -fprintf.c -fputc.c -fputs.c -fread.c -freopen.c -fscanf.c -ftell.c -fwrite.c -getchar.c -getgrent.c -getpass.c -getpw.c -fopen.c -getpwent.c -gets.c -getw.c -popen.c -fdopen.c -printf.c -putchar.c -puts.c -putw.c -rewind.c -fseek.c -scanf.c -setbuf.c -sprintf.c -doprnt.c -fltpr.c -flushbuf.c -fclose.c -data.c -fflush.c -sscanf.c -doscan.c -fillbuf.c -system.c -timezone.c -ungetc.c diff --git a/lang/cem/lint/.distr b/lang/cem/lint/.distr deleted file mode 100644 index 937488f69..000000000 --- a/lang/cem/lint/.distr +++ /dev/null @@ -1,6 +0,0 @@ -README -llib -lpass1 -lpass1.ansi -lpass2 -proto.make diff --git a/lang/cem/lint/llib/.distr b/lang/cem/lint/llib/.distr deleted file mode 100644 index 77008f041..000000000 --- a/lang/cem/lint/llib/.distr +++ /dev/null @@ -1,9 +0,0 @@ -ChangeLog -README -proto.make -c.llb -ansi_c.llb -curses.llb -m.llb -termlib.llb -unix7.c diff --git a/lang/cem/lint/lpass1.ansi/.distr b/lang/cem/lint/lpass1.ansi/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/lang/cem/lint/lpass1.ansi/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/lang/cem/lint/lpass1/.distr b/lang/cem/lint/lpass1/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/lang/cem/lint/lpass1/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/lang/cem/lint/lpass2/.distr b/lang/cem/lint/lpass2/.distr deleted file mode 100644 index 1936f79b6..000000000 --- a/lang/cem/lint/lpass2/.distr +++ /dev/null @@ -1,13 +0,0 @@ -ChangeLog -proto.make -checkargs.c -class.c -class.h -inpdef.str -l_print3ack.c -lint -lint.1 -lpass2.c -private.h -read.c -report.c diff --git a/lang/fortran/.distr b/lang/fortran/.distr deleted file mode 100644 index a9f8e4fd8..000000000 --- a/lang/fortran/.distr +++ /dev/null @@ -1,7 +0,0 @@ -changes -comp -disclaimer -fc -fixes -index -lib diff --git a/lang/fortran/comp/.distr b/lang/fortran/comp/.distr deleted file mode 100644 index 0c4266d77..000000000 --- a/lang/fortran/comp/.distr +++ /dev/null @@ -1,61 +0,0 @@ -Notice -README -cds.c -data.c -defines.h -defs.h -equiv.c -error.c -exec.c -expr.c -f2c.1 -f2c.1t -f2c.6 -f2c.h -format.c -format.h -formatdata.c -ftypes.h -gram.dcl -gram.exec -gram.expr -gram.head -gram.io -init.c -intr.c -io.c -iob.h -lex.c -machdefs.h -main.c -makefile -malloc.c -mem.c -memset.c -misc.c -names.c -names.h -niceprintf.c -niceprintf.h -output.c -output.h -p1defs.h -p1output.c -parse.h -parse_args.c -pccdefs.h -pread.c -proc.c -proto.make -put.c -putpcc.c -string.h -sysdep.c -sysdep.h -tokens -usignal.h -vax.c -version.c -xsum.c -xsum0.out -mk_tokdefs diff --git a/lang/fortran/lib/.distr b/lang/fortran/lib/.distr deleted file mode 100644 index 254dfd229..000000000 --- a/lang/fortran/lib/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libF77 -libI77 diff --git a/lang/fortran/lib/libF77/.distr b/lang/fortran/lib/libF77/.distr deleted file mode 100644 index 555cf9635..000000000 --- a/lang/fortran/lib/libF77/.distr +++ /dev/null @@ -1,118 +0,0 @@ -LIST -Notice -README -Version.c -abort_.c -c_abs.c -c_cos.c -c_div.c -c_exp.c -c_log.c -c_sin.c -c_sqrt.c -cabs.c -d_abs.c -d_acos.c -d_asin.c -d_atan.c -d_atn2.c -d_cnjg.c -d_cos.c -d_cosh.c -d_dim.c -d_exp.c -d_imag.c -d_int.c -d_lg10.c -d_log.c -d_mod.c -d_nint.c -d_prod.c -d_sign.c -d_sin.c -d_sinh.c -d_sqrt.c -d_tan.c -d_tanh.c -derf_.c -derfc_.c -ef1asc_.c -ef1cmc_.c -erf_.c -erfc_.c -getarg_.c -getenv_.c -h_abs.c -h_dim.c -h_dnnt.c -h_indx.c -h_len.c -h_mod.c -h_nint.c -h_sign.c -hl_ge.c -hl_gt.c -hl_le.c -hl_lt.c -i_abs.c -i_dim.c -i_dnnt.c -i_indx.c -i_len.c -i_mod.c -i_nint.c -i_sign.c -iargc_.c -l_ge.c -l_gt.c -l_le.c -l_lt.c -libF77.xsum -main.c -makefile -pow_ci.c -pow_dd.c -pow_di.c -pow_hh.c -pow_ii.c -pow_ri.c -pow_zi.c -pow_zz.c -r_abs.c -r_acos.c -r_asin.c -r_atan.c -r_atn2.c -r_cnjg.c -r_cos.c -r_cosh.c -r_dim.c -r_exp.c -r_imag.c -r_int.c -r_lg10.c -r_log.c -r_mod.c -r_nint.c -r_sign.c -r_sin.c -r_sinh.c -r_sqrt.c -r_tan.c -r_tanh.c -s_cat.c -s_cmp.c -s_copy.c -s_paus.c -s_rnge.c -s_stop.c -sig_die.c -signal_.c -system_.c -z_abs.c -z_cos.c -z_div.c -z_exp.c -z_log.c -z_sin.c -z_sqrt.c diff --git a/lang/fortran/lib/libI77/.distr b/lang/fortran/lib/libI77/.distr deleted file mode 100644 index 866b3077f..000000000 --- a/lang/fortran/lib/libI77/.distr +++ /dev/null @@ -1,42 +0,0 @@ -LIST -Notice -README -Version.c -backspace.c -close.c -dfe.c -dolio.c -due.c -endfile.c -err.c -fio.h -fmt.c -fmt.h -fmtlib.c -fp.h -iio.c -ilnw.c -inquire.c -libI77.xsum -lio.h -local.h -lread.c -lwrite.c -makefile -open.c -rdfmt.c -rewind.c -rsfe.c -rsli.c -rsne.c -sfe.c -sue.c -typesize.c -uio.c -util.c -wref.c -wrtfmt.c -wsfe.c -wsle.c -wsne.c -xwsne.c diff --git a/lang/m2/.distr b/lang/m2/.distr deleted file mode 100644 index ef717ff3c..000000000 --- a/lang/m2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -build.mk -comp -libm2 diff --git a/lang/m2/comp/.distr b/lang/m2/comp/.distr deleted file mode 100644 index bae10e61a..000000000 --- a/lang/m2/comp/.distr +++ /dev/null @@ -1,61 +0,0 @@ -build.mk -LLlex.c -LLlex.h -LLmessage.c -BigPars -SmallPars -SYSTEM.h -casestat.C -char.tab -chk_expr.c -chk_expr.h -class.h -code.c -cstoper.c -debug.h -declar.g -def.H -def.c -defmodule.c -desig.c -desig.h -em_m2.6 -enter.c -error.c -expression.g -f_info.h -idf.c -idf.h -input.c -input.h -lookup.c -main.c -main.h -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -misc.c -misc.h -modula-2.1 -node.H -node.c -options.c -options -program.g -real.H -scope.C -scope.h -stab.c -standards.h -statement.g -tmpvar.C -tokenname.c -tokenname.h -type.H -type.c -typequiv.c -walk.c -walk.h -warning.h diff --git a/lang/m2/libm2/.distr b/lang/m2/libm2/.distr deleted file mode 100644 index f7df21a12..000000000 --- a/lang/m2/libm2/.distr +++ /dev/null @@ -1,74 +0,0 @@ -build.mk -Termcap.mod -CSP.mod -PascalIO.mod -RealInOut.mod -InOut.mod -Streams.mod -Terminal.mod -MathLib0.mod -Mathlib.mod -Processes.mod -RealConver.mod -Storage.mod -Conversion.mod -Semaphores.mod -random.mod -Strings.mod -ArraySort.mod -catch.c -Traps.mod -XXTermcap.c -dvi.c -Arguments.c -LtoUset.e -StrAss.c -cap.c -absd.c -absf.e -absi.c -absl.c -halt.c -SYSTEM.c -par_misc.e -init.c -sigtrp.c -store.c -confarray.c -load.c -blockmove.c -stackprio.c -ucheck.c -rcka.c -rcku.c -rcki.c -rckul.c -rckil.c -EM.e -ASCII.def -Arguments.def -Conversion.def -EM.def -PascalIO.def -InOut.def -Mathlib.def -MathLib0.def -Processes.def -RealInOut.def -RealConver.def -Semaphores.def -Storage.def -Strings.def -Terminal.def -Unix.def -head_m2.e -random.def -Traps.def -CSP.def -Epilogue.def -Streams.def -ArraySort.def -StripUnix.def -Termcap.def -XXTermcap.def -proto.make diff --git a/lang/m2/m2mm/.distr b/lang/m2/m2mm/.distr deleted file mode 100644 index 3a8bc4308..000000000 --- a/lang/m2/m2mm/.distr +++ /dev/null @@ -1,30 +0,0 @@ -LLlex.c -LLlex.h -LLmessage.c -proto.make -proto.main -char.tab -class.h -declar.g -error.c -expression.g -f_info.h -file_list.h -idf.c -idf.h -idfsize.h -input.c -input.h -inputtype.h -lib.c -m2mm.1 -main.c -main.h -make.tokcase -make.tokfile -misc.c -options.c -program.g -statement.g -tokenname.c -tokenname.h diff --git a/lang/m2/test/.distr b/lang/m2/test/.distr deleted file mode 100644 index 35e4dd24b..000000000 --- a/lang/m2/test/.distr +++ /dev/null @@ -1,5 +0,0 @@ -Thalmann -Wirth -getenv.mod -m2p.mod -queens.mod diff --git a/lang/m2/test/Thalmann/.distr b/lang/m2/test/Thalmann/.distr deleted file mode 100644 index f76368222..000000000 --- a/lang/m2/test/Thalmann/.distr +++ /dev/null @@ -1,5 +0,0 @@ -LifeGame.mod -Shoes.mod -StoreFetch.mod -bold.mod -characters.mod diff --git a/lang/m2/test/Wirth/.distr b/lang/m2/test/Wirth/.distr deleted file mode 100644 index 7f345b414..000000000 --- a/lang/m2/test/Wirth/.distr +++ /dev/null @@ -1,4 +0,0 @@ -PowersOf2.mod -TableHandl.def -TableHandl.mod -XREF.mod diff --git a/lang/occam/.distr b/lang/occam/.distr deleted file mode 100644 index 216c0a94d..000000000 --- a/lang/occam/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -comp -lib -test -headers diff --git a/lang/occam/comp/.distr b/lang/occam/comp/.distr deleted file mode 100644 index d5cc91854..000000000 --- a/lang/occam/comp/.distr +++ /dev/null @@ -1,16 +0,0 @@ -build.mk -builtin.c -code.c -code.h -em.c -expr.c -expr.h -keytab.c -lex.l -occam.g -report.c -sizes.h -symtab.c -symtab.h -token.h -occam-em.h \ No newline at end of file diff --git a/lang/occam/headers/.distr b/lang/occam/headers/.distr deleted file mode 100644 index c5db45ffa..000000000 --- a/lang/occam/headers/.distr +++ /dev/null @@ -1,3 +0,0 @@ -dec.ocm -printd.ocm -prints.ocm diff --git a/lang/occam/lib/.distr b/lang/occam/lib/.distr deleted file mode 100644 index b5d4c6d50..000000000 --- a/lang/occam/lib/.distr +++ /dev/null @@ -1,11 +0,0 @@ -build.mk -builtin.c -chan_strct.c -channel.c -co.c -now.c -par.c -parco.c -misc.e -ocrt.c -par_misc.e diff --git a/lang/occam/test/.distr b/lang/occam/test/.distr deleted file mode 100644 index 6180270d7..000000000 --- a/lang/occam/test/.distr +++ /dev/null @@ -1,11 +0,0 @@ -Makefile -Huffman.ocm -READ_ME -aatob.ocm -copy.ocm -key.ocm -lifegame.ocm -matmul.ocm -sort.ocm -use_prnt.ocm -xxtoy.ocm diff --git a/lang/pc/.distr b/lang/pc/.distr deleted file mode 100644 index 8de02b7d5..000000000 --- a/lang/pc/.distr +++ /dev/null @@ -1,3 +0,0 @@ -build.mk -libpc -comp diff --git a/lang/pc/comp/.distr b/lang/pc/comp/.distr deleted file mode 100644 index 827326d8c..000000000 --- a/lang/pc/comp/.distr +++ /dev/null @@ -1,58 +0,0 @@ -build.mk -LLlex.c -LLlex.h -LLmessage.c -Parameters -body.c -casestat.C -char.tab -chk_expr.c -chk_expr.h -class.h -code.c -const.h -cstoper.c -debug.h -declar.g -def.H -def.c -desig.H -desig.c -em_pc.6 -enter.c -error.c -expression.g -f_info.h -idf.c -idf.h -input.c -input.h -label.c -lookup.c -main.c -main.h -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -misc.c -misc.h -node.H -node.c -options -options.c -program.g -progs.c -readwrite.c -required.h -scope.H -scope.c -stab.c -statement.g -tmpvar.C -tokenname.c -tokenname.h -type.H -type.c -typequiv.c diff --git a/lang/pc/libpc/.distr b/lang/pc/libpc/.distr deleted file mode 100644 index 7cbba6326..000000000 --- a/lang/pc/libpc/.distr +++ /dev/null @@ -1,75 +0,0 @@ -build.mk -abi.c -abl.c -abr.c -arg.c -ass.c -asz.c -atn.c -bcp.c -bts.e -buff.c -clock.c -diag.c -dis.c -efl.c -eln.c -encaps.e -exp.c -get.c -gto.e -hlt.c -ini.c -catch.c -log.c -mdi.c -mdl.c -new.c -nobuff.c -notext.c -opn.c -hol0.e -pac.c -pclose.c -pcreat.c -pentry.c -perrno.c -pexit.c -popen.c -cls.c -put.c -rdc.c -rdl.c -rdr.c -rdi.c -rln.c -rf.c -rnd.c -sav.e -sig.e -sin.c -sqt.c -fef.e -string.c -trap.e -unp.c -uread.c -uwrite.c -wdw.c -incpt.c -wrc.c -wrf.c -wri.c -wrl.c -wrr.c -cvt.c -fif.e -wrz.c -wrs.c -outcpt.c -wf.c -nfa.c -rcka.c -trp.e -READ_ME -head_pc.e diff --git a/lang/pc/test/.distr b/lang/pc/test/.distr deleted file mode 100644 index 69d9c4981..000000000 --- a/lang/pc/test/.distr +++ /dev/null @@ -1,12 +0,0 @@ -Makefile -b.p -machar.p -t1.p -t2.p -t3.p -t4.p -t5.p -tstenc.p -tstgto.p -callc.p -cmod.c diff --git a/lib/.distr b/lib/.distr deleted file mode 100644 index 84032cfa4..000000000 --- a/lib/.distr +++ /dev/null @@ -1,31 +0,0 @@ -6500 -6800 -6805 -6809 -arm -descr -i80 -i86 -i386 -em22 -em24 -em44 -m68020 -m68k2 -m68k4 -mantra -minix -minixST -ns -pdp -pmds -pmds4 -s2650 -sun2 -sun3 -vax4 -xenix3 -z80 -z8000 -sparc -sparc_solaris diff --git a/lib/6500/.distr b/lib/6500/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6500/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/6800/.distr b/lib/6800/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6800/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/6805/.distr b/lib/6805/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6805/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/6809/.distr b/lib/6809/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6809/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/arm/.distr b/lib/arm/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/arm/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/descr/.distr b/lib/descr/.distr deleted file mode 100644 index a75b251a3..000000000 --- a/lib/descr/.distr +++ /dev/null @@ -1,2 +0,0 @@ -fe -cpm diff --git a/lib/em22/.distr b/lib/em22/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/em22/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/em24/.distr b/lib/em24/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/em24/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/em44/.distr b/lib/em44/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/em44/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/i386/.distr b/lib/i386/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/i386/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/i80/.distr b/lib/i80/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/i80/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/i86/.distr b/lib/i86/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/i86/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/m68020/.distr b/lib/m68020/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/m68020/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/m68k2/.distr b/lib/m68k2/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/m68k2/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/m68k4/.distr b/lib/m68k4/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/m68k4/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/mantra/.distr b/lib/mantra/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/mantra/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/minix/.distr b/lib/minix/.distr deleted file mode 100644 index a4c54f9c6..000000000 --- a/lib/minix/.distr +++ /dev/null @@ -1,2 +0,0 @@ -descr -include diff --git a/lib/minix/include/.distr b/lib/minix/include/.distr deleted file mode 100644 index b5ad15f97..000000000 --- a/lib/minix/include/.distr +++ /dev/null @@ -1,13 +0,0 @@ -ansi.h -fcntl.h -limits.h -lib.h -errno.h -minix -sgtty.h -signal.h -string.h -time.h -utime.h -unistd.h -sys diff --git a/lib/minix/include/minix/.distr b/lib/minix/include/minix/.distr deleted file mode 100644 index 144062138..000000000 --- a/lib/minix/include/minix/.distr +++ /dev/null @@ -1,5 +0,0 @@ -config.h -callnr.h -com.h -const.h -type.h diff --git a/lib/minix/include/sys/.distr b/lib/minix/include/sys/.distr deleted file mode 100644 index 2781e7784..000000000 --- a/lib/minix/include/sys/.distr +++ /dev/null @@ -1,5 +0,0 @@ -times.h -wait.h -types.h -stat.h -errno.h diff --git a/lib/minixST/.distr b/lib/minixST/.distr deleted file mode 100644 index a4c54f9c6..000000000 --- a/lib/minixST/.distr +++ /dev/null @@ -1,2 +0,0 @@ -descr -include diff --git a/lib/minixST/include/.distr b/lib/minixST/include/.distr deleted file mode 100644 index bdeac18ea..000000000 --- a/lib/minixST/include/.distr +++ /dev/null @@ -1,2 +0,0 @@ -a.out.h -minix diff --git a/lib/minixST/include/minix/.distr b/lib/minixST/include/minix/.distr deleted file mode 100644 index 0e56cf2f8..000000000 --- a/lib/minixST/include/minix/.distr +++ /dev/null @@ -1 +0,0 @@ -config.h diff --git a/lib/ns/.distr b/lib/ns/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/ns/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/pdp/.distr b/lib/pdp/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/pdp/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/pmds/.distr b/lib/pmds/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/pmds/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/pmds4/.distr b/lib/pmds4/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/pmds4/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/s2650/.distr b/lib/s2650/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/s2650/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sparc/.distr b/lib/sparc/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sparc/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sparc_solaris/.distr b/lib/sparc_solaris/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sparc_solaris/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sun2/.distr b/lib/sun2/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sun2/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sun3/.distr b/lib/sun3/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sun3/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/vax4/.distr b/lib/vax4/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/vax4/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/xenix3/.distr b/lib/xenix3/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/xenix3/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/z80/.distr b/lib/z80/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/z80/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/z8000/.distr b/lib/z8000/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/z8000/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/mach/.distr b/mach/.distr deleted file mode 100644 index d2137b302..000000000 --- a/mach/.distr +++ /dev/null @@ -1,33 +0,0 @@ -6500 -6800 -6805 -6809 -arm -i80 -con_float -i86 -i386 -em22 -em24 -em44 -m68k2 -m68k4 -m68020 -mantra -minix -minixST -ns -pdp -pmds -pmds4 -proto -s2650 -sun3 -sun2 -vax4 -vc4 -xenix3 -z80 -z8000 -sparc -sparc_solaris diff --git a/mach/6500/.distr b/mach/6500/.distr deleted file mode 100644 index 4f6acc11d..000000000 --- a/mach/6500/.distr +++ /dev/null @@ -1,8 +0,0 @@ -Action -as -cg -dl -libem -libend -libmon -mach_params diff --git a/mach/6500/as/.distr b/mach/6500/as/.distr deleted file mode 100644 index d139683f8..000000000 --- a/mach/6500/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -READ_ME -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6500/cg/.distr b/mach/6500/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/6500/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/6500/dl/.distr b/mach/6500/dl/.distr deleted file mode 100644 index f838529b7..000000000 --- a/mach/6500/dl/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -dl.c diff --git a/mach/6500/libem/.distr b/mach/6500/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/6500/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/6500/libend/.distr b/mach/6500/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/6500/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/6500/libmon/.distr b/mach/6500/libmon/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/6500/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/6800/.distr b/mach/6800/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/6800/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/6800/as/.distr b/mach/6800/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/6800/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6805/.distr b/mach/6805/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/6805/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/6805/as/.distr b/mach/6805/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/6805/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6809/.distr b/mach/6809/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/6809/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/6809/as/.distr b/mach/6809/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/6809/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/arm/.distr b/mach/arm/.distr deleted file mode 100644 index ea3b4ee55..000000000 --- a/mach/arm/.distr +++ /dev/null @@ -1,11 +0,0 @@ -Action -READ_ME -as -cv -ncg -top -libem -libfp -libend -libmon -mach_params diff --git a/mach/arm/as/.distr b/mach/arm/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/arm/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/arm/cv/.distr b/mach/arm/cv/.distr deleted file mode 100644 index 457480833..000000000 --- a/mach/arm/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -arm.h -cv.c diff --git a/mach/arm/libem/.distr b/mach/arm/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/arm/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/arm/libend/.distr b/mach/arm/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/arm/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/arm/libfp/.distr b/mach/arm/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/arm/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/arm/libmon/.distr b/mach/arm/libmon/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/arm/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/arm/ncg/.distr b/mach/arm/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/arm/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/arm/top/.distr b/mach/arm/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/arm/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/em22/.distr b/mach/em22/.distr deleted file mode 100644 index cdd423d7f..000000000 --- a/mach/em22/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libend -mach_params diff --git a/mach/em22/libend/.distr b/mach/em22/libend/.distr deleted file mode 100644 index 2519bac51..000000000 --- a/mach/em22/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_e.a diff --git a/mach/em24/.distr b/mach/em24/.distr deleted file mode 100644 index cdd423d7f..000000000 --- a/mach/em24/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libend -mach_params diff --git a/mach/em24/libend/.distr b/mach/em24/libend/.distr deleted file mode 100644 index 2519bac51..000000000 --- a/mach/em24/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_e.a diff --git a/mach/em44/.distr b/mach/em44/.distr deleted file mode 100644 index cdd423d7f..000000000 --- a/mach/em44/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libend -mach_params diff --git a/mach/em44/libend/.distr b/mach/em44/libend/.distr deleted file mode 100644 index 2519bac51..000000000 --- a/mach/em44/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_e.a diff --git a/mach/i386/.distr b/mach/i386/.distr deleted file mode 100644 index 38864464f..000000000 --- a/mach/i386/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -as -ncg -libem -libend diff --git a/mach/i386/as/.distr b/mach/i386/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/i386/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/i386/ce/.distr b/mach/i386/ce/.distr deleted file mode 100644 index de050f836..000000000 --- a/mach/i386/ce/.distr +++ /dev/null @@ -1,7 +0,0 @@ -EM_table -proto.make -as.c -as.h -as_table -mach.c -mach.h diff --git a/mach/i386/cv/.distr b/mach/i386/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/i386/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/i386/libdb/.distr b/mach/i386/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/i386/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/i386/libem/.distr b/mach/i386/libem/.distr deleted file mode 100644 index c5bb0fc80..000000000 --- a/mach/i386/libem/.distr +++ /dev/null @@ -1,44 +0,0 @@ -adi.s -and.s -blm.s -cii.s -cms.s -com.s -csa4.s -csb4.s -cuu.s -dup.s -dvi.s -dvu.s -error.s -exg.s -fat.s -fp8087.s -gto.s -iaar.s -ilar.s -inn.s -ior.s -isar.s -lar4.s -loi.s -mli.s -mon.s -ngi.s -nop.s -print.s -rck.s -rmi.s -rmu.s -rol.s -ror.s -sar4.s -sbi.s -set.s -sli.s -sri.s -sti.s -strhp.s -trp.s -unknown.s -xor.s diff --git a/mach/i386/libend/.distr b/mach/i386/libend/.distr deleted file mode 100644 index afa027b6e..000000000 --- a/mach/i386/libend/.distr +++ /dev/null @@ -1,4 +0,0 @@ -edata.s -em_end.s -end.s -etext.s diff --git a/mach/i386/libfp/.distr b/mach/i386/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/i386/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/i386/libsys/.distr b/mach/i386/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/i386/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/i386/ncg/.distr b/mach/i386/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/i386/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/i80/.distr b/mach/i80/.distr deleted file mode 100644 index fb68ed554..000000000 --- a/mach/i80/.distr +++ /dev/null @@ -1,6 +0,0 @@ -build.mk -as -top -ncg -libem -libend diff --git a/mach/i80/as/.distr b/mach/i80/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/i80/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/i80/dl/.distr b/mach/i80/dl/.distr deleted file mode 100644 index c1d697e3d..000000000 --- a/mach/i80/dl/.distr +++ /dev/null @@ -1,4 +0,0 @@ -proto.make -README -mccpm.c -nascom.c diff --git a/mach/i80/libem/.distr b/mach/i80/libem/.distr deleted file mode 100644 index 8856d843f..000000000 --- a/mach/i80/libem/.distr +++ /dev/null @@ -1,37 +0,0 @@ -aar2.s -adi4.s -and.s -blm.s -cii.s -cmi4.s -cms.s -com.s -csa.s -csb.s -dup.s -dvi2.s -dvi4.s -exg.s -flp.s -inn.s -ior.s -lar2.s -loi.s -mli2.s -mli4.s -mlu2.s -ngi4.s -nop.s -rck.s -rol4.s -ror4.s -sar2.s -sbi4.s -set2.s -set.s -sli2.s -sli4.s -sri2.s -sri4.s -sti.s -xor.s diff --git a/mach/i80/libend/.distr b/mach/i80/libend/.distr deleted file mode 100644 index afa027b6e..000000000 --- a/mach/i80/libend/.distr +++ /dev/null @@ -1,4 +0,0 @@ -edata.s -em_end.s -end.s -etext.s diff --git a/mach/i80/libmon/.distr b/mach/i80/libmon/.distr deleted file mode 100644 index 90063c137..000000000 --- a/mach/i80/libmon/.distr +++ /dev/null @@ -1,5 +0,0 @@ -LIST -README -libmon_s.a -char.nas.s -head_em.s diff --git a/mach/i80/ncg/.distr b/mach/i80/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/i80/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/i80/top/.distr b/mach/i80/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/i80/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/i86/.distr b/mach/i86/.distr deleted file mode 100644 index 38864464f..000000000 --- a/mach/i86/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -as -ncg -libem -libend diff --git a/mach/i86/as/.distr b/mach/i86/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/i86/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/i86/ce/.distr b/mach/i86/ce/.distr deleted file mode 100644 index 813bb6922..000000000 --- a/mach/i86/ce/.distr +++ /dev/null @@ -1,7 +0,0 @@ -EM_table -as.c -as.h -as_table -mach.c -mach.h -proto.make diff --git a/mach/i86/cv/.distr b/mach/i86/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/i86/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/i86/libem/.distr b/mach/i86/libem/.distr deleted file mode 100644 index 0d2cf9e4b..000000000 --- a/mach/i86/libem/.distr +++ /dev/null @@ -1,59 +0,0 @@ -adi.s -and.s -cii.s -cms.s -cmi4.s -cmu4.s -com.s -csa2.s -csb2.s -csa4.s -csb4.s -cuu.s -dup.s -dvi.s -dvi4.s -dvu.s -dvu4.s -exg.s -fp8087.s -gto.s -iaar.s -ilar.s -inn.s -ior.s -isar.s -lar2.s -loi.s -mli.s -mli4.s -mon.s -ngi.s -nop.s -rck.s -rmi.s -rmi4.s -rmu.s -rmu4.s -rol.s -ror.s -sar2.s -sbi.s -set.s -sli.s -sri.s -sti.s -strhp.s -xor.s -error.s -unknown.s -fat.s -trp.s -print.s -ret6.s -ret8.s -lfr6.s -lfr8.s -retarea.s -blm.s -return.s diff --git a/mach/i86/libend/.distr b/mach/i86/libend/.distr deleted file mode 100644 index afa027b6e..000000000 --- a/mach/i86/libend/.distr +++ /dev/null @@ -1,4 +0,0 @@ -edata.s -em_end.s -end.s -etext.s diff --git a/mach/i86/libfp/.distr b/mach/i86/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/i86/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/i86/libsys/.distr b/mach/i86/libsys/.distr deleted file mode 100644 index 5f4d84d7d..000000000 --- a/mach/i86/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libmon_s.a -head_em.s diff --git a/mach/i86/ncg/.distr b/mach/i86/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/i86/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/m68020/.distr b/mach/m68020/.distr deleted file mode 100644 index 38864464f..000000000 --- a/mach/m68020/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -as -ncg -libem -libend diff --git a/mach/m68020/as/.distr b/mach/m68020/as/.distr deleted file mode 100644 index ff35f2bd0..000000000 --- a/mach/m68020/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c -Expect diff --git a/mach/m68020/ce/.distr b/mach/m68020/ce/.distr deleted file mode 100644 index f2261a886..000000000 --- a/mach/m68020/ce/.distr +++ /dev/null @@ -1,7 +0,0 @@ -proto.make -as_table -mach.c -mach.h -as.c -as.h -EM_table diff --git a/mach/m68020/cv/.distr b/mach/m68020/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/m68020/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/m68020/libdb/.distr b/mach/m68020/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/m68020/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/m68020/libem/.distr b/mach/m68020/libem/.distr deleted file mode 100644 index 43a4003c4..000000000 --- a/mach/m68020/libem/.distr +++ /dev/null @@ -1,25 +0,0 @@ -aar.s -cii.s -cmi.s -cms.s -cmu.s -csa.s -csb.s -cuu.s -cvf.s -dia.s -exg.s -fat.s -fp68881.s -inn.s -lar.s -los.s -mon.s -nop.s -pmfile -sar.s -set.s -shp.s -sts.s -trp.s -trpstr.c diff --git a/mach/m68020/libend/.distr b/mach/m68020/libend/.distr deleted file mode 100644 index afa027b6e..000000000 --- a/mach/m68020/libend/.distr +++ /dev/null @@ -1,4 +0,0 @@ -edata.s -em_end.s -end.s -etext.s diff --git a/mach/m68020/libfp/.distr b/mach/m68020/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/m68020/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/m68020/libsys/.distr b/mach/m68020/libsys/.distr deleted file mode 100644 index 1e8ac2ce6..000000000 --- a/mach/m68020/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -README -head_em.s -libmon_s.a diff --git a/mach/m68020/ncg/.distr b/mach/m68020/ncg/.distr deleted file mode 100644 index 67ed469fd..000000000 --- a/mach/m68020/ncg/.distr +++ /dev/null @@ -1,6 +0,0 @@ -README -mach.c -mach.h -table -whichone.h -instrmacs.h diff --git a/mach/m68020/top/.distr b/mach/m68020/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/m68020/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/m68k2/.distr b/mach/m68k2/.distr deleted file mode 100644 index 7d818f74d..000000000 --- a/mach/m68k2/.distr +++ /dev/null @@ -1,13 +0,0 @@ -Action -README -Unisoft_bug -as -ncg -cv -dl -libem -libend -libsys -top -libfp -mach_params diff --git a/mach/m68k2/as/.distr b/mach/m68k2/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/m68k2/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/m68k2/cv/.distr b/mach/m68k2/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/m68k2/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/m68k2/dl/.distr b/mach/m68k2/dl/.distr deleted file mode 100644 index f838529b7..000000000 --- a/mach/m68k2/dl/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -dl.c diff --git a/mach/m68k2/libem/.distr b/mach/m68k2/libem/.distr deleted file mode 100644 index 82a73034b..000000000 --- a/mach/m68k2/libem/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libem_s.a -READ_ME diff --git a/mach/m68k2/libend/.distr b/mach/m68k2/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/m68k2/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/m68k2/libfp/.distr b/mach/m68k2/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/m68k2/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/m68k2/libsys/.distr b/mach/m68k2/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/m68k2/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/m68k2/ncg/.distr b/mach/m68k2/ncg/.distr deleted file mode 100644 index 052914faf..000000000 --- a/mach/m68k2/ncg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -table_dir -whichone.h diff --git a/mach/m68k2/top/.distr b/mach/m68k2/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/m68k2/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/m68k4/.distr b/mach/m68k4/.distr deleted file mode 100644 index 87d1405a0..000000000 --- a/mach/m68k4/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -ncg -libem -libend -libfp -libsys -mach_params diff --git a/mach/m68k4/libem/.distr b/mach/m68k4/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/m68k4/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/m68k4/libend/.distr b/mach/m68k4/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/m68k4/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/m68k4/libfp/.distr b/mach/m68k4/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/m68k4/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/m68k4/libsys/.distr b/mach/m68k4/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/m68k4/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/m68k4/ncg/.distr b/mach/m68k4/ncg/.distr deleted file mode 100644 index 052914faf..000000000 --- a/mach/m68k4/ncg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -table_dir -whichone.h diff --git a/mach/mantra/.distr b/mach/mantra/.distr deleted file mode 100644 index 4ef816f4f..000000000 --- a/mach/mantra/.distr +++ /dev/null @@ -1,5 +0,0 @@ -Action -libsys -cv -int -mach_params diff --git a/mach/mantra/cv/.distr b/mach/mantra/cv/.distr deleted file mode 100644 index 5598b65a7..000000000 --- a/mach/mantra/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -Xcv.c -cv.c diff --git a/mach/mantra/int/.distr b/mach/mantra/int/.distr deleted file mode 100644 index 5f80d6561..000000000 --- a/mach/mantra/int/.distr +++ /dev/null @@ -1,19 +0,0 @@ -copyright -deffile -em.c -em.1 -proto.make -mloop0 -mloop1 -mloop2 -mloop3 -mloop4 -mloop5 -mloop6 -mloop7 -mloop8 -mloop9 -mloopa -mloopb -mloopc -con_float.c diff --git a/mach/mantra/libsys/.distr b/mach/mantra/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/mantra/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/minix/.distr b/mach/minix/.distr deleted file mode 100644 index 83f8debe0..000000000 --- a/mach/minix/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libsys -mach_params diff --git a/mach/minix/libsys/.distr b/mach/minix/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/minix/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/minixST/.distr b/mach/minixST/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/minixST/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/minixST/cv/.distr b/mach/minixST/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/minixST/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/minixST/libsys/.distr b/mach/minixST/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/minixST/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/moon3/ncg/.distr b/mach/moon3/ncg/.distr deleted file mode 100644 index 052914faf..000000000 --- a/mach/moon3/ncg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -table_dir -whichone.h diff --git a/mach/ns/.distr b/mach/ns/.distr deleted file mode 100644 index 8d2e3f04d..000000000 --- a/mach/ns/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -as -ncg -libem -libend -libmon -mach_params diff --git a/mach/ns/as/.distr b/mach/ns/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/ns/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/ns/libem/.distr b/mach/ns/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/ns/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/ns/libend/.distr b/mach/ns/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/ns/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/ns/libmon/.distr b/mach/ns/libmon/.distr deleted file mode 100644 index 5f4d84d7d..000000000 --- a/mach/ns/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libmon_s.a -head_em.s diff --git a/mach/ns/ncg/.distr b/mach/ns/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/ns/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/pdp/.distr b/mach/pdp/.distr deleted file mode 100644 index 74fda7967..000000000 --- a/mach/pdp/.distr +++ /dev/null @@ -1,10 +0,0 @@ -Action -as -cg -top -cv -int -libem -libend -libsys -mach_params diff --git a/mach/pdp/as/.distr b/mach/pdp/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/pdp/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/pdp/cg/.distr b/mach/pdp/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/pdp/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/pdp/cv/.distr b/mach/pdp/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/pdp/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/pdp/int/.distr b/mach/pdp/int/.distr deleted file mode 100644 index 0193284f9..000000000 --- a/mach/pdp/int/.distr +++ /dev/null @@ -1,15 +0,0 @@ -proto.make -README -em.1 -eminform.1 -em.c -em_int.s -eminform.s -c+ -c- -f+ -f- -p+ -p- -t+ -t- diff --git a/mach/pdp/libem/.distr b/mach/pdp/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/pdp/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/pdp/libend/.distr b/mach/pdp/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/pdp/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/pdp/libsys/.distr b/mach/pdp/libsys/.distr deleted file mode 100644 index 3a76f61cf..000000000 --- a/mach/pdp/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -libmon_s.a -sys.h -head_em.s diff --git a/mach/pdp/ncg/.distr b/mach/pdp/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/pdp/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/pdp/top/.distr b/mach/pdp/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/pdp/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/pmds/.distr b/mach/pmds/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/pmds/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/pmds/cv/.distr b/mach/pmds/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/pmds/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/pmds/libsys/.distr b/mach/pmds/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/pmds/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/pmds4/.distr b/mach/pmds4/.distr deleted file mode 100644 index 83f8debe0..000000000 --- a/mach/pmds4/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libsys -mach_params diff --git a/mach/pmds4/libsys/.distr b/mach/pmds4/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/pmds4/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/powerpc/as/.distr b/mach/powerpc/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/powerpc/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/powerpc/libem/.distr b/mach/powerpc/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/powerpc/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/powerpc/libend/.distr b/mach/powerpc/libend/.distr deleted file mode 100644 index 38509e6aa..000000000 --- a/mach/powerpc/libend/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -edata.s -em_end.s -end.s -etext.s diff --git a/mach/powerpc/ncg/.distr b/mach/powerpc/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/powerpc/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/powerpc/top/.distr b/mach/powerpc/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/powerpc/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/proto/.distr b/mach/proto/.distr deleted file mode 100644 index 78c561b64..000000000 --- a/mach/proto/.distr +++ /dev/null @@ -1,4 +0,0 @@ -as -cg -ncg -top diff --git a/mach/proto/as/.distr b/mach/proto/as/.distr deleted file mode 100644 index 49642a8e8..000000000 --- a/mach/proto/as/.distr +++ /dev/null @@ -1,10 +0,0 @@ -build.mk -comm0.h -comm1.h -comm2.y -comm3.c -comm4.c -comm5.c -comm6.c -comm7.c -comm8.c diff --git a/mach/proto/cg/.distr b/mach/proto/cg/.distr deleted file mode 100644 index cf85682ac..000000000 --- a/mach/proto/cg/.distr +++ /dev/null @@ -1,25 +0,0 @@ -assert.h -codegen.c -compute.c -data.h -equiv.c -equiv.h -extern.h -fillem.c -gencode.c -glosym.c -glosym.h -main.c -move.c -nextem.c -param.h -reg.c -regvar.c -regvar.h -result.h -salloc.c -state.c -state.h -subr.c -types.h -var.c diff --git a/mach/proto/fp/.distr b/mach/proto/fp/.distr deleted file mode 100644 index 512283b1e..000000000 --- a/mach/proto/fp/.distr +++ /dev/null @@ -1,44 +0,0 @@ -FP.script -FP_bias.h -FP_shift.h -FP_trap.h -FP_types.h -add_ext.c -adder.c -adf4.c -adf8.c -cff4.c -cff8.c -cfi.c -cfu.c -cif4.c -cif8.c -cmf4.c -cmf8.c -compact.c -cuf4.c -cuf8.c -div_ext.c -dvf4.c -dvf8.c -extend.c -fef4.c -fef8.c -fif4.c -fif8.c -fptrp.e -get_put.h -mlf4.c -mlf8.c -mul_ext.c -ngf4.c -ngf8.c -nrm_ext.c -sbf4.c -sbf8.c -sft_ext.c -shifter.c -sub_ext.c -zrf4.c -zrf8.c -zrf_ext.c diff --git a/mach/proto/grind/.distr b/mach/proto/grind/.distr deleted file mode 100644 index b57d195b7..000000000 --- a/mach/proto/grind/.distr +++ /dev/null @@ -1,4 +0,0 @@ -READ_ME -atlin.c -lib.e -par_misc.e diff --git a/mach/proto/libg/.distr b/mach/proto/libg/.distr deleted file mode 100644 index e411a18b0..000000000 --- a/mach/proto/libg/.distr +++ /dev/null @@ -1,17 +0,0 @@ -barrier.c -proto.libbc -proto.libfp -proto.libdb -proto.libpc -proto.libcc -proto.libm2 -proto.libf77 -proto.libsys -proto.sysmon -proto.libcc.ansi -proto.libmon -proto.libem -proto.libend -proto.liboc -proto.make -compmodule diff --git a/mach/proto/ncg/.distr b/mach/proto/ncg/.distr deleted file mode 100644 index 59ffc4a45..000000000 --- a/mach/proto/ncg/.distr +++ /dev/null @@ -1,28 +0,0 @@ -build.mk -assert.h -codegen.c -compute.c -data.h -equiv.c -equiv.h -extern.h -fillem.c -gencode.c -glosym.c -glosym.h -label.c -label.h -main.c -move.c -nextem.c -param.h -reg.c -regvar.c -regvar.h -result.h -salloc.c -state.c -state.h -subr.c -types.h -var.c diff --git a/mach/proto/top/.distr b/mach/proto/top/.distr deleted file mode 100644 index 6563cbe48..000000000 --- a/mach/proto/top/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -queue.c -queue.h -top.c -top.h diff --git a/mach/s2650/.distr b/mach/s2650/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/s2650/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/s2650/as/.distr b/mach/s2650/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/s2650/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/sparc/.distr b/mach/sparc/.distr deleted file mode 100644 index 154fc06cb..000000000 --- a/mach/sparc/.distr +++ /dev/null @@ -1,9 +0,0 @@ -Action -mach_params -ce -ce_cg -top -libem -libsys -libend -libdb diff --git a/mach/sparc/ce/.distr b/mach/sparc/ce/.distr deleted file mode 100644 index bb33187f0..000000000 --- a/mach/sparc/ce/.distr +++ /dev/null @@ -1,15 +0,0 @@ -EM_table -EM_table.x -Makefile -back.src -cache.c -cache.c.x -ce.src -cegpp -mach.c -mach.h -mach_em.h -misc.h -ms_reg.h -proto.make -push_pop.h diff --git a/mach/sparc/ce/back.src/.distr b/mach/sparc/ce/back.src/.distr deleted file mode 100644 index abd59b90e..000000000 --- a/mach/sparc/ce/back.src/.distr +++ /dev/null @@ -1,9 +0,0 @@ -Makefile -back.h -con_str.c -const.h -do_open.c -gen_str.c -header.h -rom_str.c -symboldef.c diff --git a/mach/sparc/ce/ce.src/.distr b/mach/sparc/ce/ce.src/.distr deleted file mode 100644 index b264bf3a7..000000000 --- a/mach/sparc/ce/ce.src/.distr +++ /dev/null @@ -1,14 +0,0 @@ -C_con_scon.c -C_cst.c -C_dlb.c -C_dnam.c -C_ilb.c -C_mes_begin.c -C_mes_end.c -C_pnam.c -C_rom_scon.c -C_scon.c -C_pro.c -C_exa_dnam.c -misc.c -ms_reg.c diff --git a/mach/sparc/ce_cg/.distr b/mach/sparc/ce_cg/.distr deleted file mode 100644 index c9c9751db..000000000 --- a/mach/sparc/ce_cg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -convert.c -proto.make diff --git a/mach/sparc/libdb/.distr b/mach/sparc/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/sparc/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/sparc/libem/.distr b/mach/sparc/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/sparc/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/sparc/libend/.distr b/mach/sparc/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/sparc/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/sparc/libsys/.distr b/mach/sparc/libsys/.distr deleted file mode 100644 index 930a523fd..000000000 --- a/mach/sparc/libsys/.distr +++ /dev/null @@ -1,5 +0,0 @@ -LIST -libmon_s.a -head_em.s -SYS.h -syscall.h diff --git a/mach/sparc/top/.distr b/mach/sparc/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/sparc/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/sparc_solaris/.distr b/mach/sparc_solaris/.distr deleted file mode 100644 index 99e11b974..000000000 --- a/mach/sparc_solaris/.distr +++ /dev/null @@ -1,8 +0,0 @@ -Action -ce -ce_cg -libdb -libem -libend -libsys -mach_params diff --git a/mach/sparc_solaris/ce/.distr b/mach/sparc_solaris/ce/.distr deleted file mode 100644 index cafc23097..000000000 --- a/mach/sparc_solaris/ce/.distr +++ /dev/null @@ -1 +0,0 @@ -proto.make diff --git a/mach/sparc_solaris/ce_cg/.distr b/mach/sparc_solaris/ce_cg/.distr deleted file mode 100644 index cafc23097..000000000 --- a/mach/sparc_solaris/ce_cg/.distr +++ /dev/null @@ -1 +0,0 @@ -proto.make diff --git a/mach/sparc_solaris/libdb/.distr b/mach/sparc_solaris/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/sparc_solaris/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/sparc_solaris/libem/.distr b/mach/sparc_solaris/libem/.distr deleted file mode 100644 index 52c8084b9..000000000 --- a/mach/sparc_solaris/libem/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -libem_s.a -READ_ME -Makefile diff --git a/mach/sparc_solaris/libend/.distr b/mach/sparc_solaris/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/sparc_solaris/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/sparc_solaris/libsys/.distr b/mach/sparc_solaris/libsys/.distr deleted file mode 100644 index 0a68a588d..000000000 --- a/mach/sparc_solaris/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -libmon_s.a -head_em.s -SYS.h diff --git a/mach/sun2/.distr b/mach/sun2/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/sun2/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/sun2/cv/.distr b/mach/sun2/cv/.distr deleted file mode 100644 index cafc23097..000000000 --- a/mach/sun2/cv/.distr +++ /dev/null @@ -1 +0,0 @@ -proto.make diff --git a/mach/sun2/libsys/.distr b/mach/sun2/libsys/.distr deleted file mode 100644 index 52a9f74e4..000000000 --- a/mach/sun2/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -head_em.s -libmon_s.a -syscall.h diff --git a/mach/sun3/.distr b/mach/sun3/.distr deleted file mode 100644 index a1f6171f7..000000000 --- a/mach/sun3/.distr +++ /dev/null @@ -1,6 +0,0 @@ -Action -cv -libsys -ce -libce -mach_params diff --git a/mach/sun3/ce/.distr b/mach/sun3/ce/.distr deleted file mode 100644 index 34f604f30..000000000 --- a/mach/sun3/ce/.distr +++ /dev/null @@ -1,14 +0,0 @@ -EM_table -Make.back -proto.make -as.c -as.h -as_table -do_close.c -do_open.c -end_back.c -mach.c -mach.h -misc.c -output.c -relocation.c diff --git a/mach/sun3/cv/.distr b/mach/sun3/cv/.distr deleted file mode 100644 index 1ea8d092c..000000000 --- a/mach/sun3/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -cv.c -Xcv.c diff --git a/mach/sun3/liba68s/.distr b/mach/sun3/liba68s/.distr deleted file mode 100644 index 37100a8aa..000000000 --- a/mach/sun3/liba68s/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -compmodule diff --git a/mach/sun3/libce/.distr b/mach/sun3/libce/.distr deleted file mode 100644 index cb69c33b0..000000000 --- a/mach/sun3/libce/.distr +++ /dev/null @@ -1,23 +0,0 @@ -proto.make -adf4.s -adf8.s -cff.s -cfi.s -cfu.s -cif.s -cmf4.s -cmf8.s -cuf.s -dvf4.s -dvf8.s -fef4.s -fef8.s -fif4.s -fif8.s -mlf4.s -mlf8.s -sbf4.s -sbf8.s -vars.s -sys.s -head_em.s diff --git a/mach/sun3/libsys/.distr b/mach/sun3/libsys/.distr deleted file mode 100644 index 52a9f74e4..000000000 --- a/mach/sun3/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -head_em.s -libmon_s.a -syscall.h diff --git a/mach/vax4/.distr b/mach/vax4/.distr deleted file mode 100644 index 8eedeeff4..000000000 --- a/mach/vax4/.distr +++ /dev/null @@ -1,14 +0,0 @@ -Action -as -cg -libem -libce -libend -libbsd4_1a -libbsd4_2 -libsysV_2 -libdb -top -ce -cv -mach_params diff --git a/mach/vax4/as/.distr b/mach/vax4/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/vax4/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/vax4/ce/.distr b/mach/vax4/ce/.distr deleted file mode 100644 index e5974f654..000000000 --- a/mach/vax4/ce/.distr +++ /dev/null @@ -1,13 +0,0 @@ -EM_table -Make.back -proto.make -as.c -as.h -as_table -do_close.c -do_open.c -end_back.c -mach.c -mach.h -output.c -relocation.c diff --git a/mach/vax4/cg/.distr b/mach/vax4/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/vax4/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/vax4/cv/.distr b/mach/vax4/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/vax4/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/vax4/libbsd4_1a/.distr b/mach/vax4/libbsd4_1a/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/vax4/libbsd4_1a/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/vax4/libbsd4_2/.distr b/mach/vax4/libbsd4_2/.distr deleted file mode 100644 index 52a9f74e4..000000000 --- a/mach/vax4/libbsd4_2/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -head_em.s -libmon_s.a -syscall.h diff --git a/mach/vax4/libce/.distr b/mach/vax4/libce/.distr deleted file mode 100644 index a24fc2610..000000000 --- a/mach/vax4/libce/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -sys.s diff --git a/mach/vax4/libdb/.distr b/mach/vax4/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/vax4/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/vax4/libem/.distr b/mach/vax4/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/vax4/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/vax4/libend/.distr b/mach/vax4/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/vax4/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/vax4/libsysV_2/.distr b/mach/vax4/libsysV_2/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/vax4/libsysV_2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/vax4/top/.distr b/mach/vax4/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/vax4/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/vc4/.distr b/mach/vc4/.distr deleted file mode 100644 index 38864464f..000000000 --- a/mach/vc4/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -as -ncg -libem -libend diff --git a/mach/vc4/as/.distr b/mach/vc4/as/.distr deleted file mode 100644 index 6ef7a1516..000000000 --- a/mach/vc4/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c -binary.h diff --git a/mach/vc4/libem/.distr b/mach/vc4/libem/.distr deleted file mode 100644 index 5dff9f5ac..000000000 --- a/mach/vc4/libem/.distr +++ /dev/null @@ -1,3 +0,0 @@ -csa.s -csb.s -videocore.h diff --git a/mach/vc4/libend/.distr b/mach/vc4/libend/.distr deleted file mode 100644 index afa027b6e..000000000 --- a/mach/vc4/libend/.distr +++ /dev/null @@ -1,4 +0,0 @@ -edata.s -em_end.s -end.s -etext.s diff --git a/mach/vc4/ncg/.distr b/mach/vc4/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/vc4/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/xenix3/.distr b/mach/xenix3/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/xenix3/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/xenix3/cv/.distr b/mach/xenix3/cv/.distr deleted file mode 100644 index bf760c7ee..000000000 --- a/mach/xenix3/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -cv.c -chstack.c -proto.make diff --git a/mach/xenix3/libsys/.distr b/mach/xenix3/libsys/.distr deleted file mode 100644 index 5f4d84d7d..000000000 --- a/mach/xenix3/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libmon_s.a -head_em.s diff --git a/mach/z80/.distr b/mach/z80/.distr deleted file mode 100644 index 8e820e454..000000000 --- a/mach/z80/.distr +++ /dev/null @@ -1,8 +0,0 @@ -Action -as -cg -int -libem -libend -libmon -mach_params diff --git a/mach/z80/as/.distr b/mach/z80/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/z80/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/z80/cg/.distr b/mach/z80/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/z80/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/z80/int/.distr b/mach/z80/int/.distr deleted file mode 100644 index d59fdf593..000000000 --- a/mach/z80/int/.distr +++ /dev/null @@ -1,13 +0,0 @@ -proto.make -READ_ME -atof.s -cv.c -dl.c -dosort -dvi4.s -dvu4.s -eb.s -em.s -fpp.s -em22 -mli4.s diff --git a/mach/z80/libem/.distr b/mach/z80/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/z80/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/z80/libend/.distr b/mach/z80/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/z80/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/z80/libmon/.distr b/mach/z80/libmon/.distr deleted file mode 100644 index 4580c5cd4..000000000 --- a/mach/z80/libmon/.distr +++ /dev/null @@ -1,8 +0,0 @@ -README -LIST -libmon_s.a -char.her.s -head_em.s -mon.cpm.s -mon.s -char.nas.s diff --git a/mach/z80/libsys/.distr b/mach/z80/libsys/.distr deleted file mode 100644 index 4580c5cd4..000000000 --- a/mach/z80/libsys/.distr +++ /dev/null @@ -1,8 +0,0 @@ -README -LIST -libmon_s.a -char.her.s -head_em.s -mon.cpm.s -mon.s -char.nas.s diff --git a/mach/z80/top/.distr b/mach/z80/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/z80/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/z8000/.distr b/mach/z8000/.distr deleted file mode 100644 index 1d705d670..000000000 --- a/mach/z8000/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -as -cg -libem -libend -libmon -mach_params diff --git a/mach/z8000/as/.distr b/mach/z8000/as/.distr deleted file mode 100644 index ec89e8dd1..000000000 --- a/mach/z8000/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -README -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/z8000/cg/.distr b/mach/z8000/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/z8000/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/z8000/libem/.distr b/mach/z8000/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/z8000/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/z8000/libend/.distr b/mach/z8000/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/z8000/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/z8000/libmon/.distr b/mach/z8000/libmon/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/z8000/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/man/.distr b/man/.distr deleted file mode 100644 index 4e52c6c32..000000000 --- a/man/.distr +++ /dev/null @@ -1,13 +0,0 @@ -i80_as.6 -i86_as.6 -i386_as.6 -m68020_as.6 -vc4_as.6 -z80_as.6 -em_cg.6 -em_ncg.6 -libmon.7 -libpc.7 -head -pc_prlib.7 -uni_ass.6 diff --git a/modules/.distr b/modules/.distr deleted file mode 100644 index e5c549d70..000000000 --- a/modules/.distr +++ /dev/null @@ -1,2 +0,0 @@ -src -h diff --git a/modules/h/.distr b/modules/h/.distr deleted file mode 100644 index a365a15ef..000000000 --- a/modules/h/.distr +++ /dev/null @@ -1,10 +0,0 @@ -ansi.h -em.h -em_arith.h -em_code.h -em_label.h -#em_codeCE.h -#emO_code.h -em_mesX.h -#em_codeO.h -#proto.make diff --git a/modules/src/.distr b/modules/src/.distr deleted file mode 100644 index c22f4c010..000000000 --- a/modules/src/.distr +++ /dev/null @@ -1,16 +0,0 @@ -Action -Action.lint -alloc -assert -em_code -em_mes -em_opt -flt_arith -idf -input -malloc -object -print -read_em -string -system diff --git a/modules/src/Xmalloc/.distr b/modules/src/Xmalloc/.distr deleted file mode 100644 index 228eaa800..000000000 --- a/modules/src/Xmalloc/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Xmalloc.c diff --git a/modules/src/alloc/.distr b/modules/src/alloc/.distr deleted file mode 100644 index 5e32a9ab6..000000000 --- a/modules/src/alloc/.distr +++ /dev/null @@ -1,12 +0,0 @@ -build.mk -Malloc.c -Srealloc.c -Realloc.c -Salloc.c -alloc.3 -alloc.h -botch.c -clear.c -st_alloc.c -std_alloc.c -No_Mem.c diff --git a/modules/src/assert/.distr b/modules/src/assert/.distr deleted file mode 100644 index 8d1e1d31f..000000000 --- a/modules/src/assert/.distr +++ /dev/null @@ -1,3 +0,0 @@ -BadAssert.c -assert.3 -assert.h diff --git a/modules/src/em_code/.distr b/modules/src/em_code/.distr deleted file mode 100644 index fa1a4b160..000000000 --- a/modules/src/em_code/.distr +++ /dev/null @@ -1,58 +0,0 @@ -build.mk -C_out.c -bhcst.c -bhdlb.c -bhdnam.c -bhfcon.c -bhicon.c -bhilb.c -bhpnam.c -bhucon.c -convert.c -crcst.c -crdlb.c -crdnam.c -crxcon.c -crilb.c -crpnam.c -crscon.c -cst.c -dfdlb.c -dfdnam.c -dfilb.c -dlb.c -dnam.c -em.c -em.nogen -em_private.h -end.c -endarg.c -exc.c -failed.c -fcon.c -getid.c -icon.c -ilb.c -insert.c -insert.h -internerr.c -make.em.gen -make.sh -msend.c -msstart.c -op.c -opcst.c -opdlb.c -opdnam.c -opilb.c -opnarg.c -oppnam.c -pnam.c -pro.c -pronarg.c -psdlb.c -psdnam.c -pspnam.c -scon.c -ucon.c -em_code.3X diff --git a/modules/src/em_data/.distr b/modules/src/em_data/.distr deleted file mode 100644 index aaddd8677..000000000 --- a/modules/src/em_data/.distr +++ /dev/null @@ -1,3 +0,0 @@ -build.mk -em_ptyp.c -new_table diff --git a/modules/src/em_mes/.distr b/modules/src/em_mes/.distr deleted file mode 100644 index ca0b69dd8..000000000 --- a/modules/src/em_mes/.distr +++ /dev/null @@ -1,14 +0,0 @@ -build.mk -C_ms_com.c -C_ms_ego.c -C_ms_emx.c -C_ms_err.c -C_ms_flt.c -C_ms_gto.c -C_ms_opt.c -C_ms_par.c -C_ms_reg.c -C_ms_src.c -C_ms_std.c -C_ms_stb.c -em_mes.3 diff --git a/modules/src/em_opt/.distr b/modules/src/em_opt/.distr deleted file mode 100644 index d11f07afd..000000000 --- a/modules/src/em_opt/.distr +++ /dev/null @@ -1,19 +0,0 @@ -proto.make -aux.c -em_nopt.6 -em_opt.3 -findworst.c -initlex.c -main.c -makefuns.awk -mkstrct.c -nopt.c -nopt.h -outcalls.c -outputdfa.c -parser.g -parser.h -patterns -pseudo.r -syntax.l -em_codeO.h diff --git a/modules/src/flt_arith/.distr b/modules/src/flt_arith/.distr deleted file mode 100644 index c4a1363d4..000000000 --- a/modules/src/flt_arith/.distr +++ /dev/null @@ -1,20 +0,0 @@ -build.mk -b64_add.c -b64_sft.c -flt_add.c -flt_arith.h -flt_ar2flt.c -flt_chk.c -flt_cmp.c -flt_div.c -flt_flt2ar.c -flt_modf.c -flt_mul.c -flt_nrm.c -flt_str2fl.c -flt_umin.c -flt_misc.h -ucmp.c -split.c -flt_arith.3 -test.c diff --git a/modules/src/idf/.distr b/modules/src/idf/.distr deleted file mode 100644 index 39d43902d..000000000 --- a/modules/src/idf/.distr +++ /dev/null @@ -1,4 +0,0 @@ -build.mk -idf.3 -idf_pkg.body -idf_pkg.spec diff --git a/modules/src/input/.distr b/modules/src/input/.distr deleted file mode 100644 index 282567634..000000000 --- a/modules/src/input/.distr +++ /dev/null @@ -1,6 +0,0 @@ -build.mk -AtEoIF.c -AtEoIT.c -inp_pkg.body -inp_pkg.spec -input.3 diff --git a/modules/src/malloc/.distr b/modules/src/malloc/.distr deleted file mode 100644 index f2d23b8a6..000000000 --- a/modules/src/malloc/.distr +++ /dev/null @@ -1,15 +0,0 @@ -proto.make -READ_ME -add_file -check.c -check.h -getsize.c -global.c -impl.h -log.c -log.h -mal.c -param.h -phys.c -phys.h -size_type.h diff --git a/modules/src/object/.distr b/modules/src/object/.distr deleted file mode 100644 index 27bc19a3e..000000000 --- a/modules/src/object/.distr +++ /dev/null @@ -1,18 +0,0 @@ -build.mk -object.3 -object.h -obj.h -rd.c -rd_arhdr.c -rd_bytes.c -rd_int2.c -rd_long.c -rd_ranlib.c -rd_unsig2.c -wr.c -wr_arhdr.c -wr_bytes.c -wr_int2.c -wr_long.c -wr_putc.c -wr_ranlib.c diff --git a/modules/src/print/.distr b/modules/src/print/.distr deleted file mode 100644 index ae84adbeb..000000000 --- a/modules/src/print/.distr +++ /dev/null @@ -1,9 +0,0 @@ -build.mk -doprnt.c -format.c -fprint.c -param.h -print.3 -print.c -print.h -sprint.c diff --git a/modules/src/read_em/.distr b/modules/src/read_em/.distr deleted file mode 100644 index 10e7531e0..000000000 --- a/modules/src/read_em/.distr +++ /dev/null @@ -1,11 +0,0 @@ -build.mk -EM_vars.c -argtype -em_comp.h -m_C_mnem -m_C_mnem_na -mkcalls.c -read_em.3 -read_em.c -reade.c -readk.c diff --git a/modules/src/string/.distr b/modules/src/string/.distr deleted file mode 100644 index 73292d23b..000000000 --- a/modules/src/string/.distr +++ /dev/null @@ -1,21 +0,0 @@ -build.mk -bts2str.c -btscat.c -btscmp.c -btscpy.c -btszero.c -long2str.c -str2bts.c -str2long.c -strcat.c -strcmp.c -strcpy.c -strindex.c -string.3 -strlen.c -strncat.c -strncmp.c -strncpy.c -strrindex.c -strzero.c -ack_string.h diff --git a/modules/src/system/.distr b/modules/src/system/.distr deleted file mode 100644 index 53683d833..000000000 --- a/modules/src/system/.distr +++ /dev/null @@ -1,21 +0,0 @@ -build.mk -access.c -break.c -chmode.c -close.c -create.c -filesize.c -lock.c -modtime.c -open.c -read.c -remove.c -rename.c -stop.c -system.3 -system.c -system.h -time.c -unlock.c -write.c -seek.c diff --git a/plat/.distr b/plat/.distr deleted file mode 100644 index 69538e79a..000000000 --- a/plat/.distr +++ /dev/null @@ -1,2 +0,0 @@ -build.mk - diff --git a/plat/cpm/.distr b/plat/cpm/.distr deleted file mode 100644 index 23343f43f..000000000 --- a/plat/cpm/.distr +++ /dev/null @@ -1,24 +0,0 @@ -descr -boot.s -build.mk -README -include/ack/config.h -include/unistd.h -include/cpm.h -libsys/_bdos.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/_hol0.s -libsys/_inn2.s -libsys/isatty.c -libsys/kill.c -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/signal.c -libsys/time.c -libsys/_trap.s -libsys/write.c diff --git a/plat/linux/.distr b/plat/linux/.distr deleted file mode 100644 index cd8d6878b..000000000 --- a/plat/linux/.distr +++ /dev/null @@ -1,2 +0,0 @@ -liblinux - diff --git a/plat/linux/libsys/.distr b/plat/linux/libsys/.distr deleted file mode 100644 index d5667c361..000000000 --- a/plat/linux/libsys/.distr +++ /dev/null @@ -1,20 +0,0 @@ -brk.c -build.mk -close.c -creat.c -errno.s -_exit.c -getpid.c -gettimeofday.c -_hol0.s -isatty.c -kill.c -libsys.h -lseek.c -open.c -pmfile -read.c -sbrk.c -signal.c -syscalls.h -write.c diff --git a/plat/linux386/.distr b/plat/linux386/.distr deleted file mode 100644 index ec0a7f252..000000000 --- a/plat/linux386/.distr +++ /dev/null @@ -1,8 +0,0 @@ -descr -boot.s -build.mk -README -include/sys/ioctl.h -include/ack/config.h -include/unistd.h -libsys/_syscall.s diff --git a/plat/linux68k/.distr b/plat/linux68k/.distr deleted file mode 100644 index ec0a7f252..000000000 --- a/plat/linux68k/.distr +++ /dev/null @@ -1,8 +0,0 @@ -descr -boot.s -build.mk -README -include/sys/ioctl.h -include/ack/config.h -include/unistd.h -libsys/_syscall.s diff --git a/plat/linuxppc/.distr b/plat/linuxppc/.distr deleted file mode 100644 index 7bf2c073b..000000000 --- a/plat/linuxppc/.distr +++ /dev/null @@ -1,26 +0,0 @@ -descr -boot.s -build.mk -README -include/ack/config.h -include/unistd.h -libsys/build.mk -libsys/_exit.c -libsys/_hol0.s -libsys/_syscall.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/gettimeofday.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/sbrk.c -libsys/signal.c -libsys/syscalls.h -libsys/write.c diff --git a/plat/pc86/.distr b/plat/pc86/.distr deleted file mode 100644 index bc4921680..000000000 --- a/plat/pc86/.distr +++ /dev/null @@ -1,23 +0,0 @@ -descr -boot.s -build.mk -README -include/ack/config.h -include/unistd.h -libsys/_hol0.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/signal.c -libsys/time.c -libsys/write.c -libsys/_sys_rawread.s -libsys/_sys_rawwrite.s diff --git a/plat/rpi/.distr b/plat/rpi/.distr deleted file mode 100644 index cb3527f02..000000000 --- a/plat/rpi/.distr +++ /dev/null @@ -1,32 +0,0 @@ -descr -boot.s -build.mk -README -include/ack/config.h -include/sys/select.h -include/unistd.h -include/pi.h -include/termios.h -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/_hol0.s -libsys/isatty.c -libsys/kill.c -libsys/libsysasm.h -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/pi_phys_to_user.s -libsys/pi_uart.s -libsys/pi_user_to_phys.s -libsys/pi_fast_mode.s -libsys/read.c -libsys/select.c -libsys/signal.c -libsys/tcgetattr.c -libsys/tcsetattr.c -libsys/time.c -libsys/write.c diff --git a/util/.distr b/util/.distr deleted file mode 100644 index c5957f803..000000000 --- a/util/.distr +++ /dev/null @@ -1,20 +0,0 @@ -ack -amisc -arch -ass -cgg -cmisc -cpp -data -ego -led -misc -ncgg -opt -shf -topgen -int -ceg -byacc -flex -grind diff --git a/util/LLgen/.distr b/util/LLgen/.distr deleted file mode 100644 index d9b7bfec4..000000000 --- a/util/LLgen/.distr +++ /dev/null @@ -1,26 +0,0 @@ -build.mk -src/main.c -src/gencode.c -src/compute.c -src/check.c -src/reach.c -src/global.c -src/name.c -src/sets.c -src/sets.h -src/alloc.c -src/machdep.c -src/cclass.c -src/cclass.h -src/savegram.c -src/LLgen.c -src/Lpars.c -src/Lpars.h -src/tokens.c -src/types.h -src/io.h -src/extern.h -lib/incl -lib/rec -lib/nc_incl -lib/nc_rec diff --git a/util/ack/.distr b/util/ack/.distr deleted file mode 100644 index 17fe19346..000000000 --- a/util/ack/.distr +++ /dev/null @@ -1,20 +0,0 @@ -build.mk -ack.h -data.c -data.h -dmach.h -files.c -grows.c -grows.h -list.c -list.h -main.c -mktables.c -rmach.c -run.c -scan.c -svars.c -trans.c -trans.h -util.c -ack.1.X diff --git a/util/amisc/.distr b/util/amisc/.distr deleted file mode 100644 index 7711636ff..000000000 --- a/util/amisc/.distr +++ /dev/null @@ -1,13 +0,0 @@ -build.mk -ashow.c -ashow.1 -anm.c -anm.1 -asize.c -asize.1 -astrip.c -astrip.1 -aslod.c -aslod.1 -aelflod.c -aelflod.1 \ No newline at end of file diff --git a/util/arch/.distr b/util/arch/.distr deleted file mode 100644 index e6dbd9e4e..000000000 --- a/util/arch/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -aal.1 -arch.1 -arch.5 -archiver.c diff --git a/util/ass/.distr b/util/ass/.distr deleted file mode 100644 index 0e3de02c4..000000000 --- a/util/ass/.distr +++ /dev/null @@ -1,17 +0,0 @@ -proto.make -ass00.c -ass00.h -ass30.c -ass40.c -ass50.c -ass60.c -ass70.c -ass80.c -assci.c -asscm.c -assda.c -assex.h -assrl.c -maktab.c -asprint.p -em_ass.6 diff --git a/util/byacc/.distr b/util/byacc/.distr deleted file mode 100644 index 94964ce7e..000000000 --- a/util/byacc/.distr +++ /dev/null @@ -1,19 +0,0 @@ -ACKNOWLEDGEMENTS -proto.make -NEW_FEATURES -NO_WARRANTY -README -closure.c -defs.h -error.c -lalr.c -lr0.c -main.c -manpage -mkpar.c -output.c -reader.c -skeleton.c -symtab.c -verbose.c -warshall.c diff --git a/util/ceg/.distr b/util/ceg/.distr deleted file mode 100644 index cbbd46d31..000000000 --- a/util/ceg/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -EM_parser -as_parser -assemble -ce_back -defaults -util diff --git a/util/ceg/EM_parser/.distr b/util/ceg/EM_parser/.distr deleted file mode 100644 index 8168b706b..000000000 --- a/util/ceg/EM_parser/.distr +++ /dev/null @@ -1,3 +0,0 @@ -as_EM_pars -common -obj_EM_pars diff --git a/util/ceg/EM_parser/as_EM_pars/.distr b/util/ceg/EM_parser/as_EM_pars/.distr deleted file mode 100644 index 0e2ec23a0..000000000 --- a/util/ceg/EM_parser/as_EM_pars/.distr +++ /dev/null @@ -1,6 +0,0 @@ -proto.make -arg_type.h -dist.c -em_decl.h -em_parser.h -error.c diff --git a/util/ceg/EM_parser/common/.distr b/util/ceg/EM_parser/common/.distr deleted file mode 100644 index 2c74fd389..000000000 --- a/util/ceg/EM_parser/common/.distr +++ /dev/null @@ -1,12 +0,0 @@ -C_instr2.c -proto.make -action.c -arg_type.h -decl.h -default.c -em_parser.h -eval.c -help.c -mylex.c -pars.g -scan.c diff --git a/util/ceg/EM_parser/obj_EM_pars/.distr b/util/ceg/EM_parser/obj_EM_pars/.distr deleted file mode 100644 index aa442e9e9..000000000 --- a/util/ceg/EM_parser/obj_EM_pars/.distr +++ /dev/null @@ -1,4 +0,0 @@ -proto.make -arg_type.h -dist.c -em_parser.h diff --git a/util/ceg/as_parser/.distr b/util/ceg/as_parser/.distr deleted file mode 100644 index 5e16f6278..000000000 --- a/util/ceg/as_parser/.distr +++ /dev/null @@ -1,9 +0,0 @@ -proto.make -as_parser.h -const.h -conversion.c -decl.h -eval -help.c -pars.g -table.l diff --git a/util/ceg/as_parser/eval/.distr b/util/ceg/as_parser/eval/.distr deleted file mode 100644 index 3c0c6492c..000000000 --- a/util/ceg/as_parser/eval/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -eval.c -states.h diff --git a/util/ceg/assemble/.distr b/util/ceg/assemble/.distr deleted file mode 100644 index 9fd2c817f..000000000 --- a/util/ceg/assemble/.distr +++ /dev/null @@ -1,3 +0,0 @@ -as_assemble -proto.make -obj_assemble diff --git a/util/ceg/assemble/as_assemble/.distr b/util/ceg/assemble/as_assemble/.distr deleted file mode 100644 index 0247bb1c5..000000000 --- a/util/ceg/assemble/as_assemble/.distr +++ /dev/null @@ -1,3 +0,0 @@ -READ_ME -assemble.c -block_as.c diff --git a/util/ceg/assemble/obj_assemble/.distr b/util/ceg/assemble/obj_assemble/.distr deleted file mode 100644 index 752d5be77..000000000 --- a/util/ceg/assemble/obj_assemble/.distr +++ /dev/null @@ -1,4 +0,0 @@ -READ_ME -assemble.c -block_as.c -const.h diff --git a/util/ceg/ce_back/.distr b/util/ceg/ce_back/.distr deleted file mode 100644 index 1625e2ad3..000000000 --- a/util/ceg/ce_back/.distr +++ /dev/null @@ -1,3 +0,0 @@ -as_back -obj_back -proto.make diff --git a/util/ceg/ce_back/as_back/.distr b/util/ceg/ce_back/as_back/.distr deleted file mode 100644 index fbc0bdb4e..000000000 --- a/util/ceg/ce_back/as_back/.distr +++ /dev/null @@ -1,30 +0,0 @@ -proto.make -READ_ME -back.h -bottom.c -bss.c -con1.c -con2.c -con4.c -do_close.c -do_open.c -end_back.c -gen1.c -gen2.c -gen4.c -header.h -init_back.c -reloc1.c -reloc2.c -reloc4.c -rom1.c -rom2.c -rom4.c -set_global.c -set_local.c -switchseg.c -symboldef.c -text1.c -text2.c -text4.c -dbsym.c diff --git a/util/ceg/ce_back/obj_back/.distr b/util/ceg/ce_back/obj_back/.distr deleted file mode 100644 index cd700c6ed..000000000 --- a/util/ceg/ce_back/obj_back/.distr +++ /dev/null @@ -1,36 +0,0 @@ -proto.make -READ_ME -back.h -con2.c -con4.c -data.c -data.h -do_close.c -do_open.c -end_back.c -extnd.c -gen1.c -gen2.c -gen4.c -hash.h -header.h -init_back.c -label.c -memory.c -misc.c -output.c -reloc1.c -reloc2.c -reloc4.c -relocation.c -rom2.c -rom4.c -set_global.c -set_local.c -switchseg.c -symboldef.c -symtable.c -text2.c -text4.c -common.c -dbsym.c diff --git a/util/ceg/defaults/.distr b/util/ceg/defaults/.distr deleted file mode 100644 index 9145090bf..000000000 --- a/util/ceg/defaults/.distr +++ /dev/null @@ -1,13 +0,0 @@ -proto.make -READ_ME -message -not_impl -pseudo -pseudo_vars.c -storage -m_C_mnem -m_C_mnem_na -argtype -C_out_skel.c -mk_C_out -EM_vars.c diff --git a/util/ceg/defaults/message/.distr b/util/ceg/defaults/message/.distr deleted file mode 100644 index 7b3324c63..000000000 --- a/util/ceg/defaults/message/.distr +++ /dev/null @@ -1,11 +0,0 @@ -C_cst.c -C_dlb.c -C_dnam.c -C_fcon.c -C_icon.c -C_ilb.c -C_mes_begin.c -C_mes_end.c -C_pnam.c -C_scon.c -C_ucon.c diff --git a/util/ceg/defaults/not_impl/.distr b/util/ceg/defaults/not_impl/.distr deleted file mode 100644 index f05c64e52..000000000 --- a/util/ceg/defaults/not_impl/.distr +++ /dev/null @@ -1,2 +0,0 @@ -not_impl.c -not_impl_table diff --git a/util/ceg/defaults/pseudo/.distr b/util/ceg/defaults/pseudo/.distr deleted file mode 100644 index cefb98132..000000000 --- a/util/ceg/defaults/pseudo/.distr +++ /dev/null @@ -1,19 +0,0 @@ -C_busy.c -C_close.c -C_df_dlb.c -C_df_dnam.c -C_df_ilb.c -C_end.c -C_end_narg.c -C_exa_dlb.c -C_exa_dnam.c -C_exp.c -C_ina_dlb.c -C_ina_dnam.c -C_init.c -C_inp.c -C_magic.c -C_open.c -C_pro.c -C_pro_narg.c -C_insertpart.c diff --git a/util/ceg/defaults/storage/.distr b/util/ceg/defaults/storage/.distr deleted file mode 100644 index 011eb5382..000000000 --- a/util/ceg/defaults/storage/.distr +++ /dev/null @@ -1,22 +0,0 @@ -C_bss_cst.c -C_bss_dlb.c -C_bss_dnam.c -C_bss_ilb.c -C_bss_pnam.c -C_con_cst.c -C_con_dlb.c -C_con_dnam.c -C_con_ilb.c -C_con_pnam.c -C_con_scon.c -C_hol_cst.c -C_hol_dlb.c -C_hol_dnam.c -C_hol_ilb.c -C_hol_pnam.c -C_rom_cst.c -C_rom_dlb.c -C_rom_dnam.c -C_rom_ilb.c -C_rom_pnam.c -C_rom_scon.c diff --git a/util/ceg/util/.distr b/util/ceg/util/.distr deleted file mode 100644 index 13803edb1..000000000 --- a/util/ceg/util/.distr +++ /dev/null @@ -1,8 +0,0 @@ -proto.make -install_ceg -make_asobj -make_back -make_ce -make_ceg -make_own -update_ceg diff --git a/util/cgg/.distr b/util/cgg/.distr deleted file mode 100644 index 60379f236..000000000 --- a/util/cgg/.distr +++ /dev/null @@ -1,4 +0,0 @@ -bootgram.y -bootlex.l -main.c -booth.h diff --git a/util/cmisc/.distr b/util/cmisc/.distr deleted file mode 100644 index a0012ed5d..000000000 --- a/util/cmisc/.distr +++ /dev/null @@ -1,12 +0,0 @@ -build.mk -GCIPM.c -cclash.1 -cclash.c -cid.1 -cid.c -mkdep.1 -mkdep.c -prid.1 -prid.c -tabgen.1 -tabgen.c diff --git a/util/cpp/.distr b/util/cpp/.distr deleted file mode 100644 index cd790f208..000000000 --- a/util/cpp/.distr +++ /dev/null @@ -1,34 +0,0 @@ -build.mk -LLlex.c -LLlex.h -LLmessage.c -Parameters -bits.h -ch7bin.c -ch7mon.c -char.tab -class.h -domacro.c -error.c -expr.c -expression.g -file_info.h -idf.c -idf.h -init.c -input.c -input.h -interface.h -macro.h -main.c -make.hfiles -make.tokcase -make.tokfile -next.c -options.c -preprocess.c -replace.c -scan.c -skip.c -tokenname.c -cpp.6 diff --git a/util/ego/.distr b/util/ego/.distr deleted file mode 100644 index c2b981405..000000000 --- a/util/ego/.distr +++ /dev/null @@ -1,16 +0,0 @@ -build.mk -bo -ca -cf -cj -cs -descr -em_ego -ic -il -lv -ra -share -sp -sr -ud diff --git a/util/ego/bo/.distr b/util/ego/bo/.distr deleted file mode 100644 index 717995eb9..000000000 --- a/util/ego/bo/.distr +++ /dev/null @@ -1 +0,0 @@ -bo.c diff --git a/util/ego/ca/.distr b/util/ego/ca/.distr deleted file mode 100644 index 4493273f6..000000000 --- a/util/ego/ca/.distr +++ /dev/null @@ -1,4 +0,0 @@ -ca.c -ca.h -ca_put.c -ca_put.h diff --git a/util/ego/cf/.distr b/util/ego/cf/.distr deleted file mode 100644 index ee48a1028..000000000 --- a/util/ego/cf/.distr +++ /dev/null @@ -1,8 +0,0 @@ -cf.c -cf.h -cf_idom.c -cf_idom.h -cf_loop.c -cf_loop.h -cf_succ.c -cf_succ.h diff --git a/util/ego/cj/.distr b/util/ego/cj/.distr deleted file mode 100644 index 9cf50ef85..000000000 --- a/util/ego/cj/.distr +++ /dev/null @@ -1 +0,0 @@ -cj.c diff --git a/util/ego/cs/.distr b/util/ego/cs/.distr deleted file mode 100644 index a364eaea8..000000000 --- a/util/ego/cs/.distr +++ /dev/null @@ -1,26 +0,0 @@ -cs.c -cs.h -cs_alloc.c -cs_alloc.h -cs_aux.c -cs_aux.h -cs_avail.c -cs_avail.h -cs_debug.c -cs_debug.h -cs_elim.c -cs_elim.h -cs_entity.c -cs_entity.h -cs_getent.c -cs_getent.h -cs_kill.c -cs_kill.h -cs_partit.c -cs_partit.h -cs_profit.c -cs_profit.h -cs_stack.c -cs_stack.h -cs_vnm.c -cs_vnm.h diff --git a/util/ego/descr/.distr b/util/ego/descr/.distr deleted file mode 100644 index f7d566cd5..000000000 --- a/util/ego/descr/.distr +++ /dev/null @@ -1,12 +0,0 @@ -descr.sed -i86.descr -i386.descr -m68020.descr -m68k2.descr -m68k4.descr -pdp.descr -vax4.descr -em22.descr -em24.descr -em44.descr -sparc.descr diff --git a/util/ego/em_ego/.distr b/util/ego/em_ego/.distr deleted file mode 100644 index 3a123f69d..000000000 --- a/util/ego/em_ego/.distr +++ /dev/null @@ -1 +0,0 @@ -em_ego.c diff --git a/util/ego/ic/.distr b/util/ego/ic/.distr deleted file mode 100644 index eb09cd319..000000000 --- a/util/ego/ic/.distr +++ /dev/null @@ -1,10 +0,0 @@ -ic.c -ic.h -ic_aux.c -ic_aux.h -ic_io.c -ic_io.h -ic_lib.c -ic_lib.h -ic_lookup.c -ic_lookup.h diff --git a/util/ego/il/.distr b/util/ego/il/.distr deleted file mode 100644 index c34e2ee46..000000000 --- a/util/ego/il/.distr +++ /dev/null @@ -1,20 +0,0 @@ -il.c -il.h -il1_anal.c -il1_anal.h -il1_aux.c -il1_aux.h -il1_cal.c -il1_cal.h -il1_formal.c -il1_formal.h -il2_aux.c -il2_aux.h -il3_aux.c -il3_aux.h -il3_change.c -il3_change.h -il3_subst.c -il3_subst.h -il_aux.c -il_aux.h diff --git a/util/ego/lv/.distr b/util/ego/lv/.distr deleted file mode 100644 index 634cc49c9..000000000 --- a/util/ego/lv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -lv.c -lv.h diff --git a/util/ego/ra/.distr b/util/ego/ra/.distr deleted file mode 100644 index 7faba06c3..000000000 --- a/util/ego/ra/.distr +++ /dev/null @@ -1,20 +0,0 @@ -itemtab.src -makeitems.c -ra.c -ra.h -ra_allocl.c -ra_allocl.h -ra_aux.c -ra_aux.h -ra_interv.c -ra_interv.h -ra_items.c -ra_items.h -ra_lifet.c -ra_lifet.h -ra_pack.c -ra_pack.h -ra_profits.c -ra_profits.h -ra_xform.c -ra_xform.h diff --git a/util/ego/share/.distr b/util/ego/share/.distr deleted file mode 100644 index 285db26f7..000000000 --- a/util/ego/share/.distr +++ /dev/null @@ -1,36 +0,0 @@ -alloc.c -alloc.h -aux.c -aux.h -cldefs.src -cset.c -cset.h -debug.c -debug.h -def.h -files.c -files.h -get.c -get.h -global.c -global.h -go.c -go.h -init_glob.c -init_glob.h -locals.c -locals.h -lset.c -lset.h -makecldef.c -map.c -map.h -parser.c -parser.h -pop_push.awk -put.c -put.h -show.c -stack_chg.c -stack_chg.h -types.h diff --git a/util/ego/sp/.distr b/util/ego/sp/.distr deleted file mode 100644 index 583ccc056..000000000 --- a/util/ego/sp/.distr +++ /dev/null @@ -1 +0,0 @@ -sp.c diff --git a/util/ego/sr/.distr b/util/ego/sr/.distr deleted file mode 100644 index f2d3fd886..000000000 --- a/util/ego/sr/.distr +++ /dev/null @@ -1,14 +0,0 @@ -sr.c -sr.h -sr_aux.c -sr_aux.h -sr_cand.c -sr_cand.h -sr_expr.c -sr_expr.h -sr_iv.c -sr_iv.h -sr_reduce.c -sr_reduce.h -sr_xform.c -sr_xform.h diff --git a/util/ego/ud/.distr b/util/ego/ud/.distr deleted file mode 100644 index 0d6ef5e95..000000000 --- a/util/ego/ud/.distr +++ /dev/null @@ -1,10 +0,0 @@ -ud.c -ud.h -ud_aux.c -ud_aux.h -ud_const.c -ud_const.h -ud_copy.c -ud_copy.h -ud_defs.c -ud_defs.h diff --git a/util/flex/.distr b/util/flex/.distr deleted file mode 100644 index b7fb02916..000000000 --- a/util/flex/.distr +++ /dev/null @@ -1,24 +0,0 @@ -COPYING -Changes -Headers -Makefile -README -ccl.c -dfa.c -ecs.c -flex.1 -flex.skel -flexdef.h -flexdoc.1 -gen.c -initscan.c -libmain.c -main.c -proto.make -misc.c -nfa.c -parse.y -scan.l -sym.c -tblcmp.c -yylex.c diff --git a/util/grind/.distr b/util/grind/.distr deleted file mode 100644 index 097bdb05c..000000000 --- a/util/grind/.distr +++ /dev/null @@ -1,54 +0,0 @@ -Makefile -PROBLEMS -READ_ME -avl.cc -avl.h -c.c -char.ct -class.h -commands.g -db_symtab.g -do_comm.c -expr.c -expr.h -file.hh -grind.1 -idf.c -idf.h -itemlist.cc -langdep.cc -langdep.h -list.c -main.c -make.allocd -make.next -make.ops -make.tokcase -make.tokfile -message.h -misc.h -modula-2.c -operator.h -operators.ot -ops.c -ops.h -pascal.c -position.c -position.h -print.c -proto.main -proto.make -rd.c -rd.h -run.c -scope.cc -scope.h -symbol.c -symbol.hh -token.h -tokenname.c -tokenname.h -tree.c -tree.hh -type.c -type.hh diff --git a/util/int/.distr b/util/int/.distr deleted file mode 100644 index 7b20f911a..000000000 --- a/util/int/.distr +++ /dev/null @@ -1,70 +0,0 @@ -READ_ME -proto.make -M.trap_msg -M.warn_h -M.warn_msg -alloc.h -fra.h -global.h -linfil.h -log.h -mem.h -memdirect.h -monstruct.h -opcode.h -proctab.h -read.h -rsb.h -shadow.h -text.h -trap.h -logging.h -debug.h -nofloat.h -segcheck.h -sysidf.h -v7ioctl.h -e.out.h -alloc.c -core.c -data.c -do_array.c -do_branch.c -do_comp.c -do_conv.c -do_fpar.c -do_incdec.c -do_intar.c -do_load.c -do_logic.c -do_misc.c -do_proc.c -do_ptrar.c -do_sets.c -do_store.c -do_unsar.c -dump.c -disassemble.c -fra.c -global.c -init.c -io.c -log.c -m_ioctl.c -m_sigtrp.c -main.c -moncalls.c -monstruct.c -proctab.c -read.c -rsb.c -segment.c -stack.c -switch.c -tally.c -text.c -trap.c -warn.c -int.1 -switch -test diff --git a/util/int/switch/.distr b/util/int/switch/.distr deleted file mode 100644 index fed3bf61a..000000000 --- a/util/int/switch/.distr +++ /dev/null @@ -1,4 +0,0 @@ -READ_ME -proto.make -mkiswitch.c -mkswitch.c diff --git a/util/int/test/.distr b/util/int/test/.distr deleted file mode 100644 index e66350655..000000000 --- a/util/int/test/.distr +++ /dev/null @@ -1,9 +0,0 @@ -args.c -awa.p -fork2.c -ioc0.c -prtime.c -set.c -sig.c -proto.make -READ_ME diff --git a/util/led/.distr b/util/led/.distr deleted file mode 100644 index d505d7858..000000000 --- a/util/led/.distr +++ /dev/null @@ -1,25 +0,0 @@ -build.mk -WRONG -ack.out.5 -archive.c -assert.h -const.h -debug.h -defs.h -error.c -extract.c -finish.c -led.6 -mach.c -main.c -memory.c -memory.h -orig.h -output.c -read.c -relocate.c -save.c -scan.c -scan.h -sym.c -write.c diff --git a/util/make/.distr b/util/make/.distr deleted file mode 100644 index 97e95bfb6..000000000 --- a/util/make/.distr +++ /dev/null @@ -1,10 +0,0 @@ -Makefile -README -check.c -h.h -input.c -macro.c -main.c -make.c -reader.c -rules.c diff --git a/util/misc/.distr b/util/misc/.distr deleted file mode 100644 index 5f41acd1d..000000000 --- a/util/misc/.distr +++ /dev/null @@ -1,5 +0,0 @@ -build.mk -convert.c -em_decode.6 -esize.1 -esize.c diff --git a/util/ncgg/.distr b/util/ncgg/.distr deleted file mode 100644 index 19d084a70..000000000 --- a/util/ncgg/.distr +++ /dev/null @@ -1,35 +0,0 @@ -build.mk -assert.h -cgg.y -coerc.c -cost.h -cvtkeywords -emlookup.c -error.c -expr.c -expr.h -extern.h -hall.c -instruct.c -instruct.h -iocc.c -iocc.h -keywords -lookup.c -lookup.h -main.c -output.c -param.h -property.h -pseudo.h -reg.h -regvar.h -scan.l -set.c -set.h -strlookup.c -subr.c -token.h -var.c -varinfo.h -ncgg.6 diff --git a/util/opt/.distr b/util/opt/.distr deleted file mode 100644 index 8ac4a7749..000000000 --- a/util/opt/.distr +++ /dev/null @@ -1,34 +0,0 @@ -build.mk -alloc.c -alloc.h -assert.h -backward.c -cleanup.c -ext.h -flow.c -getline.c -line.h -lookup.c -lookup.h -main.c -mktab.y -optim.h -param.h -pattern.h -patterns -peephole.c -pop_push.awk -pop_push.h -process.c -proinf.h -putline.c -reg.c -scan.l -tes.c -tes.h -special.c -testopt -types.h -util.c -var.c -em_opt.6 diff --git a/util/shf/.distr b/util/shf/.distr deleted file mode 100644 index 0282eead8..000000000 --- a/util/shf/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -march.sh diff --git a/util/topgen/.distr b/util/topgen/.distr deleted file mode 100644 index b26dfa968..000000000 --- a/util/topgen/.distr +++ /dev/null @@ -1,11 +0,0 @@ -build.mk -LLlex.c -hash.c -main.c -misc.h -pattern.c -symtab.c -symtab.h -token.h -topgen.g -tunable.h From de7023dd617af5f38e57bcb2ca12c4d157937333 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 2 Sep 2016 23:03:57 +0200 Subject: [PATCH 224/231] Add an install target. --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index db2297cb7..af143bcfa 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,10 @@ $(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES) CC=$(CC) \ > $(BUILDDIR)/build.$(BUILDSYSTEM) +install: + mkdir -p $(PREFIX) + tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) + clean: @rm -rf $(BUILDDIR) From ff9bf5b08abbd96c380c0e98c7eafa4af4c402f4 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 3 Sep 2016 00:20:11 +0200 Subject: [PATCH 225/231] Makefiles are now slightly less inaccurate. Does actually seem to do sensible incremental builds now. I loathe make. --- first/ackbuilder.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua index 25bfd02c0..282e6f185 100644 --- a/first/ackbuilder.lua +++ b/first/ackbuilder.lua @@ -609,15 +609,28 @@ local function install_make_emitter() end function emitter:rule(name, ins, outs) + if (#outs == 0) then + local n = name.."-IMAGINARY-OUT" + emit(".INTERMEDIATE:", n, "\n") + outs = {n} + end + + local impl = name.."-IMPL" emit(".INTERMEDIATE:", name, "\n") - for i = 1, #ins do - emit(name..":", ins[i], "\n") + emit(".INTERMEDIATE:", impl, "\n") + + for i = 1, #outs do + emit(name..":", outs[i], "\n") end for i = 1, #outs do - emit(outs[i]..":", name, ";\n") + emit(outs[i]..":", impl, ";\n") end - emit(name..":\n") + for i = 1, #ins do + emit(impl..":", ins[i], "\n") + end + + emit(impl..":", "\n") local dirs = uniquify(dirname(outs)) if (#dirs > 0) then emit("\t@mkdir -p", dirs, "\n") From ea4142daee208238a97d21ee12eb68ff63fb8d7d Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 3 Sep 2016 01:04:16 +0200 Subject: [PATCH 226/231] First half of the ackbuilder documentation. --- first/ackbuilder.md | 199 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 first/ackbuilder.md diff --git a/first/ackbuilder.md b/first/ackbuilder.md new file mode 100644 index 000000000..1b211a49e --- /dev/null +++ b/first/ackbuilder.md @@ -0,0 +1,199 @@ +ackbuilder +========== + +# ackbuilder + +## What is it? + +ackbuilder is a very small build tool inspired by [bazel](https://bazel.io/) +which uses either make or [ninja](https://ninja-build.org/) as a backend. + +It supports fully parallelisable builds (in both make and ninja), as well as +hopefully-robust support for rules which generate more than one output file, +which is something make is very, very bad at. + +It was written because the ACK is a really horribly complex thing to build and +there wasn't anything else. + +## Basic concepts + +Complete example, using the built-in C rules. This should be saved in a file +called `build.lua`: + + cprogram { + name = 'prog', + srcs = { "./*.c" }, + } + +This defines a rule `prog` which, when built, compiles all the source files in +the same directory as the `build.lua` file into an executable. + +Slightly more complex example: + + clibrary { + name = "library", + srcs = { "./library.c" }, + hdrs = { "./library.h" }, + } + + cprogram { + name = 'prog2', + srcs = { "./prog2.c" }, + deps = { "+library" } + } + +If we move the library into another directory, we can invoke it like this: + + cprogram { + name = 'prog3', + srcs = { "./prog3.c" }, + deps = { "path/to/library+library" } + } + +* Targets starting with `./` are relative to **the current directory** (i.e. + the one the build file is in). + +* Targets starting with a path are relative to the top directory of the + project. + +* Targets containing a `+` refer to a named target in another build file. So, + on encountering the library in `prog3` above, ackbuilder will look for + `path/to/library/build.lua`, load it, and then try to find a target in it + called `library`. + +**Warning**: files are interpreted from top to bottom; every time a target +referring to another build file is seen for the first time, that file is +interpreted then and there. You can't have circular dependencies (these are +caught and an error is generated). You can't refer to a target defined below +you in the same source file (these are not caught, and just won't be found). + +The `cprogram` and `clibrary` rules, by the way, are sophisticated enough to +automatically handle library and header paths. The exported headers by the +library are automatically imported into the program. + +## `simplerule` and `normalrule` + +These are the building blocks out of which all other rules are made. If you +want to run your own programs, you will be using these. + +`simplerule` is the simplest. You give it inputs, and outputs, and commands, +and it does it. + + simplerule { + name = 'sorted-input', + ins = { './input.txt' }, + outs = { './output.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } + +In a command block, `%{...}` will evaluate the Lua expression between the +braces; various useful things are in scope, including the list of inputs and +outputs. + +However, this ends up leaving the output file lying around in the project +directory, which we don't want, so we usually use `normalrule` instead. +(`normalrule` is not strictly part of the ackbuilder core; it's in the standard +library along with `cprogram` and `clibrary`.) + + normalrule { + name = 'sorted-input', + ins = { './input.txt' }, + outleaves = { 'output.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } + +Note `outleaves`; there is no `./`. This is a list of leaf filenames. The rule +will create a directory in the object tree and put the files specified in it, +somewhere; you don't care where. You can refer to the output file via the +target name, so: + + normalrule { + name = 'reversed', + ins = { '+sorted-input' }, + outleaves = { 'reversed.txt' }, + commands = { + "rev < %{ins} > %{outs}" + } + } + +One common use for this is to generate C header or source files. + + normalrule { + name = 'reversed_h', + ins = { '+reversed' }, + outleaves = { 'reversed.h' }, + commands = { + 'xxd -i %{ins} > %{outs}' + } + } + + cprogram { + name = 'prog', + srcs = { './*.c' }, + deps = { '+reversed_h' } + } + +Now you can refer to `reversed.h` in one of your C files and it'll just work +(`+reversed_h`'s output directory gets added to the include path +automatically). + +## Defining your own rules + +Like this: + + definerule("sort", + { + srcs = { type="targets" }, + }, + function(e) + return normalrule { + name = e.name, + ins = e.srcs, + outleaves = { 'sorted.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } + } + ) + + sort { + name = 'sorted', + srcs = { './input.txt' } + } + +You give `definerule()` the name of the rule you want to define, a description +of the properties the rule will take, and a callback that does the work. + +You can do anything you like in the callback, including defining as many +targets as you like; but remember that all targets must have unique names, so +for any temporary files you probably want something like `name = +e.name.."/intermediate"` to ensure uniqueness. + +The callback should end by returning an invocation of another rule, with `name += e.name` as above. + +Rules are defined whenever a build file containing them is seen. Letting this +happen automatically doesn't always work so you probably want to explicitly +include it: + + include("foo/bar/baz/build.lua") + +Rule properties are typed and can be specified to be required or optional (or have a default value). + + definerule("sort", + { + srcs = { type="targets" }, + numeric = { type="boolean", default=false } + } + ...omitted... + +The most common one is `targets`. When the rule is invoked, ackbuilder will +resolve these for you so that when your callback fires, the property is a +flattened list of target objects. + + From de2f99dc1ad0ccf7a00b588471ab9eeda01450e1 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 3 Sep 2016 19:01:47 +0200 Subject: [PATCH 227/231] More documentation. --- first/ackbuilder.md | 168 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 159 insertions(+), 9 deletions(-) diff --git a/first/ackbuilder.md b/first/ackbuilder.md index 1b211a49e..0a09a8aaa 100644 --- a/first/ackbuilder.md +++ b/first/ackbuilder.md @@ -1,6 +1,3 @@ -ackbuilder -========== - # ackbuilder ## What is it? @@ -13,7 +10,12 @@ hopefully-robust support for rules which generate more than one output file, which is something make is very, very bad at. It was written because the ACK is a really horribly complex thing to build and -there wasn't anything else. +there wasn't anything else. ackbuilder is pretty rough and ready but it does +sort of work. Be prepared for bugs. + +This document is a very rapid brain dump of how the build file works. It +doesn't cover actually running the tool (because that bit's pretty nasty) --- +go look at the top level Makefile to see that for now. ## Basic concepts @@ -67,6 +69,10 @@ interpreted then and there. You can't have circular dependencies (these are caught and an error is generated). You can't refer to a target defined below you in the same source file (these are not caught, and just won't be found). +Build files each get their own private global scope. If you randomly set a +variable, it won't be seen by other build files. (Use `vars` for that; see +below.) Build files are only loaded once. + The `cprogram` and `clibrary` rules, by the way, are sophisticated enough to automatically handle library and header paths. The exported headers by the library are automatically imported into the program. @@ -183,17 +189,161 @@ include it: include("foo/bar/baz/build.lua") -Rule properties are typed and can be specified to be required or optional (or have a default value). +Rule properties are typed and can be specified to be required or optional (or +have a default value). If you try to invoke a rule with a property which isn't +declared, or missing a property which should be declared, you'll get an error. definerule("sort", { srcs = { type="targets" }, - numeric = { type="boolean", default=false } + numeric = { type="boolean", optional=true, default=false } } ...omitted... -The most common one is `targets`. When the rule is invoked, ackbuilder will -resolve these for you so that when your callback fires, the property is a -flattened list of target objects. +(The `optional=true` part can be omitted if you specify a default which isn't +`nil`.) +Types include: + + * `targets`: the most common one. When the rule is invoked, ackbuilder will + resolve these for you so that when your callback fires, the property is a + flattened list of target objects. + + * `strings`: a Lua table of strings. If the invoker supplies a single string + which isn't a table, it'll get wrapped in one. + + * `string`: a string. + + * `boolean`: a boolean (either `true` or `false`; nothing else is allowed). + + * `table`: a Lua table. + + * `object`: any Lua value. + +## Target objects + +When a rule callback is run, any targets it needs will be resolved into target +objects. These are Lua objects with assorted useful stuff in them. + + * `object.is`: contains a set telling you which rules made the object. e.g. + `object.is.cprogram` is true if `object` was built with `cprogram`. Bear in + mind that `object.is.normalrule` is _also_ going to be true. + + * `object.dir`: the object's build directory. Only exists if the object was + built with `normalrule`. + +There are other properties (`fullname` and `outs`). Please don't use these; use +`targetnamesof()` and `filenamesof()` as described below. + +## The standard library + +Your build files are supplied a pile of useful functions. + +### Manipulating target lists + +A target list is a possibly nested set of tables containing either target +objects or strings. All of these functions will implicitly flatten the list and +resolve any strings into target objects before doing anything else to them. +Most of these functions can be supplied with varargs parameters. + +e.g. `targetsof(a, b)` is equivalent to `targetsof({a, b})` is equivalent to +`targetsof({a, {b}})`. + + * `targetsof(...)`: just flattens the list and resolves any string target + names. + + * `filenamesof(...)`: returns a list of output files for all the supplied + targets. + + * `targetnamesof(...)`: returns a list of fully qualified target names for + all the supplied stargets. + + * `selectof(targets, pattern)`: returns only those targets whose outputs + contain at least one file matching the pattern. + +### Manipulating filename lists + +Like the target list functions, all of these implicitly flatten any nested +tables. They all return lists; however, as a special exception, if any of the +functions which take varargs parameters have a single parameter which is a +string, they return just a string. + +e.g. `abspath({f})` returns a table; `abspath(f)` returns a string. + + * `abspath(...)`: attempts to return the absolute path of its arguments. This + isn't always possible due to variable references. + + * `basename(...)`: returns the basenames of its arguments (the file part of + the path). + + * `dirname(...)`: returns the directory name of its arguments. + + * `matching(files, pattern)`: returns only those files which match a Lua + pattern. + + * `replace(files, pattern, repl)`: performs a Lua pattern replace on the list + of files. + + * `uniquify(...)`: removes duplicates. + +### Other things + + * `include(file)`: loads another build file, if it hasn't been loaded before. + +## Variables + +There are two types of variable, mostly for hysterical reasons. + +### Makefile variables + +(Despite the name, these work on ninja too.) + +Filenames can contain variable references of the form `$(FOO)`. These are +expanded at build time based on definitions supplied on the ackbuilder command +line. + +ackbuilder assumes that these are absolute paths and won't attempt to +manipulate them much. + +I want to get rid of these at some point. + +### ackbuilder variables + +These are expanded by ackbuilder itself. + +Every rule invocation contains a magic property, `vars`. When a rule's commands +are executed, the variables provided in the template expansion are calculated +by combining all `vars` settings in the call stack (including the top level +build file). + +Easiest to explain with an example: + + cprogram { + name = 'another_test', + srcs = { './*.c' }, + vars = { + cflags = { '-g', '-O3' } + } + } + +When `cprogram` builds each C file, the command will refer to `%{cflags}`. The +value above will be flattened into a space-separated string and substituted in. + +Setting a variable this way will _override_ any definition further up the call +stack. However, you can do this: + + vars.cflags = { '-g' } + + cprogram { + name = 'another_test', + srcs = { './*.c' }, + vars = { + ["+cflags"] = { '-O3' } + } + } + +Now `cflags` will default to `-g` everywhere, because it's set at the top +level; but when `another_test` is built, it'll be `-g -O3`. + +ackbuilder variables are only expanded in command templates, not in filenames. From 95ad06849b9874bc9e78c972b135f87b89642a1a Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 3 Sep 2016 19:07:12 +0200 Subject: [PATCH 228/231] Updated. --- CHANGES | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index b7bd2edd1..ddc6bfc97 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ # $State$ # $Revision$ +6.1pre1 + + Threw away the make-based build system, because it just didn't work. Wrote + ackbuilder. Many, many little bugfixes and cleanups, too many to remember. + 6.0pre4 Fixed some minor bit-rotting issues that were preventing compilation on @@ -32,4 +37,4 @@ compilers, Pascal, Modula-2, Basic and Occam. Working backends: i86. Working platforms: pc86, the very noddy testbed setup that produces floppy disk images. - \ No newline at end of file + From 1b8df04e58f3802606020c8a46f4120a6d961c4e Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 3 Sep 2016 19:17:09 +0200 Subject: [PATCH 229/231] Add modeline, fix formatting. --- first/ackbuilder.md | 174 ++++++++++++++++++++++---------------------- 1 file changed, 88 insertions(+), 86 deletions(-) diff --git a/first/ackbuilder.md b/first/ackbuilder.md index 0a09a8aaa..27ca6d70b 100644 --- a/first/ackbuilder.md +++ b/first/ackbuilder.md @@ -52,16 +52,16 @@ If we move the library into another directory, we can invoke it like this: deps = { "path/to/library+library" } } -* Targets starting with `./` are relative to **the current directory** (i.e. - the one the build file is in). + * Targets starting with `./` are relative to **the current directory** (i.e. + the one the build file is in). -* Targets starting with a path are relative to the top directory of the - project. + * Targets starting with a path are relative to the top directory of the + project. -* Targets containing a `+` refer to a named target in another build file. So, - on encountering the library in `prog3` above, ackbuilder will look for - `path/to/library/build.lua`, load it, and then try to find a target in it - called `library`. + * Targets containing a `+` refer to a named target in another build file. So, + on encountering the library in `prog3` above, ackbuilder will look for + `path/to/library/build.lua`, load it, and then try to find a target in it + called `library`. **Warning**: files are interpreted from top to bottom; every time a target referring to another build file is seen for the first time, that file is @@ -86,13 +86,13 @@ want to run your own programs, you will be using these. and it does it. simplerule { - name = 'sorted-input', - ins = { './input.txt' }, - outs = { './output.txt' }, - commands = { - "sort < %{ins} > %{outs}" - } - } + name = 'sorted-input', + ins = { './input.txt' }, + outs = { './output.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } In a command block, `%{...}` will evaluate the Lua expression between the braces; various useful things are in scope, including the list of inputs and @@ -104,13 +104,13 @@ directory, which we don't want, so we usually use `normalrule` instead. library along with `cprogram` and `clibrary`.) normalrule { - name = 'sorted-input', - ins = { './input.txt' }, - outleaves = { 'output.txt' }, - commands = { - "sort < %{ins} > %{outs}" - } - } + name = 'sorted-input', + ins = { './input.txt' }, + outleaves = { 'output.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } Note `outleaves`; there is no `./`. This is a list of leaf filenames. The rule will create a directory in the object tree and put the files specified in it, @@ -118,30 +118,30 @@ somewhere; you don't care where. You can refer to the output file via the target name, so: normalrule { - name = 'reversed', - ins = { '+sorted-input' }, - outleaves = { 'reversed.txt' }, - commands = { - "rev < %{ins} > %{outs}" + name = 'reversed', + ins = { '+sorted-input' }, + outleaves = { 'reversed.txt' }, + commands = { + "rev < %{ins} > %{outs}" } } One common use for this is to generate C header or source files. normalrule { - name = 'reversed_h', - ins = { '+reversed' }, - outleaves = { 'reversed.h' }, - commands = { - 'xxd -i %{ins} > %{outs}' + name = 'reversed_h', + ins = { '+reversed' }, + outleaves = { 'reversed.h' }, + commands = { + 'xxd -i %{ins} > %{outs}' } - } + } - cprogram { - name = 'prog', - srcs = { './*.c' }, - deps = { '+reversed_h' } - } + cprogram { + name = 'prog', + srcs = { './*.c' }, + deps = { '+reversed_h' } + } Now you can refer to `reversed.h` in one of your C files and it'll just work (`+reversed_h`'s output directory gets added to the include path @@ -151,26 +151,26 @@ automatically). Like this: - definerule("sort", - { - srcs = { type="targets" }, - }, - function(e) - return normalrule { - name = e.name, - ins = e.srcs, - outleaves = { 'sorted.txt' }, - commands = { - "sort < %{ins} > %{outs}" - } + definerule("sort", + { + srcs = { type="targets" }, + }, + function(e) + return normalrule { + name = e.name, + ins = e.srcs, + outleaves = { 'sorted.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } } - } - ) + ) - sort { - name = 'sorted', - srcs = { './input.txt' } - } + sort { + name = 'sorted', + srcs = { './input.txt' } + } You give `definerule()` the name of the rule you want to define, a description of the properties the rule will take, and a callback that does the work. @@ -194,11 +194,11 @@ have a default value). If you try to invoke a rule with a property which isn't declared, or missing a property which should be declared, you'll get an error. definerule("sort", - { - srcs = { type="targets" }, - numeric = { type="boolean", optional=true, default=false } - } - ...omitted... + { + srcs = { type="targets" }, + numeric = { type="boolean", optional=true, default=false } + } + ...omitted... (The `optional=true` part can be omitted if you specify a default which isn't `nil`.) @@ -206,8 +206,8 @@ declared, or missing a property which should be declared, you'll get an error. Types include: * `targets`: the most common one. When the rule is invoked, ackbuilder will - resolve these for you so that when your callback fires, the property is a - flattened list of target objects. + resolve these for you so that when your callback fires, the property is a + flattened list of target objects. * `strings`: a Lua table of strings. If the invoker supplies a single string which isn't a table, it'll get wrapped in one. @@ -226,8 +226,8 @@ When a rule callback is run, any targets it needs will be resolved into target objects. These are Lua objects with assorted useful stuff in them. * `object.is`: contains a set telling you which rules made the object. e.g. - `object.is.cprogram` is true if `object` was built with `cprogram`. Bear in - mind that `object.is.normalrule` is _also_ going to be true. + `object.is.cprogram` is true if `object` was built with `cprogram`. Bear in + mind that `object.is.normalrule` is _also_ going to be true. * `object.dir`: the object's build directory. Only exists if the object was built with `normalrule`. @@ -250,16 +250,16 @@ e.g. `targetsof(a, b)` is equivalent to `targetsof({a, b})` is equivalent to `targetsof({a, {b}})`. * `targetsof(...)`: just flattens the list and resolves any string target - names. + names. * `filenamesof(...)`: returns a list of output files for all the supplied - targets. + targets. * `targetnamesof(...)`: returns a list of fully qualified target names for - all the supplied stargets. + all the supplied stargets. * `selectof(targets, pattern)`: returns only those targets whose outputs - contain at least one file matching the pattern. + contain at least one file matching the pattern. ### Manipulating filename lists @@ -271,18 +271,18 @@ string, they return just a string. e.g. `abspath({f})` returns a table; `abspath(f)` returns a string. * `abspath(...)`: attempts to return the absolute path of its arguments. This - isn't always possible due to variable references. + isn't always possible due to variable references. * `basename(...)`: returns the basenames of its arguments (the file part of - the path). + the path). * `dirname(...)`: returns the directory name of its arguments. * `matching(files, pattern)`: returns only those files which match a Lua - pattern. + pattern. * `replace(files, pattern, repl)`: performs a Lua pattern replace on the list - of files. + of files. * `uniquify(...)`: removes duplicates. @@ -319,12 +319,12 @@ build file). Easiest to explain with an example: cprogram { - name = 'another_test', - srcs = { './*.c' }, - vars = { - cflags = { '-g', '-O3' } - } - } + name = 'another_test', + srcs = { './*.c' }, + vars = { + cflags = { '-g', '-O3' } + } + } When `cprogram` builds each C file, the command will refer to `%{cflags}`. The value above will be flattened into a space-separated string and substituted in. @@ -334,16 +334,18 @@ stack. However, you can do this: vars.cflags = { '-g' } - cprogram { - name = 'another_test', - srcs = { './*.c' }, - vars = { - ["+cflags"] = { '-O3' } - } - } + cprogram { + name = 'another_test', + srcs = { './*.c' }, + vars = { + ["+cflags"] = { '-O3' } + } + } Now `cflags` will default to `-g` everywhere, because it's set at the top level; but when `another_test` is built, it'll be `-g -O3`. ackbuilder variables are only expanded in command templates, not in filenames. + + From 56e13e24e07f728f06b1a798a7bd80ebe5d10a17 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 3 Sep 2016 19:22:38 +0200 Subject: [PATCH 230/231] Cleanup some stray files. --- first/bouncer | 32 -------------------------------- first/build.ninja | 2 -- 2 files changed, 34 deletions(-) delete mode 100755 first/bouncer delete mode 100644 first/build.ninja diff --git a/first/bouncer b/first/bouncer deleted file mode 100755 index f7408a012..000000000 --- a/first/bouncer +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -set -e -set -x - -logfile=/tmp/bouncer.$$ -trap "rm -f $logfile" EXIT - -if [ S"$1" = S"" ]; then - >&2 echo "bouncer: syntax error: BOUNCER_WHITELIST=... bouncer " - exit 1 -fi - -strace -eopen,chdir -o $logfile -f "$@" - -awk -f- -F '[ "()]+' $logfile <<"EOF" - -BEGIN { - split(ENVIRON["BOUNCER_WHITELIST"], whitelist_array, " +"); - for (i in whitelist_array) - whitelist[whitelist_array[i]] = 1; -} - -$2 == "chdir" { - print "pid ", $1, " chdir: ", $3; -} - -($2 == "open") && ($5 !~ /O_CREAT/) && ($7 != -1) { - print "pid ", $1, " open: ", $3, $7; -} - -EOF - diff --git a/first/build.ninja b/first/build.ninja deleted file mode 100644 index d95daeed9..000000000 --- a/first/build.ninja +++ /dev/null @@ -1,2 +0,0 @@ -subninja .obj/rules.ninja - From 8c94b1316c14e5ad98d8518e2f9c6f25d1566f5f Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 4 Sep 2016 19:23:02 +0200 Subject: [PATCH 231/231] Add unlink system call. --- plat/linux/libsys/unlink.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plat/linux/libsys/unlink.c diff --git a/plat/linux/libsys/unlink.c b/plat/linux/libsys/unlink.c new file mode 100644 index 000000000..29eaad108 --- /dev/null +++ b/plat/linux/libsys/unlink.c @@ -0,0 +1,8 @@ +#include +#include "libsys.h" + +int unlink(const char* pathname) +{ + return _syscall(__NR_unlink, (quad) pathname, 0, 0); +} +