mes.git
2 years agomescc: Tinycc support: memmove.
Jan Nieuwenhuizen [Sun, 30 Jul 2017 11:59:06 +0000 (13:59 +0200)]
mescc: Tinycc support: memmove.

* mlibc/libc-mes+tcc.c (memmove): Implement.

2 years agomescc: Tinycc support: strrchr.
Jan Nieuwenhuizen [Sun, 30 Jul 2017 11:09:19 +0000 (13:09 +0200)]
mescc: Tinycc support: strrchr.

* mlibc/libc-mes+tcc.c (strrchr): Implement.

2 years agomescc: Tinycc support: strchr.
Jan Nieuwenhuizen [Sun, 30 Jul 2017 10:55:58 +0000 (12:55 +0200)]
mescc: Tinycc support: strchr.

* mlibc/libc-mes+tcc.c (strchr): Implement.

2 years agomescc: Tinycc support: noisy stubs.
Jan Nieuwenhuizen [Thu, 27 Jul 2017 16:53:44 +0000 (18:53 +0200)]
mescc: Tinycc support: noisy stubs.

* mlibc/libc-mes+tcc.c: Noisy stubs.

2 years agomescc: Tinycc support: int foo[bar] = {baz,...}.
Jan Nieuwenhuizen [Sun, 30 Jul 2017 06:27:05 +0000 (08:27 +0200)]
mescc: Tinycc support: int foo[bar] = {baz,...}.

* scaffold/tests/79-int-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
* module/language/c99/compiler.mes (init-declr->count): New function.
  (decl->info): Support int foo[bar] = {baz,...}.

2 years agomescc: Tinycc support: union.struct.
Jan Nieuwenhuizen [Sat, 29 Jul 2017 20:50:00 +0000 (22:50 +0200)]
mescc: Tinycc support: union.struct.

* module/language/c99/compiler.mes (decl->info): Support struct inside union.
* scaffold/tests/78-union-struct.c: Test it.
* make.scm (add-scaffold-test): Build it.

2 years agomescc: Tinycc support: fix accu value after comparison.
Jan Nieuwenhuizen [Sat, 29 Jul 2017 18:46:16 +0000 (20:46 +0200)]
mescc: Tinycc support: fix accu value after comparison.

* stage0/x86.M1 (setg___%al,, setge__%al, setl___%al, setle__%al): New
  defines.
* module/mes/as-i386.mes (i386:g?->accu, i386:ge?->accu,
  i386:l?->accu, i386:le?->accu, i386:jumpl, i386:jumple): New functions.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Use them to fix accu
  value after comparisons.
  (test-jump-label->info): Update comparison jumps.

2 years agomescc: Tinycc support: memcmp.
Jan Nieuwenhuizen [Sat, 29 Jul 2017 09:09:00 +0000 (11:09 +0200)]
mescc: Tinycc support: memcmp.

* mlibc/libc-mes+tcc.c (memcmp): Implement.

2 years agomescc: Tinycc support: bugfix *++foo,*--foo.
Jan Nieuwenhuizen [Sat, 29 Jul 2017 08:45:16 +0000 (10:45 +0200)]
mescc: Tinycc support: bugfix *++foo,*--foo.

* module/language/c99/compiler.mes (c99-input->full-ast): Pre-define NULL.
  (expr->pointer, expr->size): Handle pre/post-inc/dec.

2 years agomescc: Tinycc support: uniquify strings per compilation unit.
Jan Nieuwenhuizen [Sat, 29 Jul 2017 07:08:44 +0000 (09:08 +0200)]
mescc: Tinycc support: uniquify strings per compilation unit.

* module/mes/M1.mes (object->M1): Add file-name to string id.

2 years agomescc: Tinycc support: foo.bar = foo.baz = bla.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 20:45:32 +0000 (22:45 +0200)]
mescc: Tinycc support: foo.bar = foo.baz = bla.

* module/language/c99/compiler.mes (expr->base*): New function.
 (expr->accu): Use it to have value in accu for assignments.
