From e550aad6ef329ff7b164fbe7520fcfaaf51a7fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Tue, 3 Dec 2024 10:00:55 +0100 Subject: [PATCH] modules: [6/n] introduce ecl_module_aux --- src/c/main.d | 66 +++++++++++++++++++++++++++++++++--------------- src/h/internal.h | 1 + 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/c/main.d b/src/c/main.d index 61bbdc34f..41382a942 100644 --- a/src/c/main.d +++ b/src/c/main.d @@ -42,24 +42,6 @@ const char *ecl_self; static int ARGC; static char **ARGV; -static void -init_env_aux(cl_env_ptr env) -{ - /* Reader */ - env->string_pool = ECL_NIL; - env->packages_to_be_created = ECL_NIL; - env->packages_to_be_created_p = ECL_NIL; - /* Format (written in C) */ -#if !defined(ECL_CMU_FORMAT) - env->fmt_aux_stream = ecl_make_string_output_stream(64, 1); -#endif - /* Bytecodes compiler environment */ - env->c_env = NULL; - /* CLOS caches */ - env->method_cache = ecl_make_cache(64, 4096); - env->slot_cache = ecl_make_cache(3, 4096); -} - void ecl_init_first_env(cl_env_ptr the_env) { @@ -70,7 +52,6 @@ ecl_init_first_env(cl_env_ptr the_env) ecl_cs_init(env); #endif ecl_cs_init(the_env); - init_env_aux(the_env); init_stacks(the_env); } @@ -78,7 +59,6 @@ void ecl_init_env(cl_env_ptr env) { ecl_modules_init_env(env); - init_env_aux(env); init_stacks(env); } @@ -136,7 +116,6 @@ _ecl_alloc_env(cl_env_ptr parent) output->bds_stack.tl_bindings = NULL; #endif output->c_stack.org = NULL; - output->method_cache = output->slot_cache = NULL; return output; } @@ -273,6 +252,7 @@ cl_boot(int argc, char **argv) ecl_add_module(ecl_module_unixint); ecl_add_module(ecl_module_bignum); ecl_add_module(ecl_module_ffi); + ecl_add_module(ecl_module_aux); /* * Initialize the per-thread data. @@ -549,6 +529,50 @@ cl_boot(int argc, char **argv) return 1; } +/* -- Module definition (auxiliary structures) ------------------------------- */ +static cl_object +create_aux() +{ + cl_env_ptr the_env = ecl_core.first_env; + the_env->method_cache = NULL; + the_env->slot_cache = NULL; + return ECL_NIL; +} + +static cl_object +init_env_aux(cl_env_ptr the_env) +{ + /* Reader */ + the_env->string_pool = ECL_NIL; + the_env->packages_to_be_created = ECL_NIL; + the_env->packages_to_be_created_p = ECL_NIL; + /* Format (written in C) */ +#if !defined(ECL_CMU_FORMAT) + the_env->fmt_aux_stream = ecl_make_string_output_stream(64, 1); +#endif + /* Bytecodes compiler environment */ + the_env->c_env = NULL; + /* CLOS caches */ + the_env->method_cache = ecl_make_cache(64, 4096); + the_env->slot_cache = ecl_make_cache(3, 4096); + return ECL_NIL; +} + +ecl_def_ct_base_string(str_aux, "AUX", 3, static, const); + +static struct ecl_module module_aux = { + .name = str_aux, + .create = create_aux, + .enable = ecl_module_no_op, + .init_env = init_env_aux, + .init_cpu = ecl_module_no_op_env, + .free_cpu = ecl_module_no_op_cpu, + .free_env = ecl_module_no_op_env, + .disable = ecl_module_no_op, + .destroy = ecl_module_no_op +}; +cl_object ecl_module_aux = (cl_object)&module_aux; + /************************* ENVIRONMENT ROUTINES ***********************/ @(defun ext::quit (&optional (code ecl_make_fixnum(0)) (kill_all_threads ECL_T)) diff --git a/src/h/internal.h b/src/h/internal.h index 7510f2d88..9ef240338 100755 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -29,6 +29,7 @@ extern ECL_API cl_object ecl_module_gc; extern ECL_API cl_object ecl_module_unixint; extern ECL_API cl_object ecl_module_bignum; extern ECL_API cl_object ecl_module_ffi; +extern ECL_API cl_object ecl_module_aux; extern void init_all_symbols(void); extern void init_backq(void);