modules: [9/n] introduce ecl_module_thread

This commit is contained in:
Daniel Kochmański 2024-12-03 11:20:19 +01:00
parent 907036afcb
commit 4ece70632d
3 changed files with 60 additions and 17 deletions

View file

@ -42,17 +42,6 @@ const char *ecl_self;
static int ARGC;
static char **ARGV;
void
ecl_init_first_env(cl_env_ptr the_env)
{
the_env->default_sigmask = ecl_core.first_env->default_sigmask;
#ifdef ECL_THREADS
init_threads();
#else
ecl_cs_init(env);
#endif
}
void
ecl_init_env(cl_env_ptr env)
{
@ -244,6 +233,9 @@ cl_boot(int argc, char **argv)
ecl_add_module(ecl_module_stacks);
ecl_add_module(ecl_module_gc);
ecl_add_module(ecl_module_unixint);
#ifdef ECL_THREADS
ecl_add_module(ecl_module_thread);
#endif
ecl_add_module(ecl_module_bignum);
ecl_add_module(ecl_module_ffi);
ecl_add_module(ecl_module_aux);
@ -255,7 +247,6 @@ cl_boot(int argc, char **argv)
*/
env = ecl_core.first_env;
ecl_init_first_env(env);
/* We need to enable GC because a lot of stuff is to be created */
ecl_module_gc->module.enable();

View file

@ -474,12 +474,17 @@ mp_restore_signals(cl_object sigmask)
#endif
}
/* -- Initialization ------------------------------------------------ */
/* -- Module definition --------------------------------------------- */
void
init_threads()
{
cl_env_ptr the_env = ecl_process_env();
}
static cl_object
create_thread()
{
cl_env_ptr the_env = ecl_core.first_env;
cl_object process, _env = ecl_cast_ptr(cl_object,the_env);
/* We have to set the environment before any allocation takes place,
* so that the interrupt handling code works. */
@ -493,4 +498,51 @@ init_threads()
ecl_cond_var_init(&process->process.exit_barrier);
the_env->own_process = process;
ecl_stack_push(ecl_core.threads, _env);
return ECL_NIL;
}
static cl_object
enable_thread()
{
return ECL_NIL;
}
static cl_object
init_env_thread(cl_env_ptr the_env)
{
return ECL_NIL;
}
static cl_object
init_cpu_thread(cl_env_ptr the_env)
{
return ECL_NIL;
}
static cl_object
free_cpu_thread(cl_env_ptr the_env)
{
return ECL_NIL;
}
static cl_object
free_env_thread(cl_env_ptr the_env)
{
return ECL_NIL;
}
ecl_def_ct_base_string(str_thread, "THREAD", 6, static, const);
static struct ecl_module module_thread = {
.name = str_thread,
.create = create_thread,
.enable = enable_thread,
.init_env = init_env_thread,
.init_cpu = init_cpu_thread,
.free_cpu = free_cpu_thread,
.free_env = free_env_thread,
.disable = ecl_module_no_op,
.destroy = ecl_module_no_op
};
cl_object ecl_module_thread = (cl_object)&module_thread;

View file

@ -28,6 +28,9 @@ extern ECL_API cl_object ecl_module_stacks;
extern ECL_API cl_object ecl_module_dummy;
extern ECL_API cl_object ecl_module_gc;
extern ECL_API cl_object ecl_module_unixint;
#ifdef ECL_THREADS
extern ECL_API cl_object ecl_module_thread;
#endif
extern ECL_API cl_object ecl_module_bignum;
extern ECL_API cl_object ecl_module_ffi;
extern ECL_API cl_object ecl_module_aux;
@ -46,9 +49,6 @@ extern void init_unixtime(void);
extern void init_compiler(void);
extern void init_process(void);
extern void init_modules(void);
#ifdef ECL_THREADS
extern void init_threads(void);
#endif
extern void ecl_init_env(cl_env_ptr);
extern void init_lib_LSP(cl_object);