mes.git
20 months agomescc: Mes C Library: Have write behave well with buffered reads.
Jan Nieuwenhuizen [Sun, 28 Jul 2019 11:01:37 +0000 (13:01 +0200)]
mescc: Mes C Library: Have write behave well with buffered reads.

* lib/mes/write.c: New file.
* build-aux/configure-lib.sh (libc_mini_SOURCES): Add it.
(libc_mini_shared_SOURCES): New variable.
(libc_mini_SOURCES, libmes_SOURCES): Use it.
(libmes_SOURCES): Add lib/linux/lseek.c, lib/posix/write.c.
(libc_tcc_SOURCES): Remove lib/linux/lseek.c.
* lib/posix/write.c (write): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Remove read buffer correction.
* simple.sh: Update.

20 months agomescc: Mes C Library: Add buffered read.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 20:58:49 +0000 (22:58 +0200)]
mescc: Mes C Library: Add buffered read.

* lib/mes/__buffered_read.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.  Also add memmove.c.
(libc_tcc_SOURCES): Remove memmove.c
* lib/linux/close.c (close): Clear read buffer.
* lib/linux/_open3.c (_open3): Likewise.
* lib/linux/lseek.c (lseek): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Likewise.
* lib/posix/read.c (read): Call __buffered_read.
* lib/posix/write.c (write): Add FIXME note about buffered reads.
* simple.sh: Update.

22 months agotests: Disable 70-extern.c for x86_64-gcc.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 21:13:50 +0000 (23:13 +0200)]
tests: Disable 70-extern.c for x86_64-gcc.

* build-aux/check-mescc.sh (XFAIL_TESTS)[x86_64-gcc]: Add
70-extern.c.

22 months agomescc: Put char's ASCII code into register, not char.
Danny Milosavljevic [Thu, 30 May 2019 20:11:37 +0000 (22:11 +0200)]
mescc: Put char's ASCII code into register, not char.

* module/mescc/compile.scm (expr-register): Put char's ASCII code into
register, not char.

22 months agomes: Update to Nyacc 0.93.
Jan Nieuwenhuizen [Sun, 9 Jun 2019 17:42:42 +0000 (19:42 +0200)]
mes: Update to Nyacc 0.93.

* mes/module/nyacc/lang/c99/util.mes: New file.
* mes/module/nyacc/lang/c99/parser.mes: Use it.
* module/mescc/compile.scm (ast->info): Update for Nyacc 0.93.0.
* module/mescc/preprocess.scm (need-progress):  Likewise.
(ast-strip-comment): Likewise.

20 months agomes: string->number: Support #x-prefixed hex numbers.
Jan Nieuwenhuizen [Fri, 2 Aug 2019 20:52:46 +0000 (22:52 +0200)]
mes: string->number: Support #x-prefixed hex numbers.

* mes/module/mes/scm.mes (string->number): Support "#x"-prefix.
* tests/math.test ("string->number #hex"): Test it.

20 months agomescc: Do not dump variables with extern storage.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 15:22:00 +0000 (17:22 +0200)]
mescc: Do not dump variables with extern storage.

* lib/tests/scaffold/70-extern.stdout: New file.
* lib/tests/scaffold/70-extern.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it..
* module/mescc/M1.scm (global-string?, global-extern?): New function.
(info->M1): Dump strings first.  Skip extern symbols.
* module/mescc/info.scm (<global>): Add storage field.
(make-global): Add storage parameter.  Pass it.
* module/mescc/compile.scm (make-global-entry): Likewise.
(global->info): Likewise.
(init-declr->info): Likewise.
(decl->info): Pass storage.

20 months agobuild: ./pre-inst-env MES_PREFIX fixup.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 07:19:53 +0000 (09:19 +0200)]
build: ./pre-inst-env MES_PREFIX fixup.

* build-aux/pre-inst-env.in: Set MES_PREFIX to abs_top_srcdir.
* src/mes.c (open_boot): Cater for MES_PREFIX/mes and ${srcdest}.

20 months agomescc: Be silent.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 07:51:21 +0000 (09:51 +0200)]
mescc: Be silent.

* module/mescc/M1.scm (infos->M1, info->M1): Add verbose?.  Move
debugging into verbose? > 1.
* module/mescc/compile.scm (c99-input->info, c99-ast->info): Likewise.
(mescc:trace-verbose): Rename from mescc:trace.
(mescc:trace): New function.
* module/mescc.scm (mescc:main): Likewise.
* module/mescc/mescc.scm (mescc:preprocess, c->ast mescc:compile,
c->info, E->info): Likewise.
* module/mescc/preprocess.scm (c99-input->full-ast, c99-input->ast):
Likewise.

20 months agomescc: Add <include>/<kernel>/<arch> to include path.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 20:44:04 +0000 (22:44 +0200)]
mescc: Add <include>/<kernel>/<arch> to include path.

* module/mescc/preprocess.scm (c99-input->full-ast): Add
<include>/<kernel>/<arch> to include path.
* module/mescc/compile.scm (c99-input->info): Pass arch.
* module/mescc/mescc.scm (mescc:preprocess): Likewise.
(c->info): Likewise.
(c->ast): Likewise.

20 months agomescc: Add 70-function-destruct-declare.c test.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 17:09:12 +0000 (19:09 +0200)]
mescc: Add 70-function-destruct-declare.c test.

* module/mescc/compile.scm (init-declr->info): Do not attempt to
re-calculate function type.
(ftn-declr:get-type): Remove.
* lib/tests/scaffold/70-function-destruct-declare.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.

20 months agomescc: Resurrect --write.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:57:45 +0000 (18:57 +0200)]
mescc: Resurrect --write.

* module/mescc/mescc.scm (mescc:preprocess): Pass pretty-print/write
to c->ast.

20 months agobuild: Distribute crt*.c, libc+gnu.c for tcc, gcc bootstrap build.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:36:07 +0000 (18:36 +0200)]
build: Distribute crt*.c, libc+gnu.c for tcc, gcc bootstrap build.

* build-aux/build-lib.sh (libc_gnu_SOURCES): Build libc+gnu.c.  Copy
crt*.c, libc+gnu.c for distribution.

20 months agobuild: Uniquify config macros.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:20:32 +0000 (18:20 +0200)]
build: Uniquify config macros.

* configure (main): Rename VERSION to MES_VERSION, pkgdatadir to
MES_PKGDATADIR.  Update users.
* configure.sh (mes_system): Likewise.
* src/mes.c (mes_symbols): Update.
(open_boot): Update.
* scaffold/cons-mes.c (main): Update.
* simple.sh: Update.

20 months agobuild: Resurrect --with-cheating.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 16:56:58 +0000 (18:56 +0200)]
build: Resurrect --with-cheating.

* build-aux/config.sh.in (SCHEME): New substitute.
* build-aux/config.make.in: Likewise.
* configure: Substitute them.

20 months agomescc: Support tcc: libtcc1 build fixes.
Jan Nieuwenhuizen [Tue, 23 Jul 2019 18:38:29 +0000 (20:38 +0200)]
mescc: Support tcc: libtcc1 build fixes.

* lib/libtcc1.c: Support building without long long, float support.