* scaffold/tests/77-pointer-assign.c (test): Test it.
* stage0/x86.M1 (mov____%ecx,(%edx), mov___(%eax),%ecx): New define.
* module/mes/as-i386.mes (accu-mem->base->mem): New function.
  (i386:byte-base->accu-mem+n):
  (i386:byte-base->accu-mem):
  (i386:base-mem->accu-mem):
  (i386:base->accu-mem):
  (i386:value->accu-mem+n):
  (i386:value->accu-mem):
  (i386:accu->base-mem+n):
  (i386:byte-accu->base-mem):
  (i386:accu->base-mem): Rename from accu-address, base-address.
  Update callers.
* module/mes/as-i386.scm (mes): Update exports.

2 years agomescc: Tinycc support: workaround for nyacc "\0" bug.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 19:39:39 +0000 (21:39 +0200)]
mescc: Tinycc support: workaround for nyacc "\0" bug.

* module/language/c99/compiler.mes (fix-null): Replace "\nul" with "\0".
  (initzer->data): Use it.
  (expr->global): Use it.

2 years agomescc: Tinycc support: bugfix foo % bar.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 18:36:21 +0000 (20:36 +0200)]
mescc: Tinycc support: bugfix foo % bar.

* stage0/x86.M1 (mov____%edx,%ebx): Typo
  (idiv___%ebx): Replace div____%ebx.
* module/mes/as-i386.mes (i386:accu/base): Update.
  (i386:accu%base): Update.

2 years agomescc: Tinycc support: fix foo[bar]->baz.
Jan Nieuwenhuizen [Sat, 29 Jul 2017 06:37:34 +0000 (08:37 +0200)]
mescc: Tinycc support: fix foo[bar]->baz.

* module/language/c99/compiler.mes (expr->accu*): Lose one indirection.
* scaffold/tests/72-typedef-struct-def.c: Test it.

2 years agomescc: Tinycc support: foo *bar[baz].
Jan Nieuwenhuizen [Fri, 28 Jul 2017 16:04:39 +0000 (18:04 +0200)]
mescc: Tinycc support: foo *bar[baz].

* module/language/c99/compiler.mes (decl->info): Support foo *bar[baz].
* module/language/c99/compiler.mes (push-global): Support push of -2,
  -1.  Change signature to take info.  Update callers.
  (push-global-address): Change signature to take info.  Update callers.

2 years agomescc: Tinycc support: bugfix foo[bar] = baz, with foo*[].
Jan Nieuwenhuizen [Fri, 28 Jul 2017 16:00:46 +0000 (18:00 +0200)]
mescc: Tinycc support: bugfix foo[bar] = baz, with foo*[].

* module/language/c99/compiler.mes (expr->accu): Support size for more expressions.
  (expr->pointer):
  (expr->size): Support more expressions.
* scaffold/tests/77-pointer-assign.c (add0): Test it.

2 years agomescc: Tinycc support: bugfix *foo = bar.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 13:45:22 +0000 (15:45 +0200)]
mescc: Tinycc support: bugfix *foo = bar.

* module/language/c99/compiler.mes (base->ident-address): Typo, fixes (non-char*)*x = y.
* scaffold/tests/77-pointer-assign.c (test): Test it.

2 years agomescc: Tinycc support: bugfix *(cast)foo = bar.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 13:27:25 +0000 (15:27 +0200)]
mescc: Tinycc support: bugfix *(cast)foo = bar.

* module/language/c99/compiler.mes (expr->accu): Thinko for de-ref assign.
* stage0/x86.M1: Fix typos.
* module/mes/as-i386.mes: Update for typos.
* scaffold/tests/77-pointer-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.

2 years agomescc: Tinycc support: pointer arithmetic.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 08:40:30 +0000 (10:40 +0200)]
mescc: Tinycc support: pointer arithmetic.

* module/language/c99/compiler.mes (ident->size, expr->size): New function.
  (expr->accu): Use them for ++,--,add, sub.
  (i386:type-alist): Set void size to 1.
* scaffold/tests/71-struct-array.c (test):
* scaffold/tests/76-pointer-arithmetic.c: Test it.
* make.scm (add-scaffold-test): Build it.

2 years agomescc: Tinycc support: compile tcc with TCC_IS_NATIVE.
Jan Nieuwenhuizen [Fri, 28 Jul 2017 06:07:41 +0000 (08:07 +0200)]
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.

2 years agomlibc: Tinycc support: gcc -nostdinc -nostdlib.
Jan Nieuwenhuizen [Thu, 27 Jul 2017 21:44:22 +0000 (23:44 +0200)]
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.

2 years agomescc: Tinycc support: malloc,memcpy.
Jan Nieuwenhuizen [Thu, 27 Jul 2017 16:51:58 +0000 (18:51 +0200)]
mescc: Tinycc support: malloc,memcpy.

* mlibc/libc-mes.c (malloc): Rewrite.
* mlibc/libc-mes+tcc.c (memcpy): Implement.

2 years agobuild: support libc-mes+tcc.
Jan Nieuwenhuizen [Thu, 27 Jul 2017 16:41:45 +0000 (18:41 +0200)]
build: support libc-mes+tcc.

2 years agomescc: Tinycc support: memset.
Jan Nieuwenhuizen [Thu, 27 Jul 2017 07:08:11 +0000 (09:08 +0200)]
mescc: Tinycc support: memset.

* mlibc/libc-mes+tcc.c (memset): Implement.

2 years agomescc: bump default maximum for M1-strings to 80.
Jan Nieuwenhuizen [Sat, 26 Aug 2017 11:40:30 +0000 (13:40 +0200)]
mescc: bump default maximum for M1-strings to 80.

* module/mes/M1.mes (object->M1): bump default maximum for M1-strings to 80.

2 years agomescc: Tinycc support: oops, use new realloc.
Jan Nieuwenhuizen [Wed, 26 Jul 2017 22:13:39 +0000 (00:13 +0200)]
mescc: Tinycc support: oops, use new realloc.

* mlibc/libc-mes.c (realloc): Disable naive realloc for libc-mes+tcc.c.

2 years agomescc: Bugfix: output M1-strings if possible.
Jan Nieuwenhuizen [Wed, 26 Jul 2017 21:42:18 +0000 (23:42 +0200)]
mescc: Bugfix: output M1-strings if possible.

* module/mes/M1.mes (object->M1): Typo.  Also disallow \return in M1-strings.

2 years agoguix: Release update.
Jan Nieuwenhuizen [Wed, 26 Jul 2017 11:10:42 +0000 (13:10 +0200)]
guix: Release update.

* guix.scm (mes): Update commit, hash and version.

2 years agoRelease 0.9. v0.9
Jan Nieuwenhuizen [Wed, 26 Jul 2017 10:55:19 +0000 (12:55 +0200)]
Release 0.9.

* configure (VERSION): Bump to 0.9.

2 years agodoc: Release udpate.
Jan Nieuwenhuizen [Sun, 9 Jul 2017 16:40:12 +0000 (18:40 +0200)]
doc: Release udpate.

* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.9: New file.
* make.scm: Install it.
* guix.scm (mescc-tools): Bump to 0.2.

2 years agobuild: Install and installed-run fixes.
Jan Nieuwenhuizen [Wed, 26 Jul 2017 13:42:44 +0000 (15:42 +0200)]
build: Install and installed-run fixes.

* guile/mescc.scm (%datadir,%docdir,%moduledir,%version): Remove.
* scripts/mescc.mes: Likewise.
* module/language/c99/compiler.mes: Likewise.
 (%prefix): Prefer environment setting.
 (c99-input->full-ast): Remove unnecessary includes.
 Remove unnecessary defines.
* make.scm (%scm-files): Add mes/guile.scm.
 (src/mes.gcc, src/mes.mlibc-gcc, src/mes.guile):  Update  MODULEDIR,
 add -I src.
* src/mes.c (load_env): Use temporary variable for MODULEDIR concatenation.
  (bload_env): Likewise.

2 years agomescc: Tinycc support: calloc,malloc,realloc.
Jan Nieuwenhuizen [Tue, 25 Jul 2017 18:55:45 +0000 (20:55 +0200)]
mescc: Tinycc support: calloc,malloc,realloc.

* mlibc/libc-mes+tcc.c (calloc,malloc,realloc): New function.

