| 316 | } |
| 317 | |
| 318 | static bool |
| 319 | os_pages_commit(void *addr, size_t size, bool commit) { |
| 320 | assert(PAGE_ADDR2BASE(addr) == addr); |
| 321 | assert(PAGE_CEILING(size) == size); |
| 322 | |
| 323 | #ifdef _WIN32 |
| 324 | return (commit ? (addr != VirtualAlloc(addr, size, MEM_COMMIT, |
| 325 | PAGE_READWRITE)) : (!VirtualFree(addr, size, MEM_DECOMMIT))); |
| 326 | #else |
| 327 | { |
| 328 | int prot = commit ? PAGES_PROT_COMMIT : PAGES_PROT_DECOMMIT; |
| 329 | void *result = mmap(addr, size, prot, mmap_flags | MAP_FIXED, |
| 330 | PAGES_FD_TAG, 0); |
| 331 | if (result == MAP_FAILED) { |
| 332 | return true; |
| 333 | } |
| 334 | if (result != addr) { |
| 335 | /* |
| 336 | * We succeeded in mapping memory, but not in the right |
| 337 | * place. |
| 338 | */ |
| 339 | os_pages_unmap(result, size); |
| 340 | return true; |
| 341 | } |
| 342 | return false; |
| 343 | } |
| 344 | #endif |
| 345 | } |
| 346 | |
| 347 | static bool |
| 348 | pages_commit_impl(void *addr, size_t size, bool commit) { |
no test coverage detected