summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2000-07-26 08:35:35 +0000
committerDirk Herrmann <dirk@dirk-herrmanns-seiten.de>2000-07-26 08:35:35 +0000
commitf762051048ae4ca01e8620d1494b3ccfb67724e4 (patch)
treeaff621c2c3b9a69ff1d89259ef737ba3a02e6a82
parent8e2488ffae40c1f13dfbadb118ba106df9e4bc43 (diff)
downloadguile-f762051048ae4ca01e8620d1494b3ccfb67724e4.tar.gz
* Fixed struct initialization.
-rw-r--r--NEWS2
-rw-r--r--libguile/ChangeLog9
-rw-r--r--libguile/struct.c12
-rw-r--r--libguile/struct.h1
4 files changed, 16 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index e902d5a4d..693fb836f 100644
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,8 @@ SCM_ORD_SIG, SCM_NUM_SIGS
Use SCM_ASSERT_RANGE or SCM_VALIDATE_XXX_RANGE instead of SCM_OUTOFRANGE.
Use scm_memory_error instead of SCM_NALLOC.
+** Removed function: scm_struct_init
+
** Deprecated function: scm_call_catching_errors
Use scm_catch or scm_lazy_catch from throw.[ch] instead.
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 64c905361..ca986cfdd 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,12 @@
+2000-07-26 Dirk Herrmann <D.Herrmann@tu-bs.de>
+
+ * struct.[ch] (scm_struct_init): Made static. Fixed not to rely
+ on the struct cell to be fully initialized.
+
+ * struct.c (scm_make_struct, scm_make_vtable_vtable): Fix the
+ initialization order of the struct such that the type cell is
+ initialized last.
+
2000-07-25 Marius Vollmer <mvo@zagadka.ping.de>
* alist.c (scm_assq_remove_x, scm_assv_remove_x,
diff --git a/libguile/struct.c b/libguile/struct.c
index 520056c46..ea952e3b9 100644
--- a/libguile/struct.c
+++ b/libguile/struct.c
@@ -148,14 +148,12 @@ SCM_DEFINE (scm_make_struct_layout, "make-struct-layout", 1, 0, 0,
-void
-scm_struct_init (SCM handle, int tail_elts, SCM inits)
+static void
+scm_struct_init (SCM handle, SCM layout, scm_bits_t * mem, int tail_elts, SCM inits)
{
- SCM layout = SCM_STRUCT_LAYOUT (handle);
unsigned char * fields_desc = (unsigned char *) SCM_CHARS (layout) - 2;
unsigned char prot = 0;
int n_fields = SCM_LENGTH (layout) / 2;
- scm_bits_t * mem = SCM_STRUCT_DATA (handle);
int tailp = 0;
while (n_fields)
@@ -399,8 +397,8 @@ SCM_DEFINE (scm_make_struct, "make-struct", 2, 0, 1,
scm_struct_n_extra_words,
"make-struct");
SCM_SET_CELL_WORD_1 (handle, data);
+ scm_struct_init (handle, layout, data, tail_elts, init);
SCM_SET_CELL_WORD_0 (handle, (scm_bits_t) SCM_STRUCT_DATA (vtable) + scm_tc3_cons_gloc);
- scm_struct_init (handle, tail_elts, init);
SCM_ALLOW_INTS;
return handle;
}
@@ -489,9 +487,9 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1,
scm_struct_n_extra_words,
"make-vtable-vtable");
SCM_SET_CELL_WORD_1 (handle, data);
+ data [scm_vtable_index_layout] = SCM_UNPACK (layout);
+ scm_struct_init (handle, layout, data, tail_elts, scm_cons (layout, init));
SCM_SET_CELL_WORD_0 (handle, (scm_bits_t) data + scm_tc3_cons_gloc);
- SCM_SET_STRUCT_LAYOUT (handle, layout);
- scm_struct_init (handle, tail_elts, scm_cons (layout, init));
SCM_ALLOW_INTS;
return handle;
}
diff --git a/libguile/struct.h b/libguile/struct.h
index c7abfc577..623c82bf9 100644
--- a/libguile/struct.h
+++ b/libguile/struct.h
@@ -104,7 +104,6 @@ extern scm_sizet scm_struct_free_0 (scm_bits_t * vtable, scm_bits_t * data);
extern scm_sizet scm_struct_free_light (scm_bits_t * vtable, scm_bits_t * data);
extern scm_sizet scm_struct_free_standard (scm_bits_t * vtable, scm_bits_t * data);
extern scm_sizet scm_struct_free_entity (scm_bits_t * vtable, scm_bits_t * data);
-extern void scm_struct_init (SCM handle, int tail_elts, SCM inits);
extern SCM scm_make_struct_layout (SCM fields);
extern SCM scm_struct_p (SCM x);
extern SCM scm_struct_vtable_p (SCM x);