2 years agomescc: Tinycc support: bugfix struct.array.
Jan Nieuwenhuizen [Tue, 25 Jul 2017 23:13:33 +0000 (01:13 +0200)]
mescc: Tinycc support: bugfix struct.array.

* module/language/c99/compiler.mes (struct-field): Update pointer
  info.
  (field:name,field:pointer,field:size,field:type): Rely on pointer
  info.
  (field:pointer): New function.
 (expr->accu): Use it.
* scaffold/tests/71-struct-array.c (test): Test it.

2 years agomescc: Tinycc support: bugfix struct pointer.
Jan Nieuwenhuizen [Tue, 25 Jul 2017 15:01:37 +0000 (17:01 +0200)]
mescc: Tinycc support: bugfix struct pointer.

* module/language/c99/compiler.mes (decl->info): Only set non-pointer struct to -1.
* scaffold/tests/23-pointer.c (test): Test it.

2 years agomescc: Tinycc support: more function stack space.
Jan Nieuwenhuizen [Tue, 25 Jul 2017 08:01:12 +0000 (10:01 +0200)]
mescc: Tinycc support: more function stack space.

* module/mes/as-i386.mes (function-locals): Increase local space from
  64 (16 vars) to 2*1025 + 80 (20 vars).

2 years agomescc: Tinycc support: bugfix for char **pp = *p.
Jan Nieuwenhuizen [Tue, 25 Jul 2017 09:11:26 +0000 (11:11 +0200)]
mescc: Tinycc support: bugfix for char **pp = *p.

* module/language/c99/compiler.mes (ptr-declr->pointer): Grok ***.
  (decl->info): Bugfix for char **pp = *p, cleanup.
* mlibc/libc-mes.c (getenv): Update for bugfix.
* scaffold/tests/23-pointer.c (test): Test it.

2 years agomescc: Tinycc support: execvp stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 18:33:15 +0000 (20:33 +0200)]
mescc: Tinycc support: execvp stub.

* mlibc/include/unistd.h (execvp): Declare.
* mlibc/libc-mes+tcc.c (execvp): Add stub.

2 years agomescc: Tinycc support: remove stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 18:19:49 +0000 (20:19 +0200)]
mescc: Tinycc support: remove stub.

* mlibc/include/stdio.h (remove): Declare.
* mlibc/libc-mes+tcc.c (remove): Add stub.

2 years agomescc: Tinycc support: fread stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 18:16:25 +0000 (20:16 +0200)]
mescc: Tinycc support: fread stub.

* mlibc/include/stdio.h (fread): Declare.
* mlibc/libc-mes+tcc.c (fread): Add stub.

2 years agomescc: Tinycc support: ftell stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 18:14:00 +0000 (20:14 +0200)]
mescc: Tinycc support: ftell stub.

* mlibc/include/stdio.h (ftell): Declare.
* mlibc/libc-mes+tcc.c (ftell): Add stub.

2 years agomescc: Tinycc support: fseek stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 18:11:22 +0000 (20:11 +0200)]
mescc: Tinycc support: fseek stub.

* mlibc/include/stdio.h (fseek): Declare.
* mlibc/libc-mes+tcc.c (fseek): Add stub.

2 years agomescc: Tinycc support: fopen stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 18:08:38 +0000 (20:08 +0200)]
mescc: Tinycc support: fopen stub.

* mlibc/include/stdio.h (fopen): Declare.
* mlibc/libc-mes+tcc.c (fopen): Add stub.

2 years agomescc: Tinycc support: strstr stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 17:54:32 +0000 (19:54 +0200)]
mescc: Tinycc support: strstr stub.

* mlibc/include/string.h (strstr): Declare.
* mlibc/libc-mes+tcc.c (strstr): Add stub.

2 years agomescc: Tinycc support: sscanf stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 17:31:52 +0000 (19:31 +0200)]
mescc: Tinycc support: sscanf stub.

* mlibc/include/stdio.h (sscanf): Declare.
* mlibc/libc-mes+tcc.c (sscanf): Add stub.

2 years agomescc: Tinycc support: longjmp, setjump stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 17:19:31 +0000 (19:19 +0200)]
mescc: Tinycc support: longjmp, setjump stub.

