From 4abe7b8300a89d4b8c3b3277076e76f20754b27e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 10 Apr 2020 23:23:49 -0700 Subject: gc: add argument to sys:gc. * gc.c (gc_wrap): Takes argument for requesting full garbage collection. (gc_late_init): Update registration of gc intrinsic. * txr.1: Documented. --- gc.c | 7 +++++-- txr.1 | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index dc1a1939..a9f6195c 100644 --- a/gc.c +++ b/gc.c @@ -965,9 +965,12 @@ static val gc_set_delta(val delta) return nil; } -static val gc_wrap(void) +static val gc_wrap(val full) { if (gc_enabled) { +#if CONFIG_GEN_GC + full_gc = !null_or_missing_p(full); +#endif gc(); return t; } @@ -1026,7 +1029,7 @@ val valid_object_p(val obj) void gc_late_init(void) { - reg_fun(intern(lit("gc"), system_package), func_n0(gc_wrap)); + reg_fun(intern(lit("gc"), system_package), func_n1o(gc_wrap, 0)); reg_fun(intern(lit("gc-set-delta"), system_package), func_n1(gc_set_delta)); reg_fun(intern(lit("finalize"), user_package), func_n3o(gc_finalize, 2)); reg_fun(intern(lit("call-finalizers"), user_package), diff --git a/txr.1 b/txr.1 index 7b8dd653..417a656f 100644 --- a/txr.1 +++ b/txr.1 @@ -64245,7 +64245,7 @@ operator. .SS* Garbage Collection .coNP Function @ sys:gc .synb -.mets (sys:gc) +.mets (sys:gc <> [ full ]) .syne .desc The @@ -64259,6 +64259,16 @@ The function returns if garbage collection is disabled (and consequently nothing is done), otherwise .codn t . +The Boolean +.meta full +argument, defaulting to +.codn nil , +indicates whether a full garbage collection should be requested. + +Even if this argument is +.codn nil , +a full garbage collection may occur due to having been scheduled. + .coNP Function @ sys:gc-set-delta .synb .mets (sys:gc-set-delta << bytes ) -- cgit v1.2.3