Commit graph

470 commits

Author SHA1 Message Date
Jan (janneke) Nieuwenhuizen 442cef4c12
mescc: Mes C Library: Prepare for M2-Planet: _getcwd.
* lib/linux/_getcwd.c (_getcwd): Prepare for M2-Planet.
2020-07-25 19:52:33 +02:00
Jan (janneke) Nieuwenhuizen 8e8fa14f03
mescc: Mes C Library: Bugfix __ungetc_clear.
* lib/m2/mes_open.c (mes_open): Remove __ungetc_init ();
* lib/m2/open.c (open): Likewise.
2020-08-02 00:37:37 +02:00
Jan (janneke) Nieuwenhuizen fd130a03d1
kaem: scaffold/read.kaem.
* .gitignore: Update.
* include/linux/x86/syscall.h: Update for M2-Planet.
* lib/linux/brk.c (brk): Remove cast for M2-Planet.
* lib/linux/x86-mes-m2/syscall.c: New file.
* lib/m2/malloc.c: New file.
* lib/string/memset.c (memset): Update for M2-Planet.
* scaffold/read.c: Update for M2-Planet.
* scaffold/kaem.read: New file.
2020-07-15 22:27:57 +02:00
Jan (janneke) Nieuwenhuizen 488d3f6afa
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.
2020-07-15 22:15:36 +02:00
Jan (janneke) Nieuwenhuizen 6297f36d4a
kaem: scaffold/main.kaem.
* lib/linux/x86-mes-m2/crt1.c,
lib/linux/x86-mes-m2/crt1.M1,
lib/linux/x86-mes-m2/_exit.c,
lib/linux/x86-mes-m2/_write.c: New files.
* lib/m2/x86/x86_defs.M1: New file.  Import from stage0.
* lib/m2/x86/ELF-x86.hex2: New file.  Import from M2-Planet.
* scaffold/main.c: Update for M2-Planet.
* scaffold/main.kaem: New file.
* .gitignore: Update.
2020-07-15 19:25:16 +02:00
Jan (janneke) Nieuwenhuizen 2012304dc8
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:28:58 +02:00
Jan (janneke) Nieuwenhuizen cf7fc8ec2b
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:28:51 +02:00
Jan (janneke) Nieuwenhuizen d49ea35044
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:28:37 +02:00
Jan (janneke) Nieuwenhuizen 5dbae4a29b
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:29:09 +02:00
Jan (janneke) Nieuwenhuizen fac29c0e7b
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:28:28 +02:00
Jan (janneke) Nieuwenhuizen 04061cbba5
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-06-07 00:31:26 +02:00
Jan (janneke) Nieuwenhuizen 189b9d9e8c
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:28:04 +02:00
Jan (janneke) Nieuwenhuizen 11d6a9679d
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:27:53 +02:00
Jan (janneke) Nieuwenhuizen 902ed2524a
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-06-06 22:37:30 +02:00
Jan (janneke) Nieuwenhuizen 8e74d025f2
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:29:29 +02:00
Jan (janneke) Nieuwenhuizen 3b68e7de64
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:29:36 +02:00
Jan (janneke) Nieuwenhuizen b20a388715
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:29:18 +02:00
Jan (janneke) Nieuwenhuizen b4895d7495
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:44:02 +02:00
Jan (janneke) Nieuwenhuizen 99e24cd99a
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:30:04 +02:00
Jan (janneke) Nieuwenhuizen 8194ecfc0f
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:29:57 +02:00
Jan (janneke) Nieuwenhuizen c117abe06a
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2020-05-17 19:29:44 +02:00
Jan (janneke) Nieuwenhuizen 0ca159041d
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-05-17 19:27:27 +02:00
Jan (janneke) Nieuwenhuizen cf22ba44ce
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2020-04-19 15:57:06 +02:00
W. J. van der Laan be4514c4de
lib/tests: Pass int to va_arg instead of char.
* lib/tests/scaffold/70-stdarg.c (stdarg1, stdarg2, stdarg3): Pass int
to va_arg instead of char to avoid gcc trap "warning: 'char’ is promoted
to ‘int’ when passed through ‘...’ [enabled by default] (so you should
pass ‘int’ not ‘char’ to ‘va_arg’) if this code is reached, the program
will abort".
2021-05-02 16:56:29 +02:00
Jan (janneke) Nieuwenhuizen 6c1ff75c5a
mescc: Mes C Library: crt: Support more than 255 command line parameters.
Reported by Paul Dersey <pdersey@gmail.com>.

