From 59b383afd0be9c3f5b438f9b144f7165ef7f6b83 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 9 Jun 2018 21:13:31 +0900 Subject: [PATCH] Make the em interpreter build --- again, lots of warnings, so it probably won't work on clang. I have no idea whether it runs or not as building a e.out program is quite hard and needs a special platform. --- build.lua | 2 +- util/int/M.trap_msg | 22 +++------ util/int/M.warn_h | 24 +++------ util/int/M.warn_msg | 30 ++++------- util/int/alloc.c | 3 -- util/int/build.lua | 110 +++++++++++++++++++++++++++++++++++++++++ util/int/disassemble.c | 2 +- util/int/global.h | 3 ++ util/int/switch.c | 2 +- 9 files changed, 139 insertions(+), 59 deletions(-) create mode 100644 util/int/build.lua diff --git a/build.lua b/build.lua index 1ecf0eb12..629899415 100644 --- a/build.lua +++ b/build.lua @@ -47,7 +47,7 @@ installable { "util/arch+pkg", "util/ass+pkg", "util/ego+pkg", - "util/ass+pkg", + "util/int+pkg", "util/led+pkg", "util/misc+pkg", "util/opt+pkg", diff --git a/util/int/M.trap_msg b/util/int/M.trap_msg index fecec568d..f157c7450 100755 --- a/util/int/M.trap_msg +++ b/util/int/M.trap_msg @@ -1,21 +1,11 @@ #!/bin/sh # $Id$ -( - echo '/* This file is generated from '$1'; do not edit */' +echo '/* This file is generated from '$1'; do not edit */' - cat $1 | - sed ' - s/..// - s/.*/ "&",/ - ' -) >\#trap_msg - -if # the new one unchanged - cmp -s \#trap_msg trap_msg -then # throw it away - rm \#trap_msg -else # overwrite old version - mv \#trap_msg trap_msg -fi +cat $1 | +sed ' + s/..// + s/.*/ "&",/ +' diff --git a/util/int/M.warn_h b/util/int/M.warn_h index 10b6c47b3..10f7be304 100755 --- a/util/int/M.warn_h +++ b/util/int/M.warn_h @@ -1,23 +1,13 @@ #!/bin/sh # $Id$ -( - echo '/* This file is generated from '$1'; do not edit */' +echo '/* This file is generated from '$1'; do not edit */' - cat $1 | - grep '^\.Wn' | - sed ' - s/.*"/#define / - ' +cat $1 | +grep '^\.Wn' | +sed ' + s/.*"/#define / +' - echo '#define warning(n) do_warn((n), __LINE__, __FILE__)' -) >\#warn.h - -if # the new one unchanged - cmp -s \#warn.h warn.h -then # throw it away - rm \#warn.h -else # overwrite old version - mv \#warn.h warn.h -fi +echo '#define warning(n) do_warn((n), __LINE__, __FILE__)' diff --git a/util/int/M.warn_msg b/util/int/M.warn_msg index 4d6b806d6..5b1e9671f 100755 --- a/util/int/M.warn_msg +++ b/util/int/M.warn_msg @@ -1,24 +1,14 @@ #!/bin/sh # $Id$ -( - echo '/* This file is generated from '$1'; do not edit */' - - cat $1 | - grep '^\.Wn' | - sed ' - s/^\.Wn[ ]*/ {/ - s/[ ]*[0-9][0-9]*$/},/ - s/"[ ][ ]*W/", W/ - s/\\-/-/g - ' -) >\#warn_msg - -if # the new one unchanged - cmp -s \#warn_msg warn_msg -then # throw it away - rm \#warn_msg -else # overwrite old version - mv \#warn_msg warn_msg -fi +echo '/* This file is generated from '$1'; do not edit */' + +cat $1 | +grep '^\.Wn' | +sed ' + s/^\.Wn[ ]*/ {/ + s/[ ]*[0-9][0-9]*$/},/ + s/"[ ][ ]*W/", W/ + s/\\-/-/g +' diff --git a/util/int/alloc.c b/util/int/alloc.c index b7c785b2a..db3933262 100644 --- a/util/int/alloc.c +++ b/util/int/alloc.c @@ -4,9 +4,6 @@ #include "global.h" #include "alloc.h" -extern char *malloc(); -extern char *realloc(); - char *Malloc(sz, descr) size sz; char *descr; diff --git a/util/int/build.lua b/util/int/build.lua new file mode 100644 index 000000000..9c603cf1d --- /dev/null +++ b/util/int/build.lua @@ -0,0 +1,110 @@ +normalrule { + name = "trap_msg", + ins = { + "./M.trap_msg", + "etc/traps" + }, + outleaves = {"trap_msg"}, + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "warn_msg", + ins = { + "./M.warn_msg", + "etc/traps" + }, + outleaves = {"warn_msg"}, + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "warn_h", + ins = { + "./M.warn_h", + "doc/int/appA" -- there's a 1991 comment saying this needs to be moved + }, + outleaves = {"warn.h"}, + commands = { + "%{ins} > %{outs}" + } +} + +cprogram { + name = "mkiswitch", + srcs = {"./switch/mkiswitch.c"}, + deps = { + "h+emheaders", + "modules/src/em_data+lib", + } +} + +normalrule { + name = "docases", + ins = { + "+mkiswitch", + "etc/ip_spec.t" + }, + outleaves = {"DoCases"}, + commands = { + "%{ins[1]} Do %{ins[2]} %{outs}" + } +} + +cprogram { + name = "mkswitch", + srcs = {"./switch/mkswitch.c"} +} + +normalrule { + name = "prcases", + ins = { + "+mkswitch", + "etc/ip_spec.t" + }, + outleaves = {"PrCases"}, + commands = { + "%{ins[1]} Pr %{ins[2]} %{outs}" + } +} + +clibrary { + name = "generated", + srcs = {}, + hdrs = { + "+warn_msg", + "+trap_msg", + "+warn_h", + "+docases", + "+prcases", + } +} + +cprogram { + name = "int", + srcs = { + "./*.c", + }, + deps = { + "h+emheaders", + "+generated", + "modules/src/em_data+lib", + }, + vars = { + ["+cflags"] = {"-Wno-implicit-int"} + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/int"] = "+int", + ["$(INSDIR)/share/man/man1/int.1"] = "./int.1", + } +} + + diff --git a/util/int/disassemble.c b/util/int/disassemble.c index 8d53c9ff9..c5bf99613 100644 --- a/util/int/disassemble.c +++ b/util/int/disassemble.c @@ -1758,7 +1758,7 @@ PRIVATE do_pr_instr(opcode) unsigned int opcode; { switch (opcode) { -#include "switch/PrCases" /* for the muscle */ +#include "PrCases" /* for the muscle */ case SECONDARY: do_pr_instr(SEC_BASE + nextTCbyte()); break; diff --git a/util/int/global.h b/util/int/global.h index 6d0474acb..d90f09b7a 100644 --- a/util/int/global.h +++ b/util/int/global.h @@ -4,6 +4,9 @@ /* $Id$ */ +#include +#include +#include /********* PRIVATE/static *********/ diff --git a/util/int/switch.c b/util/int/switch.c index 9668b4f58..a3c704f6a 100644 --- a/util/int/switch.c +++ b/util/int/switch.c @@ -15,7 +15,7 @@ do_instr(opcode) unsigned int opcode; { switch (opcode) { -#include "switch/DoCases" /* for the muscle */ +#include "DoCases" /* for the muscle */ case SECONDARY: do_instr(SEC_BASE + nextPCbyte()); break; -- 2.34.1