22 months agomescc: Mes C Library: Avoid type/size_t conflicts.
Jan Nieuwenhuizen [Sat, 1 Jun 2019 06:44:18 +0000 (08:44 +0200)]
mescc: Mes C Library: Avoid type/size_t conflicts.

* include/alloca.h: Remove typedefs, include sys/types.h.
* include/stdint.h: Likewise.
* include/string.h: Likewise.

21 months agomescc: Support tcc: Add intptr_t, uintptr_t.
Jan Nieuwenhuizen [Wed, 17 Jul 2019 20:54:13 +0000 (22:54 +0200)]
mescc: Support tcc: Add intptr_t, uintptr_t.

* include/sys/types.h (intptr_t, uintptr_t): Add typedef.

20 months agomescc: Add 70-struct-post.c test with fix.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 20:40:42 +0000 (22:40 +0200)]
mescc: Add 70-struct-post.c test with fix.

* lib/tests/scaffold/70-struct-post.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.
* module/mescc/compile.scm (expr->register): Use type size for rank
0 (WAS: 1).

20 months agomescc: Add 70-struct-short-enum-init.c test with fix.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 14:48:26 +0000 (16:48 +0200)]
mescc: Add 70-struct-short-enum-init.c test with fix.

* module/mescc/compile.scm (init->data): Respect type of size.
* lib/tests/scaffold/70-struct-short-enum-init.c: New file.
* lib/tests/scaffold/70-struct-short-enum-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.

20 months agomescc: Add 70-array-in-struct-init.c test with fix.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 15:14:55 +0000 (17:14 +0200)]
mescc: Add 70-array-in-struct-init.c test with fix.

* lib/tests/scaffold/70-array-in-struct-init.c: New file.
* lib/tests/scaffold/70-array-in-struct-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.
* module/mescc/compile.scm (array-init-element->data): Recurse for
elements instead of using init->data.  Support array fields.

20 months agomes: Remove broken copy of simple-format.
Jan Nieuwenhuizen [Fri, 19 Jul 2019 13:36:36 +0000 (15:36 +0200)]
mes: Remove broken copy of simple-format.

* mes/module/mes/simple-format.mes: New file.
* mes/module/mes/guile.mes: Use it.
(with-output-to-string, simple-format): Remove broken copies.
* mes/module/mes/display.mes (with-output-to-string, simple-format,
format): Remove.

21 months agoFix remainder handling.
Danny Milosavljevic [Fri, 5 Jul 2019 13:52:04 +0000 (15:52 +0200)]
Fix remainder handling.

* mes/module/mes/scm.mes (number->string): Fix remainder handling.
* build-aux/check-mescc.sh (XFAIL_TESTS): Remove
lib/tests/scaffold/60-math.c.

21 months agoRevert "test: Disable 60-math.c test."
Jan Nieuwenhuizen [Tue, 9 Jul 2019 20:01:24 +0000 (22:01 +0200)]
Revert "test: Disable 60-math.c test."

This reverts commit bbe6576a66a520d429bb3ec84120ffcce88480bf.

21 months agotest: Disable 60-math.c test.
Jan Nieuwenhuizen [Tue, 9 Jul 2019 19:57:00 +0000 (21:57 +0200)]
test: Disable 60-math.c test.

* build-aux/check-mescc.sh (TESTS): Remove
lib/tests/scaffold/60-math.c.
(BROKEN_TESTS): Add it.

21 months agobuild: Resurrect bootstrap.sh.
Jan Nieuwenhuizen [Sun, 7 Jul 2019 10:17:03 +0000 (12:17 +0200)]
build: Resurrect bootstrap.sh.

* build-aux/connfigure-lib.sh: Split from build-lib.sh
* build-aux/build-lib.sh: Include it.
* build-aux/bootstrap.sh.in: New file.
* configure.sh: Substitute it.

21 months agomescc: Use basename of input as default output name.
Jan Nieuwenhuizen [Mon, 8 Jul 2019 17:42:31 +0000 (19:42 +0200)]
mescc: Use basename of input as default output name.

* module/mescc/mescc.scm (mescc:preprocess, mescc:compile,
mescc:assemble, M1->hex2): Use basename of input as default output name.

21 months agobuild: Handle gcc with --pie-by-default.
Jan Nieuwenhuizen [Sat, 6 Jul 2019 11:57:30 +0000 (13:57 +0200)]
build: Handle gcc with --pie-by-default.

This fixes upgrading to debian-hurd-20190220.img.

* build-aux/build.sh.in (CFLAGS): Add -static.  Fixes using gcc
compiled with --pie-by-default
* build-aux/check.sh.in (CFLAGS): Likewise.
* module/mescc.scm (parse-opts): Ignore -no-pie, -static.

21 months agotest: Split-off broken 72-typedef-struct-def-local.
Jan Nieuwenhuizen [Mon, 8 Jul 2019 07:04:01 +0000 (09:04 +0200)]
test: Split-off broken 72-typedef-struct-def-local.

* lib/tests/scaffold/72-typedef-struct-def-local.c: New file.
* lib/tests/scaffold/72-typedef-struct-def.c: Remove local bit.
* build-aux/check-mescc.sh (TESTS): Add it.
(XFAIL_TESTS)[mescc]: Add lib/tests/scaffold/72-typedef-struct-def.c.

21 months agotest: Fix open-read test.
Jan Nieuwenhuizen [Fri, 28 Jun 2019 18:37:47 +0000 (20:37 +0200)]
test: Fix open-read test.

* build-aux/pre-inst-env.in (srcdir): Remove.
(abs_top_srcdir, abs_top_builddir): Export.
* lib/tests/posix/50-open-read.c (main): Use abs_top_srcdir.

21 months agotest: Add open-read test.
Jan Nieuwenhuizen [Wed, 26 Jun 2019 19:55:44 +0000 (21:55 +0200)]
test: Add open-read test.

* build-aux/test-c.sh: Support running by hand.
* lib/tests/posix/50-open-read.c: New test.
* lib/tests/posix/data/open-read: New file.
* build-aux/check-mescc.sh (TESTS): Add it.

21 months agotest: Enable argv test, run tests with arguments.
Jan Nieuwenhuizen [Wed, 26 Jun 2019 17:49:36 +0000 (19:49 +0200)]
test: Enable argv test, run tests with arguments.

* build-aux/check-mescc.sh (TESTS): Enable 54-argv.c
(XFAIL_TESTS): Remove it.
* build-aux/test-c.sh: Invoke test with options.
* lib/tests/scaffold/54-argc.c: Update.

21 months agomescc: Mes C library: Move common getcwd, open bits to posix.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 21:10:52 +0000 (23:10 +0200)]
mescc: Mes C library: Move common getcwd, open bits to posix.

* lib/linux/_getcwd.c: Rename from getcwd.c.
* lib/linux/_open3.c: Rename from open.c.
* lib/posix/getcwd.c: New file with bits from ../linux/getcwd.c.
* lib/posix/open.c: New file with bits ../linux/getcwd.c.
* build-aux/build-lib.sh (libc_SOURCES): Update.

21 months agomescc: Mes C Library: Move posix bits to read.
Jan Nieuwenhuizen [Mon, 24 Jun 2019 23:58:15 +0000 (01:58 +0200)]
mescc: Mes C Library: Move posix bits to read.

* lib/linux/_read.c: Rename from read.
* lib/posix/read.c: New file.
* build-aux/build-lib.sh (libc_SOURCES): Update.
* include/mes/lib.h (_read): Declare.

21 months agoporting: Avoid failing in scaffold build.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 19:45:46 +0000 (21:45 +0200)]
porting: Avoid failing in scaffold build.

* build-aux/build-scaffold.sh: Do not fail when using courage.

21 months agobuild: Use bash if available to avoid dash problems.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 19:40:43 +0000 (21:40 +0200)]
build: Use bash if available to avoid dash problems.

* configure: Set SHELL to bash.
* configure.sh: Likewise.
* build-aux/test-suite.sh (TEST_LOGS):
* build-aux/export.make: Export SHELL.
* build-aux/config.sh.in (SHELL): New substitute, export.
* build-aux/config.make.in (SHELL): New substitute.
* build-aux/GNUmakefile.in (build, check, install, uninstall): Use
$SHELL to avoid dash problems.
* build-aux/check-mescc.sh: Likewise.
* build-aux/build.sh.in: Likewise.
* build-aux/check-mes.sh: Likewise.
* build-aux/check.sh.in: Likewise.

21 months agotest: Oops, uncomment some commented-out tests.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 18:11:57 +0000 (20:11 +0200)]
test: Oops, uncomment some commented-out tests.

* lib/tests/scaffold/55-char-array.c: Uncomment.
* lib/tests/scaffold/72-typedef-struct-def.c: Likewise.

21 months agobuild: Improve --with-system-libc support.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 17:05:58 +0000 (19:05 +0200)]
build: Improve --with-system-libc support.

* build-aux/build-lib.sh: Avoid building libc for --with-system-libc.
Make libmes richer.
build-aux/check-mescc.sh: Enable 50-malloc test.
* include/dirstream.h: Use HAVE_DIRSTREAM_H to cater for non-existing
dirstream.h.
* include/grp.h[SYSTEM_LIBC]: Typo.
* include/mes/lib.h (__brk, __call_at_exit)[SYSTEM_LIBC]: Declare.
* include/stdlib.h (comparison_fn_t)[SYSTEM_LIBC]: Declare.
* include/time.h (mktime): Return time_t.
* lib/posix/isatty.c [SYSTEM_LIBC]: Do not (re)declare termios.
* lib/stub/mktime.c (mktime): Return time_t.
* lib/tests/scaffold/41-ternary.c (main): Remove assumption that
locals are initialized.
* lib/tests/scaffold/70-stdarg.c: Cater for SYSTEM_LIBC.
* lib/tests/setjmp/80-setjmp.c: Declare jmp buf.
* lib/*/*.c: Add missing mes/lib.h, errno.h includes.

21 months agoporting: Add x86_64 scaffold: exit and write in assembly.
Jan Nieuwenhuizen [Sun, 23 Jun 2019 19:23:34 +0000 (21:23 +0200)]
porting: Add x86_64 scaffold: exit and write in assembly.

* lib/x86_64-mes-gcc/exit-42.S: New file.
* lib/x86_64-mes-gcc/hello-mes.S: New file.
* lib/x86_64-mes/elf64-0exit-42.hex2: New file.
* lib/x86_64-mes/elf64-0hello-mes.hex2: New file.
* lib/x86_64-mes/elf64-body-exit-42.hex2: Rewrite..
* lib/x86_64-mes/elf64-body-hello-mes.hex2:
* lib/x86_64-mes/elf64-0header.hex2: Fix copyright header.
* lib/x86_64-mes/elf64-header.hex2: Likewise.
* lib/x86_64-mes/elf-0footer.hex2: Remove.

22 months agoporting: Add x86 scaffold: exit and write in assembly.
Jan Nieuwenhuizen [Thu, 13 Jun 2019 12:19:59 +0000 (14:19 +0200)]
porting: Add x86 scaffold: exit and write in assembly.

* lib/x86-mes-gcc/exit-42.S: New file.
* lib/x86-mes-gcc/hello-mes.S: New file.
* lib/x86-mes/elf32-0exit-42.hex2: New file.
* lib/x86-mes/elf32-0hello-mes.hex2: New file.
* lib/x86-mes/elf32-body-hello-mes.hex2: New file.
* lib/x86-mes/elf32-body-exit-42.hex2: Rewrite.
* lib/x86-mes/elf32-header.hex2: Fix copyright header.
* lib/x86-mes/elf32-0header.hex2: Likewise.
* lib/x86-mes/elf-0footer.hex2: Remove.
* build-aux/build-scaffold.sh: Build them.
* .dir-locals.el (asm-mode): Allow TABs.
* .gitignore: Reserve .S assembly sources, i.e. manual written
assembly.  Update build system.
* module/mescc/mescc.scm: Update.
* build-aux/build-lib.sh: Update.
* scripts/ar.in: Update.

22 months agomake check: Do not re-check unless recheck=true.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 09:39:31 +0000 (11:39 +0200)]
make check: Do not re-check unless recheck=true.

* build-aux/check-mescc.sh (recheck): New variable.
* build-aux/check.sh.in (recheck): New variable.
* build-aux/test-suite.sh (TEST_LOGS): Use it.

22 months agobuild: Cater for ARM.
Jan Nieuwenhuizen [Wed, 22 May 2019 15:55:20 +0000 (17:55 +0200)]
build: Cater for ARM.

* configure: Cater for ARM.
* configure.sh: Likewise
* build-aux/GNUmakefile.in: Likewise.
* build-aux/bootstrap.sh.in: Likewise.
* module/mescc.scm (parse-opts): Likewise.
* src/mes.c (mes_environment): Likewise.
* build-aux/build.sh.in: Likewise.
* build-aux/config.sh Likewise.
* build-aux/install.sh.in: Likewise.
* module/mes/guile.scm: Likewise.
* scripts/mescc.scm.in: Likewise.
* module/mescc/mescc.scm (arch-get): New function.
(arch-get-info): New function.
(arch-get-define): New function.
(arch-get-m1-options): New function.
(arch-get-Architecture): New function.
(mescc:preprocess c->info, E->info, M1->hex2, hex2->elf,
M1->blood-elf, arch-find): Use them.

22 months agomescc: Drop $@-workaround.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 21:43:35 +0000 (23:43 +0200)]
mescc: Drop $@-workaround.

* scripts/mescc.in: Drop $@-workaround.

22 months agobuild: Simplify.
Jan Nieuwenhuizen [Sat, 8 Jun 2019 13:36:22 +0000 (15:36 +0200)]
build: Simplify.

    core: Make mes src/ c files separate compilation units.

* include/mes/constants.h: New file.
* include/mes/macros.h: New file.
* include/mes/mes.h: New file.
* src/gc.c: Update.
* src/hash.c: Update.
* src/lib.c: Update.
* src/math.c: Update.
* src/mes.c: Update.
* src/module.c: Update.
* src/posix.c: Update.
* src/reader.c: Update.
* src/string.c: Update.
* src/struct.c: Update.
* src/vector.c: Update.

    mes: Update datadir.

* src/mes.c (g_datadir): New global.
(open_boot): Rename from read_boot.
(read_boot): New function.
* mes/module/mes/boot-0.scm: Move from boot-0.scm.in
* configure: Update.
* configure.sh: Update.

    mescc: Create libraries from separate files.

* .gitignore: Update.
* build-aux/bootstrap-mes.sh: Remove.
* build-aux/bootstrap.sh.in: Remove.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build-scaffold.sh: New file.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-tcc.sh: Remove.
* build-aux/config.sh.in: New file.
* build-aux/config.sh: Remove.
* build-aux/install.sh.in: Update.
* build-aux/test-boot.sh: New file.
* build-aux/test-c.sh: New file.
* build-aux/test-driver: New file.
* build-aux/test-suite.sh: New file.
* build-aux/trace.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* lib/linux/x86-mes-mescc/crt1.c: Move from lib/linux/x86-mes.
* lib/linux/x86-mes-mescc/mini.c: Likewise.
* lib/linux/x86_64-mes-mescc/crt1.c: Move from lib/linux/x86_64-mes.
* lib/linux/x86_64-mes-mescc/mini.c: Likewise.
* lib/linux/x86-mes-gcc/syscall.c: Rename from mes.c.
* lib/linux/x86-mes-mescc/syscall.c: Likewise.
* lib/linux/x86_64-mes-gcc/syscall.c: Likewise.
* lib/linux/x86_64-mes-mescc/syscall.c: Likewise.
* lib/mes/mes_open.c: Include config.h.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* scaffold/gc-test.sh: New file.
* simple.sh: Update.

22 months agotest: Move scaffold/tests into lib.
Jan Nieuwenhuizen [Sat, 8 Jun 2019 13:34:44 +0000 (15:34 +0200)]
test: Move scaffold/tests into lib.

* lib/tests/scaffold: Move from scaffold/tests.
* scaffold/tests: Remove.
* build-aux/check-mescc.sh: Update.

23 months agobuild: Make "GUILEC" compilation status output more verbose (print full path).
Danny Milosavljevic [Fri, 10 May 2019 14:38:05 +0000 (16:38 +0200)]
build: Make "GUILEC" compilation status output more verbose (print full path).

* build-aux/build-guile.sh: Make "GUILEC" compilation status output more
verbose (print full path).

22 months agobuild: Fix --disable-silent-rules. Thanks ng0!
Jan Nieuwenhuizen [Wed, 29 May 2019 14:55:57 +0000 (16:55 +0200)]
build: Fix --disable-silent-rules. Thanks ng0!

* configure (main): Substitute V as string value.
* build-aux/trace.sh: Typo.  Fixes using V=0.
* build-aux/config.status.in (V): New substitute.
* build-aux/config.make.in (V): New substiute.

22 months agomescc: Use a.out as default executable name.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:49:22 +0000 (16:49 +0200)]
mescc: Use a.out as default executable name.

* module/mescc/mescc.scm (hex2->elf): Use a.out as default executable
name.

22 months agomescc: Robustify against empty `V' in environment.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:47:54 +0000 (16:47 +0200)]
mescc: Robustify against empty `V' in environment.

* module/mescc.scm: Robustify against empty V in environment.

22 months agomescc: Fix -dumpmachine to respect -m bits selection.
Jan Nieuwenhuizen [Tue, 28 May 2019 22:04:47 +0000 (00:04 +0200)]
mescc: Fix -dumpmachine to respect -m bits selection.

* module/mescc.scm (parse-opts): Fix -dumpmachine to respect -m bits
selection.  Also display kernel.

22 months agomescc: Support single-dash options on Mes too.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:45:28 +0000 (16:45 +0200)]
mescc: Support single-dash options on Mes too.

* scripts/mescc.in[MES]: Add -- as separator, fixes using single-dash
options on Mes too.

22 months agomescc: Ignore -fnobuiltin, -nostdinc for GCC compatibility.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:44:31 +0000 (16:44 +0200)]
mescc: Ignore -fnobuiltin, -nostdinc for GCC compatibility.

* module/mescc.scm (parse-opts): Add -fnobuiltin, -nostdinc.
(mescc:main): Ignore them.

22 months agotest: Resurrect running boot tests on Guile.
Jan Nieuwenhuizen [Mon, 27 May 2019 20:57:44 +0000 (22:57 +0200)]
test: Resurrect running boot tests on Guile.

* module/mes/guile.scm (keyword->string): New function.
* scaffold/boot/43-or.scm (foo): Add quoting.
* scaffold/boot/45-pass-if.scm (pass-if): Likewise.
* scaffold/boot/46-report.scm (pass-if): Likewise.
* scaffold/boot/47-pass-if-eq.scm (pass-if): Likewise.
* scaffold/boot/48-let.scm (map): Rename from map1.
* scaffold/boot/60-let-syntax-expanded.scm: Some work.

22 months agomescc: Mes C Library: Fix compile warnings.
Jan Nieuwenhuizen [Sun, 26 May 2019 11:41:00 +0000 (13:41 +0200)]
mescc: Mes C Library: Fix compile warnings.

* lib/stdio/fputc.c (fputc): Oops, stream is a long.
* lib/stdlib/malloc.c (malloc): Cast to char *. FIXME
* lib/string/memchr.c (memchr): Cast to void *.
* lib/string/memcmp.c (memcmp): Add const cast.

22 months agomescc: Mes C Library: Fixes for x86_64 crt1.c
Jan Nieuwenhuizen [Sun, 26 May 2019 07:36:57 +0000 (09:36 +0200)]
mescc: Mes C Library: Fixes for x86_64 crt1.c

* lib/linux/x86_64-mes/crt1.c (_start): Write only 4 bytes to int
variables __stdin, __stdout, __stderr.

22 months agotest: Move srfi-1 for-each and map tests to tests/srfi-1.test.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:30:25 +0000 (16:30 +0200)]
test: Move srfi-1 for-each and map tests to tests/srfi-1.test.

This fixes: `make check MES=guile'.

* tests/srfi-1.test ("map 1,2", "map 2,1", "for-each 1,2",
for-each 2,1"): Move from scm.test.
* tests/scm.test ("map 1,2", "map 2,1", "for-each 1,2",
for-each 2,1"): Remove.

22 months agomescc: Mes C Library: Use SYSTEM_LIBC [WAS: WITH_GLIBC].
Jan Nieuwenhuizen [Wed, 29 May 2019 14:15:12 +0000 (16:15 +0200)]
mescc: Mes C Library: Use SYSTEM_LIBC [WAS: WITH_GLIBC].

Run: sed -i 's,WITH_GLIBC,SYSTEM_LIBC,g' $(git grep -l WITH_GLIBC)

* build-aux/config.sh: Update.
* include/alloca.h: Likewise.
* include/ar.h: Likewise.
* include/argz.h: Likewise.
* include/assert.h: Likewise.
* include/ctype.h: Likewise.
* include/dirent.h: Likewise.
* include/dirstream.h: Likewise.
* include/dlfcn.h: Likewise.
* include/endian.h: Likewise.
* include/errno.h: Likewise.
* include/fcntl.h: Likewise.
* include/features.h: Likewise.
* include/float.h: Likewise.
* include/getopt.h: Likewise.
* include/inttypes.h: Likewise.
* include/libgen.h: Likewise.
* include/limits.h: Likewise.
* include/linux/x86_64/syscall.h: Likewise.
* include/locale.h: Likewise.
* include/math.h: Likewise.
* include/memory.h: Likewise.
* include/mes/lib-mini.h: Likewise.
* include/pwd.h: Likewise.
* include/setjmp.h: Likewise.
* include/signal.h: Likewise.
* include/stdarg.h: Likewise.
* include/stdbool.h: Likewise.
* include/stddef.h: Likewise.
* include/stdint.h: Likewise.
* include/stdio.h: Likewise.
* include/stdlib.h: Likewise.
* include/stdnoreturn.h: Likewise.
* include/string.h: Likewise.
* include/strings.h: Likewise.
* include/sys/cdefs.h: Likewise.
* include/sys/dir.h: Likewise.
* include/sys/file.h: Likewise.
* include/sys/ioctl.h: Likewise.
* include/sys/mman.h: Likewise.
* include/sys/param.h: Likewise.
* include/sys/resource.h: Likewise.
* include/sys/select.h: Likewise.
* include/sys/stat.h: Likewise.
* include/sys/time.h: Likewise.
* include/sys/timeb.h: Likewise.
* include/sys/times.h: Likewise.
* include/sys/types.h: Likewise.
* include/sys/ucontext.h: Likewise.
* include/sys/user.h: Likewise.
* include/sys/wait.h: Likewise.
* include/termio.h: Likewise.
* include/time.h: Likewise.
* include/unistd.h: Likewise.
* lib/libmes.c: Likewise.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* lib/tests/stdio/80-sscanf.c: Likewise.
* lib/tests/stdlib/50-malloc.c: Likewise.
* module/mescc/preprocess.scm: Likewise.
* scaffold/cons-mes.c: Likewise.
* scaffold/lib/stdlib/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/tests/61-array.c: Likewise.
* scaffold/tiny-mes.c: Likewise.
* simple.sh: Likewise.
* src/mes.c: Likewise.

22 months agomes: Bugfix for search-path. Fixes running MesCC on Guile.
Jan Nieuwenhuizen [Mon, 27 May 2019 19:51:37 +0000 (21:51 +0200)]
mes: Bugfix for search-path. Fixes running MesCC on Guile.

* module/mescc/mescc.scm (arch-find): Also look in cwd.
* mes/module/mes/posix.mes (search-path): Do not look in cwd.

22 months agomescc: Use named --architecture switch for upcoming mescc-tools 0.6.
Jan Nieuwenhuizen [Sat, 25 May 2019 14:01:39 +0000 (16:01 +0200)]
mescc: Use named --architecture switch for upcoming mescc-tools 0.6.

* module/mescc/mescc.scm (M1->hex2): Use named --architecture switch for
upcoming mescc-tools 0.6.
(hex2->elf): Likewise.
* build-aux/bootstrap-mes.sh: Likewise.
* build-aux/bootstrap.sh.in: Likewise.
* build-aux/config.sh: Likewise.

22 months agomes: Identify 64-bit bug when compiled with MesCC.
Jan Nieuwenhuizen [Mon, 27 May 2019 19:33:20 +0000 (21:33 +0200)]
mes: Identify 64-bit bug when compiled with MesCC.

* src/math.c (divide): Add divide-by-zero error.
(modulo): Likewise.
* module/mes/guile.scm (%compiler): New variable.
* module/mescc/M1.scm (mesc?): New variable.
(hex2:immediate8): Use it to avoid divide-by-zero error.
* HACKING (Bugs): Add it.

22 months agomes: Make debug levels 4 and 5 usable.
Jan Nieuwenhuizen [Mon, 27 May 2019 19:30:48 +0000 (21:30 +0200)]
mes: Make debug levels 4 and 5 usable.

* HACKING: Update debug policy.
* lib/linux/read.c (read): Print read in level 5.
* src/mes.c (eval_apply): Print module in level 6.
(main): Likewise.  Remove redundant module printing.
* src/gc.c (gc): Print symbols in level 6.

23 months agomes: Run build-aux/indent.sh.
Jan Nieuwenhuizen [Sat, 18 May 2019 11:27:42 +0000 (13:27 +0200)]
mes: Run build-aux/indent.sh.

* src/mes.c: Re-indent.
* src: Likewise.
* include: Likewise.
* lib: Likewise.
* scaffold: Likewise.

23 months agomes: Grand indent: prepare.
Jan Nieuwenhuizen [Sun, 12 May 2019 23:07:32 +0000 (01:07 +0200)]
mes: Grand indent: prepare.

* build-aux/indent.sh: New file.
* include/mes/builtins.h: Move from src/builtins.h.
* include/fcntl.h: Use // *INDENT-OFF* to prevent indent breakage.
* include/locale.h: Likewise.
* include/signal.h: Likewise.
* include/sys/stat.h: Likewise.
* include/sys/user.h: Likewise.
* lib/linux/x86-mes-gcc/crt0.c: Likewise.
* lib/linux/x86-mes-gcc/crt1.c: Likewise.
* lib/linux/x86-mes-gcc/mes.c: Likewise.
* lib/linux/x86-mes-gcc/mini.c: Likewise.
* lib/linux/x86_64-mes-gcc/crt0.c: Likewise.
* lib/linux/x86_64-mes-gcc/crt1.c: Likewise.
* lib/linux/x86_64-mes-gcc/mes.c: Likewise.
* lib/linux/x86_64-mes-gcc/mini.c: Likewise.
* lib/x86_64-mes-gcc/setjmp.c: Likewise.
* src/mes.c: Likewise.
* src/reader.c: Likewise.

23 months agomes: Support -c EXPR.
Jan (janneke) Nieuwenhuizen [Wed, 15 May 2019 22:04:45 +0000 (00:04 +0200)]
mes: Support -c EXPR.

* mes/module/mes/boot-0.scm.in: Support -c EXPR.

23 months agomes: Support optional port on read.
Jan (janneke) Nieuwenhuizen [Wed, 15 May 2019 22:05:47 +0000 (00:05 +0200)]
mes: Support optional port on read.

* mes/module/mes/scm.mes (read): Support optional port on read.

23 months agobuild: Fix mescc installation on Debian.
Jan (janneke) Nieuwenhuizen [Wed, 15 May 2019 21:26:52 +0000 (23:26 +0200)]
build: Fix mescc installation on Debian.

* build-aux/pre-inst-env.in: Set bindir.
* scripts/mescc.in: Fix configure/prefix issues.
* mes/module/mes/boot-01.scm (integer->char): Remove.
(newline): Use "\n".
(%moduledir): Use string-append.
* mes/module/mes/boot-02.scm: Likewise.
* mes/module/mes/boot-0.scm: Likewise.

23 months agobuild: Debian make check and install fixes.
Jan (janneke) Nieuwenhuizen [Wed, 15 May 2019 13:18:38 +0000 (15:18 +0200)]
build: Debian make check and install fixes.

* configure (main): Oops, typo: mandir uses --infodir.
* build-aux/check.sh.in: Run check-mescc.sh with bash.
* build-aux/config.sh (CFLAGS, CPPFLAGS, HEX2FLAGS, LDFLAGS, M1FLAGS):
unset.
* build-aux/install.sh.in: Use BASHOPTS to check for bash; on Debian
dash is used and has $SHELL=/bin/bash.  Use ${DESTDIR}@...

23 months agomes: Rename strings.c.
Jan Nieuwenhuizen [Tue, 14 May 2019 06:37:05 +0000 (08:37 +0200)]
mes: Rename strings.c.

* src/string.c: Rename from src/strings.c.
* src/mes.c
* build-aux/snarf.sh: Update.

23 months agomescc: Mes C Library: Use mes_open to avoid open trickery.
Jan Nieuwenhuizen [Sun, 12 May 2019 22:40:33 +0000 (00:40 +0200)]
mescc: Mes C Library: Use mes_open to avoid open trickery.

* include/mes/lib.h (mes_open): Declare.
* lib/libmes.c[WITH_GLIBC]: Remove open undefine.
(mes_open)[!WITH_GLIBC]: New function.
* src/mes.c (open_boot): Use mes_open.
* src/posix.c (open_input_file): Likewise.
(open_output_file): Likewise.

23 months agomescc: Mes C Library: Remove dead code.
Jan Nieuwenhuizen [Sun, 12 May 2019 22:18:29 +0000 (00:18 +0200)]
mescc: Mes C Library: Remove dead code.

* lib/glibc.c: Remove.
* lib/abtol.c: Remove.

23 months agomescc: Mes C Library: Explode linux/tcc.c.
Jan Nieuwenhuizen [Sun, 12 May 2019 22:16:47 +0000 (00:16 +0200)]
mescc: Mes C Library: Explode linux/tcc.c.

* lib/linux/close.c: New file.
* lib/linux/lseek.c: New file.
* lib/linux/rmdir.c: New file.
* lib/linux/stat.c: New file.
* lib/linux/tcc.c: Include them.
(close, lseek, rmdir, stat): Remove.

23 months agomescc: Mes C Library: Explode linux/libc.c.
Jan Nieuwenhuizen [Sun, 12 May 2019 22:09:50 +0000 (00:09 +0200)]
mescc: Mes C Library: Explode linux/libc.c.

* lib/linux/access.c: New file.
* lib/linux/brk.c: New file.
* lib/linux/chmod.c: New file.
* lib/linux/dup.c: New file.
* lib/linux/dup2.c: New file.
* lib/linux/execve.c: New file.
* lib/linux/fork.c: New file.
* lib/linux/fsync.c: New file.
* lib/linux/getcwd.c: New file.
* lib/linux/ioctl.c: New file.
* lib/linux/libc.c: New file.
* lib/linux/open.c: New file.
* lib/linux/read.c: New file.
* lib/linux/unlink.c: New file.
* lib/linux/waitpid.c: New file.
* lib/linux/libc.c: Include them.
(access, brk, chmod, dup, dup2, execve, fork, fsync, getcwd, ioctl,
libc, open, read, unlink, waitpid): Remove.

23 months agomescc: Mes C Library: Explode linux/gnu.c.
Jan Nieuwenhuizen [Sat, 11 May 2019 22:33:33 +0000 (00:33 +0200)]
mescc: Mes C Library: Explode linux/gnu.c.

* lib/linux/chdir.c: New file.
* lib/linux/fcntl.c: New file.
* lib/linux/fstat.c: New file.
* lib/linux/getdents.c: New file.
* lib/linux/getegid.c: New file.
* lib/linux/geteuid.c: New file.
* lib/linux/getgid.c: New file.
* lib/linux/getpid.c: New file.
* lib/linux/getppid.c: New file.
* lib/linux/getrusage.c: New file.
* lib/linux/getuid.c: New file.
* lib/linux/kill.c: New file.
* lib/linux/link.c: New file.
* lib/linux/lstat.c: New file.
* lib/linux/mkdir.c: New file.
* lib/linux/nanosleep.c: New file.
* lib/linux/pipe.c: New file.
* lib/linux/rename.c: New file.
* lib/linux/setgid.c: New file.
* lib/linux/settimer.c: New file.
* lib/linux/setuid.c: New file.
* lib/linux/signal.c: New file.
* lib/linux/sigprogmask.c: New file.
* lib/linux/gnu.c: Include them.
(chdir, fcntl, fstat, getdents, getegid, geteuid, getgid, getpid,
getppid, getrusage, getuid, kill, link, lstat, mkdir, munmap,
nanosleep, pipe, rename, setgid, settimer, setuid, signal,
sigprogmask): Remove.

23 months agomescc: Mes C Library: Explode libc-mini.c.
Jan Nieuwenhuizen [Thu, 9 May 2019 22:32:45 +0000 (00:32 +0200)]
mescc: Mes C Library: Explode libc-mini.c.

* lib/posix/write.c: New file.
* lib/linux/libc-mini.c: Include it.
(write): Remove.
* lib/tests/mes/30-oputs.c: Remove dead code.

23 months agomescc: Mes C Library: Cleanup includes.
Jan Nieuwenhuizen [Tue, 7 May 2019 22:25:41 +0000 (00:25 +0200)]
mescc: Mes C Library: Cleanup includes.

* include/mes/lib-mini.h: Move from include/libmes-mini.h.  Update users.
* include/mes/lib.h: Move from include/libmes.h.  Update users.

23 months agomescc: Support -nodefaultlibs, -nostartfiles, -nostdlib.
Jan Nieuwenhuizen [Sun, 5 May 2019 18:25:22 +0000 (20:25 +0200)]
mescc: Support -nodefaultlibs, -nostartfiles, -nostdlib.

* module/mescc.scm (parse-opts): Parse -nodefaultlibs, -nostartfiles, -nostdlib.
* module/mescc/mescc.scm (mescc:link): Handle -nodefaultlibs, -nostdlib.
(hex2->elf): Handle -nostartfiles, -nostdlib.

23 months agobuild: Do not install test binaries.
Jan Nieuwenhuizen [Fri, 3 May 2019 16:08:46 +0000 (18:08 +0200)]
build: Do not install test binaries.

* build-aux/install.sh.in: Do not install test binaries.

23 months agomes: m2: Move force-output to Scheme.
Jan Nieuwenhuizen [Sun, 5 May 2019 11:11:33 +0000 (13:11 +0200)]
mes: m2: Move force-output to Scheme.

* mes/module/mes/posix.mes (force-output): New function.
* src/posix.c (force_output): Remove.
* src/mes.c (mes_builtins): Remove adding of force-output.

2 years agobuild: M2-Planet first-aid, simplest build script possible.
Jan Nieuwenhuizen [Sat, 23 Mar 2019 21:05:35 +0000 (22:05 +0100)]
build: M2-Planet first-aid, simplest build script possible.

* simple.sh: New file.

2 years ago.dir-locals.el: Assert default GNU settings.
Jan Nieuwenhuizen [Wed, 27 Mar 2019 12:20:26 +0000 (13:20 +0100)]
.dir-locals.el: Assert default GNU settings.

* .dir-locals.el: Assert default GNU settings.

2 years agoFix typo in stage0 copyright headers.
Jan Nieuwenhuizen [Wed, 27 Mar 2019 12:19:53 +0000 (13:19 +0100)]
Fix typo in stage0 copyright headers.

* lib/x86-mes/elf-0footer.hex2: Fix typo.
* lib/x86-mes/elf32-0header.hex2: Fix typo.
* lib/x86-mes/elf32-body-exit-42.hex2: Fix typo.
* lib/x86-mes/elf32-footer-single-main.hex2: Fix typo.
* lib/x86-mes/elf32-header.hex2: Fix typo.
* lib/x86_64-mes/elf-0footer.hex2: Fix typo.
* lib/x86_64-mes/elf64-0header.hex2: Fix typo.
* lib/x86_64-mes/elf64-body-exit-42.hex2: Fix typo.
* lib/x86_64-mes/elf64-footer-single-main.hex2: Fix typo.
* lib/x86_64-mes/elf64-header.hex2: Fix typo.

2 years agomescc: Mes C Library: Fix ungetc.
Jan Nieuwenhuizen [Sat, 16 Mar 2019 10:55:00 +0000 (11:55 +0100)]
mescc: Mes C Library: Fix ungetc.

* include/sys/resource.h (OPEN_MAX, RLIMIT_NOFILE): New macro.
* lib/libc.c: Add memset.c include.
* lib/libc+tcc.c: Remove memset.c include.
* lib/linux/tcc.c (close):
* lib/mes/fdgetc.c (__ungetc_buf): New global.
(_ungetc_pos, _ungetc_fd, _ungetc_buf): Remove.  Update users.
* scaffold/tests/65-read.c: Update.

2 years agobuild: Replace POSIX, posix_p by WITH_GLIBC, wip_glibc_p.
Jan Nieuwenhuizen [Sat, 23 Mar 2019 20:44:00 +0000 (21:44 +0100)]
build: Replace POSIX, posix_p by WITH_GLIBC, wip_glibc_p.

* build-aux/build-mes.sh: Replace POSIX, posix_p by WITH_GLIBC, wip_glibc_p.
* build-aux/build.sh.in: Likewise.
* build-aux/cc.sh (link): Likewise.
* build-aux/config.make.in (with_glibc_p): Likewise.
* build-aux/config.sh (libc): Likewise.
(CPPFLAGS): Likewise.
* build-aux/config.status.in (with_glibc_p): Likewise.
* build-aux/test.sh: Likewise.
* configure (main): Likewise.
* configure.sh (subst): Likewise.
(mes_arch): Likewise.
* include/libmes.h: Likewise.
* include/linux/x86_64/syscall.h: Likewise.
* lib/libmes.c: Likewise.
* lib/tests/stdio/70-printf-hello.c (main): Likewise.
* lib/tests/stdio/70-printf-simple.c (main): Likewise.
* lib/tests/stdio/80-sscanf.c (main): Likewise.
* lib/tests/stdlib/50-malloc.c: Likewise.
* module/mescc/preprocess.scm (c99-input->full-ast): Likewise.
* scaffold/cons-mes.c: Likewise.
* scaffold/lib/stdlib/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/tests/61-array.c (getenv): Likewise.
* scaffold/tiny-mes.c: Likewise.
* src/mes.c: Likewise.

2 years agomescc: Mes C Library: Fix compile warnings.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 09:04:33 +0000 (10:04 +0100)]
mescc: Mes C Library: Fix compile warnings.

* include/libmes.h (dtoab, itoa, ltoa, ntoab, ultoa, utoa): Return
char* (WAS: char const*).
* lib/*/*c: Update, add missing includes.

