mes.git
2 years agocore: expand_variable: Remove weird exceptions: begin, if.
Jan Nieuwenhuizen [Tue, 16 Oct 2018 15:13:04 +0000 (17:13 +0200)]
core: expand_variable: Remove weird exceptions: begin, if.

* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.

2 years agomes: Switch to srfi-9 based on structs.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 18:42:10 +0000 (20:42 +0200)]
mes: Switch to srfi-9 based on structs.

* mes/module/srfi/srfi-9.mes: Swap symlink to srfi-9-struct.mes.
* mes/module/srfi/srfi-9/gnu.mes: Swap symlink to gnu-struct.mes.
* src/module.c (make_module_type): Update to match srfi-9-struct
records.  Update users.
* src/hash.c (make_hashq_type): Likewise.

2 years agomes: srfi-9: Add implementation based on struct.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 14:57:00 +0000 (16:57 +0200)]
mes: srfi-9: Add implementation based on struct.

* mes/module/srfi/srfi-9-struct.mes: New file.
* mes/module/srfi/srfi-9-vector.mes: Rename from srfi-9.mes
* mes/module/srfi/srfi-9.mes: Symlink to srfi-9-vector.mes.
* mes/module/srfi/srfi-9/gnu-struct.mes: Add srfi-9-struct
implementation.
* mes/module/srfi/srfi-9/gnu-vector.mes: Rename from gnu.mes.
* mes/module/srfi/srfi-9/gnu.mes: Symlink to gnu-vector.mes.

2 years agocore: hashq-table: Refactor to be a record-like struct.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 13:45:41 +0000 (15:45 +0200)]
core: hashq-table: Refactor to be a record-like struct.

* src/hash.c (hash_table_printer): New function.
(make_hashq_type): New function.
* src/module.c (module_printer): Use it.
(make_module_type): New function.
(make_initial_module): Use them.

2 years agomescc: Mes C Library: oputs: New function.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 13:44:47 +0000 (15:44 +0200)]
mescc: Mes C Library: oputs: New function.

* lib/mes/oputc.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare it.

2 years agocore: Use hashq-table for macros.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 12:13:51 +0000 (14:13 +0200)]
core: Use hashq-table for macros.

* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.

2 years agocore: Add hashq-table type.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 11:36:19 +0000 (13:36 +0200)]
core: Add hashq-table type.

src/hash.c: New file.
src/module.c (char_hash, module_hash): Remove.
* src/module.c (make_initial_module): Use hash primitives.
(module_define_x): Likewise.
(module_variable): Likewise.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

2 years agocore: Add boot-module.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 08:44:47 +0000 (10:44 +0200)]
core: Add boot-module.

* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.

2 years agocore: Add module-define!
Jan Nieuwenhuizen [Sun, 14 Oct 2018 07:10:30 +0000 (09:10 +0200)]
core: Add module-define!

* src/module.c (module_define_x, module_printer): New function.
(make_initial_module): Use them.
* tests/srfi-0.test: Test it.
* src/mes.c (display_m0): Remove.  Update callers.
* mes/module/mes/fluids.mes (make-fluid): Rewrite.
* tests/macro.test: Test it.
* mes/module/mes/boot-0.scm.in (module-define!): Remove.
* mes/module/mes/boot-02.scm: Likewise.
* module/mes/misc.scm (pk, warn): New function.
* build-aux/check-mes.sh (tests): Run tests.

2 years agocore: Add module indirection for variable lookup.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 06:30:18 +0000 (08:30 +0200)]
core: Add module indirection for variable lookup.

* src/module.c (module_ref, module_variable): New function.
* src/mes.c: Thoughout: Use them.
(assq_ref_env): Remove.
* mes/module/mes/boot-0.scm.in (defined?): Use module-variable.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.

2 years agocore: Add module type.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 06:15:22 +0000 (08:15 +0200)]
core: Add module type.

* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

2 years agocore: Add cstring_to_symbol.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 05:38:51 +0000 (07:38 +0200)]
core: Add cstring_to_symbol.

* src/mes.c (make_symbol): Rename from lookup_symbol_.  Update
callers.
(cstring_to_symbol): New function.
* src/reader.c (reader_read_identifier_or_number): Use it.

2 years agocore: Add struct type.
Jan Nieuwenhuizen [Sat, 13 Oct 2018 15:34:27 +0000 (17:34 +0200)]
core: Add struct type.

* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

2 years agobuild: factor-out snarfing.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 11:48:50 +0000 (13:48 +0200)]
build: factor-out snarfing.

* build-aux/snarf.sh: New file.
* build-aux/build-cc.sh: Use it.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-cc64.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/snarf.sh: Likewise.

2 years agocore: core:cdr: Support port type.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 10:28:02 +0000 (12:28 +0200)]
core: core:cdr: Support port type.

* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.

2 years agomes: with-fluids: Fix reset.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 08:39:02 +0000 (10:39 +0200)]
mes: with-fluids: Fix reset.

* mes/module/mes/fluids.mes (with-fluids): Fix reset.
* tests/fluids.test (report): Remove Mes failure expectation.

2 years agomescc: Recognize U integer suffix.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 21:31:30 +0000 (23:31 +0200)]
mescc: Recognize U integer suffix.

* module/mescc/compile.scm (cstring->int): Recognize U integer
suffix.  Thanks, Peter de Wachter!

2 years agomescc: Add INTn_MIN/MAX defines to stdint.h.
Peter De Wachter [Tue, 16 Oct 2018 18:40:41 +0000 (20:40 +0200)]
mescc: Add INTn_MIN/MAX defines to stdint.h.

* include/stdint.h: Add INTn_MIN/MAX defines.  Move integere size
defines from limits.h
* include/limits.h: Include it.

2 years agomescc: Allow superfluous parentheses in function declarations.
Peter De Wachter [Tue, 16 Oct 2018 18:40:40 +0000 (20:40 +0200)]
mescc: Allow superfluous parentheses in function declarations.

E.g.:  int (f)();
This is obscure but valid C.  It occurs in the csmith headers (thanks
to macro shenanigans).

* module/mescc/compile.scm (fctn-defn:get-name,
fctn-defn:get-statement): Allow superfluous parentheses in function declarations.

2 years agomescc: Implement unary plus operator.
Peter De Wachter [Tue, 16 Oct 2018 18:40:38 +0000 (20:40 +0200)]
mescc: Implement unary plus operator.

* module/mescc/compile.scm (ast->type, expr->register,
try-expr->number):): Implement unary plus operator.

2 years agomescc: Add missing assembly defines.
Peter De Wachter [Tue, 16 Oct 2018 18:40:37 +0000 (20:40 +0200)]
mescc: Add missing assembly defines.

* lib/x86-mes/x86.M1: Add missing assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.

2 years agomescc: Delete duplicate assembly defines.
Peter De Wachter [Tue, 16 Oct 2018 18:40:36 +0000 (20:40 +0200)]
mescc: Delete duplicate assembly defines.

* lib/x86-mes/x86.M1: Delete duplicate assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.

2 years agomescc: Exit with non-zero exit code when subprocess fails.
Peter De Wachter [Tue, 16 Oct 2018 18:40:35 +0000 (20:40 +0200)]
mescc: Exit with non-zero exit code when subprocess fails.

system* returns the result of waitpid. So, suppose that a subprocess
fails with exit code 1. Then the waitpid return value will be 256.
And exit(256) is equivalent to exit(0).

Modified-by: Jan Nieuwenhuizen <janneke@gnu.org>
* mes/module/mes/posix.mes (status:exit-val): New function.
* module/mescc/mescc.scm (assert-system*): Use it.

2 years agomescc: Oops typo.
Jan Nieuwenhuizen [Fri, 12 Oct 2018 07:37:10 +0000 (09:37 +0200)]
mescc: Oops typo.

* module/mescc/M1.scm (hex2:immediate8): Typo.

22 months agocore: Support \xNN in reader. Fixes tcc-boot running on Mes. fix
Jan Nieuwenhuizen [Thu, 13 Dec 2018 17:19:19 +0000 (18:19 +0100)]
core: Support \xNN in reader.  Fixes tcc-boot running on Mes.

* src/reader.c (reader_read_string): Support \xNN.  Fixes Guix
bootstrap chain; i.e., compilation of gcc-2.95.3 using tcc-boot.
* tests/base.test ("reader: \\x08"): Test it.
* scaffold/tests/17-compare-char.c: Likewise, for mescc.
* build-aux/check-mescc.sh (tests): Run it.

23 months agobuild: configure: Make dot optional.
Jan Nieuwenhuizen [Sun, 18 Nov 2018 13:30:47 +0000 (14:30 +0100)]
build: configure: Make dot optional.

* configure: Make dot optional.

2 years agobuild: Oops, remove stray lib/linux/x86_64-mes/crt1.
Jan Nieuwenhuizen [Thu, 11 Oct 2018 19:14:14 +0000 (21:14 +0200)]
build: Oops, remove stray lib/linux/x86_64-mes/crt1.

* lib/linux/x86_64-mes/crt1: Remove.

2 years agobuild: x86_64 bootstrap build fixes and workaround.
Jan Nieuwenhuizen [Tue, 9 Oct 2018 17:22:51 +0000 (19:22 +0200)]
build: x86_64 bootstrap build fixes and workaround.

* configure: Substitute @arch@ (WAS: ARCH).  Update users.
* configure.sh: Substitute @arch@.
* build-aux/build-mes.sh: Use $GUILE for x86_64 build.
* build-aux/install.sh.in: Install mes.S, mes.x86_64-mes-S too.
Prune *.E, *.out.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 15:19:04 +0000 (17:19 +0200)]
doc: Release update.

2 years agomescc: Oops, delete wrong line of assembly.
Jan Nieuwenhuizen [Mon, 8 Oct 2018 05:53:09 +0000 (07:53 +0200)]
mescc: Oops, delete wrong line of assembly.

* lib/x86-mes/x86.M1 (movzbl_%bx,%ebx): Delete wrong line.  Thanks, pdewacht!

2 years agoadmin: Release update.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 13:29:42 +0000 (15:29 +0200)]
admin: Release update.

* doc/announce/ANNOUNCE-0.18: New file.
* guix/git/mes.scm (mes): Update hash.

2 years agoRelease 0.18. v0.18
Jan Nieuwenhuizen [Thu, 4 Oct 2018 21:15:25 +0000 (23:15 +0200)]
Release 0.18.

* configure (VERSION): Update to 0.18.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.
* guix/mescc-tools-boot.patch: New file.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 05:05:08 +0000 (07:05 +0200)]
doc: Release update.

* BOOTSTRAP: Update.
* HACKING: Update.
* NEWS: Update.
* README: Update.
* doc/mes.texi (Submitting Patches): Fix misquoting, misattribution.

2 years agomescc: Another attempt at divide.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 13:15:45 +0000 (15:15 +0200)]
mescc: Another attempt at divide.

* module/mescc/i386/as.scm (i386:r0/r1): Never be signed.  Use div for unsigned.
(i386:r0%r1): Likewise.
* module/mescc/x86_64/as.scm (x86_64:r0/r1): Likewise.
(x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Add div.
* lib/x86_64-mes/x86_64.M1: Likewise.

2 years agotests: Expect srfi-13 failure, MesCC more resembles Gcc.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 12:14:50 +0000 (14:14 +0200)]
tests: Expect srfi-13 failure, MesCC more resembles Gcc.

* tests/srfi-13.test (report): Expect INT-MIN failure for x86.

2 years agocore: reader: Support 64 bit.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 22:58:31 +0000 (00:58 +0200)]
core: reader: Support 64 bit.

* src/reader.c (reader_read_identifier_or_number): Support 64 bit.
(reader_read_binary): Likewise.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.

2 years agomescc: Mes C Library: Fix execve on x86_64.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 20:38:28 +0000 (22:38 +0200)]
mescc: Mes C Library: Fix execve on x86_64.

* include/linux/x86_64/syscall.h (SYS_execve): Typo.  Fixes execve on
x86_64.

2 years agobuild: Support make seed for x86_64.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 20:26:07 +0000 (22:26 +0200)]
build: Support make seed for x86_64.

* build-aux/GNUmakefile.in (seed): Support make seed for x86_64.
* build-aux/build-mes.sh[SEED]: Also build src/mes.S.
* build-aux/build-x86_64-mes.sh[SEED]: Also build src/mes.x86_64-mes.S.

2 years agomes: Support fold-right 3.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 19:05:43 +0000 (21:05 +0200)]
mes: Support fold-right 3.

* mes/module/srfi/srfi-1.mes (fold-right): Support fold-right 3.
* tests/srfi-1.test ("fold-right-3"): Test it.

2 years agomescc: Nyacc comment escapes.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 18:32:49 +0000 (20:32 +0200)]
mescc: Nyacc comment escapes.

* module/mescc/compile.scm (ast->comment): Nyacc comment escapes.

2 years agomescc: Fix clobbering of struct by value assign.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 18:23:43 +0000 (20:23 +0200)]
mescc: Fix clobbering of struct by value assign.

* module/mescc/x86_64/as.scm (long-r0->r1-mem): New instruction.
* module/mescc/i386/as.scm: Likewise.
* lib/x86_64-mes/x86_64.M1: Support it.
* module/mescc/compile.scm (r0->r1-mem*n-): Fix clobbering.

2 years agocore: Add vector test.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:13:04 +0000 (07:13 +0200)]
core: Add vector test.

* scaffold/boot/11-vector.scm: New test.
* build-aux/check-boot.sh: Run it.

2 years agomescc: Fix obnoxious assignment ERROR message.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 17:22:16 +0000 (19:22 +0200)]
mescc: Fix obnoxious assignment ERROR message.

* module/mescc/compile.scm (expression->register): Fix assignment
ERROR message.

2 years agocore: Avoid 64bit zero divide.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 22:25:33 +0000 (00:25 +0200)]
core: Avoid 64bit zero divide.

* src/math.c (divide): Avoid (64bit) 0 divide.
(modulo): Likewise.

2 years agomescc: Support negative divide.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 15:28:08 +0000 (17:28 +0200)]
mescc: Support negative divide.

* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Support
negative divide.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Likewise.
* lib/x86_64-mes/x86_64.M1: Likewise.
* scaffold/tests/a0-math-divide-signed-negative.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Support --align, off by default.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:56:14 +0000 (15:56 +0200)]
mescc: Support --align, off by default.

* scripts/mescc.in (parse-opts): Add --align.
* module/mescc/mescc.scm (mescc:compile): Support --align, off by
default.
* module/mescc/M1.scm (infos->M1): Add #:align parameter.
(M1:merge-infos): Likewise.  Keep types.
(info->M1): Likewise.  Make alignment switchable.
* module/mescc/compile.scm (r->ident):  Do not clobber.
(ident-add): Likewise.
(clean-info): Keep types.
* module/mescc/i386/as.scm (i386:r->byte-label): New instruction.
* lib/x86-mes/x86.M1: Add instructions.
* lib/x86_64-mes/x86_64.M1: Add instructions.
* module/mescc/x86_64/as.scm (x86_64:r->byte-label,
x86_64:r->word-label, x86_64:r->long-label): New instruction.

2 years agoRevert "mescc: Make globals at least reg-size."
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:57:52 +0000 (15:57 +0200)]
Revert "mescc: Make globals at least reg-size."

This reverts commit 30544316c35ed4a2472f2029beb27e007d913792.

2 years agomescc: Make globals at least reg-size.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:36:32 +0000 (15:36 +0200)]
mescc: Make globals at least reg-size.

* module/mescc/compile.scm (global->info): Make globals at least reg-size.

2 years agomescc: Support 64-bit immediates.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 12:51:57 +0000 (14:51 +0200)]
mescc: Support 64-bit immediates.

* module/mescc/M1.scm (hex2:address8, hex2:immediate8): New function.
(info->M1): Support 64-bit.
* module/mescc/compile.scm (convert-r0): FIXME!
* module/mescc/x86_64/as.scm (x86_64:value->r, x86_64:r->local,
x86_64:label->arg, x86_64:label->r, x86_64:r+value,
x86_64:r-cmp-value, x86_64:r-long-mem-add, x86_64:r-and): Support
64-bit immediates.
* lib/x86_64-mes/x86_64.M1: Likewise.
* scaffold/tests/17-compare-unsigned-char-le.c: Test it.
* scaffold/tests/17-compare-unsigned-short-le.c: Test it.
* build-aux/check-mescc.sh (tests): Run them.

2 years agocore: Use proper name for %compiler.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 06:43:26 +0000 (08:43 +0200)]
core: Use proper name for %compiler.

* src/mes.c (mes_symbols, bload_env): : Use proper name for %compiler.

2 years agocore: Resurrect MES_MINI for non-POSIX.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:25:39 +0000 (07:25 +0200)]
core: Resurrect MES_MINI for non-POSIX.

src/mes.c[MES_MINI,!POSIX]: Resurrect.

2 years agomescc: Mes C Library: Add ultoa.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 10:02:16 +0000 (12:02 +0200)]
mescc: Mes C Library: Add ultoa.

* lib/mes/ultoa.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare ultoa.

2 years agomescc: Mes C Library: Add ltoa.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 09:59:20 +0000 (11:59 +0200)]
mescc: Mes C Library: Add ltoa.

* lib/mes/ltoa.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare ltoa.

2 years agomescc: Fix truncation of short.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 09:57:04 +0000 (11:57 +0200)]
mescc: Fix truncation of short.

* module/mescc/compile.scm (convert-r0): Typo.  Fixes truncation of
short.  Thanks, pdewacht!
* scaffold/tests/a0-call-trunc-char.c: New file.
* scaffold/tests/a0-call-trunc-short.c: New file.
* build-aux/check-mescc.sh: Add them.

2 years agobuild: Split-off x86_mes-gcc build.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:08:20 +0000 (07:08 +0200)]
build: Split-off x86_mes-gcc build.

* build-aux/build-cc64.sh: New file.
* build-aux/build.sh.in[CC64]: Invoke it.
* build-aux/build-cc.sh: Remove x86_64-mes-gcc build.
* build-aux/GNUmakefile.in (x86_64-mes-gcc): New target.
* build-aux/build-x86_64-mes.sh: Build all scafffold files.

2 years agobuild: Oops, use MES_LIBS.
Jan Nieuwenhuizen [Fri, 5 Oct 2018 20:12:48 +0000 (22:12 +0200)]
build: Oops, use MES_LIBS.

* build-aux/build-x86_64-mes.sh: Use MES_LIBS instead of the unused
MES64_LIBS.  Fixes build.  Thanks, pdewacht!

2 years agobuild: remove bashism.
Jan Nieuwenhuizen [Fri, 5 Oct 2018 19:24:14 +0000 (21:24 +0200)]
build: remove bashism.

* build-aux/trace.sh (trace): Remove bashism.  Thanks pdewacht!

2 years agocore: Support x86_64.
Jan Nieuwenhuizen [Thu, 4 Oct 2018 19:43:45 +0000 (21:43 +0200)]
core: Support x86_64.

* src/lib.c: Support x86_64.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/reader.c: Likewise.
* src/vector.c Likewise.

2 years agobuild: Oops, set VERSION.
Jan Nieuwenhuizen [Thu, 4 Oct 2018 21:10:56 +0000 (23:10 +0200)]
build: Oops, set VERSION.

* build-aux/install.sh.in (VERSION): New substituted variable.

2 years agobuild: Resurrect make seed.
Jan Nieuwenhuizen [Sun, 30 Sep 2018 10:15:11 +0000 (12:15 +0200)]
build: Resurrect make seed.

* build-aux/GNUmakefile.in (seed): Resurrect.
* build-aux/build-x86_64-mes.sh: Build from seed.

2 years agomescc: x86_64 support: Refactor to abstracted assembly, add x86_64.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 16:26:55 +0000 (18:26 +0200)]
mescc: x86_64 support: Refactor to abstracted assembly, add x86_64.

* module/mescc/as.scm: Support abstracted assembly.
* module/mescc/i386/as.scm: Rewrite.
* module/mescc/x86_64/as.scm: Implement.
* module/mescc/compile.scm: Refactor to abstracted assembly.
* module/mescc/M1.scm: Update for partial 64 bit support.
* module/mescc/bytevectors.scm (bytevector-u64-native-set!): New
procedure.
* module/mescc/i386/info.scm (i386:type-alist): Use 4 byte type length
also for faking double, long long, long double.
* module/mescc/info.scm:modified:
* module/mescc/x86_64/info.scm (x86_64:registers): New variable.
* lib/x86-mes/x86.M1: Update for new register scheme.
* lib/x86_64-mes/x86_64.M1: Implement.
* lib/x86-mes/setjmp.c: Implement.
* lib/x86_64-mes-gcc/setjmp.c: Implement.
* build-aux/build-cc.sh: Update for x86_64.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/test64.sh: Likewise.
* include/libmes.h: Likewise.
* include/setjmp.h: Likewise.
* include/signal.h: Likewise.
* include/stdarg.h: Likewise.
* include/sys/stat.h: Likewise.
* include/sys/types.h: Likewise.
* include/sys/wait.h: Likewise.
* include/unistd.h: Likewise.
* lib/libc+gnu.c: Likewise.
* lib/libc+tcc.c: Likewise.
* lib/linux/gnu.c: Likewise.
* lib/linux/libc-mini.c: Likewise.
* lib/linux/libc.c: Likewise.
* lib/linux/tcc.c: Likewise.
* lib/linux/x86_64-mes-gcc/mes.c: Likewise.
* lib/linux/x86_64-mes/crt1.c: Likewise.
* lib/mes/abtol.c: Likewise.
* lib/posix/mktemp.c: Likewise.
* lib/posix/wait.c: Likewise.
* lib/stdio/fopen.c: Likewise.
* lib/stdio/fputc.c: Likewise.
* lib/stdio/fseek.c: Likewise.
* lib/stdio/printf.c: Likewise.
* lib/stdio/sprintf.c: Likewise.
* lib/stdio/vfprintf.c: Likewise.
* lib/stdio/vsprintf.c: Likewise.
* lib/stdio/vsscanf.c: Likewise.
* lib/stdlib/qsort.c: Likewise.
* lib/x86-mes-gcc/setjmp.c: Likewise.
* scaffold/tests/11-if-1.c: Likewise.
* scaffold/tests/15-if-!f.c: Likewise.
* scaffold/tests/16-if-t.c: Likewise.
* scaffold/tests/21-char[].c: Likewise.
* scaffold/tests/23-pointer.c: Likewise.
* scaffold/tests/32-compare.c: Likewise.
* scaffold/tests/33-and-or.c: Likewise.
* scaffold/tests/34-pre-post.c: Likewise.
* scaffold/tests/35-compare-char.c: Likewise.
* scaffold/tests/36-compare-arithmetic.c: Likewise.
* scaffold/tests/37-compare-assign.c: Likewise.
* scaffold/tests/38-compare-call.c: Likewise.
* scaffold/tests/40-if-else.c: Likewise.
* scaffold/tests/41-?.c: Likewise.
* scaffold/tests/42-goto-label.c: Likewise.
* scaffold/tests/43-for-do-while.c: Likewise.
* scaffold/tests/44-switch.c: Likewise.
* scaffold/tests/45-void-call.c: Likewise.
* scaffold/tests/46-function-static.c: Likewise.
* scaffold/tests/51-strcmp.c: Likewise.
* scaffold/tests/51-strncmp.c: Likewise.
* scaffold/tests/53-strcpy.c: Likewise.
* scaffold/tests/54-argv.c: Likewise.
* scaffold/tests/60-math.c: Likewise.
* scaffold/tests/61-array.c: Likewise.
* scaffold/tests/63-struct-cell.c: Likewise.
* scaffold/tests/64-make-cell.c: Likewise.
* scaffold/tests/65-read.c: Likewise.
* scaffold/tests/70-printf.c: Likewise.
* scaffold/tests/71-struct-array.c: Likewise.
* scaffold/tests/72-typedef-struct-def.c: Likewise.
* scaffold/tests/74-multi-line-string.c: Likewise.
* scaffold/tests/76-pointer-arithmetic.c: Likewise.
* scaffold/tests/79-int-array.c: Likewise.
* scaffold/tests/7a-struct-char-array.c: Likewise.
* scaffold/tests/7b-struct-int-array.c: Likewise.
* scaffold/tests/7i-struct-struct.c: Likewise.
* scaffold/tests/7k-for-each-elem.c: Likewise.
* scaffold/tests/7l-struct-any-size-array.c: Likewise.
* scaffold/tests/7o-struct-pre-post.c: Likewise.
* scaffold/tests/7q-bit-field.c: Likewise.
* scaffold/tests/7s-struct-short.c: Likewise.
* scaffold/tests/80-setjmp.c: Likewise.
* scaffold/tests/81-qsort.c: Likewise.
* scaffold/tests/85-sizeof.c: Likewise.
* scaffold/tests/87-sscanf.c: Likewise.
* scaffold/tests/90-strpbrk.c: Likewise.
* scaffold/tests/91-fseek.c: Likewise.
* scaffold/tests/95-signal.c: Likewise.
* scaffold/tests/97-fopen.c: Likewise.
* scaffold/tests/99-readdir.c: Likewise.
* scaffold/tests/t.c: Likewise.
* lib/linux/x86_64-mes/mes.c: New file.
* lib/linux/x86_64-mes/mini.c: New file.
* lib/x86_64-mes/setjmp.c: New file.
* scaffold/tests/06-!call-1.c: New file.
* scaffold/tests/06-call-2.c: New file.
* scaffold/tests/06-call-variable.c: New file.
* scaffold/tests/08-assign-global.c: New file.
* scaffold/tests/08-assign-negative.c: New file.
* scaffold/tests/17-compare-and-or.c: New file.
* scaffold/tests/17-compare-and.c: New file.
* scaffold/tests/17-compare-ge.c: New file.
* scaffold/tests/17-compare-gt.c: New file.
* scaffold/tests/17-compare-le.c: New file.
* scaffold/tests/17-compare-lt.c: New file.
* scaffold/tests/17-compare-or.c: New file.
* scaffold/tests/17-compare-unsigned-ge.c: New file.
* scaffold/tests/17-compare-unsigned-gt.c: New file.
* scaffold/tests/17-compare-unsigned-le.c: New file.
* scaffold/tests/17-compare-unsigned-lt.c: New file.
* scaffold/tests/21-char[]-simple.c: New file.
* scaffold/tests/23-global-pointer-init-null.c: New file.
* scaffold/tests/23-global-pointer-init.c: New file.
* scaffold/tests/23-global-pointer-pointer-ref.c: New file.
* scaffold/tests/23-global-pointer-ref.c: New file.
* scaffold/tests/23-pointer-sub.c: New file.
* scaffold/tests/31-oputs.c: New file.
* scaffold/tests/32-call-wrap.c: New file.
* scaffold/tests/38-compare-call-2.c: New file.
* scaffold/tests/38-compare-call-3.c: New file.
* scaffold/tests/51-pointer-sub.c: New file.
* scaffold/tests/54-argc.c: New file.
* scaffold/tests/63-struct-array-assign.c: New file.
* scaffold/tests/63-struct-array-compare.c: New file.
* scaffold/tests/63-struct-array.c: New file.
* scaffold/tests/63-struct-assign.c: New file.
* scaffold/tests/63-struct-function.c: New file.
* scaffold/tests/63-struct-local.c: New file.
* scaffold/tests/63-struct-pointer.c: New file.
* scaffold/tests/63-struct.c: New file.
* scaffold/tests/70-printf-hello.c: New file.
* scaffold/tests/70-printf-simple.c: New file.
* scaffold/tests/70-stdarg.c: New file.
* scaffold/tests/70-strchr.c: New file.
* scaffold/tests/73-union-hello.c: New file.
* scaffold/tests/76-pointer-arithmetic-pp.c: New file.
* scaffold/tests/79-int-array-simple.c: New file.
* scaffold/tests/7b-struct-int-array-hello.c: New file.
* scaffold/tests/7b-struct-int-array-pointer.c: New file.
* scaffold/tests/7i-struct-struct-simple.c: New file.
* scaffold/tests/7k-for-each-elem-simple.c: New file.
* scaffold/tests/7l-struct-any-size-array-simple.c: New file.
* scaffold/tests/7o-struct-pre-post-simple.c: New file.
* scaffold/tests/7q-bit-field-simple.c: New file.
* scaffold/tests/90-strspn.c: New file.
* scaffold/tests/06-call-string.c.: Rename from 31-eputs.c.
* scaffold/tests/7t-function-destruct.c: Rename from 48-function-destruct.c.
* scaffold/tests/48-global-static.c: Rename from 49-global-static.c.
* scaffold/tests/55-char-array.c:renamed: Rename from 4a-char-array.c.
* scaffold/tests/51-itoa.c:r Rename from 52-itoa.c.
* include/signal.h:(struct sigaction):

