mes.git
4 days agolib/tests: Pass int to va_arg instead of char. master wip
W. J. van der Laan [Sun, 4 Apr 2021 11:27:50 +0000 (11:27 +0000)]
lib/tests: Pass int to va_arg instead of char.

* lib/tests/scaffold/70-stdarg.c (stdarg1, stdarg2, stdarg3): Pass int
to va_arg instead of char to avoid gcc trap "warning: 'char’ is promoted
to ‘int’ when passed through ‘...’ [enabled by default] (so you should
pass ‘int’ not ‘char’ to ‘va_arg’) if this code is reached, the program
will abort".

4 days agomes: Prevent out-of-bounds access for stack frame 0.
W. J. van der Laan [Mon, 5 Apr 2021 11:16:17 +0000 (11:16 +0000)]
mes: Prevent out-of-bounds access for stack frame 0.

* src/lib.c (make_frame): Add a check to prevent reads outside of the
stack when trying to determine the procedure for stack frame 0.

4 days agomescc: Pass --64 to bloodelf for 64 bit machines.
W. J. van der Laan [Fri, 23 Apr 2021 14:07:45 +0000 (14:07 +0000)]
mescc: Pass --64 to bloodelf for 64 bit machines.

* module/mescc/mescc.scm (M1->blood-elf): Pass --64 argument to bloodelf
for 64-bit machines.  This makes it able to generate the correct ELF
format.

4 days agoconfigure: Do not use GUILD_OPTIMIZE=-O1 for Guile-2.
Jan (janneke) Nieuwenhuizen [Mon, 26 Apr 2021 04:55:27 +0000 (06:55 +0200)]
configure: Do not use GUILD_OPTIMIZE=-O1 for Guile-2.

This is a follow-up to

    a0560aff676b0fe8d7d50b365a75ed158347eb3a
    configure: Use GUILD_OPTIMIZE=-O1 for Guile-3.

and fixes using Guile-2.0.x, which does not support -O1.

Reported by W. J. van der Laan <laanwj@protonmail.com>.

* configure (main): Check for Guile > 2.9.x to set optimization.

4 days agomescc: Mes C Library: crt: Support more than 255 command line parameters.
Jan (janneke) Nieuwenhuizen [Sun, 2 May 2021 12:15:37 +0000 (14:15 +0200)]
mescc: Mes C Library: crt: Support more than 255 command line parameters.

Reported by Paul Dersey <pdersey@gmail.com>.

* lib/freebsd/x86-mes-gcc/crt1.c (_start): Use mov instead of movzbl for
argc.
* lib/linux/x86-mes-gcc/crt0.c (_start): Likewise.
* lib/linux/x86-mes-gcc/crt1.c (_start): Likewise.
* lib/freebsd/x86-mes-mescc/crt1.c (_start): Likewise.
* lib/linux/x86-mes-mescc/crt1.c (_start): Likewise.

4 days agomescc: Mes C Library: malloc.c: Move unix-variant to lib/linux.
Jan (janneke) Nieuwenhuizen [Sun, 2 May 2021 11:10:40 +0000 (13:10 +0200)]
mescc: Mes C Library: malloc.c: Move unix-variant to lib/linux.

* lib/stdlib/malloc.c: Move to...
lib/linux/malloc.c: ...here.
* build-aux/configure-lib.sh (libc_SOURCES): Move malloc.c...
[linux]: ...here.

5 days agomescc: Support --bootstrap build on ARM. wip-arm
Jan (janneke) Nieuwenhuizen [Sat, 1 May 2021 13:40:56 +0000 (15:40 +0200)]
mescc: Support --bootstrap build on ARM.

The ARM port added the `-marm' option to mescc, where previously only
-m32' (the default) and `-m64' were supported.

Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.

* module/mescc/mescc.scm (arch-get-machine): When machine is "arm",
return "32".
* build-aux/build-mes.sh (LIBS)[mescc]: Add -lmescc.

2 weeks agomes: Make logand work correctly.
W. J. van der Laan [Tue, 20 Apr 2021 13:24:27 +0000 (13:24 +0000)]
mes: Make logand work correctly.

* src/math.c (logand): Start from -1 instead of 0, so that the bitwise AND-ed
result is the intersection of bit sets instead of always 0.
* tests/math.test ("logand", "logand 3"): Test it.

Co-authored-by: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
7 weeks agodoc: Post-release update.
Jan (janneke) Nieuwenhuizen [Sun, 14 Mar 2021 11:08:40 +0000 (12:08 +0100)]
doc: Post-release update.

* README: Update wording.
* doc/announce/ANNOUNCE-0.23: Likewise.  Add gen-announce checksums.

