Commit Graph

1890 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 1a114238c5
mescc: Mes C Library: Support gcc-4.6.4: vfprintf, vsnprintf: #-type.
* lib/stdio/vfprintf.c (vfprintf): Support #-type prefix.  Show whole
format upon error.
* lib/stdio/vsnprintf.c (vsnprintf): Likewise.
* lib/stdio/vfscanf.c (vfscanf): Show whole template upon error.
* lib/stdio/vsscanf.c (vsscanf): Likewise.
2019-09-09 18:34:26 +02:00
Jan Nieuwenhuizen fa1805b5e5
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-09 18:34:26 +02:00
Jan Nieuwenhuizen ce8debec54
mescc: Mes C Library: Support gcc-4.6.4: atexit: return 0.
* lib/stdlib/atexit.c (atexit): return 0.
2019-09-09 18:34:26 +02:00
Jan Nieuwenhuizen 4730386dc1
mescc: Mes C Library: Support gcc-4.6.4: Add SSIZE_MAX macro.
* include/stdint.h (SSIZE_MAX): New macro.
2019-09-09 18:34:25 +02:00
Jan Nieuwenhuizen 33729bf3f7
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-09 18:34:25 +02:00
Jan Nieuwenhuizen e2d6d83241
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/libc+gnu.c: Include them.
* lib/libg.c: Likewise.
* lib/stub/fscanf.c: Remove.
2019-09-09 18:34:25 +02:00
Jan Nieuwenhuizen 9b1fbe03ec
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-09 18:34:25 +02:00
Jan Nieuwenhuizen a127b1d6e8
mescc: Mes C Library: Support gcc-4.6.4: Add float macros.
* include/float.h (DBL_EPSILON, DBL_MANT_DIG, DBL_MAX, DBL_MIN,
FLT_RADIX, LDBL_EPSILON, LDBL_MANT_DIG, LDBL_MAX, LDBL_MIN): New
macro.
2019-09-09 18:34:25 +02:00
Jan Nieuwenhuizen 8303a676a1
mescc: Mes C Library: Support gcc-4.6.4: Add stdint [U]SHRT macros.
* include/stdint.h (SHRT_MAX, SHRT_MIN, USHRT_MAX, USHRT_MIN): New
macro.
2019-09-09 18:34:25 +02:00
Jan Nieuwenhuizen 471f47273e
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-09-09 18:34:24 +02:00
Jan Nieuwenhuizen feefb06512
mescc: Mes C Library: Support gcc-4.6.4: Fix uintptr_t, add [u]intmax_t.
* include/stdint.h: Fix uintptr_t, add [u]intmax_t.
2019-09-09 18:34:24 +02:00
Jan Nieuwenhuizen c87b1442c0
mescc: Mes C Library: vsscanf: Increase count for scanned float.
* lib/stdio/vsscanf.c (vsscanf): Increase count for scanned float.
2019-09-09 18:34:24 +02:00
Jan Nieuwenhuizen 7517ece940
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-09-09 18:34:24 +02:00
Jan Nieuwenhuizen 596672c828
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-09-09 18:34:24 +02:00
Jan Nieuwenhuizen 369f956465
mescc: Mes C Library: Support GNU Awk: Add wchar_t.
* include/sys/types.h (wchar_t): New typedef.
2019-09-09 18:34:24 +02:00
Jan Nieuwenhuizen b3ac30ba4b
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-09-09 18:34:24 +02:00
Jan Nieuwenhuizen c9204413a9
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-09-09 18:34:23 +02:00
Jan Nieuwenhuizen 88c1f05838
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-09-09 18:34:23 +02:00
Jan Nieuwenhuizen 2cbe8c7b75
mescc: Mes C Library: Support GNU Tar: Add missing defines.
* include/errno.h (ENXIO): New macro.
* include/sys/stat.h (S_IFIFO, S_ISFIFO): New macro.
2019-09-09 18:34:23 +02:00
Jan Nieuwenhuizen 8e521aae10
mescc: Mes C Library: Support GNU Bash: Add struct winsize.
* include/termio.h (struct winsize): New type.
2019-09-09 18:34:23 +02:00
Jan Nieuwenhuizen abb8718ee2
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-09-09 18:34:23 +02:00
Jan Nieuwenhuizen d5b860603e
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-09-09 18:34:23 +02:00
Jan Nieuwenhuizen b89b61a0bb
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-09-09 18:34:23 +02:00
Jan Nieuwenhuizen 8fbf0c992a
mescc: Mes C Library: Support GNU Awk: vsscanf: Support %f.
* lib/stdio/vsscanf.c (vsscanf): Support %f.
2019-09-09 18:34:22 +02:00
Jan Nieuwenhuizen 88bec31aa6
mescc: Mes C Library: Support GNU Awk: Do not flush std files.
* lib/stdio/fflush.c (fflush): Do not flush std files.
2019-09-09 18:34:22 +02:00
Jan Nieuwenhuizen 8574f85a5f
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-09-09 18:34:22 +02:00
Jan Nieuwenhuizen 38e15f4e46
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-09-09 18:34:22 +02:00
Jan Nieuwenhuizen 15e63126e7
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-09-09 18:34:22 +02:00
Jan Nieuwenhuizen 703876b609
mescc: Mes C Library: Fix compile warnings.
* include/stdlib.h (abort): Add prototype.
2019-09-09 18:34:22 +02:00
Danny Milosavljevic b956dc152c
ARM: Fix argc, argv and envp handling.
* lib/linux/arm-mes-mescc/crt1.c (_start): Fix argc, argv and envp handling.
* lib/arm-mes/arm.M1 (add____%r2,%r0,%r1,lsl#2): Add macro.
(add____%r2,%r0,%r1,lsl#4): Delete macro.
(add____%r2,%r1,%r0,lsl#2): Add macro.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic 233bcf75ea
ARM: Add macro "ldrh___%r0,(%r1)".
* lib/arm-mes/arm.M1 (ldrh___%r0,(%r1)): Add macro.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic 499da86c70
ARM: Add macro "strh___%r0,(%fp,-#$i8)".
* lib/arm-mes/arm.M1 (strh___%r0,(%fp,-#$i8)): Add macro.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic ea99d36af5
ARM: Fix encoding of "mov____0x32(%ebp),%r1", "mov____0x32(%ebp),%r0", "xchg___%r0,(%esp)" pseudo-instructions.
* lib/arm-mes/arm.M1 (mov____0x32(%ebp),%r1): Modify.
(mov____0x32(%ebp),%r0): Modify.
(xchg___%r0,(%esp)): Modify.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic c7bfc1de36
ARM: Fix strh sign handling.
* module/mescc/armv4/as.scm (armv4:word-r->local+n): Fix strh sign handling.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic f9a6e1aed0
ARM: Add macro "strh___%r0,(%fp,+#$i8)".
* lib/arm-mes/arm.M1 (strh___%r0,(%fp,+#$i8)): New macro.
2019-09-09 18:34:07 +02:00
Danny Milosavljevic 0e2d6b4b84
ARM: Add macro "sxth__%r1,%r1".
* lib/arm-mes/arm.M1 (sxth__%r1,%r1): New macro.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic 0d60769ea4
ARM: Add "strh___%r0,(%r1)" macro.
* lib/arm-mes/arm.M1 (strh___%r0,(%r1)): New macro.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic 5874b709b8
ARM: Add __sys_call6, _sys_call6.
* lib/linux/arm-mes-mescc/syscall.c (__sys_call6): New procedure.
(_sys_call6): New procedure.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic 371e11fd9e
ARM: Fix add____$i32,(%r0).
* lib/arm-mes/arm.M1 (add____$i32,(%r0)): Fix it.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic 810d063d36
ARM: Use %fp in _start.
* lib/linux/arm-mes-mescc/crt1.c (_start): Use %fp instead of %sp.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic d0e05a4a80
ARM: If "ADD"'s immediate is less than 0, subtract.
* lib/arm-mes/arm.M1 (sub____$i8,%r0): New macro.
(sub____$i8,%r1): New macro.
* module/mescc/armv4/as.scm (armv4:call-label): Add comment.
(armv4:r-byte-mem-add): Subtract if value is negative.
(armv4:r-word-mem-add): Subtract if value is negative.
(armv4:local-ptr->r): Subtract if value is negative.
(armv4:r+value): Subtract if value is negative.
(armv4:r0+value): Subtract if value is negative.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic 20d0e0d950
ARM: Fix loads.
Follow-up to 7e40a92732c3035003ae779022e5beaf6562375f.

* lib/arm-mes-mescc/setjmp.c (longjmp): Disable.
* lib/linux/arm-mes-mescc/mini.c (_exit): Use ldr.
(_write): Use ldr.
* lib/linux/arm-mes-mescc/syscall.c (__sys_call): Use ldr.
(__sys_call1): Use ldr.
(__sys_call2): Use ldr.
(__sys_call3): Use ldr.
(__sys_call4): Use ldr.
2019-09-09 18:34:06 +02:00
Danny Milosavljevic 6fbead7479
ARM: Clean up comments.
* lib/arm-mes/arm.M1: Clean up comments.
2019-09-09 18:34:05 +02:00
Jan Nieuwenhuizen fb3f34b04f
Revert "Work around nyacc #define parsing/evaluation bug."
This reverts commit 7e8dfb474340b2fd809ee54e4d816b4a4275364d.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic b9b744001a
ARM: Fix storing bytes in the stack frame.
* lib/arm-mes/arm.M1 (strb___%r0,0x8(%ebp)): Rename to...
(strb___%r0,(%fp,+#$i8)): ... this.
(strb___%r0,(%fp,-#$i8)): New macro.
* module/mescc/armv4/as.scm (armv4:byte-r->local+n): Use them.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic cf0c7db11f
ARM: Fix handling of negative offsets in load/store instructions.
* lib/arm-mes/arm.M1 (ldr____%r0,(%fp,+#$i8)): New macro.
(ldr____%r1,(%fp,+#$i8)): New macro.
(ldr____%r2,(%fp,+#$i8)): New macro.
(ldr____%r3,(%fp,+#$i8)): New macro.
(ldr____%r4,(%fp,+#$i8)): New macro.
(ldr____%r5,(%fp,+#$i8)): New macro.
(ldr____%r7,(%fp,+#$i8)): New macro.
(ldr____%fp,(%fp,+#$i8)): New macro.
(ldr____%sp,(%fp,+#$i8)): New macro.
(ldr____%r0,(%fp,-#$i8)): New macro.
(ldr____%r1,(%fp,-#$i8)): New macro.
(ldr____%r2,(%fp,-#$i8)): New macro.
(ldr____%r3,(%fp,-#$i8)): New macro.
(ldr____%r4,(%fp,-#$i8)): New macro.
(ldr____%r5,(%fp,-#$i8)): New macro.
(ldr____%r7,(%fp,-#$i8)): New macro.
(ldr____%fp,(%fp,-#$i8)): New macro.
(ldr____%sp,(%fp,-#$i8)): New macro.
(str____%r0,(%fp,+#$i8)): New macro.
(str____%r1,(%fp,+#$i8)): New macro.
(str____%r2,(%fp,+#$i8)): New macro.
(str____%r3,(%fp,+#$i8)): New macro.
(str____%r4,(%fp,+#$i8)): New macro.
(str____%r5,(%fp,+#$i8)): New macro.
(str____%r7,(%fp,+#$i8)): New macro.
(str____%fp,(%fp,+#$i8)): New macro.
(str____%sp,(%fp,+#$i8)): New macro.
(str____%r0,(%fp,-#$i8)): New macro.
(str____%r1,(%fp,-#$i8)): New macro.
(str____%r2,(%fp,-#$i8)): New macro.
(str____%r3,(%fp,-#$i8)): New macro.
(str____%r4,(%fp,-#$i8)): New macro.
(str____%r5,(%fp,-#$i8)): New macro.
(str____%r7,(%fp,-#$i8)): New macro.
(str____%fp,(%fp,-#$i8)): New macro.
(str____%sp,(%fp,-#$i8)): New macro.
(mov____%r0,0x8(%ebp)): Delete macro.
(mov____%r1,0x8(%ebp)): Delete macro.
(mov____%r2,0x8(%ebp)): Delete macro.
(mov____%r3,0x8(%ebp)): Delete macro.
(mov____%r4,0x8(%ebp)): Delete macro.
(mov____%r5,0x8(%ebp)): Delete macro.
(mov____%r7,0x8(%ebp)): Delete macro.
(mov____0x8(%ebp),%r0): Delete macro.
(mov____0x8(%ebp),%r1): Delete macro.
(mov____0x8(%ebp),%r2): Delete macro.
(mov____0x8(%ebp),%r3): Delete macro.
(mov____0x8(%ebp),%r4): Delete macro.
(mov____0x8(%ebp),%r5): Delete macro.
(mov____0x8(%ebp),%r7): Delete macro.
(mov____0x8(%ebp),%ebp): Delete macro.
(mov____0x8(%ebp),%esp): Delete macro.
* module/mescc/armv4/as.scm (armv4:local->r): Use them.
(armv4:r->local+n): Use them.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic a3988658ed
Add missing #include.
* lib/arm-mes-mescc/setjmp.c: Add missing #include.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic 105cf743ff
ARM: Support negative values as immediate.
* lib/arm-mes/arm.M1 (mvn____%r0,$i8): New macro.
(mvn____%r1,$i8): New macro.
(mvn____%r7,$i8): New macro.
* module/mescc/armv4/as.scm (immediate->r0): Use it.
(armv4:value->r): Use it.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic b82a2f1fad
ARM: Make "ret" macro do the right thing.
* lib/arm-mes/arm.M1 (ret): Make it do the right thing.
2019-09-09 18:34:05 +02:00
Danny Milosavljevic 92022f95ff
Work around nyacc #define parsing/evaluation bug.
* lib/linux/time.c: Use "#if defined" instead of "#if".
2019-09-09 18:34:04 +02:00