* mlibc/include/stdarg.h (longjmp, setjmp): Declare.
* mlibc/libc-mes+tcc.c (longjmp, setjmp): Add stub.

2 years agomescc: Tinycc support: function parameters.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 17:15:54 +0000 (19:15 +0200)]
mescc: Tinycc support: function parameters.

* module/language/c99/compiler.mes (.name): Handle function parameters.

2 years agomescc: Tinycc support: fflush stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 17:07:18 +0000 (19:07 +0200)]
mescc: Tinycc support: fflush stub.

* mlibc/include/stdio.h (fflush): Declare.
* mlibc/libc-mes+tcc.c (fflush): Add stub.

2 years agomescc: Tinycc support: vnsprintf stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 16:47:09 +0000 (18:47 +0200)]
mescc: Tinycc support: vnsprintf stub.

* mlibc/include/stdarg.h (vnsprintf): Declare.
* mlibc/libc-mes+tcc.c (vnsprintf): Add stub.

2 years agomescc: Tinycc support: jump 32.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 16:42:24 +0000 (18:42 +0200)]
mescc: Tinycc support: jump 32.

* module/mes/as-i386.mes (i386:jump-byte-z): Use jne32 (was: jne8).

2 years agomescc: Tinycc support: free stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 16:24:51 +0000 (18:24 +0200)]
mescc: Tinycc support: free stub.

* mlibc/include/stdlib.h (free): Declare.
* mlibc/libc-mes+tcc.c (free): Add stub.

2 years agomescc: Tinycc support: strrchr stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 16:16:21 +0000 (18:16 +0200)]
mescc: Tinycc support: strrchr stub.

* mlibc/include/string.h (strrchr): Declare.
* mlibc/libc-mes+tcc.c (strrchr): Add stub.

2 years agomescc: Tinycc support: strtoll stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 16:12:28 +0000 (18:12 +0200)]
mescc: Tinycc support: strtoll stub.

* mlibc/include/stdlib.h (strtoll): Declare.
* mlibc/libc-mes+tcc.c (strtoll): Add stub.

2 years agomescc: Tinycc support: strtoull stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 16:08:02 +0000 (18:08 +0200)]
mescc: Tinycc support: strtoull stub.

* mlibc/include/stdlib.h (strtoull): Declare.
* mlibc/libc-mes+tcc.c (strtoull): Add stub.

2 years agomescc: Tinycc support: strtol stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:38:25 +0000 (17:38 +0200)]
mescc: Tinycc support: strtol stub.

* mlibc/include/stdlib.h (strtol): Declare.
* mlibc/libc-mes+tcc.c (strtol): Add stub.

2 years agomescc: Tinycc support: lseek.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:33:33 +0000 (17:33 +0200)]
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.

2 years agomescc: Tinycc support: fclose stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:25:53 +0000 (17:25 +0200)]
mescc: Tinycc support: fclose stub.

* mlibc/include/stdio.h (fclose): Declare.
* mlibc/libc-mes+tcc.c (fclose): Add stub.

2 years agomescc: Tinycc support: fdopen stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:23:32 +0000 (17:23 +0200)]
mescc: Tinycc support: fdopen stub.

* mlibc/include/stdio.h (fdopen): Declare.
* mlibc/libc-mes+tcc.c (fdopen): Add stub.

2 years agomescc: Tinycc support: unlink.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:09:33 +0000 (17:09 +0200)]
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.

2 years agomescc: Tinycc support: fwrite stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:06:16 +0000 (17:06 +0200)]
mescc: Tinycc support: fwrite stub.

* mlibc/include/stdio.h (fwrite): Declare.
* mlibc/libc-mes+tcc.c (fwrite): Add stub.

2 years agomescc: Tinycc support: qsort stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 15:04:11 +0000 (17:04 +0200)]
mescc: Tinycc support: qsort stub.

* mlibc/include/stdlib.h (qsort): Declare.
* mlibc/libc-mes+tcc.c (qsort): Add stub.

2 years agomescc: Tinycc support: getcwd.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:49:17 +0000 (13:49 +0200)]
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.

2 years agomescc: Tinycc support: strchr stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:46:32 +0000 (13:46 +0200)]
mescc: Tinycc support: strchr stub.

