Ignore:
Timestamp:
Aug 31, 2023, 11:31:15 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
950c58e
Parents:
92355883 (diff), 686912c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r92355883 r2a301ff  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 30 08:37:37 2022
    13 // Update Count     : 1605
     12// Last Modified On : Wed Aug  2 18:48:30 2023
     13// Update Count     : 1614
    1414//
    1515
     
    369369static __thread size_t PAD1 CALIGN TLSMODEL __attribute__(( unused )); // protect false sharing
    370370static __thread Heap * heapManager CALIGN TLSMODEL;
     371static  __thread bool heapManagerBootFlag CALIGN TLSMODEL = false;
    371372static __thread size_t PAD2 CALIGN TLSMODEL __attribute__(( unused )); // protect further false sharing
    372373
     
    488489                        allocUnfreed = 0;
    489490                        #endif // __CFA_DEBUG__
     491                        heapManagerBootFlag = true;
    490492                } // with
    491493        } // if
     
    499501
    500502        lock( heapMaster.mgrLock );                                                     // protect heapMaster counters
     503
     504        assert( ! heapManagerBootFlag );
    501505
    502506        // get storage for heap manager
     
    514518
    515519void heapManagerDtor() libcfa_public {
     520  if ( unlikely( ! heapManagerBootFlag ) ) return;              // thread never used ?
     521
    516522        lock( heapMaster.mgrLock );
    517523
     
    521527
    522528        #ifdef __STATISTICS__
     529        heapMaster.stats += heapManager->stats;                         // retain this heap's statistics
    523530        heapMaster.threads_exited += 1;
    524531        #endif // __STATISTICS__
     
    526533        // Do not set heapManager to NULL because it is used after Cforall is shutdown but before the program shuts down.
    527534
     535        heapManagerBootFlag = false;
    528536        unlock( heapMaster.mgrLock );
    529537} // heapManagerDtor
     
    535543extern int cfa_main_returned;                                                   // from interpose.cfa
    536544extern "C" {
    537         void memory_startup( void ) {
     545        void memory_startup( void ) {                                           // singleton => called once at start of program
    538546                if ( ! heapMasterBootFlag ) heapManagerCtor();  // sanity check
    539547        } // memory_startup
     
    557565                fclose( stdin ); fclose( stdout );                              // free buffer storage
    558566          if ( ! cfa_main_returned ) return;                            // do not check unfreed storage if exit called
     567
     568                #ifdef __STATISTICS__
     569                if ( getenv( "CFA_MALLOC_STATS" ) ) {                   // check for external printing
     570                        malloc_stats();
     571                } // if
     572                #endif // __STATISTICS__
    559573
    560574                #ifdef __CFA_DEBUG__
     
    895909#endif // __STATISTICS__
    896910
     911// Uncomment to get allocation addresses for a 0-sized allocation rather than a null pointer.
     912//#define __NONNULL_0_ALLOC__
     913#if ! defined( __NONNULL_0_ALLOC__ )
     914#define __NULL_0_ALLOC__ unlikely( size == 0 ) ||               /* 0 BYTE ALLOCATION RETURNS NULL POINTER */
     915#else
     916#define __NULL_0_ALLOC__
     917#endif // __NONNULL_0_ALLOC__
     918
    897919#define PROLOG( counter, ... ) \
    898920        BOOT_HEAP_MANAGER; \
    899         if ( unlikely( size == 0 ) ||                                           /* 0 BYTE ALLOCATION RETURNS NULL POINTER */ \
     921        if ( \
     922                __NULL_0_ALLOC__ \
    900923                unlikely( size > ULONG_MAX - sizeof(Heap.Storage) ) ) { /* error check */ \
    901924                STAT_0_CNT( counter ); \
Note: See TracChangeset for help on using the changeset viewer.