mes.git
8 months agomescc: Environment setup.
Jan Nieuwenhuizen [Fri, 6 Sep 2019 21:24:23 +0000 (23:24 +0200)]
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.

9 months agoAdd missing #include.
Danny Milosavljevic [Mon, 26 Aug 2019 23:46:57 +0000 (01:46 +0200)]
Add missing #include.

* lib/stdlib/mbstowcs.c: Add missing #include.

9 months agoFix dtoab.
Danny Milosavljevic [Mon, 26 Aug 2019 22:43:37 +0000 (00:43 +0200)]
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.

9 months agova_align: Fix compiler warning.
Danny Milosavljevic [Tue, 27 Aug 2019 03:49:22 +0000 (05:49 +0200)]
va_align: Fix compiler warning.

Follow-up to 49b0cd7d2e6952044d7436260d6ba950e40ee05f.

* include/stdarg.h: Fix compiler warning.

9 months agoAdd missing #include.
Danny Milosavljevic [Tue, 27 Aug 2019 02:32:02 +0000 (04:32 +0200)]
Add missing #include.

* lib/tests/mes/90-abtod.c (main): Add missing #include.

9 months agoFix variable argument list traversal for doubles.
Danny Milosavljevic [Tue, 27 Aug 2019 02:04:56 +0000 (04:04 +0200)]
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.

9 months agobuild: Improve --with-system-libc support.
Jan Nieuwenhuizen [Sat, 24 Aug 2019 17:05:58 +0000 (19:05 +0200)]
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.

9 months agomescc: Mes C Library: vfprintf, vsnprintf: Pad floats with space.
Jan Nieuwenhuizen [Sun, 1 Sep 2019 20:18:00 +0000 (22:18 +0200)]
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.

10 months agomescc: Mes C Library: vsscanf: Increase count for scanned float.
Jan Nieuwenhuizen [Thu, 1 Aug 2019 09:01:47 +0000 (11:01 +0200)]
mescc: Mes C Library: vsscanf: Increase count for scanned float.

* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.

10 months agomescc: Mes C Library: Support GNU Tar: Fix getpwnam, getpwuid stubs.
Jan Nieuwenhuizen [Wed, 31 Jul 2019 10:25:43 +0000 (12:25 +0200)]
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.

10 months agomescc: Mes C Library: Support GNU Tar: Add getgrgid, getgrnam, setgrent stub.
Jan Nieuwenhuizen [Wed, 24 Jul 2019 10:23:54 +0000 (12:23 +0200)]
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.

10 months agomescc: Mes C Library: Support GNU Awk: Add wchar_t.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 11:23:49 +0000 (13:23 +0200)]
mescc: Mes C Library: Support GNU Awk: Add wchar_t.

* include/sys/types.h (wchar_t): New typedef.

10 months agomescc: Mes C Library: Support GNU Awk: Add getpgid, getpgrp stubs.
Jan Nieuwenhuizen [Thu, 18 Jul 2019 10:13:18 +0000 (12:13 +0200)]
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.

10 months agomescc: Mes C Library: Support GNU Tar: Add mktime stub, fix localtime stub.
Jan Nieuwenhuizen [Mon, 15 Jul 2019 09:58:21 +0000 (11:58 +0200)]
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.

10 months agomescc: Mes C Library: Support GNU Tar: Add creat, mknod.
Jan Nieuwenhuizen [Fri, 12 Jul 2019 09:56:58 +0000 (11:56 +0200)]
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.

10 months agomescc: Mes C Library: Support GNU Tar: Add missing defines.
Jan Nieuwenhuizen [Tue, 9 Jul 2019 09:53:16 +0000 (11:53 +0200)]
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.

10 months agomescc: Mes C Library: Support GNU Bash: Add struct winsize.
Jan Nieuwenhuizen [Sat, 6 Jul 2019 09:25:02 +0000 (11:25 +0200)]
mescc: Mes C Library: Support GNU Bash: Add struct winsize.

* include/termio.h (struct winsize): New type.

