Commit Graph

2016 Commits

Author SHA1 Message Date
Danny Milosavljevic 237dd8a0f0
Distinguish between gcc and mescc; select LIBS accordingly.
* build-aux/check.sh.in: Distinguish between gcc and mescc;
add MES_CHECKING_BUILTIN_LIBS.
* build-aux/test-c.sh: Use it to select LIBS accordingly.
2020-10-06 10:04:41 +02:00
Danny Milosavljevic 56f859200e
Make "raise" available for gcc use.
* build-aux/configure-lib.sh (libc_tcc_SOURCES): Move lib/posix/raise.c,
lib/linux/getpid.c, lib/linux/kill.c to...
(libc_SOURCES): ...here.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 0b79ca74ea
build: Use libgcc.a instead of libmescc.a for gcc. 2020-10-06 10:04:29 +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
Danny Milosavljevic 931ae9280e
build: Make raise available in libc+tcc for libgcc.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Remove raise, getpid, kill.
(libc_tcc_SOURCES): Add raise, getpid, kill.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen eba5c15088
mescc: Add signed char.
* module/mescc/armv4/info.scm (armv4:type-alist): Add signed char.
* module/mescc/i386/info.scm (i386:type-alist): Likewise.
* module/mescc/x86_64/info.scm (x86_64:type-alist): Likewise.
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
Jan (janneke) Nieuwenhuizen 1c06c0170a
ARM: as: Fix ldrsb_ typo.
(armv4:byte-r0-mem->r1-mem): : Add missing "_" to ldrsb_.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen a945bee494
ARM: as: Fix strh__ typo.
* module/mescc/armv4/as.scm (armv4:word-r0-mem->r1-mem): Add missing "_"
to strh__.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen ddfdd1cb7f
mescc: Do not crash when attemting to link files without extension.
* module/mescc/mescc.scm (replace-suffix): Add ELSE clause to IF for
base; add IF for old-suffix.
2020-10-06 10:04:27 +02:00
Jan (janneke) Nieuwenhuizen ae14a08aad
doc: Fix typos in `HACKING`.
* HACKING (SETUP): Typos.
2020-10-06 10:03:21 +02:00
Jan (janneke) Nieuwenhuizen f3f405a83a
ARM: as: Guile compile fix.
* module/mescc/armv4/as.scm (optimize-immediate): Do not unquote compare
functions (and numbers).
2020-08-24 11:24:02 +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 047014e704
build: Fixup cleaning of armv4.
* build-aux/GNUmakefile.in (clean): Clean armv4 go files.
2020-08-22 14:09:54 +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 aaa174382e
ARM: Factor out optimize-immediate.
* module/mescc/armv4/as.scm (optimize-immediate): New macro.
(immediate->r0): Use it.
(armv4:value->r): Use it.
(armv4:local->r): Use it.
(armv4:r->local+n): Use it.
(armv4:r-byte-mem-add): Use it.
(armv4:r-word-mem-add): Use it.
(armv4:local-ptr->r): Use it.
(armv4:r+value): Use it.
(armv4:r-cmp-value): Use it.
(armv4:r0+value): Use it.
(armv4:byte-r->local+n): Use it.
(armv4:word-r->local+n): Use it.
2020-06-16 21:07:23 +02:00
Danny Milosavljevic 341682f474
ARM: Avoid using (abs INT_MIN) and (- INT_MIN).
* module/mescc/armv4/as.scm (immediate->r0): Inline abs.
(armv4:value->r): Inline abs.
(armv4:local->r): Inline abs.
(armv4:r->local+n): Inline abs.
(armv4:r-byte-mem-add): Inline abs.
(armv4:r-word-mem-add): Inline abs.
(armv4:local-ptr->r): Inline abs.
(armv4:r+value): Inline abs.
(armv4:r-cmp-value): Inline abs.
(armv4:r0+value): Inline abs.
(armv4:byte-r->local+n): Inline abs.
(armv4:word-r->local+n): Inline abs.
2020-06-16 17:31:59 +02:00
Danny Milosavljevic 073cfca2b4
build-aux: Increase test timeout to 20 s. 2020-06-16 14:00:10 +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 3b312ca983
core: Fix unreadchar on string port when unreading EOF.
* src/posix.c (unreadchar): Fix on string port when unreading EOF.
2020-06-14 22:41:31 +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 451274bc80
mescc: Add modules for armv4.
* mes/module/mescc/armv4/as.mes: New file.
* mes/module/mescc/armv4/info.mes: New file.
* mes/module/mescc/mescc.mes: Use them.
2020-06-13 19:07:32 +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
Jan Nieuwenhuizen 40aa190459
guix: mescc-tools: Update to 0.7.0, adding ARM support.
This brings arm-linux-gnueabihf, aarch64-linux-gnu support.

* guix/git/mes.scm (mescc-tools): Update to 0.7.0.
2020-06-10 15:36:18 +02:00
Jan (janneke) Nieuwenhuizen e9672324f3
dir-locals.el: Add indentation for Guix keywords.
* .dir-locals.el (scheme-mode): Add indentation rules for Guix package
definitions.
2020-06-10 15:34:06 +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 70e7232831
doc: Post-release update.
* NEWS: Add v0.22 hash.
* doc/announce/ANNOUNCE-0.22: Add gen-announce checksums; update NEWS,
typos.
2020-06-07 10:49: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
Jan Nieuwenhuizen a44544bae9
guix: mes: Add armhf-linux, aarch64-linux support.
* guix/git/mes.scm (mes): Add armhf-linux, aarch64-linux support.
2020-06-04 21:54:42 +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 d8f5699d76
Add ARM syscall numbers.
* include/linux/arm/syscall.h: New file.
2020-06-03 08:52:10 +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 2b69460894
Prepare header files for ARMv4.
* include/fcntl.h (O_DIRECTORY): Add ARM case.
* include/signal.h (struct sigaction): Add uapi case.
* include/stdint.h: Add ARM case.
* include/sys/stat.h (struct stat): Add ARM case.
2020-06-02 14:37:55 +02:00
Danny Milosavljevic 6183816f83
Support and pass "-marm".
* build-aux/cflags.sh,
build-aux/check.sh.in: Pass "-marm" for ARM.
* module/mescc/mescc.scm: Accept it.
2020-06-02 14:35:16 +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