messages for errors in scm_lreadr() and friends.
+2002-08-05 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * configure.in: add snprintf
+
2002-08-04 Han-Wen <hanwen@cs.uu.nl>
* NEWS: add entries for GC and vector WB.
* Changes to the standalone interpreter
-** SCM_VELTS macros is now read-only. For writing, use the new macros
-SCM_WRITABLE_VELTS, SCM_SET_VECTOR_LENGTH. The use of
-SCM_WRITABLE_VELTS is discouraged, though.
-
-** Garbage collector rewrite.
-
-The garbage collector is cleaned up a lot, and now uses lazy
-sweeping. This is reflected in the output of (gc-stats); since cells
-are being freed when they are allocated, the cells-allocated field
-stays roughly constant.
-
-For malloc related triggers, the behavior is changed. It uses the same
-heuristic as the cell-triggered collections. It may be tuned with the
-environment variables GUILE_MIN_YIELD_MALLOC. This is the percentage
-for minimum yield of malloc related triggers; (default: 40)
-GUILE_INIT_MALLOC_LIMIT is the trigger for doing a GC. The default is
-200 kb.
-
-Debugging operations for the freelist have been deprecated, along with
-the C variables that control garbage collection. The environment
-variables GUILE_MAX_SEGMENT_SIZE, GUILE_INIT_SEGMENT_SIZE_2,
-GUILE_INIT_SEGMENT_SIZE_1, and GUILE_MIN_YIELD_2 should be used.
-
** New command line option `--no-debug'.
Specifying `--no-debug' on the command line will keep the debugging
* Changes to the C interface
+** The SCM_VELTS macros now returns a read-only vector. For writing,
+use the new macros SCM_WRITABLE_VELTS, SCM_SET_VECTOR_LENGTH. The use
+of SCM_WRITABLE_VELTS is discouraged, though.
+
+** Garbage collector rewrite.
+
+The garbage collector is cleaned up a lot, and now uses lazy
+sweeping. This is reflected in the output of (gc-stats); since cells
+are being freed when they are allocated, the cells-allocated field
+stays roughly constant.
+
+For malloc related triggers, the behavior is changed. It uses the same
+heuristic as the cell-triggered collections. It may be tuned with the
+environment variables GUILE_MIN_YIELD_MALLOC. This is the percentage
+for minimum yield of malloc related triggers. The default is 40.
+GUILE_INIT_MALLOC_LIMIT sets the initial trigger for doing a GC. The
+default is 200 kb.
+
+Debugging operations for the freelist have been deprecated, along with
+the C variables that control garbage collection. The environment
+variables GUILE_MAX_SEGMENT_SIZE, GUILE_INIT_SEGMENT_SIZE_2,
+GUILE_INIT_SEGMENT_SIZE_1, and GUILE_MIN_YIELD_2 should be used.
+
** The struct scm_cell has been renamed to scm_t_cell
This is in accordance to Guile's naming scheme for types. Note that
from smob free routines, among other improvements.
The new functions are scm_malloc, scm_realloc, scm_strdup,
-scm_strndup, scm_gc_malloc, scm_gc_realloc, scm_gc_free,
+scm_strndup, scm_gc_malloc, scm_gc_calloc, scm_gc_realloc, scm_gc_free,
scm_gc_register_collectable_memory, and
scm_gc_unregister_collectable_memory. Refer to the manual for more
details and for upgrading instructions.
if test $ac_cv_func_gethostbyname = no; then
AC_CHECK_LIB(nsl, gethostbyname)
fi
+
AC_CHECK_FUNCS(connect)
if test $ac_cv_func_connect = no; then
AC_CHECK_LIB(socket, connect)
+2002-08-05 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * read.c (INPUT_ERROR): Prepare for file:line:column error
+ messages for errors in scm_lreadr() and friends.
+
+2002-08-04 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * gc-malloc.c (scm_malloc): use scm_realloc() (simplifies
+ implementation).
+ (scm_gc_calloc): new function
+
2002-08-04 Han-Wen <hanwen@cs.uu.nl>
* ports.c (scm_new_port_table_entry): init port entry to 0
/* Function for non-cell memory management.
*/
-void *
-scm_malloc (size_t size)
-{
- void *ptr;
-
- if (size == 0)
- return NULL;
-
- SCM_SYSCALL (ptr = malloc (size));
- if (ptr)
- return ptr;
-
- scm_i_sweep_all_segments ("malloc");
- SCM_SYSCALL (ptr = malloc (size));
- if (ptr)
- return ptr;
-
- scm_igc ("malloc");
- scm_i_sweep_all_segments ("malloc/gc");
-
- SCM_SYSCALL (ptr = malloc (size));
- if (ptr)
- return ptr;
-
- scm_memory_error ("malloc");
-}
-
void *
scm_realloc (void *mem, size_t size)
{
scm_memory_error ("realloc");
}
+void *
+scm_malloc (size_t sz)
+{
+ return scm_realloc (NULL, sz);
+}
+
+
char *
scm_strndup (const char *str, size_t n)
{
return ptr;
}
+void *
+scm_gc_calloc (size_t size, const char *what)
+{
+ void *ptr = scm_gc_malloc (size, what);
+ memset (ptr, 0x0, size);
+ return ptr;
+}
+
+
void *
scm_gc_realloc (void *mem, size_t old_size, size_t new_size, const char *what)
{
const char *what);
SCM_API void scm_gc_unregister_collectable_memory (void *mem, size_t size,
const char *what);
+SCM_API void *scm_gc_calloc (size_t size, const char *what);
SCM_API void *scm_gc_malloc (size_t size, const char *what);
SCM_API void *scm_gc_realloc (void *mem, size_t old_size,
size_t new_size, const char *what);
scm_new_port_table_entry (void)
#define FUNC_NAME "scm_new_port_table_entry"
{
- scm_t_port *entry = (scm_t_port *) scm_gc_malloc (sizeof (scm_t_port), "port");
- memset (entry, 0x0, sizeof (scm_t_port));
-
+ scm_t_port *entry = (scm_t_port *) scm_gc_calloc (sizeof (scm_t_port), "port");
if (scm_port_table_size == scm_port_table_room)
{
/* initial malloc is in gc.c. this doesn't use scm_gc_malloc etc.,
"Style of keyword recognition: #f or 'prefix."}
};
+/*
+ Give meaningful error messages for errors
+
+ We use the format
+
+ MESSAGE
+ This happened in ....
+
+ This is not standard GNU format, but the test-suite likes the real
+ message to be in front.
+
+ Hmmm.
+
+ Maybe this is a kludge? Perhaps we should throw (list EXPR FILENAME
+ LINENO COLUMNO), and have the exception handler sort out the error
+ message?Where does the handler live, what are the conventions for
+ the expression argument of the handler? How does this work for an
+ error message like
+
+Backtrace:
+In standard input:
+ 4: 0* [list ...
+
+standard input:4:1: While evaluating arguments to list in expression (list a b):standard input:4:1: Unbound variable: a
+ABORT: (unbound-variable)
+
+
+
+ In any case, we would have to assemble that information anyway.
+ */
+
+
+#if 0
+
+#ifndef HAVE_SNPRINTF
+#define snprintf sprintf
+/*
+ should warn about buffer overflow?
+ */
+#endif
+
+#define INPUT_ERROR(port, message, arg) { \
+ char s[1024];\
+ int fn_found = SCM_STRINGP (SCM_FILENAME(port));\
+ char *fn = "";\
+ if (fn_found)\
+ fn = SCM_STRING_CHARS(SCM_FILENAME(port));\
+ snprintf (s, 1024, "%s\nThis happened in %s%s%s line %d column %d", message, \
+ fn_found ? "`" : "", \
+ fn,\
+ fn_found ? "'" : "", \
+ SCM_LINUM(port) + 1, SCM_COL(port) + 1); \
+ SCM_MISC_ERROR(s, arg); \
+ }
+#else
+#define INPUT_ERROR(port, message, arg) SCM_MISC_ERROR(message, arg)
+#endif
+
+
SCM_DEFINE (scm_read_options, "read-options-interface", 0, 1, 0,
(SCM setting),
"Option interface for the read options. Instead of using\n"
? scm_lreadrecparen (tok_buf, port, s_list, copy)
: scm_lreadparen (tok_buf, port, s_list, copy);
case ')':
- SCM_MISC_ERROR ("unexpected \")\"", SCM_EOL);
+ INPUT_ERROR(port,"unexpected \")\"", SCM_EOL);
goto tryagain;
case '\'':
if (scm_charnames[c]
&& (scm_casei_streq (scm_charnames[c], SCM_STRING_CHARS (*tok_buf))))
return SCM_MAKE_CHAR (scm_charnums[c]);
- SCM_MISC_ERROR ("unknown # object", SCM_EOL);
+ INPUT_ERROR (port, "unknown # object", SCM_EOL);
/* #:SYMBOL is a syntax for keywords supported in all contexts. */
case ':':
}
}
unkshrp:
- scm_misc_error (s_scm_read, "Unknown # object: ~S",
- scm_list_1 (SCM_MAKE_CHAR (c)));
+ INPUT_ERROR (port, "Unknown # object: ~S",
+ scm_list_1 (SCM_MAKE_CHAR (c)));
}
case '"':
while ('"' != (c = scm_getc (port)))
{
if (c == EOF)
- SCM_MISC_ERROR ("end of file in string constant", SCM_EOL);
+ INPUT_ERROR (port, "end of file in string constant", SCM_EOL);
while (j + 2 >= SCM_STRING_LENGTH (*tok_buf))
scm_grow_tok_buf (tok_buf);
c = SCM_STRING_CHARS (*tok_buf)[1];
goto callshrp;
}
- SCM_MISC_ERROR ("unknown # object", SCM_EOL);
+ INPUT_ERROR (port, "unknown # object", SCM_EOL);
}
goto tok;
ans = scm_lreadr (tok_buf, port, copy);
closeit:
if (')' != (c = scm_flush_ws (port, name)))
- SCM_MISC_ERROR ("missing close paren", SCM_EOL);
+ INPUT_ERROR (port, "missing close paren", SCM_EOL);
return ans;
}
ans = tl = scm_cons (tmp, SCM_EOL);
{
ans = scm_lreadr (tok_buf, port, copy);
if (')' != (c = scm_flush_ws (port, name)))
- SCM_MISC_ERROR ("missing close paren", SCM_EOL);
+ INPUT_ERROR (port, "missing close paren", SCM_EOL);
return ans;
}
/* Build the head of the list structure. */
: tmp,
SCM_EOL));
if (')' != (c = scm_flush_ws (port, name)))
- SCM_MISC_ERROR ("missing close paren", SCM_EOL);
+ INPUT_ERROR (port, "missing close paren", SCM_EOL);
goto exit;
}