source: release/1.7/source/lisp-kernel/memprotect.h @ 15267

Last change on this file since 15267 was 14295, checked in by rme, 9 years ago

Eliminate some (but not all) warnings produced when building with
"-Wall -Wno-format". Also a couple of minor changes that enable
clang to build the lisp kernel (at least on x8632 and x8664).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/*
2   Copyright (C) 2009 Clozure Associates
3   Copyright (C) 1994-2001 Digitool, Inc
4   This file is part of Clozure CL. 
5
6   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
7   License , known as the LLGPL and distributed with Clozure CL as the
8   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9   which is distributed with Clozure CL as the file "LGPL".  Where these
10   conflict, the preamble takes precedence. 
11
12   Clozure CL is referenced in the preamble as the "LIBRARY."
13
14   The LLGPL is also available online at
15   http://opensource.franz.com/preamble.html
16*/
17
18#ifndef __memprotect_h__
19#define __memprotect_h__
20
21
22
23#include <signal.h>
24#ifndef WINDOWS
25#ifdef DARWIN
26#include <sys/ucontext.h>
27#else
28#include <ucontext.h>
29#endif
30#endif
31
32#ifdef WINDOWS
33#define MAP_FAILED ((void *)(-1))
34
35#define MEMPROTECT_NONE PAGE_NOACCESS
36#define MEMPROTECT_RO   PAGE_READONLY
37#define MEMPROTECT_RW   PAGE_READWRITE
38#define MEMPROTECT_RX   PAGE_EXECUTE_READ
39#define MEMPROTECT_RWX  PAGE_EXECUTE_READWRITE
40
41#else
42
43#define MEMPROTECT_NONE PROT_NONE
44#define MEMPROTECT_RO   PROT_READ
45#define MEMPROTECT_RW   (PROT_READ|PROT_WRITE)
46#define MEMPROTECT_RX   (PROT_READ|PROT_EXEC)
47#define MEMPROTECT_RWX  (PROT_READ|PROT_WRITE|PROT_EXEC)
48
49
50#endif
51
52LogicalAddress
53ReserveMemoryForHeap(LogicalAddress want, natural totalsize);
54
55int
56CommitMemory (LogicalAddress start, natural len);
57
58void
59UnCommitMemory (LogicalAddress start, natural len);
60
61LogicalAddress
62MapMemory(LogicalAddress addr, natural nbytes, int protection);
63
64LogicalAddress
65MapMemoryForStack(natural nbytes);
66
67int
68UnMapMemory(LogicalAddress addr, natural nbytes);
69
70int
71ProtectMemory(LogicalAddress, natural);
72
73int
74UnProtectMemory(LogicalAddress, natural);
75
76int
77MapFile(LogicalAddress addr, natural pos, natural nbytes, int permissions, int fd);
78void allocation_failure(Boolean pointerp, natural size);
79
80void protect_watched_areas(void);
81void unprotect_watched_areas(void);
82
83typedef enum {
84  kNotProtected,                /* At least not at the moment. */
85  kVSPsoftguard,
86  kSPsoftguard,
87  kTSPsoftguard,
88  kSPhardguard,                 /* Touch one and die. */
89  kVSPhardguard,
90  kTSPhardguard,
91  kHEAPsoft,                    /* Uninitialized page in the heap */
92  kHEAPhard,                    /* The end-of-the-line in the heap */
93  /* Phony last entry. */
94  kNumProtectionKinds
95  } lisp_protection_kind;
96
97typedef
98struct protected_area {
99  struct protected_area *next;
100  BytePtr start;                /* first byte (page-aligned) that might be protected */
101  BytePtr end;                  /* last byte (page-aligned) that could be protected */
102  unsigned nprot;               /* Might be 0 */
103  unsigned protsize;            /* number of bytes to protect */
104  lisp_protection_kind why;
105} protected_area, *protected_area_ptr;
106
107void unprotect_area(protected_area_ptr);
108
109/* Various functions that try to respond to a protection violation */
110typedef 
111  OSStatus (protection_handler)(ExceptionInformation *, protected_area_ptr, BytePtr);
112
113protection_handler
114  do_spurious_wp_fault,
115  do_soft_stack_overflow,
116  do_hard_stack_overflow,
117  do_tenured_space_write,
118  do_heap_soft_probe,
119  do_heap_hard_probe;
120
121extern protection_handler
122  *protection_handlers[];
123
124
125void
126exception_cleanup(void);
127
128
129 
130#endif /* __memprotect_h__ */
Note: See TracBrowser for help on using the repository browser.