* mlibc/include/string.h (strchr): Declare.
* mlibc/libc-mes+tcc.c (strchr): Add stub.

2 years agomescc: Tinycc support: fprintf stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:39:34 +0000 (13:39 +0200)]
mescc: Tinycc support: fprintf stub.

* mlibc/include/stdio.h (fprintf): Declare.
* mlibc/libc-mes+tcc.c (fprintf): Add stub.

2 years agomescc: Tinycc support: localtime stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:28:18 +0000 (13:28 +0200)]
mescc: Tinycc support: localtime stub.

* mlibc/include/time.h (localtime): Declare.
* mlibc/libc-mes+tcc.c (localtime): Add stub.

2 years agomescc: Tinycc support: time stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:25:54 +0000 (13:25 +0200)]
mescc: Tinycc support: time stub.

* mlibc/include/time.h (time): Declare.
* mlibc/libc-mes+tcc.c (time): Add stub.

2 years agomescc: Tinycc support: snprintf stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:23:15 +0000 (13:23 +0200)]
mescc: Tinycc support: snprintf stub.

* mlibc/include/stdio.h (snprintf): Declare.
* mlibc/libc-mes+tcc.c (snprintf): Add stub.

2 years agomescc: Tinycc support: strtoul stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 11:10:27 +0000 (13:10 +0200)]
mescc: Tinycc support: strtoul stub.

* mlibc/include/stdlib.h (strtoul): Declare.
* mlibc/libc-mes+tcc.c (strtoul): Add stub.

2 years agomescc: Tinycc support: memmove stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 10:53:51 +0000 (12:53 +0200)]
mescc: Tinycc support: memmove stub.

* mlibc/include/string.h (memcmp): Declare.
* mlibc/libc-mes+tcc.c (memcmp): Add stub.

2 years agomescc: Tinycc support: memset stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 10:57:34 +0000 (12:57 +0200)]
mescc: Tinycc support: memset stub.

* mlibc/include/string.h (memset): Declare.
* mlibc/libc-mes+tcc.c (memset): Add stub.

2 years agomescc: Tinycc support: memmove stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 10:56:56 +0000 (12:56 +0200)]
mescc: Tinycc support: memmove stub.

* mlibc/include/string.h (memmove): Declare.
* mlibc/libc-mes+tcc.c (memmove): Add stub.

2 years agomescc: Tinycc support: memcpy stub.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 10:43:04 +0000 (12:43 +0200)]
mescc: Tinycc support: memcpy stub.

* mlibc/include/string.h (memcpy): Declare.
* mlibc/libc-mes+tcc.c (memcpy): Add stub.

2 years agomescc: Tinycc support: close.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 10:21:24 +0000 (12:21 +0200)]
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.

2 years agomescc: Tinycc support: arithmetic in initializes.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 13:22:51 +0000 (15:22 +0200)]
mescc: Tinycc support: arithmetic in initializes.

* module/language/c99/compiler.mes (p-expr->number): Handle
  bitwise-or, constants.
  (initzer-data): Refactor, use p-expr->number.

2 years agomescc: Tinycc support: multi-byte [local] offsets.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 06:36:43 +0000 (08:36 +0200)]
mescc: Tinycc support: multi-byte [local] offsets.

* stage0/x86.M1: Add 32bit variants for all 8bit instructions.
* module/mes/as-i386.mes: Use them, switch on size.

2 years agomescc: Naming fix.
Jan Nieuwenhuizen [Mon, 24 Jul 2017 20:57:21 +0000 (22:57 +0200)]
mescc: Naming fix.

* stage0/x86.M1 (je8): Rename from jne8.
* module/mes/as-i386.mes (i386:jump-byte-z): Update.

2 years agomescc: Tinycc support: remove warnings for foo (void), foo (...).
Jan Nieuwenhuizen [Sun, 23 Jul 2017 21:40:23 +0000 (23:40 +0200)]
mescc: Tinycc support: remove warnings for foo (void), foo (...).

* module/language/c99/compiler.mes (.name, .type): Expect foo (void), foo (...).

2 years agomescc: Tinycc support: multiple statements in default case.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 21:04:00 +0000 (23:04 +0200)]
mescc: Tinycc support: multiple statements in default case.

