nucleus: add a module boot for booting the core

Currently it contains only option setters.
This commit is contained in:
Daniel Kochmański 2022-11-24 22:50:31 +01:00
parent e1d9726d4f
commit f1bcd3fa46
4 changed files with 89 additions and 78 deletions

View file

@ -50,7 +50,7 @@ HFILES = $(HDIR)/config.h $(HDIR)/ecl.h $(HDIR)/ecl-cmp.h $(HDIR)/object.h
$(HDIR)/impl/math_dispatch.h $(HDIR)/impl/math_fenv.h \
$(HDIR)/impl/math_fenv_msvc.h $(HDIR)/nucleus.h
NUCL_OBJS = call.o jump.o atomic.o
NUCL_OBJS = boot.o call.o jump.o atomic.o
CLOS_OBJS = clos/cache.o clos/accessor.o clos/instance.o clos/gfun.o

87
src/c/boot.d Normal file
View file

@ -0,0 +1,87 @@
/* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* vim: set filetype=c tabstop=2 shiftwidth=2 expandtab: */
/* boot.c - initializing ecl internal data */
/* -- imports ------------------------------------------------------- */
#include <ecl/ecl.h>
#include <ecl/internal.h>
/* -- implementation------------------------------------------------- */
#if ECL_FIXNUM_BITS <= 32
/* 1GB */
#define ECL_DEFAULT_HEAP_SIZE 1073741824L
#else
/* 4GB */
#define ECL_DEFAULT_HEAP_SIZE 4294967296L
#endif
#ifndef ECL_DEFAULT_C_STACK_SIZE
#define ECL_DEFAULT_C_STACK_SIZE 0
#endif
#ifdef GBC_BOEHM_GENGC
#define ECL_INCREMENTAL_GC 1
#else
#define ECL_INCREMENTAL_GC 0
#endif
#if defined(ECL_THREADS) && defined(HAVE_SIGPROCMASK)
#define ECL_SIGNAL_HANDLING_THREAD 1
#else
#define ECL_SIGNAL_HANDLING_THREAD 0
#endif
/* INV: see ecl_option enum in external.h */
cl_fixnum ecl_option_values[ECL_OPT_LIMIT+1] = {
/* ---------------------------------------------------------------- */
ECL_INCREMENTAL_GC, /* ECL_OPT_INCREMENTAL_GC */
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 */
1, /* ECL_OPT_TRAP_SIGPIPE */
1, /* ECL_OPT_TRAP_INTERRUPT_SIGNAL */
ECL_SIGNAL_HANDLING_THREAD, /* ECL_OPT_SIGNAL_HANDLING_THREAD */
16, /* ECL_OPT_SIGNAL_QUEUE_SIZE */
0, /* ECL_OPT_BOOTED */
/* ---------------------------------------------------------------- */
8192, /* ECL_OPT_BIND_STACK_SIZE */
1024, /* 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 */
ECL_DEFAULT_C_STACK_SIZE, /* ECL_OPT_C_STACK_SIZE */
4*sizeof(cl_index)*1024, /* ECL_OPT_C_STACK_SAFETY_AREA */
ECL_DEFAULT_HEAP_SIZE, /* ECL_OPT_HEAP_SIZE */
1024*1024, /* ECL_OPT_HEAP_SAFETY_AREA */
0, /* ECL_OPT_THREAD_INTERRUPT_SIGNAL */
1, /* ECL_OPT_SET_GMP_MEMORY_FUNCTIONS */
1, /* ECL_OPT_USE_SETMODE_ON_FILES */
/* ---------------------------------------------------------------- */
0};
cl_fixnum
ecl_get_option(int option)
{
if (option >= ECL_OPT_LIMIT || option < 0) {
return -1;
}
return ecl_option_values[option];
}
cl_fixnum
ecl_set_option(int option, cl_fixnum value)
{
if (option > ECL_OPT_LIMIT || option < 0) {
return -1;
}
if (option >= ECL_OPT_BOOTED || !ecl_option_values[ECL_OPT_BOOTED]) {
ecl_option_values[option] = value;
}
return ecl_option_values[option];
}

View file

@ -136,84 +136,8 @@ ecl_def_ct_token(ecl_ct_dummy_tag ,ecl_stp_constant,ecl_ct_dtag_string,ECL_NIL,
/************************ GLOBAL INITIALIZATION ***********************/
/* HEAP */
#if ECL_FIXNUM_BITS <= 32
/* 1GB */
#define HEAP_SIZE_DEFAULT 1073741824L
#else
/* 4GB */
#define HEAP_SIZE_DEFAULT 4294967296L
#endif
static int ARGC;
static char **ARGV;
/* INV: see ecl_option enum in external.h */
cl_fixnum ecl_option_values[ECL_OPT_LIMIT+1] = {
#ifdef GBC_BOEHM_GENGC
1, /* ECL_OPT_INCREMENTAL_GC */
#else
0, /* ECL_OPT_INCREMENTAL_GC */
#endif
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 */
1, /* ECL_OPT_TRAP_SIGPIPE */
1, /* ECL_OPT_TRAP_INTERRUPT_SIGNAL */
#if defined(ECL_THREADS) && defined(HAVE_SIGPROCMASK)
1, /* ECL_OPT_SIGNAL_HANDLING_THREAD */
#else
0, /* ECL_OPT_SIGNAL_HANDLING_THREAD */
#endif
16, /* ECL_OPT_SIGNAL_QUEUE_SIZE */
0, /* ECL_OPT_BOOTED */
8192, /* ECL_OPT_BIND_STACK_SIZE */
1024, /* 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 */
ECL_DEFAULT_C_STACK_SIZE, /* ECL_OPT_C_STACK_SIZE */
4*sizeof(cl_index)*1024, /* ECL_OPT_C_STACK_SAFETY_AREA */
HEAP_SIZE_DEFAULT, /* ECL_OPT_HEAP_SIZE */
1024*1024, /* ECL_OPT_HEAP_SAFETY_AREA */
0, /* ECL_OPT_THREAD_INTERRUPT_SIGNAL */
1, /* ECL_OPT_SET_GMP_MEMORY_FUNCTIONS */
1, /* ECL_OPT_USE_SETMODE_ON_FILES */
0};
#if !defined(GBC_BOEHM)
static char stdin_buf[BUFSIZ];
static char stdout_buf[BUFSIZ];
#endif
cl_fixnum
ecl_get_option(int option)
{
if (option >= ECL_OPT_LIMIT || option < 0) {
FEerror("Invalid boot option ~D", 1, ecl_make_fixnum(option));
}
return ecl_option_values[option];
}
void
ecl_set_option(int option, cl_fixnum value)
{
if (option > ECL_OPT_LIMIT || option < 0) {
FEerror("Invalid boot option ~D", 1, ecl_make_fixnum(option));
} else {
if (option < ECL_OPT_BOOTED &&
ecl_option_values[ECL_OPT_BOOTED]) {
FEerror("Cannot change option ~D while ECL is running",
1, ecl_make_fixnum(option));
}
ecl_option_values[option] = value;
}
}
static void
init_env_mp(cl_env_ptr env)

View file

@ -994,7 +994,7 @@ typedef enum {
} ecl_option;
extern ECL_API const char *ecl_self;
extern ECL_API void ecl_set_option(int option, cl_fixnum value);
extern ECL_API cl_fixnum 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 void cl_shutdown(void);