2 years agomescc: Mes C Library: Fix isatty.
Jan Nieuwenhuizen [Sat, 2 Mar 2019 21:27:39 +0000 (22:27 +0100)]
mescc: Mes C Library: Fix isatty.

* lib/posix/isatty.c (isatty): Test ioctl == 0.
* mes/module/mes/boot-0.scm.in: Update: no tty?: read from stdin.

2 years agotest: 50-getenv: Test PATH, allow to fail.
Jan Nieuwenhuizen [Sat, 2 Mar 2019 21:22:35 +0000 (22:22 +0100)]
test: 50-getenv: Test PATH, allow to fail.

* lib/tests/posix/50-getenv.c (main): Test PATH.
* build-aux/check-mescc.sh (broken): Add 50-getenv.

2 years agomes: Support map and for-each with lists of unequal length.
Jan Nieuwenhuizen [Sat, 2 Mar 2019 13:33:58 +0000 (14:33 +0100)]
mes: Support map and for-each with lists of unequal length.

* mes/module/mes/base.mes (map): Support lists of unequal length.
* mes/module/mes/scm.mes (for-each): Likewise.
* module/mescc/compile.scm (expr->register): Fix compile warning.
* tests/scm.test ("map 1,2", "map 2,1", "for-each 1,2", "for-each
2,1": Test it.

2 years agomescc: Mes C Library: Use __ as global internal prefix.
Jan Nieuwenhuizen [Sat, 2 Mar 2019 11:35:18 +0000 (12:35 +0100)]
mescc: Mes C Library: Use __ as global internal prefix.

* include/libmes-mini.h (g_stdin, g_stdout, g_stderr): Rename to
__stdin, __stdout, __stderr.  Update users.

2 years agomescc: ctype.h: Add missing prototypes.
Jan Nieuwenhuizen [Thu, 28 Feb 2019 09:25:37 +0000 (10:25 +0100)]
mescc: ctype.h: Add missing prototypes.

* include/ctype.h: Add missing prototypes.

2 years agomescc: Mes C Library: Bugfix for tcc-compiled exit assembly.
Jan Nieuwenhuizen [Thu, 28 Feb 2019 19:40:16 +0000 (20:40 +0100)]
mescc: Mes C Library: Bugfix for tcc-compiled exit assembly.

* lib/linux/x86-mes-gcc/mini.c (_exit): Add clobbered registers %eax,
%ebx.  Fixes always exit 1.

2 years agotest: Remove special characters from files.
Jan Nieuwenhuizen [Mon, 25 Feb 2019 22:41:20 +0000 (23:41 +0100)]
test: Remove special characters from files.

* scaffold/tests/06-call-not-1.c: Rename from 06-call-!1.c.
* scaffold/tests/06-not-call-1.c: Rename from 06-!call-1.c.
* scaffold/tests/12-if-eq.c: Rename from 12-if-==.c.
* scaffold/tests/13-if-neq.c: Rename from 13-if-!=.c.
* scaffold/tests/15-if-not-f.c: Rename from 15-if-!f.c.
* scaffold/tests/21-char-array-simple.c: Rename from 21-char[]-simple.c.
* scaffold/tests/21-char-array.c: Rename from 21-char[].c.
* scaffold/tests/22-while-char-array.c: Rename from 22-while-char[].c.
* scaffold/tests/41-ternary.c: Rename from 41-?.c.
* scaffold/tests/7u-call-ternary.c: Rename from 7u-call-?.c.
* scaffold/tests/7u-ternary-expression.c: Rename from 7u-?-expression.c.
* build-aux/check-mescc.sh (tests): Update.

2 years agobuild: Support building with Gash.
Jan Nieuwenhuizen [Mon, 25 Feb 2019 17:37:18 +0000 (18:37 +0100)]
build: Support building with Gash.

* build-aux/check-mes.sh: Replace unspported $((..)) by $(expr ...).
* build-aux/check-mescc.sh: Likewise.
* build-aux/check-tcc.sh: Likewise.

2 years agobuild: Configure: remove temp files.
Jan Nieuwenhuizen [Mon, 18 Feb 2019 06:22:50 +0000 (07:22 +0100)]
build: Configure: remove temp files.

* configure (gulp-pipe*): Remove .error.
(check-header-c): Remove .config.c.
(check-compile-c): Likewise.
(check-link-c): Likewise.

2 years agobuild: Remove mini-mes.
Jan Nieuwenhuizen [Mon, 18 Feb 2019 06:21:54 +0000 (07:21 +0100)]
build: Remove mini-mes.

* scaffold/mini-mes.c: Remove.
* build-aux/build-mes.sh: Remove commented build instructions.
* .gitignore: Remove pattern.

2 years agomescc: Mes C Library: Initialize streams in crt1.
Jan Nieuwenhuizen [Sun, 24 Feb 2019 11:31:44 +0000 (12:31 +0100)]
mescc: Mes C Library: Initialize streams in crt1.

* lib/linux/x86-mes-gcc/crt1.c: Initialize streams.
* lib/linux/x86-mes/crt1.c: Likewise.
* lib/linux/x86_64-mes-gcc/crt1.c: Likewise.
* lib/linux/x86_64-mes/crt1.c: Likewise.
* src/mes.c (main): Remove initialization of streams.

2 years agomescc: Mes C Library: Populate with function tests from scaffold.
Jan Nieuwenhuizen [Sun, 24 Feb 2019 16:51:53 +0000 (17:51 +0100)]
mescc: Mes C Library: Populate with function tests from scaffold.

* .gitignore: Update.
* build-aux/bootstrap.sh.in: Update.
* build-aux/build-mes.sh: Update.
* build-aux/check-mescc.sh: Update.
* lib/tests/assert/50-assert.c: Move from scaffold/tests/50-assert.c.
* lib/tests/dirent/90-readdir.c: Move from scaffold/tests/99-readdir.c.
* lib/tests/dirent/readdir.dir: Move from scaffold/tests/readdir.dir.
* lib/tests/io/90-stat.c: Move from scaffold/tests/92-stat.c.
* lib/tests/mes/30-oputs.c: Move from scaffold/tests/31-oputs.c.
* lib/tests/mes/50-itoa.c: Move from scaffold/tests/51-itoa.c.
* lib/tests/posix/90-unsetenv.c: Move from scaffold/tests/94-unsetenv.c.
* lib/tests/setjmp/80-setjmp.c: Move from scaffold/tests/80-setjmp.c.
* lib/tests/signal/90-signal.c: Move from scaffold/tests/95-signal.c.
* lib/tests/stdio/70-printf-hello.c: Move from scaffold/tests/70-printf-hello.c.
* lib/tests/stdio/70-printf-simple.c: Move from scaffold/tests/70-printf-simple.c.
* lib/tests/stdio/70-printf.c: Move from scaffold/tests/70-printf.c.
* lib/tests/stdio/80-sscanf.c: Move from scaffold/tests/87-sscanf.c.
* lib/tests/stdio/90-fopen-append.c: Move from scaffold/tests/98-fopen.c.
* lib/tests/stdio/90-fopen.c: Move from scaffold/tests/97-fopen.c.
* lib/tests/stdio/90-fread-fwrite.c: Move from scaffold/tests/93-fread-fwrite.c.
* lib/tests/stdio/90-fseek.c: Move from scaffold/tests/91-fseek.c.
* lib/tests/stdlib/50-getenv.c: Move from lib/tests/stdlib/getenv.c.
* lib/tests/stdlib/50-malloc.c: Move from lib/tests/stdlib/malloc.c.
* lib/tests/stdlib/70-strtoull.c: Move from scaffold/tests/7j-strtoull.c.
* lib/tests/stdlib/80-qsort-dupes.c: Move from scaffold/tests/81-qsort-dupes.c.
* lib/tests/stdlib/80-qsort.c: Move from scaffold/tests/81-qsort.c.
* lib/tests/stdlib/90-strtol.c: Move from scaffold/tests/96-strto.c.
* lib/tests/string/30-strlen.c: Move from scaffold/tests/30-strlen.c.
* lib/tests/string/50-strcmp.c: Move from scaffold/tests/51-strcmp.c.
* lib/tests/string/50-strcpy.c: Move from scaffold/tests/53-strcpy.c.
* lib/tests/string/50-strncmp.c: Move from scaffold/tests/51-strncmp.c.
* lib/tests/string/70-strchr.c: Move from scaffold/tests/70-strchr.c.
* lib/tests/string/80-strncpy.c: Move from scaffold/tests/86-strncpy.c.
* lib/tests/string/80-strrchr.c: Move from scaffold/tests/88-strrchr.c.
* lib/tests/string/90-snprintf.c: Move from scaffold/tests/9a-snprintf.c.
* lib/tests/string/90-strpbrk.c: Move from scaffold/tests/90-strpbrk.c.
* lib/tests/string/90-strspn.c: Move from scaffold/tests/90-strspn.c.

2 years agomescc: Mes C Library: Start test suite.
Jan Nieuwenhuizen [Sun, 24 Feb 2019 08:39:00 +0000 (09:39 +0100)]
mescc: Mes C Library: Start test suite.

TODO: move strict libc tests from scaffold/test/* here.

* lib/tests/stdlib/getenv.c: New file.
* lib/tests/stdlib/malloc.c: Move from scaffold.
* build-aux/bootstrap.sh.in: Built them.
* build-aux/build-mes.sh: Likewise.

2 years agomes: Remove stray debugging newline output.
Jan Nieuwenhuizen [Sun, 24 Feb 2019 09:49:56 +0000 (10:49 +0100)]
mes: Remove stray debugging newline output.

* mes/module/mes/guile.mes (open-input-file): Move debugging newline
into debug clause.

2 years agomescc: Mes C Library: Fix brk return type compare.
Jan Nieuwenhuizen [Sun, 24 Feb 2019 08:11:55 +0000 (09:11 +0100)]
mescc: Mes C Library: Fix brk return type compare.

* lib/stdlib/malloc.c (malloc): Fix brk return type compare.

2 years agocore: Rename load_env to read_boot.
Jan Nieuwenhuizen [Sun, 24 Feb 2019 06:44:59 +0000 (07:44 +0100)]
core: Rename load_env to read_boot.

* src/mes.c (read_boot): Rename from load_env; Update users.
(open_boot): Rename from load_boot; Update users.