X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fruntime.c;h=2c971abff2f62a923565b494b64f75b40a6a9197;hb=2f9585060d5fe2c525955d80f34123761ded80fe;hp=139657390e677b9442d2afaef966f68dea5862ea;hpb=76f7887e98cbc10b4cd23e81b3e5cdfcc35c8741;p=sbcl.git diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 1396573..2c971ab 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -17,6 +17,7 @@ #include #include +#include #ifndef LISP_FEATURE_WIN32 #include #endif @@ -29,7 +30,7 @@ #include #include #include -#include +#include "runtime.h" #ifndef LISP_FEATURE_WIN32 #include #endif @@ -41,7 +42,9 @@ #include #endif +#if !(defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD)) #include "signal.h" +#endif #include "runtime.h" #include "vars.h" @@ -291,12 +294,58 @@ search_for_executable(const char *argv0) } #endif /* LISP_FEATURE_WIN32 */ +unsigned long parse_size_arg(char *arg, char *arg_name) +{ + char *tail, *power_name; + unsigned long power, res; + + res = strtoul(arg, &tail, 0); + + if (arg == tail) { + lose("%s argument is not a number: %s", arg_name, arg); + } else if (tail[0]) { + int i, size; + power_name = copied_string(tail); + size = strlen(power_name); + for (i=0; i (ULONG_MAX >> power))) { + lose("%s argument is out of range: %s", arg_name, arg); + } + res <<= power; + return res; +} + char **posix_argv; char *core_string; struct runtime_options *runtime_options; char *saved_runtime_path = NULL; +#if defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD) +void pthreads_win32_init(); +#endif + int main(int argc, char *argv[], char *envp[]) @@ -321,6 +370,11 @@ main(int argc, char *argv[], char *envp[]) lispobj initial_function; const char *sbcl_home = getenv("SBCL_HOME"); +#if defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD) + os_preinit(); + pthreads_win32_init(); +#endif + interrupt_init(); block_blockable_signals(0, 0); @@ -402,32 +456,21 @@ main(int argc, char *argv[], char *envp[]) ++argi; if (argi >= argc) lose("missing argument for --dynamic-space-size"); - { - char *tail; - long tmp = strtol(argv[argi++], &tail, 0); - if (tail[0]) - lose("--dynamic-space-size argument is not a number"); - if ((tmp <= 0) || - (tmp >= (LONG_MAX >> 20))) { - lose("--dynamic-space-size argument is out of range"); - } - dynamic_space_size = tmp << 20; - } + dynamic_space_size = parse_size_arg(argv[argi++], "--dynamic-space-size"); # ifdef MAX_DYNAMIC_SPACE_END if (!((DYNAMIC_SPACE_START < DYNAMIC_SPACE_START+dynamic_space_size) && (DYNAMIC_SPACE_START+dynamic_space_size <= MAX_DYNAMIC_SPACE_END))) - lose("--dynamic-space-size argument is too large"); + lose("--dynamic-space-size argument %s is too large, max %lu", + argv[argi-1], MAX_DYNAMIC_SPACE_END-DYNAMIC_SPACE_START); # endif } else if (0 == strcmp(arg, "--control-stack-size")) { ++argi; if (argi >= argc) lose("missing argument for --control-stack-size"); errno = 0; - thread_control_stack_size = strtol(argv[argi++], 0, 0) << 20; - if (errno) - lose("argument to --control-stack-size is not a number"); + thread_control_stack_size = parse_size_arg(argv[argi++], "--control-stack-size"); } else if (0 == strcmp(arg, "--debug-environment")) { int n = 0; printf("; Commandline arguments:\n"); @@ -452,6 +495,15 @@ main(int argc, char *argv[], char *envp[]) end_runtime_options = 1; ++argi; break; + } else if (0 == strcmp(arg, "--merge-core-pages")) { + ++argi; + merge_core_pages = 1; + } else if (0 == strcmp(arg, "--no-merge-core-pages")) { + ++argi; + merge_core_pages = 0; + } else if (0 == strcmp(arg, "--default-merge-core-pages")) { + ++argi; + merge_core_pages = -1; } else { /* This option was unrecognized as a runtime option, * so it must be a toplevel option or a user option, @@ -503,6 +555,7 @@ main(int argc, char *argv[], char *envp[]) * systems (e.g. Alpha) arch_init() needs need os_vm_page_size, so * it must follow os_init(). -- WHN 2000-01-26 */ os_init(argv, envp); + dyndebug_init(); /* after os_init: do not print output before execve */ arch_init(); gc_init(); validate(); @@ -562,6 +615,9 @@ main(int argc, char *argv[], char *envp[]) if (initial_function == NIL) { lose("couldn't find initial function\n"); } +#ifdef LISP_FEATURE_SB_DYNAMIC_CORE + os_link_runtime(); +#endif #ifdef LISP_FEATURE_HPUX /* -1 = CLOSURE_FUN_OFFSET, 23 = SIMPLE_FUN_CODE_OFFSET, we are * not in LANGUAGE_ASSEMBLY so we cant reach them. */