Changes in / [55885dd:5d1aa2f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
r55885dd r5d1aa2f 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 13 22:04:10202013 // Update Count : 9 8412 // Last Modified On : Fri Dec 11 07:36:34 2020 13 // Update Count : 970 14 14 // 15 15 … … 490 490 // If the size requested is bigger than the current remaining storage, increase the size of the heap. 491 491 492 size_t increase = ceiling2( size > heapExpand ? size : heapExpand, pageSize);492 size_t increase = ceiling2( size > heapExpand ? size : heapExpand, libAlign() ); 493 493 if ( sbrk( increase ) == (void *)-1 ) { // failed, no memory ? 494 494 unlock( extlock ); 495 495 abort( NO_MEMORY_MSG, size ); // give up 496 } // if497 if ( mprotect( (char *)heapEnd + heapRemaining, increase, PROT_READ | PROT_WRITE | PROT_EXEC ) ) {498 enum { BufferSize = 128 };499 char helpText[BufferSize];500 // Do not call strerror( errno ) as it may call malloc.501 int len = snprintf( helpText, BufferSize, "internal error, extend(), mprotect failure, heapEnd:%p size:%zd, errno:%d.", heapEnd, increase, errno );502 __cfaabi_bits_write( STDERR_FILENO, helpText, len );503 496 } // if 504 497 #ifdef __STATISTICS__ … … 575 568 #endif // __STATISTICS__ 576 569 577 block = (HeapManager.Storage *)mmap( 0, tsize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, mmapFd, 0 );570 block = (HeapManager.Storage *)mmap( 0, tsize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, mmapFd, 0 ); 578 571 if ( block == (HeapManager.Storage *)MAP_FAILED ) { // failed ? 579 572 if ( errno == ENOMEM ) abort( NO_MEMORY_MSG, tsize ); // no memory 580 573 // Do not call strerror( errno ) as it may call malloc. 581 abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu err no:%d.", &heapManager, tsize, errno );574 abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu error:%d.", &heapManager, tsize, errno ); 582 575 } //if 583 576 #ifdef __CFA_DEBUG__ … … 676 669 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) { 677 670 #else 678 for(;;) { 679 // for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; p = (p)`next->top ) { 671 // for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; p = (p)`next->top ) { 680 672 // for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; /* p = getNext( p )->top */) { 681 // HeapManager.Storage * temp = p->header.kind.real.next.top; // FIX ME: direct assignent fails, initialization works` 673 for ( HeapManager.Storage * p ;; /* p = getNext( p )->top */) { 674 HeapManager.Storage * temp = p->header.kind.real.next.top; // FIX ME: direct assignent fails, initialization works` 682 675 // typeof(p) temp = (( p )`next)->top; // FIX ME: direct assignent fails, initialization works` 683 676 // p = temp; … … 723 716 724 717 char * end = (char *)sbrk( 0 ); 725 heapBegin = heapEnd = sbrk( (char *)ceiling2( (long unsigned int)end, pageSize) - end ); // move start of heap to multiple of alignment718 heapBegin = heapEnd = sbrk( (char *)ceiling2( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment 726 719 } // HeapManager 727 720
Note: See TracChangeset
for help on using the changeset viewer.