- Timestamp:
- May 9, 2010 11:25:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/solaris/alloc-solaris.cpp
r28800 r29277 39 39 #include <sys/mman.h> 40 40 #include <strings.h> 41 42 43 /******************************************************************************* 44 * Defined Constants And Macros * 45 *******************************************************************************/ 46 #if 0 47 # define RT_USE_MMAP_PAGE 48 #endif 41 49 42 50 … … 102 110 RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW 103 111 { 112 #ifdef RT_USE_MMAP_PAGE 113 size_t cbAligned = RT_ALIGN_Z(cb, PAGE_SIZE); 114 void *pv = mmap(NULL, cbAligned, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 115 AssertMsgReturn(pv != MAP_FAILED, ("errno=%d cb=%#zx\n", errno, cb), NULL); 116 return pv; 117 118 #else 104 119 return valloc(RT_ALIGN_Z(cb, PAGE_SIZE)); 120 #endif 105 121 } 106 122 … … 115 131 RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW 116 132 { 133 #ifdef RT_USE_MMAP_PAGE 134 size_t cbAligned = RT_ALIGN_Z(cb, PAGE_SIZE); 135 void *pv = mmap(NULL, cbAligned, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 136 AssertMsgReturn(pv != MAP_FAILED, ("errno=%d cb=%#zx\n", errno, cb), NULL); 137 return pv; 138 139 #else 117 140 cb = RT_ALIGN_Z(cb, PAGE_SIZE); 118 141 void *pv = valloc(cb); … … 120 143 bzero(pv, RT_ALIGN_Z(cb, PAGE_SIZE)); 121 144 return pv; 145 #endif 122 146 } 123 147 … … 132 156 { 133 157 if (pv) 158 { 159 #ifdef RT_USE_MMAP_PAGE 160 size_t cbAligned = RT_ALIGN_Z(cb, PAGE_SIZE); 161 int rc = munmap(pv, cbAligned); 162 AssertMsg(!rc, ("munmap(%p, %#zx) -> %d errno=%d\n", pv, cbAligned, rc, errno)); NOREF(rc); 163 #else 134 164 free(pv); 165 #endif 166 } 135 167 } 136 168
Note:
See TracChangeset
for help on using the changeset viewer.