|
3 | 3 | import sys |
4 | 4 | import mmap |
5 | 5 |
|
6 | | -from mmap import PAGESIZE, mmap, ACCESS_READ |
| 6 | +from mmap import ALLOCATIONGRANULARITY, mmap, ACCESS_READ |
7 | 7 | from sys import getrefcount |
8 | 8 |
|
9 | | -__all__ = [ "align_to_page", "is_64_bit", |
10 | | - "MemoryWindow", "MappedRegion", "MappedRegionList", "PAGESIZE"] |
| 9 | +__all__ = [ "align_to_mmap", "is_64_bit", |
| 10 | + "MemoryWindow", "MappedRegion", "MappedRegionList", "ALLOCATIONGRANULARITY"] |
11 | 11 |
|
12 | 12 | #{ Utilities |
13 | 13 |
|
14 | | -def align_to_page(num, round_up): |
| 14 | +def align_to_mmap(num, round_up): |
15 | 15 | """Align the given integer number to the closest page offset, which usually is 4096 bytes. |
16 | 16 | :param round_up: if True, the next higher multiple of page size is used, otherwise |
17 | 17 | the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0) |
18 | 18 | :return: num rounded to closest page""" |
19 | | - res = (num / PAGESIZE) * PAGESIZE; |
| 19 | + res = (num / ALLOCATIONGRANULARITY) * ALLOCATIONGRANULARITY; |
20 | 20 | if round_up and (res != num): |
21 | | - res += PAGESIZE; |
| 21 | + res += ALLOCATIONGRANULARITY |
22 | 22 | #END handle size |
23 | 23 | return res; |
24 | 24 |
|
@@ -55,10 +55,10 @@ def ofs_end(self): |
55 | 55 |
|
56 | 56 | def align(self): |
57 | 57 | """Assures the previous window area is contained in the new one""" |
58 | | - nofs = align_to_page(self.ofs, 0) |
| 58 | + nofs = align_to_mmap(self.ofs, 0) |
59 | 59 | self.size += self.ofs - nofs # keep size constant |
60 | 60 | self.ofs = nofs |
61 | | - self.size = align_to_page(self.size, 1) |
| 61 | + self.size = align_to_mmap(self.size, 1) |
62 | 62 |
|
63 | 63 | def extend_left_to(self, window, max_size): |
64 | 64 | """Adjust the offset to start where the given window on our left ends if possible, |
|
0 commit comments