0.8.7.57:
[sbcl.git] / src / runtime / validate.c
index a6fa5c3..aa0890f 100644 (file)
  * files for more information.
  */
 
-/*
- * $Header$
- */
-
 #include <stdio.h>
+#include <stdlib.h>
+
+#include "sbcl.h"
 #include "runtime.h"
 #include "os.h"
 #include "globals.h"
 #include "validate.h"
 
-static void ensure_space(lispobj *start, unsigned long size)
+static void
+ensure_space(lispobj *start, unsigned long size)
 {
     if (os_validate((os_vm_address_t)start,(os_vm_size_t)size)==NULL) {
        fprintf(stderr,
-               "ensure_space: failed to validate %ld bytes at 0x%08X\n",
+               "ensure_space: failed to validate %ld bytes at 0x%08lx\n",
                size,
                (unsigned long)start);
        exit(1);
@@ -38,7 +38,8 @@ static void ensure_space(lispobj *start, unsigned long size)
 
 static os_vm_address_t holes[] = HOLES;
 
-static void make_holes(void)
+static void
+make_holes(void)
 {
     int i;
 
@@ -55,50 +56,36 @@ static void make_holes(void)
 }
 #endif
 
-void validate(void)
+void
+validate(void)
 {
 #ifdef PRINTNOISE
-       printf("validating memory ...");
-       fflush(stdout);
-#endif
-
-       /* Read-Only Space */
-       read_only_space = (lispobj *) READ_ONLY_SPACE_START;
-       ensure_space(read_only_space, READ_ONLY_SPACE_SIZE);
-
-       /* Static Space */
-       static_space = (lispobj *) STATIC_SPACE_START;
-       ensure_space(static_space, STATIC_SPACE_SIZE);
-
-       /* Dynamic-0 Space */
-       dynamic_0_space = (lispobj *) DYNAMIC_0_SPACE_START;
-       ensure_space(dynamic_0_space, DYNAMIC_SPACE_SIZE);
-
-       current_dynamic_space = dynamic_0_space;
-
-       /* Dynamic-1 Space */
-       dynamic_1_space = (lispobj *) DYNAMIC_1_SPACE_START;
-#ifndef GENCGC
-       ensure_space(dynamic_1_space, DYNAMIC_SPACE_SIZE);
+    printf("validating memory ...");
+    fflush(stdout);
 #endif
-
-       /* Control Stack */
-       control_stack = (lispobj *) CONTROL_STACK_START;
-#ifdef __i386__
-       control_stack_end = (lispobj *) (CONTROL_STACK_START
-                                        + CONTROL_STACK_SIZE);
+    
+    ensure_space( (lispobj *)READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE);
+    ensure_space( (lispobj *)STATIC_SPACE_START   , STATIC_SPACE_SIZE);
+#ifdef LISP_FEATURE_GENCGC
+    ensure_space( (lispobj *)DYNAMIC_SPACE_START  , DYNAMIC_SPACE_SIZE);
+#else
+    ensure_space( (lispobj *)DYNAMIC_0_SPACE_START  , DYNAMIC_SPACE_SIZE);
+    ensure_space( (lispobj *)DYNAMIC_1_SPACE_START  , DYNAMIC_SPACE_SIZE);
 #endif
-       ensure_space(control_stack, CONTROL_STACK_SIZE);
-
-       /* Binding Stack */
-       binding_stack = (lispobj *) BINDING_STACK_START;
-       ensure_space(binding_stack, BINDING_STACK_SIZE);
 
 #ifdef HOLES
-       make_holes();
+    make_holes();
 #endif
-
+    
 #ifdef PRINTNOISE
-       printf(" done.\n");
+    printf(" done.\n");
 #endif
 }
+
+void protect_control_stack_guard_page(pid_t t_id, int protect_p) {
+    struct thread *th = find_thread_by_pid(t_id);
+    os_protect(CONTROL_STACK_GUARD_PAGE(th),
+              os_vm_page_size,protect_p ?
+              (OS_VM_PROT_READ|OS_VM_PROT_EXECUTE) : OS_VM_PROT_ALL);
+}
+