Added scheme_init_print_buffers_places, audit and cleanedup of print.c globals

svn: r11597
This commit is contained in:
Kevin Tew 2008-09-09 15:53:29 +00:00
parent 95ab952eb9
commit f39141301a
3 changed files with 32 additions and 21 deletions

View File

@ -359,6 +359,8 @@ static void place_instance_init_pre_kernel(void *stack_base) {
static Scheme_Env *place_instance_init_post_kernel() {
Scheme_Env *env;
scheme_init_print_buffers_places();
env = scheme_make_empty_env();
scheme_set_param(scheme_current_config(), MZCONFIG_ENV, (Scheme_Object *)env);

View File

@ -34,6 +34,21 @@
int (*scheme_check_print_is_obj)(Scheme_Object *o);
#define QUICK_ENCODE_BUFFER_SIZE 256
static THREAD_LOCAL char *quick_buffer = NULL;
static THREAD_LOCAL char *quick_encode_buffer = NULL;
/* FIXME places possible race condition on growing printer size */
static Scheme_Type_Printer *printers;
static int printers_count;
static Scheme_Hash_Table *cache_ht;
/* read-only globals */
static char compacts[_CPT_COUNT_];
static Scheme_Hash_Table *global_constants_ht;
static Scheme_Object *quote_link_symbol = NULL;
/* Flag for debugging compiled code in printed form: */
#define NO_COMPACT 0
@ -99,18 +114,6 @@ static void custom_write_struct(Scheme_Object *s, Scheme_Hash_Table *ht,
PrintParams *pp, int notdisplay);
static Scheme_Object *writable_struct_subs(Scheme_Object *s, PrintParams *pp);
static Scheme_Object *quote_link_symbol = NULL;
static char *quick_buffer = NULL;
static char *quick_encode_buffer = NULL;
static Scheme_Type_Printer *printers;
static int printers_count;
#define QUICK_ENCODE_BUFFER_SIZE 256
static char compacts[_CPT_COUNT_];
static Scheme_Hash_Table *global_constants_ht;
#define print_compact(pp, v) print_this_string(pp, &compacts[v], 0, 1)
@ -132,17 +135,10 @@ static Scheme_Hash_Table *global_constants_ht;
#define ssALL(x, isbox) 1
#define ssALLp(x, isbox) isbox
static Scheme_Hash_Table *cache_ht;
void scheme_init_print(Scheme_Env *env)
{
int i;
REGISTER_SO(quick_buffer);
REGISTER_SO(quick_encode_buffer);
quick_buffer = (char *)scheme_malloc_atomic(100);
quick_encode_buffer = (char *)scheme_malloc_atomic(QUICK_ENCODE_BUFFER_SIZE);
REGISTER_SO(quote_link_symbol);
@ -159,6 +155,15 @@ void scheme_init_print(Scheme_Env *env)
REGISTER_SO(cache_ht);
}
void scheme_init_print_buffers_places()
{
REGISTER_SO(quick_buffer);
REGISTER_SO(quick_encode_buffer);
quick_buffer = (char *)scheme_malloc_atomic(100);
quick_encode_buffer = (char *)scheme_malloc_atomic(QUICK_ENCODE_BUFFER_SIZE);
}
Scheme_Object *scheme_make_svector(mzshort c, mzshort *a)
{
Scheme_Object *o;
@ -1051,8 +1056,9 @@ static void do_print_string(int compact, int notdisplay,
buf = (char *)scheme_malloc_atomic(el);
reset = 0;
}
el = scheme_utf8_encode(s, offset, offset + l,
(unsigned char *)buf, 0, 0);
el = scheme_utf8_encode(s, offset, offset + l, (unsigned char *)buf, 0, 0);
if (compact) {
print_compact(pp, CPT_CHAR_STRING);
print_compact_number(pp, el);
@ -1061,6 +1067,7 @@ static void do_print_string(int compact, int notdisplay,
} else {
print_char_string(buf, el, s, offset, l, notdisplay, 0, pp);
}
if (reset)
quick_encode_buffer = buf;
}

View File

@ -210,6 +210,8 @@ void scheme_init_foreign(Scheme_Env *env);
#endif
void scheme_init_place(Scheme_Env *env);
void scheme_init_print_buffers_places(void);
void scheme_free_dynamic_extensions(void);
/* Type readers & writers for compiled code data */