* lib/freebsd/x86-mes-gcc/crt1.c (_start): Use mov instead of movzbl for
argc.
* lib/linux/x86-mes-gcc/crt0.c (_start): Likewise.
* lib/linux/x86-mes-gcc/crt1.c (_start): Likewise.
* lib/freebsd/x86-mes-mescc/crt1.c (_start): Likewise.
* lib/linux/x86-mes-mescc/crt1.c (_start): Likewise.
2021-05-02 14:22:21 +02:00
Jan (janneke) Nieuwenhuizen dfa8e6e9d5
mescc: Mes C Library: malloc.c: Move unix-variant to lib/linux.
* lib/stdlib/malloc.c: Move to...
lib/linux/malloc.c: ...here.
* build-aux/configure-lib.sh (libc_SOURCES): Move malloc.c...
[linux]: ...here.
2021-05-02 13:13:13 +02:00
Danny Milosavljevic 2e9b02043b
libtcc1: Fix integer division, modulo and shifting procedures.
* lib/libtcc1.c (__divdi3): Make parameters integer.
(__moddi3): Make parameters integer.
(__udivdi3): Use unsigned division.
(__umoddi3): Use unsigned modulo.
(__lshrdi3): Add comment.
(__ashrdi3): Add comment.
2021-03-14 11:05:00 +01:00
Danny Milosavljevic 27b06c6ddb
mescc: Mes C Library: Make malloc align the blocks it gives out.
* include/stddef.h (max_align_t): Add typedef for max_align_t.
* lib/stdlib/malloc.c (malloc): Align the blocks it gives out to multiples
of max_align_t.
2021-01-23 08:43:48 +01:00
Jan (janneke) Nieuwenhuizen 381e8bd6e0
mescc: Mes C Library: feof: Bugfix for ARM.
* lib/stdio/feof.c (feof): Use int to compare with EOF.
2021-01-23 08:43:47 +01:00
Jan (janneke) Nieuwenhuizen 7ab9cfe864
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.
2021-01-23 08:43:47 +01:00
Jan (janneke) Nieuwenhuizen 3115261f2f
libtcc1: Compile float stubs conditionally.
* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf,
__floatdidf)[!(HAVE_FLOAT_STUB || HAVE_FLOAT)]: Remove.
2021-01-23 08:43:47 +01:00
Jan (janneke) Nieuwenhuizen d9226ca678
libtcc1: Make float stubs weak.
* lib/libtcc1.c (__floatundidf, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi, __fixunsdfdi, __fixunsdfsi, __floatdisf, __floatdidf): Add
__attribute__ ((weak)).
2021-01-23 08:43:47 +01:00
Jan (janneke) Nieuwenhuizen b7dff2c2a4
mescc: Mes C Library: ARM: setjmp.c: Inline fake asm.
* lib/linux/arm-mes-gcc/_exit.c (longjmp, setjmp): Use inline fake asm.
2021-01-23 08:43:46 +01:00
Jan (janneke) Nieuwenhuizen 6703c33f96
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.
2021-01-23 08:43:46 +01:00
Jan (janneke) Nieuwenhuizen e5ce69ec3f
mescc: Mes C Library: ARM: _write.c: Inline fake asm.
* lib/linux/arm-mes-gcc/_write.c (_write): Use inline fake asm.
2021-01-23 08:43:46 +01:00
Jan (janneke) Nieuwenhuizen 0667d1aa25
mescc: Mes C Library: ARM: _exit: Inline fake asm.
* lib/linux/arm-mes-gcc/_exit.c (_exit): Use inline fake asm.
2021-01-23 08:43:46 +01:00
Jan (janneke) Nieuwenhuizen 4e7a6057aa
mescc: Mes C Library: ARM: _start: Inline fake asm.
* lib/linux/arm-mes-gcc/crt1.c (_start): Use inline fake asm.
2021-01-23 08:43:46 +01:00
Jan (janneke) Nieuwenhuizen 9711ed70ec
tests: Add 70-or-argument.c.
* lib/tests/scaffold/70-or-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2021-01-23 08:43:46 +01:00
Jan (janneke) Nieuwenhuizen b531c73590
tests: Add 70-function-modulo.c.
* lib/tests/scaffold/70-function-modulo.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2021-01-23 08:43:45 +01:00
Jan (janneke) Nieuwenhuizen 4b194d7bc7
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.
2021-01-23 08:43:45 +01:00
Jan (janneke) Nieuwenhuizen bdb1e2ec56
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].
2021-01-23 08:43:45 +01:00
Jan (janneke) Nieuwenhuizen 905277a73a
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.
2021-01-23 08:43:45 +01:00
Jan (janneke) Nieuwenhuizen 4f66055f3b
ARM: Add fake asm for setjmp.c.
* lib/arm-mes-gcc/setjmp.c (longjmp, setjmp)[__TINYC__]: Add fake asm.
2021-01-23 08:43:44 +01:00
Jan (janneke) Nieuwenhuizen e5573ec23c
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.
2021-01-23 08:43:44 +01:00
Jan (janneke) Nieuwenhuizen 40f270f3d7
ARM: Add fake asm for mini.c.
* lib/linux/arm-mes-gcc/mini.c (_exit, _write)[__TINYC__]: Add fake asm.
2021-01-23 08:43:44 +01:00
Jan (janneke) Nieuwenhuizen 420d422e34
ARM: Add fake asm for crt1.c.
* lib/linux/arm-mes-gcc/crt1.c (_start)[__TINYC__]: Use fake asm.
2021-01-23 08:43:44 +01:00
Jan (janneke) Nieuwenhuizen ed59c243a8
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.
2021-01-23 08:43:44 +01:00
Jan (janneke) Nieuwenhuizen e82a53a40f
mescc: Mes C Library: Support ARM tcc: Add __memset.
* lib/string/__memset.c: New file.
* include/mes/lib.h (__memset): Add prototype.
2021-01-23 08:43:43 +01:00
Jan (janneke) Nieuwenhuizen 82a2388db2
mescc: Mes C Library: Support ARM tcc: Add __memmove.
* lib/string/__memmove.c: New file.
* include/mes/lib.h (__memmove): Add prototype.
2021-01-23 08:43:43 +01:00
Jan (janneke) Nieuwenhuizen bebb8dabfb
mescc: Mes C Library: Support ARM tcc: Add __memcpy.
* lib/string/__memcpy.c: New file.
* include/mes/lib.h (__memcpy): Add prototype.
2021-01-23 08:43:43 +01:00
Jan (janneke) Nieuwenhuizen 6a9e9838f0
mescc: Mes C Library: abort: Avoid __raise for TinyCC.
* lib/stdlib/abort.c: Use "raise" instead of __raise.
2021-01-23 08:43:43 +01:00
Jan (janneke) Nieuwenhuizen 98965c8807
test: Split-off scaffold/60-math-itoa.c.
* lib/tests/scaffold/60-math.c (main): Move itoa tests to...
* lib/tests/scaffold/60-math-itoa.c: ...this new file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2021-01-23 08:43:43 +01:00
Jan (janneke) Nieuwenhuizen af2353dd23
test: Split-off 36-compare-arithmetic-negative.c.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Move negative
divisions to...
* lib/tests/scaffold/36-compare-arithmetic-negative.c: ...new file here.
* build-aux/check-mescc.sh (mes_tests): Add it.
2021-01-23 08:43:43 +01:00
Jan (janneke) Nieuwenhuizen cd6131bc21
test: ARM: 08-assign.c: Avoid assembly for tcc.
* lib/tests/scaffold/08-assign.c (main)[__arm__ && __TINYC__]: Avoid assembly.
2021-01-23 08:43:42 +01:00
Jan (janneke) Nieuwenhuizen 691d25699c
test: Split-off 50-strcmp-itoa.c
* lib/tests/string/50-strcmp.c (main): Move itoa tests to...
* lib/tests/string/50-strcmp-itoa.c: ...this new file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2021-01-23 08:43:42 +01:00
Jan (janneke) Nieuwenhuizen 4a9d7a1f33
ARM: libtcc1: Add __divsi3, __modsi3, __udivsi3, __umodsi3.
* lib/libtcc1.c (__divsi3, __modsi3, __udivsi3, __umodsi3): New functions.
2021-01-23 08:43:42 +01:00
Jan (janneke) Nieuwenhuizen 04afe3e238
ARM: libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
* lib/libtcc1.c (__floatdisf, __floatdidf)[__arm__]: New stubs.
2021-01-23 08:43:42 +01:00
Jan (janneke) Nieuwenhuizen e07e731dfd
libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
* lib/libtcc1.c (__floatundidf, __fixunsdfdi, __fixunsdfsi): New stubs.
2021-01-23 08:43:42 +01:00
Jan (janneke) Nieuwenhuizen 8c53e22434
ARM: libtcc1: Add support for TinyCC.
* lib/libtcc1.c: (__udivdi3, __umoddi3, __lshrdi3, __ashldi3,
__fixunsxfdi)[__arm__ && __TINYC__]: Use __mesabi functions.
2021-01-23 08:43:42 +01:00
Jan (janneke) Nieuwenhuizen 553539ad75
libtcc1: Remove mesabi dependencies for TinyCC.
* lib/libtcc1.c (__divdi3, __moddi3, __udivdi3, __umoddi3, __lshrdi3,
__ashldi3, __ashrdi3, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi)[__TINYC__]: No stub printing.
2021-01-23 08:43:41 +01:00
Jan (janneke) Nieuwenhuizen ddd8349827
mescc: Mes C Library: div: Avoid __raise for TinyCC.
* lib/mes/div.c (__raise)[__TINYC__]: New macro.
2021-01-23 08:43:41 +01:00
Jan (janneke) Nieuwenhuizen ede49daabb
mescc: Mes C Library: Add __mesabi_umod, __mesabi_udiv.
* lib/mes/div.c (__mesabi_umod, __mesabi_udiv): New functions.
* include/mes/lib.h: Add prototypes.
2021-01-23 08:43:41 +01:00
Danny Milosavljevic c1dcdc5d7e
ARM: Implement long division.
* lib/mes/div.c (__mesabi_log2i): New procedure.
(__mesabi_uldiv1): New procedure.
(__mesabi_uldiv): Use it.

