Commit Graph

1811 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 330e9ba037
core: Prepare for M2-Planet: struct.c.
* src/struct.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen a70e82e1d6
core: Prepare for M2-Planet: string.c.
* src/string.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen de1725aebd
core: Prepare for M2-Planet: reader.c.
* src/reader.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen 42c3c28509
core: Prepare for M2-Planet: posix.c.
* src/posix.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen c8fe8f3de5
core: Prepare for M2-Planet: module.c.
* src/module.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen eb2136b4b2
core: Prepare for M2-Planet: math.c.
* src/math.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 930519b142
core: Prepare for M2-Planet: lib.c.
* src/lib.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 7225bef283
core: Prepare for M2-Planet: hash.c.
* src/hash.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen e51b2339c5
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 1aa12c225b
core: Prepare for M2-Planet: builtins.c.
* src/builtins.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen aea32924b7
core: Prepare for M2-Planet: mes.c.
Rewrite C-constructs not supported by M2-Planet, such as

    foo ? bar : baz;       -> if (foo) bar; else baz;
    static char foo[1024]  -> __func_buf = malloc (1024); ... char *foo = __func_buf;
    *foo                   -> foo[0]
    foo++                  -> foo = foo + 1   TODO: pointer arithmetic
    foo += 1;              -> foo = foo + 1
    for (int foo = ;       -> int foo; for (foo=
    if (foo)               -> if (foo != 0)
    if (!foo)              -> if (foo == 0)
    ;                      -> 0;
    // ...                 -> /* ... */

* src/mes.c: Rewrite C constructs not supported by M2-Planet.
* include/mes/mes.h (__execl_c_argv, __getcwd_buf, __open_boot_buf,
__open_boot_file_name, __setenv_buf, __reader_read_char_buf): Declare
buffers.
(init): Initialize them.
* include/mes/macros.h(__M2_PLANET__): Temporary M2 macros.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 2471c1f362
build: Run indent for M2.
* src/gc.c: Indented.
* src/string.c: Likewise.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen cf10d97045
build: mes-snarf.scm: Resurrect.
* build-aux/mes-snarf.scm (snarf-functions): Strip whitespace from
parameter list.
(function->source): Use function-scm-name, add (function1_t).
* build-aux/snarf.sh: Resurrect, combined dump to s, h, c.
* include/mes/builtins.h:
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen c5f9c3d4b6
core: Split-out builtins.c.
* src/mes.c make_builtin_type, make_builtin, builtin_name,
builtin_arity, builtin_function, builtin_p, builtin_printer,
init_builtin, mes_builtins): Move to ..
* src/builtins.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* build-aux/snarf.sh: Likewise.
* build-aux/build-mes.sh (mes_sources): Remove.  Include
configure-lib.sh
* include/mes/builtins.h: Remove constants.
* include/mes/mes.h: Add prototypes.
* include/mes/constants.h (cell_symbol_test): Rename from cell_test.
* simple.make: New file.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen 3c71aee7dc
build: simple.make.
* simple.make: New file.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen 504616b68a
tests: Add gc.test.
* tests/gc.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.
* scaffold/gc-test.scm: Remove.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen 06a2527cc9
m2: Add scripts/m2-merge.scm.
* scripts/m2-merge.scm.in: New file.
* configure: Substitute it.
* .gitignore: Update.
2019-11-17 12:25:27 +01:00
Danny Milosavljevic 6a31571d5a
Fix dtoab.
* lib/mes/dtoab.c (dtoab): Fix it.
* lib/tests/mes/90-dtoab.c (main): Fix test.
* build-aux/check-mescc.sh (XFAIL_TESTS: Remove it.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen e0926c6e12
build: Better and friendlier tarball.
* build-aux/GNUmakefile.in (dist): Be friendly to Debian; avoid using
EPOCH.  Cater for file permission differences.
2019-11-17 12:24:48 +01:00
Jan Nieuwenhuizen 4884ba4ad0
doc update 2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen b03be4a465
build: bootstrap fixes.
* build-aux/config.sh.in (bootstrap): Set up for substitution.
* configure.sh (bootstrap): Substitute.
* build-aux/install.sh.in (_v): Robustify check for V.
(__exclude_go, __exclude_scm): Initialize.
2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen 265d1c6a64
mescc: Environment setup.
* scripts/mescc.in (MES_ARENA, MES_MAX_ARENA, MES_STACK): Reduce defaults.
* build-aux/check.sh.in (MES_ARENA): Likewise.  Export them.
* build-aux/bootstrap.sh.in (MES_STACK): Likewise.
(MES_PREFIX): Set default.
2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen 530dea3405
check: Remove duplicate test.
* build-aux/check-boot.sh (TESTS): Remove duplicate test.
2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen 25082ea4bc
mes: Fix -c, --command.
* mes/module/mes/boot-0.scm: Prepend 'begin to expr list.
2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen 5ece64edd4
mescc: Mes C Libray: Fix off_t.
* include/sys/types.h (off_t): Drop unsigned.
2019-11-17 12:24:47 +01:00
Danny Milosavljevic 35e84ff8aa
Add missing #include.
* lib/stdlib/mbstowcs.c: Add missing #include.
2019-11-17 12:24:47 +01:00
Danny Milosavljevic 58f9e644f4
Fix dtoab.
* lib/mes/dtoab.c (dtoab): Fix it.
* lib/tests/mes/90-dtoab.c (main): Fix test.
* build-aux/check-mescc.sh (XFAIL_TESTS: Remove it.
2019-11-17 12:24:47 +01:00
Danny Milosavljevic 4455f45496
va_align: Fix compiler warning.
Follow-up to 49b0cd7d2e6952044d7436260d6ba950e40ee05f.

* include/stdarg.h: Fix compiler warning.
2019-11-17 12:24:46 +01:00
Danny Milosavljevic 0ea76f2f61
Add missing #include.
* lib/tests/mes/90-abtod.c (main): Add missing #include.
2019-11-17 12:24:46 +01:00
Danny Milosavljevic 809aa3f03a
Fix variable argument list traversal for doubles.
* include/stdarg.h (va_align): New macro.
(va_arg8): New macro.
* lib/stdio/vfprintf.c (vfprintf): Use it.
* lib/stdio/vsnprintf.c (vsnprintf): Use it.
2019-11-17 12:24:46 +01:00
Jan Nieuwenhuizen 4d55c843dc
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.
2019-11-17 12:24:46 +01:00
Jan Nieuwenhuizen 0857d59c24
mescc: Mes C Library: vfprintf, vsnprintf: Pad floats with space.
* lib/stdio/vfprintf.c (vfprintf): Pad floats with space.
* lib/stdio/vsnprintf.c (vsnprintf): Pad floats with space.
* lib/tests/stdio/90-sprintf.c: Test it.
2019-11-17 12:24:46 +01:00
Jan Nieuwenhuizen c7ff4cf2e2
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-11-17 12:24:46 +01:00
Jan Nieuwenhuizen 11ef8a5f85
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-11-17 12:24:46 +01:00
Jan Nieuwenhuizen 082ca6a786
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-11-17 12:24:45 +01:00
Jan Nieuwenhuizen ce5b77062f
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-11-17 12:24:45 +01:00
Jan Nieuwenhuizen cea8ff7b13
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-11-17 12:24:45 +01:00
Jan Nieuwenhuizen 9c734094ba
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-11-17 12:24:45 +01:00
Jan Nieuwenhuizen 6e59b834ef
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/mknod.c: New file.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Add it.
* include/sys/stat.h (mknod): Declare it.
* include/fcntl.h (creat): New macro.
2019-11-17 12:24:45 +01:00
Jan Nieuwenhuizen a65d759903
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-11-17 12:24:45 +01:00
Jan Nieuwenhuizen d30aa7cb04
mescc: Mes C Library: Support GNU Bash: Add struct winsize.
* include/termio.h (struct winsize): New type.
2019-11-17 12:24:44 +01:00
Jan Nieuwenhuizen f7bad50ac8
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-11-17 12:24:44 +01:00
Jan Nieuwenhuizen bea67d7683
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.
* build-aux/configure-lib.sh (libmes_SOURCES, libc_tcc_SOURCES): Add
it.
* 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-11-17 12:24:44 +01:00
Jan Nieuwenhuizen d5a542215a
mescc: Mes C Library: Support GNU Awk: Add abtod, implementing strtod.
* include/libmes.h (abtod): Declare.
* lib/mes/abtod.c: New file.
* build-aux/configure-lib.sh (libmes_SOURCES, libc_tcc_SOURCES): Add
it.
* 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-11-17 12:24:44 +01:00
Jan Nieuwenhuizen c63067c0c9
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
* lib/stdio/vsscanf.c (vsscanf): Support %f.
2019-11-17 12:24:44 +01:00
Jan Nieuwenhuizen 37e82074f0
mescc: Mes C Library: Support GNU Awk: Do not flush std files.
* lib/stdio/fflush.c (fflush): Do not flush std files.
2019-11-17 12:24:44 +01:00
Jan Nieuwenhuizen efd813d404
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-11-17 12:24:44 +01:00
Jan Nieuwenhuizen e040e55f8e
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-11-17 12:24:43 +01:00
Jan Nieuwenhuizen bcb8a071ee
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.
* build-aux/configure-lib.sh (libc_tcc_SOURCES): Add it.
* 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-11-17 12:24:43 +01:00
Jan Nieuwenhuizen d12afa089e
mescc: Mes C Library: Fix compile warnings.
* include/stdlib.h (abort): Add prototype.
2019-11-17 12:24:43 +01:00