mes.git
3 months agoAdd missing #include. wip-0.22
Danny Milosavljevic [Thu, 14 Mar 2019 23:41:34 +0000 (00:41 +0100)]
Add missing #include.

* lib/stdio/vfscanf.c: Add missing #include.

3 months agobuild: Improve --with-system-libc support.
Jan Nieuwenhuizen [Tue, 12 Mar 2019 17:05:58 +0000 (18:05 +0100)]
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.

3 months agomescc: Mes C Library: Support gcc-4.6.4: vsscanf: Support *, [, s.
Jan Nieuwenhuizen [Sat, 9 Feb 2019 20:42:17 +0000 (21:42 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: vsscanf: Support  *, [, s.

* lib/stdio/vsscanf.c (vsscanf): Support  *, [, s.
* lib/stdio/vfscanf.c (vfscanf): Likewise.
* lib/tests/stdio/90-sscanf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
* lib/x86-mes/x86.M1 (mov____%al,0x32(%ebp): New macro.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Allow larger qsort entries.
Jan Nieuwenhuizen [Sat, 9 Feb 2019 18:47:21 +0000 (19:47 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Allow larger qsort entries.

* lib/stdlib/qsort.c (qswap): Increase buffer to 128 bytes (gmp needs
36) and add assert.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Avoid type/size_t conflicts.
Jan Nieuwenhuizen [Sat, 9 Feb 2019 06:44:18 +0000 (07:44 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Avoid type/size_t conflicts.

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

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add strtok.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 13:28:13 +0000 (14:28 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add strtok.

* include/string.h (strtok): Declare.
* lib/string/strtok.c (strtok): New file.
* lib/libc+gnu.c: Include it.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add mmap, munmap.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 15:51:37 +0000 (16:51 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add mmap, munmap.

* include/linux/x86/syscall.h (SYS_mmap, SYS_munmap): New macro.
* include/linux/x86_64/syscall.h (SYS_mmap, SYS_munmap): New macro.
* include/sys/mman.h (MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS,
MAP_POPULATE, MAP_ANON, MAP_FAILED): New macro.
(mmap, munmap): Declare.
* lib/linux/x86-mes-gcc/mes.c (_sys_call6): New function.
* lib/linux/x86-mes/mes.c (__sys_call6): New function.
(_sys_call6): New function.
* lib/linux/x86_64-mes-gcc/mes.c (_sys_call6): New function.
* lib/linux/x86_64-mes/mes.c (__sys_call): Cater for 6 syscall parameters.
(_sys_call6): New function.
* lib/x86-mes/x86.M1 (pop____%ebp): New macro.
* lib/x86_64-mes/x86_64.M1 (mov____0x8(%rbp),%r9): New macro.
* lib/linux/mmap.c: New file.
* lib/linux/munmap.c: New file.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Add them.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add labs.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 12:59:02 +0000 (13:59 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add labs.

* lib/math/labs.c: New file.
* lib/libc+gnu.c: Include it.
* include/math.h (labs): Declare.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Implement rewind.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 12:56:25 +0000 (13:56 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Implement rewind.

* lib/stdio/rewind.c: Move from ../stub.  Implement.
* include/stdio.h (rewind): Declare.
* lib/libc+gnu.c: Update include.
* lib/libg.c: Update include.
* lib/stub/rewind.c: Remove.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add asctime stub.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 12:51:09 +0000 (13:51 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add asctime stub.

* lib/stub/asctime.c: New file.
* lib/libc+gnu.c: Include it.
* include/time.h (asctime): Declare.

3 months agomescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: #-type.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 12:45:44 +0000 (13:45 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: #-type.

* lib/stdio/vfprintf.c (vfprintf): Support #-type prefix.  Show whole
format upon error.
* lib/stdio/vsnprintf.c (vsnprintf): Likewise.
* lib/stdio/vfscanf.c (vfscanf): Show whole template upon error.
* lib/stdio/vsscanf.c (vsscanf): Likewise.

3 months agomescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: pad with space.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 12:44:31 +0000 (13:44 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: pad with space.

* lib/stdio/vfprintf.c (vfprintf): pad with space.
* lib/stdio/vsnprintf.c (vsnprintf): pad with space.

3 months agomescc: Mes C Library: Support gcc-4.6.4: atexit: return 0.
Jan Nieuwenhuizen [Fri, 8 Feb 2019 12:29:30 +0000 (13:29 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: atexit: return 0.

* lib/stdlib/atexit.c (atexit): return 0.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add SSIZE_MAX macro.
Jan Nieuwenhuizen [Thu, 7 Feb 2019 20:18:06 +0000 (21:18 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add SSIZE_MAX macro.

* include/stdint.h (SSIZE_MAX): New macro.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add math stubs.
Jan Nieuwenhuizen [Fri, 1 Feb 2019 13:11:38 +0000 (14:11 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add math stubs.

* lib/math/ceil.c: New file.
* lib/math/floor.c: New file.
* lib/stub/atan2.c: New file.
* lib/stub/cos.c: New file.
* lib/stub/exp.c: New file.
* lib/stub/log.c: New file.
* lib/stub/modf.c: New file.
* lib/stub/pow.c: New file.
* lib/stub/sin.c: New file.
* lib/stub/sqrt.c: New file.
* lib/libc+gnu.c: Include them.
* include/math.h (atan2, ceil, cos, exp, fabs, floor, log, modf, pow,
sin, sqrt): Declare.
* lib/math/fabs.c: Update.
* lib/stub/ldexp.c: Update.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add fscanf, vfscanf.
Jan Nieuwenhuizen [Fri, 1 Feb 2019 17:04:50 +0000 (18:04 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add fscanf, vfscanf.

* lib/stdio/vfscanf.c: New file.
* lib/stdio/fscanf.c: New file.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Add them.
* include/stdio.h (fscanf): Declare.
* include/stdarg.h (vfscanf): Declare.
* lib/libc+gnu.c: Include them.
* lib/libg.c: Likewise.
* lib/stub/fscanf.c: Remove.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add float macros.
Jan Nieuwenhuizen [Fri, 1 Feb 2019 08:29:49 +0000 (09:29 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add float macros.

* include/float.h (DBL_EPSILON, DBL_MANT_DIG, DBL_MAX, DBL_MIN,
FLT_RADIX, LDBL_EPSILON, LDBL_MANT_DIG, LDBL_MAX, LDBL_MIN): New
macro.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Add stdint [U]SHRT macros.
Jan Nieuwenhuizen [Fri, 1 Feb 2019 08:29:39 +0000 (09:29 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Add stdint [U]SHRT macros.

* include/stdint.h (SHRT_MAX, SHRT_MIN, USHRT_MAX, USHRT_MIN): New
macro.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Fix ctime stub.
Jan Nieuwenhuizen [Fri, 1 Feb 2019 16:37:55 +0000 (17:37 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Fix ctime stub.

* lib/stub/ctime.c (ctime): Fix stub to avoid segfault upon use.

3 months agomescc: Mes C Library: Support gcc-4.6.4: Fix uintptr_t, add [u]intmax_t.
Jan Nieuwenhuizen [Wed, 16 Jan 2019 12:21:36 +0000 (13:21 +0100)]
mescc: Mes C Library: Support gcc-4.6.4: Fix uintptr_t, add [u]intmax_t.

* include/stdint.h: Fix uintptr_t, add [u]intmax_t.

3 months agodoc update
Jan Nieuwenhuizen [Sat, 5 Oct 2019 15:36:15 +0000 (17:36 +0200)]
doc update

3 months agobuild: bootstrap fixes.
Jan Nieuwenhuizen [Fri, 8 Nov 2019 18:18:31 +0000 (19:18 +0100)]
build: bootstrap fixes.

* build-aux/config.sh.in (bootstrap): Set up for substitution.
* configure.sh (bootstrap): Substitute.
* build-aux/install.sh.in (_v): Robustify check for V.
(__exclude_go, __exclude_scm): Initialize.

3 months agomescc: Environment setup.
Jan Nieuwenhuizen [Mon, 16 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.

3 months agocheck: Remove duplicate test.
Jan Nieuwenhuizen [Sun, 27 Oct 2019 20:17:50 +0000 (21:17 +0100)]
check: Remove duplicate test.

* build-aux/check-boot.sh (TESTS): Remove duplicate test.

3 months agomes: Fix -c, --command.
Jan Nieuwenhuizen [Sun, 3 Nov 2019 11:22:12 +0000 (12:22 +0100)]
mes: Fix -c, --command.

* mes/module/mes/boot-0.scm: Prepend 'begin to expr list.

3 months agomescc: Mes C Libray: Fix off_t.
Jan Nieuwenhuizen [Sat, 5 Oct 2019 15:35:33 +0000 (17:35 +0200)]
mescc: Mes C Libray: Fix off_t.

* include/sys/types.h (off_t): Drop unsigned.

3 months agoAdd missing #include.
Danny Milosavljevic [Thu, 14 Mar 2019 23:46:57 +0000 (00:46 +0100)]
Add missing #include.

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

3 months agoFix dtoab.
Danny Milosavljevic [Thu, 14 Mar 2019 22:43:37 +0000 (23:43 +0100)]
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.

3 months agova_align: Fix compiler warning.
Danny Milosavljevic [Fri, 15 Mar 2019 03:49:22 +0000 (04:49 +0100)]
va_align: Fix compiler warning.

Follow-up to 49b0cd7d2e6952044d7436260d6ba950e40ee05f.

* include/stdarg.h: Fix compiler warning.

3 months agoAdd missing #include.
Danny Milosavljevic [Fri, 15 Mar 2019 02:32:02 +0000 (03:32 +0100)]
Add missing #include.

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

3 months agoFix variable argument list traversal for doubles.
Danny Milosavljevic [Fri, 15 Mar 2019 02:04:56 +0000 (03:04 +0100)]
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.

3 months agobuild: Improve --with-system-libc support.
Jan Nieuwenhuizen [Tue, 12 Mar 2019 17:05:58 +0000 (18:05 +0100)]
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.

3 months agomescc: Mes C Library: vfprintf, vsnprintf: Pad floats with space.
Jan Nieuwenhuizen [Wed, 6 Feb 2019 20:18:00 +0000 (21:18 +0100)]
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.

3 months agomescc: Mes C Library: vsscanf: Increase count for scanned float.
Jan Nieuwenhuizen [Sun, 6 Jan 2019 09:01:47 +0000 (10:01 +0100)]
mescc: Mes C Library: vsscanf: Increase count for scanned float.

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

3 months agomescc: Mes C Library: Support GNU Tar: Fix getpwnam, getpwuid stubs.
Jan Nieuwenhuizen [Sat, 5 Jan 2019 10:25:43 +0000 (11:25 +0100)]
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.

3 months agomescc: Mes C Library: Support GNU Tar: Add getgrgid, getgrnam, setgrent stub.
Jan Nieuwenhuizen [Sat, 5 Jan 2019 10:23:54 +0000 (11:23 +0100)]
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.

3 months agomescc: Mes C Library: Support GNU Awk: Add wchar_t.
Jan Nieuwenhuizen [Sat, 5 Jan 2019 11:23:49 +0000 (12:23 +0100)]
mescc: Mes C Library: Support GNU Awk: Add wchar_t.

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

3 months agomescc: Mes C Library: Support GNU Awk: Add getpgid, getpgrp stubs.
Jan Nieuwenhuizen [Sat, 5 Jan 2019 10:13:18 +0000 (11:13 +0100)]
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.

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

3 months agomescc: Mes C Library: Support GNU Tar: Add creat, mknod.
Jan Nieuwenhuizen [Sat, 5 Jan 2019 09:56:58 +0000 (10:56 +0100)]
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.

3 months agomescc: Mes C Library: Support GNU Tar: Add missing defines.
Jan Nieuwenhuizen [Sat, 5 Jan 2019 09:53:16 +0000 (10:53 +0100)]
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.

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

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

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

3 months agomescc: Mes C Library: Support GNU Awk: Add dtoab, %f in vfprintf, vsnprintf.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 17:42:25 +0000 (19:42 +0200)]
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.

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

3 months agomescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
Jan Nieuwenhuizen [Thu, 3 Jan 2019 09:48:39 +0000 (10:48 +0100)]
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.

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

3 months agomescc: Mes C Library: Support GNU Awk: Do not flush std files.
Jan Nieuwenhuizen [Thu, 3 Jan 2019 09:26:37 +0000 (10:26 +0100)]
mescc: Mes C Library: Support GNU Awk: Do not flush std files.

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

3 months agomescc: Mes C Library: Support GNU Awk: Add isgraph.
Jan Nieuwenhuizen [Thu, 3 Jan 2019 09:25:37 +0000 (10:25 +0100)]
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.

3 months agomescc: Mes C Library: Support GNU Tar: Add readlink, readlink.
Jan Nieuwenhuizen [Wed, 2 Jan 2019 23:07:19 +0000 (00:07 +0100)]
mescc: Mes C Library: Support GNU Tar: Add readlink, readlink.

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

3 months agomescc: Mes C Library: Support GNU Tar: Add execlp.
Jan Nieuwenhuizen [Wed, 2 Jan 2019 22:56:42 +0000 (23:56 +0100)]
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.

3 months agomescc: Mes C Library: Fix compile warnings.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 13:59:06 +0000 (15:59 +0200)]
mescc: Mes C Library: Fix compile warnings.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* PORTING: New file.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5 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".

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

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

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

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

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

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

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

8 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".

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

8 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__.

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

8 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".

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

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

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