2 years agomescc: x86_64 support: Add tests.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 15:19:50 +0000 (17:19 +0200)]
mescc: x86_64 support: Add tests.

2 years agomescc: Initial x86_64 support.
Jan Nieuwenhuizen [Tue, 14 Aug 2018 18:32:56 +0000 (20:32 +0200)]
mescc: Initial x86_64 support.

    make all-go && MES=guile ./pre-inst-env scripts/mescc -m64 -c scaffold/main.c

2 years agomescc: Prepare for x86_64 support.
Jan Nieuwenhuizen [Tue, 14 Aug 2018 10:35:24 +0000 (12:35 +0200)]
mescc: Prepare for x86_64 support.

* module/mescc/info.scm (info): Add allocated, registers.
* module/mescc/i386/info.scm: New file.
* build-aux/build-guile.sh (SCM_FILES): Add it.
* module/mescc/compile.scm (c99-input->info): Add info parameter.
(c99-ast->info): Likewise.
(i386:type-alist): Remove.
(alloc-register, free-register): New function.
(expr->register*): Rename from expr->accu*.  Update callers.
(expr->accu): Rename from expr->accu.  Update callers.
* module/mescc/mescc.scm(%info): New variable.
* module/mescc/mescc.scm (c->ast): Use it.
(mescc:compile): Likewise.
(E->info): Likewise.

2 years agoemacs: Add disassembly helpers.
Jan Nieuwenhuizen [Sun, 16 Sep 2018 09:07:39 +0000 (11:07 +0200)]
emacs: Add disassembly helpers.

* .dir-locals.el (as-32, as-64): Add disassembly helpers.

2 years agoguix: nyacc-for-mes: Update to 0.86.0.
Jan Nieuwenhuizen [Tue, 11 Sep 2018 17:35:24 +0000 (19:35 +0200)]
guix: nyacc-for-mes: Update to 0.86.0.

* guix/git/mes.scm (nyacc-for-mes): Update to 0.86.0 plus fix binary
literals.

2 years agomescc: Support gcc-3.0: Locale header fix.
Jan Nieuwenhuizen [Tue, 11 Sep 2018 05:01:33 +0000 (07:01 +0200)]
mescc: Support gcc-3.0: Locale header fix.

* include/locale.h (LC_ALL, LC_NUMERIC): Numbers, not strings.
(LC_COLLATE, LC_CTYPE): New macro.

2 years agobuild: Oops, fix ./check.sh for bootstrap build.
Jan Nieuwenhuizen [Sun, 9 Sep 2018 05:11:50 +0000 (07:11 +0200)]
build: Oops, fix ./check.sh for bootstrap build.