11 months agomescc: Mes C Library: Support GNU Awk: Implement atof.
Jan Nieuwenhuizen [Wed, 3 Jul 2019 09:22:57 +0000 (11:22 +0200)]
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.

4 months agomescc: Mes C Library: Support GNU Awk: Add dtoab, %f in vfprintf, vsnprintf.
Jan Nieuwenhuizen [Sun, 12 Jan 2020 17:42:25 +0000 (18:42 +0100)]
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.

11 months agomescc: Mes C Library: Support GNU Awk: Add abtod, implementing strtod.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 10:51:44 +0000 (12:51 +0200)]
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.

11 months agomescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
Jan Nieuwenhuizen [Sat, 22 Jun 2019 09:48:39 +0000 (11:48 +0200)]
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.

* lib/stdio/vsscanf.c (vsscanf): Support %f.

11 months agomescc: Mes C Library: Support GNU Awk: Do not flush std files.
Jan Nieuwenhuizen [Wed, 19 Jun 2019 09:26:37 +0000 (11:26 +0200)]
mescc: Mes C Library: Support GNU Awk: Do not flush std files.

* lib/stdio/fflush.c (fflush): Do not flush std files.

11 months agomescc: Mes C Library: Support GNU Awk: Add isgraph.
Jan Nieuwenhuizen [Sun, 16 Jun 2019 09:25:37 +0000 (11:25 +0200)]
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.

11 months agomescc: Mes C Library: Support GNU Tar: Add readlink, symlink.
Jan Nieuwenhuizen [Wed, 12 Jun 2019 23:07:19 +0000 (01:07 +0200)]
mescc: Mes C Library: Support GNU Tar: Add readlink, symlink.

* 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.

11 months agomescc: Mes C Library: Support GNU Tar: Add execlp.
Jan Nieuwenhuizen [Sun, 9 Jun 2019 22:56:42 +0000 (00:56 +0200)]
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.

11 months agomescc: Mes C Library: Fix compile warnings.
Jan Nieuwenhuizen [Wed, 12 Jun 2019 13:59:06 +0000 (15:59 +0200)]
mescc: Mes C Library: Fix compile warnings.

* include/stdlib.h (abort): Add prototype.

6 months agomescc: Mes C Library: Add missing stubs.
Jan Nieuwenhuizen [Sun, 10 Nov 2019 08:00:08 +0000 (09:00 +0100)]
mescc: Mes C Library: Add missing stubs.

* build-aux/configure-lib.sh (libc_gnu_SOURCES): Add fscanf, rewind stubs.
* lib/stdio/freeopen.c: Remove.

8 months agobuild: Avoid tar --exclude=.
Jan Nieuwenhuizen [Fri, 20 Sep 2019 17:33:29 +0000 (19:33 +0200)]
build: Avoid tar --exclude=.

