Reinstate `scm_protects', for backward compatibility.
authorLudovic Courtès <ludo@gnu.org>
Sat, 13 Feb 2010 18:33:51 +0000 (19:33 +0100)
committerLudovic Courtès <ludo@gnu.org>
Sat, 13 Feb 2010 18:33:51 +0000 (19:33 +0100)
Partly reverts e7efe8e793fa51ea898aea4477939c598b3e9fac ("decruftify
scm_sys_protects").

* libguile/gc.c (protects): Rename to...
  (scm_protects): ... this.

* libguile/gc.h (scm_protects): Add declaration.

libguile/gc.c
libguile/gc.h

index 700f3a4..fc405f3 100644 (file)
@@ -89,7 +89,10 @@ int scm_debug_cells_gc_interval = 0;
  */
 int scm_i_cell_validation_already_running ;
 
-static SCM protects;
+/* Hash table that keeps a reference to objects the user wants to protect from
+   garbage collection.  It could arguably be private but applications have come
+   to rely on it (e.g., Lilypond 2.13.9).  */
+SCM scm_protects;
 
 
 #if (SCM_DEBUG_CELL_ACCESSES == 1)
@@ -507,7 +510,7 @@ scm_gc_protect_object (SCM obj)
      critsec/mutex inconsistency here. */
   SCM_CRITICAL_SECTION_START;
 
-  handle = scm_hashq_create_handle_x (protects, obj, scm_from_int (0));
+  handle = scm_hashq_create_handle_x (scm_protects, obj, scm_from_int (0));
   SCM_SETCDR (handle, scm_sum (SCM_CDR (handle), scm_from_int (1)));
 
   protected_obj_count ++;
@@ -537,7 +540,7 @@ scm_gc_unprotect_object (SCM obj)
       abort ();
     }
  
-  handle = scm_hashq_get_handle (protects, obj);
+  handle = scm_hashq_get_handle (scm_protects, obj);
 
   if (scm_is_false (handle))
     {
@@ -548,7 +551,7 @@ scm_gc_unprotect_object (SCM obj)
     {
       SCM count = scm_difference (SCM_CDR (handle), scm_from_int (1));
       if (scm_is_eq (count, scm_from_int (0)))
-       scm_hashq_remove_x (protects, obj);
+       scm_hashq_remove_x (scm_protects, obj);
       else
        SCM_SETCDR (handle, count);
     }
@@ -636,7 +639,7 @@ scm_storage_prehistory ()
   /* GC_REGISTER_DISPLACEMENT (scm_tc3_unused); */
 
   /* Sanity check.  */
-  if (!GC_is_visible (&protects))
+  if (!GC_is_visible (&scm_protects))
     abort ();
 
   scm_c_hook_init (&scm_before_gc_c_hook, 0, SCM_C_HOOK_NORMAL);
@@ -651,7 +654,7 @@ scm_i_pthread_mutex_t scm_i_gc_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
 void
 scm_init_gc_protect_object ()
 {
-  protects = scm_c_make_hash_table (31);
+  scm_protects = scm_c_make_hash_table (31);
 
 #if 0
   /* We can't have a cleanup handler since we have no thread to run it
index 05b08af..8f05aab 100644 (file)
@@ -3,7 +3,7 @@
 #ifndef SCM_GC_H
 #define SCM_GC_H
 
-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010 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
@@ -237,6 +237,7 @@ SCM_API void scm_gc_register_root (SCM *p);
 SCM_API void scm_gc_unregister_root (SCM *p);
 SCM_API void scm_gc_register_roots (SCM *b, unsigned long n);
 SCM_API void scm_gc_unregister_roots (SCM *b, unsigned long n);
+SCM_API SCM scm_protects;
 SCM_INTERNAL void scm_storage_prehistory (void);
 SCM_INTERNAL void scm_init_gc_protect_object (void);
 SCM_INTERNAL void scm_init_gc (void);