0.6.7.22: removed CVS dollar-Header-dollar tags from sources
[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 #include <stdio.h>
17 #include "runtime.h"
18 #include "os.h"
19 #include "globals.h"
20 #include "sbcl.h"
21 #include "validate.h"
22
23 static void ensure_space(lispobj *start, unsigned long size)
24 {
25     if (os_validate((os_vm_address_t)start,(os_vm_size_t)size)==NULL) {
26         fprintf(stderr,
27                 "ensure_space: failed to validate %ld bytes at 0x%08X\n",
28                 size,
29                 (unsigned long)start);
30         exit(1);
31     }
32 }
33
34 #ifdef HOLES
35
36 static os_vm_address_t holes[] = HOLES;
37
38 static void make_holes(void)
39 {
40     int i;
41
42     for (i = 0; i < sizeof(holes)/sizeof(holes[0]); i++) {
43         if (os_validate(holes[i], HOLE_SIZE) == NULL) {
44             fprintf(stderr,
45                     "make_holes: failed to validate %ld bytes at 0x%08X\n",
46                     HOLE_SIZE,
47                     (unsigned long)holes[i]);
48             exit(1);
49         }
50         os_protect(holes[i], HOLE_SIZE, 0);
51     }
52 }
53 #endif
54
55 void validate(void)
56 {
57 #ifdef PRINTNOISE
58         printf("validating memory ...");
59         fflush(stdout);
60 #endif
61
62         ensure_space(READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE);
63         ensure_space(STATIC_SPACE_START   , STATIC_SPACE_SIZE);
64         ensure_space(DYNAMIC_SPACE_START  , DYNAMIC_SPACE_SIZE);
65         ensure_space(CONTROL_STACK_START  , CONTROL_STACK_SIZE);
66         ensure_space(BINDING_STACK_START  , BINDING_STACK_SIZE);
67
68 #ifdef HOLES
69         make_holes();
70 #endif
71
72 #ifdef PRINTNOISE
73         printf(" done.\n");
74 #endif
75 }