* module/language/c99/compiler.mes (clause->info): Support multiple
  statements in default case.

2 years agomescc: Tinycc support: array[<const-expr>].
Jan Nieuwenhuizen [Sun, 23 Jul 2017 19:58:34 +0000 (21:58 +0200)]
mescc: Tinycc support: array[<const-expr>].

* module/language/c99/compiler.mes (p-expr->number): New function.
  (struct-field, decl->info): Use it to support const expressions in array size.

2 years agomescc: Use "tag" for tag namespace.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 16:56:07 +0000 (18:56 +0200)]
mescc: Use "tag" for tag namespace.

* module/language/c99/compiler.mes: Use "tag" for tag namespace (WAS: "struct").
  Move enums to "tag" namespace.

2 years agomescc: Guile eval.c support: headers.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 18:42:29 +0000 (20:42 +0200)]
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.

2 years agomescc: Non-Guix support. Thanks rain1!
Jan Nieuwenhuizen [Sun, 23 Jul 2017 13:49:03 +0000 (15:49 +0200)]
mescc: Non-Guix support.  Thanks rain1!

* mlibc/include: Neutralize include guards before #include_next.
  Fixes compiling tinycc on Debian GNU/Linux.

2 years agomescc: Tinycc support: sizeof (struct.field).
Jan Nieuwenhuizen [Sun, 23 Jul 2017 12:18:00 +0000 (14:18 +0200)]
mescc: Tinycc support: sizeof (struct.field).

* module/language/c99/compiler.mes (expr->accu): Support sizeof (struct.field).

2 years agomescc: Tinycc support: struct.union.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 11:41:38 +0000 (13:41 +0200)]
mescc: Tinycc support: struct.union.

* module/language/c99/compiler.mes (struct-field): Add struct tag to
  struct/union types.
  (field-type, field-size, field-offset, field-field, ast-type->type):
  Ascertain struct tag with type.
* (expr->accu*): Do not add struct tag.
* scaffold/tests/75-struct-union.c: Test it.
* scaffold/tests/71-struct-array.c: Update.

2 years agomescc: Tinycc support: sizeof ("foo").
Jan Nieuwenhuizen [Sun, 23 Jul 2017 11:56:38 +0000 (13:56 +0200)]
mescc: Tinycc support: sizeof ("foo").

* module/language/c99/compiler.mes (expr->accu): Support sizeof (string).

2 years agomescc: Tinycc support: struct foo {int bar; int baz} = {0}.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 08:44:17 +0000 (10:44 +0200)]
mescc: Tinycc support: struct foo {int bar; int baz} = {0}.

* module/language/c99/compiler.mes (decl->info): struct foo {int bar; int baz} = {0}.
* scaffold/tests/72-typedef-struct-def.c (test):

2 years agomescc: Tinycc support: generalize neg.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 07:18:36 +0000 (09:18 +0200)]
mescc: Tinycc support: generalize neg.

* module/language/c99/compiler.mes (expr->accu): Generalize neg.

2 years agomescc: Tinycc support: >>=, <<=.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 06:51:42 +0000 (08:51 +0200)]
mescc: Tinycc support: >>=, <<=.

* module/language/c99/compiler.mes (expr->accu): Support >>= <<=.

2 years agomescc: Bugfix non-char* *x x[] test.
Jan Nieuwenhuizen [Sun, 23 Jul 2017 06:44:48 +0000 (08:44 +0200)]
mescc: Bugfix non-char* *x x[] test.

* module/language/c99/compiler.mes (expr->pointer): New function.
  (test-jump-label->info): Use it to fix non char* while (*x | x[i]).

2 years agomescc: Tinycc support: foo[i].bar.baz.
Jan Nieuwenhuizen [Sat, 22 Jul 2017 21:39:39 +0000 (23:39 +0200)]
mescc: Tinycc support: foo[i].bar.baz.

* module/language/c99/compiler.mes (init-declr->pointer): Use -1 for array.
 (expr->accu): Implement foo[i].bar.baz.
* scaffold/tests/72-typedef-struct-def.c (test): Test it.

