Split GENCGC_PAGE_BYTES in 3 constants
[sbcl.git] / src / runtime / runtime.c
index e4ec0e9..f127933 100644 (file)
@@ -35,6 +35,7 @@
 #endif
 #include <errno.h>
 #include <locale.h>
+#include <limits.h>
 
 #if defined(SVR4) || defined(__linux__)
 #include <time.h>
@@ -67,7 +68,7 @@
 #endif
 
 #ifndef SBCL_HOME
-#define SBCL_HOME "/usr/local/lib/sbcl/"
+#define SBCL_HOME SBCL_PREFIX"/lib/sbcl/"
 #endif
 
 #ifdef LISP_FEATURE_HPUX
@@ -336,7 +337,8 @@ main(int argc, char *argv[], char *envp[])
             core = (runtime_path ? runtime_path :
                     copied_string(saved_runtime_path));
         } else {
-            free(runtime_path);
+            if (runtime_path)
+                free(runtime_path);
         }
     }
 
@@ -392,16 +394,23 @@ main(int argc, char *argv[], char *envp[])
                 ++argi;
                 if (argi >= argc)
                     lose("missing argument for --dynamic-space-size");
-                errno = 0;
-                dynamic_space_size = strtol(argv[argi++], 0, 0) << 20;
-                if (errno)
-                    lose("argument to --dynamic-space-size is not a number");
+                {
+                  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;
+                }
 #               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("specified --dynamic-space-size too large");
+                    lose("--dynamic-space-size argument is too large");
 #               endif
             } else if (0 == strcmp(arg, "--control-stack-size")) {
                 ++argi;
@@ -473,6 +482,9 @@ main(int argc, char *argv[], char *envp[])
     /* Align down to multiple of page_table page size, and to the appropriate
      * stack alignment. */
     dynamic_space_size &= ~(PAGE_BYTES-1);
+#ifdef LISP_FEATURE_GENCGC
+    dynamic_space_size &= ~(GENCGC_CARD_BYTES-1);
+#endif
     thread_control_stack_size &= ~(CONTROL_STACK_ALIGNMENT_BYTES-1);
 
     /* Preserve the runtime options for possible future core saving */
@@ -513,7 +525,7 @@ main(int argc, char *argv[], char *envp[])
         fflush(stdout);
     }
 
-#if defined(SVR4) || defined(__linux__)
+#if defined(SVR4) || defined(__linux__) || defined(__NetBSD__)
     tzset();
 #endif