Changeset 28273 in vbox
- Timestamp:
- Apr 13, 2010 7:38:54 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60015
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/alloc-ef.cpp
r28271 r28273 323 323 * and then change the page protection of the fence. 324 324 */ 325 325 #ifdef RTALLOC_EFENCE_IN_FRONT 326 326 void *pvEFence = pvBlock; 327 327 void *pv = (char *)pvEFence + RTALLOC_EFENCE_SIZE; … … 329 329 memset((char *)pv + cb, RTALLOC_EFENCE_NOMAN_FILLER, cbBlock - RTALLOC_EFENCE_SIZE - cb); 330 330 # endif 331 331 #else 332 332 void *pvEFence = (char *)pvBlock + (cbBlock - RTALLOC_EFENCE_SIZE); 333 333 void *pv = (char *)pvEFence - cbAligned; … … 336 336 memset((char *)pv + cb, RTALLOC_EFENCE_NOMAN_FILLER, cbAligned - cb); 337 337 # endif 338 338 #endif 339 339 340 340 #ifdef RTALLOC_EFENCE_FENCE_FILLER … … 344 344 if (!rc) 345 345 { 346 346 #ifdef RTALLOC_EFENCE_TRACE 347 347 rtmemBlockInsert(pBlock, pv); 348 348 #endif 349 349 if (enmType == RTMEMTYPE_RTMEMALLOCZ) 350 350 memset(pv, 0, cb); … … 398 398 RTLogPrintf("RTMem %s: pv=%p pvCaller=%p cb=%#x\n", pszOp, pv, pvCaller, pBlock->cb); 399 399 400 # ifdef RTALLOC_EFENCE_NOMAN_FILLER400 # ifdef RTALLOC_EFENCE_NOMAN_FILLER 401 401 /* 402 402 * Check whether the no man's land is untouched. 403 403 */ 404 # ifdef RTALLOC_EFENCE_IN_FRONT404 # ifdef RTALLOC_EFENCE_IN_FRONT 405 405 void *pvWrong = ASMMemIsAll8((char *)pv + pBlock->cb, 406 406 RT_ALIGN_Z(pBlock->cb, PAGE_SIZE) - pBlock->cb, 407 407 RTALLOC_EFENCE_NOMAN_FILLER); 408 # else408 # else 409 409 /* Alignment must match allocation alignment in rtMemAlloc(). */ 410 410 size_t cbAligned = RT_ALIGN_Z(pBlock->cb, RTALLOC_EFENCE_ALIGNMENT); … … 417 417 RT_ALIGN_Z(cbAligned, PAGE_SIZE) - cbAligned, 418 418 RTALLOC_EFENCE_NOMAN_FILLER); 419 # endif419 # endif 420 420 if (pvWrong) 421 421 RTAssertDoPanic(); 422 # endif423 424 #ifdef RTALLOC_EFENCE_FREE_FILL422 # endif 423 424 # ifdef RTALLOC_EFENCE_FREE_FILL 425 425 /* 426 426 * Fill the user part of the block. 427 427 */ 428 428 memset(pv, RTALLOC_EFENCE_FREE_FILL, pBlock->cb); 429 #endif430 431 #if defined(RTALLOC_EFENCE_FREE_DELAYED) && RTALLOC_EFENCE_FREE_DELAYED > 0429 # endif 430 431 # if defined(RTALLOC_EFENCE_FREE_DELAYED) && RTALLOC_EFENCE_FREE_DELAYED > 0 432 432 /* 433 433 * We're doing delayed freeing. … … 444 444 { 445 445 pv = pBlock->Core.Key; 446 #ifdef RTALLOC_EFENCE_IN_FRONT446 # ifdef RTALLOC_EFENCE_IN_FRONT 447 447 void *pvBlock = (char *)pv - RTALLOC_EFENCE_SIZE; 448 #else448 # else 449 449 void *pvBlock = (void *)((uintptr_t)pv & ~PAGE_OFFSET_MASK); 450 #endif450 # endif 451 451 size_t cbBlock = RT_ALIGN_Z(pBlock->cb, PAGE_SIZE) + RTALLOC_EFENCE_SIZE; 452 452 rc = RTMemProtect(pvBlock, cbBlock, RTMEM_PROT_READ | RTMEM_PROT_WRITE); … … 461 461 rtmemComplain(pszOp, "Failed to expand the efence of pv=%p cb=%d, rc=%d.\n", pv, pBlock, rc); 462 462 463 #else /* !RTALLOC_EFENCE_FREE_DELAYED */463 # else /* !RTALLOC_EFENCE_FREE_DELAYED */ 464 464 465 465 /* 466 466 * Turn of the E-fence and free it. 467 467 */ 468 #ifdef RTALLOC_EFENCE_IN_FRONT468 # ifdef RTALLOC_EFENCE_IN_FRONT 469 469 void *pvBlock = (char *)pv - RTALLOC_EFENCE_SIZE; 470 470 void *pvEFence = pvBlock; 471 #else471 # else 472 472 void *pvBlock = (void *)((uintptr_t)pv & ~PAGE_OFFSET_MASK); 473 473 void *pvEFence = (char *)pv + pBlock->cb; 474 #endif474 # endif 475 475 int rc = RTMemProtect(pvEFence, RTALLOC_EFENCE_SIZE, RTMEM_PROT_READ | RTMEM_PROT_WRITE); 476 476 if (RT_SUCCESS(rc)) … … 480 480 rtmemBlockFree(pBlock); 481 481 482 #endif /* !RTALLOC_EFENCE_FREE_DELAYED */482 # endif /* !RTALLOC_EFENCE_FREE_DELAYED */ 483 483 } 484 484 else
Note:
See TracChangeset
for help on using the changeset viewer.