* build-aux/config.sh (top_builddir): Set default to `.'.

2 years agoguix: nyacc-for-mes: Update to 0.85.3.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 20:13:18 +0000 (22:13 +0200)]
guix: nyacc-for-mes: Update to 0.85.3.

* guix/git/mes.scm (nyacc-for-mes): Update to 0.85.3.

2 years agomes: Support Nyacc 0.85.3: Integrate progress.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 20:14:34 +0000 (22:14 +0200)]
mes: Support Nyacc 0.85.3: Integrate progress.

* mes/module/nyacc/lang/sx-util.mes: New file.
* mes/module/nyacc/version.mes: New file.
* mes/module/nyacc/lang/c99/cpp.mes (nyacc): Include them.
* mes/module/nyacc/lang/c99/parser.mes (nyacc): Include them.
* module/mescc/preprocess.scm (need-progress): New function.
(progress): New function.
(insert-progress-monitors): Use them to Integrate progress.

2 years agomes: Support Nyacc 0.85.3: Add char-set-copy.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 18:28:06 +0000 (20:28 +0200)]
mes: Support Nyacc 0.85.3: Add char-set-copy.

* mes/module/srfi/srfi-14.mes (char-set-copy): New function>

2 years agodoc: Update bootstrap graph.
Jan Nieuwenhuizen [Tue, 4 Sep 2018 05:51:15 +0000 (07:51 +0200)]
doc: Update bootstrap graph.

* doc/images/gcc-mesboot-graph.dot: Regenerate.
* build-aux/GNUmakefile.in (doc/mes.info): Oops change dependency to .png.
* doc/mes.texi (The Mes Bootstrap Process): Update image and wording.

2 years agoguix: Update hash.
Jan Nieuwenhuizen [Tue, 4 Sep 2018 04:40:47 +0000 (06:40 +0200)]
guix: Update hash.

* guix/git/mes.scm (mes): Update hash.

2 years agoRelease 0.17.1. v0.17.1
Jan Nieuwenhuizen [Mon, 3 Sep 2018 17:57:22 +0000 (19:57 +0200)]
Release 0.17.1.

* configure (VERSION): Update to 0.17.1.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* build-aux/GNUmakefile.in (gen-announce): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Thu, 9 Aug 2018 22:22:05 +0000 (00:22 +0200)]
doc: Release update.

* HACKING (prefix): Update.
* INSTALL (http): Update.
* NEWS: Update.
* README (C-compiler): Update.
* doc/announce/ANNOUNCE-0.17: Update.

2 years agobuild: ALlow releasing from worktree.
Jan Nieuwenhuizen [Mon, 3 Sep 2018 18:09:45 +0000 (20:09 +0200)]
build: ALlow releasing from worktree.

* build-aux/GNUmakefile.in (COMMIT): Check for .git file.

2 years agomescc: Mes C Library: Do not redefine size_t.
Jan Nieuwenhuizen [Sat, 1 Sep 2018 14:55:45 +0000 (16:55 +0200)]
mescc: Mes C Library: Do not redefine size_t.

* include/stddef.h: Do not redefine size_t.

2 years agomescc: Mes C Library: Support make 3.80: Add setlocale, sigaddset.
Jan Nieuwenhuizen [Mon, 27 Aug 2018 22:45:23 +0000 (00:45 +0200)]
mescc: Mes C Library: Support make 3.80: Add setlocale, sigaddset.

* include/limits.h (ULONG_MAX): New macro.
* include/locale.h (LC_ALL, LC_NUMERIC): New macro.
* lib/stub/setlocale.c: New file.
* lib/stub/sigaddset.c: New file.
* lib/libc+gnu.c: Include them.

2 years agomescc: Mes C Library: Fix qsort to support duplicate entries.
Jan Nieuwenhuizen [Mon, 27 Aug 2018 20:37:12 +0000 (22:37 +0200)]
mescc: Mes C Library: Fix qsort to support duplicate entries.

* lib/stdlib/qsort.c (qpart): Handle dupes.
* scaffold/tests/81-qsort-dupes.c: New file.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Mes C Library: Support make: Implement clock_gettime, time.
Jan Nieuwenhuizen [Sun, 26 Aug 2018 22:34:13 +0000 (00:34 +0200)]
mescc: Mes C Library: Support make: Implement clock_gettime, time.

* include/linux/x86/syscall.h (SYS_time, SYS_clock_gettime,
SYS_gettimeofday): New macro.
* include/linux/x86_64/syscall.h (SYS_time, SYS_clock_gettime,
SYS_gettimeofday): New macro.
* lib/linux/tcc.c (gettimeofday, time): New function.
* lib/linux/gnu.c (clock_gettime): New function.
* include/time.h: Declare it.
* lib/stub/gettimeofday.c: Remove.
* lib/stub/time.c: Remove.

2 years agomescc: Mes C Library: Support make: Support main with envp.
Jan Nieuwenhuizen [Sun, 26 Aug 2018 21:39:43 +0000 (23:39 +0200)]
mescc: Mes C Library: Support make: Support main with envp.

* lib/linux/x86-mes-gcc/crt1.c (_start): Also push envp.
* lib/linux/x86-mes/crt1.c (_start): Also push envp.
* lib/linux/x86_64-mes-gcc/crt1.c (_start): Also mov environment,%rdx.

2 years agomescc: Mes C Library: Support make: Add chdir, getlogin, setvbuf, sigblock.
Jan Nieuwenhuizen [Sun, 26 Aug 2018 20:41:52 +0000 (22:41 +0200)]
mescc: Mes C Library: Support make: Add chdir, getlogin, setvbuf, sigblock.

* lib/stub/getlogin.c: New file.
* lib/stub/setvbuf.c: New file.
* lib/stub/sigblock.c: New file.
* lib/libc+gnu.c: Include them.
* include/linux/x86/syscall.h (SYS_chdir): New macro.
* include/linux/x86_64/syscall.h (SYS_chdir): New macro.
* include/stdio.h (_IOFBF, _IOLBF, _IONBF): New macro.
* include/errno.h (ENOEXEC, ECHILD): New macro.
* include/sys/wait.h (WNOHANG): New macro.
* lib/linux/gnu.c (chdir): New function.
* include/ar.h: New file.

2 years agomescc: Mes C Library: Support diffutils: Add execl.
Jan Nieuwenhuizen [Sun, 26 Aug 2018 18:54:29 +0000 (20:54 +0200)]
mescc: Mes C Library: Support diffutils: Add execl.

* include/limits.h (CHAR_MAX): New macro.
* lib/posix/execl.c: New file.
* include/unistd.h: Declare it.

2 years agomescc: Mes C Library: Add closedir, opendir, readdir.
Jan Nieuwenhuizen [Sun, 26 Aug 2018 16:34:53 +0000 (18:34 +0200)]
mescc: Mes C Library: Add closedir, opendir, readdir.

* include/dirent.h: New file.  Import from glibc-2.2.5.
* include/dirstream.h: Likewise.
* lib/dirent/__getdirentries.c: Likewise.
* lib/dirent/closedir.c: Likewise.
* lib/dirent/readdir.c (readdir): Likewise.
* lib/libc+gnu.c: Include them.
* include/linux/x86/syscall.h (SYS_getdents): New macro.
* include/linux/x86_64/syscall.h (SYS_getdents): Likewise.
* lib/linux/gnu.c (getdents): New function.
* include/limits.h (NAME_MAX): New macro.
* include/fcntl.h (O_DIRECTORY): New macro.
* scaffold/tests/readdir.dir: New directory.
* scaffold/tests/99-readdir.c: New file, use it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Mes C Library: Move strncmp to own test.
Jan Nieuwenhuizen [Tue, 21 Aug 2018 18:33:54 +0000 (20:33 +0200)]
mescc: Mes C Library: Move strncmp to own test.

* scaffold/tests/51-strcmp.c: Remove strncmp tests.
* scaffold/tests/51-strncmp.c: New file.
* build-aux/check-mescc.sh (tests): Add it.

2 years agotest: Cleanup includes.
Jan Nieuwenhuizen [Sun, 19 Aug 2018 09:18:43 +0000 (11:18 +0200)]
test: Cleanup includes.

* scaffold/tests/30-strlen.c: Include only libmes-mini.h
* scaffold/tests/31-eputs.c: Likewise.
* scaffold/tests/32-compare.c: Likewise.
* scaffold/tests/33-and-or.c: Likewise.
* scaffold/tests/34-pre-post.c: Likewise.
* scaffold/tests/35-compare-char.c: Likewise.
* scaffold/tests/36-compare-arithmetic.c: Likewise.
* scaffold/tests/37-compare-assign.c: Likewise.
* scaffold/tests/38-compare-call.c: Likewise.
* scaffold/tests/40-if-else.c: Likewise.
* scaffold/tests/41-?.c: Likewise.
* scaffold/tests/42-goto-label.c: Likewise.
* scaffold/tests/43-for-do-while.c: Likewise.
* scaffold/tests/44-switch.c: Likewise.
* scaffold/tests/45-void-call.c: Likewise.

2 years agomescc: Cleanup includes.
Jan Nieuwenhuizen [Sun, 19 Aug 2018 09:17:57 +0000 (11:17 +0200)]
mescc: Cleanup includes.

* include/libmes-mini.h: New file.
* include/libmes.h: Use it.

2 years agomescc: Add dir to include path.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 17:11:54 +0000 (19:11 +0200)]
mescc: Add dir to include path.

* module/mescc/mescc.scm (preprocess): Add dir to include path.
(c->info): Likewise.
* scaffold/tests/08-assign.c: New file.

2 years agocheck-mescc: c-mini
Jan Nieuwenhuizen [Thu, 16 Aug 2018 19:04:36 +0000 (21:04 +0200)]
check-mescc: c-mini

2 years agomescc: Mes C Library: Explode libc+gnu.c.
Jan Nieuwenhuizen [Fri, 24 Aug 2018 18:57:34 +0000 (20:57 +0200)]
mescc: Mes C Library: Explode libc+gnu.c.

* modified:   include/math.h: Add declarations.
* lib/posix/getopt.c: Rename from lib/getopt.c.
* lib/gcc.c: Remove.
* lib/m4.c: Remove.
* lib/ctype/isalnum.c: New file, explode from libc+gnu.c.
* lib/ctype/isalpha.c: Likewise.
* lib/ctype/isascii.c: Likewise.
* lib/ctype/iscntrl.c: Likewise.
* lib/ctype/isnumber.c: Likewise.
* lib/ctype/isprint.c: Likewise.
* lib/ctype/ispunct.c: Likewise.
* lib/math/fabs.c: Likewise.
* lib/posix/alarm.c: Likewise.
* lib/posix/mktemp.c: Likewise.
* lib/posix/raise.c: Likewise.
* lib/posix/sbrk.c: Likewise.
* lib/posix/sleep.c: Likewise.
* lib/posix/unsetenv.c: Likewise.
* lib/stdio/clearerr.c: Likewise.
* lib/stdio/fdgets.c: Likewise.
* lib/stdio/feof.c: Likewise.
* lib/stdio/fgets.c: Likewise.
* lib/stdio/fileno.c: Likewise.
* lib/stdio/freeopen.c: Likewise.
* lib/stdio/freopen.c: Likewise.
* lib/stdio/perror.c: Likewise.
* lib/stdlib/__exit.c: Likewise.
* lib/stdlib/abs.c: Likewise.
* lib/stdlib/atexit.c: Likewise.
* lib/stdlib/atol.c: Likewise.
* lib/stdlib/bsearch.c: Likewise.
* lib/stdlib/mbstowcs.c: Likewise.
* lib/string/bcmp.c: Likewise.
* lib/string/bcopy.c: Likewise.
* lib/string/bzero.c: Likewise.
* lib/string/index.c: Likewise.
* lib/string/rindex.c: Likewise.
* lib/string/strcspn.c: Likewise.
* lib/string/strdup.c: Likewise.
* lib/string/strerror.c: Likewise.
* lib/string/strncat.c: Likewise.
* lib/string/strpbrk.c: Likewise.
* lib/string/strspn.c: Likewise.
* lib/stub/__cleanup.c: Likewise.
* lib/stub/atof.c: Likewise.
* lib/stub/chown.c: Likewise.
* lib/stub/ctime.c: Likewise.
* lib/stub/fpurge.c: Likewise.
* lib/stub/freadahead.c: Likewise.
* lib/stub/frexp.c: Likewise.
* lib/stub/fscanf.c: Likewise.
* lib/stub/getpwnam.c: Likewise.
* lib/stub/gmtime.c: Likewise.
* lib/stub/pclose.c: Likewise.
* lib/stub/popen.c: Likewise.
* lib/stub/rewind.c: Likewise.
* lib/stub/setbuf.c: Likewise.
* lib/stub/sigsetmask.c: Likewise.
* lib/stub/strftime.c: Likewise.
* lib/stub/sys_siglist.c: Likewise.
* lib/stub/system.c: Likewise.
* lib/stub/times.c: Likewise.
* lib/stub/umask.c: Likewise.
* lib/stub/utime.c: Likewise.
* lib/libc+gnu.c: Include explodings.
* lib/libg.c: Likewise.
* lib/libgetopt.c: Include explodings.

2 years agomescc: Mes C Library: Explode libc+tcc.c.
Jan Nieuwenhuizen [Wed, 22 Aug 2018 05:23:27 +0000 (07:23 +0200)]
mescc: Mes C Library: Explode libc+tcc.c.

* include/libmes.h: Add declarations.
* include/string.h: Likewise.
* lib/ctype/islower.c: New file, explode from lib/libc+tcc.c.
* lib/ctype/isupper.c: Likewise.
* lib/ctype/tolower.c: Likewise.
* lib/ctype/toupper.c: Likewise.
* lib/mes/search-path.c: Likewise.
* lib/posix/execvp.c: Likewise.
* lib/stdio/fclose.c: Likewise.
* lib/stdio/fdopen.c: Likewise.
* lib/stdio/ferror.c: Likewise.
* lib/stdio/fflush.c: Likewise.
* lib/stdio/fopen.c: Likewise.
* lib/stdio/fprintf.c: Likewise.
* lib/stdio/fread.c: Likewise.
* lib/stdio/fseek.c: Likewise.
* lib/stdio/ftell.c: Likewise.
* lib/stdio/fwrite.c: Likewise.
* lib/stdio/printf.c: Likewise.
* lib/stdio/remove.c: Likewise.
* lib/stdio/snprintf.c: Likewise.
* lib/stdio/sprintf.c: Likewise.
* lib/stdio/sscanf.c: Likewise.
* lib/stdio/vfprintf.c: Likewise.
* lib/stdio/vprintf.c: Likewise.
* lib/stdio/vsnprintf.c: Likewise.
* lib/stdio/vsprintf.c: Likewise.
* lib/stdio/vsscanf.c: Likewise.
* lib/stdlib/calloc.c: Likewise.
* lib/stdlib/qsort.c: Likewise.
* lib/stdlib/strtof.c: Likewise.
* lib/stdlib/strtol.c: Likewise.
* lib/stdlib/strtold.c: Likewise.
* lib/stdlib/strtoll.c: Likewise.
* lib/stdlib/strtoul.c: Likewise.
* lib/stdlib/strtoull.c: Likewise.
* lib/string/memcmp.c: Likewise.
* lib/string/memmem.c: Likewise.
* lib/string/memmove.c: Likewise.
* lib/string/memset.c: Likewise.
* lib/string/strcat.c: Likewise.
* lib/string/strchr.c: Likewise.
* lib/string/strlwr.c: Likewise.
* lib/string/strncpy.c: Likewise.
* lib/string/strrchr.c: Likewise.
* lib/string/strstr.c: Likewise.
* lib/string/strupr.c: Likewise.
* lib/stub/gettimeofday.c: Likewise.
* lib/stub/ldexp.c: Likewise.
* lib/stub/localtime.c: Likewise.
* lib/stub/mprotect.c: Likewise.
* lib/stub/sigaction.c: Likewise.
* lib/stub/sigemptyset.c: Likewise.
* lib/stub/strtod.c: Likewise.
* lib/stub/time.c: Likewise.
* lib/libc+tcc.c: Include explodings.

2 years agomescc: Mes C Library: Explode libmes.c.
Jan Nieuwenhuizen [Thu, 16 Aug 2018 09:43:27 +0000 (11:43 +0200)]
mescc: Mes C Library: Explode libmes.c.

* include/libmes.h: Add declarations.
* lib/abtol.c: New file, explode from lib/libmes.c.
* lib/ctype/isdigit.c: Likewise.
* lib/ctype/isnumber.c: Likewise.
* lib/ctype/isspace.c: Likewise.
* lib/ctype/isxdigit.c: Likewise.
* lib/mes/abtol.c: Likewise.
* lib/mes/eputc.c: Likewise.
* lib/mes/eputs.c: Likewise.
* lib/mes/fdgetc.c: Likewise.
* lib/mes/fdputc.c: Likewise.
* lib/mes/fdputs.c: Likewise.
* lib/mes/fdungetc.c: Likewise.
* lib/mes/itoa.c: Likewise.
* lib/mes/ltoab.c: Likewise.
* lib/mes/ntoab.c: Likewise.
* lib/mes/utoa.c: Likewise.
* lib/stdlib/atoi.c: Likewise.
* lib/libmes.c: Include explodings.

2 years agomescc: Mes C Library: Explode libc-mini.c.
Jan Nieuwenhuizen [Thu, 16 Aug 2018 09:07:33 +0000 (11:07 +0200)]
mescc: Mes C Library: Explode libc-mini.c.

* include/libmes.h: Add declarations.
* lib/mes/eputs.c: New file, explode from lib/libc-mini.c.
* lib/mes/oputs.c: Likewise.
* lib/stdlib/exit.c: Likewise.
* lib/stdlib/puts.c: Likewise.
* lib/string/strlen.c: Likewise.
* lib/libc-mini.c: Include explodings.

2 years agomescc: Mes C Library: Explode libc.c.
Jan Nieuwenhuizen [Thu, 16 Aug 2018 08:50:53 +0000 (10:50 +0200)]
mescc: Mes C Library: Explode libc.c.

* lib/libc.c: New file, explode from lib/libc.c.
* lib/posix/execv.c: Likewise.
* lib/posix/isatty.c: Likewise.
* lib/posix/wait.c: Likewise.
* lib/stdio/fgetc.c: Likewise.
* lib/stdio/fputc.c: Likewise.
* lib/stdio/fputs.c: Likewise.
* lib/stdio/getc.c: Likewise.
* lib/stdio/getchar.c: Likewise.
* lib/stdio/putc.c: Likewise.
* lib/stdio/putchar.c: Likewise.
* lib/stdio/ungetc.c: Likewise.
* lib/stdlib/free.c: Likewise.
* lib/stdlib/getenv.c: Likewise.
* lib/stdlib/realloc.c: Likewise.
* lib/stdlib/setenv.c: Likewise.
* lib/string/strcmp.c: Likewise.
* lib/string/strcpy.c: Likewise.
* lib/string/strncmp.c: Likewise.
* lib/libc.c: Include explodings.

2 years agotest: Build initial scaffold tests without libc.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 15:47:03 +0000 (17:47 +0200)]
test: Build initial scaffold tests without libc.

* scaffold/argv.c (strcmp): New function; support building without
libc.
* build-aux/build-cc.sh: Build initial scaffold tests without libc.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* scaffold/read.data: Rename from `mesmes'.
* scaffold/read.c: Rename from `m.c'; update.

2 years agotest: Remove 30-test.i indirection.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 16:01:14 +0000 (18:01 +0200)]
test: Remove 30-test.i indirection.

* include/30-test.i: Remove.
* scaffold/tests/30-strlen.c: Remove 30-test.i indirection.
* scaffold/tests/31-eputs.c: Likewise.
* scaffold/tests/32-compare.c: Likewise.
* scaffold/tests/33-and-or.c: Likewise.
* scaffold/tests/34-pre-post.c: Likewise.
* scaffold/tests/35-compare-char.c: Likewise.
* scaffold/tests/36-compare-arithmetic.c: Likewise.
* scaffold/tests/37-compare-assign.c: Likewise.
* scaffold/tests/38-compare-call.c: Likewise.
* scaffold/tests/40-if-else.c: Likewise.
* scaffold/tests/41-?.c: Likewise.
* scaffold/tests/42-goto-label.c: Likewise.
* scaffold/tests/43-for-do-while.c: Likewise.
* scaffold/tests/44-switch.c: Likewise.
* scaffold/tests/45-void-call.c: Likewise.
* scaffold/tests/46-function-static.c: Likewise.
* scaffold/tests/50-assert.c: Likewise.
* scaffold/tests/51-strcmp.c: Likewise.
* scaffold/tests/52-itoa.c: Likewise.
* scaffold/tests/53-strcpy.c: Likewise.
* scaffold/tests/60-math.c: Likewise.
* scaffold/tests/63-struct-cell.c: Likewise.
* scaffold/tests/64-make-cell.c: Likewise.
* scaffold/tests/65-read.c: Likewise.
* scaffold/tests/66-local-char-array.c: Likewise.
* scaffold/tests/70-printf.c: Likewise.
* scaffold/tests/71-struct-array.c: Likewise.
* scaffold/tests/72-typedef-struct-def.c: Likewise.
* scaffold/tests/73-union.c: Likewise.
* scaffold/tests/74-multi-line-string.c: Likewise.
* scaffold/tests/75-struct-union.c: Likewise.
* scaffold/tests/76-pointer-arithmetic.c: Likewise.
* scaffold/tests/77-pointer-assign.c: Likewise.
* scaffold/tests/78-union-struct.c: Likewise.
* scaffold/tests/79-int-array.c: Likewise.
* scaffold/tests/7a-struct-char-array.c: Likewise.
* scaffold/tests/7b-struct-int-array.c: Likewise.
* scaffold/tests/7c-dynarray.c: Likewise.
* scaffold/tests/7d-cast-char.c: Likewise.
* scaffold/tests/7e-struct-array-access.c: Likewise.
* scaffold/tests/7f-struct-pointer-arithmetic.c: Likewise.
* scaffold/tests/7g-struct-byte-word-field.c: Likewise.
* scaffold/tests/7h-struct-assign.c: Likewise.
* scaffold/tests/7i-struct-struct.c: Likewise.
* scaffold/tests/7j-strtoull.c: Likewise.
* scaffold/tests/7k-for-each-elem.c: Likewise.
* scaffold/tests/7l-struct-any-size-array.c: Likewise.
* scaffold/tests/7m-struct-char-array-assign.c: Likewise.
* scaffold/tests/7n-struct-struct-array.c: Likewise.
* scaffold/tests/80-setjmp.c: Likewise.
* scaffold/tests/81-qsort.c: Likewise.
* scaffold/tests/86-strncpy.c: Likewise.
* scaffold/tests/87-sscanf.c: Likewise.

2 years agotest: Remove 00-test.i indirection.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 15:27:11 +0000 (17:27 +0200)]
test: Remove 00-test.i indirection.

* include/00-test.i: Remove.
* scaffold/tests/01-return-0.c: Remove 00-test.i indirection.
* scaffold/tests/02-return-1.c: Likewise.
* scaffold/tests/03-call.c: Likewise.
* scaffold/tests/04-call-0.c: Likewise.
* scaffold/tests/05-call-1.c: Likewise.
* scaffold/tests/06-call-!1.c: Likewise.
* scaffold/tests/10-if-0.c: Likewise.
* scaffold/tests/11-if-1.c: Likewise.
* scaffold/tests/12-if-==.c: Likewise.
* scaffold/tests/13-if-!=.c: Likewise.
* scaffold/tests/14-if-goto.c: Likewise.
* scaffold/tests/15-if-!f.c: Likewise.
* scaffold/tests/16-if-t.c: Likewise.
* scaffold/tests/20-while.c: Likewise.
* scaffold/tests/21-char[].c: Likewise.
* scaffold/tests/22-while-char[].c: Likewise.
* scaffold/tests/23-pointer.c: Likewise.

2 years agobuild: Cleanup trace output.
Jan Nieuwenhuizen [Wed, 15 Aug 2018 10:28:08 +0000 (12:28 +0200)]
build: Cleanup trace output.

* build-aux/build-cc.sh: Cleanup trace output.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* build-aux/cc64-mes.sh: Likewise.
* build-aux/check-boot.sh: Likewise.

2 years agomescc: Support -l none (linking without libc).
Jan Nieuwenhuizen [Wed, 15 Aug 2018 15:46:03 +0000 (17:46 +0200)]
mescc: Support -l none (linking without libc).

* module/mescc/mescc.scm (mescc:link): Support -l none.

2 years agomescc: Support -o-.
Jan Nieuwenhuizen [Tue, 14 Aug 2018 08:58:02 +0000 (10:58 +0200)]
mescc: Support -o-.

* module/mescc/mescc.scm (GUILE-with-output-to-file): New variable.
(with-output-to-file): Use it in redefined function.