aboutsummaryrefslogtreecommitdiffstats
path: root/examples/lisp/uns_lisp_cheney_c89.c
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-07-14 09:58:42 -0400
committerGravatar Peter McGoron 2024-07-14 09:58:42 -0400
commit01774a757841ec73182b770a43af347c46a55368 (patch)
tree5c4cb352c1bbbc5f822e68b6291b8a7472f3e675 /examples/lisp/uns_lisp_cheney_c89.c
parentuns_lisp: add first part of CPS transformer (diff)
uns_lisp: fix some bugs in first pass of CPS
Diffstat (limited to 'examples/lisp/uns_lisp_cheney_c89.c')
-rw-r--r--examples/lisp/uns_lisp_cheney_c89.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/examples/lisp/uns_lisp_cheney_c89.c b/examples/lisp/uns_lisp_cheney_c89.c
index a1f770c..04febb7 100644
--- a/examples/lisp/uns_lisp_cheney_c89.c
+++ b/examples/lisp/uns_lisp_cheney_c89.c
@@ -28,14 +28,18 @@
#include "uns.h"
#include "cheney_c89.h"
+static int silent = 0;
+
static void after_gc(Uns_GC gc, struct uns_cheney_c89_statistics *stats)
{
- fprintf(stderr,
- "cheney_c89 %ld: %lu -> %lu\n",
- stats->collection_number,
- stats->usage_before,
- stats->usage_after
- );
+ if (!silent) {
+ fprintf(stderr,
+ "cheney_c89 %ld: %lu -> %lu\n",
+ stats->collection_number,
+ stats->usage_before,
+ stats->usage_after
+ );
+ }
if (stats->usage_after >= stats->usage_before * 7/10) {
@@ -48,12 +52,18 @@ static void after_gc(Uns_GC gc, struct uns_cheney_c89_statistics *stats)
Uns_GC uns_lisp_gc_init(void)
{
Uns_GC gc = malloc(uns_gc_size);
+ const char *env;
uns_gc_zero(gc);
if (!uns_cheney_c89_init(gc, 512)) {
fprintf(stderr, "Error initializing GC\n");
exit(1);
}
+ env = getenv("UNS_LISP_SILENT");
+ if (env && env[0] == 'y') {
+ silent = 1;
+ }
+
uns_cheney_c89_set_collect_callback(gc, after_gc);
uns_cheney_c89_set_new_heap_size(gc, 1024);