add SCM_{PACK,UNPACK}_POINTER
[bpt/guile.git] / libguile / fluids.c
index 6d048a0..7f0e704 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,2000,2001, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,2000,2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -110,7 +110,7 @@ new_fluid ()
 
   /* Fluids are pointerless cells: the first word is the type tag; the second
      word is the fluid number.  */
-  fluid = PTR2SCM (scm_gc_malloc_pointerless (sizeof (scm_t_cell), "fluid"));
+  fluid = SCM_PACK_POINTER (scm_gc_malloc_pointerless (sizeof (scm_t_cell), "fluid"));
   SCM_SET_CELL_TYPE (fluid, scm_tc7_fluid);
 
   scm_dynwind_begin (0);
@@ -156,13 +156,18 @@ new_fluid ()
       allocated_fluids_len += FLUID_GROW;
     }
 
-  allocated_fluids[n] = SCM2PTR (fluid);
+  allocated_fluids[n] = SCM_UNPACK_POINTER (fluid);
   SCM_SET_CELL_WORD_1 (fluid, (scm_t_bits) n);
 
   GC_GENERAL_REGISTER_DISAPPEARING_LINK (&allocated_fluids[n],
                                         SCM2PTR (fluid));
 
   scm_dynwind_end ();
+
+  /* Now null out values.  We could (and probably should) do this when
+     the fluid is collected instead of now.  */
+  scm_i_reset_fluid (n, SCM_BOOL_F);
+
   return fluid;
 }
 
@@ -181,10 +186,10 @@ SCM_DEFINE (scm_make_fluid, "make-fluid", 0, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_make_undefined_fluid, "make-undefined-fluid", 0, 0, 0,
+SCM_DEFINE (scm_make_unbound_fluid, "make-unbound-fluid", 0, 0, 0,
             (),
-            "")
-#define FUNC_NAME s_scm_make_undefined_fluid
+            "Make a fluid that is initially unbound.")
+#define FUNC_NAME s_scm_make_unbound_fluid
 {
   SCM f = new_fluid ();
   scm_fluid_set_x (f, SCM_UNDEFINED);
@@ -304,7 +309,7 @@ scm_i_make_with_fluids (size_t n, SCM *fluids, SCM *vals)
 
     while (j--)
       for (i = 0; i < j; i++)
-        if (fluids[i] == fluids[j])
+        if (scm_is_eq (fluids[i], fluids[j]))
           {
             vals[i] = vals[j]; /* later bindings win */
             n--;