Co-Authored-By: Nathalie Kopaczewski <natkopa@gmail.com>
2021-01-23 08:43:41 +01:00
Jan (janneke) Nieuwenhuizen 13b69f4b9b
tests: Add 70-ternary-arithmetic-argument.c.
* lib/tests/scaffold/70-ternary-arithmetic-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests, xfail_tests): Add it.
2021-01-23 08:43:41 +01:00
Danny Milosavljevic 10bcb3709b
ARM: Speed up __mesabi_uldiv for powers-of-two divisors.
* lib/mes/div.c (__mesabi_uldiv): Speed up division for powers-of-two
divisors.
2021-01-23 08:43:41 +01:00
Paul Dersey 4492173466
Mes C Library: stdlib/qsort.c: Fix qswap segfault.
* stdlib/qsort.c (qswap): Remove hard coded buffer size.  Allow
swapping of objects of arbitrary size.
2021-01-23 08:43:05 +01:00
Jan (janneke) Nieuwenhuizen b601eb64af
mescc: Mes C Library: ntoab: Use unsigned base.
This fixes 60-math, 60-math-itoa, 70-printf-simple, 70-printf.

* lib/mes/ntoab.c (ntoab): Use unsigned base.
* include/mes/lib.h: Update prototype.
2020-12-13 22:19:06 +01:00
Jan (janneke) Nieuwenhuizen fa4147a284
mescc: Use signed division for x86, x86_64 when appropriate.
This fixes 36-compare-arithmetic.c

* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Do not reset
signed?.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Use unique exit
value per failure.
2020-10-06 19:53:02 +02:00
Jan (janneke) Nieuwenhuizen 84ff05a839
mescc: Mes C Library: Support gcc-10.
See <https://lists.gnu.org/archive/html/bug-mes/2020-07/msg00000.html>.

Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.

* include/setjmp.h (jmp_buf): Remove.
* include/errno.h (errno): Mark extern.
* include/mes/lib-mini.h (environ, errno, __stdin, __stdout, __stderr):
Likewise.
* lib/mes/globals.c: New file; define them.
* build-aux/configure-lib.sh (libc_mini_shared_SOURCES,
libmescc_SOURCES): Add it.
* build-aux/test-c.sh: Always use -l c-mini as a minimum.
2020-10-06 13:13:44 +02:00
Jan (janneke) Nieuwenhuizen 0650e08744
mescc: Mes C Library: x86_64: Add syscall-internal.
This resurrects the x86_64 build.

* lib/linux/x86_64-mes-gcc/syscall-internal.c (__sys_call_internal),
lib/linux/x86_64-mes-mescc/syscall-internal.c: New file.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen e16d1e469a
mescc: Mes C Library: x86_64: Introduce __sys_call and friends.
This prepares for x86_64 syscall-internal.

* lib/linux/x86_64-mes-gcc/syscall.c (__sys_call, __sys_call1,
__sys_call2, __sys_call3, __sys_call4): New functions, copied from ...
(_sys_call, _sys_call1, _sys_call2, _sys_call3, _sys_call4): ... these.
Use them, handle errno only.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen 1c128c7a9f
mescc: Mes C Library: x86: Use long for syscalls.
The Linux signature uses long, also this allows for making
_sys_call and friends architecture-independent.

* lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal,
__sys_call2_internal): Use long.  Update callers.
* lib/linux/x86-mes-mescc/syscall.c (__sys_call, __sys_call1,
__sys_call2, __sys_call3, __sys_call4, _sys_call, _sys_call1,
_sys_call2, _sys_call3, _sys_call4): Likewise.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen 5f8a424328
mescc: Mes C Library: Remove redundant prototypes.
* lib/linux/x86-mes-gcc/syscall.c(__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4): Remove prototype.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen c11a721c36
mescc: Mes C Library: Whitespace fixes.
* lib/linux/signal.c (signal): Whitespace fixes.
* lib/linux/time.c (time): Likewise.
2020-10-06 10:04:42 +02:00
Danny Milosavljevic afac5847e7
div: Remove libgcc-compatible API.
* lib/mes/div.c (__aeabi_idiv): Delete procedure.
(__aeabi_idivmod): Delete procedure.
(__aeabi_uidivmod): Delete procedure.
(__aeabi_uidiv): Delete procedure.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 9db916bba1
Revert syscall split (of commit 55d38162be);
just copy the two syscalls I need for __raise instead.

* lib/linux/arm-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/arm-mes-gcc/syscall.c: ...here.
* lib/linux/arm-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/arm-mes-mescc/syscall.c: ...here.
* lib/linux/x86-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/x86-mes-gcc/syscall.c: ...here.
* lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/x86-mes-mescc/syscall.c: ...here.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 3ed3b51371
div: Add comment about __aeabi_idiv.
* lib/mes/div.c (__aeabi_idiv): Add comment.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 95c71f3178
div: Move __aeabi_idiv to __GNUC__; introduce __mesabi_idiv.
* lib/mes/div.c (__aeabi_idiv): Move for conditional compilation.
(__mesabi_idiv): New procedure.
* module/mescc/armv4/as.scm (armv4:r0/r1): Use __mesabi_idiv.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen 3973e87219
ARM: Add missing instruction.
* lib/arm-mes/arm.M1: Add missing define.
2020-10-06 10:04:28 +02:00
Danny Milosavljevic e3aba5d464
test: Make 7l-struct-any-size-array-simple compatible with default ARM gcc.
* lib/tests/scaffold/7l-struct-any-size-array-simple.c: Make "signed"
explicit in signed char types.
2020-08-22 21:01:45 +02:00
Danny Milosavljevic 7e23d98494
test: Make 7r-sign-extend compatible with default ARM gcc.
* lib/tests/scaffold/7r-sign-extend.c: Make "signed" explicit in
signed char types.
2020-08-22 21:01:36 +02:00
Danny Milosavljevic acf86208ed
ARM: Support comparing 32 bit values.
* lib/arm-mes/arm.M1 (cmp____$i32,%r0): New macro.
(cmp____$i32,%r1): New macro.
(cmp____$i32,%r2): New macro.
2020-06-19 02:45:51 +02:00
Danny Milosavljevic d9bda45853
ARM: Handle signed values in r-byte-mem-add, r-word-mem-add.
* lib/arm-mes/arm.M1 (ldrb___%r0,(%r1)): Delete macro.
(ldrh___%r0,(%r0)): Delete macro.
(ldrsh__%r0,(%r0)): New macro.
(ldrh___%r0,(%r1)): Delete macro.
(ldrsh__%r0,(%r1)): New macro.
(ldrh___%r1,(%r1)): Delete macro.
(ldrsh__%r1,(%r1)): New macro.
(ldrh___%r2,(%r2)): Delete macro.
(ldrsh__%r2,(%r2)): New macro.
(ldrh___%r3,(%r3)): Delete macro.
(ldrsh__%r3,(%r3)): New macro.
(ldrsb__%r0,(%r1)): New macro.
* module/mescc/armv4/as.scm (armv4:r-byte-mem-add): Use ldrsb.
(armv4:r-word-mem-add): Use ldrsh, add____$i32,(%r0).
(armv4:word-mem->r): Use ldrsh.
2020-06-19 02:45:33 +02:00
Danny Milosavljevic 821d1b8fe9
ntoab: Simplify LONG_MIN case.
* lib/mes/ntoab.c (ntoab): Simplify LONG_MIN case.

Co-Authored-By: Nathalie Kopaczewski <natkopa@gmail.com>
2020-06-17 00:21:57 +02:00
Danny Milosavljevic b11510f4da
ntoab: Handle LONG_MIN case.
* lib/mes/ntoab.c (ntoab): Handle LONG_MIN case.
* lib/tests/scaffold/60-math.c (main): Add test for INT_MIN and hex.
2020-06-15 11:26:43 +02:00
Danny Milosavljevic 449f3c7e00
Add ARM gcc scaffold assembly.
* lib/linux/arm-mes-gcc/exit-42.S: New file.
* lib/linux/arm-mes-gcc/hello-mes.S: New file.
2020-06-13 19:44:29 +02:00
Danny Milosavljevic 6478476ed7
Implement setjmp for ARM mescc.
* include/setjmp.h: Add ARM case.
* lib/arm-mes-mescc/setjmp.c: New file.
2020-06-12 23:20:17 +02:00
Danny Milosavljevic 48ecb2f29e
test: Test signed division.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Test signed division.
2020-06-10 17:04:55 +02:00
Danny Milosavljevic 3f03574050
ldiv: Work around missing struct return feature.
* lib/mes/div.c (__mesabi_ldiv): Remove return type.
(__mesabi_imod): Adapt call site.
(__aeabi_idiv): Adapt call site and move it to conditional compilation.
(__aeabi_idivmod): Adapt call site.
2020-06-10 15:46:12 +02:00
Danny Milosavljevic d42f99e6cf
mescc: Mes C Library: Hang at the end if necessary.
* lib/linux/arm-mes-mescc/crt1.c (_start): Hang at the end if necessary.
2020-06-10 13:14:33 +02:00
Danny Milosavljevic 040220acee
Add ARM backend.
* build-aux/build-guile.sh: Add ARM backend.
* lib/arm-mes/arm.M1: New file.
* module/mescc/armv4/as.scm: New file.
* module/mescc/armv4/info.scm: New file.
* module/mescc/mescc.scm: Use it.
* module/mescc/M1.scm (info->M1): Support ARM symbolic instructions,
including little endian instructions.  Align functions.
2020-06-10 13:11:07 +02:00
Jan Nieuwenhuizen 80419817e6
ARM: Mes C Library: Support gcc-sans-libc.
* lib/linux/arm-mes-gcc/crt1.c: New file.
* lib/linux/arm-mes-gcc/mini.c: New file.
* lib/arm-mes-gcc/setjmp.c: New file.

Co-Authored-By: Danny Milosavljevic <dannym@scratchpost.org>
2020-06-04 21:59:30 +02:00
Danny Milosavljevic b0347bf53d
ntoab: Make sure not to get stuck on base 1.
* lib/mes/ntoab.c (ntoab): Make sure not to get stuck on base 1.
2020-06-03 20:56:51 +02:00
Danny Milosavljevic 1f47a76e7a
mescc: Mes C Library: Add crt1, mini.
* lib/linux/arm-mes-mescc/crt1.c: New file.
* lib/linux/arm-mes-mescc/mini.c: New file.
2020-06-03 20:46:41 +02:00
Danny Milosavljevic 85e690ea64
ARM: Mes C Library: Add comment.
* lib/linux/time.c: Add comment.
2020-06-03 11:24:03 +02:00
Jan Nieuwenhuizen be1ff7e625
ARM: Mes C Library: Add compile stub for time.
* lib/linux/time.c (time)[SYS_gettimeofday]: Implement using gettimeofday.
(time)[!SYS_time && !SYS_gettimeofday]: Compile stub.
2020-06-03 10:41:37 +02:00
Danny Milosavljevic a944400112
waitpid: Support ARM.
* lib/linux/waitpid.c (waitpid): Support ARM.
2020-06-03 00:55:07 +02:00
Danny Milosavljevic 65013db594
Add ARM linker support files.
* lib/linux/arm-mes/elf32-0exit-42.hex2,
lib/linux/arm-mes/elf32-0header.hex2,
lib/linux/arm-mes/elf32-0hello-mes.hex2,
lib/linux/arm-mes/elf32-body-exit-42.hex2,
lib/linux/arm-mes/elf32-body-hello-mes.hex2,
lib/linux/arm-mes/elf32-footer-single-main.hex2,
lib/linux/arm-mes/elf32-header.hex2: New files.
2020-06-02 20:27:52 +02:00
Danny Milosavljevic 4775de0021
Raise SIGABRT on abort().
* lib/stdlib/abort.c (abort): Raise SIGABRT.
2020-06-02 15:05:12 +02:00
Danny Milosavljevic 55d38162be
Introduce libmescc.a; Put division by integer in there; split syscalls' errno off.
* build-aux/configure-lib.sh (libmescc_SOURCES): Add lib/mes/div.c,
lib/linux/*/syscall-internal.c.
* build-aux/build-lib.sh: Add libmescc.a.
* build-aux/build-mes.sh: On gcc, add "-lmescc".
* build-aux/test-c.sh: Add "-lmescc".
* build-aux/check.sh.in: Add mescc to LIBS.
* module/mescc/mescc.scm (mescc:link): Add "mescc".
* module/mescc.scm (mescc:main): Update documentation of "-nodefaultlibs"
and "-nostdlib".
* lib/mes/div.c (ldiv): Rename to...
(__mesabi_ldiv): ...this.  Avoid assert.
(__mesabi_div0): Avoid assert.
(__aeabi_idivmod): New procedure.
(__aeabi_idiv): New procedure.
(__aeabi_uidivmod): New procedure.
(__aeabi_uidiv): New procedure.
* lib/linux/x86-mes-gcc/syscall.c (__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4): Move to...
* lib/linux/x86-mes-gcc/syscall-internal.c: ...here.
(__raise): New procedure.
* lib/linux/x86-mes-mescc/syscall.c (__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4): Move to...
* lib/linux/x86-mes-mescc/syscall-internal.c: ...here.
(__raise): New procedure.
* lib/linux/arm-mes-gcc/syscall.c: New file.
* lib/linux/arm-mes-gcc/syscall-internal.c: New file.
* lib/linux/arm-mes-mescc/syscall.c: New file.
* lib/linux/arm-mes-mescc/syscall-internal.c: New file.
* lib/gnu/syscall.c (__syscall, __syscall2, __syscall_get, __syscall_put):
Move to...
* lib/gnu/syscall-internal.c: ...here.
2020-06-02 15:04:13 +02:00
Danny Milosavljevic fbc249832c
Prepare tests for ARMv4.
* lib/tests/io/90-stat.c,
lib/tests/scaffold/76-pointer-arithmetic.c,
lib/tests/scaffold/7k-for-each-elem.c,
lib/tests/scaffold/85-sizeof.c: Prepare tests for ARMv4.
2020-06-02 14:30:02 +02:00
Jan Nieuwenhuizen d8fca8321e
mescc: Mes C Library: Fix execlp, execvp for file names with slash.
Reported by mid-kid.

* lib/posix/execlp.c (execlp): Do not use search_path when file name
contains a slash (WAS: when file name starts with slash).
* lib/posix/execvp.c (execvp): Likewise.
2020-01-20 22:47:52 +01:00
Jan Nieuwenhuizen 3abd3e0bcc
mescc: Mes C Library: lseek: Be careful clearing read buffer.
* lib/linux/lseek.c (_lseek): New function.
* lib/linux/lseek.c (lseek): Use it to check if we should reset read
buffer.
* lib/mes/__buffered_read.c (__read_buffer_max): New variable.
(__buffered_read_init): Add environment override: MES_READ_BUFFER.
(__buffered_read): Use it.
2020-01-20 22:47:52 +01:00
Jan Nieuwenhuizen ec9aecea07
freebsd: Initial x86 scaffold.
* lib/freebsd/x86-mes-gcc/crt1.c: New file.
* lib/freebsd/x86-mes-gcc/exit-42.S: New file.
* lib/freebsd/x86-mes-gcc/hello-mes.S: New file.
* lib/freebsd/x86-mes-gcc/mini.c: New file.
* lib/freebsd/x86-mes-mescc/crt1.c: New file.
* lib/freebsd/x86-mes-mescc/mini.c: New file.
* lib/freebsd/x86-mes/elf32-0exit-42.hex2: New file.
* lib/freebsd/x86-mes/elf32-0header.hex2: New file.
* lib/freebsd/x86-mes/elf32-0hello-mes.hex2: New file.
* lib/freebsd/x86-mes/elf32-body-exit-42.hex2: New file.
* lib/freebsd/x86-mes/elf32-body-hello-mes.hex2: New file.
* lib/freebsd/x86-mes/elf32-footer-single-main.hex2: New file.
* lib/freebsd/x86-mes/elf32-header.hex2: New file.
2019-12-17 21:08:18 +01:00
Jan Nieuwenhuizen 34106fc420
build: Prepare for kernel variants.
* configure: Fix detection of Arch, FreeBSD.
* lib/linux/x86-mes-gcc/exit-42.S: Move from ...
* lib/x86-mes-gcc/exit-42.S: ... here.
* lib/linux/x86-mes-gcc/hello-mes.S: Move from ...
* lib/x86-mes-gcc/hello-mes.S: ... here.
* lib/linux/x86-mes-mescc/exit-42.S: Move from ...
* lib/x86-mes-mescc/exit-42.S: ... here.
* lib/linux/x86-mes-mescc/hello-mes.S: Move from ...
* lib/x86-mes-mescc/hello-mes.S: ... here.
* lib/linux/x86-mes/elf32-0exit-42.hex2: Move from ...
* lib/x86-mes/elf32-0exit-42.hex2: ... here.
* lib/linux/x86-mes/elf32-0header.hex2: Move from ...
* lib/x86-mes/elf32-0header.hex2: ... here.
* lib/linux/x86-mes/elf32-0hello-mes.hex2: Move from ...
* lib/x86-mes/elf32-0hello-mes.hex2: ... here.
* lib/linux/x86-mes/elf32-body-exit-42.hex2: Move from ...
* lib/x86-mes/elf32-body-exit-42.hex2: ... here.
* lib/linux/x86-mes/elf32-body-hello-mes.hex2: Move from ...
* lib/x86-mes/elf32-body-hello-mes.hex2: ... here.
* lib/linux/x86-mes/elf32-footer-single-main.hex2: Move from ...
* lib/x86-mes/elf32-footer-single-main.hex2: ... here.
* lib/linux/x86-mes/elf32-header.hex2: Move from ...
* lib/x86-mes/elf32-header.hex2: ... here.
* lib/linux/x86_64-mes-gcc/exit-42.S: Move from ...
* lib/x86_64-mes-gcc/exit-42.S: ... here.
* lib/linux/x86_64-mes-gcc/hello-mes.S: Move from ...
* lib/x86_64-mes-gcc/hello-mes.S: ... here.
* lib/linux/x86_64-mes-mescc/exit-42.S: Move from ...
* lib/x86_64-mes-mescc/exit-42.S: ... here.
* lib/linux/x86_64-mes-mescc/hello-mes.S: Move from ...
* lib/x86_64-mes-mescc/hello-mes.S: ... here.
* lib/linux/x86_64-mes/elf64-0exit-42.hex2: Move from ...
* lib/x86_64-mes/elf64-0exit-42.hex2: ... here.
* lib/linux/x86_64-mes/elf64-0header.hex2: Move from ...
* lib/x86_64-mes/elf64-0header.hex2: ... here.
* lib/linux/x86_64-mes/elf64-0hello-mes.hex2: Move from ...
* lib/x86_64-mes/elf64-0hello-mes.hex2: ... here.
* lib/linux/x86_64-mes/elf64-body-exit-42.hex2: Move from ...
* lib/x86_64-mes/elf64-body-exit-42.hex2: ... here.
* lib/linux/x86_64-mes/elf64-body-hello-mes.hex2: Move from ...
* lib/x86_64-mes/elf64-body-hello-mes.hex2: ... here.
* lib/linux/x86_64-mes/elf64-footer-single-main.hex2: Move from ...
* lib/x86_64-mes/elf64-footer-single-main.hex2: ... here.
* lib/linux/x86_64-mes/elf64-header.hex2: Move from ...
* lib/x86_64-mes/elf64-header.hex2: ... here.
* module/mescc.scm (parse-opts): Support --kernel.
* module/mescc/mescc.scm (kernel-find): New function.
* module/mescc/mescc.scm (hex2->elf): Use it to find kernel-specific ELF
snippets.
* build-aux/install.sh.in: Install it.
2019-12-17 21:07:35 +01:00
Jan Nieuwenhuizen c673c9d303
mescc: Mes C Library: Add ioctl3 stub. 2019-12-13 21:52:31 +01:00
Jan Nieuwenhuizen f5bf3f4cf6
mescc: Mes C Library: Fix access stub.
* lib/stub/access.c (access): Use _open3 to give more meaningful
behaviour.  Fixes hanging of mes.
2019-12-13 21:52:31 +01:00
Jan Nieuwenhuizen 7c6da0c213
hurd: Fixes for upgrade to debian-hurd-20190220.img.
* include/mach/mach-init.h (__mach_host_self, __mach_task_self):
Remove macro magic.
(mach_host_self, mach_task_self): Remove macro magic; declare as function.
* lib/mach/mach-init.c (mach_host_self, mach_task_self): New function.
(mach_init): Use them.
* lib/gnu/hurd-start.c (_hurd_start): Use mach_task_self ().
* lib/gnu/_exit.c (_exit): Likewise.
2019-12-13 21:52:31 +01:00
Jan Nieuwenhuizen 9b0009a888
hurd: Add malloc.
* include/gnu/syscall.h (__vm_allocate): New value.
(__vm_allocate): Declare.
* lib/gnu/malloc.c: New file.
* lib/stdlib/malloc.c[__GNU__]: Disable.  See FIXME.
* lib/gnu/vm-allocate.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.
2019-12-13 21:52:31 +01:00
Jan Nieuwenhuizen 89945751d9
hurd: Add open.
* include/fcntl.h (O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_APPEND,
O_TRUNC)[__GNU__]: Specialize for GNU.
* lib/gnu/dir-lookup.c: New file.
* lib/stdio/fopen.c (fopen): Use O_RDONLY.
* lib/tests/posix/50-open-read.c (main): Likewise.
* lib/tests/stdio/90-fseek.c (main): Likewise.
* include/gnu/syscall.h (SYS__dir_lookup): New value.
* lib/gnu/_open3.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Build them.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen 67d82a6de5
hurd: Add argv and environ.
* include/gnu/hurd.h (struct hurd_startup_data): Add argp, envp.
* lib/gnu/hurd-start.c (__argv, __env): Define them.
* lib/gnu/exec-startup-get-data.c (mach_startup_info2hurd_startup_data):
Set them.
* lib/gnu/x86-mes-gcc/crt1.c (_start): Use them.
* build-aux/configure-lib.sh (libc_mini_SOURCES): Add argz-extract.c.
* include/argz.h: Build fix.
* lib/string/argz-count.c: Likewise.
* lib/string/argz-extract.c: Likewise.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen 72c76d6b3a
hurd: Add stubs for missing libc+tcc functions.
* lib/stub/close.c: New file.
* lib/stub/rmdir.c: New file.
* lib/stub/stat.c: New file.
* build-aux/configure-lib.sh (libc_tcc_SOURCES)[gnu]: Add them.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen 49ff9a7edd
hurd: Add stubs for missing libc functions.
* lib/stub/_getcwd.c: New file.
* lib/stub/_getcwd.c: New file.
* lib/stub/_open3.c: New file.
* lib/stub/access.c: New file.
* lib/stub/brk.c: New file.
* lib/stub/chmod.c: New file.
* lib/stub/clock_gettime.c: New file.
* lib/stub/dup.c: New file.
* lib/stub/dup2.c: New file.
* lib/stub/execve.c: New file.
* lib/stub/fork.c: New file.
* lib/stub/gettimeofday.c: New file.
* lib/stub/ioctl.c: New file.
* lib/stub/time.c: New file.
* lib/stub/unlink.c: New file.
* lib/stub/waitpid.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES)[gnu]: Add them.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen 9b9d37ee95
hurd: Add stubs for missing libmes functions.
* lib/stub/lseek.c: New file.
* build-aux/configure-lib.sh (libmes_SOURCES)[gnu]: Add it.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen 6d3b9b687d
hurd: Add _read.
* include/gnu/hurd.h (fd_read): Declare.
* include/gnu/syscall.h (SYS__io_read): New value.
* lib/gnu/_read.c: New file.
* lib/gnu/fd-read.c: New file.
* lib/gnu/io-read.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Add _read sources.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen db4a202c6b
hurd: Add _write.
* include/gnu/syscall.h (SYS__io_write): Add enum field.
(_hurd_dtable, _hurd_dtable_size): Declare variable.
(fd_get, fd_write, __io_write, __syscall_put): Declare.
* lib/gnu/hurd-start.c (_hurd_dtable, _hurd_dtable_size): Define
variable.
* lib/gnu/_write.c: New file.
* lib/gnu/fd-get.c (fd_get): New file.
* lib/gnu/fd-write.c (fd_write): New file.
* lib/gnu/io-write.c: New file.
* lib/gnu/syscall.c (__syscall_put): New function.
* build-aux/cofnigure-lib.sh (libc_mini_SOURCES): Add write sources.
* lib/tests/mes/30-oputs.c (main): Update.
* lib/tests/mes/30-oputs.stdout: New file.
* lib/tests/mes/30-eputs.c: New test.
* lib/tests/mes/30-eputs.stderr: New file.
* build-aux/check-mescc.sh (TESTS): Add it.
2019-12-13 21:52:30 +01:00
Jan Nieuwenhuizen 784838e368
hurd: Initial support.
This adds minimal Hurd support by implementing the _exit function.

* AUTHORS: Update.
* .gitignore: Ignore a.out, core, .config.
* include/sys/wait.h (W_EXITCODE): New define.
* lib/gnu/x86-mes-gcc/crt1.c: New file.
* lib/gnu/x86-mes-gcc/mini.c: New file.
* lib/gnu/hurd-start.c: New file.
* lib/gnu/_exit.c: New file.
* include/gnu/syscall.h: New file.
* include/gnu/hurd.h: New file.
* lib/gnu/_exit.c: New file.
* lib/gnu/exec-startup-get-data.c: New file.
* lib/gnu/hurd-start.c: New file.
* lib/gnu/proc-mark-exit.c: New file.
* lib/gnu/syscall.c: New file.
* lib/gnu/task-get-special-port.c: New file.
* lib/gnu/task-terminate.c: New file.
* lib/gnu/vm-statistics.c: New file.
* build-aux/configure-lib.sh (libc_mini_SOURCES): Add Hurd sources.
* build-aux/build.sh.in (CPPFLAGS): Add lib to includes, to find linux
crt1.c.
* build-aux/test-c.sh: Always use at least -l c+mini for GNU.
* lib/tests/scaffold/30-exit-42.exit: New file.
* lib/tests/scaffold/30-exit-42.c: New test.
* build-aux/check-mescc.sh (TESTS): Add it.
* lib/tests/scaffold/30-exit-0.c (main): Move from 00-exit-0.c; Rewrite,
use _exit.
* include/gnu/hurd-types.h: Import from GNU C Library.
* include/mach/mach-init.h: Likewise.
* lib/mach/mach-init.c: Likewise.
* lib/mach/mach_host_self.S: Likewise.
* lib/mach/mach_msg_trap.S: Likewise.
* lib/mach/mach_reply_port.S: Likewise.
* lib/mach/mach_task_self.S: Likewise.
* lib/mach/mach_thread_self.S: Likewise.
* lib/mach/msg.c: Likewise.
2019-12-13 21:52:29 +01:00
Jan Nieuwenhuizen 093a8b0903
bootstrap: Build files only once.
* build-aux/bootstrap.sh.in: Build files only once.
2019-12-07 23:29:34 +01:00
Jan Nieuwenhuizen b4b20d6ac4
build: Add mescc scaffold for regular build.
* lib/x86-mes-mescc/exit-42.S: New file.
* lib/x86-mes-mescc/hello-mes.S: New file.
* lib/x86_64-mes-mescc/exit-42.S: New file.
* lib/x86_64-mes-mescc/hello-mes.S: New file.
2019-12-06 19:53:50 +01:00
Jan Nieuwenhuizen 3de6450117
test: 90-abtod: Remove printf dependency. Fixes gcc.
* lib/tests/mes/90-abtod.stdout: Remove.
* lib/tests/mes/90-abtod.c (main): Remove printf.
2019-12-02 10:00:03 +01:00
Jan Nieuwenhuizen 35c97baaef
test: 90-readdir: Remove qsort dependency. Fixes tmpfs failures.
* lib/tests/dirent/90-readdir.c (check_seen): New function.
(main): Use it instead of qsort.
(qsort_strcmp): Remove.
2019-12-01 23:58:48 +01:00
Jan Nieuwenhuizen 2673d28e50
mescc: Mes C Library: Support gcc-4.6.4: Fix ctime stub.
* lib/stub/ctime.c (ctime): Fix stub to avoid segfault upon use.
2019-11-23 21:35:05 +01:00
Jan Nieuwenhuizen 5480c133ae
mescc: Mes C Library: Fix isatty for x86_64.
* lib/linux/ioctl.c (ioctl3): New function.
* include/sys/ioctl.h: Declare it.
* lib/posix/isatty.c (__tcgetattr): Use it.
2019-11-23 21:29:36 +01:00
Jan Nieuwenhuizen 0e55071bc7
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.
2019-09-20 14:44:31 +02:00
Jan Nieuwenhuizen 98b9ac8e98
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.
2019-09-13 15:11:38 +02:00
Jan Nieuwenhuizen 6bb225b403
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/stub/fscanf.c: Remove.
2019-09-06 19:04:50 +02:00
Danny Milosavljevic 73715dab4a
Add missing #include.
* lib/stdlib/mbstowcs.c: Add missing #include.
2019-08-27 01:46:57 +02:00
Danny Milosavljevic 01ae1994ed
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-08-27 00:43:37 +02:00
Danny Milosavljevic abc0809bfa
Add missing #include.
* lib/tests/mes/90-abtod.c (main): Add missing #include.
2019-08-27 04:32:02 +02:00
Danny Milosavljevic 4c77c2c9ca
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-08-27 04:04:56 +02:00
Jan Nieuwenhuizen 58fb0cf764
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-08-24 19:05:58 +02:00
Jan Nieuwenhuizen fd1109a25f
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-09-01 22:18:00 +02:00
Jan Nieuwenhuizen f097a9d270
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-08-01 11:01:47 +02:00
Jan Nieuwenhuizen de197a48f5
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-07-31 12:25:43 +02:00
Jan Nieuwenhuizen 5c979a8ce1
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-07-24 12:23:54 +02:00
Jan Nieuwenhuizen 9573f469f8
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-07-21 13:23:49 +02:00
Jan Nieuwenhuizen fe96cc37df
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-07-18 12:13:18 +02:00
Jan Nieuwenhuizen 0d3f1ed2ae
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-07-15 11:58:21 +02:00
Jan Nieuwenhuizen b97c59ff21
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-07-12 11:56:58 +02:00
Jan Nieuwenhuizen 8d45c6484f
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-07-03 11:22:57 +02:00
Jan Nieuwenhuizen f3154aabe4
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.
2020-01-12 18:42:25 +01:00
Jan Nieuwenhuizen 742e88abd5
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-06-25 12:51:44 +02:00
Jan Nieuwenhuizen cd50beca3a
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
* lib/stdio/vsscanf.c (vsscanf): Support %f.
2019-06-22 11:48:39 +02:00
Jan Nieuwenhuizen 749248ac3a
mescc: Mes C Library: Support GNU Awk: Do not flush std files.
* lib/stdio/fflush.c (fflush): Do not flush std files.
2019-06-19 11:26:37 +02:00
Jan Nieuwenhuizen 9faa38bee1
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-06-16 11:25:37 +02:00
Jan Nieuwenhuizen 9be33485e2
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.
2019-06-13 01:07:19 +02:00
Jan Nieuwenhuizen 4e6a3ce846
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-06-10 00:56:42 +02:00
Jan Nieuwenhuizen 18195b4d05
mescc: Mes C Library: Fix compile warnings.
* include/stdlib.h (abort): Add prototype.
2019-06-12 15:59:06 +02:00
Jan Nieuwenhuizen 396e96c056
mescc: Mes C Library: Add missing stubs.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Add fscanf, rewind stubs.
* lib/stdio/freeopen.c: Remove.
2019-11-10 09:00:08 +01: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