diff --git a/guile-readline/readline.c b/guile-readline/readline.c index 5f6719dd7..2d3617d8d 100644 --- a/guile-readline/readline.c +++ b/guile-readline/readline.c @@ -557,7 +557,7 @@ scm_init_readline () rl_basic_word_break_characters = "\t\n\"'`;()"; rl_readline_name = "Guile"; - reentry_barrier_mutex = scm_permanent_object (scm_make_mutex ()); + reentry_barrier_mutex = scm_make_mutex (); scm_init_opts (scm_readline_options, scm_readline_opts); #if HAVE_RL_GET_KEYMAP diff --git a/libguile/array-map.c b/libguile/array-map.c index 747747a96..c673b4df3 100644 --- a/libguile/array-map.c +++ b/libguile/array-map.c @@ -645,11 +645,7 @@ ramap (SCM ra0, SCM proc, SCM ras) unsigned long k, i1 = SCM_I_ARRAY_BASE (ra1); long inc1 = SCM_I_ARRAY_DIMS (ra1)->inc; ra1 = SCM_I_ARRAY_V (ra1); - ras = SCM_CDR (ras); - if (scm_is_null(ras)) - ras = scm_nullvect; - else - ras = scm_vector (ras); + ras = scm_vector (SCM_CDR (ras)); for (; i <= n; i++, i1 += inc1) { @@ -706,11 +702,8 @@ rafe (SCM ra0, SCM proc, SCM ras) unsigned long k, i1 = SCM_I_ARRAY_BASE (ra1); long inc1 = SCM_I_ARRAY_DIMS (ra1)->inc; ra1 = SCM_I_ARRAY_V (ra1); - ras = SCM_CDR (ras); - if (scm_is_null(ras)) - ras = scm_nullvect; - else - ras = scm_vector (ras); + ras = scm_vector (SCM_CDR (ras)); + for (; i <= n; i++, i0 += inc0, i1 += inc1) { args = SCM_EOL; diff --git a/libguile/async.c b/libguile/async.c index 664264f3c..7ec8b6e1d 100644 --- a/libguile/async.c +++ b/libguile/async.c @@ -501,7 +501,6 @@ scm_async_tick (void) void scm_init_async () { - scm_asyncs = SCM_EOL; tc16_async = scm_make_smob_type ("async", 0); #include "libguile/async.x" diff --git a/libguile/eval.c b/libguile/eval.c index eb56f4ab7..ec19c2345 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -923,8 +923,6 @@ scm_init_eval () scm_init_opts (scm_eval_options_interface, scm_eval_opts); - scm_listofnull = scm_list_1 (SCM_EOL); - f_apply = scm_c_define_gsubr ("apply", 2, 0, 1, scm_apply); scm_tc16_boot_closure = scm_make_smob_type ("boot-closure", 0); diff --git a/libguile/gc.c b/libguile/gc.c index b527e4955..4bd1d5d7e 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -90,6 +90,9 @@ int scm_debug_cells_gc_interval = 0; */ int scm_i_cell_validation_already_running ; +static SCM protects; + + #if (SCM_DEBUG_CELL_ACCESSES == 1) @@ -505,7 +508,7 @@ scm_gc_protect_object (SCM obj) critsec/mutex inconsistency here. */ SCM_CRITICAL_SECTION_START; - handle = scm_hashq_create_handle_x (scm_protects, obj, scm_from_int (0)); + handle = scm_hashq_create_handle_x (protects, obj, scm_from_int (0)); SCM_SETCDR (handle, scm_sum (SCM_CDR (handle), scm_from_int (1))); protected_obj_count ++; @@ -535,7 +538,7 @@ scm_gc_unprotect_object (SCM obj) abort (); } - handle = scm_hashq_get_handle (scm_protects, obj); + handle = scm_hashq_get_handle (protects, obj); if (scm_is_false (handle)) { @@ -546,7 +549,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 (scm_protects, obj); + scm_hashq_remove_x (protects, obj); else SCM_SETCDR (handle, count); } @@ -634,7 +637,7 @@ scm_storage_prehistory () /* GC_REGISTER_DISPLACEMENT (scm_tc3_unused); */ /* Sanity check. */ - if (!GC_is_visible (scm_sys_protects)) + if (!GC_is_visible (&protects)) abort (); scm_c_hook_init (&scm_before_gc_c_hook, 0, SCM_C_HOOK_NORMAL); @@ -649,11 +652,7 @@ scm_i_pthread_mutex_t scm_i_gc_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; void scm_init_gc_protect_object () { - size_t j; - - j = SCM_NUM_PROTECTS; - while (j) - scm_sys_protects[--j] = SCM_BOOL_F; + protects = scm_c_make_hash_table (31); #if 0 /* We can't have a cleanup handler since we have no thread to run it @@ -668,8 +667,6 @@ scm_init_gc_protect_object () #endif #endif - - scm_protects = scm_c_make_hash_table (31); } diff --git a/libguile/keywords.c b/libguile/keywords.c index c415ccbab..0740801ae 100644 --- a/libguile/keywords.c +++ b/libguile/keywords.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2008, 2009 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 @@ -37,6 +37,8 @@ +static SCM keyword_obarray; + scm_t_bits scm_tc16_keyword; #define KEYWORDP(X) (SCM_SMOB_PREDICATE (scm_tc16_keyword, (X))) @@ -71,11 +73,11 @@ SCM_DEFINE (scm_symbol_to_keyword, "symbol->keyword", 1, 0, 0, SCM_CRITICAL_SECTION_START; /* njrev: NEWSMOB and hashq_set_x can raise errors */ - keyword = scm_hashq_ref (scm_keyword_obarray, symbol, SCM_BOOL_F); + keyword = scm_hashq_ref (keyword_obarray, symbol, SCM_BOOL_F); if (scm_is_false (keyword)) { SCM_NEWSMOB (keyword, scm_tc16_keyword, SCM_UNPACK (symbol)); - scm_hashq_set_x (scm_keyword_obarray, symbol, keyword); + scm_hashq_set_x (keyword_obarray, symbol, keyword); } SCM_CRITICAL_SECTION_END; return keyword; @@ -117,7 +119,7 @@ scm_init_keywords () scm_tc16_keyword = scm_make_smob_type ("keyword", 0); scm_set_smob_print (scm_tc16_keyword, keyword_print); - scm_keyword_obarray = scm_c_make_hash_table (0); + keyword_obarray = scm_c_make_hash_table (0); #include "libguile/keywords.x" } diff --git a/libguile/numbers.c b/libguile/numbers.c index 6232ddc6c..358a1cdf8 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -98,6 +98,8 @@ /* the macro above will not work as is with fractions */ +static SCM flo0; + #define SCM_SWAP(x, y) do { SCM __t = x; x = y; y = __t; } while (0) /* FLOBUFLEN is the maximum number of characters neccessary for the @@ -5828,7 +5830,7 @@ scm_imag_part (SCM z) else if (SCM_BIGP (z)) return SCM_INUM0; else if (SCM_REALP (z)) - return scm_flo0; + return flo0; else if (SCM_COMPLEXP (z)) return scm_from_double (SCM_COMPLEX_IMAG (z)); else if (SCM_FRACTIONP (z)) @@ -5923,13 +5925,13 @@ SCM scm_angle (SCM z) { /* atan(0,-1) is pi and it'd be possible to have that as a constant like - scm_flo0 to save allocating a new flonum with scm_from_double each time. + flo0 to save allocating a new flonum with scm_from_double each time. But if atan2 follows the floating point rounding mode, then the value is not a constant. Maybe it'd be close enough though. */ if (SCM_I_INUMP (z)) { if (SCM_I_INUM (z) >= 0) - return scm_flo0; + return flo0; else return scm_from_double (atan2 (0.0, -1.0)); } @@ -5940,12 +5942,12 @@ scm_angle (SCM z) if (sgn < 0) return scm_from_double (atan2 (0.0, -1.0)); else - return scm_flo0; + return flo0; } else if (SCM_REALP (z)) { if (SCM_REAL_VALUE (z) >= 0) - return scm_flo0; + return flo0; else return scm_from_double (atan2 (0.0, -1.0)); } @@ -5954,7 +5956,7 @@ scm_angle (SCM z) else if (SCM_FRACTIONP (z)) { if (scm_is_false (scm_negative_p (SCM_FRACTION_NUMERATOR (z)))) - return scm_flo0; + return flo0; else return scm_from_double (atan2 (0.0, -1.0)); } else @@ -6594,7 +6596,7 @@ scm_init_numbers () scm_add_feature ("complex"); scm_add_feature ("inexact"); - scm_flo0 = scm_from_double (0.0); + flo0 = scm_from_double (0.0); /* determine floating point precision */ for (i=2; i <= SCM_MAX_DBL_RADIX; ++i) diff --git a/libguile/objprop.c b/libguile/objprop.c index 6dd1da631..39fcfb5ca 100644 --- a/libguile/objprop.c +++ b/libguile/objprop.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996, 2000, 2001, 2003, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996, 2000, 2001, 2003, 2006, 2008, 2009 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 @@ -35,12 +35,14 @@ /* {Object Properties} */ +static SCM object_whash; + SCM_DEFINE (scm_object_properties, "object-properties", 1, 0, 0, (SCM obj), "Return @var{obj}'s property list.") #define FUNC_NAME s_scm_object_properties { - return scm_hashq_ref (scm_object_whash, obj, SCM_EOL); + return scm_hashq_ref (object_whash, obj, SCM_EOL); } #undef FUNC_NAME @@ -50,7 +52,7 @@ SCM_DEFINE (scm_set_object_properties_x, "set-object-properties!", 2, 0, 0, "Set @var{obj}'s property list to @var{alist}.") #define FUNC_NAME s_scm_set_object_properties_x { - SCM handle = scm_hashq_create_handle_x (scm_object_whash, obj, alist); + SCM handle = scm_hashq_create_handle_x (object_whash, obj, alist); SCM_SETCDR (handle, alist); return alist; } @@ -75,7 +77,7 @@ SCM_DEFINE (scm_set_object_property_x, "set-object-property!", 3, 0, 0, { SCM h; SCM assoc; - h = scm_hashq_create_handle_x (scm_object_whash, obj, SCM_EOL); + h = scm_hashq_create_handle_x (object_whash, obj, SCM_EOL); SCM_CRITICAL_SECTION_START; assoc = scm_assq (key, SCM_CDR (h)); if (SCM_NIMP (assoc)) @@ -94,7 +96,7 @@ SCM_DEFINE (scm_set_object_property_x, "set-object-property!", 3, 0, 0, void scm_init_objprop () { - scm_object_whash = scm_make_weak_key_hash_table (SCM_UNDEFINED); + object_whash = scm_make_weak_key_hash_table (SCM_UNDEFINED); #include "libguile/objprop.x" } diff --git a/libguile/properties.c b/libguile/properties.c index 60ff2ff65..1f3c668a2 100644 --- a/libguile/properties.c +++ b/libguile/properties.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,2000,2001, 2003, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,2000,2001, 2003, 2006, 2008, 2009 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 @@ -36,6 +36,8 @@ /* {Properties} */ +static SCM properties_whash; + SCM_DEFINE (scm_primitive_make_property, "primitive-make-property", 1, 0, 0, (SCM not_found_proc), "Create a @dfn{property token} that can be used with\n" @@ -67,7 +69,7 @@ SCM_DEFINE (scm_primitive_property_ref, "primitive-property-ref", 2, 0, 0, SCM_VALIDATE_CONS (SCM_ARG1, prop); - h = scm_hashq_get_handle (scm_properties_whash, obj); + h = scm_hashq_get_handle (properties_whash, obj); if (scm_is_true (h)) { SCM assoc = scm_assq (prop, SCM_CDR (h)); @@ -81,7 +83,7 @@ SCM_DEFINE (scm_primitive_property_ref, "primitive-property-ref", 2, 0, 0, { SCM val = scm_call_2 (SCM_CAR (prop), prop, obj); if (scm_is_false (h)) - h = scm_hashq_create_handle_x (scm_properties_whash, obj, SCM_EOL); + h = scm_hashq_create_handle_x (properties_whash, obj, SCM_EOL); SCM_SETCDR (h, scm_acons (prop, val, SCM_CDR (h))); return val; } @@ -96,7 +98,7 @@ SCM_DEFINE (scm_primitive_property_set_x, "primitive-property-set!", 3, 0, 0, { SCM h, assoc; SCM_VALIDATE_CONS (SCM_ARG1, prop); - h = scm_hashq_create_handle_x (scm_properties_whash, obj, SCM_EOL); + h = scm_hashq_create_handle_x (properties_whash, obj, SCM_EOL); assoc = scm_assq (prop, SCM_CDR (h)); if (SCM_NIMP (assoc)) SCM_SETCDR (assoc, val); @@ -117,7 +119,7 @@ SCM_DEFINE (scm_primitive_property_del_x, "primitive-property-del!", 2, 0, 0, { SCM h; SCM_VALIDATE_CONS (SCM_ARG1, prop); - h = scm_hashq_get_handle (scm_properties_whash, obj); + h = scm_hashq_get_handle (properties_whash, obj); if (scm_is_true (h)) SCM_SETCDR (h, scm_assq_remove_x (SCM_CDR (h), prop)); return SCM_UNSPECIFIED; @@ -128,7 +130,7 @@ SCM_DEFINE (scm_primitive_property_del_x, "primitive-property-del!", 2, 0, 0, void scm_init_properties () { - scm_properties_whash = scm_make_weak_key_hash_table (SCM_UNDEFINED); + properties_whash = scm_make_weak_key_hash_table (SCM_UNDEFINED); #include "libguile/properties.x" } diff --git a/libguile/root.c b/libguile/root.c index 83960b5d8..d35d8e89e 100644 --- a/libguile/root.c +++ b/libguile/root.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,1999,2000, 2001, 2002, 2006, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000, 2001, 2002, 2006, 2008, 2009 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 @@ -38,10 +38,6 @@ #include "libguile/root.h" -SCM scm_sys_protects[SCM_NUM_PROTECTS]; - - - /* {call-with-dynamic-root} * * Suspending the current thread to evaluate a thunk on the diff --git a/libguile/root.h b/libguile/root.h index 46b9be013..68ab5c7ce 100644 --- a/libguile/root.h +++ b/libguile/root.h @@ -29,22 +29,6 @@ -#define scm_flo0 scm_sys_protects[0] -#define scm_listofnull scm_sys_protects[1] -#define scm_nullvect scm_sys_protects[2] -#define scm_nullstr scm_sys_protects[3] -#define scm_keyword_obarray scm_sys_protects[4] -#define scm_object_whash scm_sys_protects[5] -#define scm_asyncs scm_sys_protects[6] -#define scm_protects scm_sys_protects[7] -#define scm_properties_whash scm_sys_protects[8] -#define scm_source_whash scm_sys_protects[9] -#define SCM_NUM_PROTECTS 10 - -SCM_API SCM scm_sys_protects[]; - - - SCM_API SCM scm_internal_cwdr (scm_t_catch_body body, void *body_data, scm_t_catch_handler handler, diff --git a/libguile/snarf.h b/libguile/snarf.h index 720cff582..ef1fcd01d 100644 --- a/libguile/snarf.h +++ b/libguile/snarf.h @@ -237,37 +237,37 @@ SCM_SNARF_INIT( \ # define SCM_SYMBOL(c_name, scheme_name) \ SCM_SNARF_HERE(static SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_from_locale_symbol (scheme_name))) +SCM_SNARF_INIT(c_name = scm_from_locale_symbol (scheme_name)) # define SCM_GLOBAL_SYMBOL(c_name, scheme_name) \ SCM_SNARF_HERE(SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_from_locale_symbol (scheme_name))) +SCM_SNARF_INIT(c_name = scm_from_locale_symbol (scheme_name)) #endif /* !SCM_SUPPORT_STATIC_ALLOCATION */ #define SCM_KEYWORD(c_name, scheme_name) \ SCM_SNARF_HERE(static SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_from_locale_keyword (scheme_name))) +SCM_SNARF_INIT(c_name = scm_from_locale_keyword (scheme_name)) #define SCM_GLOBAL_KEYWORD(c_name, scheme_name) \ SCM_SNARF_HERE(SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_from_locale_keyword (scheme_name))) +SCM_SNARF_INIT(c_name = scm_from_locale_keyword (scheme_name)) #define SCM_VARIABLE(c_name, scheme_name) \ SCM_SNARF_HERE(static SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, SCM_BOOL_F));) +SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, SCM_BOOL_F);) #define SCM_GLOBAL_VARIABLE(c_name, scheme_name) \ SCM_SNARF_HERE(SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, SCM_BOOL_F));) +SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, SCM_BOOL_F);) #define SCM_VARIABLE_INIT(c_name, scheme_name, init_val) \ SCM_SNARF_HERE(static SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, init_val));) +SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, init_val);) #define SCM_GLOBAL_VARIABLE_INIT(c_name, scheme_name, init_val) \ SCM_SNARF_HERE(SCM c_name) \ -SCM_SNARF_INIT(c_name = scm_permanent_object (scm_c_define (scheme_name, init_val));) +SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, init_val);) #define SCM_MUTEX(c_name) \ SCM_SNARF_HERE(static scm_t_mutex c_name) \ diff --git a/libguile/srcprop.c b/libguile/srcprop.c index f9d5ed18b..b57fc32d3 100644 --- a/libguile/srcprop.c +++ b/libguile/srcprop.c @@ -59,6 +59,7 @@ SCM_GLOBAL_SYMBOL (scm_sym_copy, "copy"); SCM_GLOBAL_SYMBOL (scm_sym_line, "line"); SCM_GLOBAL_SYMBOL (scm_sym_column, "column"); SCM_GLOBAL_SYMBOL (scm_sym_breakpoint, "breakpoint"); +SCM scm_source_whash; diff --git a/libguile/srcprop.h b/libguile/srcprop.h index a0f4772b5..34538d012 100644 --- a/libguile/srcprop.h +++ b/libguile/srcprop.h @@ -57,6 +57,7 @@ do { \ #define SCM_SOURCE_PROPERTY_FLAG_BREAK 1 SCM_API scm_t_bits scm_tc16_srcprops; +SCM_INTERNAL SCM scm_source_whash; SCM_API SCM scm_sym_filename; SCM_API SCM scm_sym_copy; diff --git a/libguile/strings.c b/libguile/strings.c index 0ea50fdeb..651b0193d 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -253,6 +253,8 @@ scm_i_pthread_mutex_t stringbuf_write_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; #define IS_SH_STRING(str) (SCM_CELL_TYPE(str)==SH_STRING_TAG) +SCM scm_nullstr; + /* Create a scheme string with space for LEN 8-bit Latin-1-encoded characters. CHARSP, if not NULL, will be set to location of the char array. */ diff --git a/libguile/strings.h b/libguile/strings.h index 601bd9c6b..edff0f825 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -98,6 +98,8 @@ typedef enum SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE = SCM_ICONVEH_ESCAPE_SEQUENCE } scm_t_string_failed_conversion_handler; +SCM_INTERNAL SCM scm_nullstr; + SCM_API SCM scm_string_p (SCM x); SCM_API SCM scm_string (SCM chrs); SCM_API SCM scm_make_string (SCM k, SCM chr); diff --git a/libguile/vectors.c b/libguile/vectors.c index 405ebb163..fddf0ce51 100644 --- a/libguile/vectors.c +++ b/libguile/vectors.c @@ -637,8 +637,6 @@ SCM_VECTOR_IMPLEMENTATION (SCM_ARRAY_ELEMENT_TYPE_SCM, scm_make_vector); void scm_init_vectors () { - scm_nullvect = scm_c_make_vector (0, SCM_UNDEFINED); - #include "libguile/vectors.x" }