Changes in / [db1ebed:6111f1f]


Ignore:
Location:
libcfa/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    rdb1ebed r6111f1f  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug  9 19:03:02 2021
    13 // Update Count     : 1040
     12// Last Modified On : Sun Jan  2 23:29:41 2022
     13// Update Count     : 1058
    1414//
    1515
     
    263263#ifdef __STATISTICS__
    264264// Heap statistics counters.
    265 static unsigned int malloc_zero_calls, malloc_calls;
    266 static unsigned long long int malloc_storage;
    267 static unsigned int aalloc_zero_calls, aalloc_calls;
    268 static unsigned long long int aalloc_storage;
    269 static unsigned int calloc_zero_calls, calloc_calls;
    270 static unsigned long long int calloc_storage;
    271 static unsigned int memalign_zero_calls, memalign_calls;
    272 static unsigned long long int memalign_storage;
    273 static unsigned int amemalign_zero_calls, amemalign_calls;
    274 static unsigned long long int amemalign_storage;
    275 static unsigned int cmemalign_zero_calls, cmemalign_calls;
    276 static unsigned long long int cmemalign_storage;
    277 static unsigned int resize_zero_calls, resize_calls;
    278 static unsigned long long int resize_storage;
    279 static unsigned int realloc_zero_calls, realloc_calls;
    280 static unsigned long long int realloc_storage;
    281 static unsigned int free_zero_calls, free_calls;
    282 static unsigned long long int free_storage;
     265static unsigned int malloc_calls, malloc_0_calls;
     266static unsigned long long int malloc_storage_request, malloc_storage_alloc;
     267static unsigned int aalloc_calls, aalloc_0_calls;
     268static unsigned long long int aalloc_storage_request, aalloc_storage_alloc;
     269static unsigned int calloc_calls, calloc_0_calls;
     270static unsigned long long int calloc_storage_request, calloc_storage_alloc;
     271static unsigned int memalign_calls, memalign_0_calls;
     272static unsigned long long int memalign_storage_request, memalign_storage_alloc;
     273static unsigned int amemalign_calls, amemalign_0_calls;
     274static unsigned long long int amemalign_storage_request, amemalign_storage_alloc;
     275static unsigned int cmemalign_calls, cmemalign_0_calls;
     276static unsigned long long int cmemalign_storage_request, cmemalign_storage_alloc;
     277static unsigned int resize_calls, resize_0_calls;
     278static unsigned long long int resize_storage_request, resize_storage_alloc;
     279static unsigned int realloc_calls, realloc_0_calls;
     280static unsigned long long int realloc_storage_request, realloc_storage_alloc;
     281static unsigned int free_calls, free_null_calls;
     282static unsigned long long int free_storage_request, free_storage_alloc;
    283283static unsigned int mmap_calls;
    284 static unsigned long long int mmap_storage;
     284static unsigned long long int mmap_storage_request, mmap_storage_alloc;
    285285static unsigned int munmap_calls;
    286 static unsigned long long int munmap_storage;
     286static unsigned long long int munmap_storage_request, munmap_storage_alloc;
    287287static unsigned int sbrk_calls;
    288288static unsigned long long int sbrk_storage;
     
    294294        char helpText[1024];
    295295        __cfaabi_bits_print_buffer( STDERR_FILENO, helpText, sizeof(helpText),
    296                                                                 "\nHeap statistics:\n"
    297                                                                 "  malloc    0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    298                                                                 "  aalloc    0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    299                                                                 "  calloc    0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    300                                                                 "  memalign  0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    301                                                                 "  amemalign 0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    302                                                                 "  cmemalign 0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    303                                                                 "  resize    0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    304                                                                 "  realloc   0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    305                                                                 "  free      0-calls %'u; >0-calls %'u; storage %'llu bytes\n"
    306                                                                 "  mmap      calls %'u; storage %'llu bytes\n"
    307                                                                 "  munmap    calls %'u; storage %'llu bytes\n"
    308                                                                 "  sbrk      calls %'u; storage %'llu bytes\n",
    309                                                                 malloc_zero_calls, malloc_calls, malloc_storage,
    310                                                                 aalloc_zero_calls, aalloc_calls, aalloc_storage,
    311                                                                 calloc_zero_calls, calloc_calls, calloc_storage,
    312                                                                 memalign_zero_calls, memalign_calls, memalign_storage,
    313                                                                 amemalign_zero_calls, amemalign_calls, amemalign_storage,
    314                                                                 cmemalign_zero_calls, cmemalign_calls, cmemalign_storage,
    315                                                                 resize_zero_calls, resize_calls, resize_storage,
    316                                                                 realloc_zero_calls, realloc_calls, realloc_storage,
    317                                                                 free_zero_calls, free_calls, free_storage,
    318                                                                 mmap_calls, mmap_storage,
    319                                                                 munmap_calls, munmap_storage,
    320                                                                 sbrk_calls, sbrk_storage
     296                                                                "\nHeap statistics: (storage request / allocation + header)\n"
     297                                                                "  malloc    >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     298                                                                "  aalloc    >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     299                                                                "  calloc    >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     300                                                                "  memalign  >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     301                                                                "  amemalign >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     302                                                                "  cmemalign >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     303                                                                "  resize    >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     304                                                                "  realloc   >0 calls %'u; 0 calls %'u; storage %'llu / %'llu bytes\n"
     305                                                                "  free      !null calls %'u; null calls %'u; storage %'llu / %'llu bytes\n"
     306                                                                "  sbrk      calls %'u; storage %'llu bytes\n"
     307                                                                "  mmap      calls %'u; storage %'llu / %'llu bytes\n"
     308                                                                "  munmap    calls %'u; storage %'llu / %'llu bytes\n",
     309                                                                malloc_calls, malloc_0_calls, malloc_storage_request, malloc_storage_alloc,
     310                                                                aalloc_calls, aalloc_0_calls, aalloc_storage_request, aalloc_storage_alloc,
     311                                                                calloc_calls, calloc_0_calls, calloc_storage_request, calloc_storage_alloc,
     312                                                                memalign_calls, memalign_0_calls, memalign_storage_request, memalign_storage_alloc,
     313                                                                amemalign_calls, amemalign_0_calls, amemalign_storage_request, amemalign_storage_alloc,
     314                                                                cmemalign_calls, cmemalign_0_calls, cmemalign_storage_request, cmemalign_storage_alloc,
     315                                                                resize_calls, resize_0_calls, resize_storage_request, resize_storage_alloc,
     316                                                                realloc_calls, realloc_0_calls, realloc_storage_request, realloc_storage_alloc,
     317                                                                free_calls, free_null_calls, free_storage_request, free_storage_alloc,
     318                                                                sbrk_calls, sbrk_storage,
     319                                                                mmap_calls, mmap_storage_request, mmap_storage_alloc,
     320                                                                munmap_calls, munmap_storage_request, munmap_storage_alloc
    321321                );
    322322} // printStats
     
    329329                                                "<sizes>\n"
    330330                                                "</sizes>\n"
    331                                                 "<total type=\"malloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    332                                                 "<total type=\"aalloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    333                                                 "<total type=\"calloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    334                                                 "<total type=\"memalign\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    335                                                 "<total type=\"amemalign\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    336                                                 "<total type=\"cmemalign\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    337                                                 "<total type=\"resize\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    338                                                 "<total type=\"realloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    339                                                 "<total type=\"free\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    340                                                 "<total type=\"mmap\" count=\"%'u;\" size=\"%'llu\"/> bytes\n"
    341                                                 "<total type=\"munmap\" count=\"%'u;\" size=\"%'llu\"/> bytes\n"
     331                                                "<total type=\"malloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     332                                                "<total type=\"aalloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     333                                                "<total type=\"calloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     334                                                "<total type=\"memalign\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     335                                                "<total type=\"amemalign\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     336                                                "<total type=\"cmemalign\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     337                                                "<total type=\"resize\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     338                                                "<total type=\"realloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
     339                                                "<total type=\"free\" !null=\"%'u;\" 0 null=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
    342340                                                "<total type=\"sbrk\" count=\"%'u;\" size=\"%'llu\"/> bytes\n"
     341                                                "<total type=\"mmap\" count=\"%'u;\" size=\"%'llu / %'llu\" / > bytes\n"
     342                                                "<total type=\"munmap\" count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"
    343343                                                "</malloc>",
    344                                                 malloc_zero_calls, malloc_calls, malloc_storage,
    345                                                 aalloc_zero_calls, aalloc_calls, aalloc_storage,
    346                                                 calloc_zero_calls, calloc_calls, calloc_storage,
    347                                                 memalign_zero_calls, memalign_calls, memalign_storage,
    348                                                 amemalign_zero_calls, amemalign_calls, amemalign_storage,
    349                                                 cmemalign_zero_calls, cmemalign_calls, cmemalign_storage,
    350                                                 resize_zero_calls, resize_calls, resize_storage,
    351                                                 realloc_zero_calls, realloc_calls, realloc_storage,
    352                                                 free_zero_calls, free_calls, free_storage,
    353                                                 mmap_calls, mmap_storage,
    354                                                 munmap_calls, munmap_storage,
    355                                                 sbrk_calls, sbrk_storage
     344                                                malloc_calls, malloc_0_calls, malloc_storage_request, malloc_storage_alloc,
     345                                                aalloc_calls, aalloc_0_calls, aalloc_storage_request, aalloc_storage_alloc,
     346                                                calloc_calls, calloc_0_calls, calloc_storage_request, calloc_storage_alloc,
     347                                                memalign_calls, memalign_0_calls, memalign_storage_request, memalign_storage_alloc,
     348                                                amemalign_calls, amemalign_0_calls, amemalign_storage_request, amemalign_storage_alloc,
     349                                                cmemalign_calls, cmemalign_0_calls, cmemalign_storage_request, cmemalign_storage_alloc,
     350                                                resize_calls, resize_0_calls, resize_storage_request, resize_storage_alloc,
     351                                                realloc_calls, realloc_0_calls, realloc_storage_request, realloc_storage_alloc,
     352                                                free_calls, free_null_calls, free_storage_request, free_storage_alloc,
     353                                                sbrk_calls, sbrk_storage,
     354                                                mmap_calls, mmap_storage_request, mmap_storage_alloc,
     355                                                munmap_calls, munmap_storage_request, munmap_storage_alloc
    356356                );
    357357        __cfaabi_bits_write( fileno( stream ), helpText, len ); // ensures all bytes written or exit
     
    577577                #ifdef __STATISTICS__
    578578                __atomic_add_fetch( &mmap_calls, 1, __ATOMIC_SEQ_CST );
    579                 __atomic_add_fetch( &mmap_storage, tsize, __ATOMIC_SEQ_CST );
     579                __atomic_add_fetch( &mmap_storage_request, size, __ATOMIC_SEQ_CST );
     580                __atomic_add_fetch( &mmap_storage_alloc, tsize, __ATOMIC_SEQ_CST );
    580581                #endif // __STATISTICS__
    581582
     
    626627                #ifdef __STATISTICS__
    627628                __atomic_add_fetch( &munmap_calls, 1, __ATOMIC_SEQ_CST );
    628                 __atomic_add_fetch( &munmap_storage, size, __ATOMIC_SEQ_CST );
     629                __atomic_add_fetch( &munmap_storage_request, header->kind.real.size, __ATOMIC_SEQ_CST );
     630                __atomic_add_fetch( &munmap_storage_alloc, size, __ATOMIC_SEQ_CST );
    629631                #endif // __STATISTICS__
    630632                if ( munmap( header, size ) == -1 ) {
     
    642644                #ifdef __STATISTICS__
    643645                __atomic_add_fetch( &free_calls, 1, __ATOMIC_SEQ_CST );
    644                 __atomic_add_fetch( &free_storage, size, __ATOMIC_SEQ_CST );
     646                __atomic_add_fetch( &free_storage_request, header->kind.real.size, __ATOMIC_SEQ_CST );
     647                __atomic_add_fetch( &free_storage_alloc, size, __ATOMIC_SEQ_CST );
    645648                #endif // __STATISTICS__
    646649
     
    819822                if ( likely( size > 0 ) ) {
    820823                        __atomic_add_fetch( &malloc_calls, 1, __ATOMIC_SEQ_CST );
    821                         __atomic_add_fetch( &malloc_storage, size, __ATOMIC_SEQ_CST );
     824                        __atomic_add_fetch( &malloc_storage_request, size, __ATOMIC_SEQ_CST );
    822825                } else {
    823                         __atomic_add_fetch( &malloc_zero_calls, 1, __ATOMIC_SEQ_CST );
     826                        __atomic_add_fetch( &malloc_0_calls, 1, __ATOMIC_SEQ_CST );
    824827                } // if
    825828                #endif // __STATISTICS__
     
    835838                if ( likely( size > 0 ) ) {
    836839                        __atomic_add_fetch( &aalloc_calls, 1, __ATOMIC_SEQ_CST );
    837                         __atomic_add_fetch( &aalloc_storage, size, __ATOMIC_SEQ_CST );
     840                        __atomic_add_fetch( &aalloc_storage_request, size, __ATOMIC_SEQ_CST );
    838841                } else {
    839                         __atomic_add_fetch( &aalloc_zero_calls, 1, __ATOMIC_SEQ_CST );
     842                        __atomic_add_fetch( &aalloc_0_calls, 1, __ATOMIC_SEQ_CST );
    840843                } // if
    841844                #endif // __STATISTICS__
     
    850853          if ( unlikely( size ) == 0 ) {                        // 0 BYTE ALLOCATION RETURNS NULL POINTER
    851854                        #ifdef __STATISTICS__
    852                         __atomic_add_fetch( &calloc_zero_calls, 1, __ATOMIC_SEQ_CST );
     855                        __atomic_add_fetch( &calloc_0_calls, 1, __ATOMIC_SEQ_CST );
    853856                        #endif // __STATISTICS__
    854857                        return 0p;
     
    856859                #ifdef __STATISTICS__
    857860                __atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST );
    858                 __atomic_add_fetch( &calloc_storage, dim * elemSize, __ATOMIC_SEQ_CST );
     861                __atomic_add_fetch( &calloc_storage_request, dim * elemSize, __ATOMIC_SEQ_CST );
    859862                #endif // __STATISTICS__
    860863
     
    891894          if ( unlikely( size == 0 ) ) {                                        // special cases
    892895                        #ifdef __STATISTICS__
    893                         __atomic_add_fetch( &resize_zero_calls, 1, __ATOMIC_SEQ_CST );
     896                        __atomic_add_fetch( &resize_0_calls, 1, __ATOMIC_SEQ_CST );
    894897                        #endif // __STATISTICS__
    895898                        free( oaddr );
     
    902905          if ( unlikely( oaddr == 0p ) ) {
    903906                        #ifdef __STATISTICS__
    904                         __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );
     907                        __atomic_add_fetch( &resize_storage_request, size, __ATOMIC_SEQ_CST );
    905908                        #endif // __STATISTICS__
    906909                        return mallocNoStats( size );
     
    921924
    922925                #ifdef __STATISTICS__
    923                 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );
     926                __atomic_add_fetch( &resize_storage_request, size, __ATOMIC_SEQ_CST );
    924927                #endif // __STATISTICS__
    925928
     
    936939          if ( unlikely( size == 0 ) ) {                                        // special cases
    937940                        #ifdef __STATISTICS__
    938                         __atomic_add_fetch( &realloc_zero_calls, 1, __ATOMIC_SEQ_CST );
     941                        __atomic_add_fetch( &realloc_0_calls, 1, __ATOMIC_SEQ_CST );
    939942                        #endif // __STATISTICS__
    940943                        free( oaddr );
     
    947950          if ( unlikely( oaddr == 0p ) ) {
    948951                        #ifdef __STATISTICS__
    949                         __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
     952                        __atomic_add_fetch( &realloc_storage_request, size, __ATOMIC_SEQ_CST );
    950953                        #endif // __STATISTICS__
    951954                        return mallocNoStats( size );
     
    969972
    970973                #ifdef __STATISTICS__
    971                 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
     974                __atomic_add_fetch( &realloc_storage_request, size, __ATOMIC_SEQ_CST );
    972975                #endif // __STATISTICS__
    973976
     
    10001003                if ( likely( size > 0 ) ) {
    10011004                        __atomic_add_fetch( &memalign_calls, 1, __ATOMIC_SEQ_CST );
    1002                         __atomic_add_fetch( &memalign_storage, size, __ATOMIC_SEQ_CST );
     1005                        __atomic_add_fetch( &memalign_storage_request, size, __ATOMIC_SEQ_CST );
    10031006                } else {
    1004                         __atomic_add_fetch( &memalign_zero_calls, 1, __ATOMIC_SEQ_CST );
     1007                        __atomic_add_fetch( &memalign_0_calls, 1, __ATOMIC_SEQ_CST );
    10051008                } // if
    10061009                #endif // __STATISTICS__
     
    10161019                if ( likely( size > 0 ) ) {
    10171020                        __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
    1018                         __atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST );
     1021                        __atomic_add_fetch( &cmemalign_storage_request, size, __ATOMIC_SEQ_CST );
    10191022                } else {
    1020                         __atomic_add_fetch( &cmemalign_zero_calls, 1, __ATOMIC_SEQ_CST );
     1023                        __atomic_add_fetch( &cmemalign_0_calls, 1, __ATOMIC_SEQ_CST );
    10211024                } // if
    10221025                #endif // __STATISTICS__
     
    10311034          if ( unlikely( size ) == 0 ) {                                        // 0 BYTE ALLOCATION RETURNS NULL POINTER
    10321035                        #ifdef __STATISTICS__
    1033                         __atomic_add_fetch( &cmemalign_zero_calls, 1, __ATOMIC_SEQ_CST );
     1036                        __atomic_add_fetch( &cmemalign_0_calls, 1, __ATOMIC_SEQ_CST );
    10341037                        #endif // __STATISTICS__
    10351038                        return 0p;
     
    10371040                #ifdef __STATISTICS__
    10381041                __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
    1039                 __atomic_add_fetch( &cmemalign_storage, dim * elemSize, __ATOMIC_SEQ_CST );
     1042                __atomic_add_fetch( &cmemalign_storage_request, dim * elemSize, __ATOMIC_SEQ_CST );
    10401043                #endif // __STATISTICS__
    10411044
     
    11011104          if ( unlikely( addr == 0p ) ) {                                       // special case
    11021105                        #ifdef __STATISTICS__
    1103                         __atomic_add_fetch( &free_zero_calls, 1, __ATOMIC_SEQ_CST );
     1106                        __atomic_add_fetch( &free_null_calls, 1, __ATOMIC_SEQ_CST );
    11041107                        #endif // __STATISTICS__
    11051108
     
    12801283  if ( unlikely( size == 0 ) ) {                                                // special cases
    12811284                #ifdef __STATISTICS__
    1282                 __atomic_add_fetch( &resize_zero_calls, 1, __ATOMIC_SEQ_CST );
     1285                __atomic_add_fetch( &resize_0_calls, 1, __ATOMIC_SEQ_CST );
    12831286                #endif // __STATISTICS__
    12841287                free( oaddr );
     
    12941297                #ifdef __STATISTICS__
    12951298                __atomic_add_fetch( &resize_calls, 1, __ATOMIC_SEQ_CST );
    1296                 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );
     1299                __atomic_add_fetch( &resize_storage_request, size, __ATOMIC_SEQ_CST );
    12971300                #endif // __STATISTICS__
    12981301                return memalignNoStats( nalign, size );
     
    13291332
    13301333        #ifdef __STATISTICS__
    1331         __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST );
     1334        __atomic_add_fetch( &resize_storage_request, size, __ATOMIC_SEQ_CST );
    13321335        #endif // __STATISTICS__
    13331336
     
    13421345  if ( unlikely( size == 0 ) ) {                                                // special cases
    13431346                #ifdef __STATISTICS__
    1344                 __atomic_add_fetch( &realloc_zero_calls, 1, __ATOMIC_SEQ_CST );
     1347                __atomic_add_fetch( &realloc_0_calls, 1, __ATOMIC_SEQ_CST );
    13451348                #endif // __STATISTICS__
    13461349                free( oaddr );
     
    13561359                #ifdef __STATISTICS__
    13571360                __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
    1358                 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
     1361                __atomic_add_fetch( &realloc_storage_request, size, __ATOMIC_SEQ_CST );
    13591362                #endif // __STATISTICS__
    13601363                return memalignNoStats( nalign, size );
     
    13801383        #ifdef __STATISTICS__
    13811384        __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
    1382         __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
     1385        __atomic_add_fetch( &realloc_storage_request, size, __ATOMIC_SEQ_CST );
    13831386        #endif // __STATISTICS__
    13841387
  • libcfa/src/stdlib.cfa

    rdb1ebed r6111f1f  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 29 15:32:44 2021
    13 // Update Count     : 512
     12// Last Modified On : Mon Jan  3 09:36:27 2022
     13// Update Count     : 519
    1414//
    1515
     
    241241        if ( unlikely( seed == 0 ) ) set_seed( rdtscl() );
    242242        else if ( unlikely( state == 0 ) ) state = seed;
    243         return state = 36973 * (state & 65535) + (state >> 16);
     243        return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
    244244} // LCG
    245245
  • libcfa/src/stdlib.hfa

    rdb1ebed r6111f1f  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 29 15:30:58 2021
    13 // Update Count     : 591
     12// Last Modified On : Sun Jan  2 22:53:57 2022
     13// Update Count     : 594
    1414//
    1515
     
    4343//---------------------------------------
    4444
    45 // Macro because of returns
    46 #define ARRAY_ALLOC$( allocation, alignment, dim ) \
    47         if ( _Alignof(T) <= libAlign() ) return (T *)(void *)allocation( dim, (size_t)sizeof(T) ); /* C allocation */ \
    48         else return (T *)alignment( _Alignof(T), dim, sizeof(T) )
    49 
    5045static inline forall( T & | sized(T) ) {
    5146        // CFA safe equivalents, i.e., implicit size specification
    5247
    5348        T * malloc( void ) {
    54                 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)malloc( (size_t)sizeof(T) ); // C allocation
     49                if ( _Alignof(T) <= libAlign() ) return (T *)malloc( sizeof(T) ); // C allocation
    5550                else return (T *)memalign( _Alignof(T), sizeof(T) );
    5651        } // malloc
    5752
    5853        T * aalloc( size_t dim ) {
    59                 ARRAY_ALLOC$( aalloc, amemalign, dim );
     54                if ( _Alignof(T) <= libAlign() ) return (T *)aalloc( dim, sizeof(T) ); // C allocation
     55                else return (T *)amemalign( _Alignof(T), dim, sizeof(T) );
    6056        } // aalloc
    6157
    6258        T * calloc( size_t dim ) {
    63                 ARRAY_ALLOC$( calloc, cmemalign, dim );
     59                if ( _Alignof(T) <= libAlign() ) return (T *)calloc( dim, sizeof(T) ); // C allocation
     60                else return (T *)cmemalign( _Alignof(T), dim, sizeof(T) );
    6461        } // calloc
    6562
    6663        T * resize( T * ptr, size_t size ) {                            // CFA resize, eliminate return-type cast
    67                 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)resize( (void *)ptr, size ); // CFA resize
    68                 else return (T *)(void *)resize( (void *)ptr, _Alignof(T), size ); // CFA resize
     64                if ( _Alignof(T) <= libAlign() ) return (T *)resize( (void *)ptr, size ); // CFA resize
     65                else return (T *)resize( (void *)ptr, _Alignof(T), size ); // CFA resize
    6966        } // resize
    7067
    7168        T * realloc( T * ptr, size_t size ) {                           // CFA realloc, eliminate return-type cast
    72                 if ( _Alignof(T) <= libAlign() ) return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    73                 else return (T *)(void *)realloc( (void *)ptr, _Alignof(T), size ); // CFA realloc
     69                if ( _Alignof(T) <= libAlign() ) return (T *)realloc( (void *)ptr, size ); // C realloc
     70                else return (T *)realloc( (void *)ptr, _Alignof(T), size ); // CFA realloc
    7471        } // realloc
    7572
Note: See TracChangeset for help on using the changeset viewer.