mes.git
4 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.

4 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.

4 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.

4 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.

4 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.

4 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}@...

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

4 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.

5 months 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.

5 months 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.

5 months 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.

6 months 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.

5 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

7 months 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.

7 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

6 months 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.

7 months agocore: Initialize g_buf dynamically, add MES_STRING_MAX override.
Jan Nieuwenhuizen [Sun, 10 Feb 2019 05:56:06 +0000 (06:56 +0100)]
core: Initialize g_buf dynamically, add MES_STRING_MAX override.

* src/mes.c (g_buf, MAX_STRING): Move from strings.c.
(gc_init_cells): Initialize g_buf dynamically.
(main): Add environment override MES_MAX_STRING for MAX_STRING.
* doc/mes.texi (Environment Variables): Document it.

7 months agomes-snarf: rewrite for development-time snarfing
Jan Nieuwenhuizen [Sun, 3 Feb 2019 19:59:51 +0000 (20:59 +0100)]
mes-snarf: rewrite for development-time snarfing

* build-aux/mes-snarf.scm (%gcc?): Remove.
(symbol->header): Produce code for src/builtins.h.
(symbol->source, symbol->names, function->environment): Remove.
(snarf-symbols): Rewrite, snarf from init_symbol (...).
(function->source): Produce code to be manually put into
(main): Remove --mes option.

7 months agocore: Resurrect POSIX build. Thanks, gio!
Jan Nieuwenhuizen [Fri, 15 Feb 2019 08:28:46 +0000 (09:28 +0100)]
core: Resurrect POSIX build. Thanks, gio!

* lib/libmes.c[POSIX]: Define and initialize g_stdin, g_stdout and
g_stderr that were moved to crt1 for non-POSIX builds.
* src/mes.c[POSIX]: Remove struct-initialisation exceptions.

8 months agocore: Remove struct definitions for builtins, drop snarfing.
Jan Nieuwenhuizen [Fri, 4 Jan 2019 08:55:16 +0000 (09:55 +0100)]
core: Remove struct definitions for builtins, drop snarfing.

After making a change to the list of builtin functions, run

    cat src/*.i

and move the into

    src/mes.c:mes_builtins ()

and, or also after changing the list of fixed symbols in src/mes.c:mes_symbols (), do

    cat src/*.h > src/builtins.h

* build-aux/build.sh.in: Remove snarfing.
* build-aux/bootstrap.sh.in: Likewise.
* mes/module/mes/display.mes (display):
* mes/module/mes/type-0.mes (cell:type-alist): Remove <cell:function>.
(function?, builtin?): Remove.
* src/builtins.h: New file.
* src/mes.c (TFUNCTION): Remove.
(struct function): Remove.
(apply_builtin): Rewrite from call.
(mes_builtins): Rewrite.
(init_builtin, make_builtin_type, make_builtin, builtin_name,
builtin_arity, builtin, builtin_p, builtin_printer): New function.

8 months agocore: Remove struct definitions for cells, drop snarfing for symbols.
Jan Nieuwenhuizen [Fri, 4 Jan 2019 07:07:48 +0000 (08:07 +0100)]
core: Remove struct definitions for cells, drop snarfing for symbols.

* src/mes.c (init_symbol): New function.
(mes_symbols): Use it.
(scm_nil, ... scm_test): Remove.

8 months agomes: Add take-while.
Jan Nieuwenhuizen [Thu, 27 Dec 2018 15:36:22 +0000 (16:36 +0100)]
mes: Add take-while.

* mes/module/srfi/srfi-1.mes (take-while): New function.

8 months agomescc: Enhance POSIX command-line support, e.g. -DFOO=1.
Jan Nieuwenhuizen [Wed, 26 Dec 2018 13:14:02 +0000 (14:14 +0100)]
mescc: Enhance POSIX command-line support, e.g. -DFOO=1.

* module/mescc.scm (unclump-single): New function.
(main): Use it to support -DFOO=bar, and equivalent.

8 months agobuild: Support running out-of-tree.
Jan Nieuwenhuizen [Thu, 27 Dec 2018 15:36:39 +0000 (16:36 +0100)]
build: Support running out-of-tree.

* build-aux/pre-inst-env.in (MES_PREFIX): Use absolute name.

8 months agocore: Remove string debugging.
Jan Nieuwenhuizen [Thu, 27 Dec 2018 15:48:45 +0000 (16:48 +0100)]
core: Remove string debugging.

* src/strings.c (make_bytes, make_string, string_equal_p,
symbol_to_string, symbol_to_keyword, make_symbol): Remove string
debugging.

8 months agocore: Remove --dump, --load.
Jan Nieuwenhuizen [Thu, 27 Dec 2018 15:47:56 +0000 (16:47 +0100)]
core: Remove --dump, --load.

* mes/module/mes/boot-0.scm.in (tty?): Remove --dump, --load.
* src/mes.c (bload_env): Remove.
* src/reader.c (dump): Remove.

9 months agodoc: Post-release update.
Jan Nieuwenhuizen [Sun, 16 Dec 2018 18:35:48 +0000 (19:35 +0100)]
doc: Post-release update.

* doc/announce/ANNOUNCE-0.19: Update.

9 months agoRelease 0.19. v0.19
Jan Nieuwenhuizen [Sun, 16 Dec 2018 13:51:18 +0000 (14:51 +0100)]
Release 0.19.

* configure (VERSION): Update to 0.19.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.

11 months agodoc: Release update.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 07:53:44 +0000 (09:53 +0200)]
doc: Release update.

* AUTHORS: Update.
* HACKING: Update.
* NEWS: Update.
* doc/mes.guix: Update.
* scripts/mescc.in: Update.
* mes/module/mes/boot-0.scm.in: Update.
* doc/announce/ANNOUNCE-0.19: New file.

9 months agomes: assq-ref, assoc-ref: Support alist == #f.
Jan Nieuwenhuizen [Sat, 15 Dec 2018 11:56:15 +0000 (12:56 +0100)]
mes: assq-ref, assoc-ref: Support alist == #f.

* mes/module/mes/scm.mes (assq-ref): Support alist == #f.
(assoc-ref): Likewise.

9 months agocore: Bump MAX_STRING to 524288
Jan Nieuwenhuizen [Sat, 15 Dec 2018 09:34:57 +0000 (10:34 +0100)]
core: Bump MAX_STRING to 524288

* src/strings.c (MAX_STRING): Bump to 524288.
(assert_max_string): New function.
(list_to_cstring, string_append, read_string): Use it.
* src/reader.c (reader_read_string): Use it.

9 months agomescc: Support Bash: Add getppid.
Jan Nieuwenhuizen [Fri, 14 Dec 2018 17:48:03 +0000 (18:48 +0100)]
mescc: Support Bash: Add getppid.

* lib/linux/gnu.c (getppid): New function.
* include/linux/x86/syscall.h (SYS_getppid): New macro.
* include/linux/x86_64/syscall.h (SYS_getppid): New macro.

9 months agomescc: Support bash: Add sigdelset stub.
Jan Nieuwenhuizen [Fri, 14 Dec 2018 17:46:44 +0000 (18:46 +0100)]
mescc: Support bash: Add sigdelset stub.

* lib/stub/sigdelset.c (sigdelset): New stub.
* lib/libc+gnu.c: Include it.

9 months agomescc: getcwd: Support getcwd (0, 0) GNU extension.
Jan Nieuwenhuizen [Fri, 7 Dec 2018 19:18:01 +0000 (20:18 +0100)]
mescc: getcwd: Support getcwd (0, 0) GNU extension.

* lib/linux/libc.c (_getcwd): Rename from getcwd.
(_getcwd): New function.  Support getcwd (0, 0) GNU extension.

9 months agomescc: Replace \r in comments.
Jan Nieuwenhuizen [Sun, 2 Dec 2018 06:26:07 +0000 (07:26 +0100)]
mescc: Replace \r in comments.

* module/mescc/compile.scm (ast->comment): Replace \r in comments.

9 months agobuild: Support building with Gash.
Jan Nieuwenhuizen [Sat, 24 Nov 2018 20:07:31 +0000 (21:07 +0100)]
build: Support building with Gash.

* build-aux/install.sh: Replace variables with substitution.
* build-aux/bootstrap.sh: New file.
* configure: Substitute it.
* configure.sh: Likewise.  Be friendly to Gash.
* .gitignore: Ignore it.

9 months agomescc: Run without shell.
Jan Nieuwenhuizen [Sun, 25 Nov 2018 12:21:03 +0000 (13:21 +0100)]
mescc: Run without shell.

* mes/module/mescc.mes: New file.
* module/mescc.scm: Include it.
* scripts/mescc.scm.in: New file.
* scripts/mescc.in: Use it; Make pure shell.
* configure: Substitute it.
* configure.sh: Substitute it.
* build-aux/install.sh.in: Install it.

10 months agocore: Add string-ref.
Jan Nieuwenhuizen [Thu, 15 Nov 2018 23:15:50 +0000 (00:15 +0100)]
core: Add string-ref.

* src/strings.c (string_ref): New function.
* mes/module/mes/scm.mes (string-ref): Remove.

10 months agocore: Add string-length.
Jan Nieuwenhuizen [Thu, 15 Nov 2018 22:51:29 +0000 (23:51 +0100)]
core: Add string-length.

* src/strings.c (string_length): New function.
* mes/module/mes/scm.mes (string-length): Remove.

10 months agocore: Add string-append.
Jan Nieuwenhuizen [Thu, 15 Nov 2018 22:09:56 +0000 (23:09 +0100)]
core: Add string-append.

* src/strings.c (string_append): New function.
* mes/module/mes/boot-0.scm.in (string-append): Remove.
* mes/module/mes/boot-03.scm (string-append): Remove.
* scaffold/boot/50-make-string.scm (string-append): Remove.
* scaffold/boot/50-string-append.scm (string-append): Remove.
* scaffold/boot/50-string-join.scm (string-append): Remove.
* scaffold/boot/51-module.scm (string-append): Remove.
* scaffold/boot/52-define-module.scm (string-append): Remove.
* tests/macro.test (string-append): Remove.
* scaffold/boot/17-string-append.scm: Move from 50-string-append.scm.

10 months agocore: String as array of bytes.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 15:25:36 +0000 (16:25 +0100)]
core: String as array of bytes.

* src/strings.c: New file.
* src/mes.c: Use it.  Update users.

9 months agomescc: Move mecmp to libc.
Jan Nieuwenhuizen [Sun, 25 Nov 2018 15:09:31 +0000 (16:09 +0100)]
mescc: Move mecmp to libc.

* lib/libc.c: Include mecmp.c.
* lib/libc+tcc.c: Remove mecmp.c include.

10 months agomescc: Move memchr to libc.
Jan Nieuwenhuizen [Thu, 15 Nov 2018 23:01:18 +0000 (00:01 +0100)]
mescc: Move memchr to libc.

* lib/libc.c: Include memchr.c.

10 months agotest: Use write instead of display.
Jan Nieuwenhuizen [Thu, 15 Nov 2018 16:10:03 +0000 (17:10 +0100)]
test: Use write instead of display.

* module/mes/test.scm (seq?, sequal?, seq2?, sless?, sequal2?): Use
write for expected, actual.

10 months agocore: struct_set_: Oops typo.
Jan Nieuwenhuizen [Wed, 14 Nov 2018 07:16:58 +0000 (08:16 +0100)]
core: struct_set_: Oops typo.

* src/struct.c (struct_set_x_): Oops, remove indirection.

10 months agomes: Remove copy of make-string.
Jan Nieuwenhuizen [Wed, 14 Nov 2018 07:19:01 +0000 (08:19 +0100)]
mes: Remove copy of make-string.

* mes/module/mes/guile.mes (make-string): Remove copy.

10 months agomescc: Compile fixes.
Jan Nieuwenhuizen [Wed, 14 Nov 2018 12:07:59 +0000 (13:07 +0100)]
mescc: Compile fixes.

* include/libmes-mini.h[WITH_GLIBC]: Do not declare strlen, write, types.

10 months agomes: Oops, %moduledir debug info.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 13:47:14 +0000 (14:47 +0100)]
mes: Oops, %moduledir debug info.

* mes/module/mes/boot-0.scm.in: Oops, %moduledir debug info.

10 months agobuild: configure: Support Mes.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:38:02 +0000 (10:38 +0100)]
build: configure: Support Mes.

* configure: Support Mes.

10 months agomes; Add read-line.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 15:57:58 +0000 (16:57 +0100)]
mes; Add read-line.

* mes/module/mes/guile.mes (read-line): New function.

10 months agomes: dirname: Fix for absolute file names.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:15:12 +0000 (10:15 +0100)]
mes: dirname: Fix for absolute file names.

* mes/module/mes/guile.mes (dirname): Fix absolute files.

10 months agomes: Add file-exists?.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:14:50 +0000 (10:14 +0100)]
mes: Add file-exists?.

* mes/module/mes/guile.mes (file-exists?): New function.

10 months agomes: Add with-error-to-file.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:14:10 +0000 (10:14 +0100)]
mes: Add with-error-to-file.

* mes/module/mes/guile.mes (with-error-to-file): New function.

10 months agomes: Add string-downcase, string-upcase, string-tokenize.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:00:04 +0000 (10:00 +0100)]
mes: Add string-downcase, string-upcase, string-tokenize.

* mes/module/srfi/srfi-13.mes (string-downcase, string-upcase,
string-tokenize): New function.

10 months agomes: Add char-downcase, char-upcase.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:10:43 +0000 (10:10 +0100)]
mes: Add char-downcase, char-upcase.

* mes/module/srfi/srfi-14.mes (char-downcase, char-upcase): New
function.

10 months agomes: Add char-set:digit, char-set:lower-case, char-set:upper-case.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:09:41 +0000 (10:09 +0100)]
mes: Add char-set:digit, char-set:lower-case, char-set:upper-case.

* mes/module/srfi/srfi-14.mes (char-set:digit, char-set:lower-case,
char-set:upper-case): New variable.

10 months agomes: Add char-set-adjoin, char-set-complement.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:08:03 +0000 (10:08 +0100)]
mes: Add char-set-adjoin, char-set-complement.

* mes/module/srfi/srfi-14.mes (char-set-adjoin, char-set-complement):
New function.

10 months agomes: system*: Support redirection.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:00:50 +0000 (10:00 +0100)]
mes: system*: Support redirection.

* mes/module/mes/posix.mes (system*): Support redirection.

10 months agocore: read_string: Allow for gc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:17:50 +0000 (10:17 +0100)]
core: read_string: Allow for gc.

* src/posix.c (read_char): Add optional port parameter.
(read_string): Allow for gc.

10 months agocore: Add delete_file.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 10:03:03 +0000 (11:03 +0100)]
core: Add delete_file.

* src/posix.c (delete_file): New function.

10 months agocore: Add dup, dup2.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:18:50 +0000 (10:18 +0100)]
core: Add dup, dup2.

* src/posix.c (dup_, dup2_): New function.

10 months agocore: Add getcwd.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:16:19 +0000 (10:16 +0100)]
core: Add getcwd.

* src/posix.c (getcwd_): New function.

10 months agocore: Support redirection of stderr.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:04:03 +0000 (10:04 +0100)]
core: Support redirection of stderr.

* include/libmes-mini.h (g_stderr): New global.
* lib/mes/eputc.c (eputc): Use it.
* lib/mes/eputs.c (eputs): Likewise.
* lib/mes/oputc.c (oputc): Likewise.
* lib/mes/oputs.c (oputs): Likewise.
* src/lib.c (display_error_, write_error_): Likewise.
* src/posix.c (write_byte): Likewise.
* src/mes.c (mes_builtins): Likewise.
(main): Iniitalize g_stderr.
* src/posix.c (current_error_port, set_current_error_port): New
function.
* mes/module/mes/boot-0.scm.in (current-output-port,
current-error-port): Remove.

10 months agocore: Assert g_free in alloc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:01:49 +0000 (10:01 +0100)]
core: Assert g_free in alloc.

* src/mes.c (alloc): Assert g_free.

10 months agomescc: unlink: Move to libc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 10:00:42 +0000 (11:00 +0100)]
mescc: unlink: Move to libc.

* lib/linux/libc.c (unlink): New function.
* lib/linux/tcc.c (unlink): Remove.

10 months agomescc: dup, dup2: Move to libc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:13:01 +0000 (10:13 +0100)]
mescc: dup, dup2: Move to libc.

* lib/linux/libc.c (dup, dup2): New function.
* lib/linux/gnu.c (dup, dup2): Remove.

10 months agomescc: getcwd: Move to libc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:12:19 +0000 (10:12 +0100)]
mescc: getcwd: Move to libc.

* lib/linux/libc.c (getcwd): New function.
* lib/linux/tcc.c (getcwd): Remove.

10 months agomescc: Support GNU make with POSIX.
Jan Nieuwenhuizen [Sat, 10 Nov 2018 07:32:42 +0000 (08:32 +0100)]
mescc: Support GNU make with POSIX.

* include/linux/x86/syscall.h (SYS_sigprocmask): New macro.
* include/linux/x86_64/syscall.h (SYS_rt_sigprocmask): New macro.
* include/signal.h (SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK): New macro.
(sigprocmask): Declare.
* lib/linux/gnu.c (sigprocmask): New function.

10 months agomescc: Support GNU Bash.
Jan Nieuwenhuizen [Fri, 9 Nov 2018 20:26:10 +0000 (21:26 +0100)]
mescc: Support GNU Bash.

* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.

10 months agobuild: Simplify: cater for one compiler at a time.
Jan Nieuwenhuizen [Tue, 6 Nov 2018 19:29:35 +0000 (20:29 +0100)]
build: Simplify: cater for one compiler at a time.

* build-aux/build-cc.sh: Remove.
* build-aux/build-cc32.sh: Remove.
* build-aux/build-cc64.sh: Remove.
* build-aux/build-x86_64-mes.sh: Remove.
* build-aux/cc-mes.sh: Remove.
* build-aux/cc-x86_64-mes.sh: Remove.
* build-aux/cc32-mes.sh: Remove.
* build-aux/cc64-mes.sh: Remove.
* build-aux/test64.sh: Remove.
* build-aux/bootstrap-mes.sh: New file.
* build-aux/config.make.in: New file.
* build-aux/config.status.in: New file.
* build-aux/test-cc.sh: New file.
* .gitignore: Update.
* build-aux/GNUmakefile.in: Update.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-boot.sh: Update.
* build-aux/check-mes.sh: Update.
* build-aux/check-mescc.sh: Update.
* build-aux/check-tcc.sh: Update.
* build-aux/check.sh.in: Update.
* build-aux/config.sh: Update.
* build-aux/export.make: Update.
* build-aux/install.sh.in: Update.
* build-aux/pre-inst-env.in: Update.
* build-aux/test.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* module/mescc/i386/as.scm: Update.
* module/mescc/preprocess.scm: Update.
* module/mescc/x86_64/as.scm: Update.
* scripts/mescc.in: Update.
* tests/psyntax.test: Update.

10 months agomescc: Add missing define.
Jan Nieuwenhuizen [Fri, 9 Nov 2018 15:56:54 +0000 (16:56 +0100)]
mescc: Add missing define.

* lib/x86-mes/x86.M1: Add missing define.

10 months agomescc: Exit if library cannot be found.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 13:46:46 +0000 (14:46 +0100)]
mescc: Exit if library cannot be found.

* module/mescc/mescc.scm (arch-find): Exit upon failure.

10 months agomescc: Accept -O, --std, -x.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 13:07:27 +0000 (14:07 +0100)]
mescc: Accept -O, --std, -x.

* scripts/mescc.in (parse-opts): Accept -O, --std, -x.

10 months agomescc: Support -dumpmachine.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 21:41:20 +0000 (22:41 +0100)]
mescc: Support -dumpmachine.

* scripts/mescc.in (parse-opts): Support -dumpmachine.

10 months agomescc: vsnprintf: Compliant implementation.
Jan Nieuwenhuizen [Mon, 22 Oct 2018 16:33:40 +0000 (18:33 +0200)]
mescc: vsnprintf: Compliant implementation.

* lib/stdio/vsnprintf.c (vsnprintf): New, complient implementation,
replacing vsnprint.
* lib/stdio/vsprintf.c (vsnprint): Forward to vsnprint.
* lib/stdio/snprintf.c (snprintf): Likewise.
* scaffold/tests/9a-snprintf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

11 months agotest: Add performance test.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:04:25 +0000 (12:04 +0200)]
test: Add performance test.

* module/mes/test.scm (pass-if-timeout): New macro.
* tests/perform.test: New test.
* build-aux/check-mes.sh (tests): Run it.

11 months agomes: Add ceil, floor, round, inexact->exact.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:07:06 +0000 (12:07 +0200)]
mes: Add ceil, floor, round, inexact->exact.

* mes/module/mes/scm.mes (ceil, floor, round, inexact->exact,
exact->inexact): New function.