Commit graph

51 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 93714ad0a4 mescc: Tinycc support: strtoull.
* mlibc/include/mlibc.h (_atoi): Declare.
* mlibc/include/ctype.h (isxdigit): Declare.
* mlibc/libc-gcc.c (isxdigit, _atoi): New function.
  (atoi): Use it.
* mlibc/libc-mes.c (isxdigit, _atoi): New function.
  (atoi): Use it.
* scaffold/tests/7j-strtoull.c (test): Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-19 10:51:24 +02:00
Jan Nieuwenhuizen 70e3e83581 mescc: Tinycc support: snprintf.
* mlibc/include/stdarg.h (vsprintf): Declare.
* mlibc/libc-gcc.c (vsprintf): New function.
  (sprintf): Use it.
* mlibc/libc-mes+tcc.c (snprintf): Implement.
* mlibc/libc-mes.c (vsprintf): New function
  (sprintf): Use it.
2017-08-12 17:38:44 +02:00
Jan Nieuwenhuizen 5230ddc93b mescc: Fix compile warnings.
* mlibc/include/stdio.h (fdputs): Declare.
* mlibc/libc-gcc.c (malloc):
  (memcpy): Fix compile warning.
2017-08-10 21:00:22 +02:00
Jan Nieuwenhuizen e616d6120b mescc: Tinycc support: eputc.
* mlibc/include/stdio.h (eputc): Declare.
* mlibc/libc-gcc.c (eputc):
* mlibc/libc-mes.c (eputc): New function.
2017-08-06 13:53:56 +02:00
Jan Nieuwenhuizen 513180eb2c mescc: Tinycc support: eputs as function for gcc.
* mlibc/libc-gcc.c (eputs)[POSIX]: New function.
* mlibc/include/stdio.h (eputs)[POSIX]: Remove define.
2017-08-06 12:16:34 +02:00
Jan Nieuwenhuizen ce980c8239 mescc: Tinycc support: compile tcc with TCC_IS_NATIVE.
* mlibc/include/string.h (strcat): Declare.
* mlibc/libc-mes+tcc.c (dlclose, dlopen, mprotect, sigaction,
  sigemptyset, strcat, vfprintf): Move from libc-gcc+tcc.c.
* mlibc/libc-gcc+tcc.c: Remove them.
* module/language/c99/compiler.mes (c99-input->full-ast): Define __i386__=1.
  (i386:type-alist): Parse `long long int', `unsigned short int',
  `unsigned long long int'.
  (struct-field): Support void**.
  (init-declr->name):
  (init-declr->pointer): Support function declaration.
2017-07-28 08:07:41 +02:00
Jan Nieuwenhuizen 397d7a6c43 mlibc: Tinycc support: gcc -nostdinc -nostdlib.
* mlibc/libc-gcc+tcc.c: New file.
* mlibc/include/dlfcn.h:
* mlibc/include/errno.h:
* mlibc/include/signal.h:
* mlibc/include/sys/mman.h:
* mlibc/include/sys/time.h:  Add tcc declarations.
2017-07-27 23:44:22 +02:00
Jan Nieuwenhuizen 62e7809725 mescc: Tinycc support: calloc,malloc,realloc.
* mlibc/libc-mes+tcc.c (calloc,malloc,realloc): New function.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 91f9817a44 mescc: Tinycc support: execvp stub.
* mlibc/include/unistd.h (execvp): Declare.
* mlibc/libc-mes+tcc.c (execvp): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 8296c8ec2c mescc: Tinycc support: remove stub.
* mlibc/include/stdio.h (remove): Declare.
* mlibc/libc-mes+tcc.c (remove): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 2914b74aa4 mescc: Tinycc support: fread stub.
* mlibc/include/stdio.h (fread): Declare.
* mlibc/libc-mes+tcc.c (fread): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 47f0ce1d5c mescc: Tinycc support: ftell stub.
* mlibc/include/stdio.h (ftell): Declare.
* mlibc/libc-mes+tcc.c (ftell): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 019994b8ed mescc: Tinycc support: fseek stub.
* mlibc/include/stdio.h (fseek): Declare.
* mlibc/libc-mes+tcc.c (fseek): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 76e97a9b08 mescc: Tinycc support: fopen stub.
* mlibc/include/stdio.h (fopen): Declare.
* mlibc/libc-mes+tcc.c (fopen): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen fd63f744f7 mescc: Tinycc support: strstr stub.
* mlibc/include/string.h (strstr): Declare.
* mlibc/libc-mes+tcc.c (strstr): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen d4e9659d19 mescc: Tinycc support: sscanf stub.
* mlibc/include/stdio.h (sscanf): Declare.
* mlibc/libc-mes+tcc.c (sscanf): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen cd5536b283 mescc: Tinycc support: longjmp, setjump stub.
* mlibc/include/stdarg.h (longjmp, setjmp): Declare.
* mlibc/libc-mes+tcc.c (longjmp, setjmp): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen f711b2f005 mescc: Tinycc support: fflush stub.
* mlibc/include/stdio.h (fflush): Declare.
* mlibc/libc-mes+tcc.c (fflush): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen ff16c5a31f mescc: Tinycc support: vnsprintf stub.
* mlibc/include/stdarg.h (vnsprintf): Declare.
* mlibc/libc-mes+tcc.c (vnsprintf): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 8f2c74c1cb mescc: Tinycc support: free stub.
* mlibc/include/stdlib.h (free): Declare.
* mlibc/libc-mes+tcc.c (free): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 60de51241a mescc: Tinycc support: strrchr stub.
* mlibc/include/string.h (strrchr): Declare.
* mlibc/libc-mes+tcc.c (strrchr): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 9f44c4875a mescc: Tinycc support: strtoll stub.
* mlibc/include/stdlib.h (strtoll): Declare.
* mlibc/libc-mes+tcc.c (strtoll): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen ec335eef50 mescc: Tinycc support: strtoull stub.
* mlibc/include/stdlib.h (strtoull): Declare.
* mlibc/libc-mes+tcc.c (strtoull): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen c749bb5aa3 mescc: Tinycc support: strtol stub.
* mlibc/include/stdlib.h (strtol): Declare.
* mlibc/libc-mes+tcc.c (strtol): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 9f60904d1c mescc: Tinycc support: lseek.
* mlibc/include/unistd.h (lseek): Declare.
* stage0/x86.M1 (SYS_lseek): New define.
* mlibc/libc-mes+tcc.c (lseek): New function.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen a8f22ea993 mescc: Tinycc support: fclose stub.
* mlibc/include/stdio.h (fclose): Declare.
* mlibc/libc-mes+tcc.c (fclose): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen b479d200b3 mescc: Tinycc support: fdopen stub.
* mlibc/include/stdio.h (fdopen): Declare.
* mlibc/libc-mes+tcc.c (fdopen): Add stub.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen 3e39c56f35 mescc: Tinycc support: unlink.
* mlibc/include/unistd.h (unlink): Declare.
* stage0/x86.M1 (SYS_unlink): New define.
* mlibc/libc-mes+tcc.c (unlink): New function.
2017-07-26 11:36:45 +02:00
Jan Nieuwenhuizen b860cb7a17 mescc: Tinycc support: fwrite stub.
* mlibc/include/stdio.h (fwrite): Declare.
* mlibc/libc-mes+tcc.c (fwrite): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 15a9452d33 mescc: Tinycc support: qsort stub.
* mlibc/include/stdlib.h (qsort): Declare.
* mlibc/libc-mes+tcc.c (qsort): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 2d1623c5f0 mescc: Tinycc support: getcwd.
* mlibc/include/unistd.h (getcwd): Declare.
* stage0/x86.M1 (SYS_getcwd): New define.
* mlibc/libc-mes+tcc.c (getcwd): New function.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen ecf0fb50b1 mescc: Tinycc support: strchr stub.
* mlibc/include/string.h (strchr): Declare.
* mlibc/libc-mes+tcc.c (strchr): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 718410e426 mescc: Tinycc support: fprintf stub.
* mlibc/include/stdio.h (fprintf): Declare.
* mlibc/libc-mes+tcc.c (fprintf): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 702a1f9f54 mescc: Tinycc support: localtime stub.
* mlibc/include/time.h (localtime): Declare.
* mlibc/libc-mes+tcc.c (localtime): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen aa297a28a9 mescc: Tinycc support: time stub.
* mlibc/include/time.h (time): Declare.
* mlibc/libc-mes+tcc.c (time): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen beb24d9550 mescc: Tinycc support: snprintf stub.
* mlibc/include/stdio.h (snprintf): Declare.
* mlibc/libc-mes+tcc.c (snprintf): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen ce9f0b12d0 mescc: Tinycc support: strtoul stub.
* mlibc/include/stdlib.h (strtoul): Declare.
* mlibc/libc-mes+tcc.c (strtoul): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 5c338ef705 mescc: Tinycc support: memmove stub.
* mlibc/include/string.h (memcmp): Declare.
* mlibc/libc-mes+tcc.c (memcmp): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 6c7d26fa1c mescc: Tinycc support: memset stub.
* mlibc/include/string.h (memset): Declare.
* mlibc/libc-mes+tcc.c (memset): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 8f7b47ef36 mescc: Tinycc support: memmove stub.
* mlibc/include/string.h (memmove): Declare.
* mlibc/libc-mes+tcc.c (memmove): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 7b8253cd47 mescc: Tinycc support: memcpy stub.
* mlibc/include/string.h (memcpy): Declare.
* mlibc/libc-mes+tcc.c (memcpy): Add stub.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen ba6edad975 mescc: Tinycc support: close.
* stage0/x86.M1 (SYS_close): New define.
* mlibc/include/unistd.h (close): Declare.
* mlibc/libc-mes+tcc.c: New file.
* make.scm: Build and install it.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 5f90fe3919 mescc: Guile eval.c support: headers.
* mlibc/include/signal.h (sigset_t): New type.
* mlibc/include/float.h: New file.
* mlibc/include/stddef.h: New file.
* mlibc/include/sys/select.h: New file.
2017-07-26 11:36:36 +02:00
Jan Nieuwenhuizen eee7f8cb3c mescc: Non-Guix support. Thanks rain1!
* mlibc/include: Neutralize include guards before #include_next.
  Fixes compiling tinycc on Debian GNU/Linux.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 2ab93d7308 mescc: Tinycc support: declare struct tm.
* mlibc/include/time.h (struct tm): New type.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 16b9a21712 mescc: Tinycc support: headers.
* mlibc/include/string.h (ssize_t): New type.
* mlibc/include/unistd.h (ssize_t): New type.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 64db2eaf7d test: Split-up Mescc scaffold test.
* make.scm (check-scaffold, check-scaffold-tests): New targets.
* mlibc/include/00-test.i: New file.
* mlibc/include/30-test.i: New file.
* mlibc/mini-libc-mes.c (puts): New function.
* scaffold/tests/00-exit-0.c: : New file.
* scaffold/tests/01-return-0.c: : New file.
* scaffold/tests/02-return-1.c: : New file.
* scaffold/tests/03-call.c: : New file.
* scaffold/tests/04-call-0.c: : New file.
* scaffold/tests/05-call-1.c: : New file.
* scaffold/tests/06-call-!1.c: : New file.
* scaffold/tests/10-if-0.c: : New file.
* scaffold/tests/11-if-1.c: : New file.
* scaffold/tests/12-if-==.c: : New file.
* scaffold/tests/13-if-!=.c: : New file.
* scaffold/tests/14-if-goto.c: : New file.
* scaffold/tests/15-if-!f.c: : New file.
* scaffold/tests/16-if-t.c: : New file.
* scaffold/tests/20-while.c: : New file.
* scaffold/tests/21-char[].c: : New file.
* scaffold/tests/22-while-char[].c: : New file.
* scaffold/tests/30-strlen.c: : New file.
* scaffold/tests/31-eputs.c: : New file.
* scaffold/tests/32-compare.c: : New file.
* scaffold/tests/33-and-or.c: : New file.
* scaffold/tests/34-pre-post.c: : New file.
* scaffold/tests/35-compare-char.c: : New file.
* scaffold/tests/36-compare-arithmetic.c: : New file.
* scaffold/tests/37-compare-assign.c: : New file.
* scaffold/tests/38-compare-call.c: : New file.
* scaffold/tests/40-if-else.c: : New file.
* scaffold/tests/41-?.c: : New file.
* scaffold/tests/42-goto-label.c: : New file.
* scaffold/tests/43-for-do-while.c: : New file.
* scaffold/tests/44-switch.c: : New file.
* scaffold/tests/45-void-call.c: : New file.
* scaffold/tests/50-assert.c: : New file.
* scaffold/tests/51-strcmp.c: : New file.
* scaffold/tests/52-itoa.c: : New file.
* scaffold/tests/53-strcpy.c: : New file.
* scaffold/tests/54-argv.c: : New file.
* scaffold/tests/60-math.c: : New file.
* scaffold/tests/61-array.c: : New file.
* scaffold/tests/63-struct-cell.c: : New file.
* scaffold/tests/64-make-cell.c: : New file.
* scaffold/tests/65-read.c: : New file.
* scaffold/tests/66-struct-array.c: : New file.
* scaffold/t.c: Remove.
* scaffold/t-tcc.c: Remove.
2017-07-09 09:24:07 +02:00
Jan Nieuwenhuizen ebb15c72a3 mescc: Support stdarg.
* mlibc/include/stdarg.h (va_list): New type.
  (va_start, va_arg, va_end, va_copy): New macro.
  (vprintf): New declaration.
* mlibc/libc-mes.c (vprintf): New function.
  (printf): Rewrite using vprintf.
* module/language/c99/compiler.mes (expr->accu, expr->accu*): Handle
  any array.  Limitation: element size must be 4/sizeof (expression).
  (make-type): Add value pointer to type.
  (type:type, type:size, type:pointer, type:description): New functions.
  (ast->info): Handle typedef with pointer.
2017-07-05 18:48:08 +02:00
Jan Nieuwenhuizen 03ecebd594 mescc: Add headers for guile:eval.c.
* mlibc/include/alloca.h: New file.
* mlibc/include/stdint.h: New file.
* mlibc/include/inttypes.h: Remove definitionss, include stdint.h.
2017-06-18 17:54:33 +02:00
Jan Nieuwenhuizen cf7211e8a7 mescc: Add headers for 8cc.
* mlibc/include/libgen.h: New file.
* mlibc/include/locale.hh: New file.
* mlibc/include/stdbool.h: New file.
* mlibc/include/stdnoreturn.h: New file.
* mlibc/include/time.h: Add time_t.
2017-06-18 16:12:15 +02:00