mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2025-12-06 02:40:26 -08:00
modules: [3/n] introduce ecl_module_process
This commit is contained in:
parent
10c03bedfc
commit
46b0aa512d
4 changed files with 60 additions and 22 deletions
|
|
@ -178,11 +178,7 @@ ecl_boot(void)
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
init_process();
|
|
||||||
init_modules();
|
init_modules();
|
||||||
/* init_unixint(); */
|
|
||||||
/* init_garbage(); */
|
|
||||||
|
|
||||||
ecl_core.path_max = MAXPATHLEN;
|
ecl_core.path_max = MAXPATHLEN;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ ecl_init_env(cl_env_ptr env)
|
||||||
void
|
void
|
||||||
_ecl_dealloc_env(cl_env_ptr env)
|
_ecl_dealloc_env(cl_env_ptr env)
|
||||||
{
|
{
|
||||||
env->own_process = ECL_NIL;
|
|
||||||
ecl_modules_free_env(env);
|
ecl_modules_free_env(env);
|
||||||
free_stacks(env);
|
free_stacks(env);
|
||||||
#if defined(ECL_USE_MPROTECT)
|
#if defined(ECL_USE_MPROTECT)
|
||||||
|
|
@ -152,7 +151,6 @@ _ecl_alloc_env(cl_env_ptr parent)
|
||||||
output->bds_stack.tl_bindings_size = 0;
|
output->bds_stack.tl_bindings_size = 0;
|
||||||
output->bds_stack.tl_bindings = NULL;
|
output->bds_stack.tl_bindings = NULL;
|
||||||
#endif
|
#endif
|
||||||
output->own_process = ECL_NIL;
|
|
||||||
output->c_stack.org = NULL;
|
output->c_stack.org = NULL;
|
||||||
for (cl_index i = 0; i < ECL_BIGNUM_REGISTER_NUMBER; i++) {
|
for (cl_index i = 0; i < ECL_BIGNUM_REGISTER_NUMBER; i++) {
|
||||||
output->big_register[i] = ECL_NIL;
|
output->big_register[i] = ECL_NIL;
|
||||||
|
|
@ -289,6 +287,7 @@ cl_boot(int argc, char **argv)
|
||||||
ARGV = argv;
|
ARGV = argv;
|
||||||
ecl_self = argv[0];
|
ecl_self = argv[0];
|
||||||
|
|
||||||
|
ecl_add_module(ecl_module_process);
|
||||||
ecl_add_module(ecl_module_gc);
|
ecl_add_module(ecl_module_gc);
|
||||||
ecl_add_module(ecl_module_unixint);
|
ecl_add_module(ecl_module_unixint);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,6 @@ ecl_disown_cpu()
|
||||||
#ifdef ECL_WINDOWS_THREADS
|
#ifdef ECL_WINDOWS_THREADS
|
||||||
CloseHandle(the_env->thread);
|
CloseHandle(the_env->thread);
|
||||||
#endif
|
#endif
|
||||||
ecl_set_process_env(NULL);
|
|
||||||
del_env(the_env);
|
del_env(the_env);
|
||||||
_ecl_dealloc_env(the_env);
|
_ecl_dealloc_env(the_env);
|
||||||
unregister_gc_thread();
|
unregister_gc_thread();
|
||||||
|
|
@ -212,7 +211,6 @@ thread_entry_point(void *ptr)
|
||||||
cl_env_ptr the_env = ecl_cast_ptr(cl_env_ptr, ptr);
|
cl_env_ptr the_env = ecl_cast_ptr(cl_env_ptr, ptr);
|
||||||
cl_object process = the_env->own_process;
|
cl_object process = the_env->own_process;
|
||||||
/* Setup the environment for the execution of the thread. */
|
/* Setup the environment for the execution of the thread. */
|
||||||
ecl_set_process_env(the_env);
|
|
||||||
ecl_modules_init_cpu(the_env);
|
ecl_modules_init_cpu(the_env);
|
||||||
ecl_cs_init(the_env);
|
ecl_cs_init(the_env);
|
||||||
|
|
||||||
|
|
@ -228,8 +226,6 @@ thread_entry_point(void *ptr)
|
||||||
* mp_interrupt_process() and mp_process_kill(). */
|
* mp_interrupt_process() and mp_process_kill(). */
|
||||||
|
|
||||||
ecl_disable_interrupts_env(the_env);
|
ecl_disable_interrupts_env(the_env);
|
||||||
ecl_set_process_env(NULL);
|
|
||||||
the_env->own_process = ECL_NIL;
|
|
||||||
ecl_modules_free_cpu(the_env);
|
ecl_modules_free_cpu(the_env);
|
||||||
del_env(the_env);
|
del_env(the_env);
|
||||||
#ifdef ECL_WINDOWS_THREADS
|
#ifdef ECL_WINDOWS_THREADS
|
||||||
|
|
@ -317,16 +313,11 @@ ecl_spawn_cpu(cl_object process)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* -- Initialiation --------------------------------------------------------- */
|
/* -- Module definition (so meta!) ------------------------------------------ */
|
||||||
|
static cl_object
|
||||||
void
|
create_process(void)
|
||||||
init_process(void)
|
|
||||||
{
|
{
|
||||||
cl_env_ptr the_env = ecl_core.first_env;
|
|
||||||
#ifdef ECL_THREADS
|
#ifdef ECL_THREADS
|
||||||
ecl_thread_t main_thread;
|
|
||||||
ecl_set_process_self(main_thread);
|
|
||||||
the_env->thread = main_thread;
|
|
||||||
ecl_process_key_create(cl_env_key);
|
ecl_process_key_create(cl_env_key);
|
||||||
ecl_mutex_init(&ecl_core.processes_lock, 1);
|
ecl_mutex_init(&ecl_core.processes_lock, 1);
|
||||||
ecl_mutex_init(&ecl_core.global_lock, 1);
|
ecl_mutex_init(&ecl_core.global_lock, 1);
|
||||||
|
|
@ -334,8 +325,59 @@ init_process(void)
|
||||||
ecl_rwlock_init(&ecl_core.global_env_lock);
|
ecl_rwlock_init(&ecl_core.global_env_lock);
|
||||||
ecl_core.threads = ecl_make_stack(16);
|
ecl_core.threads = ecl_make_stack(16);
|
||||||
#endif
|
#endif
|
||||||
ecl_set_process_env(the_env);
|
return ECL_NIL;
|
||||||
the_env->c_stack.org = NULL;
|
|
||||||
the_env->method_cache = NULL;
|
|
||||||
the_env->slot_cache = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cl_object
|
||||||
|
init_env_process(cl_env_ptr the_env)
|
||||||
|
{
|
||||||
|
#ifdef ECL_THREAD
|
||||||
|
the_env->own_process = ECL_NIL;
|
||||||
|
#endif
|
||||||
|
return ECL_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cl_object
|
||||||
|
init_cpu_process(cl_env_ptr the_env)
|
||||||
|
{
|
||||||
|
ecl_set_process_env(the_env);
|
||||||
|
return ECL_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cl_object
|
||||||
|
free_cpu_process(cl_env_ptr the_env)
|
||||||
|
{
|
||||||
|
ecl_set_process_env(NULL);
|
||||||
|
return ECL_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cl_object
|
||||||
|
free_env_process(cl_env_ptr the_env)
|
||||||
|
{
|
||||||
|
#ifdef ECL_THREAD
|
||||||
|
the_env->own_process = ECL_NIL;
|
||||||
|
#endif
|
||||||
|
return ECL_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cl_object
|
||||||
|
destroy_process(void)
|
||||||
|
{
|
||||||
|
return ECL_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecl_def_ct_base_string(str_process, "PROCESS", 7, static, const);
|
||||||
|
|
||||||
|
static struct ecl_module module_process = {
|
||||||
|
.name = str_process,
|
||||||
|
.create = create_process,
|
||||||
|
.enable = ecl_module_no_op,
|
||||||
|
.init_env = init_env_process,
|
||||||
|
.init_cpu = init_cpu_process,
|
||||||
|
.free_cpu = free_cpu_process,
|
||||||
|
.free_env = free_env_process,
|
||||||
|
.disable = ecl_module_no_op,
|
||||||
|
.destroy = destroy_process
|
||||||
|
};
|
||||||
|
|
||||||
|
cl_object ecl_module_process = (cl_object)&module_process;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ extern "C" {
|
||||||
#define unlikely_if(x) if (ecl_unlikely(x))
|
#define unlikely_if(x) if (ecl_unlikely(x))
|
||||||
|
|
||||||
/* booting */
|
/* booting */
|
||||||
|
extern ECL_API cl_object ecl_module_process;
|
||||||
extern ECL_API cl_object ecl_module_dummy;
|
extern ECL_API cl_object ecl_module_dummy;
|
||||||
extern ECL_API cl_object ecl_module_gc;
|
extern ECL_API cl_object ecl_module_gc;
|
||||||
extern ECL_API cl_object ecl_module_unixint;
|
extern ECL_API cl_object ecl_module_unixint;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue