Remove double indirection in array-map! with <2 args
[bpt/guile.git] / libguile / guardians.c
index 580e212..6ba8c0b 100644 (file)
@@ -1,5 +1,6 @@
-/* Copyright (C) 1998,1999,2000,2001, 2006, 2008 Free Software Foundation, Inc.
- * 
+/* Copyright (C) 1998,1999,2000,2001, 2006, 2008, 2009, 2011,
+ *   2012, 2013 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
  * as published by the Free Software Foundation; either version 3 of
@@ -62,7 +63,7 @@
 #include "libguile/eval.h"
 
 #include "libguile/guardians.h"
-#include "libguile/boehm-gc.h"
+#include "libguile/bdw-gc.h"
 
 
 
@@ -77,7 +78,7 @@ typedef struct t_guardian
 } t_guardian;
 
 #define GUARDIAN_P(x)    SCM_SMOB_PREDICATE(tc16_guardian, x)
-#define GUARDIAN_DATA(x) ((t_guardian *) SCM_CELL_WORD_1 (x))
+#define GUARDIAN_DATA(x) ((t_guardian *) SCM_SMOB_DATA_1 (x))
 
 
 
@@ -104,7 +105,7 @@ guardian_print (SCM guardian, SCM port, scm_print_state *pstate SCM_UNUSED)
 /* Handle finalization of OBJ which is guarded by the guardians listed in
    GUARDIAN_LIST.  */
 static void
-finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data)
+finalize_guarded (void *ptr, void *finalizer_data)
 {
   SCM cell_pool;
   SCM obj, guardian_list, proxied_finalizer;
@@ -127,7 +128,7 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data)
   /* Tell each guardian interested in OBJ that OBJ is no longer
      reachable.  */
   for (;
-       guardian_list != SCM_EOL;
+       !scm_is_null (guardian_list);
        guardian_list = SCM_CDR (guardian_list))
     {
       SCM zombies;
@@ -151,7 +152,7 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data)
       cell_pool = SCM_CDR (cell_pool);
 
       /* Compute and update G's zombie list.  */
-      SCM_SETCAR (zombies, SCM_PACK (obj));
+      SCM_SETCAR (zombies, obj);
       SCM_SETCDR (zombies, g->zombies);
       g->zombies = zombies;
 
@@ -159,12 +160,12 @@ finalize_guarded (GC_PTR ptr, GC_PTR finalizer_data)
       g->zombies = zombies;
     }
 
-  if (proxied_finalizer != SCM_BOOL_F)
+  if (scm_is_true (proxied_finalizer))
     {
       /* Re-register the finalizer that was in place before we installed this
         one.  */
       GC_finalization_proc finalizer, prev_finalizer;
-      GC_PTR finalizer_data, prev_finalizer_data;
+      void *finalizer_data, *prev_finalizer_data;
 
       finalizer = (GC_finalization_proc) SCM2PTR (SCM_CAR (proxied_finalizer));
       finalizer_data = SCM2PTR (SCM_CDR (proxied_finalizer));
@@ -204,7 +205,7 @@ scm_i_guard (SCM guardian, SCM obj)
         the very beginning of an object's lifetime (e.g., see `SCM_NEWSMOB')
         or by this function.  */
       GC_finalization_proc prev_finalizer;
-      GC_PTR prev_data;
+      void *prev_data;
       SCM guardians_for_obj, finalizer_data;
 
       g->live++;
@@ -257,7 +258,7 @@ scm_i_get_one_zombie (SCM guardian)
   t_guardian *g = GUARDIAN_DATA (guardian);
   SCM res = SCM_BOOL_F;
 
-  if (g->zombies != SCM_EOL)
+  if (!scm_is_null (g->zombies))
     {
       /* Note: We return zombies in reverse order.  */
       res = SCM_CAR (g->zombies);
@@ -279,13 +280,6 @@ scm_i_get_one_zombie (SCM guardian)
 static SCM
 guardian_apply (SCM guardian, SCM obj, SCM throw_p)
 {
-#if ENABLE_DEPRECATED
-  if (!SCM_UNBNDP (throw_p))
-    scm_c_issue_deprecation_warning
-      ("Using the 'throw?' argument of a guardian is deprecated "
-       "and ineffective.");
-#endif
-
   if (!SCM_UNBNDP (obj))
     {
       scm_i_guard (guardian, obj);
@@ -357,16 +351,18 @@ void
 scm_init_guardians ()
 {
   /* We use unordered finalization `a la Java.  */
+#ifdef HAVE_GC_SET_JAVA_FINALIZATION
+  /* This function was added in 7.2alpha2 (June 2009).  */
+  GC_set_java_finalization (1);
+#else
+  /* This symbol is deprecated as of 7.3.  */
   GC_java_finalization = 1;
+#endif
 
   tc16_guardian = scm_make_smob_type ("guardian", 0);
 
   scm_set_smob_print (tc16_guardian, guardian_print);
-#if ENABLE_DEPRECATED
-  scm_set_smob_apply (tc16_guardian, guardian_apply, 0, 2, 0);
-#else
   scm_set_smob_apply (tc16_guardian, guardian_apply, 0, 1, 0);
-#endif
 
 #include "libguile/guardians.x"
 }