7 weeks agoguix: mes: Update to 0.23.
Jan (janneke) Nieuwenhuizen [Sun, 14 Mar 2021 11:07:23 +0000 (12:07 +0100)]
guix: mes: Update to 0.23.

* guix/git/mes.scm (mes)[source]: Update to 0.23.

7 weeks agobuild: Release 0.23. v0.23
Jan (janneke) Nieuwenhuizen [Sun, 10 Jan 2021 10:58:50 +0000 (11:58 +0100)]
build: Release 0.23.

* configure (VERSION): Bump to 0.23.
(main): Update mes requirement to 0.22.
* configure.sh (VERSION): Likewise.

7 weeks agodoc: Fix broken link in 'README'.
Jan (janneke) Nieuwenhuizen [Sun, 21 Feb 2021 07:13:07 +0000 (08:13 +0100)]
doc: Fix broken link in 'README'.

Reported by Arkadiusz.Ryś <Arkadiusz.Rys@protonmail.com>.

* README: Fix m2-planet link.

7 weeks agodoc: Release update.
Jan (janneke) Nieuwenhuizen [Thu, 31 Dec 2020 12:05:41 +0000 (13:05 +0100)]
doc: Release update.

* ROADMAP (release 0.x, unsorted): Rewrite, move done items ...
(DONE): ...here.
* build-aux/GNUmakefile.in: Update release process.
(gen-announce): Remove trailing '-'.
* NEWS (Changes in 0.23 since 0.22): Add section.
* README: Add armhf-linux, aarch64-linux, NLNet sponsoring, remove
confusing references to mes-m2 fork.
* doc/announce/ANNOUNCE-0.23: New file.
* mes/module/mes/repl.mes: Update copyright years.
* doc/mes.texi (Porting GNU Mes): Mention that armhf-linux is supported.
(Regular Requirements): Update.
* INSTALL (Other GNU/Linux): Likewise.

7 weeks agolibtcc1: Fix integer division, modulo and shifting procedures.
Danny Milosavljevic [Mon, 8 Feb 2021 18:31:53 +0000 (19:31 +0100)]
libtcc1: Fix integer division, modulo and shifting procedures.

* lib/libtcc1.c (__divdi3): Make parameters integer.
(__moddi3): Make parameters integer.
(__udivdi3): Use unsigned division.
(__umoddi3): Use unsigned modulo.
(__lshrdi3): Add comment.
(__ashrdi3): Add comment.

3 months agomescc: Mes C Library: Make malloc align the blocks it gives out.
Danny Milosavljevic [Fri, 8 Jan 2021 21:08:39 +0000 (22:08 +0100)]
mescc: Mes C Library: Make malloc align the blocks it gives out.

* include/stddef.h (max_align_t): Add typedef for max_align_t.
* lib/stdlib/malloc.c (malloc): Align the blocks it gives out to multiples
of max_align_t.

3 months agotests: Update to bin/mes for standalone run.
Jan (janneke) Nieuwenhuizen [Thu, 31 Dec 2020 10:45:46 +0000 (11:45 +0100)]
tests: Update to bin/mes for standalone run.

* tests/base.test,
tests/boot.test,
tests/macro.test,
tests/perform.test,
tests/quasiquote.test,
tests/read.test,
tests/scm.test,
tests/srfi-0.test: Default to bin/mes.

3 months agomescc: Mes C Library: div.c: Use only for ARM.
Jan (janneke) Nieuwenhuizen [Tue, 29 Dec 2020 16:09:35 +0000 (17:09 +0100)]
mescc: Mes C Library: div.c: Use only for ARM.

* build-aux/configure-lib.sh (libmescc_SOURCES): Remove div.c unless
ARM.

3 months agomescc: Mes C Library: feof: Bugfix for ARM.
Jan (janneke) Nieuwenhuizen [Mon, 28 Dec 2020 09:19:56 +0000 (10:19 +0100)]
mescc: Mes C Library: feof: Bugfix for ARM.

* lib/stdio/feof.c (feof): Use int to compare with EOF.

3 months agomescc: Mes C Library: time.c: Use #if defined.
Jan (janneke) Nieuwenhuizen [Wed, 23 Dec 2020 15:06:15 +0000 (16:06 +0100)]
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.

3 months agomescc: Change --align to --align=functions, --align=globals.
Jan (janneke) Nieuwenhuizen [Wed, 23 Dec 2020 13:38:38 +0000 (14:38 +0100)]
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.

3 months agolibtcc1: Compile float stubs conditionally.
Jan (janneke) Nieuwenhuizen [Wed, 16 Dec 2020 11:31:41 +0000 (12:31 +0100)]
libtcc1: Compile float stubs conditionally.

* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf,
__floatdidf)[!(HAVE_FLOAT_STUB || HAVE_FLOAT)]: Remove.

3 months agolibtcc1: Make float stubs weak.
Jan (janneke) Nieuwenhuizen [Sun, 13 Dec 2020 08:43:20 +0000 (09:43 +0100)]
libtcc1: Make float stubs weak.

* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf, __floatdidf): Add
__attribute__ ((weak)).

3 months agomescc: Skip attributes on function definitions.
Jan (janneke) Nieuwenhuizen [Sun, 13 Dec 2020 08:41:38 +0000 (09:41 +0100)]
mescc: Skip attributes on function definitions.

* module/mescc/preprocess.scm (ast-strip-attributes): New procedure.
(c99-input->ast): Use it.

3 months agomescc: Mes C Library: Declare __mesabi_uldiv.
Jan (janneke) Nieuwenhuizen [Sat, 12 Dec 2020 21:52:13 +0000 (22:52 +0100)]
mescc: Mes C Library: Declare __mesabi_uldiv.

* include/mes/lib.h (__mesabi_uldiv): Add prototype.

3 months agomescc: Mes C Library: ARM: setjmp.c: Inline fake asm.
Jan (janneke) Nieuwenhuizen [Mon, 7 Dec 2020 12:03:45 +0000 (13:03 +0100)]
mescc: Mes C Library: ARM: setjmp.c: Inline fake asm.

* lib/linux/arm-mes-gcc/_exit.c (longjmp, setjmp): Use inline fake asm.

3 months agomescc: Mes C Library: ARM: syscall.c: Inline fake asm.
Jan (janneke) Nieuwenhuizen [Mon, 7 Dec 2020 12:03:33 +0000 (13:03 +0100)]
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.

3 months agomescc: Mes C Library: ARM: _write.c: Inline fake asm.
Jan (janneke) Nieuwenhuizen [Mon, 7 Dec 2020 12:03:21 +0000 (13:03 +0100)]
mescc: Mes C Library: ARM: _write.c: Inline fake asm.

* lib/linux/arm-mes-gcc/_write.c (_write): Use inline fake asm.

3 months agomescc: Mes C Library: ARM: _exit: Inline fake asm.
Jan (janneke) Nieuwenhuizen [Mon, 7 Dec 2020 12:03:06 +0000 (13:03 +0100)]
mescc: Mes C Library: ARM: _exit: Inline fake asm.

* lib/linux/arm-mes-gcc/_exit.c (_exit): Use inline fake asm.

3 months agomescc: Mes C Library: ARM: _start: Inline fake asm.
Jan (janneke) Nieuwenhuizen [Mon, 7 Dec 2020 06:16:14 +0000 (07:16 +0100)]
mescc: Mes C Library: ARM: _start: Inline fake asm.

* lib/linux/arm-mes-gcc/crt1.c (_start): Use inline fake asm.

3 months agotests: Add 70-or-argument.c.
Jan (janneke) Nieuwenhuizen [Tue, 1 Dec 2020 10:36:23 +0000 (11:36 +0100)]
tests: Add 70-or-argument.c.

* lib/tests/scaffold/70-or-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.

3 months agotests: Add 70-function-modulo.c.
Jan (janneke) Nieuwenhuizen [Tue, 1 Dec 2020 10:34:08 +0000 (11:34 +0100)]
tests: Add 70-function-modulo.c.

* lib/tests/scaffold/70-function-modulo.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.

3 months agotests: 70-strchr.c: Rewrite for TinyCC.
Jan (janneke) Nieuwenhuizen [Sun, 29 Nov 2020 09:27:36 +0000 (10:27 +0100)]
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.

3 months agotest: scaffold/54-argv.c: Support running with TinyCC.
Jan (janneke) Nieuwenhuizen [Sun, 29 Nov 2020 07:58:12 +0000 (08:58 +0100)]
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].

3 months agomescc: Mes C Library: Split _exit.c, _write.c from mini.c.
Jan (janneke) Nieuwenhuizen [Sat, 28 Nov 2020 17:22:51 +0000 (18:22 +0100)]
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.

3 months agomescc: define int64_t and uint64_t only if it's possible to define them as
Danny Milosavljevic [Wed, 25 Nov 2020 18:46:40 +0000 (19:46 +0100)]
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.

3 months agomescc: Add __SIZEOF defines for int, long, long long.
Jan (janneke) Nieuwenhuizen [Wed, 25 Nov 2020 17:33:51 +0000 (18:33 +0100)]
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.

