mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-16 06:12:25 -08:00
ecl_init_env() split into ecl_init_env and ecl_cs_set_org() so that the former does not need to be executed in the same thread where it is going to be used.
This commit is contained in:
parent
24138f8fd9
commit
8382e4e800
4 changed files with 33 additions and 37 deletions
16
src/c/main.d
16
src/c/main.d
|
|
@ -203,8 +203,6 @@ ecl_set_option(int option, cl_fixnum value)
|
|||
void
|
||||
ecl_init_env(cl_env_ptr env)
|
||||
{
|
||||
char i;
|
||||
|
||||
env->c_env = NULL;
|
||||
|
||||
env->string_pool = Cnil;
|
||||
|
|
@ -221,17 +219,6 @@ ecl_init_env(cl_env_ptr env)
|
|||
env->indent_stack = ecl_alloc_atomic(ECL_PPRINT_INDENTATION_STACK_SIZE * sizeof(short));
|
||||
env->fmt_aux_stream = ecl_make_string_output_stream(64, 1);
|
||||
#endif
|
||||
#if !defined(GBC_BOEHM)
|
||||
# if defined(THREADS)
|
||||
# error "No means to mark the stack of a thread :-/"
|
||||
# else
|
||||
/* Rough estimate. Not very safe. We assume that cl_boot()
|
||||
* is invoked from the main() routine of the program.
|
||||
*/
|
||||
env->cs_org = (char*)(&env);
|
||||
# endif /* THREADS */
|
||||
#endif /* !GBC_BOEHM */
|
||||
|
||||
#ifdef HAVE_LIBFFI
|
||||
env->ffi_args_limit = 0;
|
||||
env->ffi_types = 0;
|
||||
|
|
@ -254,7 +241,7 @@ ecl_init_env(cl_env_ptr env)
|
|||
#endif
|
||||
env->pending_interrupt = Cnil;
|
||||
|
||||
init_stacks(env, &i);
|
||||
init_stacks(env);
|
||||
|
||||
{
|
||||
int i;
|
||||
|
|
@ -532,6 +519,7 @@ cl_boot(int argc, char **argv)
|
|||
*/
|
||||
init_big();
|
||||
ecl_init_env(env);
|
||||
ecl_cs_set_org(env);
|
||||
#if !defined(GBC_BOEHM)
|
||||
/* We need this because a lot of stuff is to be created */
|
||||
init_GC();
|
||||
|
|
|
|||
|
|
@ -72,6 +72,34 @@ ecl_cs_overflow(void)
|
|||
cs_set_size(env, size);
|
||||
}
|
||||
|
||||
void
|
||||
ecl_cs_set_org(cl_env_ptr env)
|
||||
{
|
||||
/* Rough estimate. Not very safe. We assume that cl_boot()
|
||||
* is invoked from the main() routine of the program.
|
||||
*/
|
||||
env->cs_org = (char*)(&env);
|
||||
env->cs_barrier = env->cs_org;
|
||||
#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_STACK)
|
||||
{
|
||||
struct rlimit rl;
|
||||
cl_index size;
|
||||
getrlimit(RLIMIT_STACK, &rl);
|
||||
if (rl.rlim_cur != RLIM_INFINITY) {
|
||||
size = rl.rlim_cur / 2;
|
||||
if (size > (cl_index)ecl_get_option(ECL_OPT_C_STACK_SIZE))
|
||||
ecl_set_option(ECL_OPT_C_STACK_SIZE, size);
|
||||
#ifdef ECL_DOWN_STACK
|
||||
env->cs_barrier = env->cs_org - rl.rlim_cur - 1024;
|
||||
#else
|
||||
env->cs_barrier = env->cs_org + rl.rlim_cur + 1024;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
cs_set_size(env, ecl_get_option(ECL_OPT_C_STACK_SIZE));
|
||||
}
|
||||
|
||||
|
||||
/********************* BINDING STACK ************************/
|
||||
|
||||
|
|
@ -562,7 +590,7 @@ si_get_limit(cl_object type)
|
|||
}
|
||||
|
||||
void
|
||||
init_stacks(cl_env_ptr env, char *new_cs_org)
|
||||
init_stacks(cl_env_ptr env)
|
||||
{
|
||||
static struct ihs_frame ihs_org = { NULL, NULL, NULL, 0};
|
||||
cl_index size, margin;
|
||||
|
|
@ -586,27 +614,6 @@ init_stacks(cl_env_ptr env, char *new_cs_org)
|
|||
ihs_org.lex_env = Cnil;
|
||||
ihs_org.index = 0;
|
||||
|
||||
env->cs_org = new_cs_org;
|
||||
env->cs_barrier = new_cs_org;
|
||||
#if defined(HAVE_SYS_RESOURCE_H) && defined(RLIMIT_STACK)
|
||||
{
|
||||
struct rlimit rl;
|
||||
cl_index size;
|
||||
getrlimit(RLIMIT_STACK, &rl);
|
||||
if (rl.rlim_cur != RLIM_INFINITY) {
|
||||
size = rl.rlim_cur / 2;
|
||||
if (size > (cl_index)ecl_get_option(ECL_OPT_C_STACK_SIZE))
|
||||
ecl_set_option(ECL_OPT_C_STACK_SIZE, size);
|
||||
#ifdef ECL_DOWN_STACK
|
||||
env->cs_barrier = env->cs_org - rl.rlim_cur - 1024;
|
||||
#else
|
||||
env->cs_barrier = env->cs_org + rl.rlim_cur + 1024;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
cs_set_size(env, ecl_get_option(ECL_OPT_C_STACK_SIZE));
|
||||
|
||||
#if 0 /* defined(HAVE_SIGPROCMASK) && defined(SA_SIGINFO) && defined(SA_ONSTACK) */
|
||||
if (ecl_get_option(ECL_OPT_SIGALTSTACK_SIZE)) {
|
||||
stack_t new_stack;
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ thread_entry_point(void *arg)
|
|||
cl_core.processes = CONS(process, cl_core.processes);
|
||||
THREAD_OP_UNLOCK();
|
||||
ecl_init_env(env);
|
||||
ecl_cs_set_org(env);
|
||||
env->bindings_hash = process->process.initial_bindings;
|
||||
ecl_enable_interrupts_env(env);
|
||||
env->trap_fpe_bits = process->process.trap_fpe_bits;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ extern void init_GC(void);
|
|||
extern void init_macros(void);
|
||||
extern void init_number(void);
|
||||
extern void init_read(void);
|
||||
extern void init_stacks(cl_env_ptr, char *);
|
||||
extern void init_stacks(cl_env_ptr);
|
||||
extern void init_unixint(int pass);
|
||||
extern void init_unixtime(void);
|
||||
#ifdef mingw32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue