- Timestamp:
- Jul 31, 2023, 4:59:46 PM (13 months ago)
- Branches:
- master
- Children:
- 28c2933
- Parents:
- c68f6e6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
rc68f6e6 r07b59ec 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 30 08:37:37 202213 // Update Count : 16 0512 // Last Modified On : Fri Jul 28 18:27:53 2023 13 // Update Count : 1612 14 14 // 15 15 … … 369 369 static __thread size_t PAD1 CALIGN TLSMODEL __attribute__(( unused )); // protect false sharing 370 370 static __thread Heap * heapManager CALIGN TLSMODEL; 371 static __thread bool heapManagerBootFlag CALIGN TLSMODEL = false; 371 372 static __thread size_t PAD2 CALIGN TLSMODEL __attribute__(( unused )); // protect further false sharing 372 373 … … 488 489 allocUnfreed = 0; 489 490 #endif // __CFA_DEBUG__ 491 heapManagerBootFlag = true; 490 492 } // with 491 493 } // if … … 499 501 500 502 lock( heapMaster.mgrLock ); // protect heapMaster counters 503 504 assert( ! heapManagerBootFlag ); 501 505 502 506 // get storage for heap manager … … 514 518 515 519 void heapManagerDtor() libcfa_public { 520 if ( unlikely( ! heapManagerBootFlag ) ) return; // thread never used ? 521 516 522 lock( heapMaster.mgrLock ); 517 523 … … 526 532 // Do not set heapManager to NULL because it is used after Cforall is shutdown but before the program shuts down. 527 533 534 heapManagerBootFlag = false; 528 535 unlock( heapMaster.mgrLock ); 529 536 } // heapManagerDtor … … 535 542 extern int cfa_main_returned; // from interpose.cfa 536 543 extern "C" { 537 void memory_startup( void ) { 544 void memory_startup( void ) { // singleton => called once at start of program 538 545 if ( ! heapMasterBootFlag ) heapManagerCtor(); // sanity check 539 546 } // memory_startup … … 895 902 #endif // __STATISTICS__ 896 903 904 // Uncomment to get allocation addresses for a 0-sized allocation rather than a null pointer. 905 //#define __NONNULL_0_ALLOC__ 906 #if ! defined( __NONNULL_0_ALLOC__ ) 907 #define __NULL_0_ALLOC__ unlikely( size == 0 ) || /* 0 BYTE ALLOCATION RETURNS NULL POINTER */ 908 #else 909 #define __NULL_0_ALLOC__ 910 #endif // __NONNULL_0_ALLOC__ 911 897 912 #define PROLOG( counter, ... ) \ 898 913 BOOT_HEAP_MANAGER; \ 899 if ( unlikely( size == 0 ) || /* 0 BYTE ALLOCATION RETURNS NULL POINTER */ \ 914 if ( \ 915 __NULL_0_ALLOC__ \ 900 916 unlikely( size > ULONG_MAX - sizeof(Heap.Storage) ) ) { /* error check */ \ 901 917 STAT_0_CNT( counter ); \
Note: See TracChangeset
for help on using the changeset viewer.