1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Reinstate `scm_protects', for backward compatibility.

Partly reverts e7efe8e793 ("decruftify
scm_sys_protects").

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

* libguile/gc.h (scm_protects): Add declaration.
This commit is contained in:
Ludovic Courtès 2010-02-13 19:33:51 +01:00
parent 524aa8ae68
commit acbccb0c83
2 changed files with 11 additions and 7 deletions

View file

@ -89,7 +89,10 @@ int scm_debug_cells_gc_interval = 0;
*/ */
int scm_i_cell_validation_already_running ; 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) #if (SCM_DEBUG_CELL_ACCESSES == 1)
@ -507,7 +510,7 @@ scm_gc_protect_object (SCM obj)
critsec/mutex inconsistency here. */ critsec/mutex inconsistency here. */
SCM_CRITICAL_SECTION_START; 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))); SCM_SETCDR (handle, scm_sum (SCM_CDR (handle), scm_from_int (1)));
protected_obj_count ++; protected_obj_count ++;
@ -537,7 +540,7 @@ scm_gc_unprotect_object (SCM obj)
abort (); abort ();
} }
handle = scm_hashq_get_handle (protects, obj); handle = scm_hashq_get_handle (scm_protects, obj);
if (scm_is_false (handle)) 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)); SCM count = scm_difference (SCM_CDR (handle), scm_from_int (1));
if (scm_is_eq (count, scm_from_int (0))) if (scm_is_eq (count, scm_from_int (0)))
scm_hashq_remove_x (protects, obj); scm_hashq_remove_x (scm_protects, obj);
else else
SCM_SETCDR (handle, count); SCM_SETCDR (handle, count);
} }
@ -636,7 +639,7 @@ scm_storage_prehistory ()
/* GC_REGISTER_DISPLACEMENT (scm_tc3_unused); */ /* GC_REGISTER_DISPLACEMENT (scm_tc3_unused); */
/* Sanity check. */ /* Sanity check. */
if (!GC_is_visible (&protects)) if (!GC_is_visible (&scm_protects))
abort (); abort ();
scm_c_hook_init (&scm_before_gc_c_hook, 0, SCM_C_HOOK_NORMAL); 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 void
scm_init_gc_protect_object () scm_init_gc_protect_object ()
{ {
protects = scm_c_make_hash_table (31); scm_protects = scm_c_make_hash_table (31);
#if 0 #if 0
/* We can't have a cleanup handler since we have no thread to run it /* We can't have a cleanup handler since we have no thread to run it

View file

@ -3,7 +3,7 @@
#ifndef SCM_GC_H #ifndef SCM_GC_H
#define 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * 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_unregister_root (SCM *p);
SCM_API void scm_gc_register_roots (SCM *b, unsigned long n); 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 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_storage_prehistory (void);
SCM_INTERNAL void scm_init_gc_protect_object (void); SCM_INTERNAL void scm_init_gc_protect_object (void);
SCM_INTERNAL void scm_init_gc (void); SCM_INTERNAL void scm_init_gc (void);