ack.git
7 years agoFix an issue throughout where B couldn't be built by ackprogram due to symbol
David Given [Thu, 29 Dec 2016 17:11:53 +0000 (17:11 +0000)]
Fix an issue throughout where B couldn't be built by ackprogram due to symbol
laziness.

7 years agoBuild the B compiler and standard library (also the Basic one, which was
David Given [Thu, 29 Dec 2016 17:11:07 +0000 (17:11 +0000)]
Build the B compiler and standard library (also the Basic one, which was
missing).

7 years agoFirst draft of the B module code; a module name can now be specified as a
David Given [Thu, 29 Dec 2016 17:10:21 +0000 (17:10 +0000)]
First draft of the B module code; a module name can now be specified as a
compiler flag, which is used to set the name of the patch table. The compiler
now understands C preprocessor line directives. Extend the standard library
somewhat.

7 years agoChange the i80 assembler to be three-pass, which allows forward references;
David Given [Thu, 29 Dec 2016 17:08:53 +0000 (17:08 +0000)]
Change the i80 assembler to be three-pass, which allows forward references;
required for assembling B.

7 years agoDon't crash when using the -u option to enter undefined symbols.
David Given [Wed, 28 Dec 2016 23:49:55 +0000 (23:49 +0000)]
Don't crash when using the -u option to enter undefined symbols.

7 years agoCorrectly export PREFIX to the Lua build system.
David Given [Wed, 28 Dec 2016 19:16:15 +0000 (19:16 +0000)]
Correctly export PREFIX to the Lua build system.

7 years agoMerge in B changes.
David Given [Wed, 28 Dec 2016 17:30:14 +0000 (17:30 +0000)]
Merge in B changes.

7 years agoMerge from default.
David Given [Mon, 26 Dec 2016 19:44:48 +0000 (19:44 +0000)]
Merge from default.

7 years agoMerge pull request #29 from kernigh/pr-elf-symbol
David Given [Wed, 14 Dec 2016 21:30:44 +0000 (22:30 +0100)]
Merge pull request #29 from kernigh/pr-elf-symbol

ELF symbol table from aelflod

7 years agoUpdate aelflod.1 to describe options, mention symbol table.
George Koehler [Tue, 13 Dec 2016 22:22:45 +0000 (17:22 -0500)]
Update aelflod.1 to describe options, mention symbol table.

7 years agoTeach aelflod to write the ELF symbol table.
George Koehler [Tue, 13 Dec 2016 21:41:22 +0000 (16:41 -0500)]
Teach aelflod to write the ELF symbol table.

Convert each ack.out symbol to ELF, preserving its name and value, and
some but not all other symbol info.  The ELF symbol table comes with
ELF section headers.  If the input file has no symbols (ack -Rled-s),
then the output file has no ELF section headers.

Append the symbol table and section headers to the ELF file.  Linux
ignores this appended info when it execs the file.  The info might
pollute the last page of the ELF segment, but Linux clears this
pollution.  Tools like nm and gdb can read the ELF symbol table.

I include code to translate debugger symbols to an ELF .stab section.
I did not test this code, because I did not find a platform that can
put S_STB symbols in the ack.out file.

7 years agoIn aslod, remove some unused m68k2 stuff.
George Koehler [Tue, 13 Dec 2016 21:02:38 +0000 (16:02 -0500)]
In aslod, remove some unused m68k2 stuff.

7 years agoTweak man syntax in aelflod.1 and aslod.1
George Koehler [Tue, 13 Dec 2016 20:54:38 +0000 (15:54 -0500)]
Tweak man syntax in aelflod.1 and aslod.1

Put end of sentence at end of line.  This is roff(7) syntax so the
formatter can make spacing between sentences.

Use the macro .PP to break paragraphs.  Use bold for the command name
in SYNOPSIS, to match other ack manuals.

7 years agoMerge pull request #27 from kernigh/pr-qemu-doze
David Given [Sun, 11 Dec 2016 22:17:12 +0000 (23:17 +0100)]
Merge pull request #27 from kernigh/pr-qemu-doze

Teach qemuppc to halt the cpu on _exit().

7 years agoConvert the inn test to work with the test library and not import InOut; it now
David Given [Sun, 11 Dec 2016 22:06:37 +0000 (23:06 +0100)]
Convert the inn test to work with the test library and not import InOut; it now
runs on qemuppc again. Reenable qemuppc tests.

7 years agoMerge pull request #28 from kernigh/pr-set-ppc
David Given [Sun, 11 Dec 2016 21:25:04 +0000 (22:25 +0100)]
Merge pull request #28 from kernigh/pr-set-ppc

add Modula-2 set operations to PowerPC ncg

7 years agoAdd Modula-2 set operations to PowerPC ncg.
George Koehler [Sat, 10 Dec 2016 17:23:07 +0000 (12:23 -0500)]
Add Modula-2 set operations to PowerPC ncg.

This provides and, ior, xor, com, zer, set, cms when defined($1) and
ior, set when !defined($1).  I don't provide the other operations
!defined($1) because our Modula-2 compiler hasn't used them.

I wrote a Modula-2 example in
https://gist.github.com/kernigh/add79662bb3c63ffb7c46d01dc8ae788

Put a dummy comment in mach/powerpc/libem/build.lua so git checkout
will touch that file.  Without the touch, the build system doesn't see
the new *.s files.

7 years agoAdd some missing clauses to los, sts, aar, inn, cmi, cmu.
George Koehler [Sat, 10 Dec 2016 00:49:50 +0000 (19:49 -0500)]
Add some missing clauses to los, sts, aar, inn, cmi, cmu.

We only implement 'los 4', 'sts 4', 'cmi 4', 'cmu 4', not for sizes
other than 4.  Add clause $1==4.

We only implement inn when defined($1).

The rule for aar needs 'kills ALL' because it kills many registers,
like other rules that call libem.

7 years agoAdd a move from CONST smalls(%val) to GPR.
George Koehler [Fri, 9 Dec 2016 23:40:14 +0000 (18:40 -0500)]
Add a move from CONST smalls(%val) to GPR.

This allows 'move {CONST, $1}, R3' with a small enough $1 to emit one
instruction (addi) instead of two instructions (addis, ori).  The
CONST token confusingly isn't in the CONST_ALL set.

7 years agoFix ass to match the EM spec.
George Koehler [Fri, 9 Dec 2016 22:32:42 +0000 (17:32 -0500)]
Fix ass to match the EM spec.

The spec says, "ASS w: Adjust the stack pointer by w-byte integer".
The w argument "can either be given as argument or on top of the
stack."  Therefore, 'ass 4' would pop the 4-byte integer from the
stack, but 'ass' would pop the size w from the stack, then pop the
w-byte integer.

PowerPC ncg wrongly implemented 'ass' as if it was 'ass 4'.  Fix it to
accept only 'ass 4'.

7 years agoRemove the bogus rules for 'lor 2' and 'str 2'.
George Koehler [Fri, 9 Dec 2016 22:00:56 +0000 (17:00 -0500)]
Remove the bogus rules for 'lor 2' and 'str 2'.

These instructions would load or store the EM heap pointer.  They
don't work.  Programs must use brk() or sbrk() in libsys.

The last file to use 'lor 2' and 'str 2' was lang/pc/libpc/sav.e in
the Pascal library.  Commit c084f9f deleted the file, so we no longer
need rules 'lor 2' or 'str 2' to build the ACK.

7 years agoFill in a hint for enabling the COMMENT macro.
George Koehler [Fri, 9 Dec 2016 21:58:47 +0000 (16:58 -0500)]
Fill in a hint for enabling the COMMENT macro.

If you want to enable comments in the .s file, change

    #define COMMENT(n) /* comment {LABEL, n} */

to

    #define COMMENT(n) comment {LABEL, n}

7 years agoRemove trailing whitespace in mach/powerpc/ncg/table
George Koehler [Fri, 9 Dec 2016 21:36:42 +0000 (16:36 -0500)]
Remove trailing whitespace in mach/powerpc/ncg/table

7 years agoFix typo: msr0 should be msr.
George Koehler [Fri, 9 Dec 2016 21:04:21 +0000 (16:04 -0500)]
Fix typo: msr0 should be msr.

7 years agoTeach qemuppc to halt the cpu on _exit().
George Koehler [Wed, 7 Dec 2016 23:11:12 +0000 (18:11 -0500)]
Teach qemuppc to halt the cpu on _exit().

Without this, qemu-system-ppc spins the host cpu until I close its
window.  I assume the default G3 emulation.  The emulator yields the
host cpu if I set certain flags in hid0 then msr.  The hid0 flag can
be any of DOZE, NAP, SLEEP, so I just set all 3.  I encode mfmsr and
mtmsr with .data4, because our assembler doesn't know instructions for
supervisor mode.

Also move some common symbols from .rom to .bss.  Our assembler puts
common symbols in any section.

Also clean up the file.  Delete a comment about linuxppc that is wrong
here.  Delete redundant .extern because .define is the same.

7 years agoAllow mfspr, mtspr with a register number.
George Koehler [Wed, 7 Dec 2016 22:28:00 +0000 (17:28 -0500)]
Allow mfspr, mtspr with a register number.

PowerPC has a few hundred special-purpose registers.  The assembler
had only accepted the names "xer", "lr", "ctr".  Most programs use
only those three SPRs.  If I add more names, they would almost never
get used, and they might conflict with labels.

I want to use "mfspr r3, 0x3f0" and "mtspr 0x3f0, r3" in
plat/qemu/boot.s to access register hid0 from supervisor mode.

7 years agoMerge pull request #25 from davidgiven/dtrg-inn
David Given [Tue, 6 Dec 2016 21:24:31 +0000 (22:24 +0100)]
Merge pull request #25 from davidgiven/dtrg-inn

Fix endianess issue with inn.

7 years agoAdd a test for #22.
David Given [Tue, 6 Dec 2016 21:07:22 +0000 (22:07 +0100)]
Add a test for #22.

7 years agoDisable qemuppc tests; turns out qemu-system-ppc won't load more than the first
David Given [Tue, 6 Dec 2016 21:06:17 +0000 (22:06 +0100)]
Disable qemuppc tests; turns out qemu-system-ppc won't load more than the first
4kB of a kernel...

7 years agoFix redirection so stray stderr output from qemu doesn't cause mysterious test
David Given [Tue, 6 Dec 2016 21:05:14 +0000 (22:05 +0100)]
Fix redirection so stray stderr output from qemu doesn't cause mysterious test
failures.

7 years agoinn was assuming that bitfields were arrays of bytes, when actually they're
David Given [Tue, 6 Dec 2016 20:45:20 +0000 (21:45 +0100)]
inn was assuming that bitfields were arrays of bytes, when actually they're
arrays of words (which makes the LSB move on big-endian systems).

7 years agoMerge pull request #23 from kernigh/pr-osx
David Given [Tue, 6 Dec 2016 15:28:24 +0000 (16:28 +0100)]
Merge pull request #23 from kernigh/pr-osx

new platforms osx386 and osxppc

7 years agoDon't share as, ncg, top between Linux and Mac OS X. kernigh-osx
George Koehler [Tue, 6 Dec 2016 01:13:29 +0000 (20:13 -0500)]
Don't share as, ncg, top between Linux and Mac OS X.

Telling osx386 and osxppc to build and run their own tools, not to
reuse the tools from linux386 and linuxppc.  This wastes time to build
identical tools, but it removes some bogus dependencies.  OS X tools
had wrongly depended on Linux descr files and aelflod; now they don't.

Discussion in https://github.com/davidgiven/ack/pull/23

7 years agoFix some shell issues that would occasionally cause hangs if no tests failed. kernigh-pr-osx
David Given [Mon, 5 Dec 2016 20:06:38 +0000 (21:06 +0100)]
Fix some shell issues that would occasionally cause hangs if no tests failed.

7 years agoClean up how the language libraries refer to plat headers; they should be using
David Given [Mon, 5 Dec 2016 20:05:24 +0000 (21:05 +0100)]
Clean up how the language libraries refer to plat headers; they should be using
the +pkg forms of the rules and getting the headers via the paths in descr,
rather than depending on the +headers version.

7 years agoChange dependency from simplerule{} with a dependency but no outputs to an
David Given [Mon, 5 Dec 2016 19:33:26 +0000 (20:33 +0100)]
Change dependency from simplerule{} with a dependency but no outputs to an
installable; otherwise, the dependency would be built, but the result wouldn't
get added to the header path and so wouldn't be seen.

7 years agoMerge branch 'pr-osx' of https://github.com/kernigh/ack into kernigh-pr-osx
David Given [Mon, 5 Dec 2016 19:14:54 +0000 (20:14 +0100)]
Merge branch 'pr-osx' of https://github.com/kernigh/ack into kernigh-pr-osx

7 years agoCreate Mach-o files with mode 0777 to allow executing them.
George Koehler [Sat, 3 Dec 2016 22:52:24 +0000 (17:52 -0500)]
Create Mach-o files with mode 0777 to allow executing them.

Until now, I was always doing chmod +x before running my files on the
Mac.  Now files get created +x.  There's no change when overwriting
an existing file.  I needed to gmake clean my build to remove the
example programs without +x, so cvmach can create them with +x.

7 years agoWrite README files for osx386 and osxppc.
George Koehler [Sat, 3 Dec 2016 22:17:44 +0000 (17:17 -0500)]
Write README files for osx386 and osxppc.

7 years agoRemove bad overflow check from plat/osx/libsys/brk.c
George Koehler [Sat, 3 Dec 2016 22:07:51 +0000 (17:07 -0500)]
Remove bad overflow check from plat/osx/libsys/brk.c

If I want to check for overflow, then I should check it before I do
base + incr, not after.

Now that I have no check, I am passing the overflowed base + incr to
brk1(), where it will probably fail the nbreak < segment check.

7 years agoWrite a manual page for cvmach(6).
George Koehler [Fri, 2 Dec 2016 23:04:06 +0000 (18:04 -0500)]
Write a manual page for cvmach(6).

This manual is in the new mdoc(7) format.  All existing ack manuals
use the old man(7) format.  This might be a problem if someone can't
display mdoc(7) files.

The build system doesn't install the cvmach(6) manual; that might
happen later.  The current build system installs manuals in two
different places, and doesn't install some manuals, so I don't know
what to do.

7 years agoMerge from default.
David Given [Thu, 1 Dec 2016 23:25:50 +0000 (00:25 +0100)]
Merge from default.

7 years agoMerge pull request #21 from davidgiven/dtrg-tests
David Given [Thu, 1 Dec 2016 23:24:44 +0000 (00:24 +0100)]
Merge pull request #21 from davidgiven/dtrg-tests

Run all tests, even if some fail, and produce a test summary at the end of the build.

7 years agoTypo fix.
David Given [Thu, 1 Dec 2016 23:18:44 +0000 (00:18 +0100)]
Typo fix.

7 years agoDon't fail to build if all tests are skipped.
David Given [Thu, 1 Dec 2016 23:14:40 +0000 (00:14 +0100)]
Don't fail to build if all tests are skipped.

7 years agoUI tweaks to the test summary.
David Given [Thu, 1 Dec 2016 23:10:33 +0000 (00:10 +0100)]
UI tweaks to the test summary.

7 years agoReport skipped, failed and timed out tests.
David Given [Thu, 1 Dec 2016 23:00:31 +0000 (00:00 +0100)]
Report skipped, failed and timed out tests.

7 years agoMark skipped tests in the logs (so we can get stats on them later).
David Given [Thu, 1 Dec 2016 22:14:29 +0000 (23:14 +0100)]
Mark skipped tests in the logs (so we can get stats on them later).

7 years agoRun all tests, even the ones which fail, and emit a test summary right at the
David Given [Thu, 1 Dec 2016 22:03:30 +0000 (23:03 +0100)]
Run all tests, even the ones which fail, and emit a test summary right at the
end of the build (and fail then).

7 years agoMerge pull request #20 from davidgiven/dtrg-tests
David Given [Thu, 1 Dec 2016 21:23:09 +0000 (22:23 +0100)]
Merge pull request #20 from davidgiven/dtrg-tests

Replace the hacky pipeline in testdriver.sh with a bespoke tool.

7 years agoFix signal unsafety in testdriver.c.
David Given [Thu, 1 Dec 2016 21:05:22 +0000 (22:05 +0100)]
Fix signal unsafety in testdriver.c.

7 years agoMerge from default.
David Given [Wed, 30 Nov 2016 21:07:29 +0000 (22:07 +0100)]
Merge from default.

7 years agoMerge from default.
David Given [Wed, 30 Nov 2016 21:04:11 +0000 (22:04 +0100)]
Merge from default.

7 years agoMerge pull request #18 from kernigh/pr-util-ack
David Given [Wed, 30 Nov 2016 21:00:55 +0000 (22:00 +0100)]
Merge pull request #18 from kernigh/pr-util-ack

util/ack: use DEFAULT_PLATFORM, allow non-ASCII filenames, other changes

7 years agoWrite a powerpc.descr for ego and use it with osxppc.
George Koehler [Wed, 30 Nov 2016 20:29:19 +0000 (15:29 -0500)]
Write a powerpc.descr for ego and use it with osxppc.

No change to linuxppc and qemuppc.  They continue to run ego without
any descr file.

I copied m68020.descr to powerpc.descr and changed some numbers.  My
numbers are guesses; I know little about PowerPC cycle counts, and
almost nothing about ego.  This powerpc.descr causes most of the
example programs to shrink in size (without descr -> with descr):

  65429 -> 57237  hilo_b.osxppc        -8192
  36516 -> 32420  hilo_c.osxppc        -4096
  55782 -> 51686  hilo_mod.osxppc      -4096
  20096 -> 20096  hilo_p.osxppc            0
   8813 ->  8813  mandelbrot_c.osxppc      0
  93355 -> 89259  paranoia_c.osxppc    -4096
  92751 -> 84559  startrek_c.osxppc    -8192

(Each file has 2 Mach segments, then a symbol table.  Each segment
takes a multiple of 4096 bytes.  When the code shrinks, we lose a
multiple of 4096 bytes.)

I used "ack -mosxppc -O6 -c.so" to examine the assembly code for
hilo.mod and mandelbrot.c, both without and with descr.  This reveals
optimizations made only with descr, from 2 ego phases: SP (stack
pollution) and RA (register allocation).  In hilo.mod, SP deletes some
instructions that remove items from the stack.  These items get
removed when the function returns.  In both hilo.mod and mandelbrot.c,
RA moves some values into local variables, so ncg can make them into
register variables.  This shrinks code size, probably because register
variables get preserved across function calls.  More values stay in
registers, and ncg emits shorter code.

I believe that the ego descr file uses (time,space) tuples but the ncg
table uses (space,time) tuples.  This is confusing.  Perhaps I am
wrong, and some or all tuples are backwards.  My time values are the
cycle counts in latency from the MPC7450 Reference Manual (but not
including complications like "store serialization").

In powerpc.descr, I give the cost for saving and restoring registers
as if I was using chains of stw and lwz instructions.  Actually ncg
uses single stmw and lmw instructions with at least 2 instructions.
The (time,space) for stmw and lmw would be much less than the
(time,space) for chains of stw and lwz.  But this ignores the pipeline
of the MPC7450.  The chains of stw and lwz may run faster than stmw
and lmw in the pipeline, because the throughput may be better than the
latency.  By using the wrong values for (time,space), I'm trying to
tell ego that stmw and lmw are not better than chains of stw and lwz.

7 years agoDeclare raise() for Mac OS X.
George Koehler [Wed, 30 Nov 2016 19:33:40 +0000 (14:33 -0500)]
Declare raise() for Mac OS X.

This prevents the warning, "implicit declaration of function raise",
in programs that call raise().  I forgot to declare it because the
function raise() is in libc but the declaration goes in libsys.

7 years agoReplace the hacky and broken pipeline in testdriver.sh with a custom-written
David Given [Tue, 29 Nov 2016 19:59:43 +0000 (20:59 +0100)]
Replace the hacky and broken pipeline in testdriver.sh with a custom-written
tool in C; much more robust and easier to understand, as well as avoiding the
dependency on timeout (which isn't Posix).

7 years agoEnable top and make other tweaks in plat/osxppc/descr
George Koehler [Tue, 29 Nov 2016 01:58:51 +0000 (20:58 -0500)]
Enable top and make other tweaks in plat/osxppc/descr

David Given made top for PowerPC.  Copy the asopt phase (running top)
from linuxppc to osxppc.

Remove CC_ALIGN=-Vr to become compatible with Apple's gcc.  Apple uses
left adjustment for bitfields; the first bitfield is on the left side
(the big end), not the right side.

Remove unused variables C_LIB and OLD_C_LIB; the file libc-ansi.a
doesn't exist.

Change MACHOPT_F from -m10 to -m3.  This means to use no more than 3
adds and shifts to optimize a multiply by a constant.  I pick -m3
because -m4 can use too many instructions.  At -m4, the compiler
rewrites

    n * 14

as

    s = n << 1
    (s << 3) + (0 - s)

This means (n * 16 - n * 2), but even at ack -O6, the compiler doesn't
rewrite (a + (0 - b)) as (a - b).  The compiler emits 5 instructions:
2 of rlinmw for 2 left shifts, then addi to load 0 in a register, subf
to subtract from that 0, then add.  These 5 instructions cost 5 cycles
on the MPC7450, using the cycle counts from mach/powerpc/ncg/table.

At -m3, (n * 14) becomes 2 instructions: addi to load 14 in a register
and mullw to multiply.  This also costs 5 cycles (because mullw costs
4 cycles), but uses less space.

7 years agoMerge branch 'default' into kernigh-osx
George Koehler [Mon, 28 Nov 2016 21:20:56 +0000 (16:20 -0500)]
Merge branch 'default' into kernigh-osx

This brings in David Given's PowerPC changes, including the addition
of the modern code generator (mcg) for PowerPC.

Resolve minor conflicts in top build.lua and util/led/main.c

7 years agoFix putchar() return value.
David Given [Mon, 28 Nov 2016 20:38:46 +0000 (21:38 +0100)]
Fix putchar() return value.

7 years agoAdd getdirentries() and stat() for Mac OS X.
George Koehler [Mon, 28 Nov 2016 19:32:49 +0000 (14:32 -0500)]
Add getdirentries() and stat() for Mac OS X.

Also add fstat() and lstat().  I don't #define the constants for
st_mode or d_type, but I provide enough to get the block size of a
file and to list the names in a directory.  Some fields of struct stat
get truncated, see XXX in plat/osx/include/sys/stat.h.

In struct dirent, the inode field might be d_ino or d_fileno.  I
picked d_ino because Apple's sys/dirent.h uses d_ino (but Apple's
manual pages use d_fileno).

7 years agoImplement enough libb to make 'Hello, world!' work.
David Given [Sun, 27 Nov 2016 21:05:15 +0000 (22:05 +0100)]
Implement enough libb to make 'Hello, world!' work.

7 years agoAdd support for consecutive labels; needed by the B compiler.
David Given [Sun, 27 Nov 2016 20:18:00 +0000 (21:18 +0100)]
Add support for consecutive labels; needed by the B compiler.

7 years agoFix some basic showstopping bugs; compilation now works up to failing to find
David Given [Sun, 27 Nov 2016 20:08:14 +0000 (21:08 +0100)]
Fix some basic showstopping bugs; compilation now works up to failing to find
the libb standard library.

7 years agoHook the B compiler up to the compiler driver.
David Given [Sun, 27 Nov 2016 19:48:07 +0000 (20:48 +0100)]
Hook the B compiler up to the compiler driver.

7 years agoChange the extension used by Basic files for .b to .bas, to avoid conflicts
David Given [Sun, 27 Nov 2016 19:38:33 +0000 (20:38 +0100)]
Change the extension used by Basic files for .b to .bas, to avoid conflicts
with B.

7 years agoPerform initial (i.e. feature complete and compiling, but not necessarily
David Given [Sun, 27 Nov 2016 19:28:19 +0000 (20:28 +0100)]
Perform initial (i.e. feature complete and compiling, but not necessarily
working) port of the B compiler to EM.

7 years agoInitial EM-ification; start threading word size stuff through the code.
David Given [Sun, 27 Nov 2016 10:58:59 +0000 (11:58 +0100)]
Initial EM-ification; start threading word size stuff through the code.

7 years agoImport aap@github's B compiler.
David Given [Sun, 27 Nov 2016 10:37:25 +0000 (11:37 +0100)]
Import aap@github's B compiler.

7 years agoSuppress spurious message when testdriver probes for a testing method.
David Given [Sat, 26 Nov 2016 20:50:56 +0000 (21:50 +0100)]
Suppress spurious message when testdriver probes for a testing method.

7 years agoUpdated the README.
David Given [Sat, 26 Nov 2016 18:25:02 +0000 (19:25 +0100)]
Updated the README.

7 years agoMerge pull request #17 from davidgiven/dtrg-tests
David Given [Sat, 26 Nov 2016 11:59:13 +0000 (12:59 +0100)]
Merge pull request #17 from davidgiven/dtrg-tests

Refactor the tests so they run for several plats.

7 years agoUse command -v rather than hash to detect commands (command is Posix and works
David Given [Sat, 26 Nov 2016 11:53:36 +0000 (12:53 +0100)]
Use command -v rather than hash to detect commands (command is Posix and works
on OpenBSD).

7 years agoOSX doesn't work; let's not bother building it.
David Given [Sat, 26 Nov 2016 11:52:09 +0000 (12:52 +0100)]
OSX doesn't work; let's not bother building it.

7 years agoPlats which use aelflod need to depend on it.
David Given [Sat, 26 Nov 2016 11:07:08 +0000 (12:07 +0100)]
Plats which use aelflod need to depend on it.

7 years agoqmu-system-x86 isn't in Travis' repository? Let's try qemu-user.
David Given [Sat, 26 Nov 2016 11:00:59 +0000 (12:00 +0100)]
qmu-system-x86 isn't in Travis' repository? Let's try qemu-user.

7 years agoEnable tests for linux386 via qemu-i386.
David Given [Sat, 26 Nov 2016 10:58:02 +0000 (11:58 +0100)]
Enable tests for linux386 via qemu-i386.

7 years agoEnable tests for linuxppc via qemu-ppc.
David Given [Sat, 26 Nov 2016 10:56:17 +0000 (11:56 +0100)]
Enable tests for linuxppc via qemu-ppc.

7 years agoTravis only whitelists the -x86 version of qemu.
David Given [Sat, 26 Nov 2016 10:29:57 +0000 (11:29 +0100)]
Travis only whitelists the -x86 version of qemu.

7 years agoRework the tests to run on pc86; lots of test fixes for the brk() test, which
David Given [Sat, 26 Nov 2016 10:23:25 +0000 (11:23 +0100)]
Rework the tests to run on pc86; lots of test fixes for the brk() test, which
was nearly useless; lots of fixes to qemuppc and pc86 sbrk(), which was broken;
change the pc86 console to echo output to the serial port (needed for running
tests on qemu).

7 years agoRefactored the tests to make the generic across different plats.
David Given [Fri, 25 Nov 2016 20:02:51 +0000 (21:02 +0100)]
Refactored the tests to make the generic across different plats.

7 years agoMake pc86 echo console output to the serial port, so qemu can pipe it to
David Given [Fri, 25 Nov 2016 19:28:41 +0000 (20:28 +0100)]
Make pc86 echo console output to the serial port, so qemu can pipe it to
stdout.

7 years agoAnsify Paranoia, because I was getting annoyed by all the compiler warnings on
David Given [Fri, 25 Nov 2016 19:01:43 +0000 (20:01 +0100)]
Ansify Paranoia, because I was getting annoyed by all the compiler warnings on
every build.

7 years agoMerge pull request #16 from davidgiven/dtrg-pascal-mark-release
David Given [Thu, 24 Nov 2016 19:45:14 +0000 (20:45 +0100)]
Merge pull request #16 from davidgiven/dtrg-pascal-mark-release

Remove the Mark() and Release() procedures from Pascal.

7 years agoRemove the Mark() and Release() procedures from the Pascal compiler and
David Given [Thu, 24 Nov 2016 19:35:26 +0000 (20:35 +0100)]
Remove the Mark() and Release() procedures from the Pascal compiler and
standard library, because they never worked and come from an achingly old
version of the Pascal specification. Fix the implementations of New() and
Dispose() to use the standard C memory allocator rather than rolling their own
(also in C). Write test!

7 years agoForgot to check in the change to qemuppc's brk() to set errno on memory
David Given [Thu, 24 Nov 2016 18:47:11 +0000 (19:47 +0100)]
Forgot to check in the change to qemuppc's brk() to set errno on memory
allocation failure.

7 years agoMerge pull request #15 from davidgiven/dtrg-allocs
David Given [Wed, 23 Nov 2016 21:35:50 +0000 (22:35 +0100)]
Merge pull request #15 from davidgiven/dtrg-allocs

Fix various memory allocation bugs.

7 years agoAdd a test for brk() and sbrk().
David Given [Wed, 23 Nov 2016 21:28:21 +0000 (22:28 +0100)]
Add a test for brk() and sbrk().

7 years agoAdd a test for calloc().
David Given [Wed, 23 Nov 2016 21:22:04 +0000 (22:22 +0100)]
Add a test for calloc().

7 years agoImplement calloc() (accidentally got dropped with the malloc rewrite).
David Given [Wed, 23 Nov 2016 21:16:25 +0000 (22:16 +0100)]
Implement calloc() (accidentally got dropped with the malloc rewrite).

7 years agoChange sbrk() to take an int rather than an intptr_t (following the OpenBSD way
David Given [Wed, 23 Nov 2016 21:06:24 +0000 (22:06 +0100)]
Change sbrk() to take an int rather than an intptr_t (following the OpenBSD way
rather than the Linux way; various non-C bits of the ACK assume it takes an
int, so it's cleaner).

7 years agoCombine brk() with sbrk(); modify brk() to update the sbrk(0) value.
David Given [Wed, 23 Nov 2016 21:04:21 +0000 (22:04 +0100)]
Combine brk() with sbrk(); modify brk() to update the sbrk(0) value.

7 years agoMerge pull request #14 from davidgiven/dtrg-experimental-mcgg
David Given [Wed, 23 Nov 2016 20:58:31 +0000 (21:58 +0100)]
Merge pull request #14 from davidgiven/dtrg-experimental-mcgg

Merge mcg code generator to trunk

7 years agoDon't install qemu-system-ppc until openbios-ppc gets whitelisted by Travis.
David Given [Wed, 23 Nov 2016 20:53:14 +0000 (21:53 +0100)]
Don't install qemu-system-ppc until openbios-ppc gets whitelisted by Travis.

7 years agoMake working gettimeofday() for Mac OS X.
George Koehler [Wed, 23 Nov 2016 18:25:55 +0000 (13:25 -0500)]
Make working gettimeofday() for Mac OS X.

The system call puts the time in a pair of registers, not in the
timeval structure.  Add code to move the time to the structure, so
programs see the correct time, not garbage.  This fixes our example
programs that use the time as a random seed.

7 years agoTeach cvmach to emit the symbol table.
George Koehler [Tue, 22 Nov 2016 22:16:30 +0000 (17:16 -0500)]
Teach cvmach to emit the symbol table.

This preserves the name and value of every symbol.  The type and other
info of a symbol might be lost.  In gdb, one can now "disas main" or
"disas '.ret'" to disassemble functions by name.

Most symbols are in sections, so I also teach cvmach to emit the Mach
section headers.  The entry point in plat/osx*/descr moves down to
make room for the section headers and LC_SYMTAB.

I fix some bugs in calculations of cvmach.  They were wrong if ROM had
a greater alignment than TEXT, or if DATA did not start on a page
boundary.  I introduce machseg[] to simplify the mess of variables in
main().  I declare most functions as static.  Also, cvmach becomes the
first program to #include <object.h>.

7 years agoMake possible to #include <object.h>.
George Koehler [Tue, 22 Nov 2016 16:13:14 +0000 (11:13 -0500)]
Make possible to #include <object.h>.

This header declares functions in libobject.  Our programs never
included object.h, but called functions in libobject without declaring
them.  So, our build system never put object.h in the include path;
any #include <object.h> would fail to find the header.

With this commit, a program may #include <object.h> if it has
modules/src/object+lib in its deps.

Declare structs in object.h so we can use them in prototypes without
gcc warning, "'struct whatever' declared inside parameter list".

Remove inclusion of ansi.h from object.h.  Programs would need to
depend on modules+headers to get ansi.h in the include path.

7 years agoAlso call .trp .trap, for ncg compatibility.
David Given [Sun, 20 Nov 2016 18:39:28 +0000 (19:39 +0100)]
Also call .trp .trap, for ncg compatibility.

7 years agoinn on ncg now passes the CPU tests.
David Given [Sun, 20 Nov 2016 18:35:34 +0000 (19:35 +0100)]
inn on ncg now passes the CPU tests.

7 years agoFinally fix the build system issue where ackprogram would try to explicitly
David Given [Sun, 20 Nov 2016 17:57:44 +0000 (18:57 +0100)]
Finally fix the build system issue where ackprogram would try to explicitly
link all the language libraries.