2 years agomescc: Tinycc support: *global =.
Jan Nieuwenhuizen [Sat, 22 Jul 2017 08:02:53 +0000 (10:02 +0200)]
mescc: Tinycc support: *global =.

* module/language/c99/compiler.mes (base->ident-address):
  Support *global = ...
* scaffold/tests/74-multi-line-string.c: Test it.

2 years agomescc: Tinycc support: anonymous union.
Jan Nieuwenhuizen [Sat, 22 Jul 2017 18:40:41 +0000 (20:40 +0200)]
mescc: Tinycc support: anonymous union.

* module/language/c99/compiler.mes (field:name): New function.
  (decl->info): Use it.
  (struct-field): Support anonymous union.
  (field:size): Update.
  (field-field): Update.
  (field-offset): Update.

2 years agomescc: Tinycc support: declare struct tm.
Jan Nieuwenhuizen [Sat, 22 Jul 2017 07:22:11 +0000 (09:22 +0200)]
mescc: Tinycc support: declare struct tm.

* mlibc/include/time.h (struct tm): New type.

2 years agomescc: Tinycc support: ignore [ULL], UL, LL, L.
Jan Nieuwenhuizen [Fri, 21 Jul 2017 19:43:18 +0000 (21:43 +0200)]
mescc: Tinycc support: ignore [ULL], UL, LL, L.

* module/language/c99/compiler.mes (cstring->number): Drop suffix.

2 years agomescc: Tinycc support: ~, ^=.
Jan Nieuwenhuizen [Fri, 21 Jul 2017 08:39:04 +0000 (10:39 +0200)]
mescc: Tinycc support: ~, ^=.

* module/mes/as-i386.mes (i386:accu-not): New function.
  (i386:accu-negate): Rename from i386:accu-not.
* module/mes/as-i386.scm (mes): Export them.
* module/language/c99/compiler.mes (expr->accu): Support ~, ^=.
* scaffold/tests/60-math.c (test): Test it.
* stage0/x86.M1 (not____%eax): New define.

2 years agomescc: Tinycc support: struct.struct.
Jan Nieuwenhuizen [Tue, 18 Jul 2017 18:22:44 +0000 (20:22 +0200)]
mescc: Tinycc support: struct.struct.

* module/language/c99/compiler.mes (expr->accu): Support &*,
  bar.foo.i, p->foo.i, p->pf->i (*pp)->foo.i, [slightly modified] offsetof.
* scaffold/tests/72-typedef-struct-def.c (test): Test them.

2 years agomescc: Tinycc support: ***parameter.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 23:02:17 +0000 (01:02 +0200)]
mescc: Tinycc support: ***parameter.

* module/language/c99/compiler.mes (.name): Support ***parameter.

2 years agomescc: Tinycc support: bitwise-or initializer.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 22:21:31 +0000 (00:21 +0200)]
mescc: Tinycc support: bitwise-or initializer.

* module/language/c99/compiler.mes (initzer->value): New function.
  (initzer->data): Use it to support bitwise-or initializer.
* scaffold/tests/74-multi-line-string.c (test): Test it.

2 years agomescc: Tinycc support: char*[] in function.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 22:09:18 +0000 (00:09 +0200)]
mescc: Tinycc support: char*[] in function.

* module/language/c99/compiler.mes (c99-input->full-ast): Add NULL.
  (decl->info): Support char* [] in function scope.
* scaffold/tests/71-struct-array.c (test) Test it.

2 years agomescc: Tinycc support: more list initializers.
Jan Nieuwenhuizen [Tue, 18 Jul 2017 06:04:50 +0000 (08:04 +0200)]
mescc: Tinycc support: more list initializers.

* module/language/c99/compiler.mes (init-declr->name): Handle array,
  pointer array.
  (init-declr->pointer): Likewise.
  (decl->info): Generalize list initializers, add pointer variant.
  FIXME: AST-rewriting?

2 years agomescc: Tinycc support: headers.
Jan Nieuwenhuizen [Mon, 17 Jul 2017 20:03:11 +0000 (22:03 +0200)]
mescc: Tinycc support: headers.

* mlibc/include/string.h (ssize_t): New type.
* mlibc/include/unistd.h (ssize_t): New type.