3 months agoARM: Add fake asm for setjmp.c.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 21:21:16 +0000 (22:21 +0100)]
ARM: Add fake asm for setjmp.c.

* lib/arm-mes-gcc/setjmp.c (longjmp, setjmp)[__TINYC__]: Add fake asm.

3 months agoARM: Add fake asm for syscall.c.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 21:20:22 +0000 (22:20 +0100)]
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.

3 months agoARM: Add fake asm for mini.c.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 20:35:38 +0000 (21:35 +0100)]
ARM: Add fake asm for mini.c.

* lib/linux/arm-mes-gcc/mini.c (_exit, _write)[__TINYC__]: Add fake asm.

3 months agoARM: Add fake asm for crt1.c.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 20:29:54 +0000 (21:29 +0100)]
ARM: Add fake asm for crt1.c.

* lib/linux/arm-mes-gcc/crt1.c (_start)[__TINYC__]: Use fake asm.

3 months agomescc: Mes C Library: Support ARM tcc: Add crti.c, crtn.c.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 20:13:46 +0000 (21:13 +0100)]
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.

3 months agoARM: libtcc1: Add div.c, __memcpy, __memmove, __memset.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 19:44:05 +0000 (20:44 +0100)]
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.

3 months agomescc: Mes C Library: Support ARM tcc: Add __memset.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 19:43:35 +0000 (20:43 +0100)]
mescc: Mes C Library: Support ARM tcc: Add __memset.

* lib/string/__memset.c: New file.
* include/mes/lib.h (__memset): Add prototype.

3 months agomescc: Mes C Library: Support ARM tcc: Add __memmove.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 19:42:49 +0000 (20:42 +0100)]
mescc: Mes C Library: Support ARM tcc: Add __memmove.

* lib/string/__memmove.c: New file.
* include/mes/lib.h (__memmove): Add prototype.

3 months agomescc: Mes C Library: Support ARM tcc: Add __memcpy.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 19:41:07 +0000 (20:41 +0100)]
mescc: Mes C Library: Support ARM tcc: Add __memcpy.

* lib/string/__memcpy.c: New file.
* include/mes/lib.h (__memcpy): Add prototype.

3 months agomescc: Mes C Library: abort: Avoid __raise for TinyCC.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 19:21:13 +0000 (20:21 +0100)]
mescc: Mes C Library: abort: Avoid __raise for TinyCC.

* lib/stdlib/abort.c: Use "raise" instead of __raise.

3 months agodoc: Update 'AUTHORS'.
Jan (janneke) Nieuwenhuizen [Sat, 21 Nov 2020 22:04:47 +0000 (23:04 +0100)]
doc: Update 'AUTHORS'.

* AUTHORS: Add Natalie Kopaczewski.

3 months agotest: Split-off scaffold/60-math-itoa.c.
Jan (janneke) Nieuwenhuizen [Sat, 21 Nov 2020 20:04:45 +0000 (21:04 +0100)]
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.

3 months agotest: Split-off 36-compare-arithmetic-negative.c.
Jan (janneke) Nieuwenhuizen [Sat, 21 Nov 2020 19:38:58 +0000 (20:38 +0100)]
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.

3 months agotest: ARM: 08-assign.c: Avoid assembly for tcc.
Jan (janneke) Nieuwenhuizen [Sat, 21 Nov 2020 19:21:28 +0000 (20:21 +0100)]
test: ARM: 08-assign.c: Avoid assembly for tcc.

* lib/tests/scaffold/08-assign.c (main)[__arm__ && __TINYC__]: Avoid assembly.

3 months agotest: Split-off 50-strcmp-itoa.c
Jan (janneke) Nieuwenhuizen [Sat, 21 Nov 2020 19:18:01 +0000 (20:18 +0100)]
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.

3 months agoARM: libtcc1: Add __divsi3, __modsi3, __udivsi3, __umodsi3.
Jan (janneke) Nieuwenhuizen [Sat, 12 Dec 2020 23:07:10 +0000 (00:07 +0100)]
ARM: libtcc1: Add __divsi3, __modsi3, __udivsi3, __umodsi3.

* lib/libtcc1.c (__divsi3, __modsi3, __udivsi3, __umodsi3): New functions.

3 months agoARM: libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
Jan (janneke) Nieuwenhuizen [Sat, 12 Dec 2020 23:06:18 +0000 (00:06 +0100)]
ARM: libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.

* lib/libtcc1.c (__floatdisf, __floatdidf)[__arm__]: New stubs.

3 months agolibtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
Jan (janneke) Nieuwenhuizen [Sat, 12 Dec 2020 23:01:44 +0000 (00:01 +0100)]
libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.

