Back to index

plt-scheme  4.2.1
protect_range.c
Go to the documentation of this file.
00001 /*
00002   Provides:
00003   Requires:
00004    [page_range.c exports]
00005    [page allocator]
00006 */
00007 
00008 #ifdef _WIN32
00009 
00010 /* VirtualProtect can be used only on pages allocated at the same
00011    time, so we can't collapse ranges. */
00012 
00013 # define initialize_protect_page_ranges(pr, b, s) /* */
00014 # define add_protect_page_range(pr, s, l, a, w) vm_protect_pages(s, l, w)
00015 # define flush_protect_page_ranges(pr, w) /* */
00016 
00017 #else
00018 
00019 static void initialize_protect_page_ranges(Page_Range *protect_range, void *block, unsigned long size)
00020 {
00021   initialize_page_ranges(protect_range, block, size);
00022 }
00023 
00024 static void flush_protect_page_ranges(Page_Range *protect_range, int writeable)
00025 {
00026   Range *work;
00027 
00028   compact_page_ranges(protect_range);
00029 
00030   for (work = protect_range->range_start; work; work = work->next) {
00031     vm_protect_pages((void *)work->start, work->len, writeable);
00032   }
00033 
00034   reset_page_ranges(protect_range);
00035 }
00036 
00037 static void add_protect_page_range(Page_Range *protect_range, void *_start, unsigned long len, unsigned long alignment, int writeable)
00038 {
00039   if (!add_page_range(protect_range, _start, len, alignment)) {
00040     flush_protect_page_ranges(protect_range, writeable);
00041     add_page_range(protect_range, _start, len, alignment);
00042   }
00043 }
00044 
00045 #endif