mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-14 05:12:38 -08:00
Implemented an interface for setting/querying options with numeric values and used it for stack sizes and limits.
This commit is contained in:
parent
a86e4bfb5a
commit
89a5283927
16 changed files with 187 additions and 144 deletions
|
|
@ -54,6 +54,32 @@ ECL 8.9.0:
|
|||
- In platforms that support sigaltstack(), ECL may detect stack overflows and
|
||||
gracefully quit.
|
||||
|
||||
* Embedding:
|
||||
|
||||
- ECL now implements a more transparent interface for setting and querying
|
||||
options related to signal trapping, stack sizes and general behavior. These
|
||||
are options that should be set before calling cl_boot() to customize later
|
||||
behavior. It does not make sense to change them at run time. The current
|
||||
list of options is set with ecl_set_option(code, value) and queried with
|
||||
ecl_get_option(code):
|
||||
ECL_OPT_INCREMENTAL_GC,
|
||||
ECL_OPT_TRAP_SIGSEGV,
|
||||
ECL_OPT_TRAP_SIGFPE,
|
||||
ECL_OPT_TRAP_SIGINT,
|
||||
ECL_OPT_TRAP_SIGILL,
|
||||
ECL_OPT_TRAP_SIGBUS,
|
||||
ECL_OPT_BOOTED, /* read only */
|
||||
ECL_OPT_BIND_STACK_SIZE,
|
||||
ECL_OPT_BIND_STACK_SAFETY_AREA,
|
||||
ECL_OPT_FRAME_STACK_SIZE,
|
||||
ECL_OPT_FRAME_STACK_SAFETY_AREA,
|
||||
ECL_OPT_LISP_STACK_SIZE,
|
||||
ECL_OPT_LISP_STACK_SAFETY_AREA,
|
||||
ECL_OPT_C_STACK_SIZE,
|
||||
ECL_OPT_C_STACK_SAFETY_AREA,
|
||||
ECL_OPT_SIGALTSTACK_SIZE,
|
||||
ECL_OPT_LIMIT
|
||||
|
||||
* Bugs fixed:
|
||||
|
||||
- The optimizer for COERCE might enter an infinite loop for certain
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ init_alloc(void)
|
|||
GC_all_interior_pointers = 0;
|
||||
GC_time_limit = GC_TIME_UNLIMITED;
|
||||
GC_init();
|
||||
if (ecl_get_option(ECL_INCREMENTAL_GC)) {
|
||||
if (ecl_get_option(ECL_OPT_INCREMENTAL_GC)) {
|
||||
GC_enable_incremental();
|
||||
}
|
||||
GC_register_displacement(1);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ cl_fmakunbound(cl_object fname)
|
|||
void
|
||||
ecl_clear_compiler_properties(cl_object sym)
|
||||
{
|
||||
if (ecl_booted) {
|
||||
if (ecl_get_option(ECL_OPT_BOOTED)) {
|
||||
si_unlink_symbol(sym);
|
||||
funcall(2, @'si::clear-compiler-properties', sym);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,19 +26,6 @@
|
|||
#endif
|
||||
#include <ecl/internal.h>
|
||||
|
||||
void
|
||||
ecl_cs_overflow(void)
|
||||
{
|
||||
#ifdef DOWN_STACK
|
||||
if (cl_env.cs_limit < cl_env.cs_org - cl_env.cs_size)
|
||||
cl_env.cs_limit -= CSGETA;
|
||||
#else
|
||||
if (cl_env.cs_limit > cl_env.cs_org + cl_env.cs_size)
|
||||
cl_env.cs_limit += CSGETA;
|
||||
#endif
|
||||
FEerror("Control stack overflow.", 0);
|
||||
}
|
||||
|
||||
void
|
||||
ecl_internal_error(const char *s)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@
|
|||
/* -------------------- INTERPRETER STACK -------------------- */
|
||||
|
||||
void
|
||||
cl_stack_set_size(cl_index new_size)
|
||||
cl_stack_set_size(cl_index tentative_new_size)
|
||||
{
|
||||
cl_index top = cl_env.stack_top - cl_env.stack;
|
||||
cl_object *new_stack;
|
||||
|
||||
/*printf("*+*+*+\n");*/
|
||||
cl_index safety_area = ecl_get_option(ECL_OPT_LISP_STACK_SAFETY_AREA);
|
||||
cl_index new_size = tentative_new_size + 2*safety_area;
|
||||
|
||||
if (top > new_size)
|
||||
FEerror("Internal error: cannot shrink stack that much.",0);
|
||||
|
|
@ -46,7 +46,7 @@ cl_stack_set_size(cl_index new_size)
|
|||
cl_env.stack_size = new_size;
|
||||
cl_env.stack = new_stack;
|
||||
cl_env.stack_top = cl_env.stack + top;
|
||||
cl_env.stack_limit = cl_env.stack + (new_size - 2);
|
||||
cl_env.stack_limit = cl_env.stack + (new_size - 2*safety_area);
|
||||
|
||||
/* A stack always has at least one element. This is assumed by cl__va_start
|
||||
* and friends, which take a sp=0 to have no arguments.
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ si_load_binary(cl_object filename, cl_object verbose, cl_object print)
|
|||
/* A full garbage collection enables us to detect unused code
|
||||
and leave space for the library to be loaded. This is only
|
||||
required when we use the dlopen wrappers. */
|
||||
if (!ecl_get_option(ECL_INCREMENTAL_GC)) {
|
||||
if (!ecl_get_option(ECL_OPT_INCREMENTAL_GC)) {
|
||||
si_gc(Ct);
|
||||
}
|
||||
|
||||
|
|
|
|||
72
src/c/main.d
72
src/c/main.d
|
|
@ -39,7 +39,6 @@ extern int GC_dont_gc;
|
|||
|
||||
/******************************* EXPORTS ******************************/
|
||||
|
||||
bool ecl_booted = 0;
|
||||
#if !defined(ECL_THREADS)
|
||||
struct cl_env_struct cl_env;
|
||||
#elif defined(WITH___THREAD)
|
||||
|
|
@ -52,41 +51,61 @@ const char *ecl_self;
|
|||
|
||||
static int ARGC;
|
||||
static char **ARGV;
|
||||
static cl_index boot_options = ECL_TRAP_SIGSEGV
|
||||
| ECL_TRAP_SIGFPE
|
||||
| ECL_TRAP_SIGINT
|
||||
| ECL_TRAP_SIGILL
|
||||
static cl_fixnum option_values[ECL_OPT_LIMIT] = {
|
||||
#ifdef GBC_BOEHM_GENGC
|
||||
| ECL_INCREMENTAL_GC
|
||||
1, /* ECL_OPT_INCREMENTAL_GC */
|
||||
#else
|
||||
0, /* ECL_OPT_INCREMENTAL_GC */
|
||||
#endif
|
||||
| ECL_TRAP_SIGBUS;
|
||||
1, /* ECL_OPT_TRAP_SIGSEGV */
|
||||
1, /* ECL_OPT_TRAP_SIGFPE */
|
||||
1, /* ECL_OPT_TRAP_SIGINT */
|
||||
1, /* ECL_OPT_TRAP_SIGILL */
|
||||
1, /* ECL_OPT_TRAP_SIGBUS */
|
||||
0, /* ECL_OPT_BOOTED */
|
||||
8192, /* ECL_OPT_BIND_STACK_SIZE */
|
||||
128, /* ECL_OPT_BIND_STACK_SAFETY_AREA */
|
||||
2048, /* ECL_OPT_FRAME_STACK_SIZE */
|
||||
128, /* ECL_OPT_FRAME_STACK_SAFETY_AREA */
|
||||
32768, /* ECL_OPT_LISP_STACK_SIZE */
|
||||
128, /* ECL_OPT_LISP_STACK_SAFETY_AREA */
|
||||
#ifdef THREADS
|
||||
7500, /* ECL_OPT_C_STACK_SIZE */
|
||||
500, /* ECL_OPT_C_STACK_SAFETY_AREA */
|
||||
#else
|
||||
20000, /* ECL_OPT_C_STACK_SIZE */
|
||||
4000, /* ECL_OPT_C_STACK_SAFETY_AREA */
|
||||
#endif
|
||||
1, /* ECL_OPT_SIGALTSTACK_SIZE */
|
||||
0};
|
||||
|
||||
#if !defined(GBC_BOEHM)
|
||||
static char stdin_buf[BUFSIZ];
|
||||
static char stdout_buf[BUFSIZ];
|
||||
#endif
|
||||
|
||||
int
|
||||
cl_fixnum
|
||||
ecl_get_option(int option)
|
||||
{
|
||||
if (option > ECL_INCREMENTAL_GC || option < 0) {
|
||||
FEerror("Invalid boot option ~D", 0, MAKE_FIXNUM(option));
|
||||
if (option >= ECL_OPT_LIMIT || option < 0) {
|
||||
FEerror("Invalid boot option ~D", 1, MAKE_FIXNUM(option));
|
||||
} else {
|
||||
return option_values[option];
|
||||
}
|
||||
return (boot_options & option);
|
||||
}
|
||||
|
||||
void
|
||||
ecl_set_option(int option, int value)
|
||||
ecl_set_option(int option, cl_fixnum value)
|
||||
{
|
||||
if (option > ECL_INCREMENTAL_GC || option < 0) {
|
||||
FEerror("Invalid boot option ~D", 0, MAKE_FIXNUM(option));
|
||||
if (option > ECL_OPT_LIMIT || option < 0) {
|
||||
FEerror("Invalid boot option ~D", 1, MAKE_FIXNUM(option));
|
||||
} else {
|
||||
cl_index mask = option;
|
||||
if (value) {
|
||||
boot_options |= mask;
|
||||
} else {
|
||||
boot_options &= ~mask;
|
||||
if (option > ECL_OPT_BOOTED &&
|
||||
option_values[ECL_OPT_BOOTED]) {
|
||||
FEerror("Cannot change option ~D while ECL is running",
|
||||
1, MAKE_FIXNUM(option));
|
||||
}
|
||||
option_values[option] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +122,7 @@ ecl_init_env(struct cl_env_struct *env)
|
|||
env->stack_top = NULL;
|
||||
env->stack_limit = NULL;
|
||||
env->stack_size = 0;
|
||||
cl_stack_set_size(16*LISP_PAGESIZE);
|
||||
cl_stack_set_size(ecl_get_option(ECL_OPT_LISP_STACK_SIZE));
|
||||
|
||||
#if !defined(ECL_CMU_FORMAT)
|
||||
env->print_pretty = FALSE;
|
||||
|
|
@ -185,7 +204,7 @@ static const struct {
|
|||
int
|
||||
cl_shutdown(void)
|
||||
{
|
||||
if (ecl_booted > 0) {
|
||||
if (ecl_get_option(ECL_OPT_BOOTED) > 0) {
|
||||
cl_object l = SYM_VAL(@'si::*exit-hooks*');
|
||||
cl_object form = cl_list(2, @'funcall', Cnil);
|
||||
while (CONSP(l)) {
|
||||
|
|
@ -201,7 +220,7 @@ cl_shutdown(void)
|
|||
ecl_tcp_close_all();
|
||||
#endif
|
||||
}
|
||||
ecl_booted = -1;
|
||||
ecl_set_option(ECL_OPT_BOOTED, -1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -212,10 +231,11 @@ cl_boot(int argc, char **argv)
|
|||
cl_object features;
|
||||
int i;
|
||||
|
||||
if (ecl_booted) {
|
||||
if (ecl_booted < 0) {
|
||||
i = ecl_get_option(ECL_OPT_BOOTED);
|
||||
if (i) {
|
||||
if (i < 0) {
|
||||
/* We have called cl_shutdown and want to use ECL again. */
|
||||
ecl_booted = 1;
|
||||
ecl_set_option(ECL_OPT_BOOTED, 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -549,7 +569,7 @@ cl_boot(int argc, char **argv)
|
|||
|
||||
/* This has to come before init_LSP/CLOS, because we need
|
||||
* ecl_clear_compiler_properties() to work in init_CLOS(). */
|
||||
ecl_booted = 1;
|
||||
ecl_set_option(ECL_OPT_BOOTED, 1);
|
||||
|
||||
read_VV(OBJNULL,init_lib_LSP);
|
||||
|
||||
|
|
|
|||
|
|
@ -278,7 +278,8 @@ ecl_find_package_nolock(cl_object name)
|
|||
#ifdef ECL_RELATIVE_PACKAGE_NAMES
|
||||
/* Note that this function may actually be called _before_ symbols are set up
|
||||
* and bound! */
|
||||
if (ecl_booted && SYM_VAL(@'si::*relative-package-names*') != Cnil) {
|
||||
if (ecl_get_option(ECL_OPT_BOOTED) &&
|
||||
SYM_VAL(@'si::*relative-package-names*') != Cnil) {
|
||||
return si_find_relative_package(1, name);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
144
src/c/stacks.d
144
src/c/stacks.d
|
|
@ -23,6 +23,47 @@
|
|||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
/************************ C STACK ***************************/
|
||||
|
||||
static void
|
||||
cs_set_size(cl_index new_size)
|
||||
{
|
||||
volatile int foo = 0;
|
||||
cl_index safety_area = ecl_get_option(ECL_OPT_C_STACK_SAFETY_AREA);
|
||||
new_size += 2*safety_area;
|
||||
#ifdef DOWN_STACK
|
||||
if (&foo > cl_env.cs_org - new_size + 16)
|
||||
cl_env.cs_limit = cl_env.cs_org - new_size;
|
||||
#else
|
||||
if (&foo < cl_env.cs_org + new_size - 16)
|
||||
cl_env.cs_limit = cl_env.cs_org + new_size;
|
||||
#endif
|
||||
else
|
||||
ecl_internal_error("can't reset cl_env.cs_limit.");
|
||||
}
|
||||
|
||||
void
|
||||
ecl_cs_overflow(void)
|
||||
{
|
||||
cl_index safety_area = ecl_get_option(ECL_OPT_C_STACK_SAFETY_AREA);
|
||||
cl_index size = cl_env.cs_size;
|
||||
#ifdef DOWN_STACK
|
||||
if (cl_env.cs_limit < cl_env.cs_org - size)
|
||||
cl_env.cs_limit -= safety_area;
|
||||
#else
|
||||
if (cl_env.cs_limit > cl_env.cs_org + size)
|
||||
cl_env.cs_limit += safety_area;
|
||||
#endif
|
||||
else
|
||||
ecl_internal_error("Cannot grow stack size.");
|
||||
cl_cerror(6, make_constant_base_string("Extend stack size"),
|
||||
@'ext::stack-overflow', @':size', MAKE_FIXNUM(size),
|
||||
@':type', @'ext::c-stack');
|
||||
size += size / 2;
|
||||
cs_set_size(size);
|
||||
}
|
||||
|
||||
|
||||
/********************* BINDING STACK ************************/
|
||||
|
||||
#ifdef ECL_THREADS
|
||||
|
|
@ -128,12 +169,13 @@ bds_set_size(cl_index size)
|
|||
FEerror("Cannot shrink the binding stack below ~D.", 1,
|
||||
ecl_make_unsigned_integer(limit));
|
||||
} else {
|
||||
cl_index margin = ecl_get_option(ECL_OPT_BIND_STACK_SAFETY_AREA);
|
||||
bds_ptr org;
|
||||
org = cl_alloc_atomic(size * sizeof(*org));
|
||||
memcpy(org, cl_env.bds_org, (cl_env.bds_top - cl_env.bds_org) * sizeof(*org));
|
||||
cl_env.bds_top = org + (cl_env.bds_top - cl_env.bds_org);
|
||||
memcpy(org, cl_env.bds_org, (limit + 1) * sizeof(*org));
|
||||
cl_env.bds_top = org + limit;
|
||||
cl_env.bds_org = org;
|
||||
cl_env.bds_limit = org + (size - 2*BDSGETA);
|
||||
cl_env.bds_limit = org + (size - 2*margin);
|
||||
cl_env.bds_size = size;
|
||||
}
|
||||
}
|
||||
|
|
@ -141,13 +183,14 @@ bds_set_size(cl_index size)
|
|||
void
|
||||
bds_overflow(void)
|
||||
{
|
||||
cl_index margin = ecl_get_option(ECL_OPT_BIND_STACK_SAFETY_AREA);
|
||||
cl_index size = cl_env.bds_size;
|
||||
bds_ptr org = cl_env.bds_org;
|
||||
bds_ptr last = org + size;
|
||||
if (cl_env.bds_limit >= last) {
|
||||
ecl_internal_error("Bind stack overflow, cannot grow larger.");
|
||||
}
|
||||
cl_env.bds_limit += BDSGETA;
|
||||
cl_env.bds_limit += margin;
|
||||
cl_cerror(6, make_constant_base_string("Extend stack size"),
|
||||
@'ext::stack-overflow', @':size', MAKE_FIXNUM(size),
|
||||
@':type', @'ext::binding-stack');
|
||||
|
|
@ -294,12 +337,14 @@ frs_set_size(cl_index size)
|
|||
FEerror("Cannot shrink frame stack below ~D.", 1,
|
||||
ecl_make_unsigned_integer(limit));
|
||||
} else {
|
||||
cl_index margin = ecl_get_option(ECL_OPT_FRAME_STACK_SAFETY_AREA);
|
||||
ecl_frame_ptr org;
|
||||
size += 2*margin;
|
||||
org = cl_alloc_atomic(size * sizeof(*org));
|
||||
memcpy(org, cl_env.frs_org, (cl_env.frs_top - cl_env.frs_org) * sizeof(*org));
|
||||
cl_env.frs_top = org + (cl_env.frs_top - cl_env.frs_org);
|
||||
memcpy(org, cl_env.frs_org, (limit + 1) * sizeof(*org));
|
||||
cl_env.frs_top = org + limit;
|
||||
cl_env.frs_org = org;
|
||||
cl_env.frs_limit = org + (size - 2*FRSGETA);
|
||||
cl_env.frs_limit = org + (size - 2*margin);
|
||||
cl_env.frs_size = size;
|
||||
}
|
||||
}
|
||||
|
|
@ -307,13 +352,14 @@ frs_set_size(cl_index size)
|
|||
static void
|
||||
frs_overflow(void) /* used as condition in list.d */
|
||||
{
|
||||
cl_index margin = ecl_get_option(ECL_OPT_FRAME_STACK_SAFETY_AREA);
|
||||
cl_index size = cl_env.frs_size;
|
||||
ecl_frame_ptr org = cl_env.frs_org;
|
||||
ecl_frame_ptr last = org + size;
|
||||
if (cl_env.frs_limit >= last) {
|
||||
ecl_internal_error("Frame stack overflow, cannot grow larger.");
|
||||
}
|
||||
cl_env.frs_limit += FRSGETA;
|
||||
cl_env.frs_limit += margin;
|
||||
cl_cerror(6, make_constant_base_string("Extend stack size"),
|
||||
@'ext::stack-overflow', @':size', MAKE_FIXNUM(size),
|
||||
@':type', @'ext::frame-stack');
|
||||
|
|
@ -411,31 +457,6 @@ si_sch_frs_base(cl_object fr, cl_object ihs)
|
|||
|
||||
/********************* INITIALIZATION ***********************/
|
||||
|
||||
cl_object
|
||||
si_reset_stack_limits()
|
||||
{
|
||||
volatile int foo = 0;
|
||||
if (cl_env.bds_top < cl_env.bds_org + (cl_env.bds_size - 2*BDSGETA))
|
||||
cl_env.bds_limit = cl_env.bds_org + (cl_env.bds_size - 2*BDSGETA);
|
||||
else
|
||||
ecl_internal_error("can't reset bds_limit.");
|
||||
if (cl_env.frs_top < cl_env.frs_org + (cl_env.frs_size - 2*FRSGETA))
|
||||
cl_env.frs_limit = cl_env.frs_org + (cl_env.frs_size - 2*FRSGETA);
|
||||
else
|
||||
ecl_internal_error("can't reset frs_limit.");
|
||||
#ifdef DOWN_STACK
|
||||
if (&foo > cl_env.cs_org - cl_env.cs_size + 16)
|
||||
cl_env.cs_limit = cl_env.cs_org - cl_env.cs_size;
|
||||
#else
|
||||
if (&foo < cl_env.cs_org + cl_env.cs_size - 16)
|
||||
cl_env.cs_limit = cl_env.cs_org + cl_env.cs_size;
|
||||
#endif
|
||||
else
|
||||
ecl_internal_error("can't reset cl_env.cs_limit.");
|
||||
|
||||
@(return Cnil)
|
||||
}
|
||||
|
||||
cl_object
|
||||
si_set_stack_size(cl_object type, cl_object size)
|
||||
{
|
||||
|
|
@ -454,16 +475,21 @@ void
|
|||
init_stacks(struct cl_env_struct *env, int *new_cs_org)
|
||||
{
|
||||
static struct ihs_frame ihs_org = { NULL, NULL, NULL, 0};
|
||||
cl_index size;
|
||||
cl_index size, margin;
|
||||
|
||||
env->frs_size = size = FRSSIZE + 2*FRSGETA;
|
||||
margin = ecl_get_option(ECL_OPT_FRAME_STACK_SAFETY_AREA);
|
||||
size = ecl_get_option(ECL_OPT_FRAME_STACK_SIZE) + 2 * margin;
|
||||
env->frs_size = size;
|
||||
env->frs_org = (ecl_frame_ptr)cl_alloc_atomic(size * sizeof(*env->frs_org));
|
||||
env->frs_top = env->frs_org-1;
|
||||
env->frs_limit = &env->frs_org[size - 2*FRSGETA];
|
||||
env->bds_size = size = BDSSIZE + 2*BDSGETA;
|
||||
env->frs_limit = &env->frs_org[size - 2*margin];
|
||||
|
||||
margin = ecl_get_option(ECL_OPT_BIND_STACK_SAFETY_AREA);
|
||||
size = ecl_get_option(ECL_OPT_BIND_STACK_SIZE) + 2 * margin;
|
||||
env->bds_size = size;
|
||||
env->bds_org = (bds_ptr)cl_alloc_atomic(size * sizeof(*env->bds_org));
|
||||
env->bds_top = env->bds_org-1;
|
||||
env->bds_limit = &env->bds_org[size - 2*BDSGETA];
|
||||
env->bds_limit = &env->bds_org[size - 2*margin];
|
||||
|
||||
env->ihs_top = &ihs_org;
|
||||
ihs_org.function = @'si::top-level';
|
||||
|
|
@ -475,34 +501,26 @@ init_stacks(struct cl_env_struct *env, int *new_cs_org)
|
|||
{
|
||||
struct rlimit rl;
|
||||
getrlimit(RLIMIT_STACK, &rl);
|
||||
env->cs_size = rl.rlim_cur/4 - 4*CSGETA;
|
||||
ecl_set_option(ECL_OPT_C_STACK_SIZE, rl.rlim_cur/4);
|
||||
}
|
||||
#else
|
||||
env->cs_size = CSSIZE;
|
||||
#endif
|
||||
#ifdef DOWN_STACK
|
||||
/* Sanity check - in case rlimit is set too high */
|
||||
if (env->cs_org - env->cs_size > env->cs_org) {
|
||||
env->cs_size = CSSIZE;
|
||||
}
|
||||
env->cs_limit = env->cs_org - env->cs_size; /* in THREADS I'm assigning to the main thread clwp */
|
||||
#else
|
||||
/* Sanity check - in case rlimit is set too high */
|
||||
if (env->cs_org + env->cs_size < env->cs_org) {
|
||||
env->cs_size = CSSIZE;
|
||||
}
|
||||
env->cs_limit = env->cs_org + env->cs_size;
|
||||
#endif
|
||||
cs_set_size(ecl_get_option(ECL_OPT_C_STACK_SIZE));
|
||||
|
||||
#if defined(HAVE_SIGPROCMASK) && defined(SA_SIGINFO)
|
||||
{
|
||||
stack_t new_stack;
|
||||
env->altstack_size = SIGSTKSZ + (sizeof(double)*16) + (sizeof(cl_object)*4);
|
||||
env->altstack = cl_alloc_atomic(env->altstack_size);
|
||||
memset(&new_stack, 0, sizeof(new_stack));
|
||||
new_stack.ss_size = env->altstack_size;
|
||||
new_stack.ss_sp = env->altstack;
|
||||
new_stack.ss_flags = 0;
|
||||
sigaltstack(&new_stack, NULL);
|
||||
if (ecl_get_option(ECL_OPT_SIGALTSTACK_SIZE)) {
|
||||
stack_t new_stack;
|
||||
cl_index size = ecl_get_option(ECL_OPT_SIGALTSTACK_SIZE);
|
||||
if (size < SIGSTKSZ) {
|
||||
size = SIGSTKSZ + (sizeof(double)*16) +
|
||||
(sizeof(cl_object)*4);
|
||||
}
|
||||
env->altstack_size = size;
|
||||
env->altstack = cl_alloc_atomic(size);
|
||||
memset(&new_stack, 0, sizeof(new_stack));
|
||||
new_stack.ss_size = env->altstack_size;
|
||||
new_stack.ss_sp = env->altstack;
|
||||
new_stack.ss_flags = 0;
|
||||
sigaltstack(&new_stack, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,6 @@ cl_symbols[] = {
|
|||
{SYS_ "REM-F", SI_ORDINARY, si_rem_f, 2, OBJNULL},
|
||||
{SYS_ "REM-SYSPROP", SI_ORDINARY, si_rem_sysprop, 2, OBJNULL},
|
||||
{SYS_ "REPLACE-ARRAY", SI_ORDINARY, si_replace_array, 2, OBJNULL},
|
||||
{SYS_ "RESET-STACK-LIMITS", SI_ORDINARY, si_reset_stack_limits, 0, OBJNULL},
|
||||
{SYS_ "ROW-MAJOR-ASET", SI_ORDINARY, si_row_major_aset, 3, OBJNULL},
|
||||
{EXT_ "RUN-PROGRAM", SI_ORDINARY, si_run_program, -1, OBJNULL},
|
||||
{SYS_ "SAFE-EVAL", SI_ORDINARY, si_safe_eval, -1, OBJNULL},
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,6 @@ cl_symbols[] = {
|
|||
{SYS_ "REM-F","si_rem_f"},
|
||||
{SYS_ "REM-SYSPROP","si_rem_sysprop"},
|
||||
{SYS_ "REPLACE-ARRAY","si_replace_array"},
|
||||
{SYS_ "RESET-STACK-LIMITS","si_reset_stack_limits"},
|
||||
{SYS_ "ROW-MAJOR-ASET","si_row_major_aset"},
|
||||
{EXT_ "RUN-PROGRAM","si_run_program"},
|
||||
{SYS_ "SAFE-EVAL","si_safe_eval"},
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ si_catch_signal(cl_object code, cl_object boolean)
|
|||
#ifdef GBC_BOEHM
|
||||
int error = 0;
|
||||
#ifdef SIGSEGV
|
||||
if ((code_int == SIGSEGV) && ecl_get_option(ECL_INCREMENTAL_GC))
|
||||
if ((code_int == SIGSEGV) && ecl_get_option(ECL_OPT_INCREMENTAL_GC))
|
||||
FEerror("It is not allowed to change the behavior of SIGSEGV.",
|
||||
0);
|
||||
#endif
|
||||
|
|
@ -438,22 +438,22 @@ init_unixint(int pass)
|
|||
{
|
||||
if (pass == 0) {
|
||||
#ifdef SIGSEGV
|
||||
if (ecl_get_option(ECL_TRAP_SIGSEGV)) {
|
||||
if (ecl_get_option(ECL_OPT_TRAP_SIGSEGV)) {
|
||||
mysignal(SIGSEGV, signal_catcher);
|
||||
}
|
||||
#endif
|
||||
#if defined(SIGBUS) && !defined(GBC_BOEHM)
|
||||
if (ecl_get_option(ECL_TRAP_SIGBUS)) {
|
||||
if (ecl_get_option(ECL_OPT_TRAP_SIGBUS)) {
|
||||
mysignal(SIGBUS, signal_catcher);
|
||||
}
|
||||
#endif
|
||||
#ifdef SIGINT
|
||||
if (ecl_get_option(ECL_TRAP_SIGINT)) {
|
||||
if (ecl_get_option(ECL_OPT_TRAP_SIGINT)) {
|
||||
mysignal(SIGINT, signal_catcher);
|
||||
}
|
||||
#endif
|
||||
#ifdef SIGFPE
|
||||
if (ecl_get_option(ECL_TRAP_SIGFPE)) {
|
||||
if (ecl_get_option(ECL_OPT_TRAP_SIGFPE)) {
|
||||
mysignal(SIGFPE, signal_catcher);
|
||||
si_trap_fpe(Ct, Ct);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -650,7 +650,6 @@
|
|||
(proclaim-function si:argc (*) t)
|
||||
(proclaim-function si:argv (*) t)
|
||||
(proclaim-function si:getenv (*) t)
|
||||
(proclaim-function si:reset-stack-limits (*) t)
|
||||
(proclaim-function si:pointer (*) t)
|
||||
|
||||
;; file mapfun.d
|
||||
|
|
|
|||
|
|
@ -324,21 +324,6 @@ typedef unsigned @CL_FIXNUM_TYPE@ cl_hashkey;
|
|||
#define LISP_PAGESIZE 2048 /* Page size in bytes */
|
||||
#define MAXPAGE 65536 /* Maximum Memory Size */
|
||||
|
||||
/*
|
||||
* The lisp environment has several stacks. These are their limits:
|
||||
*/
|
||||
#define BDSSIZE 8192 /* Size of Binding Stack */
|
||||
#define BDSGETA 128 /* Safety zone of BDS */
|
||||
#define FRSSIZE 2048 /* Size of Frame Stack */
|
||||
#define FRSGETA 128 /* Safety zone of FRS */
|
||||
#ifdef THREADS
|
||||
#define CSSIZE 7500 /* Size of C Stack of each thread */
|
||||
#define CSGETA 500
|
||||
#else
|
||||
#define CSSIZE 20000 /* Size of C Stack */
|
||||
#define CSGETA 4000
|
||||
#endif
|
||||
|
||||
/* We reserve these many bytes for computation with bignums registers */
|
||||
#define BIGNUM_REGISTER_SIZE 16
|
||||
|
||||
|
|
|
|||
|
|
@ -836,17 +836,28 @@ extern ECL_API cl_object si_pointer(cl_object x);
|
|||
extern ECL_API cl_object si_quit _ARGS((cl_narg narg, ...)) /*__attribute__((noreturn))*/;
|
||||
|
||||
typedef enum {
|
||||
ECL_TRAP_SIGSEGV = 1,
|
||||
ECL_TRAP_SIGFPE = 2,
|
||||
ECL_TRAP_SIGINT = 4,
|
||||
ECL_TRAP_SIGILL = 8,
|
||||
ECL_TRAP_SIGBUS = 16,
|
||||
ECL_INCREMENTAL_GC = 128
|
||||
ECL_OPT_INCREMENTAL_GC = 0,
|
||||
ECL_OPT_TRAP_SIGSEGV,
|
||||
ECL_OPT_TRAP_SIGFPE,
|
||||
ECL_OPT_TRAP_SIGINT,
|
||||
ECL_OPT_TRAP_SIGILL,
|
||||
ECL_OPT_TRAP_SIGBUS,
|
||||
ECL_OPT_BOOTED,
|
||||
ECL_OPT_BIND_STACK_SIZE,
|
||||
ECL_OPT_BIND_STACK_SAFETY_AREA,
|
||||
ECL_OPT_FRAME_STACK_SIZE,
|
||||
ECL_OPT_FRAME_STACK_SAFETY_AREA,
|
||||
ECL_OPT_LISP_STACK_SIZE,
|
||||
ECL_OPT_LISP_STACK_SAFETY_AREA,
|
||||
ECL_OPT_C_STACK_SIZE,
|
||||
ECL_OPT_C_STACK_SAFETY_AREA,
|
||||
ECL_OPT_SIGALTSTACK_SIZE,
|
||||
ECL_OPT_LIMIT
|
||||
} ecl_option;
|
||||
extern ECL_API bool ecl_booted;
|
||||
|
||||
extern ECL_API const char *ecl_self;
|
||||
extern ECL_API void ecl_set_option(int option, int value);
|
||||
extern ECL_API int ecl_get_option(int option);
|
||||
extern ECL_API void ecl_set_option(int option, cl_fixnum value);
|
||||
extern ECL_API cl_fixnum ecl_get_option(int option);
|
||||
extern ECL_API int cl_boot(int argc, char **argv);
|
||||
extern ECL_API int cl_shutdown(void);
|
||||
#if defined(_MSC_VER) || defined(mingw32)
|
||||
|
|
|
|||
|
|
@ -398,8 +398,6 @@ under certain conditions; see file 'Copyright' for details.")
|
|||
(break-where))
|
||||
(loop
|
||||
(setq +++ ++ ++ + + -)
|
||||
(when (zerop *tpl-level*)
|
||||
(reset-stack-limits))
|
||||
(when (catch *quit-tag*
|
||||
(tpl-prompt)
|
||||
(setq - (locally (declare (notinline tpl-read)) (tpl-read)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue