summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/ChangeLog6
-rw-r--r--libguile/dump.c48
-rw-r--r--libguile/dump.h69
3 files changed, 36 insertions, 87 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index b00c9d5b4..92589c2c6 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,9 @@
+2001-02-10 Keisuke Nishida <kxn30@po.cwru.edu>
+
+ * dump.c (scm_store_bytes): Store data size before data.
+ (scm_restore_bytes): Restore data size. Takes a pointer to size.
+ * dump.h (scm_restore_bytes): Updated.
+
2001-02-09 Keisuke Nishida <kxn30@po.cwru.edu>
* dump.c: Use double cells for update schedule.
diff --git a/libguile/dump.c b/libguile/dump.c
index 69af7ebb0..de0b46d63 100644
--- a/libguile/dump.c
+++ b/libguile/dump.c
@@ -246,22 +246,21 @@ scm_store_pad (SCM dstate)
}
void
-scm_store_string (const char *addr, scm_sizet size, SCM dstate)
+scm_store_word (const scm_bits_t word, SCM dstate)
{
struct scm_dstate *p = SCM_DSTATE_DATA (dstate);
- while (p->image_index + size + 1 >= p->image_size)
+ while (p->image_index + sizeof (scm_bits_t) >= p->image_size)
dstate_extend (p);
- memcpy (p->image_base + p->image_index, addr, size);
- memcpy (p->image_base + p->image_index + size, "\0", 1);
- p->image_index += size + 1;
- scm_store_pad (dstate);
+ memcpy (p->image_base + p->image_index, &word, sizeof (scm_bits_t));
+ p->image_index += sizeof (scm_bits_t);
}
void
scm_store_bytes (const void *addr, scm_sizet size, SCM dstate)
{
struct scm_dstate *p = SCM_DSTATE_DATA (dstate);
- while (p->image_index + size >= p->image_size)
+ scm_store_word (size, dstate);
+ while (p->image_index + size + sizeof (scm_bits_t) >= p->image_size)
dstate_extend (p);
memcpy (p->image_base + p->image_index, addr, size);
p->image_index += size;
@@ -269,9 +268,15 @@ scm_store_bytes (const void *addr, scm_sizet size, SCM dstate)
}
void
-scm_store_word (const scm_bits_t word, SCM dstate)
+scm_store_string (const char *addr, scm_sizet size, SCM dstate)
{
- scm_store_bytes (&word, sizeof (scm_bits_t), dstate);
+ struct scm_dstate *p = SCM_DSTATE_DATA (dstate);
+ while (p->image_index + size + 1 >= p->image_size)
+ dstate_extend (p);
+ memcpy (p->image_base + p->image_index, addr, size);
+ memcpy (p->image_base + p->image_index + size, "\0", 1);
+ p->image_index += size + 1;
+ scm_store_pad (dstate);
}
void
@@ -302,30 +307,37 @@ scm_restore_pad (struct scm_dstate *p)
}
void
-scm_restore_string (const char **pp, scm_sizet *sizep, SCM dstate)
+scm_restore_word (scm_bits_t *wordp, SCM dstate)
{
struct scm_dstate *p = SCM_DSTATE_DATA (dstate);
- *pp = p->image_base + p->image_index;
- *sizep = strlen (*pp);
- p->image_index += *sizep + 1;
- scm_restore_pad (p);
+ *wordp = *(scm_bits_t *) (p->image_base + p->image_index);
+ p->image_index += sizeof (scm_bits_t);
}
void
-scm_restore_bytes (const void **pp, scm_sizet size, SCM dstate)
+scm_restore_bytes (const void **pp, scm_sizet *sizep, SCM dstate)
{
+ scm_bits_t size;
struct scm_dstate *p = SCM_DSTATE_DATA (dstate);
+ scm_restore_word (&size, dstate);
+ if (sizep)
+ *sizep = size;
*pp = p->image_base + p->image_index;
p->image_index += size;
scm_restore_pad (p);
}
void
-scm_restore_word (scm_bits_t *wordp, SCM dstate)
+scm_restore_string (const char **pp, scm_sizet *sizep, SCM dstate)
{
+ int len;
struct scm_dstate *p = SCM_DSTATE_DATA (dstate);
- *wordp = *(scm_bits_t *) (p->image_base + p->image_index);
- p->image_index += sizeof (scm_bits_t);
+ *pp = p->image_base + p->image_index;
+ len = strlen (*pp);
+ if (sizep)
+ *sizep = len;
+ p->image_index += len + 1;
+ scm_restore_pad (p);
}
void
diff --git a/libguile/dump.h b/libguile/dump.h
index 583bc0ea8..e69de29bb 100644
--- a/libguile/dump.h
+++ b/libguile/dump.h
@@ -1,69 +0,0 @@
-/* classes: h_files */
-
-#ifndef DUMPH
-#define DUMPH
-/* Copyright (C) 2001 Free Software Foundation, Inc.
- *
- * This program 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 2, or (at your option)
- * any later version.
- *
- * This program 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 this software; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * As a special exception, the Free Software Foundation gives permission
- * for additional uses of the text contained in its release of GUILE.
- *
- * The exception is that, if you link the GUILE library with other files
- * to produce an executable, this does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * Your use of that executable is in no way restricted on account of
- * linking the GUILE library code into it.
- *
- * This exception does not however invalidate any other reasons why
- * the executable file might be covered by the GNU General Public License.
- *
- * This exception applies only to the code released by the
- * Free Software Foundation under the name GUILE. If you copy
- * code from other Free Software Foundation releases into a copy of
- * GUILE, as the General Public License permits, the exception does
- * not apply to the code that you add in this way. To avoid misleading
- * anyone as to the status of such modified files, you must delete
- * this exception notice from them.
- *
- * If you write modifications of your own for GUILE, it is your choice
- * whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice. */
-
-#include "libguile/__scm.h"
-
-extern void scm_store_string (const char *addr, scm_sizet size, SCM dstate);
-extern void scm_store_bytes (const void *addr, scm_sizet size, SCM dstate);
-extern void scm_store_word (const scm_bits_t word, SCM dstate);
-extern void scm_store_object (SCM obj, SCM dstate);
-
-extern void scm_restore_string (const char **pp, scm_sizet *sizep, SCM dstate);
-extern void scm_restore_bytes (const void **pp, scm_sizet size, SCM dstate);
-extern void scm_restore_word (scm_bits_t *wordp, SCM dstate);
-extern void scm_restore_object (SCM *objp, SCM dstate);
-
-extern SCM scm_binary_write (SCM obj, SCM port);
-extern SCM scm_binary_read (SCM port);
-
-extern void scm_init_dump (void);
-
-#endif /* DUMPH */
-
-/*
- Local Variables:
- c-file-style: "gnu"
- End:
-*/