Commit Graph

2147 Commits

Author SHA1 Message Date
Jan (janneke) Nieuwenhuizen 945b238a6a
core: Prepare for M2-Planet: module.c.
* src/module.c: Rewrite C constructs not supported by M2-Planet.
2020-12-29 18:10:52 +01:00
Jan (janneke) Nieuwenhuizen e62009b02d
core: Prepare for M2-Planet: math.c.
* src/math.c: Rewrite C constructs not supported by M2-Planet.
2020-12-29 18:10:52 +01:00
Jan (janneke) Nieuwenhuizen fcc4e483af
core: Prepare for M2-Planet: lib.c.
* src/lib.c: Rewrite C constructs not supported by M2-Planet.
2020-12-29 18:10:52 +01:00
Jan (janneke) Nieuwenhuizen 9c1a950cc6
core: Prepare for M2-Planet: hash.c.
* src/hash.c: Rewrite C constructs not supported by M2-Planet.
2020-12-29 18:10:51 +01:00
Jan (janneke) Nieuwenhuizen 6f513dd2d7
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2020-12-29 18:10:51 +01:00
Jan (janneke) Nieuwenhuizen 145d277a8b
core: Prepare for M2-Planet: builtins.c.
* src/builtins.c: Rewrite C constructs not supported by M2-Planet.
2020-12-29 18:10:51 +01:00
Jan (janneke) Nieuwenhuizen 4a6b3f990c
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.
2020-12-29 18:10:51 +01:00
Jan (janneke) Nieuwenhuizen 06ca28aafb
build: Run indent for M2.
* src/gc.c: Indented.
* src/string.c: Likewise.
2020-12-29 18:10:51 +01:00
Jan (janneke) Nieuwenhuizen 748a856b50
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:
2020-12-29 18:10:51 +01:00
Jan (janneke) Nieuwenhuizen e0ac5588ae
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.
2020-12-29 18:10:50 +01:00
Jan (janneke) Nieuwenhuizen d5321636ef
build: simple.make.
* simple.make: New file.
* src/posix.c: Make sure to define EOF.
2020-12-29 18:10:50 +01:00
Jan (janneke) Nieuwenhuizen 64635bd1e1
tests: Add gc.test.
* tests/gc.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.
* scaffold/gc-test.scm: Remove.
2020-12-29 18:10:50 +01:00
Jan (janneke) Nieuwenhuizen 3bd3e5edfe
mescc: Mes C Library: div.c: Use only for ARM.
* build-aux/configure-lib.sh (libmescc_SOURCES): Remove div.c unless
ARM.
2020-12-29 17:09:35 +01:00
Jan (janneke) Nieuwenhuizen 9b0e04c0e3
mescc: Mes C Library: feof: Bugfix for ARM.
* lib/stdio/feof.c (feof): Use int to compare with EOF.
2020-12-29 14:24:30 +01:00
Jan (janneke) Nieuwenhuizen 42a18b3425
mescc: Mes C Library: time.c: Use #if defined.
This helps resurrect the mes-0.19-based bootstrap.

* lib/linux/time.c: Use #if defined () instead of plain #if for possibly
undefined macros.
2020-12-29 14:24:30 +01:00
Jan (janneke) Nieuwenhuizen 0dbfe669fa
mescc: Change --align to --align=functions, --align=globals.
This makes function alignment optional and disables function alignment
when using MesCC-Tools 0.5.2 (numbered architecture).

