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

Last change on this file since 11910 was 11910, checked in by gb, 11 years ago

Hide things defined in <ucontext.h> but not defined in <sys/ucontext.h>
from the tender eyes of Darwin.

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