Commit Graph

1898 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 7c91edf610
mescc: Mes C Library: Support gcc-4.6.4: vsscanf: Support *, [, s.
* lib/stdio/vsscanf.c (vsscanf): Support  *, [, s.
* lib/stdio/vfscanf.c (vfscanf): Likewise.
* lib/tests/stdio/90-sscanf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
* lib/x86-mes/x86.M1 (mov____%al,0x32(%ebp): New macro.
2019-09-09 18:34:27 +02:00
Jan Nieuwenhuizen b429c4c4d4
mescc: Mes C Library: Support gcc-4.6.4: Allow larger qsort entries.
* lib/stdlib/qsort.c (qswap): Increase buffer to 128 bytes (gmp needs
36) and add assert.
2019-09-09 18:34:27 +02:00
Jan Nieuwenhuizen 225baf2527
mescc: Mes C Library: Support gcc-4.6.4: Avoid type/size_t conflicts.
* include/alloca.h: Remove typedefs, include sys/types.h.
* include/stdint.h: Likewise.
* include/string.h: Likewise.
2019-09-09 18:34:27 +02:00
Jan Nieuwenhuizen 4fe93e4acc
mescc: Mes C Library: Support gcc-4.6.4: Add strtok.
* include/string.h (strtok): Declare.
* lib/string/strtok.c (strtok): New file.
* lib/libc+gnu.c: Include it.
2019-09-09 18:34:27 +02:00
Jan Nieuwenhuizen 4e89d924e2
mescc: Mes C Library: Support gcc-4.6.4: Add mmap, munmap.
* include/linux/x86/syscall.h (SYS_mmap, SYS_munmap): New macro.
* include/linux/x86_64/syscall.h (SYS_mmap, SYS_munmap): New macro.
* include/sys/mman.h (MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS,
MAP_POPULATE, MAP_ANON, MAP_FAILED): New macro.
(mmap, munmap): Declare.
* lib/linux/x86-mes-gcc/mes.c (_sys_call6): New function.
* lib/linux/x86-mes/mes.c (__sys_call6): New function.
(_sys_call6): New function.
* lib/linux/x86_64-mes-gcc/mes.c (_sys_call6): New function.
* lib/linux/x86_64-mes/mes.c (__sys_call): Cater for 6 syscall parameters.
(_sys_call6): New function.
* lib/x86-mes/x86.M1 (pop____%ebp): New macro.
* lib/x86_64-mes/x86_64.M1 (mov____0x8(%rbp),%r9): New macro.
* lib/linux/mmap.c: New file.
* lib/linux/munmap.c: New file.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Add them.
2019-09-09 18:34:26 +02:00
Jan Nieuwenhuizen 717a231908
mescc: Mes C Library: Support gcc-4.6.4: Add labs.
* lib/math/labs.c: New file.
* lib/libc+gnu.c: Include it.
* include/math.h (labs): Declare.
2019-09-09 18:34:26 +02:00
Jan Nieuwenhuizen 2ecf24880c
mescc: Mes C Library: Support gcc-4.6.4: Implement rewind.
* lib/stdio/rewind.c: Move from ../stub.  Implement.
* include/stdio.h (rewind): Declare.
* lib/libc+gnu.c: Update include.
* lib/libg.c: Update include.
* lib/stub/rewind.c: Remove.
2019-09-09 18:34:26 +02:00
Jan Nieuwenhuizen aca93122e3
mescc: Mes C Library: Support gcc-4.6.4: Add asctime stub.
* lib/stub/asctime.c: New file.
* lib/libc+gnu.c: Include it.
* include/time.h (asctime): Declare.
2019-09-09 18:34:26 +02:00
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