* module/mescc.scm (parse-opts): Make --align take a value.
* module/mescc/mescc.scm (mescc:compile, infos->hex2): Parse it and pass
it as renamed #:align keyword argument to ...
* module/mescc/M1.scm (infos->M1): ...here.  Rename parameter align? to
align, pass it to...
(info->M1): ...here.  Likewise.  Use it to make function alignment
optional.
2020-12-29 14:24:29 +01:00
Jan (janneke) Nieuwenhuizen 9d92e839c8
libtcc1: Compile float stubs conditionally.
* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf,
__floatdidf)[!(HAVE_FLOAT_STUB || HAVE_FLOAT)]: Remove.
2020-12-29 14:24:28 +01:00
Jan (janneke) Nieuwenhuizen 57cd02ed0d
bootstrap: Resurrect.
* build-aux/bootstrap.sh.in (AM_CFLAGS): Use -L ${srcdest}lib.
Build libmescc.a and use it to link mes.
2020-12-29 14:24:28 +01:00
Jan (janneke) Nieuwenhuizen dacc55711c
mescc: Make sure includedir, libdir are set.
* scripts/mescc.in (prefix): New variable.
2020-12-29 14:24:27 +01:00
Jan (janneke) Nieuwenhuizen a8f1b63519
build: Make mescc more verbose on V=2, V=3.
* build-aux/cflags.sh (AM_CFLAGS): Add -v, -v -v for V=2, V=3
respectively.
2020-12-29 14:24:26 +01:00
Jan (janneke) Nieuwenhuizen dae845aad4
libtcc1: Make float stubs weak.
* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf, __floatdidf): Add
__attribute__ ((weak)).
2020-12-29 14:24:26 +01:00
Jan (janneke) Nieuwenhuizen 5c45d7d9de
mescc: Skip attributes on function definitions.
* module/mescc/preprocess.scm (ast-strip-attributes): New procedure.
(c99-input->ast): Use it.
2020-12-29 14:24:26 +01:00
Jan (janneke) Nieuwenhuizen 8458e3680d
mescc: Mes C Library: Declare __mesabi_uldiv.
* include/mes/lib.h (__mesabi_uldiv): Add prototype.
2020-12-29 14:24:25 +01:00
Jan (janneke) Nieuwenhuizen 6c64b2fc0f
mescc: Mes C Library: ARM: setjmp.c: Inline fake asm.
* lib/linux/arm-mes-gcc/_exit.c (longjmp, setjmp): Use inline fake asm.
2020-12-29 14:24:24 +01:00
Jan (janneke) Nieuwenhuizen b77845ae9a
mescc: Mes C Library: ARM: syscall.c: Inline fake asm.
* lib/linux/arm-mes-gcc/syscall.c (__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4): Use inline fake asm.
2020-12-29 14:24:24 +01:00
Jan (janneke) Nieuwenhuizen 191de698a7
mescc: Mes C Library: ARM: _write.c: Inline fake asm.
* lib/linux/arm-mes-gcc/_write.c (_write): Use inline fake asm.
2020-12-29 14:24:23 +01:00
Jan (janneke) Nieuwenhuizen fb4b8bb58c
mescc: Mes C Library: ARM: _exit: Inline fake asm.
* lib/linux/arm-mes-gcc/_exit.c (_exit): Use inline fake asm.
2020-12-29 14:24:22 +01:00
Jan (janneke) Nieuwenhuizen 99a9ab7411
mescc: Mes C Library: ARM: _start: Inline fake asm.
* lib/linux/arm-mes-gcc/crt1.c (_start): Use inline fake asm.
2020-12-29 14:24:21 +01:00
Jan (janneke) Nieuwenhuizen 733b927c4c
tests: Add 70-or-argument.c.
* lib/tests/scaffold/70-or-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2020-12-29 14:24:21 +01:00
Jan (janneke) Nieuwenhuizen 299a9ea369
tests: Add 70-function-modulo.c.
* lib/tests/scaffold/70-function-modulo.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2020-12-29 14:24:20 +01:00
Jan (janneke) Nieuwenhuizen 8c85bccd56
tests: 70-strchr.c: Rewrite for TinyCC.
* lib/tests/string/70-strchr.c (main): Use char* hello for comparison.
Allows for duplication of "hello" string.
2020-12-29 14:24:19 +01:00
Jan (janneke) Nieuwenhuizen 614c9146ba
test: scaffold/54-argv.c: Support running with TinyCC.
This fixes running as lib/tests/scaffold/54-argv-i686-unknown-linux-gnu-tcc.

* lib/tests/scaffold/54-argv.c (main): Compare only first 26 characters
of argv[0].
2020-12-29 14:24:18 +01:00
Jan (janneke) Nieuwenhuizen 612714b26b
mescc: Mes C Library: Split _exit.c, _write.c from mini.c.
* lib/freebsd/x86-mes-gcc/mini.c: Split into...
* lib/freebsd/x86-mes-gcc/_exit.c: ...this, and...
* lib/freebsd/x86-mes-gcc/_write.c: ...this.
* lib/freebsd/x86-mes-mescc/mini.c: Slpit into...
* lib/freebsd/x86-mes-mescc/_exit.c: ...this, and...
* lib/freebsd/x86-mes-mescc/_write.c: ...this.
* lib/gnu/x86-mes-gcc/mini.c: Split into...
* lib/gnu/x86-mes-gcc/_exit.c: ...this, and...
* lib/gnu/x86-mes-gcc/_write.c: ...this.
* lib/linux/arm-mes-gcc/mini.c: Split into...
* lib/linux/arm-mes-gcc/_exit.c: ...this, and...
* lib/linux/arm-mes-gcc/_write.c: ...this.
* lib/linux/arm-mes-mescc/mini.c: Split into...
* lib/linux/arm-mes-mescc/_exit.c: ...this, and...
* lib/linux/arm-mes-mescc/_write.c: ...this.
* build-aux/configure-lib.sh (libc_mini_shared_SOURCES): Replace mini.c
with add _exit.c, _write.c.
* simple.sh: Update accordingly.
2020-12-29 14:24:18 +01:00
Danny Milosavljevic d2d3844738
mescc: define int64_t and uint64_t only if it's possible to define them as
exactly 64 bits.

