Commit Graph

370 Commits

Author SHA1 Message Date
Jan (janneke) Nieuwenhuizen ec834cdfd7
mescc: Mes C Library: Prepare for M2-Planet: gettimeofday.
* lib/linux/gettimeofday.c (gettimeofday): Prepare for M2-Planet.
2021-01-01 16:17:18 +01:00
Jan (janneke) Nieuwenhuizen 8be29f2c08
mescc: Mes C Library: Prepare for M2-Planet: dup2.
* lib/linux/dup2.c (dup2): Prepare for M2-Planet.
2021-01-01 16:17:18 +01:00
Jan (janneke) Nieuwenhuizen 0e2816ff41
mescc: Mes C Library: Prepare for M2-Planet: dup.
* lib/linux/dup.c (dup): Prepare for M2-Planet.
2021-01-01 16:17:18 +01:00
Jan (janneke) Nieuwenhuizen de163436c1
mescc: Mes C Library: Prepare for M2-Planet: clock_gettime.
* lib/linux/clock_gettime.c (clock_gettime): Prepare for M2-Planet.
2021-01-01 16:17:18 +01:00
Jan (janneke) Nieuwenhuizen be593ea70c
mescc: Mes C Library: Prepare for M2-Planet: chmod.
* lib/linux/chmod.c (chmod): Prepare for M2-Planet.
2021-01-01 16:17:18 +01:00
Jan (janneke) Nieuwenhuizen a96cd77dda
mescc: Mes C Library: Prepare for M2-Planet: access.
* lib/linux/access.c (access): Prepare for M2-Planet.
2021-01-01 16:17:18 +01:00
Jan (janneke) Nieuwenhuizen 0d5bca7034
mescc: Mes C Library: Prepare for M2-Planet: _getcwd.
* lib/linux/_getcwd.c (_getcwd): Prepare for M2-Planet.
2021-01-01 16:17:17 +01:00
Jan (janneke) Nieuwenhuizen 4955d99dd0
mescc: Mes C Library: Bugfix __ungetc_clear.
* lib/m2/mes_open.c (mes_open): Remove __ungetc_init ();
* lib/m2/open.c (open): Likewise.
2021-01-01 16:17:17 +01:00
Jan (janneke) Nieuwenhuizen da257f6bdb
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.
2021-01-01 16:17:17 +01:00
Jan (janneke) Nieuwenhuizen fc36c6588f
kaem: scaffold/argv.kaem.
* scaffold/argv.c (strcmp): Remove.
(main): Update.
* scaffold/argv.kaem: New file.
lib/x86-mes/x86.M1 (mov____%edi,%ebp, mov____%esp,%edi): New macro.
2021-01-01 16:17:17 +01:00
Jan (janneke) Nieuwenhuizen b12fc77f63
kaem: scaffold/main.kaem.
* .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.
* lib/m2/x86/ELF-i386-debug.hex2: New file.  Import from M2-Planet.
* scaffold/main.c: Update for M2-Planet.
* scaffold/main.kaem: New file.
2021-01-01 16:16:02 +01:00
Jan (janneke) Nieuwenhuizen a1a1fe62a8
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:26 +01:00
Jan (janneke) Nieuwenhuizen beef3cf647
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:26 +01:00
Jan (janneke) Nieuwenhuizen 7cc4b6ffe8
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:26 +01:00
Jan (janneke) Nieuwenhuizen 97919c858f
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:26 +01:00
Jan (janneke) Nieuwenhuizen a84288f476
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:26 +01:00
Jan (janneke) Nieuwenhuizen 47d1d48a9a
mescc: Mes C Library: Bugfix __ungetc_clear.
* lib/linux/_open3.c (_open3): Remove __ungetc_init ();
* lib/mes/mes_open.c (mes_open): Likewise.
* lib/mes/fdungetc.c (fdungetc): Likewise.
* lib/mes/fdgetc.c (__ungetc_p, __ungetc_clear, __ungetc_set): Call
__ungetc_init if buffer is uninitialized.
2020-12-31 14:00:26 +01:00
Jan (janneke) Nieuwenhuizen 79e64a1045
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:25 +01:00
Jan (janneke) Nieuwenhuizen 21ba46ec35
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:25 +01:00
Jan (janneke) Nieuwenhuizen 31cab7bfca
mescc: Mes C Library: memcmp: bugfix.
* lib/string/memcmp.c (memcmp): Bugfix.
* lib/tests/string/50-memcmp.c: Test it.
* build-aux/check-mescc.sh (TESTS): Add it.
2020-12-31 14:00:25 +01:00
Jan (janneke) Nieuwenhuizen 8ddd1825e0
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:25 +01:00
Jan (janneke) Nieuwenhuizen 6d11008f43
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:25 +01:00
Jan (janneke) Nieuwenhuizen 4ebd0cbb5c
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:25 +01:00
Jan (janneke) Nieuwenhuizen c58320128e
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:24 +01:00
Jan (janneke) Nieuwenhuizen 5758b5377f
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:24 +01:00
Jan (janneke) Nieuwenhuizen ffd265edc2
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:24 +01:00
Jan (janneke) Nieuwenhuizen 1ed2bb50f7
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2020-12-31 14:00:24 +01:00
Jan (janneke) Nieuwenhuizen f33db40b6d
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.
2020-12-31 14:00:24 +01:00
Jan (janneke) Nieuwenhuizen a06166230d
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2020-12-31 14:00:24 +01:00
Jan (janneke) Nieuwenhuizen 9b0e04c0e3
mescc: Mes C Library: feof: Bugfix for ARM.
* lib/stdio/feof.c (feof): Use int to compare with EOF.
2020-12-29 14:24:30 +01:00
Jan (janneke) Nieuwenhuizen 42a18b3425
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.
2020-12-29 14:24:30 +01:00
Jan (janneke) Nieuwenhuizen 9d92e839c8
libtcc1: Compile float stubs conditionally.
* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf,
__floatdidf)[!(HAVE_FLOAT_STUB || HAVE_FLOAT)]: Remove.
2020-12-29 14:24:28 +01:00
Jan (janneke) Nieuwenhuizen dae845aad4
libtcc1: Make float stubs weak.
* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf, __floatdidf): Add
__attribute__ ((weak)).
2020-12-29 14:24:26 +01:00
Jan (janneke) Nieuwenhuizen 6c64b2fc0f
mescc: Mes C Library: ARM: setjmp.c: Inline fake asm.
* lib/linux/arm-mes-gcc/_exit.c (longjmp, setjmp): Use inline fake asm.
2020-12-29 14:24:24 +01:00
Jan (janneke) Nieuwenhuizen b77845ae9a
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.
2020-12-29 14:24:24 +01:00
Jan (janneke) Nieuwenhuizen 191de698a7
mescc: Mes C Library: ARM: _write.c: Inline fake asm.
* lib/linux/arm-mes-gcc/_write.c (_write): Use inline fake asm.
2020-12-29 14:24:23 +01:00
Jan (janneke) Nieuwenhuizen fb4b8bb58c
mescc: Mes C Library: ARM: _exit: Inline fake asm.
* lib/linux/arm-mes-gcc/_exit.c (_exit): Use inline fake asm.
2020-12-29 14:24:22 +01:00
Jan (janneke) Nieuwenhuizen 99a9ab7411
mescc: Mes C Library: ARM: _start: Inline fake asm.
* lib/linux/arm-mes-gcc/crt1.c (_start): Use inline fake asm.
2020-12-29 14:24:21 +01:00
Jan (janneke) Nieuwenhuizen 733b927c4c
tests: Add 70-or-argument.c.
* lib/tests/scaffold/70-or-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2020-12-29 14:24:21 +01:00
Jan (janneke) Nieuwenhuizen 299a9ea369
tests: Add 70-function-modulo.c.
* lib/tests/scaffold/70-function-modulo.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2020-12-29 14:24:20 +01:00
Jan (janneke) Nieuwenhuizen 8c85bccd56
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.
2020-12-29 14:24:19 +01:00
Jan (janneke) Nieuwenhuizen 614c9146ba
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].
2020-12-29 14:24:18 +01:00
Jan (janneke) Nieuwenhuizen 612714b26b
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.
2020-12-29 14:24:18 +01:00
Jan (janneke) Nieuwenhuizen 2c3e96bcfc
ARM: Add fake asm for setjmp.c.
* lib/arm-mes-gcc/setjmp.c (longjmp, setjmp)[__TINYC__]: Add fake asm.
2020-12-29 14:24:17 +01:00
Jan (janneke) Nieuwenhuizen 9553e33379
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.
2020-12-29 14:24:16 +01:00
Jan (janneke) Nieuwenhuizen 8062b7cd21
ARM: Add fake asm for mini.c.
* lib/linux/arm-mes-gcc/mini.c (_exit, _write)[__TINYC__]: Add fake asm.
2020-12-29 14:24:15 +01:00
Jan (janneke) Nieuwenhuizen ae3e50f5b3
ARM: Add fake asm for crt1.c.
* lib/linux/arm-mes-gcc/crt1.c (_start)[__TINYC__]: Use fake asm.
2020-12-29 14:24:15 +01:00
Jan (janneke) Nieuwenhuizen 5eaefeac38
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.
2020-12-29 14:24:14 +01:00
Jan (janneke) Nieuwenhuizen def9c6c330
mescc: Mes C Library: Support ARM tcc: Add __memset.
* lib/string/__memset.c: New file.
* include/mes/lib.h (__memset): Add prototype.
2020-12-29 14:24:13 +01:00
Jan (janneke) Nieuwenhuizen f0c1f4c4d2
mescc: Mes C Library: Support ARM tcc: Add __memmove.
* lib/string/__memmove.c: New file.
* include/mes/lib.h (__memmove): Add prototype.
2020-12-29 14:24:12 +01:00