Commit Graph

274 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 138d4b458d
M2: setenv 2019-10-26 13:45:56 +02:00
Jan Nieuwenhuizen 920a103344
M2: ntoab 2019-10-26 13:45:56 +02:00
Jan Nieuwenhuizen 529156c393
M2: malloc 2019-10-26 13:45:56 +02:00
Jan Nieuwenhuizen c4c92c64cb
M2: getcwd 2019-10-26 13:45:56 +02:00
Jan Nieuwenhuizen c2ba415b1f
M2: memset 2019-10-26 13:45:56 +02:00
Jan Nieuwenhuizen 739c4eb81e
m2: memcpy! 2019-10-25 11:12:14 +02:00
Jan Nieuwenhuizen 09dad49b65
m2 lib 2019-10-24 10:45:38 +02:00
Jan Nieuwenhuizen 44cd2f132f
m2 lib c 2019-10-24 09:09:08 +02:00
Jan Nieuwenhuizen fcb694be6b
m2: getenv 2019-10-24 07:19:57 +02:00
Jan Nieuwenhuizen f19d7b78d6
kaem.run: New file.
* kaem.run: New file.
* lib/m2/missing.hex2: New file.
2019-10-24 00:12:53 +02:00
Jan Nieuwenhuizen 5582a673ce
kaem: scaffold/read.kaem. 2019-10-23 23:51:51 +02:00
Jan Nieuwenhuizen fe2d7c7b4f
kaem: scaffold/argv.kaem 2019-10-23 23:51:51 +02:00
Jan Nieuwenhuizen ac297d36db
kaem: scaffold/main.kaem. 2019-10-23 23:51:50 +02:00
Jan Nieuwenhuizen 8129434bfd
mescc: Mes C Library: Add M2-Planet support. WIP
* lib/m2/abtolc.: New file.
* lib/m2/accessc.: New file.
* lib/m2/atoic.: New file.
* lib/m2/chmodc.: New file.
* lib/m2/clock_gettimec.: New file.
* lib/m2/dupc.: New file.
* lib/m2/dup2c.: New file.
* lib/m2/eputsc.: New file.
* lib/m2/execvc.: New file.
* lib/m2/execvec.: New file.
* lib/m2/exitc.: New file.
* lib/m2/fdputcc.: New file.
* lib/m2/forkc.: New file.
* lib/m2/getcwdc.: New file.
* lib/m2/getenvc.: New file.
* lib/m2/isattyc.: New file.
* lib/m2/memchrc.: New file.
* lib/m2/memcmpc.: New file.
* lib/m2/memcpyc.: New file.
* lib/m2/mes_openc.: New file.
* lib/m2/ntoabc.: New file.
* lib/m2/openc.: New file.
* lib/m2/readc.: New file.
* lib/m2/setenvc.: New file.
* lib/m2/strcmpc.: New file.
* lib/m2/strcpyc.: New file.
* lib/m2/strlenc.: New file.
* lib/m2/strncmpc.: New file.
* lib/m2/timec.: New file.
* lib/m2/unlinkc.: New file.
* lib/m2/waitpidc.: New file.
* lib/m2/writec.: New file.
2019-10-23 18:00:00 +02:00
Jan Nieuwenhuizen 998a3fdc15
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:37 +02:00
Jan Nieuwenhuizen c01fb5aa4a
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:37 +02:00
Jan Nieuwenhuizen ade7d6aa42
WIP FIXUP: ntoab 2019-10-23 17:59:37 +02:00
Jan Nieuwenhuizen 2dd3ae31ce
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:37 +02:00
Jan Nieuwenhuizen 58e06f1faa
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:37 +02:00
Jan Nieuwenhuizen 62ddf437b1
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:37 +02:00
Jan Nieuwenhuizen 74dbd3c8d0
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen 5994b93df9
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen 5bac3f4701
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen 214fd948da
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen 5ab4840e03
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen f96a548103
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen 3eb5a70ec8
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:36 +02:00
Jan Nieuwenhuizen 38833c9cbf
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:35 +02:00
Jan Nieuwenhuizen 262ec7f603
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-23 17:59:35 +02:00
Jan Nieuwenhuizen 6e7313263f
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-23 17:59:35 +02:00
Jan Nieuwenhuizen f4d38292cf
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2019-10-23 17:59:35 +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