0.6.7.14: Some constant C vars are now constants.
[sbcl.git] / src / runtime / validate.c
1 /*
2  * memory validation
3  */
4
5 /*
6  * This software is part of the SBCL system. See the README file for
7  * more information.
8  *
9  * This software is derived from the CMU CL system, which was
10  * written at Carnegie Mellon University and released into the
11  * public domain. The software is in the public domain and is
12  * provided with absolutely no warranty. See the COPYING and CREDITS
13  * files for more information.
14  */
15
16 /*
17  * $Header$
18  */
19
20 #include <stdio.h>
21 #include "runtime.h"
22 #include "os.h"
23 #include "globals.h"
24 #include "sbcl.h"
25 #include "validate.h"
26
27 static void ensure_space(lispobj *start, unsigned long size)
28 {
29     if (os_validate((os_vm_address_t)start,(os_vm_size_t)size)==NULL) {
30         fprintf(stderr,
31                 "ensure_space: failed to validate %ld bytes at 0x%08X\n",
32                 size,
33                 (unsigned long)start);
34         exit(1);
35     }
36 }
37
38 #ifdef HOLES
39
40 static os_vm_address_t holes[] = HOLES;
41
42 static void make_holes(void)
43 {
44     int i;
45
46     for (i = 0; i < sizeof(holes)/sizeof(holes[0]); i++) {
47         if (os_validate(holes[i], HOLE_SIZE) == NULL) {
48             fprintf(stderr,
49                     "make_holes: failed to validate %ld bytes at 0x%08X\n",
50                     HOLE_SIZE,
51                     (unsigned long)holes[i]);
52             exit(1);
53         }
54         os_protect(holes[i], HOLE_SIZE, 0);
55     }
56 }
57 #endif
58
59 void validate(void)
60 {
61 #ifdef PRINTNOISE
62         printf("validating memory ...");
63         fflush(stdout);
64 #endif
65
66         ensure_space(READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE);
67
68         ensure_space(STATIC_SPACE_START, STATIC_SPACE_SIZE);
69
70         ensure_space(DYNAMIC_SPACE_START, DYNAMIC_SPACE_SIZE);
71
72         control_stack = (lispobj *) CONTROL_STACK_START;
73 #ifdef __i386__
74         control_stack_end = (lispobj *) (CONTROL_STACK_START
75                                          + CONTROL_STACK_SIZE);
76 #endif
77         ensure_space(control_stack, CONTROL_STACK_SIZE);
78
79         ensure_space(BINDING_STACK_START, BINDING_STACK_SIZE);
80
81 #ifdef HOLES
82         make_holes();
83 #endif
84
85 #ifdef PRINTNOISE
86         printf(" done.\n");
87 #endif
88 }