Commit Graph

1872 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 65e545d589
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:02 +02:00
Jan Nieuwenhuizen b03046b370
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen e88f10b067
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen b6cd0bd34f
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen cb1a018f29
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen dd54e779b6
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 938c4262f6
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 33f640e005
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 6d55e94b6a
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen d62f5ac1b4
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 3d0411ac25
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 85627f123c
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 70028b1928
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen b7ba80a25b
mescc: Mes C Library: Prepare for M2-Planet: __assert_fail.
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;

* lib/mes/__assert_fail.c: Rewrite C-constructs not supported by
M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen b391ca3894
core: Use assert_msg.
* src/mes.c: Use assert_msg instead of assert.
* src/gc.c: Likewise.
* src/hash.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/module.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
* src/string.c: Likewise.
* src/struct.c: Likewise.
* src/vector.c: Likewise.
* simple.make (LIB_SOURCES): Add lib/mes/assert_msg.c.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen ad173240c0
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen dfa397f886
core: Prepare for M2-Planet: vector.c.
* src/vector.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 08ffdb51bc
core: Prepare for M2-Planet: struct.c.
* src/struct.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 6c6d85b519
core: Prepare for M2-Planet: string.c.
* src/string.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 2d1bde7621
core: Prepare for M2-Planet: reader.c.
* src/reader.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 6ab4e04921
core: Prepare for M2-Planet: posix.c.
* src/posix.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 64a6f23fea
core: Prepare for M2-Planet: module.c.
* src/module.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen eb3ce6f639
core: Prepare for M2-Planet: math.c.
* src/math.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 633a795393
core: Prepare for M2-Planet: lib.c.
* src/lib.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen deb499a64e
core: Prepare for M2-Planet: hash.c.
* src/hash.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen 4cb35018ed
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen 727065be5e
core: Prepare for M2-Planet: builtins.c.
* src/builtins.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen ea4c39da65
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-10-26 19:40:58 +02:00
Jan Nieuwenhuizen 1971a3722f
mescc: stack: unbump WIP 2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen b6ea857e22
build: Run indent for M2.
* src/gc.c: Indented.
* src/string.c: Likewise.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen f87370a7da
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-10-26 19:40:57 +02:00
Jan Nieuwenhuizen b7dbdc670f
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/build-mes.sh (mes_sources): Add it.
* build-aux/snarf.sh: Likewise.
* 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-10-26 19:40:57 +02:00
Jan Nieuwenhuizen 13a4a2d849
build: simple.make.
* simple.make: New file.
2019-10-26 19:40:57 +02:00
Jan Nieuwenhuizen a15c95aef0
tests: Add gc.test.
* tests/gc.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.
* scaffold/gc-test.scm: Remove.
2019-10-26 19:40:38 +02:00
Jan Nieuwenhuizen dabb424e65
m2: Add scripts/m2-merge.scm.
* scripts/m2-merge.scm.in: New file.
* configure: Substitute it.
* .gitignore: Update.
2019-10-21 21:43:04 +02:00
Jan Nieuwenhuizen 60339608dc
doc update 2019-10-21 21:43:04 +02:00
Jan Nieuwenhuizen 1d1dcdfe40
mescc: Mes C Libray: Fix off_t.
* include/sys/types.h (off_t): Drop unsigned.
2019-10-21 21:43:04 +02:00
Danny Milosavljevic 738264c3bb
Add missing #include.
* lib/stdlib/mbstowcs.c: Add missing #include.
2019-10-21 21:43:04 +02:00
Danny Milosavljevic 30d362321e
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-10-21 21:43:03 +02:00
Danny Milosavljevic 11542affea
va_align: Fix compiler warning.
Follow-up to 49b0cd7d2e6952044d7436260d6ba950e40ee05f.

* include/stdarg.h: Fix compiler warning.
2019-10-05 17:38:20 +02:00
Danny Milosavljevic fce055e9da
Add missing #include.
* lib/tests/mes/90-abtod.c (main): Add missing #include.
2019-10-05 17:38:20 +02:00
Danny Milosavljevic a840c5398f
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-10-05 17:38:19 +02:00
Jan Nieuwenhuizen 52b9dd2b0e
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-10-05 17:38:15 +02:00
Jan Nieuwenhuizen 7181d3dd9a
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-10-05 17:37:28 +02:00
Jan Nieuwenhuizen f4d6851c63
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-10-05 17:37:05 +02:00
Jan Nieuwenhuizen 36e9f532be
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-10-05 17:37:04 +02:00
Jan Nieuwenhuizen eff0077d63
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-10-05 17:37:04 +02:00
Jan Nieuwenhuizen a0efce35a0
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen 4cbdc75bb4
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-10-05 17:37:04 +02:00
Jan Nieuwenhuizen 1f21136539
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-10-05 17:37:04 +02:00