Changeset fe610ab for libcfa


Ignore:
Timestamp:
Feb 17, 2022, 6:53:31 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
f69fac7
Parents:
778315e (diff), 9ef9644 (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:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

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

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r778315e rfe610ab  
    7272        common.hfa \
    7373        fstream.hfa \
    74         heap.hfa \
    7574        iostream.hfa \
    7675        iterator.hfa \
     
    102101        startup.hfa \
    103102        virtual.c \
    104         virtual.h
     103        virtual.h \
     104        heap.cc \
     105        heap.h
    105106
    106107# not all platforms support concurrency, add option do disable it
     
    172173
    173174-include $(libdeps)
     175-include $(DEPDIR)/heap.Plo
    174176
    175177thread_libdeps = $(join \
  • libcfa/src/concurrency/coroutine.cfa

    r778315e rfe610ab  
    8585// minimum feasible stack size in bytes
    8686static const size_t MinStackSize = 1000;
    87 extern size_t __page_size;                              // architecture pagesize HACK, should go in proper runtime singleton
    88 extern int __map_prot;
     87
     88extern "C" {
     89        extern size_t __cfa_page_size;                          // architecture pagesize HACK, should go in proper runtime singleton
     90        extern int __map_prot;
     91}
    8992
    9093void __stack_prepare( __stack_info_t * this, size_t create_size );
     
    157160[void *, size_t] __stack_alloc( size_t storageSize ) {
    158161        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    159         assert(__page_size != 0l);
     162        assert(__cfa_page_size != 0l);
    160163        size_t size = libCeiling( storageSize, 16 ) + stack_data_size;
    161         size = ceiling(size, __page_size);
     164        size = ceiling(size, __cfa_page_size);
    162165
    163166        // If we are running debug, we also need to allocate a guardpage to catch stack overflows.
    164167        void * storage;
    165168        #if CFA_COROUTINE_USE_MMAP
    166                 storage = mmap(0p, size + __page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
     169                storage = mmap(0p, size + __cfa_page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    167170                if(storage == ((void*)-1)) {
    168171                        abort( "coroutine stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    169172                }
    170                 if ( mprotect( storage, __page_size, PROT_NONE ) == -1 ) {
     173                if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) {
    171174                        abort( "coroutine stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    172175                } // if
    173                 storage = (void *)(((intptr_t)storage) + __page_size);
     176                storage = (void *)(((intptr_t)storage) + __cfa_page_size);
    174177        #else
    175178                __cfaabi_dbg_debug_do(
    176                         storage = memalign( __page_size, size + __page_size );
     179                        storage = memalign( __cfa_page_size, size + __cfa_page_size );
    177180                );
    178181                __cfaabi_dbg_no_debug_do(
     
    181184
    182185                __cfaabi_dbg_debug_do(
    183                         if ( mprotect( storage, __page_size, PROT_NONE ) == -1 ) {
     186                        if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) {
    184187                                abort( "__stack_alloc : internal error, mprotect failure, error(%d) %s.", (int)errno, strerror( (int)errno ) );
    185188                        }
    186                         storage = (void *)(((intptr_t)storage) + __page_size);
     189                        storage = (void *)(((intptr_t)storage) + __cfa_page_size);
    187190                );
    188191        #endif
     
    198201        #if CFA_COROUTINE_USE_MMAP
    199202                size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t);
    200                 storage = (void *)(((intptr_t)storage) - __page_size);
    201                 if(munmap(storage, size + __page_size) == -1) {
     203                storage = (void *)(((intptr_t)storage) - __cfa_page_size);
     204                if(munmap(storage, size + __cfa_page_size) == -1) {
    202205                        abort( "coroutine stack destruction : internal error, munmap failure, error(%d) %s.", errno, strerror( errno ) );
    203206                }
    204207        #else
    205208                __cfaabi_dbg_debug_do(
    206                         storage = (char*)(storage) - __page_size;
    207                         if ( mprotect( storage, __page_size, __map_prot ) == -1 ) {
     209                        storage = (char*)(storage) - __cfa_page_size;
     210                        if ( mprotect( storage, __cfa_page_size, __map_prot ) == -1 ) {
    208211                                abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
    209212                        }
  • libcfa/src/concurrency/kernel/startup.cfa

    r778315e rfe610ab  
    122122extern "C" {
    123123        struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
    124 }
    125 
    126 extern size_t __page_size;
    127 extern int __map_prot;
     124        extern size_t __cfa_page_size;
     125        extern int __map_prot;
     126}
    128127
    129128//-----------------------------------------------------------------------------
     
    574573}
    575574
    576 extern size_t __page_size;
    577575void ^?{}(processor & this) with( this ){
    578576        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     
    740738        void * stack;
    741739        #if CFA_PROCESSOR_USE_MMAP
    742                 stacksize = ceiling( stacksize, __page_size ) + __page_size;
     740                stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size;
    743741                stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    744742                if(stack == ((void*)-1)) {
    745743                        abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    746744                }
    747                 if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
     745                if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
    748746                        abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    749747                } // if
    750748        #else
    751749                __cfaabi_dbg_debug_do(
    752                         stack = memalign( __page_size, stacksize + __page_size );
     750                        stack = memalign( __cfa_page_size, stacksize + __cfa_page_size );
    753751                        // pthread has no mechanism to create the guard page in user supplied stack.
    754                         if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
     752                        if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
    755753                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    756754                        } // if
     
    779777                check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    780778                assert( stacksize >= PTHREAD_STACK_MIN );
    781                 stacksize += __page_size;
     779                stacksize += __cfa_page_size;
    782780
    783781                if(munmap(stack, stacksize) == -1) {
     
    787785                __cfaabi_dbg_debug_do(
    788786                        // pthread has no mechanism to create the guard page in user supplied stack.
    789                         if ( mprotect( stack, __page_size, __map_prot ) == -1 ) {
     787                        if ( mprotect( stack, __cfa_page_size, __map_prot ) == -1 ) {
    790788                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    791789                        } // if
  • libcfa/src/math.trait.hfa

    r778315e rfe610ab  
    1616#pragma once
    1717
    18 trait Not( T ) {
    19         void ?{}( T &, zero_t );
    20         int !?( T );
     18trait Not( U ) {
     19        void ?{}( U &, zero_t );
     20        int !?( U );
    2121}; // Not
    2222
     
    2626}; // Equality
    2727
    28 trait Relational( T | Equality( T ) ) {
    29         int ?<?( T, T );
    30         int ?<=?( T, T );
    31         int ?>?( T, T );
    32         int ?>=?( T, T );
     28trait Relational( U | Equality( U ) ) {
     29        int ?<?( U, U );
     30        int ?<=?( U, U );
     31        int ?>?( U, U );
     32        int ?>=?( U, U );
    3333}; // Relational
    3434
     
    3939}; // Signed
    4040
    41 trait Additive( T | Signed( T ) ) {
    42         T ?+?( T, T );
    43         T ?-?( T, T );
    44         T ?+=?( T &, T );
    45         T ?-=?( T &, T );
     41trait Additive( U | Signed( U ) ) {
     42        U ?+?( U, U );
     43        U ?-?( U, U );
     44        U ?+=?( U &, U );
     45        U ?-=?( U &, U );
    4646}; // Additive
    4747
     
    4949        void ?{}( T &, one_t );
    5050        // T ?++( T & );
    51         // T ++?( T &);
     51        // T ++?( T & );
    5252        // T ?--( T & );
    5353        // T --?( T & );
    5454}; // Incdec
    5555
    56 trait Multiplicative( T | Incdec( T ) ) {
    57         T ?*?( T, T );
    58         T ?/?( T, T );
    59         T ?%?( T, T );
    60         T ?/=?( T &, T );
     56trait Multiplicative( U | Incdec( U ) ) {
     57        U ?*?( U, U );
     58        U ?/?( U, U );
     59        U ?%?( U, U );
     60        U ?/=?( U &, U );
    6161}; // Multiplicative
    6262
  • libcfa/src/startup.cfa

    r778315e rfe610ab  
    2727        void __cfaabi_appready_startup( void ) {
    2828                tzset();                                                                                // initialize time global variables
    29                 #ifdef __CFA_DEBUG__
     29                #ifdef __CFA_DEBUG__FIXME
    3030                extern void heapAppStart();
    3131                heapAppStart();
    32                 #endif // __CFA_DEBUG__
     32                #endif // __CFA_DEBUG__FIXME
    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__
     37                #ifdef __CFA_DEBUG__FIXME
    3838                extern void heapAppStop();
    3939                heapAppStop();
    40                 #endif // __CFA_DEBUG__
     40                #endif // __CFA_DEBUG__FIXME
    4141        } // __cfaabi_appready_shutdown
    4242
  • libcfa/src/stdhdr/malloc.h

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

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