add SCM_{PACK,UNPACK}_POINTER

* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros.
  The old SCM2PTR and PTR2SCM were defined in such a way that
  round-tripping through a pointer could lose precision, even in the
  case in which you weren't interested in actually dereferencing the
  pointer, it was simply that you needed to plumb a SCM through APIs
  that take pointers.  These new macros are more like SCM_PACK and
  SCM_UNPACK, but for pointer types.  The bit representation of the
  pointer should be the same as the scm_t_bits representation.

* libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS
  pointers.  We are going to try tagging the SCM object itself in the
  future, and I don't think that keeping this support is worth its
  cost.  It probably doesn't work anyway.

* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/symbols.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Update many sites to use the new macros.
This commit is contained in:
Andy Wingo 2011-10-24 17:58:22 +02:00
commit 21041372ed
19 changed files with 83 additions and 91 deletions

View file

@ -682,7 +682,7 @@ SCM_SYMBOL (sym_auto_compilation_options, "%auto-compilation-options");
static SCM
do_try_auto_compile (void *data)
{
SCM source = PTR2SCM (data);
SCM source = SCM_PACK_POINTER (data);
SCM comp_mod, compile_file;
scm_puts (";;; compiling ", scm_current_error_port ());
@ -732,7 +732,7 @@ do_try_auto_compile (void *data)
static SCM
auto_compile_catch_handler (void *data, SCM tag, SCM throw_args)
{
SCM source = PTR2SCM (data);
SCM source = SCM_PACK_POINTER (data);
SCM oport, lines;
oport = scm_open_output_string ();
@ -784,9 +784,9 @@ scm_try_auto_compile (SCM source)
scm_sys_warn_auto_compilation_enabled ();
return scm_c_catch (SCM_BOOL_T,
do_try_auto_compile,
SCM2PTR (source),
SCM_UNPACK_POINTER (source),
auto_compile_catch_handler,
SCM2PTR (source),
SCM_UNPACK_POINTER (source),
NULL, NULL);
}