* include/stdint.h[__SIZEOF_LONG_LONG__ != 8]: Remove typedefs for int64_t,
uint16_t.
2020-12-29 14:24:18 +01:00
Jan (janneke) Nieuwenhuizen 54fca6cad9
mescc: Add __SIZEOF defines for int, long, long long.
* module/mescc/mescc.scm (arch-get-define): Rename
to...  (arch-get-defines): ...this.  Return a list of defines: Also
adding __SIZEOF_INT__, __SIZEOF_LONG__, and add __SIZEOF_LONG_LONG__ if
it's >=8.
(mescc:preprocess, c->info): Update callers.
* include/stdint.h[!__SIZEOF_LONG_LONG__]: Remove typedefs for int64_t,
uint16_t.
2020-12-29 14:24:17 +01:00
Jan (janneke) Nieuwenhuizen 2c3e96bcfc
ARM: Add fake asm for setjmp.c.
* lib/arm-mes-gcc/setjmp.c (longjmp, setjmp)[__TINYC__]: Add fake asm.
2020-12-29 14:24:17 +01:00
Jan (janneke) Nieuwenhuizen 9553e33379
ARM: Add fake asm for syscall.c.
* lib/linux/arm-mes-gcc/syscall.c (__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4) [__TINYC__]: Add fake asm.
2020-12-29 14:24:16 +01:00
Jan (janneke) Nieuwenhuizen 8062b7cd21
ARM: Add fake asm for mini.c.
* lib/linux/arm-mes-gcc/mini.c (_exit, _write)[__TINYC__]: Add fake asm.
2020-12-29 14:24:15 +01:00
Jan (janneke) Nieuwenhuizen ae3e50f5b3
ARM: Add fake asm for crt1.c.
* lib/linux/arm-mes-gcc/crt1.c (_start)[__TINYC__]: Use fake asm.
2020-12-29 14:24:15 +01:00
Jan (janneke) Nieuwenhuizen 5eaefeac38
mescc: Mes C Library: Support ARM tcc: Add crti.c, crtn.c.
* lib/linux/arm-mes-gcc/crti.c: New file.
* lib/linux/arm-mes-gcc/crtn.c: New file.
2020-12-29 14:24:14 +01:00
Jan (janneke) Nieuwenhuizen 74e0ed606c
ARM: libtcc1: Add div.c, __memcpy, __memmove, __memset.
* build-aux/configure-lib.sh (libtcc1_SOURCES)[arm]: Add div.c,
__memcpy, __memmove, __memset.
* build-aux/build-source-lib.sh: Generate libtcc1.
2020-12-29 14:24:14 +01:00
Jan (janneke) Nieuwenhuizen def9c6c330
mescc: Mes C Library: Support ARM tcc: Add __memset.
* lib/string/__memset.c: New file.
* include/mes/lib.h (__memset): Add prototype.
2020-12-29 14:24:13 +01:00
Jan (janneke) Nieuwenhuizen f0c1f4c4d2
mescc: Mes C Library: Support ARM tcc: Add __memmove.
* lib/string/__memmove.c: New file.
* include/mes/lib.h (__memmove): Add prototype.
2020-12-29 14:24:12 +01:00
Jan (janneke) Nieuwenhuizen 15d860d334
mescc: Mes C Library: Support ARM tcc: Add __memcpy.
* lib/string/__memcpy.c: New file.
* include/mes/lib.h (__memcpy): Add prototype.
2020-12-29 14:24:12 +01:00
Jan (janneke) Nieuwenhuizen 4e092fdedd
mescc: Mes C Library: abort: Avoid __raise for TinyCC.
* lib/stdlib/abort.c: Use "raise" instead of __raise.
2020-12-29 14:24:11 +01:00
Jan (janneke) Nieuwenhuizen 68fc0e6ec6
doc: Update 'AUTHORS'.
* AUTHORS: Add Natalie Kopaczewski.
2020-12-29 14:24:11 +01:00
Jan (janneke) Nieuwenhuizen 8fb2ab4439
test: Split-off scaffold/60-math-itoa.c.
* lib/tests/scaffold/60-math.c (main): Move itoa tests to...
* lib/tests/scaffold/60-math-itoa.c: ...this new file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2020-12-29 14:24:10 +01:00
Jan (janneke) Nieuwenhuizen a810bc50e0
test: Split-off 36-compare-arithmetic-negative.c.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Move negative
divisions to...
* lib/tests/scaffold/36-compare-arithmetic-negative.c: ...new file here.
* build-aux/check-mescc.sh (mes_tests): Add it.
2020-12-29 14:24:10 +01:00
Jan (janneke) Nieuwenhuizen f478ab3805
test: ARM: 08-assign.c: Avoid assembly for tcc.
* lib/tests/scaffold/08-assign.c (main)[__arm__ && __TINYC__]: Avoid assembly.
2020-12-29 14:24:09 +01:00
Jan (janneke) Nieuwenhuizen 6a8f67efa2
test: Split-off 50-strcmp-itoa.c
* lib/tests/string/50-strcmp.c (main): Move itoa tests to...
* lib/tests/string/50-strcmp-itoa.c: ...this new file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2020-12-29 14:24:09 +01:00