* build-aux/install.sh.in: Only use `tar --exclude=' if we also have .go
files compiled by Guile.

8 months agobuild: mesar: Remove bashisms.
Jan Nieuwenhuizen [Mon, 16 Sep 2019 20:46:39 +0000 (22:46 +0200)]
build: mesar: Remove bashisms.

* scripts/mesar.in: Remove bashisms.

8 months agoconfigure.sh: Cleanup argument parsing. Thanks, Timothy!
Jan Nieuwenhuizen [Tue, 1 Oct 2019 17:12:56 +0000 (19:12 +0200)]
configure.sh: Cleanup argument parsing. Thanks, Timothy!

* configure.sh: Cleanup argument parsing.

8 months agoconfigure.sh: Remove bashisms.
Jan Nieuwenhuizen [Mon, 16 Sep 2019 19:12:56 +0000 (21:12 +0200)]
configure.sh: Remove bashisms.

* configure.sh: Remove bashisms.  Fixes running with Gash 0.1.

8 months agoRevert "nyacc: 0.86.0 compatibility stub. WIP"
Jan Nieuwenhuizen [Mon, 16 Sep 2019 19:14:15 +0000 (21:14 +0200)]
Revert "nyacc: 0.86.0 compatibility stub. WIP"

This reverts commit 0183cc1c42437fda27196e27b490285a61d47f59.

While it works to run Nyacc 0.86.0, it breaks running Nyacc 0.93 and
up.  This would need more thought and work, adding a nyacc-compat
directory or so.  Seems not worth the effort right now.

8 months agonyacc: 0.86.0 compatibility stub. WIP
Jan Nieuwenhuizen [Mon, 16 Sep 2019 19:13:46 +0000 (21:13 +0200)]
nyacc: 0.86.0 compatibility stub. WIP

* mes/module/nyacc/lang/c99/util.scm: 0.86.0 compatibility stub.

8 months agobuild: Split-out build-source-lib.sh from build-lib.sh.
Jan Nieuwenhuizen [Fri, 20 Sep 2019 17:40:37 +0000 (19:40 +0200)]
build: Split-out build-source-lib.sh from build-lib.sh.

* build-aux/build-lib.sh: Remove building of source lib.
* build-aux/build-source-lib.sh: New file.
* build-aux/build.sh.in: Invoke it.
* build-aux/bootstrap.sh.in: Likewise.

6 months agobuild: Honor configure's --includedir. Thanks, Vagrant!
Jan Nieuwenhuizen [Wed, 13 Nov 2019 08:23:27 +0000 (09:23 +0100)]
build: Honor configure's --includedir. Thanks, Vagrant!

Suggested by Vagrant Cascadian

    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902174#84

* build-aux/install.sh.in: Install headers in $includedir.
* configure (includedir): Typo.
* configure.sh (includedir): Likewise.

6 months agobuild: Create ascii signature.
Jan Nieuwenhuizen [Sat, 23 Nov 2019 21:23:33 +0000 (22:23 +0100)]
build: Create ascii signature.

* build-aux/GNUmakefile.in (sign): Create ascii signature.

8 months agodoc: Post-release update.
Jan Nieuwenhuizen [Mon, 9 Sep 2019 14:48:15 +0000 (16:48 +0200)]
doc: Post-release update.

* doc/announce/ANNOUNCE-0.20: Update.
* guix/git/mes.scm (mes): Update.

8 months agoRelease 0.20. v0.20
Jan Nieuwenhuizen [Sun, 8 Sep 2019 07:31:38 +0000 (09:31 +0200)]
Release 0.20.

* configure (VERSION): Update to 0.20.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.

8 months agodoc: Release update.
Jan Nieuwenhuizen [Thu, 20 Dec 2018 06:44:18 +0000 (07:44 +0100)]
doc: Release update.

* BLURB: New file.
* AUTHORS: Update.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/images/gcc-mesboot-graph.dot: Update.
* doc/mes.texi: Update.
* simple.sh: Update.
* doc/announce/ANNOUNCE-0.20: New file.

8 months agoguix: Update mescc-tools to 0.6.1.
Jan Nieuwenhuizen [Mon, 9 Sep 2019 14:39:08 +0000 (16:39 +0200)]
guix: Update mescc-tools to 0.6.1.

* guix/git/mes.scm (mescc-tools): Update to 0.6.1.
* configure: Check for mescc-tools versions 0.6 or higher.

8 months agobuild: Create ascii signature.
Jan Nieuwenhuizen [Sun, 8 Sep 2019 09:10:45 +0000 (11:10 +0200)]
build: Create ascii signature.

* build-aux/GNUmakefile.in (sign): Create ascii signature.

8 months agoguix: Update Nyacc to 0.99.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 15:15:05 +0000 (17:15 +0200)]
guix: Update Nyacc to 0.99.

* guix/git/mes.scm (nyacc): Update to 0.99.

8 months agodoc: Add PORTING.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 19:19:42 +0000 (20:19 +0100)]
doc: Add PORTING.

* PORTING: New file.

8 months agodoc: Typos. Thanks, dddddd.
Jan Nieuwenhuizen [Mon, 22 Apr 2019 17:21:41 +0000 (19:21 +0200)]
doc: Typos. Thanks, dddddd.

* doc/announce/ANNOUNCE-0.11: Typo.
* doc/announce/ANNOUNCE-0.12: Typo.
* doc/announce/ANNOUNCE-0.13: Typo.
* doc/announce/ANNOUNCE-0.14: Typo.

8 months agomescc: Remove dead code. Thanks Mark Weaver.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 14:17:03 +0000 (16:17 +0200)]
mescc: Remove dead code. Thanks Mark Weaver.

* module/mescc/compile.scm (field-size): Remove dead function.

8 months agoguix: Update packaging.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 14:49:00 +0000 (16:49 +0200)]
guix: Update packaging.

* build-aux/manifest.scm (string-append):
* guix/git/mes.scm (nyacc, git-file?): Remove.
(mescc-tools): Bump to 0.6.0.
(%source-dir): New variable.
(mes.git): Ues it.
* guix.scm: Rename from .guix.scm.

8 months agobuild: Do not generate ChangeLog from tarball.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 15:13:39 +0000 (17:13 +0200)]
build: Do not generate ChangeLog from tarball.

* configure (main): Set .git-for-build.
* build-aux/install.sh.in (DESTDIR): Use it as canary to skip
ChangeLog rebuild.

8 months agobuild: Use mesar instead of ar.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 14:44:54 +0000 (16:44 +0200)]
build: Use mesar instead of ar.

* scripts/mesar.in: Rename from ar.in.  Update users.
* build-aux/build.sh.in (LIBS): Update.
* build-aux/check.sh.in (recheck): Likwise.
* build-aux/install.sh.in (DESTDIR): Likwise.
* configure (main): Likwise.
* configure.sh (mes_system): Likwise.
* .gitignore: Update.

8 months agogetopt: Remove old FSF address, thanks Vagrant.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 13:55:07 +0000 (15:55 +0200)]
getopt: Remove old FSF address, thanks Vagrant.

* lib/posix/getopt.c: Remove old FSF address.

8 months agoAdd missing #include.
Danny Milosavljevic [Fri, 5 Jul 2019 15:13:16 +0000 (17:13 +0200)]
Add missing #include.

* lib/tests/scaffold/55-char-array.c: Add missing #include.

8 months agoAdd missing #include.
Danny Milosavljevic [Fri, 5 Jul 2019 15:12:54 +0000 (17:12 +0200)]
Add missing #include.

* lib/tests/io/90-stat.c: Add missing #include.

8 months agoAdd missing #include.
Danny Milosavljevic [Fri, 5 Jul 2019 15:12:28 +0000 (17:12 +0200)]
Add missing #include.

* lib/posix/getcwd.c: Add missing #include.

8 months agosignal: Use SA_RESTORER on x86-64.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 16:52:09 +0000 (18:52 +0200)]
signal: Use SA_RESTORER on x86-64.

* lib/linux/signal.c (signal)[x86_64]: Avoid segfault by setting
SA_RESTORER flag.

8 months agosignal: Add comment on why we don't use the restorer.
Danny Milosavljevic [Thu, 4 Jul 2019 11:22:42 +0000 (13:22 +0200)]
signal: Add comment on why we don't use the restorer.

* lib/linux/signal.c: Add comment on why we don't use the restorer.

8 months agosignal: Remove SA_SIGINFO.
Danny Milosavljevic [Thu, 4 Jul 2019 01:43:32 +0000 (03:43 +0200)]
signal: Remove SA_SIGINFO.

* lib/linux/signal.c (signal): Remove SA_SIGINFO.

8 months agosignal: Don't use custom restorer.
Danny Milosavljevic [Thu, 4 Jul 2019 01:36:19 +0000 (03:36 +0200)]
signal: Don't use custom restorer.

* lib/linux/signal.c (signal): Don't use custom restorer.

8 months agosignal: Use SA_SIGINFO (like glibc).
Danny Milosavljevic [Thu, 4 Jul 2019 01:25:59 +0000 (03:25 +0200)]
signal: Use SA_SIGINFO (like glibc).

* lib/linux/signal.c (_restorer): Rename to...
(_restorer_for_siginfo): ...this.
(signal): Use it.  Use SA_SIGINFO.

8 months agosignal: Make sure that the signal mask is actually unsigned long.
Danny Milosavljevic [Thu, 4 Jul 2019 00:39:11 +0000 (02:39 +0200)]
signal: Make sure that the signal mask is actually unsigned long.

* lib/linux/signal.c (signal): Make sure that the signal mask is actually
unsigned long.

8 months agoDelete "__sigmask".
Danny Milosavljevic [Thu, 4 Jul 2019 00:38:06 +0000 (02:38 +0200)]
Delete "__sigmask".

Follow-up to 6d95b89759d3c598fc84194429ae8c57249daa1a

* lib/linux/signal.c (__sigmask): Delete definition.

8 months agoFix "struct sigaction" structure for rt_sigaction.
Danny Milosavljevic [Thu, 4 Jul 2019 00:21:24 +0000 (02:21 +0200)]
Fix "struct sigaction" structure for rt_sigaction.

* include/signal.h (sigset_t): Increase size.
* lib/linux/signal.c (signal): Use new sigset_t.

8 months agoInherit CFLAGS for mes.
Danny Milosavljevic [Wed, 3 Jul 2019 14:47:42 +0000 (16:47 +0200)]
Inherit CFLAGS for mes.

* build-aux/check.sh.in: Inherit CFLAGS for mes.

8 months agoFix typo.
Danny Milosavljevic [Tue, 2 Jul 2019 23:07:05 +0000 (01:07 +0200)]
Fix typo.

* build-aux/build.sh.in: Fix typo in "CFLAGS".

8 months agotests: Fail early on nonexistent file.
Danny Milosavljevic [Tue, 2 Jul 2019 11:39:41 +0000 (13:39 +0200)]
tests: Fail early on nonexistent file.

* lib/tests/io/90-stat.c (main): Fail early on nonexistent file.

8 months agoopen: Check flags, and use _open2 if applicable.
Danny Milosavljevic [Tue, 2 Jul 2019 01:36:18 +0000 (03:36 +0200)]
open: Check flags, and use _open2 if applicable.

* lib/linux/open.c (open): Check flags; use _open2.

8 months agoldiv: Make rem < 0 if a < 0.
Danny Milosavljevic [Mon, 1 Jul 2019 21:02:19 +0000 (23:02 +0200)]
ldiv: Make rem < 0 if a < 0.

* lib/mes/div.c (ldiv): Make rem < 0 if a < 0.

8 months agoldiv: Handle a == LONG_MIN.
Danny Milosavljevic [Mon, 1 Jul 2019 20:14:11 +0000 (22:14 +0200)]
ldiv: Handle a == LONG_MIN.

* lib/mes/div.c (ldiv): Handle a == LONG_MIN.

8 months agontoab: Use __mesabi_uldiv only for arm.
Jan Nieuwenhuizen [Mon, 9 Sep 2019 14:01:40 +0000 (16:01 +0200)]
ntoab: Use __mesabi_uldiv only for arm.

* lib/mes/ntoab.c (ntoab)[__MESC__ && __arm__]: Use __mesabi_uldiv.
* build-aux/check-mescc.sh (XFAIL_TESTS): 70-printf-simple.c and
70-printf.c now pass for x86_64 mescc.

11 months agoFix ntoab.
Danny Milosavljevic [Mon, 1 Jul 2019 18:04:26 +0000 (20:04 +0200)]
Fix ntoab.

Follow-up to b5b19304b59fefbed923b146ec8c8d495556fa76.

* lib/mes/ntoab.c (ntoab): Fix non-MESC case.

11 months agosignal: Define "_restorer" everywhere except on i386.
Danny Milosavljevic [Tue, 18 Jun 2019 17:26:45 +0000 (19:26 +0200)]
signal: Define "_restorer" everywhere except on i386.

* lib/linux/signal.c: Define "_restorer" everywhere except on i386.

11 months agoClarify our data type choices in "struct stat".
Danny Milosavljevic [Tue, 18 Jun 2019 15:37:10 +0000 (17:37 +0200)]
Clarify our data type choices in "struct stat".

* include/sys/stat.h: Clarify our data type choices in "struct stat".

8 months agotest: Bump timeout.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 17:55:12 +0000 (19:55 +0200)]
test: Bump timeout.

* build-aux/test-c.sh: Bump timeout to 10s, __mesabi_uldiv can be slow.

11 months agontoab: Use __mesabi_uldiv only on __MESC__.
Danny Milosavljevic [Fri, 14 Jun 2019 15:45:32 +0000 (17:45 +0200)]
ntoab: Use __mesabi_uldiv only on __MESC__.

* lib/mes/ntoab.c (ntoab): Use __mesabi_uldiv only on __MESC__.

11 months agomescc: Mes C Library: Include mes/div.c for mescc builds.
Jan Nieuwenhuizen [Fri, 14 Jun 2019 08:02:49 +0000 (10:02 +0200)]
mescc: Mes C Library: Include mes/div.c for mescc builds.

* build-aux/configure-lib.sh (libmes_SOURCES): Add mes/div.c.
* simple.sh: Likewise.

11 months agontoab: Include "assert.h".
Danny Milosavljevic [Thu, 13 Jun 2019 23:27:15 +0000 (01:27 +0200)]
ntoab: Include "assert.h".

* lib/mes/ntoab.c: #include "assert.h".

11 months agomescc: Mes C Library: Use __mesabi_uldiv.
Danny Milosavljevic [Thu, 13 Jun 2019 23:02:40 +0000 (01:02 +0200)]
mescc: Mes C Library: Use __mesabi_uldiv.

* lib/mes/ntoab.c (ntoab): Use __mesabi_uldiv.

11 months agomescc: Mes C Library: Add integer division algorithm.
Danny Milosavljevic [Thu, 13 Jun 2019 22:57:43 +0000 (00:57 +0200)]
mescc: Mes C Library: Add integer division algorithm.

* lib/mes/div.c: New file.

10 months agomescc: Mes C Library: Have write behave well with buffered reads.
Jan Nieuwenhuizen [Sun, 28 Jul 2019 11:01:37 +0000 (13:01 +0200)]
mescc: Mes C Library: Have write behave well with buffered reads.

* lib/mes/write.c: New file.
* build-aux/configure-lib.sh (libc_mini_SOURCES): Add it.
(libc_mini_shared_SOURCES): New variable.
(libc_mini_SOURCES, libmes_SOURCES): Use it.
(libmes_SOURCES): Add lib/linux/lseek.c, lib/posix/write.c.
(libc_tcc_SOURCES): Remove lib/linux/lseek.c.
* lib/posix/write.c (write): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Remove read buffer correction.
* simple.sh: Update.

10 months agomescc: Mes C Library: Add buffered read.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 20:58:49 +0000 (22:58 +0200)]
mescc: Mes C Library: Add buffered read.

* lib/mes/__buffered_read.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.  Also add memmove.c.
(libc_tcc_SOURCES): Remove memmove.c
* lib/linux/close.c (close): Clear read buffer.
* lib/linux/_open3.c (_open3): Likewise.
* lib/linux/lseek.c (lseek): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Likewise.
* lib/posix/read.c (read): Call __buffered_read.
* lib/posix/write.c (write): Add FIXME note about buffered reads.
* simple.sh: Update.

11 months agotests: Disable 70-extern.c for x86_64-gcc.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 21:13:50 +0000 (23:13 +0200)]
tests: Disable 70-extern.c for x86_64-gcc.

* build-aux/check-mescc.sh (XFAIL_TESTS)[x86_64-gcc]: Add
70-extern.c.

12 months agomescc: Put char's ASCII code into register, not char.
Danny Milosavljevic [Thu, 30 May 2019 20:11:37 +0000 (22:11 +0200)]
mescc: Put char's ASCII code into register, not char.

* module/mescc/compile.scm (expr-register): Put char's ASCII code into
register, not char.

11 months agomes: Update to Nyacc 0.93.
Jan Nieuwenhuizen [Sun, 9 Jun 2019 17:42:42 +0000 (19:42 +0200)]
mes: Update to Nyacc 0.93.

* mes/module/nyacc/lang/c99/util.mes: New file.
* mes/module/nyacc/lang/c99/parser.mes: Use it.
* module/mescc/compile.scm (ast->info): Update for Nyacc 0.93.0.
* module/mescc/preprocess.scm (need-progress):  Likewise.
(ast-strip-comment): Likewise.

10 months agomes: string->number: Support #x-prefixed hex numbers.
Jan Nieuwenhuizen [Fri, 2 Aug 2019 20:52:46 +0000 (22:52 +0200)]
mes: string->number: Support #x-prefixed hex numbers.

* mes/module/mes/scm.mes (string->number): Support "#x"-prefix.
* tests/math.test ("string->number #hex"): Test it.

10 months agomescc: Do not dump variables with extern storage.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 15:22:00 +0000 (17:22 +0200)]
mescc: Do not dump variables with extern storage.

* lib/tests/scaffold/70-extern.stdout: New file.
* lib/tests/scaffold/70-extern.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it..
* module/mescc/M1.scm (global-string?, global-extern?): New function.
(info->M1): Dump strings first.  Skip extern symbols.
* module/mescc/info.scm (<global>): Add storage field.
(make-global): Add storage parameter.  Pass it.
* module/mescc/compile.scm (make-global-entry): Likewise.
(global->info): Likewise.
(init-declr->info): Likewise.
(decl->info): Pass storage.

10 months agobuild: ./pre-inst-env MES_PREFIX fixup.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 07:19:53 +0000 (09:19 +0200)]
build: ./pre-inst-env MES_PREFIX fixup.

* build-aux/pre-inst-env.in: Set MES_PREFIX to abs_top_srcdir.
* src/mes.c (open_boot): Cater for MES_PREFIX/mes and ${srcdest}.

10 months agomescc: Be silent.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 07:51:21 +0000 (09:51 +0200)]
mescc: Be silent.

* module/mescc/M1.scm (infos->M1, info->M1): Add verbose?.  Move
debugging into verbose? > 1.
* module/mescc/compile.scm (c99-input->info, c99-ast->info): Likewise.
(mescc:trace-verbose): Rename from mescc:trace.
(mescc:trace): New function.
* module/mescc.scm (mescc:main): Likewise.
* module/mescc/mescc.scm (mescc:preprocess, c->ast mescc:compile,
c->info, E->info): Likewise.
* module/mescc/preprocess.scm (c99-input->full-ast, c99-input->ast):
Likewise.

10 months agomescc: Add <include>/<kernel>/<arch> to include path.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 20:44:04 +0000 (22:44 +0200)]
mescc: Add <include>/<kernel>/<arch> to include path.

* module/mescc/preprocess.scm (c99-input->full-ast): Add
<include>/<kernel>/<arch> to include path.
* module/mescc/compile.scm (c99-input->info): Pass arch.
* module/mescc/mescc.scm (mescc:preprocess): Likewise.
(c->info): Likewise.
(c->ast): Likewise.

10 months agomescc: Add 70-function-destruct-declare.c test.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 17:09:12 +0000 (19:09 +0200)]
mescc: Add 70-function-destruct-declare.c test.

* module/mescc/compile.scm (init-declr->info): Do not attempt to
re-calculate function type.
(ftn-declr:get-type): Remove.
* lib/tests/scaffold/70-function-destruct-declare.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.

10 months agomescc: Resurrect --write.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:57:45 +0000 (18:57 +0200)]
mescc: Resurrect --write.

* module/mescc/mescc.scm (mescc:preprocess): Pass pretty-print/write
to c->ast.

10 months agobuild: Distribute crt*.c, libc+gnu.c for tcc, gcc bootstrap build.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:36:07 +0000 (18:36 +0200)]
build: Distribute crt*.c, libc+gnu.c for tcc, gcc bootstrap build.

* build-aux/build-lib.sh (libc_gnu_SOURCES): Build libc+gnu.c.  Copy
crt*.c, libc+gnu.c for distribution.

10 months agobuild: Uniquify config macros.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:20:32 +0000 (18:20 +0200)]
build: Uniquify config macros.

* configure (main): Rename VERSION to MES_VERSION, pkgdatadir to
MES_PKGDATADIR.  Update users.
* configure.sh (mes_system): Likewise.
* src/mes.c (mes_symbols): Update.
(open_boot): Update.
* scaffold/cons-mes.c (main): Update.
* simple.sh: Update.

10 months agobuild: Resurrect --with-cheating.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 16:56:58 +0000 (18:56 +0200)]
build: Resurrect --with-cheating.

* build-aux/config.sh.in (SCHEME): New substitute.
* build-aux/config.make.in: Likewise.
* configure: Substitute them.

10 months agomescc: Support tcc: libtcc1 build fixes.
Jan Nieuwenhuizen [Tue, 23 Jul 2019 18:38:29 +0000 (20:38 +0200)]
mescc: Support tcc: libtcc1 build fixes.

* lib/libtcc1.c: Support building without long long, float support.

12 months agomescc: Mes C Library: Avoid type/size_t conflicts.
Jan Nieuwenhuizen [Sat, 1 Jun 2019 06:44:18 +0000 (08:44 +0200)]
mescc: Mes C Library: Avoid type/size_t conflicts.

* include/alloca.h: Remove typedefs, include sys/types.h.
* include/stdint.h: Likewise.
* include/string.h: Likewise.

10 months agomescc: Support tcc: Add intptr_t, uintptr_t.
Jan Nieuwenhuizen [Wed, 17 Jul 2019 20:54:13 +0000 (22:54 +0200)]
mescc: Support tcc: Add intptr_t, uintptr_t.

* include/sys/types.h (intptr_t, uintptr_t): Add typedef.

10 months agomescc: Add 70-struct-post.c test with fix.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 20:40:42 +0000 (22:40 +0200)]
mescc: Add 70-struct-post.c test with fix.

* lib/tests/scaffold/70-struct-post.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.
* module/mescc/compile.scm (expr->register): Use type size for rank
0 (WAS: 1).

10 months agomescc: Add 70-struct-short-enum-init.c test with fix.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 14:48:26 +0000 (16:48 +0200)]
mescc: Add 70-struct-short-enum-init.c test with fix.

* module/mescc/compile.scm (init->data): Respect type of size.
* lib/tests/scaffold/70-struct-short-enum-init.c: New file.
* lib/tests/scaffold/70-struct-short-enum-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.

10 months agomescc: Add 70-array-in-struct-init.c test with fix.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 15:14:55 +0000 (17:14 +0200)]
mescc: Add 70-array-in-struct-init.c test with fix.

* lib/tests/scaffold/70-array-in-struct-init.c: New file.
* lib/tests/scaffold/70-array-in-struct-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.
* module/mescc/compile.scm (array-init-element->data): Recurse for
elements instead of using init->data.  Support array fields.

10 months agomes: Remove broken copy of simple-format.
Jan Nieuwenhuizen [Fri, 19 Jul 2019 13:36:36 +0000 (15:36 +0200)]
mes: Remove broken copy of simple-format.

* mes/module/mes/simple-format.mes: New file.
* mes/module/mes/guile.mes: Use it.
(with-output-to-string, simple-format): Remove broken copies.
* mes/module/mes/display.mes (with-output-to-string, simple-format,
format): Remove.

10 months agoFix remainder handling.
Danny Milosavljevic [Fri, 5 Jul 2019 13:52:04 +0000 (15:52 +0200)]
Fix remainder handling.

* mes/module/mes/scm.mes (number->string): Fix remainder handling.
* build-aux/check-mescc.sh (XFAIL_TESTS): Remove
lib/tests/scaffold/60-math.c.

10 months agoRevert "test: Disable 60-math.c test."
Jan Nieuwenhuizen [Tue, 9 Jul 2019 20:01:24 +0000 (22:01 +0200)]
Revert "test: Disable 60-math.c test."

This reverts commit bbe6576a66a520d429bb3ec84120ffcce88480bf.