From 789844e8d3708a63ffb4b2bc4d78bc780a4bb9d9 Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Thu, 11 Dec 2003 12:56:38 +0000 Subject: [PATCH] Use a lisp object to fill unbound slots rather than a null pointer which may end up causing SIGSEGV. --- src/c/instance.d | 12 ++++++------ src/c/symbols_list.h | 1 + src/cmp/sysfun.lsp | 4 ++-- src/h/object.h | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/c/instance.d b/src/c/instance.d index 2c883e7d2..ad101f0e1 100644 --- a/src/c/instance.d +++ b/src/c/instance.d @@ -22,7 +22,7 @@ ecl_allocate_instance(cl_object clas, int size) int i; CLASS_OF(x) = clas; for (i = 0; i < size; i++) - x->instance.slots[i] = OBJNULL; + x->instance.slots[i] = ECL_UNBOUND; return(x); } @@ -58,7 +58,7 @@ si_change_instance(cl_object x, cl_object clas, cl_object size, cl_object corr) corr = CDR(corr); } else - x->instance.slots[i] = OBJNULL; + x->instance.slots[i] = ECL_UNBOUND; } @(return) /* FIXME! Is this what we need? */ } @@ -116,7 +116,7 @@ si_instance_ref_safe(cl_object x, cl_object index) (i = fix(index)) < 0 || i >= x->instance.length) FEerror("~S is an illegal slot index.", 1, index); x = x->instance.slots[i]; - if (x == OBJNULL) + if (x == ECL_UNBOUND) FEerror("Slot index ~S unbound", 1, index); @(return x) } @@ -157,13 +157,13 @@ si_unbound() { /* Returns an object that cannot be read or written and which is used to represent an unitialized slot */ - @(return OBJNULL) + @(return ECL_UNBOUND) } cl_object si_sl_boundp(cl_object x) { - @(return ((x == OBJNULL) ? Cnil : Ct)) + @(return ((x == ECL_UNBOUND) ? Cnil : Ct)) } cl_object @@ -176,7 +176,7 @@ si_sl_makunbound(cl_object x, cl_object index) if (!FIXNUMP(index) || (i = fix(index)) >= x->instance.length || i < 0) FEerror("~S is an illegal slot index.", 1, index); - x->instance.slots[i] = OBJNULL; + x->instance.slots[i] = ECL_UNBOUND; @(return x) } diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index 2d937f8b2..c15da66a6 100644 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -18,6 +18,7 @@ cl_symbols[] = { {"NIL", CL_ORDINARY, NULL, -1}, {"T", CL_ORDINARY, NULL, -1}, +{SYS_ "UNBOUND", SI_ORDINARY, NULL, -1, OBJNULL}, /* LISP PACKAGE */ {"&ALLOW-OTHER-KEYS", CL_ORDINARY, NULL, -1, OBJNULL}, diff --git a/src/cmp/sysfun.lsp b/src/cmp/sysfun.lsp index 3440f6aa6..17dff379f 100644 --- a/src/cmp/sysfun.lsp +++ b/src/cmp/sysfun.lsp @@ -1049,9 +1049,9 @@ type_of(#0)==t_bitvector")) (si::INSTANCE-CLASS-SET (t t) T) (si::INSTANCEP (t) T nil t) (si::UNBOUND nil T nil t - :inline-always (nil T nil nil "OBJNULL")) + :inline-always (nil T nil nil "ECL_UNBOUND")) (si::SL-BOUNDP (t) T nil t - :inline-always ((t) :bool nil nil "(#0)!=OBJNULL")) + :inline-always ((t) :bool nil nil "(#0)!=ECL_UNBOUND")) (si::SL-MAKUNBOUND (t fixnum) T nil t) )) ; end of of #+clos diff --git a/src/h/object.h b/src/h/object.h index acb11424b..56887e38a 100644 --- a/src/h/object.h +++ b/src/h/object.h @@ -118,6 +118,7 @@ enum ecl_stype { /* symbol type */ #define Cnil ((cl_object)cl_symbols) #define Ct ((cl_object)(cl_symbols+1)) +#define ECL_UNBOUND ((cl_object)(cl_symbols+2)) struct ecl_symbol { HEADER4(stype, mflag, isform, dynamic);