Commit Graph

264 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 421687c624
kaem.run: New file.
* kaem.run: New file.
2019-10-28 17:02:17 +01:00
Jan Nieuwenhuizen 78c4757ec3
mescc: Mes C Library: Add M2-Planet support. WIP
* lib/m2/abtol.c: New file.
* lib/m2/access.c: New file.
* lib/m2/atoi.c: New file.
* lib/m2/chmod.c: New file.
* lib/m2/clock_gettime.c: New file.
* lib/m2/dup.c: New file.
* lib/m2/dup2.c: New file.
* lib/m2/eputs.c: New file.
* lib/m2/execv.c: New file.
* lib/m2/execve.c: New file.
* lib/m2/exit.c: New file.
* lib/m2/fdputc.c: New file.
* lib/m2/fork.c: New file.
* lib/m2/getcwd.c: New file.
* lib/m2/getenv.c: New file.
* lib/m2/isatty.c: New file.
* lib/m2/memchr.c: New file.
* lib/m2/memcmp.c: New file.
* lib/m2/memcpy.c: New file.
* lib/m2/memset.c: New file.
* lib/m2/mes_open.c: New file.
* lib/m2/ntoab.c: New file.
* lib/m2/open.c: New file.
* lib/m2/read.c: New file.
* lib/m2/setenv.c: New file.
* lib/m2/strcmp.c: New file.
* lib/m2/strcpy.c: New file.
* lib/m2/strlen.c: New file.
* lib/m2/strncmp.c: New file.
* lib/m2/time.c: New file.
* lib/m2/unlink.c: New file.
* lib/m2/waitpid.c: New file.
* lib/m2/write.c: New file.
2019-10-27 00:12:45 +02:00
Jan Nieuwenhuizen ce6e927af5
kaem: scaffold/read.kaem.
* .gitignore: Update.
* include/linux/x86/syscall.h: Update for M2-Planet.
* scaffold/read.c: Update for M2-Planet.
* lib/stdlib/malloc.c (malloc): Remove cast for M2-Planet.
* lib/string/memset.c (memset): Update for M2-Planet.
* lib/linux/brk.c (brk): Remove cast for M2-Planet.
2019-10-26 23:24:59 +02:00
Jan Nieuwenhuizen 27bd10f055
kaem: scaffold/argv.kaem.
* scaffold/argv.c (strcmp): Remove.
(main): Update.
* scaffold/argv.kaem: New file.
2019-10-26 22:56:40 +02:00
Jan Nieuwenhuizen abfb402c47
kaem: scaffold/main.kaem. WIp
* .gitignore: Update.
* lib/linux/x86-mes-m2/crt1.M1: New file.
* lib/linux/x86-mes-m2/crt1.c: New file.
* lib/m2/x86/x86_defs.M1: New file.  Import from stage0.
* scaffold/main.c: Update for M2-Planet.
2019-10-26 21:49:23 +02:00
Jan Nieuwenhuizen 6a400a4d8d
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:02 +02:00
Jan Nieuwenhuizen 65e545d589
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:02 +02:00
Jan Nieuwenhuizen b03046b370
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen e88f10b067
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen b6cd0bd34f
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen cb1a018f29
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen dd54e779b6
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 938c4262f6
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 33f640e005
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 6d55e94b6a
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen d62f5ac1b4
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 3d0411ac25
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 85627f123c
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 70028b1928
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen b7ba80a25b
mescc: Mes C Library: Prepare for M2-Planet: __assert_fail.
Rewrite C-constructs not supported by M2-Planet, such as

    foo ? bar : baz;       -> if (foo) bar; else baz;
    static char foo[1024]  -> __func_buf = malloc (1024); ... char *foo = __func_buf;
    *foo                   -> foo[0]
    foo++                  -> foo = foo + 1   TODO: pointer arithmetic
    foo += 1;              -> foo = foo + 1
    for (int foo = ;       -> int foo; for (foo=
    if (foo)               -> if (foo != 0)
    if (!foo)              -> if (foo == 0)
    ;                      -> 0;

* lib/mes/__assert_fail.c: Rewrite C-constructs not supported by
M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen ad173240c0
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2019-10-26 19:41:00 +02:00
Danny Milosavljevic 738264c3bb
Add missing #include.
* lib/stdlib/mbstowcs.c: Add missing #include.
2019-10-21 21:43:04 +02:00
Danny Milosavljevic 30d362321e
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.
2019-10-21 21:43:03 +02:00
Danny Milosavljevic fce055e9da
Add missing #include.
* lib/tests/mes/90-abtod.c (main): Add missing #include.
2019-10-05 17:38:20 +02:00
Danny Milosavljevic a840c5398f
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.
2019-10-05 17:38:19 +02:00
Jan Nieuwenhuizen 52b9dd2b0e
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.
2019-10-05 17:38:15 +02:00
Jan Nieuwenhuizen 7181d3dd9a
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.
2019-10-05 17:37:28 +02:00
Jan Nieuwenhuizen f4d6851c63
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-10-05 17:37:05 +02:00
Jan Nieuwenhuizen 36e9f532be
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.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen eff0077d63
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.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen a0efce35a0
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen 4cbdc75bb4
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.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen 1f21136539
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.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen 18adda19fd
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.
2019-10-05 17:37:04 +02:00
Jan Nieuwenhuizen 8b2e2cebde
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.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen 92e6a8e323
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.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen 5d40ba08b6
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.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen e7e69fff7b
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
* lib/stdio/vsscanf.c (vsscanf): Support %f.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen 3f74342f36
mescc: Mes C Library: Support GNU Awk: Do not flush std files.
* lib/stdio/fflush.c (fflush): Do not flush std files.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen 5dfe2459c8
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.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen 396b666b38
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.
2019-10-05 17:37:03 +02:00
Jan Nieuwenhuizen 30e931920d
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.
2019-10-05 17:37:02 +02:00
Jan Nieuwenhuizen aae5f0f578
mescc: Mes C Library: Fix compile warnings.
* include/stdlib.h (abort): Add prototype.
2019-10-05 17:37:02 +02:00
Jan Nieuwenhuizen 3bed314d94
getopt: Remove old FSF address, thanks Vagrant.
* lib/posix/getopt.c: Remove old FSF address.
2019-09-09 16:04:15 +02:00
Danny Milosavljevic 15a39f0efe
Add missing #include.
* lib/tests/scaffold/55-char-array.c: Add missing #include.
2019-09-09 16:04:15 +02:00
Danny Milosavljevic e2dfaef89e
Add missing #include.
* lib/tests/io/90-stat.c: Add missing #include.
2019-09-09 16:04:15 +02:00
Danny Milosavljevic 5f82a697b3
Add missing #include.
* lib/posix/getcwd.c: Add missing #include.
2019-09-09 16:04:15 +02:00
Jan Nieuwenhuizen 2db5ec2f55
signal: Use SA_RESTORER on x86-64.
* lib/linux/signal.c (signal)[x86_64]: Avoid segfault by setting
SA_RESTORER flag.
2019-09-09 16:04:15 +02:00
Danny Milosavljevic 23d857c834
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.
2019-09-09 16:04:15 +02:00
Danny Milosavljevic 4a183fa1cf
signal: Remove SA_SIGINFO.
* lib/linux/signal.c (signal): Remove SA_SIGINFO.
2019-09-09 16:04:15 +02:00