source: trunk/source/lisp-kernel/memprotect.h @ 13067

Last change on this file since 13067 was 13067, checked in by rme, 10 years ago

Update copyright notices.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 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 "lisptypes.h"
24#ifdef PPC
25#include "ppc-constants.h"
26#endif
27#include <signal.h>
28#ifndef WINDOWS
29#ifdef DARWIN
30#include <sys/ucontext.h>
31#else
32#include <ucontext.h>
33#endif
34#endif
35
36#ifdef WINDOWS
37#define MAP_FAILED ((void *)(-1))
38
39#define MEMPROTECT_NONE PAGE_NOACCESS
40#define MEMPROTECT_RO   PAGE_READONLY
41#define MEMPROTECT_RW   PAGE_READWRITE
42#define MEMPROTECT_RX   PAGE_EXECUTE_READ
43#define MEMPROTECT_RWX  PAGE_EXECUTE_READWRITE
44
45#else
46
47#define MEMPROTECT_NONE PROT_NONE
48#define MEMPROTECT_RO   PROT_READ
49#define MEMPROTECT_RW   (PROT_READ|PROT_WRITE)
50#define MEMPROTECT_RX   (PROT_READ|PROT_EXEC)
51#define MEMPROTECT_RWX  (PROT_READ|PROT_WRITE|PROT_EXEC)
52#ifndef MAP_GROWSDOWN
53#define MAP_GROWSDOWN (0)
54#endif
55
56
57#endif
58
59LogicalAddress
60ReserveMemoryForHeap(LogicalAddress want, natural totalsize);
61
62int
63CommitMemory (LogicalAddress start, natural len);
64
65void
66UnCommitMemory (LogicalAddress start, natural len);
67
68LogicalAddress
69MapMemory(LogicalAddress addr, natural nbytes, int protection);
70
71LogicalAddress
72MapMemoryForStack(natural nbytes);
73
74int
75UnMapMemory(LogicalAddress addr, natural nbytes);
76
77int
78ProtectMemory(LogicalAddress, natural);
79
80int
81UnProtectMemory(LogicalAddress, natural);
82
83int
84MapFile(LogicalAddress addr, natural pos, natural nbytes, int permissions, int fd);
85
86typedef enum {
87  kNotProtected,                /* At least not at the moment. */
88  kVSPsoftguard,
89  kSPsoftguard,
90  kTSPsoftguard,
91  kSPhardguard,                 /* Touch one and die. */
92  kVSPhardguard,
93  kTSPhardguard,
94  kHEAPsoft,                    /* Uninitialized page in the heap */
95  kHEAPhard,                    /* The end-of-the-line in the heap */
96  /* Phony last entry. */
97  kNumProtectionKinds
98  } lisp_protection_kind;
99
100typedef
101struct protected_area {
102  struct protected_area *next;
103  BytePtr start;                /* first byte (page-aligned) that might be protected */
104  BytePtr end;                  /* last byte (page-aligned) that could be protected */
105  unsigned nprot;               /* Might be 0 */
106  unsigned protsize;            /* number of bytes to protect */
107  lisp_protection_kind why;
108} protected_area, *protected_area_ptr;
109
110
111/* Various functions that try to respond to a protection violation */
112typedef 
113  OSStatus (protection_handler)(ExceptionInformation *, protected_area_ptr, BytePtr);
114
115protection_handler
116  do_spurious_wp_fault,
117  do_soft_stack_overflow,
118  do_hard_stack_overflow,
119  do_tenured_space_write,
120  do_heap_soft_probe,
121  do_heap_hard_probe;
122
123extern protection_handler
124  *protection_handlers[];
125
126
127void
128exception_cleanup(void);
129
130
131 
132#endif /* __memprotect_h__ */
Note: See TracBrowser for help on using the repository browser.