Changes in / [55885dd:5d1aa2f]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r55885dd r5d1aa2f  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Dec 13 22:04:10 2020
    13 // Update Count     : 984
     12// Last Modified On : Fri Dec 11 07:36:34 2020
     13// Update Count     : 970
    1414//
    1515
     
    490490                // If the size requested is bigger than the current remaining storage, increase the size of the heap.
    491491
    492                 size_t increase = ceiling2( size > heapExpand ? size : heapExpand, pageSize );
     492                size_t increase = ceiling2( size > heapExpand ? size : heapExpand, libAlign() );
    493493                if ( sbrk( increase ) == (void *)-1 ) {                 // failed, no memory ?
    494494                        unlock( extlock );
    495495                        abort( NO_MEMORY_MSG, size );                           // give up
    496                 } // if
    497                 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 );
    503496                } // if
    504497                #ifdef __STATISTICS__
     
    575568                #endif // __STATISTICS__
    576569
    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 );
    578571                if ( block == (HeapManager.Storage *)MAP_FAILED ) { // failed ?
    579572                        if ( errno == ENOMEM ) abort( NO_MEMORY_MSG, tsize ); // no memory
    580573                        // Do not call strerror( errno ) as it may call malloc.
    581                         abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu errno:%d.", &heapManager, tsize, errno );
     574                        abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu error:%d.", &heapManager, tsize, errno );
    582575                } //if
    583576                #ifdef __CFA_DEBUG__
     
    676669                for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) {
    677670                #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 ) {
    680672//              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`
    682675//                      typeof(p) temp = (( p )`next)->top;                     // FIX ME: direct assignent fails, initialization works`
    683676//                      p = temp;
     
    723716
    724717        char * end = (char *)sbrk( 0 );
    725         heapBegin = heapEnd = sbrk( (char *)ceiling2( (long unsigned int)end, pageSize ) - end ); // move start of heap to multiple of alignment
     718        heapBegin = heapEnd = sbrk( (char *)ceiling2( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment
    726719} // HeapManager
    727720
Note: See TracChangeset for help on using the changeset viewer.