test/gc: Add gc inspection test.
* src/test/gc.c (main): New unit test. * simple.make (test-gcc, test-m2): New target to build it. * build-aux/pointer.sh: Add it.
This commit is contained in:
parent
c247733bcd
commit
17805e9d3a
|
@ -63,4 +63,5 @@ sed -ri \
|
||||||
src/struct.c \
|
src/struct.c \
|
||||||
src/symbol.c \
|
src/symbol.c \
|
||||||
src/vector.c \
|
src/vector.c \
|
||||||
simple.make
|
src/test/gc.c \
|
||||||
|
simple.make \
|
||||||
|
|
17
simple.make
17
simple.make
|
@ -52,7 +52,7 @@ CFLAGS:= \
|
||||||
-Wno-incompatible-pointer-types \
|
-Wno-incompatible-pointer-types \
|
||||||
-Wno-int-conversion
|
-Wno-int-conversion
|
||||||
|
|
||||||
MES_SOURCES = \
|
LIBMES_SOURCES = \
|
||||||
src/builtins.c \
|
src/builtins.c \
|
||||||
src/core.c \
|
src/core.c \
|
||||||
src/display.c \
|
src/display.c \
|
||||||
|
@ -61,7 +61,6 @@ MES_SOURCES = \
|
||||||
src/hash.c \
|
src/hash.c \
|
||||||
src/lib.c \
|
src/lib.c \
|
||||||
src/math.c \
|
src/math.c \
|
||||||
src/mes.c \
|
|
||||||
src/module.c \
|
src/module.c \
|
||||||
src/posix.c \
|
src/posix.c \
|
||||||
src/reader.c \
|
src/reader.c \
|
||||||
|
@ -71,6 +70,14 @@ MES_SOURCES = \
|
||||||
src/symbol.c \
|
src/symbol.c \
|
||||||
src/vector.c
|
src/vector.c
|
||||||
|
|
||||||
|
MES_SOURCES = \
|
||||||
|
$(LIBMES_SOURCES) \
|
||||||
|
src/mes.c
|
||||||
|
|
||||||
|
TEST_GC_SOURCES = \
|
||||||
|
$(LIBMES_SOURCES) \
|
||||||
|
src/test/gc.c
|
||||||
|
|
||||||
M2_SOURCES = \
|
M2_SOURCES = \
|
||||||
lib/linux/x86-mes-m2/crt1.c \
|
lib/linux/x86-mes-m2/crt1.c \
|
||||||
lib/linux/x86-mes-m2/_exit.c \
|
lib/linux/x86-mes-m2/_exit.c \
|
||||||
|
@ -168,9 +175,15 @@ GCC_SOURCES = \
|
||||||
mes-gcc: bin/mes-gcc
|
mes-gcc: bin/mes-gcc
|
||||||
mes-m2: bin/mes-m2
|
mes-m2: bin/mes-m2
|
||||||
|
|
||||||
|
gc-gcc: bin/gc-gcc
|
||||||
|
gc-m2: bin/gc-m2
|
||||||
|
|
||||||
bin/mes-gcc: simple.make $(GCC_SOURCES) $(MES_SOURCES) $(INCLUDES) | bin
|
bin/mes-gcc: simple.make $(GCC_SOURCES) $(MES_SOURCES) $(INCLUDES) | bin
|
||||||
$(CC) $(CFLAGS) $(GCC_SOURCES) $(MES_SOURCES) -o $@
|
$(CC) $(CFLAGS) $(GCC_SOURCES) $(MES_SOURCES) -o $@
|
||||||
|
|
||||||
|
bin/gc-gcc: simple.make $(GCC_SOURCES) $(TEST_GC_SOURCES) $(INCLUDES) | bin
|
||||||
|
$(CC) $(CFLAGS) -D GC_TEST=1 $(GCC_SOURCES) $(TEST_GC_SOURCES) -o $@
|
||||||
|
|
||||||
M2_PLANET_INCLUDES = \
|
M2_PLANET_INCLUDES = \
|
||||||
include/m2/lib.h \
|
include/m2/lib.h \
|
||||||
include/linux/x86/syscall.h \
|
include/linux/x86/syscall.h \
|
||||||
|
|
2
src/gc.c
2
src/gc.c
|
@ -294,7 +294,7 @@ gc_init_news ()
|
||||||
#else
|
#else
|
||||||
g_news = g_cells + g_free;
|
g_news = g_cells + g_free;
|
||||||
NTYPE (cell_arena) = TVECTOR;
|
NTYPE (cell_arena) = TVECTOR;
|
||||||
NLENGTH (cell_arena) = 1000;
|
NLENGTH (cell_arena) = LENGTH (cell_arena - 1);
|
||||||
NVECTOR (cell_arena) = 0;
|
NVECTOR (cell_arena) = 0;
|
||||||
g_news = g_news + 1;
|
g_news = g_news + 1;
|
||||||
NTYPE (cell_arena) = TCHAR;
|
NTYPE (cell_arena) = TCHAR;
|
||||||
|
|
46
src/test/gc.c
Normal file
46
src/test/gc.c
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU 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.
|
||||||
|
*
|
||||||
|
* GNU 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 GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mes/lib.h"
|
||||||
|
#include "mes/mes.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int g_debug;
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv, char **envp)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
if (p = getenv ("MES_DEBUG"))
|
||||||
|
g_debug = atoi (p);
|
||||||
|
gc_init ();
|
||||||
|
|
||||||
|
SCM v = -1;
|
||||||
|
LENGTH (v) = 10;
|
||||||
|
eputs ("arena: "); write_ (v); eputs ("\n");
|
||||||
|
gc_stats_ ("0");
|
||||||
|
gc_ ();
|
||||||
|
v = -1;
|
||||||
|
eputs ("arena: "); write_ (v); eputs ("\n");
|
||||||
|
gc_stats_ ("1");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue