Changeset 9dd730d1 in mainline
- Timestamp:
- 2011-04-16T12:40:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8a2474f
- Parents:
- 8b655705
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_elf.c
r8b655705 r9dd730d1 72 72 bool elf_create(as_area_t *area) 73 73 { 74 elf_segment_header_t *entry = area->backend_data.segment; 75 size_t nonanon_pages = ALIGN_DOWN(entry->p_filesz, PAGE_SIZE); 76 74 77 /** 75 78 * @todo: … … 77 80 * supporting structures allocated during the page fault. 78 81 */ 79 return reserve_try_alloc(area->pages); 82 83 if (area->pages <= nonanon_pages) 84 return true; 85 86 return reserve_try_alloc(area->pages - nonanon_pages); 80 87 } 81 88 82 89 bool elf_resize(as_area_t *area, size_t new_pages) 83 90 { 84 if (new_pages > area->pages) 85 return reserve_try_alloc(new_pages - area->pages); 86 else if (new_pages < area->pages) 87 reserve_free(area->pages - new_pages); 91 elf_segment_header_t *entry = area->backend_data.segment; 92 size_t nonanon_pages = ALIGN_DOWN(entry->p_filesz, PAGE_SIZE); 93 94 if (new_pages > area->pages) { 95 /* The area is growing. */ 96 if (area->pages >= nonanon_pages) 97 return reserve_try_alloc(new_pages - area->pages); 98 else if (new_pages > nonanon_pages) 99 return reserve_try_alloc(new_pages - nonanon_pages); 100 } else if (new_pages < area->pages) { 101 /* The area is shrinking. */ 102 if (new_pages >= nonanon_pages) 103 reserve_free(area->pages - new_pages); 104 else if (area->pages > nonanon_pages) 105 reserve_free(nonanon_pages - new_pages); 106 } 88 107 89 108 return true; … … 180 199 void elf_destroy(as_area_t *area) 181 200 { 182 /**183 * @todo:184 * Unreserve only how much was really reserved. 185 */186 reserve_free(area->pages);201 elf_segment_header_t *entry = area->backend_data.segment; 202 size_t nonanon_pages = ALIGN_DOWN(entry->p_filesz, PAGE_SIZE); 203 204 if (area->pages > nonanon_pages) 205 reserve_free(area->pages - nonanon_pages); 187 206 } 188 207
Note:
See TracChangeset
for help on using the changeset viewer.