* lib/libtcc1.c (__floatundidf, __fixunsdfdi, __fixunsdfsi): New stubs.

3 months agoARM: libtcc1: Add support for TinyCC.
Jan (janneke) Nieuwenhuizen [Sat, 12 Dec 2020 22:57:58 +0000 (23:57 +0100)]
ARM: libtcc1: Add support for TinyCC.

* lib/libtcc1.c: (__udivdi3, __umoddi3, __lshrdi3, __ashldi3,
__fixunsxfdi)[__arm__ && __TINYC__]: Use __mesabi functions.

3 months agolibtcc1: Remove mesabi dependencies for TinyCC.
Jan (janneke) Nieuwenhuizen [Sat, 12 Dec 2020 22:53:03 +0000 (23:53 +0100)]
libtcc1: Remove mesabi dependencies for TinyCC.

* lib/libtcc1.c (__divdi3, __moddi3, __udivdi3, __umoddi3, __lshrdi3,
__ashldi3, __ashrdi3, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi)[__TINYC__]: No stub printing.

3 months agomescc: Mes C Library: div: Avoid __raise for TinyCC.
Jan (janneke) Nieuwenhuizen [Sun, 22 Nov 2020 20:01:21 +0000 (21:01 +0100)]
mescc: Mes C Library: div: Avoid __raise for TinyCC.

* lib/mes/div.c (__raise)[__TINYC__]: New macro.

3 months agomescc: Mes C Library: Add __mesabi_umod, __mesabi_udiv.
Jan (janneke) Nieuwenhuizen [Sat, 21 Nov 2020 15:09:13 +0000 (16:09 +0100)]
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.

3 months agoARM: Implement long division.
Danny Milosavljevic [Mon, 16 Nov 2020 02:20:16 +0000 (03:20 +0100)]
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>
3 months agoARM: Special-case setjmp struct for gcc with mes libc.
Danny Milosavljevic [Sun, 15 Nov 2020 22:00:25 +0000 (23:00 +0100)]
ARM: Special-case setjmp struct for gcc with mes libc.

* include/setjmp.h (__jmp_buf): Special-case setjmp struct for gcc with mes
libc.

3 months agotests: Add 70-ternary-arithmetic-argument.c.
Jan (janneke) Nieuwenhuizen [Sun, 15 Nov 2020 20:40:53 +0000 (21:40 +0100)]
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.

3 months agoARM: Speed up __mesabi_uldiv for powers-of-two divisors.
Danny Milosavljevic [Sun, 15 Nov 2020 13:36:10 +0000 (14:36 +0100)]
ARM: Speed up __mesabi_uldiv for powers-of-two divisors.

* lib/mes/div.c (__mesabi_uldiv): Speed up division for powers-of-two
divisors.

3 months agoARM: Revert to 4 byte types only.
Jan (janneke) Nieuwenhuizen [Sat, 14 Nov 2020 14:02:06 +0000 (15:02 +0100)]
ARM: Revert to 4 byte types only.

* module/mescc/armv4/info.scm (armv4:type-alist): Use size 4 for long
longs too.

3 months agoMes C Library: stdlib/qsort.c: Fix qswap segfault.
Paul Dersey [Fri, 22 Jan 2021 15:56:36 +0000 (10:56 -0500)]
Mes C Library: stdlib/qsort.c: Fix qswap segfault.

* stdlib/qsort.c (qswap): Remove hard coded buffer size.  Allow
swapping of objects of arbitrary size.

3 months agodoc: Update to bug-mes@gnu.org.
Jan (janneke) Nieuwenhuizen [Fri, 22 Jan 2021 15:17:18 +0000 (16:17 +0100)]
doc: Update to bug-mes@gnu.org.

* doc/mes.texi (Submitting Patches): Use bug-gnu instead of
guix-patches, guix-devel.

3 months agobuild: Update guix package version too.
Jan (janneke) Nieuwenhuizen [Sun, 10 Jan 2021 11:06:17 +0000 (12:06 +0100)]
build: Update guix package version too.

* guix/git/mes.scm (mes, mes.git)[version]: Mark fields.
* build-aux/GNUmakefile.in (update-hash): Update mes version too.
(release): Remove gen-announce, guix-build dependencies.

3 months agomescc: Update -g help text.
Jan (janneke) Nieuwenhuizen [Tue, 5 Jan 2021 19:04:22 +0000 (20:04 +0100)]
mescc: Update -g help text.

* module/mescc.scm (parse-opts): Remove TODO, mention call stack.

3 months agobootstrap: Resurrect.
Jan (janneke) Nieuwenhuizen [Tue, 15 Dec 2020 17:06:40 +0000 (18:06 +0100)]
bootstrap: Resurrect.

* build-aux/bootstrap.sh.in (AM_CFLAGS): Use -L ${srcdest}lib.
Build libmescc.a and use it to link mes.

3 months agomescc: Make sure includedir, libdir are set.
Jan (janneke) Nieuwenhuizen [Tue, 15 Dec 2020 16:40:46 +0000 (17:40 +0100)]
mescc: Make sure includedir, libdir are set.

* scripts/mescc.in (prefix): New variable.

3 months agobuild: Make mescc more verbose on V=2, V=3.
Jan (janneke) Nieuwenhuizen [Tue, 15 Dec 2020 14:24:54 +0000 (15:24 +0100)]
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.

4 months agoguix: Switch to guile-3.0-latest.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 16:06:47 +0000 (18:06 +0200)]
guix: Switch to guile-3.0-latest.

* guix/git/mes.scm (nyacc)[inputs]: New field.
(mes)[inputs]: Update to guile-latest.

4 months agomescc: Mes C Library: ntoab: Use unsigned base.
Jan (janneke) Nieuwenhuizen [Sun, 13 Dec 2020 21:15:12 +0000 (22:15 +0100)]
mescc: Mes C Library: ntoab: Use unsigned base.

This fixes 60-math, 60-math-itoa, 70-printf-simple, 70-printf.

* lib/mes/ntoab.c (ntoab): Use unsigned base.
* include/mes/lib.h: Update prototype.

6 months agoconfigure: Use GUILD_OPTIMIZE=-O1 for Guile-3.
Jan (janneke) Nieuwenhuizen [Wed, 7 Oct 2020 11:55:06 +0000 (13:55 +0200)]
configure: Use GUILD_OPTIMIZE=-O1 for Guile-3.

* configure (main): Set guild_optimize to "-O1" for Guile-3.
* build-aux/config.make.in (GUILD_OPTIMIZE): New variable.
* build-aux/export.make (GUILD_OPTIMIZE): Export if set.
* build-aux/config.sh.in (GUILD_OPTIMIZE): New variable.
* build-aux/build-guile.sh: Use it.

6 months agomescc: Use signed division for x86, x86_64 when appropriate.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 17:41:14 +0000 (19:41 +0200)]
mescc: Use signed division for x86, x86_64 when appropriate.

This fixes 36-compare-arithmetic.c

* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Do not reset
signed?.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Use unique exit
value per failure.

6 months agobuild: Bump MESCC_STACK.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 13:58:01 +0000 (15:58 +0200)]
build: Bump MESCC_STACK.

This fixes running ./pre-inst-env mescc ...

* scripts/mescc.in (MES_STACK): Bump to 6000000.

6 months agoguix: nyacc: Update to 1.00.2.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 14:17:21 +0000 (16:17 +0200)]
guix: nyacc: Update to 1.00.2.

* guix/git/mes.scm (nyacc): Rename to...
(nyacc-0.99): ...this.
(nyacc): New variable.

6 months agoRevert "guix: nyacc: Update to 1.03.0."
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 14:42:59 +0000 (16:42 +0200)]
Revert "guix: nyacc: Update to 1.03.0."

This does not work yet, sorry for the noise.

This reverts commit 70b2942286ecc0b40798ac4e1fdaa9cd56a48aaf.

6 months agoguix: nyacc: Update to 1.03.0.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 11:51:42 +0000 (13:51 +0200)]
guix: nyacc: Update to 1.03.0.

* guix/git/mes.scm (nyacc): Rename to...
(nyacc-0.99): ...this.
(nyacc): New variable.
(mes): Update to guile-3.0.

6 months agobuild: Support guile-3.0.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 11:43:11 +0000 (13:43 +0200)]
build: Support guile-3.0.

* configure (main): Prefer guile-3.

6 months agobuild: Support make check TESTS=... XFAIL=... for mescc tests.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 11:11:20 +0000 (13:11 +0200)]
build: Support make check TESTS=... XFAIL=... for mescc tests.

* build-aux/config.sh.in (TESTS, XFAIL_TESTS): Export.
* build-aux/export.make (TESTS, XFAIL_TESTS): Export if set.
* build-aux/check-mescc.sh (TESTS, XFAIL_TESTS): Allow user override.

6 months agomes: Support for gcc-10.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 08:36:59 +0000 (10:36 +0200)]
mes: Support for gcc-10.

Fixes <https://lists.gnu.org/archive/html/bug-mes/2020-07/msg00000.html>.

Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.

* src/string.c (MAX_STRING): Remove duplicate definition.

6 months agomescc: Mes C Library: Support gcc-10.
Jan (janneke) Nieuwenhuizen [Tue, 6 Oct 2020 08:33:55 +0000 (10:33 +0200)]
mescc: Mes C Library: Support gcc-10.

See <https://lists.gnu.org/archive/html/bug-mes/2020-07/msg00000.html>.

Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.

* include/setjmp.h (jmp_buf): Remove.
* include/errno.h (errno): Mark extern.
* include/mes/lib-mini.h (environ, errno, __stdin, __stdout, __stderr):
Likewise.
* lib/mes/globals.c: New file; define them.
* build-aux/configure-lib.sh (libc_mini_shared_SOURCES,
libmescc_SOURCES): Add it.
* build-aux/test-c.sh: Always use -l c-mini as a minimum.

6 months agobuild: Resurrect running mescc from elsewhere.
Jan (janneke) Nieuwenhuizen [Sun, 30 Aug 2020 13:00:26 +0000 (15:00 +0200)]
build: Resurrect running mescc from elsewhere.

After setting-up a buld environment, running something like

   ~/src/mes/wip/pre-inst-env mescc -v -v ~/src/mes/wip/scaffold/main.c

works again.

TODO: Make this less complex.

 * The mescc-lib (and gcc-lib) build directories do not help;
   these were introduced to support `wip-autotools'.
 * We used to opt for short *PATH variables: "." rather than
   /gnu/store/.... or /home/janneke/src/mes/master to avoid
   filling the MES arena. XXX Has this been solved?
 * In the Guix bootstrap, we run module/mescc.scm directly
       $MES -e '(mescc)' module/mescc.scm

   ...so that's why these overrides started to appear in multiple
   places.

* build-aux/pre-inst-env.in (MES_UNINSTALLED): New variable.
* scripts/mescc.in (includedir,libdir): Use it to override these.
* module/mescc/mescc.scm (arch-find): Use it to add <lib>-messc.

6 months agomescc: Mes C Library: x86_64: Add syscall-internal.
Jan (janneke) Nieuwenhuizen [Sun, 30 Aug 2020 10:14:28 +0000 (12:14 +0200)]
mescc: Mes C Library: x86_64: Add syscall-internal.

This resurrects the x86_64 build.

* lib/linux/x86_64-mes-gcc/syscall-internal.c (__sys_call_internal),
lib/linux/x86_64-mes-mescc/syscall-internal.c: New file.

6 months agomescc: Mes C Library: x86_64: Introduce __sys_call and friends.
Jan (janneke) Nieuwenhuizen [Sun, 30 Aug 2020 10:11:51 +0000 (12:11 +0200)]
mescc: Mes C Library: x86_64: Introduce __sys_call and friends.

This prepares for x86_64 syscall-internal.

* lib/linux/x86_64-mes-gcc/syscall.c (__sys_call, __sys_call1,
__sys_call2, __sys_call3, __sys_call4): New functions, copied from ...
(_sys_call, _sys_call1, _sys_call2, _sys_call3, _sys_call4): ... these.
Use them, handle errno only.

6 months agomescc: Mes C Library: x86: Use long for syscalls.
Jan (janneke) Nieuwenhuizen [Sun, 30 Aug 2020 10:09:32 +0000 (12:09 +0200)]
mescc: Mes C Library: x86: Use long for syscalls.

The Linux signature uses long, also this allows for making
_sys_call and friends architecture-independent.

* lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal,
__sys_call2_internal): Use long.  Update callers.
* lib/linux/x86-mes-mescc/syscall.c (__sys_call, __sys_call1,
__sys_call2, __sys_call3, __sys_call4, _sys_call, _sys_call1,
_sys_call2, _sys_call3, _sys_call4): Likewise.

6 months agomescc: Mes C Library: Remove redundant prototypes.
Jan (janneke) Nieuwenhuizen [Sun, 30 Aug 2020 10:05:21 +0000 (12:05 +0200)]
mescc: Mes C Library: Remove redundant prototypes.

* lib/linux/x86-mes-gcc/syscall.c(__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4): Remove prototype.

6 months agomescc: Mes C Library: Whitespace fixes.
Jan (janneke) Nieuwenhuizen [Sun, 30 Aug 2020 09:31:29 +0000 (11:31 +0200)]
mescc: Mes C Library: Whitespace fixes.

* lib/linux/signal.c (signal): Whitespace fixes.
* lib/linux/time.c (time): Likewise.

6 months agocommand line: Support "mescc --print-libgcc-file-name".
Danny Milosavljevic [Sat, 29 Aug 2020 21:24:31 +0000 (23:24 +0200)]
command line: Support "mescc --print-libgcc-file-name".

* module/mescc.scm (parse-opts): Add "--print-libgcc-file-name".

6 months agoDistinguish between gcc and mescc; select LIBS accordingly.
Danny Milosavljevic [Sat, 29 Aug 2020 13:24:48 +0000 (15:24 +0200)]
Distinguish between gcc and mescc; select LIBS accordingly.

* build-aux/check.sh.in: Distinguish between gcc and mescc;
add MES_CHECKING_BUILTIN_LIBS.
* build-aux/test-c.sh: Use it to select LIBS accordingly.

6 months agoMake "raise" available for gcc use.
Danny Milosavljevic [Sat, 29 Aug 2020 10:52:12 +0000 (12:52 +0200)]
Make "raise" available for gcc use.

* build-aux/configure-lib.sh (libc_tcc_SOURCES): Move lib/posix/raise.c,
lib/linux/getpid.c, lib/linux/kill.c to...
(libc_SOURCES): ...here.

6 months agobuild: Use libgcc.a instead of libmescc.a for gcc.
Danny Milosavljevic [Sat, 29 Aug 2020 10:50:34 +0000 (12:50 +0200)]
build: Use libgcc.a instead of libmescc.a for gcc.

6 months agodiv: Remove libgcc-compatible API.
Danny Milosavljevic [Thu, 27 Aug 2020 08:06:48 +0000 (10:06 +0200)]
div: Remove libgcc-compatible API.

* lib/mes/div.c (__aeabi_idiv): Delete procedure.
(__aeabi_idivmod): Delete procedure.
(__aeabi_uidivmod): Delete procedure.
(__aeabi_uidiv): Delete procedure.

6 months agoRevert syscall split (of commit 55d38162be9ebd5b90b2550d0331a030c446c001);
Danny Milosavljevic [Tue, 25 Aug 2020 09:08:20 +0000 (11:08 +0200)]
Revert syscall split (of commit 55d38162be9ebd5b90b2550d0331a030c446c001);
just copy the two syscalls I need for __raise instead.

* lib/linux/arm-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/arm-mes-gcc/syscall.c: ...here.
* lib/linux/arm-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/arm-mes-mescc/syscall.c: ...here.
* lib/linux/x86-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/x86-mes-gcc/syscall.c: ...here.
* lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/x86-mes-mescc/syscall.c: ...here.

6 months agodiv: Add comment about __aeabi_idiv.
Danny Milosavljevic [Sun, 23 Aug 2020 14:15:09 +0000 (16:15 +0200)]
div: Add comment about __aeabi_idiv.

* lib/mes/div.c (__aeabi_idiv): Add comment.

6 months agodiv: Move __aeabi_idiv to __GNUC__; introduce __mesabi_idiv.
Danny Milosavljevic [Sun, 23 Aug 2020 14:08:57 +0000 (16:08 +0200)]
div: Move __aeabi_idiv to __GNUC__; introduce __mesabi_idiv.

* lib/mes/div.c (__aeabi_idiv): Move for conditional compilation.
(__mesabi_idiv): New procedure.
* module/mescc/armv4/as.scm (armv4:r0/r1): Use __mesabi_idiv.

6 months agobuild: Make raise available in libc+tcc for libgcc.
Danny Milosavljevic [Sun, 23 Aug 2020 13:55:17 +0000 (15:55 +0200)]
build: Make raise available in libc+tcc for libgcc.

* build-aux/configure-lib.sh (libc_gnu_SOURCES): Remove raise, getpid, kill.
(libc_tcc_SOURCES): Add raise, getpid, kill.

6 months agomescc: Add signed char.
Jan (janneke) Nieuwenhuizen [Sun, 23 Aug 2020 10:37:18 +0000 (12:37 +0200)]
mescc: Add signed char.

* module/mescc/armv4/info.scm (armv4:type-alist): Add signed char.
* module/mescc/i386/info.scm (i386:type-alist): Likewise.
* module/mescc/x86_64/info.scm (x86_64:type-alist): Likewise.

6 months agoARM: Add missing instruction.
Jan (janneke) Nieuwenhuizen [Sun, 23 Aug 2020 09:07:50 +0000 (11:07 +0200)]
ARM: Add missing instruction.

* lib/arm-mes/arm.M1: Add missing define.

6 months agoARM: as: Fix ldrsb_ typo.
Jan (janneke) Nieuwenhuizen [Sun, 23 Aug 2020 09:06:06 +0000 (11:06 +0200)]
ARM: as: Fix ldrsb_ typo.

(armv4:byte-r0-mem->r1-mem): : Add missing "_" to ldrsb_.