Commit Graph

1652 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen bbc65faa84
.dir-locals.el: Assert default GNU settings.
* .dir-locals.el: Assert default GNU settings.
2019-01-16 13:20:26 +01:00
Jan Nieuwenhuizen c410e4ad18
WIP typo in stage0 copyright headers. 2019-01-16 13:19:53 +01:00
Jan Nieuwenhuizen 5725e5a097
doc: Update WIP 2019-01-12 22:08:36 +01:00
Jan Nieuwenhuizen 1b10685770
build: simple.sh: M2-Planet first-aid. WIP 2019-01-12 22:08:35 +01:00
Jan Nieuwenhuizen 984fb447ae
build: Remove POSIX define, use WITH_GLIBC only. WIP 2019-01-12 22:08:34 +01:00
Jan Nieuwenhuizen 7291308484
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.
2019-01-12 22:08:22 +01:00
Jan Nieuwenhuizen 4a78958133
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-01-12 22:08:22 +01:00
Jan Nieuwenhuizen 212cce5692
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.
2019-01-12 22:08:22 +01:00
Jan Nieuwenhuizen f9ceaac9b7
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.
2019-01-12 22:08:22 +01:00
Jan Nieuwenhuizen 570a05be3e
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.
2019-01-12 22:08:21 +01:00
Jan Nieuwenhuizen 64ccd5c9c2
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.
2019-01-12 22:08:21 +01:00
Jan Nieuwenhuizen 338010d498
mescc: Mes C Library: Support GNU Sed: 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.
2019-01-12 22:08:19 +01:00
Jan Nieuwenhuizen ab6028e5bd
mescc: Mes C Library: Support GNU Tar: Fix getpwnam, getpwuid stubs.
* lib/stub/getpwnam.c (getpwnam): Return pointer to static struct
passwd.
* lib/stub/getpwuid.c (getpwuid): Likewise.
2019-01-12 22:01:43 +01:00
Jan Nieuwenhuizen 2fd4ce4e62
mescc: Mes C Library: Support GNU Tar: Add getgrgid, getgrnam, setgrent stub.
* include/grp.h: New file.
* lib/stub/getgrgid.c: New file.
* lib/stub/getgrnam.c: New file.
* lib/stub/setgrent.c: New file.
* lib/libc+gnu.c: Include them.
2019-01-12 22:01:43 +01:00
Jan Nieuwenhuizen 640ec0a9ea
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen f308c3f6bc
mescc: Mes C Library: Support GNU Awk: Add getpgid, getpgrp stubs.
* include/unistd.h (getpgid, getpgrp): Declare.
* lib/stub/getpgid.c: New file.
* lib/stub/getpgrp.c: New file.
* lib/libc+gnu.c: Include them.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen b1a96c2fc6
mescc: Mes C Library: Support GNU Tar: Add mktime stub, fix localtime stub.
* include/time.h (mktime): Declare.
* lib/stub/mktime.c: New stub.
* lib/libc+gnu.c: Include it.
* lib/stub/localtime.c (localtime): Return pointer to static struct
tm.  Avoids segfaults.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen 2b3fbf5ffa
mescc: Mes C Library: Support GNU Tar: Add creat, mknod.
* include/linux/x86_64/syscall.h (SYS_mknod): New macro.
* include/linux/x86/syscall.h (SYS_mknod): New macro.
* lib/linux/gnu.c (mknod): New function, use it.
* include/sys/stat.h: Declare it.
* include/fcntl.h (creat): New macro.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen 098baf52a8
mescc: Mes C Library: Support GNU Tar: Add missing defines.
* include/errno.h (ENXIO): New macro.
* include/sys/stat.h (S_IFIFO, S_ISFIFO): New macro.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen 532e5b0d2d
mescc: Mes C Library: Support GNU Bash: Add struct winsize.
* include/termio.h (struct winsize): New type.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen 73fb77c191
mescc: Mes C Library: Support GNU Awk: Implement atof.
* lib/stdlib/atoi.c: Update.
* lib/stdlib/atof.c: Rename from stub/atof.c; Implement.
* lib/libc+gnu.c: Update include.
* lib/libg.c: Update include.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen a2fbf3de11
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.
2019-01-12 22:01:42 +01:00
Jan Nieuwenhuizen 09a7722c21
mescc: Mes C Library: Support GNU Awk: Add dtoab, %f in vfprintf, vsnprintf.
* include/libmes.h (dtoab): Declare.
* lib/mes/ntoab.c (ntoab): Update.
* lib/mes/dtoab.c: New file.
* lib/tests/mes/90-dtoab.c: Test it.
* lib/tests/stdio/90-sprintf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it, against...
* lib/tests/mes/90-dtoab.stdout: ...baseline.
* lib/stdio/vfprintf.c (vfprintf): Support %f, even more naive support
for %e, %E, %g, %G.
* lib/stdio/vsnprintf.c (vsnprintf): Likewise.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen 0ce74918c1
mescc: Mes C Library: Support GNU Awk: Add abtod, implementing sttrod.
* include/libmes.h (abtod): Declare.
* lib/mes/abtod.c: New file.
* lib/mes/abtol.c: Update.
* lib/stdlib/strtod.c: Use it to implement; move from stub/strtod.
* lib/tests/mes/90-abtod.c: Test it.
* lib/tests/mes/90-abtod.stdout: Baseline.
* build-aux/check-mescc.sh (tests): Run it.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen 85c108076a
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
* lib/stdio/vsscanf.c (vsscanf): Support %f.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen 288a25893c
mescc: Mes C Library: Support GNU Awk: Do not flush std files.
* lib/stdio/fflush.c (fflush): Do not flush std files.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen 539dcb2680
mescc: Mes C Library: Support GNU Awk: Add isgraph.
* lib/ctype/isgraph.c: New file.
* lib/libc+gnu.c: Include it.
* include/ctype.h: Add missing prototypes.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen ab9d47a72f
mescc: Mes C Library: Support GNU Tar: Add readlink, readlink.
* lib/linux/gnu.c (readlink, symlink): New function.
* include/unistd.h (readlink, symlink): Declare.
* include/linux/x86/syscall.h (SYS_readlink, SYS_symlink): New macro.
* include/linux/x86_64/syscall.h (SYS_symlink, SYS_readlink): New
macro.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen 73bb01dc13
mescc: Mes C Library: Support GNU Tar: Add execlp.
* lib/posix/execl.c (vexec): New function.
(execl): Use it.
* lib/posix/execlp.c: New file.
* lib/libc+gnu.c: Include it.
* include/unistd.h (execlp): Declare.
* lib/tests/posix/90-execlp.c: New file.
* lib/tests/posix/90-execlp.stdout: New file.
* build-aux/check-mescc.sh: Test it.
2019-01-12 22:01:41 +01:00
Jan Nieuwenhuizen 5f516870e6
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.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen 3b802ff77c
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.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen 472ea876d4
build: Configure: remove temp files.
* configure (gulp-pipe*): Remove .error.
(check-header-c): Remove .config.c.
(check-compile-c): Likewise.
(check-link-c): Likewise.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen f791a2505a
build: Remove mini-mes.
* scaffold/mini-mes.c: Remove.
* build-aux/build-mes.sh: Remove commented build instructions.
* .gitignore: Remove pattern.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen 9dbbe334b0
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.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen 8b21ff5925
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.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen d3c9fcf57a
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.
2019-01-12 22:01:40 +01:00
Jan Nieuwenhuizen 06e5ccbd83
mes: Remove stray debugging newline output.
* mes/module/mes/guile.mes (open-input-file): Move debugging newline
into debug clause.
2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 9ab3d3cc59
mescc: Mes C Library: Fix brk return type compare.
* lib/stdlib/malloc.c (malloc): Fix brk return type compare.
2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 2721053bc5
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.
2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 586bc0eec9
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.
2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 6c266552e8
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.
2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 6947d7505d
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.
2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 511484cfcd
FIXUP: 41eb11ffd core: Remove struct definitions for builtins, drop snarfing. 2019-01-12 22:01:39 +01:00
Jan Nieuwenhuizen 41eb11ffdb
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.
2019-01-12 20:12:37 +01:00
Jan Nieuwenhuizen 46b76ac699
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.
2019-01-12 20:08:54 +01:00
Jan Nieuwenhuizen d615c03706
mes: Add take-while.
* mes/module/srfi/srfi-1.mes (take-while): New function.
2018-12-30 10:41:00 +01:00
Jan Nieuwenhuizen 885a1c8ea3
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.
2018-12-30 10:41:00 +01:00
Jan Nieuwenhuizen 8040913edc
build: Support running out-of-tree.
* build-aux/pre-inst-env.in (MES_PREFIX): Use absolute name.
2018-12-20 16:50:06 +01:00
Jan Nieuwenhuizen 77ea72bb7d
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.
2018-12-20 16:50:06 +01:00
Jan Nieuwenhuizen f6e4a00b2a
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.
2018-12-20 16:50:06 +01:00