2009-01-18 16:42:17 +01:00
|
|
|
|
/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2004, 2006, 2009 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library 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
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-03-25 23:59:53 +00:00
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
|
2005-03-07 21:42:02 +00:00
|
|
|
|
#include "libguile/async.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/objects.h"
|
2005-01-18 13:59:04 +00:00
|
|
|
|
#include "libguile/goops.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/ports.h"
|
1999-03-14 16:51:55 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
|
|
#include <malloc.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/smob.h"
|
1999-05-23 09:57:31 +00:00
|
|
|
|
|
2006-12-03 21:59:02 +00:00
|
|
|
|
#include "libguile/boehm-gc.h"
|
2006-05-23 21:59:42 +00:00
|
|
|
|
#include <gc/gc_mark.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* scm_smobs scm_numsmob
|
2001-04-21 21:50:08 +00:00
|
|
|
|
* implement a fixed sized array of smob records.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
* Indexes into this table are used when generating type
|
|
|
|
|
|
* tags for smobjects (if you know a tag you can get an index and conversely).
|
|
|
|
|
|
*/
|
2001-04-21 21:50:08 +00:00
|
|
|
|
|
2009-01-18 16:42:17 +01:00
|
|
|
|
#define MAX_SMOB_COUNT SCM_I_MAX_SMOB_TYPE_COUNT
|
|
|
|
|
|
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long scm_numsmob;
|
2001-04-21 21:50:08 +00:00
|
|
|
|
scm_smob_descriptor scm_smobs[MAX_SMOB_COUNT];
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
* smob.h (SCM_SMOB_DATA_2, SCM_SMOB_DATA_3, SCM_SMOB_FLAGS,
SCM_SET_SMOB_DATA_2, SCM_SET_SMOB_DATA_3, SCM_SET_SMOB_FLAGS,
SCM_SMOB_OBJECT, SCM_SMOB_OBJECT_2, SCM_SMOB_OBJECT_3,
SCM_SET_SMOB_OBJECT, SCM_SET_SMOB_OBJECT_2, SCM_SET_SMOB_OBJECT_3,
SCM_SMOB_OBJECT_LOC, SCM_SMOB_OBJECT_2_LOC,
SCM_SMOB_OBJECT_3_LOC): New.
* smob.c (scm_i_set_smob_flags): New function.
2004-05-06 16:41:27 +00:00
|
|
|
|
/* Lower 16 bit of data must be zero.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_i_set_smob_flags (SCM x, scm_t_bits data)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SET_CELL_WORD_0 (x, (SCM_CELL_WORD_0 (x) & 0xFFFF) | data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-09-24 01:46:09 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_assert_smob_type (scm_t_bits tag, SCM val)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!SCM_SMOB_PREDICATE (tag, val))
|
|
|
|
|
|
scm_wrong_type_arg_msg (NULL, 0, val, scm_smobs[SCM_TC2SMOBNUM(tag)].name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1999-05-23 09:57:31 +00:00
|
|
|
|
/* {Mark}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* This function is vestigial. It used to be the mark function's
|
|
|
|
|
|
responsibility to set the mark bit on the smob or port, but now the
|
|
|
|
|
|
generic marking routine in gc.c takes care of that, and a zero
|
|
|
|
|
|
pointer for a mark function means "don't bother". So you never
|
|
|
|
|
|
need scm_mark0.
|
|
|
|
|
|
|
|
|
|
|
|
However, we leave it here because it's harmless to call it, and
|
|
|
|
|
|
people out there have smob code that uses it, and there's no reason
|
|
|
|
|
|
to make their links fail. */
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_mark0 (SCM ptr SCM_UNUSED)
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
2001-03-30 15:03:23 +00:00
|
|
|
|
/* Dirk::FIXME: The name markcdr is misleading, since the term cdr should only
|
|
|
|
|
|
be used for real pairs. */
|
1999-12-12 20:35:02 +00:00
|
|
|
|
scm_markcdr (SCM ptr)
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
2001-03-30 15:03:23 +00:00
|
|
|
|
return SCM_CELL_OBJECT_1 (ptr);
|
1999-05-23 09:57:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* {Free}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
size_t
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_free0 (SCM ptr SCM_UNUSED)
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
size_t
|
1999-05-23 09:57:31 +00:00
|
|
|
|
scm_smob_free (SCM obj)
|
|
|
|
|
|
{
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
long n = SCM_SMOBNUM (obj);
|
|
|
|
|
|
if (scm_smobs[n].size > 0)
|
|
|
|
|
|
scm_gc_free ((void *) SCM_CELL_WORD_1 (obj),
|
|
|
|
|
|
scm_smobs[n].size, SCM_SMOBNAME (n));
|
|
|
|
|
|
return 0;
|
1999-05-23 09:57:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* {Print}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_smob_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long n = SCM_SMOBNUM (exp);
|
1999-05-23 09:57:31 +00:00
|
|
|
|
scm_puts ("#<", port);
|
1999-07-24 23:10:27 +00:00
|
|
|
|
scm_puts (SCM_SMOBNAME (n) ? SCM_SMOBNAME (n) : "smob", port);
|
1999-05-23 09:57:31 +00:00
|
|
|
|
scm_putc (' ', port);
|
2001-04-21 21:50:08 +00:00
|
|
|
|
if (scm_smobs[n].size)
|
* variable.c, threads.c, struct.c, stackchk.c, smob.c, root.c,
print.c, ports.c, mallocs.c, hooks.c, hashtab.c, fports.c,
guardians.c, filesys.c, coop-pthreads.c, continuations.c: Use
scm_uintprint to print unsigned integers, raw heap words, and
adresses, using a cast to scm_t_bits to turn pointers into
integers.
2004-10-22 15:13:12 +00:00
|
|
|
|
scm_uintprint (SCM_CELL_WORD_1 (exp), 16, port);
|
2001-04-21 21:50:08 +00:00
|
|
|
|
else
|
* variable.c, threads.c, struct.c, stackchk.c, smob.c, root.c,
print.c, ports.c, mallocs.c, hooks.c, hashtab.c, fports.c,
guardians.c, filesys.c, coop-pthreads.c, continuations.c: Use
scm_uintprint to print unsigned integers, raw heap words, and
adresses, using a cast to scm_t_bits to turn pointers into
integers.
2004-10-22 15:13:12 +00:00
|
|
|
|
scm_uintprint (SCM_UNPACK (exp), 16, port);
|
1999-05-23 09:57:31 +00:00
|
|
|
|
scm_putc ('>', port);
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
2000-08-25 02:26:22 +00:00
|
|
|
|
/* {Apply}
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2000-12-07 00:55:12 +00:00
|
|
|
|
#define SCM_SMOB_APPLY0(SMOB) \
|
|
|
|
|
|
SCM_SMOB_DESCRIPTOR (SMOB).apply (SMOB)
|
2002-07-20 14:08:34 +00:00
|
|
|
|
#define SCM_SMOB_APPLY1(SMOB, A1) \
|
2000-12-07 00:55:12 +00:00
|
|
|
|
SCM_SMOB_DESCRIPTOR (SMOB).apply (SMOB, A1)
|
2002-07-20 14:08:34 +00:00
|
|
|
|
#define SCM_SMOB_APPLY2(SMOB, A1, A2) \
|
2000-12-07 00:55:12 +00:00
|
|
|
|
SCM_SMOB_DESCRIPTOR (SMOB).apply (SMOB, A1, A2)
|
2002-07-20 14:08:34 +00:00
|
|
|
|
#define SCM_SMOB_APPLY3(SMOB, A1, A2, A3) \
|
2000-12-07 00:55:12 +00:00
|
|
|
|
SCM_SMOB_DESCRIPTOR (SMOB).apply (SMOB, A1, A2, A3)
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_010 (SCM smob)
|
2000-08-25 02:26:22 +00:00
|
|
|
|
{
|
2000-12-07 00:55:12 +00:00
|
|
|
|
return SCM_SMOB_APPLY1 (smob, SCM_UNDEFINED);
|
2000-08-25 02:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-12-07 00:55:12 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_020 (SCM smob)
|
2000-08-25 02:26:22 +00:00
|
|
|
|
{
|
2000-12-07 00:55:12 +00:00
|
|
|
|
return SCM_SMOB_APPLY2 (smob, SCM_UNDEFINED, SCM_UNDEFINED);
|
2000-08-25 02:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-12-07 00:55:12 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_030 (SCM smob)
|
2000-08-25 02:26:22 +00:00
|
|
|
|
{
|
2000-12-07 00:55:12 +00:00
|
|
|
|
return SCM_SMOB_APPLY3 (smob, SCM_UNDEFINED, SCM_UNDEFINED, SCM_UNDEFINED);
|
2000-08-25 02:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-12-07 00:55:12 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_001 (SCM smob)
|
2000-08-25 02:26:22 +00:00
|
|
|
|
{
|
2000-12-07 00:55:12 +00:00
|
|
|
|
return SCM_SMOB_APPLY1 (smob, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_011 (SCM smob)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY2 (smob, SCM_UNDEFINED, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_021 (SCM smob)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, SCM_UNDEFINED, SCM_UNDEFINED, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_0_error (SCM smob)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_num_args (smob);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_1_020 (SCM smob, SCM a1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY2 (smob, a1, SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_1_030 (SCM smob, SCM a1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, a1, SCM_UNDEFINED, SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_1_001 (SCM smob, SCM a1)
|
|
|
|
|
|
{
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
return SCM_SMOB_APPLY1 (smob, scm_list_1 (a1));
|
2000-12-07 00:55:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_1_011 (SCM smob, SCM a1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY2 (smob, a1, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_1_021 (SCM smob, SCM a1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, a1, SCM_UNDEFINED, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_smob_apply_1_error (SCM smob, SCM a1 SCM_UNUSED)
|
2000-12-07 00:55:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_num_args (smob);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_2_030 (SCM smob, SCM a1, SCM a2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, a1, a2, SCM_UNDEFINED);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_2_001 (SCM smob, SCM a1, SCM a2)
|
|
|
|
|
|
{
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
return SCM_SMOB_APPLY1 (smob, scm_list_2 (a1, a2));
|
2000-12-07 12:04:48 +00:00
|
|
|
|
}
|
2000-12-07 00:55:12 +00:00
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_2_011 (SCM smob, SCM a1, SCM a2)
|
|
|
|
|
|
{
|
* list.h (scm_list_1, scm_list_2, scm_list_3, scm_list_4, scm_list_5,
scm_list_n): New functions.
(SCM_LIST0, SCM_LIST1, SCM_LIST2, SCM_LIST3, SCM_LIST4, SCM_LIST5,
SCM_LIST6, SCM_LIST7, SCM_LIST8, SCM_LIST9, scm_listify): Deprecated.
(lots of files): Use the new functions.
* goops.c (CALL_GF1, CALL_GF2, CALL_GF3, CALL_GF4): Use scm_call_N.
* strings.c: #include "libguile/deprecation.h".
2001-06-28 01:11:59 +00:00
|
|
|
|
return SCM_SMOB_APPLY2 (smob, a1, scm_list_1 (a2));
|
2000-12-07 00:55:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_2_021 (SCM smob, SCM a1, SCM a2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, a1, a2, SCM_EOL);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_smob_apply_2_error (SCM smob, SCM a1 SCM_UNUSED, SCM a2 SCM_UNUSED)
|
2000-12-07 00:55:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_num_args (smob);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_3_030 (SCM smob, SCM a1, SCM a2, SCM rst)
|
|
|
|
|
|
{
|
2004-09-22 17:41:37 +00:00
|
|
|
|
if (!scm_is_null (SCM_CDR (rst)))
|
2000-12-07 00:55:12 +00:00
|
|
|
|
scm_wrong_num_args (smob);
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, a1, a2, SCM_CAR (rst));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_3_001 (SCM smob, SCM a1, SCM a2, SCM rst)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY1 (smob, scm_cons2 (a1, a2, rst));
|
2000-08-25 02:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-12-07 00:55:12 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_3_011 (SCM smob, SCM a1, SCM a2, SCM rst)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY2 (smob, a1, scm_cons (a2, rst));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_smob_apply_3_021 (SCM smob, SCM a1, SCM a2, SCM rst)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_SMOB_APPLY3 (smob, a1, a2, rst);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
2001-06-07 21:12:19 +00:00
|
|
|
|
scm_smob_apply_3_error (SCM smob,
|
|
|
|
|
|
SCM a1 SCM_UNUSED,
|
|
|
|
|
|
SCM a2 SCM_UNUSED,
|
|
|
|
|
|
SCM rst SCM_UNUSED)
|
2000-12-07 00:55:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_wrong_num_args (smob);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-04-21 21:50:08 +00:00
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_bits
|
2003-10-07 15:58:19 +00:00
|
|
|
|
scm_make_smob_type (char const *name, size_t size)
|
2001-04-21 21:50:08 +00:00
|
|
|
|
#define FUNC_NAME "scm_make_smob_type"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long new_smob;
|
2001-04-21 21:50:08 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_START;
|
2001-04-21 21:50:08 +00:00
|
|
|
|
new_smob = scm_numsmob;
|
|
|
|
|
|
if (scm_numsmob != MAX_SMOB_COUNT)
|
|
|
|
|
|
++scm_numsmob;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_CRITICAL_SECTION_END;
|
2001-04-21 21:50:08 +00:00
|
|
|
|
|
|
|
|
|
|
if (new_smob == MAX_SMOB_COUNT)
|
|
|
|
|
|
scm_misc_error (FUNC_NAME, "maximum number of smobs exceeded", SCM_EOL);
|
|
|
|
|
|
|
|
|
|
|
|
scm_smobs[new_smob].name = name;
|
|
|
|
|
|
if (size != 0)
|
2000-06-29 15:54:58 +00:00
|
|
|
|
{
|
2001-04-21 21:50:08 +00:00
|
|
|
|
scm_smobs[new_smob].size = size;
|
|
|
|
|
|
scm_smobs[new_smob].free = scm_smob_free;
|
2000-06-29 15:54:58 +00:00
|
|
|
|
}
|
2001-04-21 21:50:08 +00:00
|
|
|
|
|
1999-03-14 16:51:55 +00:00
|
|
|
|
/* Make a class object if Goops is present. */
|
|
|
|
|
|
if (scm_smob_class)
|
2003-03-19 08:57:47 +00:00
|
|
|
|
scm_smob_class[new_smob] = scm_make_extended_class (name, 0);
|
2001-04-21 21:50:08 +00:00
|
|
|
|
|
|
|
|
|
|
return scm_tc7_smob + new_smob * 256;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2001-04-21 21:50:08 +00:00
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1999-05-23 09:57:31 +00:00
|
|
|
|
void
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_set_smob_mark (scm_t_bits tc, SCM (*mark) (SCM))
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].mark = mark;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_set_smob_free (scm_t_bits tc, size_t (*free) (SCM))
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].free = free;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_set_smob_print (scm_t_bits tc, int (*print) (SCM, SCM, scm_print_state*))
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].print = print;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_set_smob_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM))
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].equalp = equalp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2000-08-25 02:26:22 +00:00
|
|
|
|
void
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_set_smob_apply (scm_t_bits tc, SCM (*apply) (),
|
2000-12-07 12:04:48 +00:00
|
|
|
|
unsigned int req, unsigned int opt, unsigned int rst)
|
2000-08-25 02:26:22 +00:00
|
|
|
|
{
|
2000-12-07 00:55:12 +00:00
|
|
|
|
SCM (*apply_0) (SCM);
|
|
|
|
|
|
SCM (*apply_1) (SCM, SCM);
|
|
|
|
|
|
SCM (*apply_2) (SCM, SCM, SCM);
|
|
|
|
|
|
SCM (*apply_3) (SCM, SCM, SCM, SCM);
|
|
|
|
|
|
int type = SCM_GSUBR_MAKTYPE (req, opt, rst);
|
|
|
|
|
|
|
2000-12-07 12:04:48 +00:00
|
|
|
|
if (rst > 1 || req + opt + rst > 3)
|
2000-12-07 00:55:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
puts ("Unsupported smob application type");
|
|
|
|
|
|
abort ();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 0, 0):
|
2000-12-07 12:04:48 +00:00
|
|
|
|
apply_0 = apply; break;
|
2000-12-07 00:55:12 +00:00
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 1, 0):
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_010; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 0):
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_020; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 3, 0):
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_030; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 0, 1):
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_001; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 1, 1):
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_011; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 1):
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_021; break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
apply_0 = scm_smob_apply_0_error; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 0, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 1, 0):
|
2000-12-07 12:04:48 +00:00
|
|
|
|
apply_1 = apply; break;
|
2000-12-07 00:55:12 +00:00
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 1, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 0):
|
|
|
|
|
|
apply_1 = scm_smob_apply_1_020; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 2, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 3, 0):
|
|
|
|
|
|
apply_1 = scm_smob_apply_1_030; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 0, 1):
|
|
|
|
|
|
apply_1 = scm_smob_apply_1_001; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 0, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 1, 1):
|
|
|
|
|
|
apply_1 = scm_smob_apply_1_011; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 1, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 1):
|
|
|
|
|
|
apply_1 = scm_smob_apply_1_021; break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
apply_1 = scm_smob_apply_1_error; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (2, 0, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 1, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 0):
|
2000-12-07 12:04:48 +00:00
|
|
|
|
apply_2 = apply; break;
|
2000-12-07 00:55:12 +00:00
|
|
|
|
case SCM_GSUBR_MAKTYPE (2, 1, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 2, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 3, 0):
|
|
|
|
|
|
apply_2 = scm_smob_apply_2_030; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 0, 1):
|
|
|
|
|
|
apply_2 = scm_smob_apply_2_001; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 0, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 1, 1):
|
|
|
|
|
|
apply_2 = scm_smob_apply_2_011; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (2, 0, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 1, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 1):
|
|
|
|
|
|
apply_2 = scm_smob_apply_2_021; break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
apply_2 = scm_smob_apply_2_error; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (3, 0, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (2, 1, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 2, 0):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 3, 0):
|
|
|
|
|
|
apply_3 = scm_smob_apply_3_030; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 0, 1):
|
|
|
|
|
|
apply_3 = scm_smob_apply_3_001; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 0, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 1, 1):
|
|
|
|
|
|
apply_3 = scm_smob_apply_3_011; break;
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (2, 0, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (1, 1, 1):
|
|
|
|
|
|
case SCM_GSUBR_MAKTYPE (0, 2, 1):
|
|
|
|
|
|
apply_3 = scm_smob_apply_3_021; break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
apply_3 = scm_smob_apply_3_error; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-02-03 04:59:16 +00:00
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].apply = apply;
|
2000-12-07 00:55:12 +00:00
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].apply_0 = apply_0;
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].apply_1 = apply_1;
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].apply_2 = apply_2;
|
|
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].apply_3 = apply_3;
|
2000-12-07 07:10:26 +00:00
|
|
|
|
scm_smobs[SCM_TC2SMOBNUM (tc)].gsubr_type = type;
|
2003-03-19 08:57:47 +00:00
|
|
|
|
|
|
|
|
|
|
if (scm_smob_class)
|
|
|
|
|
|
scm_i_inherit_applicable (scm_smob_class[SCM_TC2SMOBNUM (tc)]);
|
2000-08-25 02:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
1999-05-23 09:57:31 +00:00
|
|
|
|
SCM
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_make_smob (scm_t_bits tc)
|
1999-05-23 09:57:31 +00:00
|
|
|
|
{
|
2006-05-23 21:59:56 +00:00
|
|
|
|
scm_t_bits n = SCM_TC2SMOBNUM (tc);
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
size_t size = scm_smobs[n].size;
|
2001-11-25 15:21:07 +00:00
|
|
|
|
scm_t_bits data = (size > 0
|
* gc.h, gc.c (scm_gc_sweep): Issue deprecation warning when
non-zero is returned from a port or smob free function.
(scm_malloc, scm_realloc, scm_strndup, scm_strdup,
scm_gc_register_collectable_memory,
scm_gc_unregister_collectable_memory, scm_gc_malloc,
scm_gc_realloc, scm_gc_free, scm_gc_strndup, scm_gc_strdup): New.
* backtrace.c, continuations.c, convert.i.c, coop-threads.c,
debug-malloc.c, dynl.c, environments.c, environments.h,
extensions.c, filesys.c, fports.c, gc.c, gc.h, gh_data.c, goops.c,
guardians.c, hooks.c, init.c, keywords.c, load.c, numbers.c,
ports.c, posix.c, procs.c, rdelim.c, regex-posix.c, root.c,
smob.c, stime.c, strings.c, struct.c, struct.h, symbols.c, unif.c,
vectors.c, weaks.c: Use scm_gc_malloc/scm_malloc and
scm_gc_free/free instead of scm_must_malloc and scm_must_free, as
appropriate. Return zero from smob and port free functions.
* debug-malloc.c (scm_malloc_reregister): Handle "old == NULL".
* fports.c (scm_setvbuf): Reset read buffer to saved values when
it is pointing to the putback buffer.
2002-02-11 18:06:50 +00:00
|
|
|
|
? (scm_t_bits) scm_gc_malloc (size, SCM_SMOBNAME (n))
|
2001-11-25 15:21:07 +00:00
|
|
|
|
: 0);
|
2006-05-23 21:59:56 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_RETURN_NEWSMOB (tc, data);
|
1999-05-23 09:57:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
1998-12-05 16:52:34 +00:00
|
|
|
|
|
This set of patches introduces a new tc7 code scm_tc7_number for
numbers. Bignums, reals and complex numbers are turned from smobs
into subtypes of scm_tc7_number.
* tags.h (scm_tc7_number): New.
* eq.c (scm_equal_p), eval.c (SCM_CEVAL), evalext.c
(scm_self_evaluating_p), gc-card.c (scm_i_sweep_card), gc-mark.c
(scm_gc_mark_dependencies), goops.c (create_smob_classes), hash.c
(scm_hasher), numbers.c, numbers.h (SCM_NUMP), objects.c
(scm_class_of), print.c (scm_iprin1), smob.c
(scm_smob_prehistory): Don't handle bignums, reals and complex
numbers as subtypes of scm_tc7_smob any more.
* numbers.h, tags.h (scm_tc16_big, scm_tc16_real,
scm_tc16_complex): Moved definitions from tags.h to numbers.h.
2003-09-18 20:55:40 +00:00
|
|
|
|
/* {Initialization for the type of free cells}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
1998-12-05 16:52:34 +00:00
|
|
|
|
static int
|
2001-06-07 21:12:19 +00:00
|
|
|
|
free_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
|
1998-12-05 16:52:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
char buf[100];
|
2000-12-08 17:32:56 +00:00
|
|
|
|
sprintf (buf, "#<freed cell %p; GC missed a reference>",
|
|
|
|
|
|
(void *) SCM_UNPACK (exp));
|
1998-12-05 16:52:34 +00:00
|
|
|
|
scm_puts (buf, port);
|
2002-09-08 11:31:32 +00:00
|
|
|
|
|
|
|
|
|
|
#if (SCM_DEBUG_CELL_ACCESSES == 1)
|
|
|
|
|
|
if (scm_debug_cell_accesses_p)
|
|
|
|
|
|
abort();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1998-12-05 16:52:34 +00:00
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-05-22 19:12:12 +00:00
|
|
|
|
|
|
|
|
|
|
/* Marking SMOBs using user-supplied mark procedures. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The freelist and GC kind used for SMOB types that provide a custom mark
|
|
|
|
|
|
procedure. */
|
|
|
|
|
|
static void **smob_freelist = NULL;
|
|
|
|
|
|
static int smob_gc_kind = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The generic SMOB mark procedure that gets called for SMOBs allocated with
|
|
|
|
|
|
`scm_i_new_smob_with_mark_proc ()'. */
|
|
|
|
|
|
static struct GC_ms_entry *
|
|
|
|
|
|
smob_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
|
|
|
|
|
|
struct GC_ms_entry *mark_stack_limit, GC_word env)
|
|
|
|
|
|
{
|
|
|
|
|
|
register SCM cell;
|
2006-05-28 20:05:05 +00:00
|
|
|
|
register scm_t_bits tc, smobnum;
|
|
|
|
|
|
|
|
|
|
|
|
cell = PTR2SCM (addr);
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_TYP7 (cell) != scm_tc7_smob)
|
|
|
|
|
|
/* It is likely that the GC passed us a pointer to a free-list element
|
|
|
|
|
|
which we must ignore (see warning in `gc/gc_mark.h'). */
|
|
|
|
|
|
return mark_stack_ptr;
|
2006-05-22 19:12:12 +00:00
|
|
|
|
|
|
|
|
|
|
tc = SCM_CELL_WORD_0 (cell);
|
|
|
|
|
|
smobnum = SCM_TC2SMOBNUM (tc);
|
|
|
|
|
|
|
|
|
|
|
|
if (smobnum >= scm_numsmob)
|
2006-05-28 20:05:05 +00:00
|
|
|
|
/* The first word looks corrupt. */
|
2006-05-22 19:12:12 +00:00
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
|
|
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (SCM_CELL_OBJECT_1 (cell)),
|
|
|
|
|
|
mark_stack_ptr,
|
|
|
|
|
|
mark_stack_limit, NULL);
|
|
|
|
|
|
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (SCM_CELL_OBJECT_2 (cell)),
|
|
|
|
|
|
mark_stack_ptr,
|
|
|
|
|
|
mark_stack_limit, NULL);
|
|
|
|
|
|
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (SCM_CELL_OBJECT_3 (cell)),
|
|
|
|
|
|
mark_stack_ptr,
|
|
|
|
|
|
mark_stack_limit, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_smobs[smobnum].mark)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM obj;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_I_CURRENT_THREAD->current_mark_stack_ptr = mark_stack_ptr;
|
|
|
|
|
|
SCM_I_CURRENT_THREAD->current_mark_stack_limit = mark_stack_limit;
|
|
|
|
|
|
|
|
|
|
|
|
/* Invoke the SMOB's mark procedure, which will in turn invoke
|
|
|
|
|
|
`scm_gc_mark ()', which may modify `current_mark_stack_ptr'. */
|
|
|
|
|
|
obj = scm_smobs[smobnum].mark (cell);
|
|
|
|
|
|
|
|
|
|
|
|
mark_stack_ptr = SCM_I_CURRENT_THREAD->current_mark_stack_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_NIMP (obj))
|
|
|
|
|
|
/* Mark the returned object. */
|
|
|
|
|
|
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (obj),
|
|
|
|
|
|
mark_stack_ptr,
|
|
|
|
|
|
mark_stack_limit, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_I_CURRENT_THREAD->current_mark_stack_limit = NULL;
|
|
|
|
|
|
SCM_I_CURRENT_THREAD->current_mark_stack_ptr = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mark_stack_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Mark object O. We assume that this function is only called during the
|
|
|
|
|
|
mark phase, i.e., from within `smob_mark ()' or one of its
|
|
|
|
|
|
descendents. */
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_gc_mark (SCM o)
|
|
|
|
|
|
{
|
2006-05-28 20:05:05 +00:00
|
|
|
|
#define CURRENT_MARK_PTR \
|
|
|
|
|
|
((struct GC_ms_entry *)(SCM_I_CURRENT_THREAD->current_mark_stack_ptr))
|
|
|
|
|
|
#define CURRENT_MARK_LIMIT \
|
|
|
|
|
|
((struct GC_ms_entry *)(SCM_I_CURRENT_THREAD->current_mark_stack_limit))
|
|
|
|
|
|
|
2006-05-22 19:12:12 +00:00
|
|
|
|
if (SCM_NIMP (o))
|
|
|
|
|
|
{
|
|
|
|
|
|
/* At this point, the `current_mark_*' fields of the current thread
|
|
|
|
|
|
must be defined (they are set in `smob_mark ()'). */
|
|
|
|
|
|
register struct GC_ms_entry *mark_stack_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
if (!CURRENT_MARK_PTR)
|
|
|
|
|
|
/* The function was not called from a mark procedure. */
|
|
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
|
|
|
|
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (o),
|
|
|
|
|
|
CURRENT_MARK_PTR, CURRENT_MARK_LIMIT,
|
|
|
|
|
|
NULL);
|
|
|
|
|
|
SCM_I_CURRENT_THREAD->current_mark_stack_ptr = mark_stack_ptr;
|
|
|
|
|
|
}
|
2006-05-28 20:05:05 +00:00
|
|
|
|
#undef CURRENT_MARK_PTR
|
|
|
|
|
|
#undef CURRENT_MARK_LIMIT
|
2006-05-22 19:12:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Return a SMOB with typecode TC. The SMOB type corresponding to TC may
|
|
|
|
|
|
provide a custom mark procedure and it will be honored. */
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_i_new_smob_with_mark_proc (scm_t_bits tc, scm_t_bits data1,
|
|
|
|
|
|
scm_t_bits data2, scm_t_bits data3)
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Return a double cell. */
|
|
|
|
|
|
SCM cell = SCM_PACK (GC_generic_malloc (2 * sizeof (scm_t_cell),
|
|
|
|
|
|
smob_gc_kind));
|
|
|
|
|
|
|
|
|
|
|
|
SCM_SET_CELL_WORD_3 (cell, data3);
|
|
|
|
|
|
SCM_SET_CELL_WORD_2 (cell, data2);
|
|
|
|
|
|
SCM_SET_CELL_WORD_1 (cell, data1);
|
|
|
|
|
|
SCM_SET_CELL_WORD_0 (cell, tc);
|
|
|
|
|
|
|
|
|
|
|
|
return cell;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-05-23 21:59:42 +00:00
|
|
|
|
|
|
|
|
|
|
/* Finalize SMOB by calling its SMOB type's free function, if any. */
|
2006-05-26 13:50:21 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_finalize_smob (GC_PTR ptr, GC_PTR data)
|
2006-05-23 21:59:42 +00:00
|
|
|
|
{
|
2006-05-26 13:50:21 +00:00
|
|
|
|
SCM smob;
|
2006-05-23 21:59:42 +00:00
|
|
|
|
size_t (* free_smob) (SCM);
|
|
|
|
|
|
|
2006-05-26 13:50:21 +00:00
|
|
|
|
smob = PTR2SCM (ptr);
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
printf ("finalizing SMOB %p (smobnum: %u)\n",
|
|
|
|
|
|
ptr, SCM_SMOBNUM (smob));
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2006-05-23 21:59:42 +00:00
|
|
|
|
free_smob = scm_smobs[SCM_SMOBNUM (smob)].free;
|
|
|
|
|
|
if (free_smob)
|
|
|
|
|
|
free_smob (smob);
|
|
|
|
|
|
}
|
2006-05-22 19:12:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_smob_prehistory ()
|
|
|
|
|
|
{
|
2001-05-26 20:51:22 +00:00
|
|
|
|
long i;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_bits tc;
|
2000-12-08 17:32:56 +00:00
|
|
|
|
|
2006-05-22 19:12:12 +00:00
|
|
|
|
smob_freelist = GC_new_free_list ();
|
|
|
|
|
|
smob_gc_kind = GC_new_kind ((void **)smob_freelist,
|
|
|
|
|
|
GC_MAKE_PROC (GC_new_proc (smob_mark), 0),
|
2008-10-31 21:55:55 +01:00
|
|
|
|
0,
|
|
|
|
|
|
/* Clear new objects. As of version 7.1, libgc
|
|
|
|
|
|
doesn't seem to support passing 0 here. */
|
|
|
|
|
|
1);
|
2006-05-22 19:12:12 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
scm_numsmob = 0;
|
2001-04-21 21:50:08 +00:00
|
|
|
|
for (i = 0; i < MAX_SMOB_COUNT; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_smobs[i].name = 0;
|
|
|
|
|
|
scm_smobs[i].size = 0;
|
|
|
|
|
|
scm_smobs[i].mark = 0;
|
|
|
|
|
|
scm_smobs[i].free = 0;
|
|
|
|
|
|
scm_smobs[i].print = scm_smob_print;
|
|
|
|
|
|
scm_smobs[i].equalp = 0;
|
|
|
|
|
|
scm_smobs[i].apply = 0;
|
|
|
|
|
|
scm_smobs[i].apply_0 = 0;
|
|
|
|
|
|
scm_smobs[i].apply_1 = 0;
|
|
|
|
|
|
scm_smobs[i].apply_2 = 0;
|
|
|
|
|
|
scm_smobs[i].apply_3 = 0;
|
|
|
|
|
|
scm_smobs[i].gsubr_type = 0;
|
|
|
|
|
|
}
|
1999-05-23 09:57:31 +00:00
|
|
|
|
|
This set of patches introduces a new tc7 code scm_tc7_number for
numbers. Bignums, reals and complex numbers are turned from smobs
into subtypes of scm_tc7_number.
* tags.h (scm_tc7_number): New.
* eq.c (scm_equal_p), eval.c (SCM_CEVAL), evalext.c
(scm_self_evaluating_p), gc-card.c (scm_i_sweep_card), gc-mark.c
(scm_gc_mark_dependencies), goops.c (create_smob_classes), hash.c
(scm_hasher), numbers.c, numbers.h (SCM_NUMP), objects.c
(scm_class_of), print.c (scm_iprin1), smob.c
(scm_smob_prehistory): Don't handle bignums, reals and complex
numbers as subtypes of scm_tc7_smob any more.
* numbers.h, tags.h (scm_tc16_big, scm_tc16_real,
scm_tc16_complex): Moved definitions from tags.h to numbers.h.
2003-09-18 20:55:40 +00:00
|
|
|
|
/* WARNING: This scm_make_smob_type call must be done first. */
|
2000-12-08 17:32:56 +00:00
|
|
|
|
tc = scm_make_smob_type ("free", 0);
|
|
|
|
|
|
scm_set_smob_print (tc, free_print);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|