mescc: Support regular C99 compile, headers + mlibc.
* libc/include/assert.h: New file. * libc/include/ctype.h: New file. * libc/include/errno.h: New file. * libc/include/fcntl.h: New file. * libc/include/limits.h: New file. * libc/include/mlibc.h: New file. * libc/include/stdio.h: New file. * libc/include/stdlib: New file. * libc/include/string.h: New file. * libc/include/unistd.h: New file. * libc/mlibc.c: Remove declarations. * make/bin.make (INCLUDES): Factor out standard includes. * make/bin-mlibc.make: New file. * scaffold/scaffold.make: Use it. * src/src.make: Use it. * module/language/c99/compiler.mes (ast-info): Handle more function declarations. * scaffold/cons-mes.c: Remove mlibc definitionsa and mlibc.c include. Instead include <mlibc.h>. * scaffold/hello.c: Likewise. * scaffold/m.c: Likewise. * scaffold/malloc.c: Likewise. * scaffold/micro-mes.c: Likewise. * scaffold/mini-mes.c: Likewise. * scaffold/t.c: Likewise. * scaffold/tiny-mes.c: Likewise. * src/gc.c: Likewise. * src/lib.c: Likewise. * src/math.c: Likewise. * src/mes.c: Likewise. * src/posix.c: Likewise. * src/reader.c: Likewise.
This commit is contained in:
parent
d9780e66cd
commit
fe727301c5
|
@ -5,7 +5,7 @@ QUIET:=@
|
|||
default: all
|
||||
|
||||
MES_DEBUG:=1
|
||||
CFLAGS:=--std=gnu99 -O0 -g
|
||||
CFLAGS:=--std=gnu99 -O0 -g --include mlibc.c
|
||||
OUT:=out
|
||||
|
||||
SUBDIRS:=\
|
||||
|
|
32
libc/include/assert.h
Normal file
32
libc/include/assert.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __ASSERT_H
|
||||
#define __ASSERT_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <assert.h>
|
||||
#else // ! (__GNUC__ && POSIX)
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __ASSERT_H
|
33
libc/include/ctype.h
Normal file
33
libc/include/ctype.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __CTYPE_H
|
||||
#define __CTYPE_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <ctype.h>
|
||||
|
||||
#else // ! (__GNUC__ && POSIX)
|
||||
int isdigit (int);
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __CTYPE_H
|
30
libc/include/errno.h
Normal file
30
libc/include/errno.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __ERRNO_H
|
||||
#define __ERRNO_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <errno.h>
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __ERRNO_H
|
34
libc/include/fcntl.h
Normal file
34
libc/include/fcntl.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __FCNTL_H
|
||||
#define __FCNTL_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <fcntl.h>
|
||||
|
||||
#else // ! (__GNUC__ && POSIX)
|
||||
#define O_RDONLY 0
|
||||
int open (char const *s, int mode);
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __FCNTL_H
|
34
libc/include/limits.h
Normal file
34
libc/include/limits.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __LIMITS_H
|
||||
#define __LIMITS_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <limits.h>
|
||||
|
||||
#else // ! (__GNUC__ && POSIX)
|
||||
#define INT_MIN -2147483648
|
||||
#define INT_MAX 2147483647
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __LIMITS_H
|
26
libc/include/mlibc.h
Normal file
26
libc/include/mlibc.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MLIBC_H
|
||||
#define __MLIBC_H
|
||||
|
||||
char const* itoa (int);
|
||||
|
||||
#endif //__MLIBC_H
|
|
@ -1,6 +1,66 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __STDIO_H
|
||||
#define __STDIO_H 1
|
||||
|
||||
char **g_environment;
|
||||
int g_stdin;
|
||||
|
||||
#define EOF -1
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
|
||||
int printf (char const* format, ...);
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <stdio.h>
|
||||
|
||||
int fdputs (char const* s, int fd);
|
||||
|
||||
#undef puts
|
||||
#define puts(x) fdputs(x, STDOUT)
|
||||
#define eputs(x) fdputs(x, STDERR)
|
||||
#define fputs fdputs
|
||||
|
||||
#ifdef putc
|
||||
#undef putc
|
||||
#endif
|
||||
|
||||
int getchar ();
|
||||
|
||||
int fdputc (int c, int fd);
|
||||
|
||||
#define fputc fdputc
|
||||
#define ungetc fdungetc
|
||||
int fdungetc (int c, int fd);
|
||||
|
||||
#else // !POSIX
|
||||
|
||||
#undef fputs
|
||||
#undef fdputs
|
||||
int fdputs (char const* s, int fd);
|
||||
|
||||
#endif // __GNUC__ && POSIX
|
||||
|
||||
#endif // __STDIO_H
|
||||
|
|
40
libc/include/stdlib.h
Normal file
40
libc/include/stdlib.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __STDLIB_H
|
||||
#define __STDLIB_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <stdlib.h>
|
||||
#else // !(__GNUC__ && POSIX)
|
||||
|
||||
#ifndef __SIZE_T
|
||||
#define __SIZE_T
|
||||
typedef long size_t;
|
||||
#endif
|
||||
|
||||
void *malloc (size_t);
|
||||
void exit (int);
|
||||
#endif // !(__GNUC__ && POSIX)
|
||||
|
||||
#endif // __STDLIB_H
|
||||
|
41
libc/include/string.h
Normal file
41
libc/include/string.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __STRING_H
|
||||
#define __STRING_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <string.h>
|
||||
|
||||
#else // ! (__GNUC__ && POSIX)
|
||||
|
||||
#ifndef __SIZE_T
|
||||
#define __SIZE_T
|
||||
typedef long size_t;
|
||||
#endif
|
||||
|
||||
size_t strlen (char const*);
|
||||
int strcmp (char const*, char const*);
|
||||
int strncmp (char const*, char const*, size_t);
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __STRING_H
|
40
libc/include/unistd.h
Normal file
40
libc/include/unistd.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of Mes.
|
||||
*
|
||||
* Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __UNISTD_H
|
||||
#define __UNISTD_H 1
|
||||
|
||||
#if __GNUC__ && POSIX
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include_next <unistd.h>
|
||||
|
||||
#else // ! (__GNUC__ && POSIX)
|
||||
|
||||
#ifndef __SIZE_T
|
||||
#define __SIZE_T
|
||||
typedef long size_t;
|
||||
#endif
|
||||
|
||||
int read (int fd, void* buf, size_t n);
|
||||
int write (int fd, char const* s, int n);
|
||||
#endif // ! (__GNUC__ && POSIX)
|
||||
|
||||
#endif // __UNISTD_H
|
48
libc/mlibc.c
48
libc/mlibc.c
|
@ -21,22 +21,12 @@
|
|||
char **g_environment = 0;
|
||||
int g_stdin = 0;
|
||||
|
||||
#define EOF -1
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
#include <stdio.h>
|
||||
#include <mlibc.h>
|
||||
|
||||
#if __GNUC__ && !POSIX
|
||||
|
||||
#define O_RDONLY 0
|
||||
#define INT_MIN -2147483648
|
||||
#define INT_MAX 2147483647
|
||||
|
||||
typedef long size_t;
|
||||
void *malloc (size_t i);
|
||||
int open (char const *s, int mode);
|
||||
int read (int fd, void* buf, size_t n);
|
||||
int write (int fd, char const* s, int n);
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
exit (int code)
|
||||
|
@ -288,7 +278,7 @@ ungetc (int c, int fd)
|
|||
char const* itoa (int);
|
||||
|
||||
int
|
||||
strncmp (char const* a, char const* b, int length)
|
||||
strncmp (char const* a, char const* b, size_t length)
|
||||
{
|
||||
while (*a && *b && *a == *b && --length) {a++;b++;}
|
||||
return *a - *b;
|
||||
|
@ -432,22 +422,13 @@ itoa (int x)
|
|||
}
|
||||
|
||||
#if POSIX
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#endif // POSIX
|
||||
|
||||
#undef puts
|
||||
#define puts(x) fdputs(x, STDOUT)
|
||||
#define eputs(x) fdputs(x, STDERR)
|
||||
#define fputs fdputs
|
||||
int
|
||||
fdputs (char const* s, int fd)
|
||||
{
|
||||
|
@ -456,10 +437,8 @@ fdputs (char const* s, int fd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef putc
|
||||
#undef putc
|
||||
#endif
|
||||
#define fputc fdputc
|
||||
#if POSIX
|
||||
|
||||
int
|
||||
fdputc (int c, int fd)
|
||||
{
|
||||
|
@ -496,7 +475,6 @@ getchar ()
|
|||
return i;
|
||||
}
|
||||
|
||||
#define ungetc fdungetc
|
||||
int
|
||||
fdungetc (int c, int fd)
|
||||
{
|
||||
|
@ -504,15 +482,5 @@ fdungetc (int c, int fd)
|
|||
ungetc_buf[++ungetc_char] = c;
|
||||
return c;
|
||||
}
|
||||
#else
|
||||
|
||||
#define fputs fdputs
|
||||
int
|
||||
fdputs (char const* s, int fd)
|
||||
{
|
||||
int i = strlen (s);
|
||||
write (fd, s, i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // POSIX
|
||||
|
|
|
@ -52,4 +52,4 @@ _start ()
|
|||
);
|
||||
exit (r);
|
||||
}
|
||||
#endif
|
||||
#endif // __GNUC__
|
||||
|
|
5
make/bin-mlibc.make
Normal file
5
make/bin-mlibc.make
Normal file
|
@ -0,0 +1,5 @@
|
|||
C_FLAGS:=-nostdinc --include mstart.c -fno-builtin
|
||||
LD_FLAGS:=-nostdlib
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
|
||||
include make/bin.make
|
|
@ -11,6 +11,8 @@ endif
|
|||
CLEAN+=$(O_FILES) $(OUT)/$(TARGET)
|
||||
DIST-CLEAN+=$(D_FILES)
|
||||
|
||||
INCLUDES+=libc/include libc $(OUT)/$(DIR)
|
||||
|
||||
$(OUT)/$(TARGET): ld:=$(CROSS)LD
|
||||
$(OUT)/$(TARGET): LD:=$(CROSS)$(LD)
|
||||
$(OUT)/$(TARGET): CC:=$(CROSS)$(CC)
|
||||
|
|
|
@ -1732,8 +1732,24 @@
|
|||
(let ((types (.types info)))
|
||||
(clone info #:types (cons (cons name (assoc-ref types type)) types))))
|
||||
|
||||
;; int foo ();
|
||||
((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list . ,param-list)))))
|
||||
info)
|
||||
|
||||
;; void foo ();
|
||||
((decl (decl-spec-list (type-spec (void))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list . ,param-list)))))
|
||||
info)
|
||||
|
||||
;; void foo (*);
|
||||
((decl (decl-spec-list (type-spec (void))) (init-declr-list (init-declr (ptr-declr (pointer) (ftn-declr (ident ,name) (param-list . ,param-list))))))
|
||||
info)
|
||||
|
||||
;; char const* itoa ();
|
||||
((decl (decl-spec-list (type-spec (fixed-type ,type)) (type-qual ,qual)) (init-declr-list (init-declr (ptr-declr (pointer) (ftn-declr (ident ,name) (param-list . ,param-list))))))
|
||||
info)
|
||||
|
||||
;; printf (char const* format, ...)
|
||||
((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list ,param-list (ellipsis))))))
|
||||
((decl (decl-spec-list (type-spec (fixed-type ,type))) (init-declr-list (init-declr (ftn-declr (ident ,name) (param-list ,param-list . (ellipsis))))))
|
||||
info)
|
||||
|
||||
;; int i = 0, j = 0;
|
||||
|
|
|
@ -22,15 +22,11 @@
|
|||
#error "POSIX not supported"
|
||||
#endif
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mlibc.h>
|
||||
|
||||
char arena[2000];
|
||||
|
||||
|
@ -878,7 +874,3 @@ main (int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if !__MESC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,15 +18,7 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <mlibc.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -40,7 +32,3 @@ main (int argc, char *argv[])
|
|||
if (argc > 1 && !strcmp (argv[1], "--help")) {puts ("argc > 1 && --help\n"); return argc;}
|
||||
return 42;
|
||||
}
|
||||
|
||||
#if !__MESC__ && !POSIX
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
14
scaffold/m.c
14
scaffold/m.c
|
@ -18,15 +18,7 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <mlibc.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -40,7 +32,3 @@ main (int argc, char *argv[])
|
|||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
#if !__MESC__ && !POSIX
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
|
@ -22,14 +22,7 @@
|
|||
#error "POSIX not supported"
|
||||
#endif
|
||||
|
||||
#if __MESC__
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <mlibc.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -59,7 +52,3 @@ main (int argc, char *argv[])
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if __GNUC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
|
@ -22,15 +22,7 @@
|
|||
#error "POSIX not supported"
|
||||
#endif
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <mlibc.h>
|
||||
|
||||
typedef int SCM;
|
||||
|
||||
|
@ -79,7 +71,3 @@ main (int argc, char *argv[])
|
|||
int i = argc;
|
||||
return i;
|
||||
}
|
||||
|
||||
#if !__MESC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
|
@ -22,15 +22,11 @@
|
|||
#error "POSIX not supported"
|
||||
#endif
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mlibc.h>
|
||||
|
||||
int ARENA_SIZE = 100000;
|
||||
int MAX_ARENA_SIZE = 40000000;
|
||||
|
@ -1201,23 +1197,18 @@ bload_env (SCM a) ///((internal))
|
|||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
eputs ("Hello mini-mes!\n");
|
||||
#if _POSIX_SOURCE
|
||||
g_debug = getenv ("MES_DEBUG");
|
||||
if (g_debug) {eputs ("MODULEDIR=");eputs (MODULEDIR);eputs ("\n");}
|
||||
if (getenv ("MES_ARENA")) ARENA_SIZE = atoi (getenv ("MES_ARENA"));
|
||||
#endif
|
||||
g_debug = 1;
|
||||
if (argc > 1 && !strcmp (argv[1], "--help")) return puts ("Usage: mes [--dump|--load] < FILE");
|
||||
if (argc > 1 && !strcmp (argv[1], "--version")) {puts ("Mes ");puts (VERSION);return 0;};
|
||||
g_stdin = STDIN;
|
||||
char *p;
|
||||
if (p = getenv ("MES_DEBUG")) g_debug = atoi (p);
|
||||
if (g_debug) {eputs (";;; MODULEDIR=");eputs (MODULEDIR);eputs ("\n");}
|
||||
if (p = getenv ("MES_MAX_ARENA")) MAX_ARENA_SIZE = atoi (p);
|
||||
if (p = getenv ("MES_ARENA")) ARENA_SIZE = atoi (p);
|
||||
if (argc > 1 && !strcmp (argv[1], "--help")) return puts ("Usage: mes [--dump|--load] < FILE\n");
|
||||
if (argc > 1 && !strcmp (argv[1], "--version")) {puts ("Mes ");puts (VERSION);puts ("\n");return 0;};
|
||||
r0 = mes_environment ();
|
||||
|
||||
SCM program = bload_env (r0);
|
||||
SCM lst = cell_nil;
|
||||
#if !__MESC__
|
||||
for (int i=argc-1; i>=0; i--) lst = cons (MAKE_STRING (cstring_to_list (argv[i])), lst);
|
||||
#endif
|
||||
r0 = acons (cell_symbol_argv, lst, r0);
|
||||
push_cc (r2, cell_unspecified, r0, cell_unspecified);
|
||||
if (g_debug)
|
||||
|
@ -1239,7 +1230,3 @@ main (int argc, char *argv[])
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !__MESC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
|
@ -29,11 +29,7 @@ include make/check.make
|
|||
|
||||
TARGET:=m.mlibc
|
||||
C_FILES:=$(DIR)/m.c
|
||||
INCLUDES:=libc
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TARGET:=m.mlibc
|
||||
EXPECT:=255
|
||||
|
@ -41,11 +37,7 @@ include make/check.make
|
|||
|
||||
TARGET:=hello.mlibc
|
||||
C_FILES:=$(DIR)/hello.c
|
||||
INCLUDES:=libc
|
||||
C_FLAGS:=-nostdinc -g
|
||||
LD_FLAGS:=-nostdlib -g
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TARGET:=hello.mlibc
|
||||
EXPECT:=42
|
||||
|
@ -53,11 +45,7 @@ include make/check.make
|
|||
|
||||
TARGET:=micro-mes.mlibc
|
||||
C_FILES:=$(DIR)/micro-mes.c
|
||||
INCLUDES:=libc
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TEST:=micro-mes.mlibc-check
|
||||
$(TEST): $(OUT)/micro-mes.mlibc
|
||||
|
@ -66,48 +54,35 @@ include make/check.make
|
|||
|
||||
TARGET:=tiny-mes.mlibc
|
||||
C_FILES:=$(DIR)/tiny-mes.c
|
||||
INCLUDES:=libc
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TARGET:=tiny-mes.mlibc
|
||||
include make/check.make
|
||||
|
||||
TARGET:=cons-mes.mlibc
|
||||
C_FILES:=$(DIR)/cons-mes.c
|
||||
INCLUDES:=libc
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
DEFINES:=VERSION='"$(VERSION)"'
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TARGET:=cons-mes.mlibc
|
||||
include make/check.make
|
||||
|
||||
TARGET:=t.mlibc
|
||||
C_FILES:=$(DIR)/t.c
|
||||
INCLUDES:=libc
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TARGET:=t.mlibc
|
||||
include make/check.make
|
||||
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
#$(OUT)/$(DIR)/mini-mes.$(CROSS)o: $(SNARF.MES)
|
||||
$(OUT)/mini-mes: $(SNARF.MES)
|
||||
|
||||
TARGET:=mini-mes.mlibc
|
||||
C_FILES:=$(DIR)/mini-mes.c
|
||||
DEFINES:=FIXED_PRIMITIVES=1 VERSION='"$(VERSION)"' PREFIX='"$(PREFIX)"'
|
||||
INCLUDES:=libc src $(OUT)/src
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
include make/bin.make
|
||||
DEFINES:=FIXED_PRIMITIVES=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
|
||||
INCLUDES:=src $(OUT)/src
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TEST:=mini-mes.mlibc-check
|
||||
$(TEST): $(OUT)/mini-mes.mlibc
|
||||
|
@ -174,7 +149,7 @@ $(TEST): $(OUT)/mini-mes.guile
|
|||
include make/check.make
|
||||
|
||||
# scripts/mescc.mes
|
||||
|
||||
ifeq ($(MES_SKIP_MES),)
|
||||
TARGET:=m.mes
|
||||
C_FILES:=$(DIR)/m.c
|
||||
include make/mescc-mes.make
|
||||
|
@ -223,6 +198,7 @@ include make/mescc-mes.make
|
|||
|
||||
TARGET:=t.mes
|
||||
include make/check.make
|
||||
endif
|
||||
|
||||
ifneq ($(BOOTSTRAP),)
|
||||
$(OUT)/mini-mes.mes: module/mes/read-0-32.mo
|
||||
|
|
15
scaffold/t.c
15
scaffold/t.c
|
@ -18,14 +18,9 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if __MESC__
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <mlibc.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct scm {
|
||||
int type;
|
||||
|
@ -924,7 +919,3 @@ main (int argc, char *argv[])
|
|||
|
||||
return 22;
|
||||
}
|
||||
|
||||
#if !POSIX && !__MESC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
|
@ -22,15 +22,7 @@
|
|||
#error "POSIX not supported"
|
||||
#endif
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <mlibc.h>
|
||||
|
||||
char arena[300];
|
||||
|
||||
|
@ -346,7 +338,3 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !__MESC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
2
src/gc.c
2
src/gc.c
|
@ -18,6 +18,8 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
SCM
|
||||
gc_up_arena () ///((internal))
|
||||
{
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !__MESC__
|
||||
#define fputs fdputs
|
||||
#endif
|
||||
|
||||
int g_depth;
|
||||
SCM fdisplay_ (SCM, int);
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
SCM
|
||||
greater_p (SCM x) ///((name . ">") (arity . n))
|
||||
{
|
||||
|
|
18
src/mes.c
18
src/mes.c
|
@ -18,15 +18,11 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if __MESC__
|
||||
char **g_environment;
|
||||
int g_stdin = 0;
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
#endif
|
||||
|
||||
#if !__MESC__
|
||||
#include "mlibc.c"
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mlibc.h>
|
||||
|
||||
int ARENA_SIZE = 100000;
|
||||
int MAX_ARENA_SIZE = 20000000;
|
||||
|
@ -1376,7 +1372,3 @@ main (int argc, char *argv[])
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !_POSIX_SOURCE && !__MESC__
|
||||
#include "mstart.c"
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
int
|
||||
ungetchar (int c)
|
||||
{
|
||||
|
|
|
@ -18,11 +18,7 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// #if _POSIX_SOURCE
|
||||
// #undef fputs
|
||||
// #undef fdputs
|
||||
// #undef fdputc
|
||||
// #endif
|
||||
#include <ctype.h>
|
||||
|
||||
SCM
|
||||
___end_of_mes___ ()
|
||||
|
|
19
src/src.make
19
src/src.make
|
@ -40,25 +40,16 @@ snarf-mes: $(SNARF.MES)
|
|||
|
||||
include make/reset.make
|
||||
|
||||
# a full 32 bit cross compiler with glibc
|
||||
# CROSS:=$(CC32:%gcc=%)
|
||||
# TARGET:=$(CROSS)mes
|
||||
# $(OUT)/$(DIR)/mes.$(CROSS)o: $(SNARF.MES)
|
||||
# C_FILES:=$(DIR)/mes.c
|
||||
# DEFINES:=FIXED_PRIMITIVES=1 MES_FULL=1 POSIX=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
|
||||
# INCLUDES:=libc $(OUT)/src
|
||||
# include make/bin.make
|
||||
|
||||
# a simple non-glibc cross compiler, using mlibc.
|
||||
CROSS:=$(CC32:%gcc=%)
|
||||
TARGET:=$(CROSS)mes
|
||||
$(OUT)/$(CROSS)%: $(OUT)/%.mlibc
|
||||
@ln -sf $(<F) $@
|
||||
|
||||
TARGET:=mes.mlibc
|
||||
$(OUT)/$(DIR)/mes.$(CROSS)o: $(SNARF.MES)
|
||||
C_FILES:=$(DIR)/mes.c
|
||||
DEFINES:=FIXED_PRIMITIVES=1 MES_FULL=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
|
||||
INCLUDES:=libc $(OUT)/src
|
||||
C_FLAGS:=-nostdinc
|
||||
LD_FLAGS:=-nostdlib
|
||||
include make/bin.make
|
||||
include make/bin-mlibc.make
|
||||
|
||||
TARGET:=mes.guile
|
||||
$(OUT)/mes.mes: module/mes/read-0-32.mo
|
||||
|
|
Loading…
Reference in a new issue