Changeset a182ad5 for libcfa


Ignore:
Timestamp:
Feb 22, 2022, 12:23:14 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
f53afafb
Parents:
f69fac7
Message:

Revert "removed old memory allocator and replaced it with the concurrent allocator"

This reverts commit 5614a1915d68cb593dc2a2076d1d7e51433b157e.

Location:
libcfa/src
Files:
2 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    rf69fac7 ra182ad5  
    7272        common.hfa \
    7373        fstream.hfa \
     74        heap.hfa \
    7475        iostream.hfa \
    7576        iterator.hfa \
     
    101102        startup.hfa \
    102103        virtual.c \
    103         virtual.h \
    104         heap.cc \
    105         heap.h
     104        virtual.h
    106105
    107106# not all platforms support concurrency, add option do disable it
     
    173172
    174173-include $(libdeps)
    175 -include $(DEPDIR)/heap.Plo
    176174
    177175thread_libdeps = $(join \
  • libcfa/src/concurrency/coroutine.cfa

    rf69fac7 ra182ad5  
    8585// minimum feasible stack size in bytes
    8686static const size_t MinStackSize = 1000;
    87 
    88 extern "C" {
    89         extern size_t __cfa_page_size;                          // architecture pagesize HACK, should go in proper runtime singleton
    90         extern int __map_prot;
    91 }
     87extern size_t __page_size;                              // architecture pagesize HACK, should go in proper runtime singleton
     88extern int __map_prot;
    9289
    9390void __stack_prepare( __stack_info_t * this, size_t create_size );
     
    160157[void *, size_t] __stack_alloc( size_t storageSize ) {
    161158        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    162         assert(__cfa_page_size != 0l);
     159        assert(__page_size != 0l);
    163160        size_t size = libCeiling( storageSize, 16 ) + stack_data_size;
    164         size = ceiling(size, __cfa_page_size);
     161        size = ceiling(size, __page_size);
    165162
    166163        // If we are running debug, we also need to allocate a guardpage to catch stack overflows.
    167164        void * storage;
    168165        #if CFA_COROUTINE_USE_MMAP
    169                 storage = mmap(0p, size + __cfa_page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
     166                storage = mmap(0p, size + __page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    170167                if(storage == ((void*)-1)) {
    171168                        abort( "coroutine stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    172169                }
    173                 if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) {
     170                if ( mprotect( storage, __page_size, PROT_NONE ) == -1 ) {
    174171                        abort( "coroutine stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    175172                } // if
    176                 storage = (void *)(((intptr_t)storage) + __cfa_page_size);
     173                storage = (void *)(((intptr_t)storage) + __page_size);
    177174        #else
    178175                __cfaabi_dbg_debug_do(
    179                         storage = memalign( __cfa_page_size, size + __cfa_page_size );
     176                        storage = memalign( __page_size, size + __page_size );
    180177                );
    181178                __cfaabi_dbg_no_debug_do(
     
    184181
    185182                __cfaabi_dbg_debug_do(
    186                         if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) {
     183                        if ( mprotect( storage, __page_size, PROT_NONE ) == -1 ) {
    187184                                abort( "__stack_alloc : internal error, mprotect failure, error(%d) %s.", (int)errno, strerror( (int)errno ) );
    188185                        }
    189                         storage = (void *)(((intptr_t)storage) + __cfa_page_size);
     186                        storage = (void *)(((intptr_t)storage) + __page_size);
    190187                );
    191188        #endif
     
    201198        #if CFA_COROUTINE_USE_MMAP
    202199                size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t);
    203                 storage = (void *)(((intptr_t)storage) - __cfa_page_size);
    204                 if(munmap(storage, size + __cfa_page_size) == -1) {
     200                storage = (void *)(((intptr_t)storage) - __page_size);
     201                if(munmap(storage, size + __page_size) == -1) {
    205202                        abort( "coroutine stack destruction : internal error, munmap failure, error(%d) %s.", errno, strerror( errno ) );
    206203                }
    207204        #else
    208205                __cfaabi_dbg_debug_do(
    209                         storage = (char*)(storage) - __cfa_page_size;
    210                         if ( mprotect( storage, __cfa_page_size, __map_prot ) == -1 ) {
     206                        storage = (char*)(storage) - __page_size;
     207                        if ( mprotect( storage, __page_size, __map_prot ) == -1 ) {
    211208                                abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
    212209                        }
  • libcfa/src/concurrency/kernel/startup.cfa

    rf69fac7 ra182ad5  
    122122extern "C" {
    123123        struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
    124         extern size_t __cfa_page_size;
    125         extern int __map_prot;
    126 }
     124}
     125
     126extern size_t __page_size;
     127extern int __map_prot;
    127128
    128129//-----------------------------------------------------------------------------
     
    573574}
    574575
     576extern size_t __page_size;
    575577void ^?{}(processor & this) with( this ){
    576578        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     
    738740        void * stack;
    739741        #if CFA_PROCESSOR_USE_MMAP
    740                 stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size;
     742                stacksize = ceiling( stacksize, __page_size ) + __page_size;
    741743                stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    742744                if(stack == ((void*)-1)) {
    743745                        abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    744746                }
    745                 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
     747                if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    746748                        abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    747749                } // if
    748750        #else
    749751                __cfaabi_dbg_debug_do(
    750                         stack = memalign( __cfa_page_size, stacksize + __cfa_page_size );
     752                        stack = memalign( __page_size, stacksize + __page_size );
    751753                        // pthread has no mechanism to create the guard page in user supplied stack.
    752                         if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
     754                        if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    753755                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    754756                        } // if
     
    777779                check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    778780                assert( stacksize >= PTHREAD_STACK_MIN );
    779                 stacksize += __cfa_page_size;
     781                stacksize += __page_size;
    780782
    781783                if(munmap(stack, stacksize) == -1) {
     
    785787                __cfaabi_dbg_debug_do(
    786788                        // pthread has no mechanism to create the guard page in user supplied stack.
    787                         if ( mprotect( stack, __cfa_page_size, __map_prot ) == -1 ) {
     789                        if ( mprotect( stack, __page_size, __map_prot ) == -1 ) {
    788790                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    789791                        } // if
  • libcfa/src/startup.cfa

    rf69fac7 ra182ad5  
    2727        void __cfaabi_appready_startup( void ) {
    2828                tzset();                                                                                // initialize time global variables
    29                 #ifdef __CFA_DEBUG__FIXME
     29                #ifdef __CFA_DEBUG__
    3030                extern void heapAppStart();
    3131                heapAppStart();
    32                 #endif // __CFA_DEBUG__FIXME
     32                #endif // __CFA_DEBUG__
    3333        } // __cfaabi_appready_startup
    3434
    3535        void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
    3636        void __cfaabi_appready_shutdown( void ) {
    37                 #ifdef __CFA_DEBUG__FIXME
     37                #ifdef __CFA_DEBUG__
    3838                extern void heapAppStop();
    3939                heapAppStop();
    40                 #endif // __CFA_DEBUG__FIXME
     40                #endif // __CFA_DEBUG__
    4141        } // __cfaabi_appready_shutdown
    4242
  • libcfa/src/stdhdr/malloc.h

    rf69fac7 ra182ad5  
    1818} // extern "C"
    1919
    20 #include <heap.h>
     20#include <heap.hfa>
    2121
    2222// Local Variables: //
  • libcfa/src/stdlib.hfa

    rf69fac7 ra182ad5  
    2121
    2222#include <stdlib.h>                                                                             // *alloc, strto*, ato*
    23 #include <heap.h>
     23#include <heap.hfa>
    2424
    2525
Note: See TracChangeset for help on using the changeset viewer.