Commit Graph

2187 Commits

Author SHA1 Message Date
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
Jan (janneke) Nieuwenhuizen ddfb34a40d
ARM: libtcc1: Add __divsi3, __modsi3, __udivsi3, __umodsi3.
* lib/libtcc1.c (__divsi3, __modsi3, __udivsi3, __umodsi3): New functions.
2020-12-29 14:24:09 +01:00
Jan (janneke) Nieuwenhuizen 40e0cb11b9
ARM: libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
* lib/libtcc1.c (__floatdisf, __floatdidf)[__arm__]: New stubs.
2020-12-29 14:24:08 +01:00
Jan (janneke) Nieuwenhuizen c340ca3e27
libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
* lib/libtcc1.c (__floatundidf, __fixunsdfdi, __fixunsdfsi): New stubs.
2020-12-29 14:24:07 +01:00
Jan (janneke) Nieuwenhuizen e2da1c5c7b
ARM: libtcc1: Add support for TinyCC.
* lib/libtcc1.c: (__udivdi3, __umoddi3, __lshrdi3, __ashldi3,
__fixunsxfdi)[__arm__ && __TINYC__]: Use __mesabi functions.
2020-12-29 14:24:07 +01:00
Jan (janneke) Nieuwenhuizen 9694354633
libtcc1: Remove mesabi dependencies for TinyCC.
* lib/libtcc1.c (__divdi3, __moddi3, __udivdi3, __umoddi3, __lshrdi3,
__ashldi3, __ashrdi3, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi)[__TINYC__]: No stub printing.
2020-12-29 14:24:06 +01:00
Jan (janneke) Nieuwenhuizen cb79d8ffb1
mescc: Mes C Library: div: Avoid __raise for TinyCC.
* lib/mes/div.c (__raise)[__TINYC__]: New macro.
2020-12-29 14:24:06 +01:00
Jan (janneke) Nieuwenhuizen 0727fd39cc
mescc: Mes C Library: Add __mesabi_umod, __mesabi_udiv.
* lib/mes/div.c (__mesabi_umod, __mesabi_udiv): New functions.
* include/mes/lib.h: Add prototypes.
2020-12-29 14:24:06 +01:00
Danny Milosavljevic 62205a9925
ARM: Implement long division.
* lib/mes/div.c (__mesabi_log2i): New procedure.
(__mesabi_uldiv1): New procedure.
(__mesabi_uldiv): Use it.

Co-Authored-By: Nathalie Kopaczewski <natkopa@gmail.com>
2020-12-29 14:24:05 +01:00
Danny Milosavljevic 80e08cf1ef
ARM: Special-case setjmp struct for gcc with mes libc.
* include/setjmp.h (__jmp_buf): Special-case setjmp struct for gcc with mes
libc.
2020-12-29 14:24:05 +01:00
Jan (janneke) Nieuwenhuizen 04c058fe5e
tests: Add 70-ternary-arithmetic-argument.c.
* lib/tests/scaffold/70-ternary-arithmetic-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests, xfail_tests): Add it.
2020-12-29 14:24:05 +01:00