Jan Nieuwenhuizen
a9215931e8
mescc: Support binutils 2.15a: fread: read ungetc'd chars too.
...
* lib/libmes.c (_ungetc_fd): New variable.
(fdgetc): Use it.
(_fdungetc_p): New function.
* lib/libc+tcc.c (_fungetc_p): New function.
* lib/libc+tcc.c (fread): Use it to read ungetc'd chars too.
2018-06-16 20:51:16 +02:00
Jan Nieuwenhuizen
65d530f4ec
mescc: Support binutils-2.14: fopen: Return 0 upon failure.
...
* lib/libc+tcc.c (fopen): Return 0 upon failure.
2018-06-16 10:54:59 +02:00
Jan Nieuwenhuizen
125b43acc8
mescc: Update elf32-header for linux-4.17.
...
Previously, our binaries showed this
$ readelf -s scaffold/main.mes-out
There are 2 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x01000000 0x01000000 0x0557c 0x0557c RWE 0x1
LOAD 0x000000 0x01000000 0x01000000 0x0557c 0x0557c RWE 0x1
Section to Segment mapping:
Segment Sections...
00 .text .data
01 .text .data
Linux-4.17 refuses to run this and says
Uhuuh, elf segment at 0000000001000000 requested but the memory is mapped already
Segmentation fault
* lib/x86-mes/elf32-header.hex2: Remove unused data program header.
2018-06-16 08:32:12 +02:00
Jan Nieuwenhuizen
c086f67cec
mescc: Support less-patched tcc/gcc: Add crti and crtn.
...
* lib/crt0.c[__MESC__]: Support MesCC.
* lib/crti.c: New file.
* lib/crtn.c: New file.
* build-aux/build-mes-gcc.sh: Build them.
2018-06-10 16:03:18 +02:00
Jan Nieuwenhuizen
c2c3554884
mescc: Refactor debug and stub printing.
...
* lib/libc.c (__mes_debug): New function. Use it for debug printing
and in stubs throughout.
2018-06-10 14:07:19 +02:00
Jan Nieuwenhuizen
18194b1ae4
mescc: Support binutils-2.30: fopen fix.
...
* lib/libc+tcc.c (fopen): Set O_APPEND for 'a'.
2018-06-10 13:33:30 +02:00
Jan Nieuwenhuizen
c349f6fdd8
mescc: Support binutils-2.30.
...
* lib/binutils.c (raise, strdup): New function.
(mbstowcs): New stub.
* include/fcntl.h (O_APPEND, FD_CLOEXEC): New define.
2018-06-09 17:58:47 +02:00
Jan Nieuwenhuizen
53dd76ffc0
mescc: Support binutils-2.10.1: Stubs set errno to 0.
2018-06-09 11:28:31 +02:00
Jan Nieuwenhuizen
bb3353a272
mescc: Silence some stubs.
...
* lib/libc+tcc.c: [!NOISY_FLOATS, !NOISY_TIMES]: Silence stubs.
* lib/gcc.c: Likewise.
* lib/binutils.c: Likewise.
2018-06-09 07:40:07 +02:00
Jan Nieuwenhuizen
a744fd9ba4
mescc: Add debug printing: fopen, fwrite.
...
* lib/libc+tcc.c (fopen, fwrite)[MESC_DEBUG]: Print debug info.
2018-06-10 07:51:56 +02:00
Jan Nieuwenhuizen
3ba5b23dab
mescc: Support binutils-2.10.1: opentype `r+'.
...
* lib/libc+tcc.c (fopen): Support opentype `r+'.
2018-06-10 07:51:10 +02:00
Jan Nieuwenhuizen
831bd71a14
mescc: syscall: return only ever error -1, set errno.
2018-06-08 07:17:51 +02:00
Jan Nieuwenhuizen
b7d913d7a0
mescc: Support gcc-2.95: Add getpwnam stub.
...
* lib/gcc.c (getpwnam): New stub.
2018-06-07 18:04:17 +02:00
Jan Nieuwenhuizen
a70bc92857
mescc: Support gcc-3.0: Implement alarm, setitimer.
2018-06-07 18:03:51 +02:00
Jan Nieuwenhuizen
ef0a39547c
mescc: Support gcc-3.0: Implement atexit.
2018-06-07 18:02:21 +02:00
Jan Nieuwenhuizen
93cb6375ae
mescc: Support gcc-3.0: Implement dup2, fcntl, getrusage.
...
* include/sys/resource.h: New file.
* lib/linux+gnu.c (fcntl, dup2, getrusage): New function.
* lib/binutils.c (fcntl): Remove stub.
2018-06-07 08:02:32 +02:00
Jan Nieuwenhuizen
b7c35dad69
mescc: Support gcc-3.2: Implement getuid, getgid.
...
* lib/linux+gnu.c (getuid, getdid): New function.
* lib/binutils.c (getuid, getdid): Remove stub.
2018-06-07 07:19:01 +02:00
Jan Nieuwenhuizen
d1e3a786aa
mescc: Support gcc-3.2: Reset errno.
...
* lib/linux-gcc.c (_sys_call, _sys_call1, _sys_call2, _sys_call3):
Reset errno.
* lib/linux-mes.c (__sys_call, __sys_call1, __sys_call2 ,
__sys_call3): Rename from _*.
(_sys_call, _sys_call1, _sys_call2, _sys_call3): New function.
Reset errno.
2018-06-07 07:16:43 +02:00
Jan Nieuwenhuizen
cc466662b9
mescc: Support gcc-3.2: Implement integer strto*.
...
* lib/libc+tcc.c (strtoll, strtoul): Call strtoul.
2018-06-06 22:39:57 +02:00
Jan Nieuwenhuizen
04302b3fe4
mescc: Support gcc-3.2: Add getpid, signal.
...
* lib/linux+gnu.c (getpid, signal): New function.
* include/signal.h: Declare signal.
* include/unistd.h: Declare getpid.
* scaffold/tests/95-signal.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-06-06 22:14:35 +02:00
Jan Nieuwenhuizen
7c4a6a88ed
mescc: Support gcc-3.4.0: *printf: Support `%n'.
...
* lib/libc+tcc.c (vfprintf, vsprintf): Support `%n'. For Gcc 3.4.0.
* scaffold/tests/70-printf.c: Test it.
2018-06-06 19:29:32 +02:00
Jan Nieuwenhuizen
f4616dfef1
mescc: Support gcc-3.4.0: alloca.
...
* lib/alloca.c: New file.
* AUTHORS: Mention it.
* lib/libc+gnu.c: Add it.
* include/stdlib.h: Declare alloca.
2018-06-06 19:44:29 +02:00
Jan Nieuwenhuizen
f60cac6e1d
mescc: Support gcc-3.4.0: unsetenv.
...
* lib/gcc.c (unsetenv): New function.
2018-06-06 19:43:32 +02:00
Jan Nieuwenhuizen
4f6f79973e
mescc: Support gcc-3.2: Add __divdi3, __moddi3 stubs.
...
* lib/gcc.c (__divdi3, __moddi3): New stubs.
2018-06-06 17:02:01 +02:00
Jan Nieuwenhuizen
0f3856f7b4
mescc: Support gcc-3.2: puts with newline.
...
* lib/libc-mini.c (oputs): Rename from puts.
(puts): New function: Add newline.
2018-06-06 15:55:03 +02:00
Jan Nieuwenhuizen
eb939b11b8
mescc: Support binutils-2.10.1.
...
xx
2018-06-06 13:16:25 +02:00
Jan Nieuwenhuizen
635dfd03a2
mescc: Support glibc-1.06.4.
...
* lib/glibc.c: New file.
* lib/libc+gnu.c: Include it.
2018-06-03 18:54:26 +02:00
Jan Nieuwenhuizen
de964f3e1f
mescc: Support gcc-2.6.3.
...
* TODO
2018-06-02 11:41:06 +02:00
Jan Nieuwenhuizen
f1efaa0e93
mescc: Support binutils-2.5.1.
...
* include/stdint.h: #undef types before typedef'ing them.
* include/sys/types.h: Likewise.
* include/string.h (NULL): New define.
* include/stdio.h (BUFSIZ): New define.
2018-05-30 21:55:39 +02:00
Jan Nieuwenhuizen
a3a3654d54
mescc: Implement fflush, sscanf, vsscanf.
...
* lib/libc+tcc.c (vsscanf): New function.
(sscanf): Use it.
(fflush): Remove stub notice; we have no buffering.
* include/stdarg.h: Declare it.
* scaffold/tests/87-sscanf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-05-30 21:49:40 +02:00
Jan Nieuwenhuizen
272b522962
build: Use arch-dir.
...
* lib/x86-mes: Move from stage0.
* build-aux/build-cc.sh: Create libraries in lib/gcc. Update users.
* build-aux/build-mes.sh: Create libraries in lib/x86-mes. Update users.
* build-aux/build-mes-gcc.sh: Rename from build-mlibc.sh. Create
libraries in lib/x86-mes-gcc. Update callers.
* build-aux/cc-mes-gcc.sh: Rename from cc-mlibc.sh. Update callers.
2018-05-29 20:07:46 +02:00
Jan Nieuwenhuizen
9f90960392
mlibc: Implement strstr.
...
* lib/libc+tcc.c (_memmem, memmem): New function. Import from GNU
LilyPond.
(strstr): Implement using memmem.
* include/string.h (_memmem, memmem): Declare.
* AUTHORS: Add Han-Wen Nienhuys.
2018-05-29 19:35:20 +02:00
Jan Nieuwenhuizen
26e1876d12
mlibc: Implement ftell, fseek.
...
* lib/libc+tcc.c (ftell, fseek): Implement.
2018-05-29 19:33:32 +02:00
Jan Nieuwenhuizen
2cda87257a
mlibc: Cleanup.
2018-05-29 18:15:22 +02:00
Jan Nieuwenhuizen
559699969c
mescc: m4 support: WIP
2018-05-27 10:28:30 +02:00
Jan Nieuwenhuizen
a10c48735d
mescc: Posixify interface.
...
* module/mescc/compile.mes: Move from language/c99/compiler.mes.
* module/mescc: New module..
* module/mescc/M1.scm: Move from mes/M1.mes.
* module/mescc/as.scm: Likewise.
* module/mescc/bytevectors.scm: Likewise.
* module/mescc/mescc.scm: New file.
* scripts/mescc: Update to new layout and posixy interface.
* GNUmakefile: Likewise.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-mlibc.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc-mlibc.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/test.sh: Likewise.
* build.sh: Likewise.
* .gitignore: Update for posixy extensions.
2018-05-25 08:05:02 +02:00
Jan Nieuwenhuizen
e4d0298d1b
core: Support fork, waitpid, execve.
...
* stage0/x86.M1 (SYS_fork, SYS_waitpid, SYS_execve): New define.
* lib/linux-gcc.c (fork, waitpid, execve): New function.
* lib/linux-mes.c (fork, waitpid, execve): New function.
* lib/libc.c (wait): New function.
* include/unistd.h (fork, execve): Declare.
* include/sys/wait.h (waitpid, wait): Declare.
* module/mes/posix.mes (search-path, execlp, system*, waitpid): New function.
* src/posix.c (primitive_fork, execl): New function.
2018-05-24 19:54:42 +02:00
Jeremiah Orians
43a74e382a
mescc: Add fopen.
...
* lib/libc+tcc.c (fopen)[!POSIX]: Remove stub.
* lib/libc.c (fopen)[!POSIX]: New function.
* AUTHORS: Add Jeremiah.
2018-05-26 16:33:00 -04:00
Jan Nieuwenhuizen
948fbf9743
mescc: Tinycc support: strncpy.
...
* lib/libc+tcc.c (strncpy): New function.
* scaffold/tests/86-strncpy.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
* build-aux/cc-mlibc.sh (LIBC): Acknowlegde.
* build-aux/test.sh (LIBC): Export it.
2018-05-20 10:55:44 +02:00
Jan Nieuwenhuizen
8f1a26b40a
tinycc: Add stubs: __fixdfdi, __fixxfdi, __fixsfdi.
...
* lib/libc+tcc-gcc.c (__fixdfdi, __fixxfdi, __fixsfdi): New stub.
2018-05-21 08:43:58 +02:00
Jan Nieuwenhuizen
b9b6e17141
tinycc: Add stubs: __floatundixf __fixunsxfdi.
...
* lib/libc+tcc-gcc.c (__floatundixf, __fixunsxfdi): New stub.
2018-05-20 10:38:13 +02:00
Jan Nieuwenhuizen
1dedd0ebca
mescc: Fix itoa.
...
* lib/libc.c (itoa): Use function-static buffer. Increase to 12 to
handle INT_MIN.
(itoab): Likewise.
2018-05-20 08:33:06 +02:00
Jan Nieuwenhuizen
cfda148e1e
mescc: Tinycc support: Minimal float support.
...
* lib/libc+tcc.c (ldexp, strtod, strtof, strtold): New stub.
* include/math.h (ldexp): Declare.
* include/stdlib.h (strtod, strtof, strtold): Declare.
* module/mes/scm.mes (string->number): Minimal float support.
(inexact->exact): New function.
* tests/math.test ("string->number"): Test it.
* module/language/c99/compiler.mes (ast->type): Handle float type.
(type->info): Likewise.
(cstring->int): Rename from cstring->number. Update callers.
(cstring->float): New function.
(expr->accu): Use it.
2018-05-18 15:28:05 +02:00
Jan Nieuwenhuizen
8c6e41d92d
mescc: Tinycc support: Add __lshrdi3, __ashldi3, __ashrdi3.
...
* lib/libc+tcc-gcc.c (__lshrdi3, __ashldi3, __ashrdi3): New function.
2018-05-14 22:36:14 +02:00
Jan Nieuwenhuizen
0ba240a4e0
build: Build mini-libc and libc+tcc-gcc too.
...
* include/getopt.h[__GNUC__ && POSIX]: Only use include_next.
* lib/libc+tcc-gcc.c[POSIX](longjmp, setjmp, __udivdi3, __umoddi3):
Remove.
* build-aux/build-cc.sh: Build mini-libc-gcc and libc+tcc-gcc too.
* build-aux/build-mlibc.sh: Build mini-libc-gcc too.
2018-05-23 18:41:57 +02:00
Jan Nieuwenhuizen
865e72ae8a
core: Fix compile warnings.
...
* src/posix.c: Include sys/stat.h.
(chmod): Return cell_unspecified.
* include/stdlib.h: Typo.
2018-04-29 12:02:23 +02:00
Jan Nieuwenhuizen
bb45012c39
mes: Add isatty?.
...
* src/posix.c (isatty_p): New function.
2018-04-22 11:48:38 +02:00
Jan Nieuwenhuizen
ece39a9a18
mlibc: Add isatty.
...
* lib/libc.c (isatty): New function.
* include/unistd.h: Declare it.
2018-04-22 11:47:44 +02:00
Jan Nieuwenhuizen
979406f3a6
mlibc: Add ioctl.
...
* stage0/x86.M1 (SYS_ioctl): New define.
* lib/linux-mes.c (ioctl): New syscall.
* lib/linux-gcc.c (ioctl): New syscall.
* include/sys/ioctl.h: New file.
2018-04-22 11:42:47 +02:00
Jan Nieuwenhuizen
7cad0671f3
Revert "mlibc: Use memmove in realloc."
...
This reverts commit f47a21e3cb4814c4a30d10ff59e5c947441725e9.
2018-04-21 13:42:16 +02:00