File: mmap-protect.c

package info (click to toggle)
mlton 20100608-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 34,980 kB
  • ctags: 69,089
  • sloc: ansic: 18,421; lisp: 2,879; makefile: 1,570; sh: 1,325; pascal: 256; asm: 97
file content (16 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void *GC_mmapAnon_safe_protect (void *start, size_t length,
                                size_t dead_low, size_t dead_high) {
        void *base,*low,*result,*high;

        base = GC_mmapAnon_safe (start, length + dead_low + dead_high);
        low = base;
        if (mprotect (low, dead_low, PROT_NONE))
                diee ("mprotect failed");
        result = (void*)((pointer)low + dead_low);
        if (mprotect (result, length, PROT_READ | PROT_WRITE | PROT_EXEC))
                diee ("mprotect failed");
        high = (void*)((pointer)result + length);
        if (mprotect (high, dead_high, PROT_NONE))
                diee ("mprotect failed");
        return result;
}