Changeset f80f840


Ignore:
Timestamp:
Dec 10, 2019, 4:24:49 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
2a3d446
Parents:
b798713 (diff), e307e12 (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' into relaxed_ready

Files:
38 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.in

    rb798713 rf80f840  
    352352LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    353353        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    354         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    355         $(AM_CFLAGS) $(CFLAGS)
     354        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    356355
    357356AM_V_CFA = $(am__v_CFA_@AM_V@)
  • driver/cfa.cc

    rb798713 rf80f840  
    401401                args[nargs++] = "-Xlinker";
    402402                args[nargs++] = "--undefined=__cfaabi_appready_startup";
     403                args[nargs++] = "-z";
     404                args[nargs++] = "execstack";
    403405
    404406                // include the cfa library in case it is needed
     
    409411                args[nargs++] = "-Wl,--pop-state";
    410412                args[nargs++] = "-lcfa";
    411                 args[nargs++] = "-lpthread";
     413                args[nargs++] = "-pthread";
    412414                args[nargs++] = "-ldl";
    413415                args[nargs++] = "-lrt";
  • libcfa/configure

    rb798713 rf80f840  
    30003000case $CONFIGURATION in
    30013001        "debug"   )
    3002                 CONFIG_CFLAGS="-Og -g"
     3002                CONFIG_CFLAGS="-O0 -g"
    30033003                CONFIG_CFAFLAGS="-debug"
    30043004                CONFIG_BUILDLIB="yes"
  • libcfa/configure.ac

    rb798713 rf80f840  
    6868case $CONFIGURATION in
    6969        "debug"   )
    70                 CONFIG_CFLAGS="-Og -g"
     70                CONFIG_CFLAGS="-O0 -g"
    7171                CONFIG_CFAFLAGS="-debug"
    7272                CONFIG_BUILDLIB="yes"
  • libcfa/src/Makefile.am

    rb798713 rf80f840  
    3333# The built sources must not depend on the installed headers
    3434AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
     35AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3737CFACC = @CFACC@
  • libcfa/src/Makefile.in

    rb798713 rf80f840  
    417417LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    418418        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    419         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    420         $(AM_CFLAGS) $(CFLAGS)
     419        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    421420
    422421AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    446445# The built sources must not depend on the installed headers
    447446AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    448 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
     447AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    449448AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    450449@BUILDLIB_FALSE@headers_nosrc =
  • libcfa/src/concurrency/alarm.cfa

    rb798713 rf80f840  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May 25 06:25:47 2018
    13 // Update Count     : 67
     12// Last Modified On : Tue Dec  3 22:47:24 2019
     13// Update Count     : 68
    1414//
    1515
     
    4040void __kernel_set_timer( Duration alarm ) {
    4141        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
    42         setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
     42        setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p );
    4343}
    4444
     
    113113                        this->tail = &this->head;
    114114                }
    115                 head->next = NULL;
     115                head->next = 0p;
    116116        }
    117117        verify( validate( this ) );
     
    127127                this->tail = it;
    128128        }
    129         n->next = NULL;
     129        n->next = 0p;
    130130
    131131        verify( validate( this ) );
  • libcfa/src/concurrency/coroutine.cfa

    rb798713 rf80f840  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 17:20:57 2018
    13 // Update Count     : 9
     12// Last Modified On : Thu Dec  5 14:37:29 2019
     13// Update Count     : 15
    1414//
    1515
     
    9090
    9191void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) {
    92         (this.context){NULL, NULL};
     92        (this.context){0p, 0p};
    9393        (this.stack){storage, storageSize};
    9494        this.name = name;
    9595        state = Start;
    96         starter = NULL;
    97         last = NULL;
    98         cancellation = NULL;
     96        starter = 0p;
     97        last = 0p;
     98        cancellation = 0p;
    9999}
    100100
     
    131131
    132132[void *, size_t] __stack_alloc( size_t storageSize ) {
    133         static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
     133        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    134134        assert(__page_size != 0l);
    135135        size_t size = libCeiling( storageSize, 16 ) + stack_data_size;
     
    157157
    158158void __stack_prepare( __stack_info_t * this, size_t create_size ) {
    159         static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
     159        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    160160        bool userStack;
    161161        void * storage;
  • libcfa/src/concurrency/coroutine.hfa

    rb798713 rf80f840  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 17:49:39 2019
    13 // Update Count     : 9
     12// Last Modified On : Tue Dec  3 22:47:58 2019
     13// Update Count     : 10
    1414//
    1515
     
    3838void ^?{}( coroutine_desc & this );
    3939
    40 static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", NULL, 0 }; }
    41 static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", NULL, stackSize }; }
     40static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
     41static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
    4242static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
    43 static inline void ?{}( coroutine_desc & this, const char * name)                    { this{ name, NULL, 0 }; }
    44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, stackSize }; }
     43static inline void ?{}( coroutine_desc & this, const char * name)                    { this{ name, 0p, 0 }; }
     44static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, 0p, stackSize }; }
    4545
    4646//-----------------------------------------------------------------------------
     
    8989        src->state = Active;
    9090
    91         if( unlikely(src->cancellation != NULL) ) {
     91        if( unlikely(src->cancellation != 0p) ) {
    9292                _CtxCoroutine_Unwind(src->cancellation, src);
    9393        }
     
    128128        coroutine_desc * dst = get_coroutine(cor);
    129129
    130         if( unlikely(dst->context.SP == NULL) ) {
     130        if( unlikely(dst->context.SP == 0p) ) {
    131131                __stack_prepare(&dst->stack, 65000);
    132132                CtxStart(&cor, CtxInvokeCoroutine);
  • libcfa/src/concurrency/invoke.h

    rb798713 rf80f840  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 22 18:19:13 2019
    13 // Update Count     : 40
     12// Last Modified On : Thu Dec  5 16:26:03 2019
     13// Update Count     : 44
    1414//
    1515
     
    215215
    216216                static inline void ?{}(__monitor_group_t & this) {
    217                         (this.data){NULL};
     217                        (this.data){0p};
    218218                        (this.size){0};
    219219                        (this.func){NULL};
  • libcfa/src/concurrency/kernel.cfa

    rb798713 rf80f840  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 16:46:59 2019
    13 // Update Count     : 27
     12// Last Modified On : Thu Dec  5 16:25:52 2019
     13// Update Count     : 52
    1414//
    1515
     
    2626#include <signal.h>
    2727#include <unistd.h>
     28#include <limits.h>                                                                             // PTHREAD_STACK_MIN
     29#include <sys/mman.h>                                                                   // mprotect
    2830}
    2931
     
    4042//-----------------------------------------------------------------------------
    4143// Some assembly required
    42 #if   defined( __i386 )
     44#if defined( __i386 )
    4345        #define CtxGet( ctx )        \
    4446                __asm__ volatile (     \
     
    123125
    124126extern "C" {
    125 struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
     127        struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
    126128}
    127129
     
    131133// Global state
    132134thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) = {
    133         NULL,
     135        NULL,                                                                                           // cannot use 0p
    134136        NULL,
    135137        { 1, false, false },
     
    140142// Struct to steal stack
    141143struct current_stack_info_t {
    142         __stack_t * storage;            // pointer to stack object
    143         void *base;                             // base of stack
    144         void *limit;                    // stack grows towards stack limit
    145         void *context;                  // address of cfa_context_t
     144        __stack_t * storage;                                                            // pointer to stack object
     145        void * base;                                                                            // base of stack
     146        void * limit;                                                                           // stack grows towards stack limit
     147        void * context;                                                                         // address of cfa_context_t
    146148};
    147149
     
    172174        name = "Main Thread";
    173175        state = Start;
    174         starter = NULL;
    175         last = NULL;
    176         cancellation = NULL;
     176        starter = 0p;
     177        last = 0p;
     178        cancellation = 0p;
    177179}
    178180
     
    188190        link.prev = 0p;
    189191
    190         node.next = NULL;
    191         node.prev = NULL;
     192        node.next = 0p;
     193        node.prev = 0p;
    192194        doregister(curr_cluster, this);
    193195
     
    214216        terminated{ 0 };
    215217        do_terminate = false;
    216         preemption_alarm = NULL;
     218        preemption_alarm = 0p;
    217219        pending_preemption = false;
    218220        runner.proc = &this;
     
    234236        }
    235237
    236         pthread_join( kernel_thread, NULL );
     238        pthread_join( kernel_thread, 0p );
     239        free( this.stack );
    237240}
    238241
     
    284287                __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
    285288
    286                 thread_desc * readyThread = NULL;
    287                 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
    288                 {
     289                thread_desc * readyThread = 0p;
     290                for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) {
    289291                        readyThread = nextThread( this->cltr );
    290292
    291                         if(readyThread)
    292                         {
     293                        if(readyThread) {
    293294                                verify( ! kernelTLS.preemption_state.enabled );
    294295
     
    301302
    302303                                spin_count = 0;
    303                         }
    304                         else
    305                         {
     304                        } else {
    306305                                // spin(this, &spin_count);
    307306                                halt(this);
     
    423422        processor * proc = (processor *) arg;
    424423        kernelTLS.this_processor = proc;
    425         kernelTLS.this_thread    = NULL;
     424        kernelTLS.this_thread    = 0p;
    426425        kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
    427426        // SKULLDUGGERY: We want to create a context for the processor coroutine
     
    436435
    437436        //Set global state
    438         kernelTLS.this_thread    = NULL;
     437        kernelTLS.this_thread = 0p;
    439438
    440439        //We now have a proper context from which to schedule threads
     
    452451        __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
    453452
    454         return NULL;
     453        return 0p;
     454}
     455
     456static void Abort( int ret, const char * func ) {
     457        if ( ret ) {                                                                            // pthread routines return errno values
     458                abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
     459        } // if
     460} // Abort
     461
     462void * create_pthread( pthread_t * pthread, void * (*start)(void *), void * arg ) {
     463        pthread_attr_t attr;
     464
     465        Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
     466
     467        size_t stacksize;
     468        // default stack size, normally defined by shell limit
     469        Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
     470        assert( stacksize >= PTHREAD_STACK_MIN );
     471
     472        void * stack;
     473        __cfaabi_dbg_debug_do(
     474                stack = memalign( __page_size, stacksize + __page_size );
     475                // pthread has no mechanism to create the guard page in user supplied stack.
     476                if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
     477                        abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
     478                } // if
     479        );
     480        __cfaabi_dbg_no_debug_do(
     481                stack = malloc( stacksize );
     482        );
     483
     484        Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
     485
     486        Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
     487        return stack;
    455488}
    456489
     
    458491        __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
    459492
    460         pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
     493        this->stack = create_pthread( &this->kernel_thread, CtxInvokeProcessor, (void *)this );
    461494
    462495        __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
     
    515548        verify( ! kernelTLS.preemption_state.enabled );
    516549
    517         verifyf( thrd->link.next == NULL, "Expected null got %p", thrd->link.next );
     550        verifyf( thrd->link.next == 0p, "Expected null got %p", thrd->link.next );
    518551
    519552
     
    695728        void ?{}(processorCtx_t & this, processor * proc) {
    696729                (this.__cor){ "Processor" };
    697                 this.__cor.starter = NULL;
     730                this.__cor.starter = 0p;
    698731                this.proc = proc;
    699732        }
     
    704737                terminated{ 0 };
    705738                do_terminate = false;
    706                 preemption_alarm = NULL;
     739                preemption_alarm = 0p;
    707740                pending_preemption = false;
    708741                kernel_thread = pthread_self();
     
    907940
    908941void V(semaphore & this) with( this ) {
    909         thread_desc * thrd = NULL;
     942        thread_desc * thrd = 0p;
    910943        lock( lock __cfaabi_dbg_ctx2 );
    911944        count += 1;
  • libcfa/src/concurrency/kernel.hfa

    rb798713 rf80f840  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 22 11:39:17 2019
    13 // Update Count     : 16
     12// Last Modified On : Wed Dec  4 07:54:51 2019
     13// Update Count     : 18
    1414//
    1515
     
    8989static inline void ?{}(FinishAction & this) {
    9090        this.action_code = No_Action;
    91         this.thrd = NULL;
    92         this.lock = NULL;
     91        this.thrd = 0p;
     92        this.lock = 0p;
    9393}
    9494static inline void ^?{}(FinishAction &) {}
     
    135135        // Termination synchronisation
    136136        semaphore terminated;
     137
     138        // pthread Stack
     139        void * stack;
    137140
    138141        // Link lists fields
  • libcfa/src/concurrency/kernel_private.hfa

    rb798713 rf80f840  
    1010// Created On       : Mon Feb 13 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 29 14:06:40 2018
    13 // Update Count     : 3
     12// Last Modified On : Sat Nov 30 19:25:02 2019
     13// Update Count     : 8
    1414//
    1515
     
    5757void main(processorCtx_t *);
    5858
     59void * create_pthread( pthread_t *, void * (*)(void *), void * );
     60
    5961static inline void wake_fast(processor * this) {
    6062        __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this);
  • libcfa/src/concurrency/monitor.cfa

    rb798713 rf80f840  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 14:30:26 2018
    13 // Update Count     : 9
     12// Last Modified On : Wed Dec  4 07:55:14 2019
     13// Update Count     : 10
    1414//
    1515
     
    363363        this.waiting_thread = waiting_thread;
    364364        this.count = count;
    365         this.next = NULL;
     365        this.next = 0p;
    366366        this.user_info = user_info;
    367367}
     
    369369void ?{}(__condition_criterion_t & this ) with( this ) {
    370370        ready  = false;
    371         target = NULL;
    372         owner  = NULL;
    373         next   = NULL;
     371        target = 0p;
     372        owner  = 0p;
     373        next   = 0p;
    374374}
    375375
     
    378378        this.target = target;
    379379        this.owner  = &owner;
    380         this.next   = NULL;
     380        this.next   = 0p;
    381381}
    382382
     
    387387
    388388        // Check that everything is as expected
    389         assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
     389        assertf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );
    390390        verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
    391391        verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count );
     
    449449
    450450        // Lock all monitors
    451         lock_all( this.monitors, NULL, count );
     451        lock_all( this.monitors, 0p, count );
    452452
    453453        //Pop the head of the waiting queue
     
    471471
    472472        //Check that everything is as expected
    473         verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
     473        verifyf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );
    474474        verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
    475475
     
    674674
    675675static inline void reset_mask( monitor_desc * this ) {
    676         this->mask.accepted = NULL;
    677         this->mask.data = NULL;
     676        this->mask.accepted = 0p;
     677        this->mask.data = 0p;
    678678        this->mask.size = 0;
    679679}
     
    816816        }
    817817
    818         __cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL );
    819         return ready2run ? node->waiting_thread : NULL;
     818        __cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : 0p );
     819        return ready2run ? node->waiting_thread : 0p;
    820820}
    821821
     
    824824        if( !this.monitors ) {
    825825                // __cfaabi_dbg_print_safe( "Branding\n" );
    826                 assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data );
     826                assertf( thrd->monitors.data != 0p, "No current monitor to brand condition %p", thrd->monitors.data );
    827827                this.monitor_count = thrd->monitors.size;
    828828
  • libcfa/src/concurrency/monitor.hfa

    rb798713 rf80f840  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  7 18:06:45 2017
    13 // Update Count     : 10
     12// Last Modified On : Wed Dec  4 07:55:32 2019
     13// Update Count     : 11
    1414//
    1515
     
    3131        entry_queue{};
    3232        signal_stack{};
    33         owner         = NULL;
     33        owner         = 0p;
    3434        recursion     = 0;
    35         mask.accepted = NULL;
    36         mask.data     = NULL;
     35        mask.accepted = 0p;
     36        mask.data     = 0p;
    3737        mask.size     = 0;
    38         dtor_node     = NULL;
     38        dtor_node     = 0p;
    3939}
    4040
     
    122122
    123123static inline void ?{}( condition & this ) {
    124         this.monitors = NULL;
     124        this.monitors = 0p;
    125125        this.monitor_count = 0;
    126126}
  • libcfa/src/concurrency/mutex.cfa

    rb798713 rf80f840  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:37:11 2018
    13 // Last Modified By : Thierry Delisle
    14 // Last Modified On : Fri May 25 01:37:51 2018
    15 // Update Count     : 0
     13// Last Modified By : Peter A. Buhr
     14// Last Modified On : Wed Dec  4 09:16:39 2019
     15// Update Count     : 1
    1616//
    1717
     
    7373        this.lock{};
    7474        this.blocked_threads{};
    75         this.owner = NULL;
     75        this.owner = 0p;
    7676        this.recursion_count = 0;
    7777}
     
    8383void lock(recursive_mutex_lock & this) with(this) {
    8484        lock( lock __cfaabi_dbg_ctx2 );
    85         if( owner == NULL ) {
     85        if( owner == 0p ) {
    8686                owner = kernelTLS.this_thread;
    8787                recursion_count = 1;
     
    101101        bool ret = false;
    102102        lock( lock __cfaabi_dbg_ctx2 );
    103         if( owner == NULL ) {
     103        if( owner == 0p ) {
    104104                owner = kernelTLS.this_thread;
    105105                recursion_count = 1;
  • libcfa/src/concurrency/mutex.hfa

    rb798713 rf80f840  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:24:09 2018
    13 // Last Modified By : Thierry Delisle
    14 // Last Modified On : Fri May 25 01:24:12 2018
    15 // Update Count     : 0
     13// Last Modified By : Peter A. Buhr
     14// Last Modified On : Wed Dec  4 09:16:53 2019
     15// Update Count     : 1
    1616//
    1717
     
    110110
    111111        static inline void ?{}(lock_scope(L) & this) {
    112                 this.locks = NULL;
     112                this.locks = 0p;
    113113                this.count = 0;
    114114        }
  • libcfa/src/concurrency/preemption.cfa

    rb798713 rf80f840  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun  5 17:35:49 2018
    13 // Update Count     : 37
     12// Last Modified On : Thu Dec  5 16:34:05 2019
     13// Update Count     : 43
    1414//
    1515
     
    2424#include <string.h>
    2525#include <unistd.h>
     26#include <limits.h>                                                                             // PTHREAD_STACK_MIN
    2627}
    2728
     
    6465event_kernel_t * event_kernel;                        // kernel public handle to even kernel
    6566static pthread_t alarm_thread;                        // pthread handle to alarm thread
     67static void * alarm_stack;                                                        // pthread stack for alarm thread
    6668
    6769static void ?{}(event_kernel_t & this) with( this ) {
     
    8183// Get next expired node
    8284static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
    83         if( !alarms->head ) return NULL;                          // If no alarms return null
    84         if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
    85         return pop(alarms);                                       // Otherwise just pop head
     85        if( !alarms->head ) return 0p;                                          // If no alarms return null
     86        if( alarms->head->alarm >= currtime ) return 0p;        // If alarms head not expired return null
     87        return pop(alarms);                                                                     // Otherwise just pop head
    8688}
    8789
    8890// Tick one frame of the Discrete Event Simulation for alarms
    8991static void tick_preemption() {
    90         alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
    91         alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
    92         Time currtime = __kernel_get_time();                    // Check current time once so we everything "happens at once"
     92        alarm_node_t * node = 0p;                                                       // Used in the while loop but cannot be declared in the while condition
     93        alarm_list_t * alarms = &event_kernel->alarms;          // Local copy for ease of reading
     94        Time currtime = __kernel_get_time();                            // Check current time once so everything "happens at once"
    9395
    9496        //Loop throught every thing expired
     
    243245        sigaddset( &mask, sig );
    244246
    245         if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
     247        if ( pthread_sigmask( SIG_UNBLOCK, &mask, 0p ) == -1 ) {
    246248            abort( "internal error, pthread_sigmask" );
    247249        }
     
    254256        sigaddset( &mask, sig );
    255257
    256         if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
     258        if ( pthread_sigmask( SIG_BLOCK, &mask, 0p ) == -1 ) {
    257259            abort( "internal error, pthread_sigmask" );
    258260        }
     
    301303
    302304        // Setup proper signal handlers
    303         __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
     305        __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // CtxSwitch handler
    304306
    305307        signal_block( SIGALRM );
    306308
    307         pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
     309        alarm_stack = create_pthread( &alarm_thread, alarm_loop, 0p );
    308310}
    309311
     
    316318        sigset_t mask;
    317319        sigfillset( &mask );
    318         sigprocmask( SIG_BLOCK, &mask, NULL );
     320        sigprocmask( SIG_BLOCK, &mask, 0p );
    319321
    320322        // Notify the alarm thread of the shutdown
     
    323325
    324326        // Wait for the preemption thread to finish
    325         pthread_join( alarm_thread, NULL );
     327
     328        pthread_join( alarm_thread, 0p );
     329        free( alarm_stack );
    326330
    327331        // Preemption is now fully stopped
     
    380384        static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
    381385        #endif
    382         if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
     386        if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), 0p ) == -1 ) {
    383387                abort( "internal error, sigprocmask" );
    384388        }
     
    399403        sigset_t mask;
    400404        sigfillset(&mask);
    401         if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
     405        if ( pthread_sigmask( SIG_BLOCK, &mask, 0p ) == -1 ) {
    402406            abort( "internal error, pthread_sigmask" );
    403407        }
     
    420424                                        {__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );}
    421425                                        continue;
    422                         case EINVAL :
     426                                case EINVAL :
    423427                                        abort( "Timeout was invalid." );
    424428                                default:
     
    453457EXIT:
    454458        __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
    455         return NULL;
     459        return 0p;
    456460}
    457461
     
    466470        sigset_t oldset;
    467471        int ret;
    468         ret = pthread_sigmask(0, NULL, &oldset);
     472        ret = pthread_sigmask(0, 0p, &oldset);
    469473        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
    470474
  • libcfa/src/concurrency/thread.cfa

    rb798713 rf80f840  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 17:19:52 2018
    13 // Update Count     : 8
     12// Last Modified On : Wed Dec  4 09:17:49 2019
     13// Update Count     : 9
    1414//
    1515
     
    3333// Thread ctors and dtors
    3434void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    35         context{ NULL, NULL };
     35        context{ 0p, 0p };
    3636        self_cor{ name, storage, storageSize };
    3737        state = Start;
     
    4444        link.prev = 0p;
    4545
    46         node.next = NULL;
    47         node.prev = NULL;
     46        node.next = 0p;
     47        node.prev = 0p;
    4848        doregister(curr_cluster, this);
    4949
  • libcfa/src/concurrency/thread.hfa

    rb798713 rf80f840  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 17:51:33 2019
    13 // Update Count     : 5
     12// Last Modified On : Wed Dec  4 09:18:14 2019
     13// Update Count     : 6
    1414//
    1515
     
    6161void ^?{}(thread_desc & this);
    6262
    63 static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, NULL, 65000 }; }
    64 static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, NULL, stackSize }; }
     63static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
     64static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }
    6565static inline void ?{}(thread_desc & this, void * storage, size_t storageSize )                             { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }
    66 static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, NULL, 65000 }; }
    67 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, NULL, stackSize }; }
     66static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
     67static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, 0p, stackSize }; }
    6868static inline void ?{}(thread_desc & this, struct cluster & cl, void * storage, size_t storageSize )        { this{ "Anonymous Thread", cl, storage, storageSize }; }
    69 static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, NULL, 65000 }; }
    70 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, NULL, 65000 }; }
    71 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, NULL, stackSize }; }
     69static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
     70static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
     71static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }
    7272
    7373//-----------------------------------------------------------------------------
  • libcfa/src/fstream.cfa

    rb798713 rf80f840  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 10 22:19:56 2019
    13 // Update Count     : 354
     12// Last Modified On : Fri Nov 29 06:56:46 2019
     13// Update Count     : 355
    1414//
    1515
     
    6666} // ?{}
    6767
     68void ^?{}( ofstream & os ) {
     69        close( os );
     70} // ^?{}
     71
    6872void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
    6973void sepOff( ofstream & os ) { os.sepOnOff = false; }
     
    195199} // ?{}
    196200
     201void ^?{}( ifstream & is ) {
     202        close( is );
     203} // ^?{}
     204
    197205void nlOn( ifstream & os ) { os.nlOnOff = true; }
    198206void nlOff( ifstream & os ) { os.nlOnOff = false; }
  • libcfa/src/fstream.hfa

    rb798713 rf80f840  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 15 18:10:23 2019
    13 // Update Count     : 167
     12// Last Modified On : Fri Nov 29 06:56:02 2019
     13// Update Count     : 168
    1414//
    1515
     
    7272void ?{}( ofstream & os, const char * name, const char * mode );
    7373void ?{}( ofstream & os, const char * name );
     74void ^?{}( ofstream & os );
    7475
    7576extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
     
    101102void ?{}( ifstream & is, const char * name, const char * mode );
    102103void ?{}( ifstream & is, const char * name );
     104void ^?{}( ifstream & is );
    103105
    104106extern ifstream & sin, & stdin;                                                 // aliases
  • libcfa/src/heap.cfa

    rb798713 rf80f840  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Nov 24 17:56:15 2019
    13 // Update Count     : 638
     12// Last Modified On : Wed Dec  4 21:42:46 2019
     13// Update Count     : 646
    1414//
    1515
     
    3535static bool traceHeap = false;
    3636
    37 inline bool traceHeap() {
    38         return traceHeap;
    39 } // traceHeap
     37inline bool traceHeap() { return traceHeap; }
    4038
    4139bool traceHeapOn() {
     
    5149} // traceHeapOff
    5250
     51bool traceHeapTerm() { return false; }
     52
    5353
    5454static bool prtFree = false;
     
    7171
    7272
    73 // static bool traceHeapTerm = false;
    74 
    75 // inline bool traceHeapTerm() {
    76 //      return traceHeapTerm;
    77 // } // traceHeapTerm
    78 
    79 // bool traceHeapTermOn() {
    80 //      bool temp = traceHeapTerm;
    81 //      traceHeapTerm = true;
    82 //      return temp;
    83 // } // traceHeapTermOn
    84 
    85 // bool traceHeapTermOff() {
    86 //      bool temp = traceHeapTerm;
    87 //      traceHeapTerm = false;
    88 //      return temp;
    89 // } // traceHeapTermOff
    90 
    91 
    9273enum {
    9374        // Define the default extension heap amount in units of bytes. When the uC++ supplied heap reaches the brk address,
     
    11596        if ( allocFree != 0 ) {
    11697                // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
    117                 // char helpText[512];
    118                 // int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
    119                 //                                      "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
    120                 //                                      (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
    121                 // __cfaabi_dbg_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
     98                char helpText[512];
     99                int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
     100                                                        "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
     101                                                        (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
     102                __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
    122103        } // if
    123104} // prtUnfreed
     
    713694static void ^?{}( HeapManager & ) {
    714695        #ifdef __STATISTICS__
    715         // if ( traceHeapTerm() ) {
    716         //      printStats();
    717         //      if ( prtfree() ) prtFree( heapManager, true );
    718         // } // if
     696        if ( traceHeapTerm() ) {
     697                printStats();
     698                // if ( prtfree() ) prtFree( heapManager, true );
     699        } // if
    719700        #endif // __STATISTICS__
    720701} // ~HeapManager
     
    874855                #endif // __STATISTICS__
    875856
    876           if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases
     857                // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
     858          if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases
    877859          if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );
    878860
     
    11011083        #endif // __STATISTICS__
    11021084
    1103   if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases
     1085        // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
     1086  if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases
    11041087  if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );
    11051088
  • libcfa/src/interpose.cfa

    rb798713 rf80f840  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 16:47:02 2019
    13 // Update Count     : 118
     12// Last Modified On : Sat Nov 30 07:09:42 2019
     13// Update Count     : 119
    1414//
    1515
     
    196196        __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]);
    197197
    198         for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) {
    199                 char * name = NULL, * offset_begin = NULL, * offset_end = NULL;
     198        for ( int i = Start; i < size - abort_lastframe && messages != 0p; i += 1 ) {
     199                char * name = 0p, * offset_begin = 0p, * offset_end = 0p;
    200200
    201201                for ( char * p = messages[i]; *p; ++p ) {
  • libcfa/src/startup.cfa

    rb798713 rf80f840  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 25 16:42:01 2018
    13 // Update Count     : 11
     12// Last Modified On : Sat Nov 30 07:07:56 2019
     13// Update Count     : 13
    1414//
    1515
    1616#include "startup.hfa"
    17 #include <unistd.h>
    18 
     17#include <time.h>                                                                               // tzset
    1918
    2019extern "C" {
    2120    static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
    2221    void __cfaabi_appready_startup( void ) {
     22                tzset();                                                                                // initialize time global variables
    2323                #ifdef __CFA_DEBUG__
    2424                extern void heapAppStart();
  • libcfa/src/stdlib.hfa

    rb798713 rf80f840  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 22 15:13:14 2019
    13 // Update Count     : 399
     12// Last Modified On : Fri Nov 29 23:08:02 2019
     13// Update Count     : 400
    1414//
    1515
     
    210210
    211211static inline {
    212         int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); }
    213         unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); }
    214         long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); }
    215         unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0, 10 ); }
    216         long long int ato( const char * sptr ) { return strtoll( sptr, 0, 10 ); }
    217         unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0, 10 ); }
    218 
    219         float ato( const char * sptr ) { return strtof( sptr, 0 ); }
    220         double ato( const char * sptr ) { return strtod( sptr, 0 ); }
    221         long double ato( const char * sptr ) { return strtold( sptr, 0 ); }
    222 
    223         float _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    224         double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    225         long double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
     212        int ato( const char * sptr ) { return (int)strtol( sptr, 0p, 10 ); }
     213        unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0p, 10 ); }
     214        long int ato( const char * sptr ) { return strtol( sptr, 0p, 10 ); }
     215        unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0p, 10 ); }
     216        long long int ato( const char * sptr ) { return strtoll( sptr, 0p, 10 ); }
     217        unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0p, 10 ); }
     218
     219        float ato( const char * sptr ) { return strtof( sptr, 0p ); }
     220        double ato( const char * sptr ) { return strtod( sptr, 0p ); }
     221        long double ato( const char * sptr ) { return strtold( sptr, 0p ); }
     222
     223        float _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
     224        double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
     225        long double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
    226226} // distribution
    227227
  • longrun_tests/Makefile.in

    rb798713 rf80f840  
    486486LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    487487        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    488         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    489         $(AM_CFLAGS) $(CFLAGS)
     488        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    490489
    491490AM_V_CFA = $(am__v_CFA_@AM_V@)
  • src/Concurrency/Keywords.cc

    rb798713 rf80f840  
    309309                        if( !type_decl ) SemanticError( cast, context_error );
    310310                        if( !dtor_decl ) SemanticError( cast, context_error );
    311                         Expression * arg = cast->arg;
    312                         cast->arg = nullptr;
    313                         delete cast;
    314                         return new CastExpr(
    315                                 UntypedExpr::createDeref(
    316                                         new UntypedExpr( new NameExpr( getter_name ), { arg } )
    317                                 ),
    318                                 new ReferenceType(
    319                                         noQualifiers,
    320                                         new StructInstType( noQualifiers, type_decl ) )
    321                                 );
     311                        assert( cast->result == nullptr );
     312                        cast->set_result( new ReferenceType( noQualifiers, new StructInstType( noQualifiers, type_decl ) ) );
     313                        cast->concrete_target.field  = field_name;
     314                        cast->concrete_target.getter = getter_name;
    322315                }
    323316                return cast;
  • src/Parser/parser.yy

    rb798713 rf80f840  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 21:48:23 2019
    13 // Update Count     : 4364
     12// Last Modified On : Sat Dec  7 10:43:44 2019
     13// Update Count     : 4394
    1414//
    1515
     
    211211} // forCtrl
    212212
     213KeywordCastExpr::Target Aggregate2Target( DeclarationNode::Aggregate aggr ) {
     214        KeywordCastExpr::Target target;
     215        switch ( aggr ) {
     216          case DeclarationNode::Coroutine: target = KeywordCastExpr::Coroutine; break;
     217          case DeclarationNode::Monitor: target = KeywordCastExpr::Monitor; break;
     218          case DeclarationNode::Thread: target = KeywordCastExpr::Thread; break;
     219          default: abort();
     220        } // switch
     221        return target;
     222} // Aggregate2Target
     223
    213224
    214225bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     
    365376%type<decl> abstract_parameter_declaration
    366377
    367 %type<aggKey> aggregate_key
     378%type<aggKey> aggregate_key aggregate_data aggregate_control
    368379%type<decl> aggregate_type aggregate_type_nobody
    369380
     
    650661        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651662                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     663        | postfix_expression '.' aggregate_control
     664                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }
    652665        | postfix_expression ARROW identifier
    653666                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    793806        | '(' type_no_function ')' cast_expression
    794807                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    795                 // keyword cast cannot be grouped because of reduction in aggregate_key
    796         | '(' GENERATOR '&' ')' cast_expression                         // CFA
    797                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
    798         | '(' COROUTINE '&' ')' cast_expression                         // CFA
    799                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
    800         | '(' THREAD '&' ')' cast_expression                            // CFA
    801                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
    802         | '(' MONITOR '&' ')' cast_expression                           // CFA
    803                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
     808        | '(' aggregate_control '&' ')' cast_expression         // CFA
     809                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); }
    804810                // VIRTUAL cannot be opt because of look ahead issues
    805811        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    20592065
    20602066aggregate_key:
     2067        aggregate_data
     2068        | aggregate_control
     2069        ;
     2070
     2071aggregate_data:
    20612072        STRUCT
    20622073                { yyy = true; $$ = DeclarationNode::Struct; }
    20632074        | UNION
    20642075                { yyy = true; $$ = DeclarationNode::Union; }
    2065         | EXCEPTION
     2076        | EXCEPTION                                                                                     // CFA
    20662077                { yyy = true; $$ = DeclarationNode::Exception; }
    2067         | GENERATOR
     2078        ;
     2079
     2080aggregate_control:                                                                              // CFA
     2081        GENERATOR
    20682082                { yyy = true; $$ = DeclarationNode::Coroutine; }
    20692083        | COROUTINE
     
    20962110                        distInl( $3 );
    20972111                }
     2112        | INLINE aggregate_control ';'                                          // CFA
     2113                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    20982114        | typedef_declaration ';'                                                       // CFA
    20992115        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
  • src/ResolvExpr/AlternativeFinder.cc

    rb798713 rf80f840  
    6969                void postvisit( CastExpr * castExpr );
    7070                void postvisit( VirtualCastExpr * castExpr );
     71                void postvisit( KeywordCastExpr * castExpr );
    7172                void postvisit( UntypedMemberExpr * memberExpr );
    7273                void postvisit( MemberExpr * memberExpr );
     
    12551256        }
    12561257
     1258        void AlternativeFinder::Finder::postvisit( KeywordCastExpr * castExpr ) {
     1259                assertf( castExpr->get_result(), "Cast target should have been set in Validate." );
     1260                auto ref = dynamic_cast<ReferenceType*>(castExpr->get_result());
     1261                assert(ref);
     1262                auto inst = dynamic_cast<StructInstType*>(ref->base);
     1263                assert(inst);
     1264                auto target = inst->baseStruct;
     1265
     1266                AlternativeFinder finder( indexer, env );
     1267
     1268                auto pick_alternatives = [target, this](AltList & found, bool expect_ref) {
     1269                        for(auto & alt : found) {
     1270                                Type * expr = alt.expr->get_result();
     1271                                if(expect_ref) {
     1272                                        auto res = dynamic_cast<ReferenceType*>(expr);
     1273                                        if(!res) { continue; }
     1274                                        expr = res->base;
     1275                                }
     1276
     1277                                if(auto insttype = dynamic_cast<TypeInstType*>(expr)) {
     1278                                        auto td = alt.env.lookup(insttype->name);
     1279                                        if(!td) { continue; }
     1280                                        expr = td->type;
     1281                                }
     1282
     1283                                if(auto base = dynamic_cast<StructInstType*>(expr)) {
     1284                                        if(base->baseStruct == target) {
     1285                                                alternatives.push_back(
     1286                                                        std::move(alt)
     1287                                                );
     1288                                        }
     1289                                }
     1290                        }
     1291                };
     1292
     1293                try {
     1294                        // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd
     1295                        // Clone is purely for memory management
     1296                        std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };
     1297
     1298                        // don't prune here, since it's guaranteed all alternatives will have the same type
     1299                        finder.findWithoutPrune( tech1.get() );
     1300                        pick_alternatives(finder.alternatives, false);
     1301
     1302                        return;
     1303                } catch(SemanticErrorException & ) {}
     1304
     1305                // Fallback : turn (thread&)X into (thread_desc&)get_thread(X)
     1306                std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };
     1307                // don't prune here, since it's guaranteed all alternatives will have the same type
     1308                finder.findWithoutPrune( fallback.get() );
     1309
     1310                pick_alternatives(finder.alternatives, true);
     1311
     1312                // Whatever happens here, we have no more fallbacks
     1313        }
     1314
    12571315        namespace {
    12581316                /// Gets name from untyped member expression (member must be NameExpr)
  • src/SynTree/Expression.h

    rb798713 rf80f840  
    231231        enum Target {
    232232                Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
    233         } target;
     233        };
     234        struct Concrete {
     235                std::string field;
     236                std::string getter;
     237        };
     238        Target target;
     239        Concrete concrete_target;
    234240
    235241        KeywordCastExpr( Expression * arg, Target target );
  • src/cfa.make

    rb798713 rf80f840  
    44LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    55        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    6         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    7         $(AM_CFLAGS) $(CFLAGS)
     6        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    87
    98AM_V_CFA = $(am__v_CFA_@AM_V@)
  • tests/Makefile.am

    rb798713 rf80f840  
    4646
    4747# adjust CC to current flags
    48 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     48CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    4949CFACC = $(CC)
    5050
     
    5353
    5454# adjusted CC but without the actual distcc call
    55 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     55CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    5656
    5757PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
  • tests/Makefile.in

    rb798713 rf80f840  
    214214
    215215# adjust CC to current flags
    216 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     216CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    217217CCAS = @CCAS@
    218218CCASDEPMODE = @CCASDEPMODE@
     
    358358LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    359359        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    360         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
    361         $(AM_CFLAGS) $(CFLAGS)
     360        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
    362361
    363362AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    405404
    406405# adjusted CC but without the actual distcc call
    407 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     406CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    408407PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
    409408avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa
  • tests/concurrent/thread.cfa

    rb798713 rf80f840  
    77thread Second { semaphore* lock; };
    88
    9 void ?{}( First  & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; }
    10 void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; }
     9void ?{}( First  & this, semaphore & lock ) { ((thread&)this){ "Thread 1" }; this.lock = &lock; }
     10void ?{}( Second & this, semaphore & lock ) { ((thread&)this){ "Thread 2" }; this.lock = &lock; }
    1111
    1212void main(First& this) {
  • tests/linking/withthreads.cfa

    rb798713 rf80f840  
    3434// Local Variables: //
    3535// tab-width: 4 //
    36 // compile-command: "cfa nothreads.cfa" //
     36// compile-command: "cfa withthreads.cfa" //
    3737// End: //
  • tests/references.cfa

    rb798713 rf80f840  
    124124                int *p = &a;
    125125                asm (
    126                         "incl %[p]\n\t" :
    127                         : [p] "m" (*p)
     126                        "incl %[p]\n\t"
     127                        : [p] "+m" (*p)
    128128                );
    129129                printf("%d\n", a);
  • tests/time.cfa

    rb798713 rf80f840  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 20 23:09:21 2018
    13 // Update Count     : 23
     12// Last Modified On : Fri Nov 29 23:05:30 2019
     13// Update Count     : 24
    1414//
    1515
     
    2020        Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns;
    2121        sout | d1 | d2 | d3 | d4 | d5;
    22         int i;
    2322        d1 = 0;
    2423        sout | d1 | d2 | d3;
Note: See TracChangeset for help on using the changeset viewer.