Changeset 9b443c7f


Ignore:
Timestamp:
Mar 15, 2017, 5:02:25 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
f2e40a9f
Parents:
5a3ac84 (diff), 29f44a74 (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

Files:
43 edited
4 moved

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    r5a3ac84 r9b443c7f  
    2020
    2121                                        parallel (
    22                                                 gcc_6_x64: { trigger_build( 'gcc-6',   'x64' ) },
    23                                                 gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
    24                                                 gcc_5_x64: { trigger_build( 'gcc-5',   'x64' ) },
    25                                                 gcc_5_x86: { trigger_build( 'gcc-5',   'x86' ) },
    26                                                 gcc_4_x64: { trigger_build( 'gcc-4.9', 'x64' ) },
    27                                                 gcc_4_x86: { trigger_build( 'gcc-4.9', 'x86' ) },
    28                                                 clang_x64: { trigger_build( 'clang',   'x64' ) },
    29                                                 clang_x86: { trigger_build( 'clang',   'x86' ) },
     22                                                gcc_6_x64: { trigger_build( 'gcc-6',   'x64', true ) },
     23                                                gcc_6_x86: { trigger_build( 'gcc-6',   'x86', true ) },
     24                                                gcc_5_x64: { trigger_build( 'gcc-5',   'x64', false ) },
     25                                                gcc_5_x86: { trigger_build( 'gcc-5',   'x86', false ) },
     26                                                gcc_4_x64: { trigger_build( 'gcc-4.9', 'x64', false ) },
     27                                                gcc_4_x86: { trigger_build( 'gcc-4.9', 'x86', false ) },
     28                                                clang_x64: { trigger_build( 'clang',   'x64', false ) },
     29                                                clang_x86: { trigger_build( 'clang',   'x86', false ) },
    3030                                        )
    3131
     
    6262//===========================================================================================================
    6363
    64 def trigger_build(String cc, String arch) {
     64def trigger_build(String cc, String arch, Boolean publish) {
    6565        def result = build job: 'Cforall/master',               \
    6666                parameters: [                                           \
     
    8282                        [$class: 'BooleanParameterValue',               \
    8383                          name: 'pPublish',                             \
    84                           value: true],                                         \
     84                          value: publish],                                      \
    8585                        [$class: 'BooleanParameterValue',               \
    8686                          name: 'pSilent',                              \
  • Jenkinsfile

    r5a3ac84 r9b443c7f  
    1313
    1414        compiler                = null
     15        arch_name               = ''
    1516        architecture    = ''
    1617       
     
    130131                                [$class: 'BooleanParameterDefinition',                                                  \
    131132                                        description: 'If true, jenkins also builds documentation',              \
    132                                         name: 'pBuildDocumentation',                                                            \
     133                                        name: 'pBuildDocumentation',                                                    \
    133134                                        defaultValue: true,                                                             \
    134135                                ],                                                                                              \
     
    136137                                        description: 'If true, jenkins also publishes results',                 \
    137138                                        name: 'pPublish',                                                               \
    138                                         defaultValue: true,                                                             \
     139                                        defaultValue: false,                                                            \
    139140                                ],                                                                                              \
    140141                                [$class: 'BooleanParameterDefinition',                                                  \
    141142                                        description: 'If true, jenkins will not send emails',           \
    142                                         name: 'pSilent',                                                \
     143                                        name: 'pSilent',                                                                        \
    143144                                        defaultValue: false,                                                            \
    144145                                ],                                                                                              \
     
    147148
    148149        compiler                = compiler_from_params( pCompiler )
    149         architecture    = architecture_from_params( pArchitecture )
     150        arch_name               = pArchitecture
     151        architecture    = architecture_from_params( arch_name )
    150152
    151153        do_alltests             = (pRunAllTests == 'true')
     
    156158
    157159        echo """Compiler                : ${compiler.cc_name} (${compiler.cpp_cc}/${compiler.cfa_cc})
    158 Architecture            : ${architecture}
     160Architecture            : ${arch_name}
     161Arc Flags               : ${architecture}
    159162Run All Tests           : ${ pRunAllTests.toString() }
    160163Run Benchmark           : ${ pRunBenchmark.toString() }
     
    287290
    288291                //Write the commit id to Benchmark
    289                 writeFile  file: 'bench.csv', text:'data=' + gitRefNewValue + ','
     292                writeFile  file: 'bench.csv', text:'data=' + gitRefNewValue + ',' + arch_name + ','
    290293 
    291294                //Append bench results
  • doc/proposals/concurrency/thePlan.md

    r5a3ac84 r9b443c7f  
    77
    88_Phase 2_ : Minimum Viable Product
    9 Monitor type and enter/leave mutex member routines
     9done - Monitor type and enter/leave mutex member routines
    1010Monitors as a language feature (not calling enter/leave by hand)
    1111Internal scheduling
  • src/CodeGen/CodeGenerator.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Mar  5 17:13:33 2017
    13 // Update Count     : 475
     12// Last Modified On : Mon Mar 13 23:56:59 2017
     13// Update Count     : 477
    1414//
    1515
     
    895895
    896896        void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) {
    897                 if ( decl->get_storageClasses().any() ) {
     897                if ( decl->get_storageClasses().val != 0 ) {
    898898                        DeclarationNode::print_StorageClass( output, decl->get_storageClasses() );
    899899                } // if
  • src/Common/utility.h

    r5a3ac84 r9b443c7f  
    265265reverse_iterate_t< T > reverseIterate( T & ref ) {
    266266        return reverse_iterate_t< T >( ref );
     267}
     268
     269template< typename OutType, typename Range, typename Functor >
     270OutType map_range( const Range& range, Functor&& functor ) {
     271        OutType out;
     272
     273        std::transform(
     274                begin( range ),
     275                end( range ),
     276                std::back_inserter( out ),
     277                std::forward< Functor >( functor )
     278        );
     279
     280        return out;
    267281}
    268282
  • src/Concurrency/Keywords.cc

    r5a3ac84 r9b443c7f  
     1//                              -*- Mode: CPP -*-
     2//
     3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     4//
     5// The contents of this file are covered under the licence agreement in the
     6// file "LICENCE" distributed with Cforall.
     7//
     8// Keywords.cc --
     9//
     10// Author           : Thierry Delisle
     11// Created On       : Mon Mar 13 12:41:22 2017
     12// Last Modified By :
     13// Last Modified On :
     14// Update Count     : 0
     15//
     16
     17#include "Concurrency/Keywords.h"
     18
     19#include "SynTree/Declaration.h"
     20#include "SynTree/Expression.h"
     21#include "SynTree/Initializer.h"
     22#include "SynTree/Mutator.h"
     23#include "SynTree/Statement.h"
     24#include "SynTree/Type.h"
     25#include "SynTree/Visitor.h"
     26
     27namespace Concurrency {
     28
     29        namespace {
     30                const std::list<Label> noLabels;
     31                DeclarationNode::StorageClasses noStorage;
     32                Type::Qualifiers noQualifiers;
     33        }
     34
     35        //=============================================================================================
     36        // Visitors declaration
     37        //=============================================================================================
     38
     39        //-----------------------------------------------------------------------------
     40        //Handles thread type declarations :
     41        // thread Mythread {                         struct MyThread {
     42        //      int data;                                  int data;
     43        //      a_struct_t more_data;                      a_struct_t more_data;
     44        //                                =>             thread_desc __thrd_d;
     45        // };                                        };
     46        //                                           static inline thread_desc * get_thread( MyThread * this ) { return &this->__thrd_d; }
     47        //                                           void main( MyThread * this );
     48        //
     49        class ThreadKeyword final : public Mutator {
     50          public:
     51
     52                static void implement( std::list< Declaration * > & translationUnit ) {}
     53        };
     54
     55        //-----------------------------------------------------------------------------
     56        //Handles coroutine type declarations :
     57        // coroutine MyCoroutine {                   struct MyCoroutine {
     58        //      int data;                                  int data;
     59        //      a_struct_t more_data;                      a_struct_t more_data;
     60        //                                =>             coroutine_desc __cor_d;
     61        // };                                        };
     62        //                                           static inline coroutine_desc * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; }
     63        //                                           void main( MyCoroutine * this );
     64        //
     65        class CoroutineKeyword final : public Mutator {
     66          public:
     67
     68                static void implement( std::list< Declaration * > & translationUnit ) {}
     69        };
     70
     71        //-----------------------------------------------------------------------------
     72        //Handles monitor type declarations :
     73        // monitor MyMonitor {                       struct MyMonitor {
     74        //      int data;                                  int data;
     75        //      a_struct_t more_data;                      a_struct_t more_data;
     76        //                                =>             monitor_desc __mon_d;
     77        // };                                        };
     78        //                                           static inline monitor_desc * get_coroutine( MyMonitor * this ) { return &this->__cor_d; }
     79        //                                           void main( MyMonitor * this );
     80        //
     81        class MonitorKeyword final : public Mutator {
     82          public:
     83
     84                static void implement( std::list< Declaration * > & translationUnit ) {}
     85        };
     86
     87        //-----------------------------------------------------------------------------
     88        //Handles mutex routines definitions :
     89        // void foo( A * mutex a, B * mutex b,  int i ) {                  void foo( A * a, B * b,  int i ) {
     90        //                                                                       monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) };
     91        //                                                                       monitor_guard_t __guard = { __monitors, 2 };
     92        //    /*Some code*/                                       =>           /*Some code*/
     93        // }                                                               }
     94        //
     95        class MutexKeyword final : public Visitor {
     96          public:
     97
     98                using Visitor::visit;
     99                virtual void visit( FunctionDecl *functionDecl ) override final;
     100                virtual void visit(   StructDecl *functionDecl ) override final;
     101
     102                std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
     103                void validate( DeclarationWithType * );
     104                void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &);
     105
     106                static void implement( std::list< Declaration * > & translationUnit ) {
     107                        MutexKeyword impl;
     108                        acceptAll( translationUnit, impl );
     109                }
     110
     111          private:
     112                StructDecl* monitor_decl = nullptr;
     113        };
     114
     115        //=============================================================================================
     116        // General entry routine
     117        //=============================================================================================
     118        void applyKeywords( std::list< Declaration * > & translationUnit ) {
     119                ThreadKeyword   ::implement( translationUnit );
     120                CoroutineKeyword        ::implement( translationUnit );
     121                MonitorKeyword  ::implement( translationUnit );
     122                MutexKeyword    ::implement( translationUnit );
     123        }
     124
     125        //=============================================================================================
     126        // Mutex keyword implementation
     127        //=============================================================================================
     128        void MutexKeyword::visit(FunctionDecl* decl) {
     129                std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl );
     130                if( mutexArgs.empty() ) return;
     131
     132                for(auto arg : mutexArgs) {
     133                        validate( arg );
     134                }
     135
     136                CompoundStmt* body = decl->get_statements();
     137                if( ! body ) return;
     138
     139                assert(monitor_decl);
     140                addStatments( body, mutexArgs );
     141        }
     142
     143        void MutexKeyword::visit(StructDecl* decl) {
     144                if( decl->get_name() == "monitor_desc" ) {
     145                        assert( !monitor_decl );
     146                        monitor_decl = decl;
     147                }
     148        }
     149
     150        std::list<DeclarationWithType*> MutexKeyword::findMutexArgs( FunctionDecl* decl ) {
     151                std::list<DeclarationWithType*> mutexArgs;
     152
     153                for( auto arg : decl->get_functionType()->get_parameters()) {
     154                        //Find mutex arguments
     155                        Type* ty = arg->get_type();
     156                        if( ! ty->get_qualifiers().isMutex ) continue;
     157
     158                        //Append it to the list
     159                        mutexArgs.push_back( arg );
     160                }
     161
     162                return mutexArgs;
     163        }
     164
     165        void MutexKeyword::validate( DeclarationWithType * arg ) {
     166                Type* ty = arg->get_type();
     167
     168                //Makes sure it's not a copy
     169                PointerType* pty = dynamic_cast< PointerType * >( ty );
     170                if( ! pty ) throw SemanticError( "Mutex argument must be of pointer/reference type ", arg );
     171
     172                //Make sure the we are pointing directly to a type
     173                Type* base = pty->get_base();
     174                if(  dynamic_cast< PointerType * >( base ) ) throw SemanticError( "Mutex argument have exactly one level of indirection ", arg );
     175
     176                //Make sure that typed isn't mutex
     177                if( ! base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );
     178        }
     179
     180        void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
     181
     182                ObjectDecl * monitors = new ObjectDecl(
     183                        "__monitors",
     184                        noStorage,
     185                        LinkageSpec::Cforall,
     186                        nullptr,
     187                        new ArrayType(
     188                                noQualifiers,
     189                                new PointerType(
     190                                        noQualifiers,
     191                                        new StructInstType(
     192                                                noQualifiers,
     193                                                monitor_decl
     194                                        )
     195                                ),
     196                                new ConstantExpr( Constant::from_ulong( args.size() ) ),
     197                                false,
     198                                false
     199                        ),
     200                        new ListInit(
     201                                map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){
     202                                        return new SingleInit( new UntypedExpr(
     203                                                new NameExpr( "get_monitor" ),
     204                                                {  new VariableExpr( var ) }
     205                                        ) );
     206                                })
     207                        )
     208                );
     209
     210                //in reverse order :
     211                // monitor_guard_t __guard = { __monitors, # };
     212                body->push_front(
     213                        new DeclStmt( noLabels, new ObjectDecl(
     214                                "__guard",
     215                                noStorage,
     216                                LinkageSpec::Cforall,
     217                                nullptr,
     218                                new StructInstType(
     219                                        noQualifiers,
     220                                        "monitor_guard_t"
     221                                ),
     222                                new ListInit(
     223                                        {
     224                                                new SingleInit( new VariableExpr( monitors ) ),
     225                                                new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
     226                                        }
     227                                )
     228                        ))
     229                );
     230
     231                //monitor_desc * __monitors[] = { a, b };
     232                body->push_front( new DeclStmt( noLabels, monitors) );
     233        }
     234};
  • src/Concurrency/Keywords.h

    r5a3ac84 r9b443c7f  
     1//                              -*- Mode: CPP -*-
     2//
     3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     4//
     5// The contents of this file are covered under the licence agreement in the
     6// file "LICENCE" distributed with Cforall.
     7//
     8// Keywords.h --
     9//
     10// Author           : Thierry Delisle
     11// Created On       : Fri Mar 10 15:16:42 2017
     12// Last Modified By :
     13// Last Modified On :
     14// Update Count     : 0
     15//
     16
     17#ifndef KEYWORDS_H
     18#define KEYWORDS_H
     19
     20#include <list>
     21
     22#include "SynTree/Declaration.h"
     23
     24namespace Concurrency {
     25        void applyKeywords( std::list< Declaration * > & translationUnit );
     26};
     27
     28#endif //KEYWORDS_H
  • src/GenPoly/Box.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  6 23:45:59 2017
    13 // Update Count     : 330
     12// Last Modified On : Tue Mar 14 07:45:29 2017
     13// Update Count     : 334
    1414//
    1515
     
    299299                // because each unit generates copies of the default routines for each aggregate.
    300300                FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ),
    301                                                                                                          functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass ),
     301                                                                                                         functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static ),
    302302                                                                                                         LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ),
    303                                                                                                          std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) );
     303                                                                                                         std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );
    304304                layoutDecl->fixUniqueId();
    305305                return layoutDecl;
  • src/InitTweak/FixGlobalInit.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Mon May 04 15:14:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  6 23:14:19 2017
    13 // Update Count     : 14
     12// Last Modified On : Mon Mar 13 23:58:27 2017
     13// Update Count     : 16
    1414//
    1515
     
    8787                        dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) );
    8888                }
    89                 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
     89                initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
    9090                initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) );
    91                 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
     91                destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
    9292                destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) );
    9393        }
     
    143143// compile-command: "make install" //
    144144// End: //
    145 
  • src/InitTweak/FixInit.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:51:40 2017
    13 // Update Count     : 59
     12// Last Modified On : Tue Mar 14 08:05:28 2017
     13// Update Count     : 63
    1414//
    1515
     
    678678                                assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() );
    679679                                if ( Statement * ctor = ctorInit->get_ctor() ) {
    680                                         if ( objDecl->get_storageClasses()[ DeclarationNode::Static ] ) {
     680                                        if ( objDecl->get_storageClasses().is_static ) {
    681681                                                // originally wanted to take advantage of gcc nested functions, but
    682682                                                // we get memory errors with this approach. To remedy this, the static
     
    704704                                                BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
    705705                                                SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators );
    706                                                 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
     706                                                ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
    707707                                                isUninitializedVar->fixUniqueId();
    708708
     
    731731
    732732                                                        // void __objName_dtor_atexitN(...) {...}
    733                                                         FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
     733                                                        FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
    734734                                                        dtorCaller->fixUniqueId();
    735735                                                        dtorCaller->get_statements()->push_back( dtorStmt );
     
    764764                                                        // create a new object which is never used
    765765                                                        static UniqueName dummyNamer( "_dummy" );
    766                                                         ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::StaticClass ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );
     766                                                        ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );
    767767                                                        return dummy;
    768768                                                }
     
    821821                void InsertDtors::visit( ObjectDecl * objDecl ) {
    822822                        // remember non-static destructed objects so that their destructors can be inserted later
    823                         if ( ! objDecl->get_storageClasses()[ DeclarationNode::Static ] ) {
     823                        if ( ! objDecl->get_storageClasses().is_static ) {
    824824                                if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
    825825                                        // a decision should have been made by the resolver, so ctor and init are not both non-NULL
  • src/InitTweak/GenInit.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:51:38 2017
    13 // Update Count     : 179
     12// Last Modified On : Mon Mar 13 23:59:09 2017
     13// Update Count     : 180
    1414//
    1515
     
    186186                // C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension.
    187187                if ( ! inFunction ) return;
    188                 if ( storageClasses[ DeclarationNode::StaticClass] ) return;
     188                if ( storageClasses.is_static ) return;
    189189
    190190                if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
  • src/InitTweak/InitTweak.cc

    r5a3ac84 r9b443c7f  
    260260                        (objDecl->get_init() == NULL ||
    261261                                ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ))
    262                         && ! objDecl->get_storageClasses()[ DeclarationNode::Extern ];
     262                        && ! objDecl->get_storageClasses().is_extern;
    263263        }
    264264
  • src/Parser/DeclarationNode.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 17:28:56 2017
    13 // Update Count     : 937
     12// Last Modified On : Tue Mar 14 14:45:52 2017
     13// Update Count     : 973
    1414//
    1515
     
    9090        newnode->type = maybeClone( type );
    9191        newnode->storageClasses = storageClasses;
     92        newnode->funcSpecs = funcSpecs;
    9293        newnode->bitfieldWidth = maybeClone( bitfieldWidth );
    93         newnode->funcSpecs = funcSpecs;
    9494        newnode->enumeratorValue.reset( maybeClone( enumeratorValue.get() ) );
    9595        newnode->hasEllipsis = hasEllipsis;
     
    117117
    118118void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) {
    119         if ( storageClasses.any() ) {                                                           // function specifiers?
     119        if ( storageClasses.val != 0 ) {                                        // storage classes ?
    120120                for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) {
    121121                        if ( storageClasses[i] ) {
     
    127127
    128128void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) {
    129         if ( funcSpec.any() ) {                                                         // function specifiers?
     129        if ( funcSpec.val != 0 ) {                                                      // function specifiers ?
    130130                for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) {
    131131                        if ( funcSpec[i] ) {
     
    202202
    203203
    204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {
    205         DeclarationNode * newnode = new DeclarationNode;
    206         newnode->storageClasses[ sc ] = true;
     204DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) {
     205        DeclarationNode * newnode = new DeclarationNode;
     206        newnode->storageClasses = sc;
    207207        return newnode;
    208208} // DeclarationNode::newStorageClass
    209209
    210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifier fs ) {
    211         DeclarationNode * newnode = new DeclarationNode;
    212         newnode->funcSpecs[ fs ] = true;
     210DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) {
     211        DeclarationNode * newnode = new DeclarationNode;
     212        newnode->funcSpecs = fs;
    213213        return newnode;
    214214} // DeclarationNode::newFuncSpecifier
    215215
    216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) {
     216DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifiers tq ) {
    217217        DeclarationNode * newnode = new DeclarationNode;
    218218        newnode->type = new TypeData();
    219         newnode->type->typeQualifiers[ tq ] = true;
     219        newnode->type->typeQualifiers = tq;
    220220        return newnode;
    221221} // DeclarationNode::newQualifier
     
    457457
    458458void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) {
    459         const TypeData::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization
    460 
    461         if ( (qsrc & qdst).any() ) {                                            // common qualifier ?
    462                 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find common qualifiers
     459        const TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization
     460
     461        if ( (qsrc.val & qdst.val) != 0 ) {                                     // duplicates ?
     462                for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates
    463463                        if ( qsrc[i] && qdst[i] ) {
    464464                                appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] );
     
    469469
    470470void DeclarationNode::checkSpecifiers( DeclarationNode * src ) {
    471         if ( (funcSpecs & src->funcSpecs).any() ) {                     // common specifier ?
    472                 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find common specifier
     471        if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) {                // duplicates ?
     472                for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates
    473473                        if ( funcSpecs[i] && src->funcSpecs[i] ) {
    474474                                appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] );
     
    477477        } // if
    478478
    479         if ( storageClasses != 0 && src->storageClasses != 0 ) { // any reason to check ?
    480                 if ( (storageClasses & src->storageClasses).any() ) { // duplicates ?
     479        if ( storageClasses.val != 0 && src->storageClasses.val != 0 ) { // any reason to check ?
     480                if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ?
    481481                        for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates
    482482                                if ( storageClasses[i] && src->storageClasses[i] ) {
     
    485485                        } // for
    486486                        // src is the new item being added and has a single bit
    487                 } else if ( ! src->storageClasses[ Threadlocal ] ) { // conflict ?
    488                         appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.to_ulong() ) - 1] +
    489                                                  " & " + storageClassNames[ffs( src->storageClasses.to_ulong() ) - 1] );
    490                         src->storageClasses.reset();                            // FIX to preserve invariant of one basic storage specifier
     487                } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ?
     488                        appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] +
     489                                                 " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] );
     490                        src->storageClasses.val = 0;                            // FIX to preserve invariant of one basic storage specifier
    491491                } // if
    492492        } // if
     
    496496
    497497DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) {
    498         funcSpecs = funcSpecs | q->funcSpecs;
    499         storageClasses = storageClasses | q->storageClasses;
     498        funcSpecs.val = funcSpecs.val | q->funcSpecs.val;
     499        storageClasses.val = storageClasses.val | q->storageClasses.val;
    500500
    501501        for ( Attribute *attr: reverseIterate( q->attributes ) ) {
     
    520520                src = nullptr;
    521521        } else {
    522                 dst->typeQualifiers |= src->typeQualifiers;
     522                dst->typeQualifiers.val |= src->typeQualifiers.val;
    523523        } // if
    524524} // addQualifiersToType
     
    578578                switch ( dst->kind ) {
    579579                  case TypeData::Unknown:
    580                         src->typeQualifiers |= dst->typeQualifiers;
     580                        src->typeQualifiers.val |= dst->typeQualifiers.val;
    581581                        dst = src;
    582582                        src = nullptr;
    583583                        break;
    584584                  case TypeData::Basic:
    585                         dst->typeQualifiers |= src->typeQualifiers;
     585                        dst->typeQualifiers.val |= src->typeQualifiers.val;
    586586                        if ( src->kind != TypeData::Unknown ) {
    587587                                assert( src->kind == TypeData::Basic );
     
    619619                                        dst->base->aggInst.params = maybeClone( src->aggregate.actuals );
    620620                                } // if
    621                                 dst->base->typeQualifiers |= src->typeQualifiers;
     621                                dst->base->typeQualifiers.val |= src->typeQualifiers.val;
    622622                                src = nullptr;
    623623                                break;
     
    651651                                                type->aggInst.hoistType = o->type->enumeration.body;
    652652                                        } // if
    653                                         type->typeQualifiers |= o->type->typeQualifiers;
     653                                        type->typeQualifiers.val |= o->type->typeQualifiers.val;
    654654                                } else {
    655655                                        type = o->type;
     
    807807                                        p->type->base->aggInst.params = maybeClone( type->aggregate.actuals );
    808808                                } // if
    809                                 p->type->base->typeQualifiers |= type->typeQualifiers;
     809                                p->type->base->typeQualifiers.val |= type->typeQualifiers.val;
    810810                                break;
    811811
     
    844844                                        lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals );
    845845                                } // if
    846                                 lastArray->base->typeQualifiers |= type->typeQualifiers;
     846                                lastArray->base->typeQualifiers.val |= type->typeQualifiers.val;
    847847                                break;
    848848                          default:
     
    10581058                //    inline _Noreturn int g( int i );  // allowed
    10591059                //    inline _Noreturn int i;                   // disallowed
    1060                 if ( type->kind != TypeData::Function && funcSpecs.any() ) {
     1060                if ( type->kind != TypeData::Function && funcSpecs.val != 0 ) {
    10611061                        throw SemanticError( "invalid function specifier for ", this );
    10621062                } // if
     
    10681068        //    inlne _Noreturn struct S { ... };         // disallowed
    10691069        //    inlne _Noreturn enum   E { ... };         // disallowed
    1070         if ( funcSpecs.any() ) {
     1070        if ( funcSpecs.val != 0 ) {
    10711071                throw SemanticError( "invalid function specifier for ", this );
    10721072        } // if
  • src/Parser/ParseNode.h

    r5a3ac84 r9b443c7f  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 08:10:53 2017
    13 // Update Count     : 726
     12// Last Modified On : Tue Mar 14 16:53:19 2017
     13// Update Count     : 757
    1414//
    1515
     
    1919#include <string>
    2020#include <list>
    21 #include <bitset>
    2221#include <iterator>
    2322#include <memory>
     
    204203        // These must remain in the same order as the corresponding DeclarationNode names.
    205204
    206         enum StorageClass { Extern, Static, Auto, Register, Threadlocal, NoStorageClass,
    207                                                 ExternClass = 1 << Extern, StaticClass = 1 << Static, AutoClass = 1 << Auto, RegisterClass = 1 << Register, ThreadlocalClass = 1 << Threadlocal };
    208         enum FuncSpecifier { Inline, Noreturn, Fortran, NoFuncSpecifier,
    209                                                  InlineSpec = 1 << Inline, NoreturnSpec = 1 << Noreturn, FortranSpec = 1 << Fortran };
    210         enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier };
     205        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 };
     206        union StorageClasses {
     207                unsigned int val;
     208                struct {
     209                        bool is_extern : 1;
     210                        bool is_static : 1;
     211                        bool is_auto : 1;
     212                        bool is_register : 1;
     213                        bool is_threadlocal : 1;
     214                };
     215                StorageClasses() : val( 0 ) {}
     216                StorageClasses( unsigned int val ) : val( val ) {}
     217                bool operator[]( unsigned int i ) const { return val & (1 << i); }
     218        }; // StorageClasses
     219
     220        enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 };
     221        union FuncSpecifiers {
     222                unsigned int val;
     223                struct {
     224                        bool is_inline : 1;
     225                        bool is_noreturn : 1;
     226                        bool is_fortran : 1;
     227                };
     228                FuncSpecifiers() : val( 0 ) {}
     229                FuncSpecifiers( unsigned int val ) : val( val ) {}
     230                bool operator[]( unsigned int i ) const { return val & (1 << i); }
     231        }; // FuncSpecifiers
     232
     233        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NoTypeQualifier = 6 };
     234        union TypeQualifiers {
     235                unsigned int val;
     236                struct {
     237                        bool is_const : 1;
     238                        bool is_restrict : 1;
     239                        bool is_volatile : 1;
     240                        bool is_lvalue : 1;
     241                        bool is_mutex : 1;
     242                        bool is_atomic : 1;
     243                };
     244                TypeQualifiers() : val( 0 ) {}
     245                TypeQualifiers( unsigned int val ) : val( val ) {}
     246                bool operator[]( unsigned int i ) const { return val & (1 << i); }
     247        }; // TypeQualifiers
     248
    211249        enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType };
    212250        enum ComplexType { Complex, Imaginary, NoComplexType };
     
    228266        static const char * builtinTypeNames[];
    229267
    230         static DeclarationNode * newStorageClass( StorageClass );
    231         static DeclarationNode * newFuncSpecifier( FuncSpecifier );
    232         static DeclarationNode * newTypeQualifier( TypeQualifier );
     268        static DeclarationNode * newStorageClass( StorageClasses );
     269        static DeclarationNode * newFuncSpecifier( FuncSpecifiers );
     270        static DeclarationNode * newTypeQualifier( TypeQualifiers );
    233271        static DeclarationNode * newBasicType( BasicType );
    234272        static DeclarationNode * newComplexType( ComplexType );
     
    326364        TypeData * type;
    327365
    328         typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses;
    329366        StorageClasses storageClasses;
    330367        static void print_StorageClass( std::ostream & output, StorageClasses storageClasses );
    331368
    332         typedef std::bitset< DeclarationNode::NoFuncSpecifier > FuncSpecifiers;
    333369        FuncSpecifiers funcSpecs;
    334370        static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs );
  • src/Parser/TypeData.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 08:08:21 2017
    13 // Update Count     : 538
     12// Last Modified On : Tue Mar 14 15:01:44 2017
     13// Update Count     : 548
    1414//
    1515
     
    2626using namespace std;
    2727
    28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {
     28TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ {
    2929        switch ( kind ) {
    3030          case Unknown:
     
    5050                function.newStyle = false;
    5151                break;
     52                // Enum is an Aggregate, so both structures are initialized together.
     53          case Enum:
     54                // enumeration = new Enumeration_t;
     55                enumeration.name = nullptr;
     56                enumeration.constants = nullptr;
     57                enumeration.body = false;
    5258          case Aggregate:
    5359                // aggregate = new Aggregate_t;
     
    6369                aggInst.params = nullptr;
    6470                aggInst.hoistType = false;;
    65                 break;
    66           case Enum:
    67                 // enumeration = new Enumeration_t;
    68                 enumeration.name = nullptr;
    69                 enumeration.constants = nullptr;
    70                 enumeration.body = false;
    7171                break;
    7272          case Symbolic:
     
    494494Type::Qualifiers buildQualifiers( const TypeData * td ) {
    495495        Type::Qualifiers q;
    496         q.isConst = td->typeQualifiers[ DeclarationNode::Const ];
    497         q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ];
    498         q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ];
    499         q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ];
    500         q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];;
     496        q.isConst = td->typeQualifiers.is_const;
     497        q.isVolatile = td->typeQualifiers.is_volatile;
     498        q.isRestrict = td->typeQualifiers.is_restrict;
     499        q.isLvalue = td->typeQualifiers.is_lvalue;
     500        q.isAtomic = td->typeQualifiers.is_atomic;
    501501        return q;
    502502} // buildQualifiers
  • src/Parser/TypeData.h

    r5a3ac84 r9b443c7f  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  8 22:28:33 2017
    13 // Update Count     : 174
     12// Last Modified On : Tue Mar 14 16:51:26 2017
     13// Update Count     : 181
    1414//
    1515
    1616#ifndef TYPEDATA_H
    1717#define TYPEDATA_H
    18 
    19 #include <bitset>
    2018
    2119#include "ParseNode.h"
     
    7775        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
    7876
    79         typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers;
    80         TypeQualifiers typeQualifiers;
     77        DeclarationNode::TypeQualifiers typeQualifiers;
    8178        DeclarationNode * forall;
    8279
  • src/SymTab/Autogen.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:42:44 2017
    13 // Update Count     : 51
     12// Last Modified On : Tue Mar 14 07:45:00 2017
     13// Update Count     : 54
    1414//
    1515
     
    162162                // because each unit generates copies of the default routines for each aggregate.
    163163//              DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static;
    164                 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass );
     164                DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static );
    165165                LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen;
    166166                FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ),
    167                                                                                                 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) );
     167                                                                                                std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) );
    168168                decl->fixUniqueId();
    169169                return decl;
     
    720720                                        TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl );
    721721                                        newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,
    722                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     722                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
    723723                                        newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
    724                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     724                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
    725725                                        newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,
    726                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     726                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
    727727                                        newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
    728                                                                                                                                                    std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     728                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) );
    729729                                        typeParams.push_back( newDecl );
    730730                                        done.insert( ty->get_baseType() );
  • src/SymTab/Autogen.h

    r5a3ac84 r9b443c7f  
    5858                        assert( type );
    5959                        Type * castType = type->clone();
    60                         castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true);
     60                        castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
    6161                        castType->set_isLvalue( true ); // xxx - might not need this
    6262                        dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
  • src/SymTab/Indexer.cc

    r5a3ac84 r9b443c7f  
    1010// Created On       : Sun May 17 21:37:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:45:32 2017
    13 // Update Count     : 16
     12// Last Modified On : Tue Mar 14 08:07:34 2017
     13// Update Count     : 17
    1414//
    1515
     
    738738                                ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added );
    739739                                ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing );
    740                                 if ( ! newobj->get_storageClasses()[ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ] ) {
     740                                if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) {
    741741                                        throw SemanticError( "duplicate object definition for ", added );
    742742                                } // if
  • src/SymTab/Validate.cc

    r5a3ac84 r9b443c7f  
    323323                        ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i );
    324324                        assert( obj );
    325                         obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) );
     325                        obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) );
    326326                } // for
    327327                Parent::visit( enumDecl );
  • src/SynTree/Type.h

    r5a3ac84 r9b443c7f  
    2525  public:
    2626        struct Qualifiers {
    27                 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}
    28                 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {}
     27                Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {}
     28                Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {}
    2929
    3030                Qualifiers &operator&=( const Qualifiers &other );
     
    4545                bool isLvalue;
    4646                bool isAtomic;
     47                bool isMutex;
    4748        };
    4849
     
    511512        isLvalue &= other.isLvalue;
    512513        isAtomic &= other.isAtomic;
     514        isMutex &= other.isMutex;
    513515        return *this;
    514516}
     
    520522        isLvalue |= other.isLvalue;
    521523        isAtomic |= other.isAtomic;
     524        isMutex |= other.isMutex;
    522525        return *this;
    523526}
     
    528531        if ( other.isRestrict ) isRestrict = 0;
    529532        if ( other.isAtomic ) isAtomic = 0;
     533        if ( other.isMutex ) isMutex = 0;
    530534        return *this;
    531535}
  • src/Tuples/TupleAssignment.cc

    r5a3ac84 r9b443c7f  
    199199                                Type * type = InitTweak::getPointerBase( castType );
    200200                                assert( type );
    201                                 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true);
     201                                type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
    202202                                type->set_isLvalue( true ); // xxx - might not need this
    203203                                expr = new CastExpr( expr, castType );
  • src/Tuples/TupleExpansion.cc

    r5a3ac84 r9b443c7f  
    305305        Type * makeTupleType( const std::list< Expression * > & exprs ) {
    306306                // produce the TupleType which aggregates the types of the exprs
    307                 TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true) );
     307                TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) );
    308308                Type::Qualifiers &qualifiers = tupleType->get_qualifiers();
    309309                for ( Expression * expr : exprs ) {
  • src/benchmark/CorCtxSwitch.c

    r5a3ac84 r9b443c7f  
    11#include <fstream>
    22#include <stdlib>
    3 #include <threads>
     3#include <thread>
    44
    55#include <unistd.h>                                     // sysconf
     
    2424
    2525struct GreatSuspender {
    26         coroutine c;
     26        coroutine_desc c;
    2727};
    2828
  • src/benchmark/ThrdCtxSwitch.c

    r5a3ac84 r9b443c7f  
    11#include <fstream>
    22#include <stdlib>
    3 #include <threads>
     3#include <thread>
    44
    55#include <unistd.h>                                     // sysconf
  • src/benchmark/bench.c

    r5a3ac84 r9b443c7f  
    22#include <fstream>
    33#include <stdlib>
    4 #include <threads>
     4#include <thread>
    55
    66#include <unistd.h>                                     // sysconf
     
    8686//=======================================
    8787
    88 struct CoroutineDummy { coroutine c; };
     88struct CoroutineDummy { coroutine_desc c; };
    8989DECL_COROUTINE(CoroutineDummy);
    9090void main(CoroutineDummy * this) {}
     
    119119struct CoroutineResume {
    120120    int N;
    121     coroutine c;
     121    coroutine_desc c;
    122122};
    123123
     
    150150//=======================================
    151151
    152 struct ThreadDummy { thread t; };
     152struct ThreadDummy { thread_desc t; };
    153153DECL_THREAD(ThreadDummy);
    154154void main(ThreadDummy * this) {}
     
    180180    int N;
    181181    long long result;
    182     thread t;
     182    thread_desc t;
    183183};
    184184
  • src/benchmark/csv-data.c

    r5a3ac84 r9b443c7f  
    11#include <fstream>
    22#include <stdlib>
    3 #include <threads>
     3#include <thread>
    44
    55extern "C" {
     
    2626
    2727struct GreatSuspender {
    28         coroutine c;
     28        coroutine_desc c;
    2929};
    3030
  • src/examples/multicore.c

    r5a3ac84 r9b443c7f  
    11#include <kernel>
    2 #include <threads>
     2#include <thread>
    33
    4 struct MyThread { thread t; };
     4struct MyThread { thread_desc t; };
    55
    66DECL_THREAD(MyThread);
  • src/libcfa/Makefile.am

    r5a3ac84 r9b443c7f  
    4545# not all platforms support concurrency, add option do disable it
    4646if BUILD_CONCURRENCY
    47 headers += containers/vector concurrency/coroutines concurrency/threads concurrency/kernel concurrency/monitor
     47headers += containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor
    4848endif
    4949
  • src/libcfa/Makefile.in

    r5a3ac84 r9b443c7f  
    4343
    4444# not all platforms support concurrency, add option do disable it
    45 @BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutines concurrency/threads concurrency/kernel concurrency/monitor
     45@BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor
    4646
    4747# not all platforms support concurrency, add option do disable it
     
    9999am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c \
    100100        math.c iostream.c fstream.c iterator.c rational.c assert.c \
    101         containers/vector.c concurrency/coroutines.c \
    102         concurrency/threads.c concurrency/kernel.c \
     101        containers/vector.c concurrency/coroutine.c \
     102        concurrency/thread.c concurrency/kernel.c \
    103103        concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    104104        concurrency/invoke.c
    105105am__dirstamp = $(am__leading_dot)dirstamp
    106106@BUILD_CONCURRENCY_TRUE@am__objects_1 = containers/libcfa_d_a-vector.$(OBJEXT) \
    107 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-coroutines.$(OBJEXT) \
    108 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-threads.$(OBJEXT) \
     107@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
     108@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-thread.$(OBJEXT) \
    109109@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-kernel.$(OBJEXT) \
    110110@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-monitor.$(OBJEXT)
     
    124124am__libcfa_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c math.c \
    125125        iostream.c fstream.c iterator.c rational.c assert.c \
    126         containers/vector.c concurrency/coroutines.c \
    127         concurrency/threads.c concurrency/kernel.c \
     126        containers/vector.c concurrency/coroutine.c \
     127        concurrency/thread.c concurrency/kernel.c \
    128128        concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \
    129129        concurrency/invoke.c
    130130@BUILD_CONCURRENCY_TRUE@am__objects_5 =  \
    131131@BUILD_CONCURRENCY_TRUE@        containers/libcfa_a-vector.$(OBJEXT) \
    132 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-coroutines.$(OBJEXT) \
    133 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-threads.$(OBJEXT) \
     132@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-coroutine.$(OBJEXT) \
     133@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
    134134@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-kernel.$(OBJEXT) \
    135135@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-monitor.$(OBJEXT)
     
    175175am__nobase_cfa_include_HEADERS_DIST = limits stdlib math iostream \
    176176        fstream iterator rational assert containers/vector \
    177         concurrency/coroutines concurrency/threads concurrency/kernel \
     177        concurrency/coroutine concurrency/thread concurrency/kernel \
    178178        concurrency/monitor ${shell echo stdhdr/*} \
    179179        concurrency/invoke.h
     
    397397        @$(MKDIR_P) concurrency/$(DEPDIR)
    398398        @: > concurrency/$(DEPDIR)/$(am__dirstamp)
    399 concurrency/libcfa_d_a-coroutines.$(OBJEXT):  \
     399concurrency/libcfa_d_a-coroutine.$(OBJEXT):  \
    400400        concurrency/$(am__dirstamp) \
    401401        concurrency/$(DEPDIR)/$(am__dirstamp)
    402 concurrency/libcfa_d_a-threads.$(OBJEXT): concurrency/$(am__dirstamp) \
     402concurrency/libcfa_d_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \
    403403        concurrency/$(DEPDIR)/$(am__dirstamp)
    404404concurrency/libcfa_d_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \
     
    417417containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \
    418418        containers/$(DEPDIR)/$(am__dirstamp)
    419 concurrency/libcfa_a-coroutines.$(OBJEXT):  \
    420         concurrency/$(am__dirstamp) \
     419concurrency/libcfa_a-coroutine.$(OBJEXT): concurrency/$(am__dirstamp) \
    421420        concurrency/$(DEPDIR)/$(am__dirstamp)
    422 concurrency/libcfa_a-threads.$(OBJEXT): concurrency/$(am__dirstamp) \
     421concurrency/libcfa_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \
    423422        concurrency/$(DEPDIR)/$(am__dirstamp)
    424423concurrency/libcfa_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \
     
    436435        -rm -f *.$(OBJEXT)
    437436        -rm -f concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT)
    438         -rm -f concurrency/libcfa_a-coroutines.$(OBJEXT)
     437        -rm -f concurrency/libcfa_a-coroutine.$(OBJEXT)
    439438        -rm -f concurrency/libcfa_a-invoke.$(OBJEXT)
    440439        -rm -f concurrency/libcfa_a-kernel.$(OBJEXT)
    441440        -rm -f concurrency/libcfa_a-monitor.$(OBJEXT)
    442         -rm -f concurrency/libcfa_a-threads.$(OBJEXT)
    443         -rm -f concurrency/libcfa_d_a-coroutines.$(OBJEXT)
     441        -rm -f concurrency/libcfa_a-thread.$(OBJEXT)
     442        -rm -f concurrency/libcfa_d_a-coroutine.$(OBJEXT)
    444443        -rm -f concurrency/libcfa_d_a-invoke.$(OBJEXT)
    445444        -rm -f concurrency/libcfa_d_a-kernel.$(OBJEXT)
    446445        -rm -f concurrency/libcfa_d_a-monitor.$(OBJEXT)
    447         -rm -f concurrency/libcfa_d_a-threads.$(OBJEXT)
     446        -rm -f concurrency/libcfa_d_a-thread.$(OBJEXT)
    448447        -rm -f containers/libcfa_a-vector.$(OBJEXT)
    449448        -rm -f containers/libcfa_d_a-vector.$(OBJEXT)
     
    471470@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@
    472471@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@MACHINE_TYPE@.Po@am__quote@
    473 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutines.Po@am__quote@
     472@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine.Po@am__quote@
    474473@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-invoke.Po@am__quote@
    475474@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@
    476475@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@
    477 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-threads.Po@am__quote@
    478 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po@am__quote@
     476@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@
     477@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po@am__quote@
    479478@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-invoke.Po@am__quote@
    480479@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@
    481480@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-monitor.Po@am__quote@
    482 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-threads.Po@am__quote@
     481@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@
    483482@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-vector.Po@am__quote@
    484483@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-vector.Po@am__quote@
     
    649648@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi`
    650649
    651 concurrency/libcfa_d_a-coroutines.o: concurrency/coroutines.c
    652 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutines.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo -c -o concurrency/libcfa_d_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c
    653 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po
    654 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutines.c' object='concurrency/libcfa_d_a-coroutines.o' libtool=no @AMDEPBACKSLASH@
    655 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    656 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c
    657 
    658 concurrency/libcfa_d_a-coroutines.obj: concurrency/coroutines.c
    659 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutines.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo -c -o concurrency/libcfa_d_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`
    660 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po
    661 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutines.c' object='concurrency/libcfa_d_a-coroutines.obj' libtool=no @AMDEPBACKSLASH@
    662 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    663 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`
    664 
    665 concurrency/libcfa_d_a-threads.o: concurrency/threads.c
    666 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-threads.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo -c -o concurrency/libcfa_d_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c
    667 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo concurrency/$(DEPDIR)/libcfa_d_a-threads.Po
    668 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/threads.c' object='concurrency/libcfa_d_a-threads.o' libtool=no @AMDEPBACKSLASH@
    669 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    670 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c
    671 
    672 concurrency/libcfa_d_a-threads.obj: concurrency/threads.c
    673 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-threads.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo -c -o concurrency/libcfa_d_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`
    674 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo concurrency/$(DEPDIR)/libcfa_d_a-threads.Po
    675 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/threads.c' object='concurrency/libcfa_d_a-threads.obj' libtool=no @AMDEPBACKSLASH@
    676 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    677 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`
     650concurrency/libcfa_d_a-coroutine.o: concurrency/coroutine.c
     651@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo -c -o concurrency/libcfa_d_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c
     652@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po
     653@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_d_a-coroutine.o' libtool=no @AMDEPBACKSLASH@
     654@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     655@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c
     656
     657concurrency/libcfa_d_a-coroutine.obj: concurrency/coroutine.c
     658@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo -c -o concurrency/libcfa_d_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi`
     659@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po
     660@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_d_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@
     661@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     662@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi`
     663
     664concurrency/libcfa_d_a-thread.o: concurrency/thread.c
     665@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo -c -o concurrency/libcfa_d_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c
     666@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_d_a-thread.Po
     667@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_d_a-thread.o' libtool=no @AMDEPBACKSLASH@
     668@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     669@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c
     670
     671concurrency/libcfa_d_a-thread.obj: concurrency/thread.c
     672@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo -c -o concurrency/libcfa_d_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi`
     673@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_d_a-thread.Po
     674@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_d_a-thread.obj' libtool=no @AMDEPBACKSLASH@
     675@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     676@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi`
    678677
    679678concurrency/libcfa_d_a-kernel.o: concurrency/kernel.c
     
    845844@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi`
    846845
    847 concurrency/libcfa_a-coroutines.o: concurrency/coroutines.c
    848 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutines.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo -c -o concurrency/libcfa_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c
    849 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutines.Po
    850 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutines.c' object='concurrency/libcfa_a-coroutines.o' libtool=no @AMDEPBACKSLASH@
    851 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    852 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c
    853 
    854 concurrency/libcfa_a-coroutines.obj: concurrency/coroutines.c
    855 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutines.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo -c -o concurrency/libcfa_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`
    856 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutines.Po
    857 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutines.c' object='concurrency/libcfa_a-coroutines.obj' libtool=no @AMDEPBACKSLASH@
    858 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    859 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`
    860 
    861 concurrency/libcfa_a-threads.o: concurrency/threads.c
    862 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-threads.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-threads.Tpo -c -o concurrency/libcfa_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c
    863 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-threads.Tpo concurrency/$(DEPDIR)/libcfa_a-threads.Po
    864 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/threads.c' object='concurrency/libcfa_a-threads.o' libtool=no @AMDEPBACKSLASH@
    865 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    866 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c
    867 
    868 concurrency/libcfa_a-threads.obj: concurrency/threads.c
    869 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-threads.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-threads.Tpo -c -o concurrency/libcfa_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`
    870 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-threads.Tpo concurrency/$(DEPDIR)/libcfa_a-threads.Po
    871 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/threads.c' object='concurrency/libcfa_a-threads.obj' libtool=no @AMDEPBACKSLASH@
    872 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    873 @am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`
     846concurrency/libcfa_a-coroutine.o: concurrency/coroutine.c
     847@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c
     848@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po
     849@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.o' libtool=no @AMDEPBACKSLASH@
     850@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     851@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c
     852
     853concurrency/libcfa_a-coroutine.obj: concurrency/coroutine.c
     854@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi`
     855@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po
     856@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@
     857@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     858@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi`
     859
     860concurrency/libcfa_a-thread.o: concurrency/thread.c
     861@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c
     862@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po
     863@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.o' libtool=no @AMDEPBACKSLASH@
     864@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     865@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c
     866
     867concurrency/libcfa_a-thread.obj: concurrency/thread.c
     868@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi`
     869@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po
     870@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.obj' libtool=no @AMDEPBACKSLASH@
     871@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     872@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi`
    874873
    875874concurrency/libcfa_a-kernel.o: concurrency/kernel.c
  • src/libcfa/concurrency/coroutine

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // coroutines --
     8// coroutine --
    99//
    1010// Author           : Thierry Delisle
     
    2727trait is_coroutine(dtype T) {
    2828      void main(T * this);
    29       coroutine * get_coroutine(T * this);
     29      coroutine_desc * get_coroutine(T * this);
    3030};
    3131
    32 #define DECL_COROUTINE(X) static inline coroutine* get_coroutine(X* this) { return &this->c; } void main(X* this)
     32#define DECL_COROUTINE(X) static inline coroutine_desc* get_coroutine(X* this) { return &this->c; } void main(X* this)
    3333
    3434//-----------------------------------------------------------------------------
    3535// Ctors and dtors
    3636void ?{}(coStack_t * this);
    37 void ?{}(coroutine * this);
    38 void ?{}(coroutine * this, const char * name);
     37void ?{}(coroutine_desc * this);
     38void ?{}(coroutine_desc * this, const char * name);
    3939void ^?{}(coStack_t * this);
    40 void ^?{}(coroutine * this);
     40void ^?{}(coroutine_desc * this);
    4141
    4242//-----------------------------------------------------------------------------
     
    6363
    6464// Get current coroutine
    65 coroutine * this_coroutine(void);
     65coroutine_desc * this_coroutine(void);
    6666
    6767// Private wrappers for context switch and stack creation
    68 extern void CoroutineCtxSwitch(coroutine * src, coroutine * dst);
     68extern void CoroutineCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    6969extern void create_stack( coStack_t * this, unsigned int storageSize );
    7070
    7171// Suspend implementation inlined for performance
    7272static inline void suspend() {
    73       coroutine * src = this_coroutine();               // optimization
     73      coroutine_desc * src = this_coroutine();          // optimization
    7474
    7575        assertf( src->last != 0,
     
    8888forall(dtype T | is_coroutine(T))
    8989static inline void resume(T * cor) {
    90         coroutine * src = this_coroutine();             // optimization
    91         coroutine * dst = get_coroutine(cor);
     90        coroutine_desc * src = this_coroutine();                // optimization
     91        coroutine_desc * dst = get_coroutine(cor);
    9292
    9393      if( unlikely(!dst->stack.base) ) {
     
    111111}
    112112
    113 static inline void resume(coroutine * dst) {
    114         coroutine * src = this_coroutine();             // optimization
     113static inline void resume(coroutine_desc * dst) {
     114        coroutine_desc * src = this_coroutine();                // optimization
    115115
    116116      // not resuming self ?
  • src/libcfa/concurrency/coroutine.c

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // coroutines.c --
     8// coroutine.c --
    99//
    1010// Author           : Thierry Delisle
     
    1515//
    1616
    17 #include "coroutines"
     17#include "coroutine"
    1818
    1919extern "C" {
     
    3232#include "invoke.h"
    3333
    34 extern processor * get_this_processor();
     34extern thread_local processor * this_processor;
    3535
    3636//-----------------------------------------------------------------------------
     
    6060}
    6161
    62 void ?{}(coroutine* this) {
     62void ?{}(coroutine_desc* this) {
    6363        this{ "Anonymous Coroutine" };
    6464}
    6565
    66 void ?{}(coroutine* this, const char * name) {
     66void ?{}(coroutine_desc* this, const char * name) {
    6767        this->name = name;
    6868        this->errno_ = 0;
     
    7272}
    7373
    74 void ?{}(coroutine* this, size_t size) {
     74void ?{}(coroutine_desc* this, size_t size) {
    7575        this{};
    7676        (&this->stack){size};
     
    8888}
    8989
    90 void ^?{}(coroutine* this) {}
     90void ^?{}(coroutine_desc* this) {}
    9191
    9292// Part of the Public API
     
    9494forall(dtype T | is_coroutine(T))
    9595void prime(T* cor) {
    96         coroutine* this = get_coroutine(cor);
     96        coroutine_desc* this = get_coroutine(cor);
    9797        assert(this->state == Start);
    9898
     
    102102
    103103// Wrapper for co
    104 void CoroutineCtxSwitch(coroutine* src, coroutine* dst) {
     104void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    105105        // THREAD_GETMEM( This )->disableInterrupts();
    106106
     
    109109
    110110        // set new coroutine that task is executing
    111         get_this_processor()->current_coroutine = dst;                 
     111        this_processor->current_coroutine = dst;
    112112
    113113        // context switch to specified coroutine
  • src/libcfa/concurrency/invoke.c

    r5a3ac84 r9b443c7f  
    2929
    3030extern void __suspend_internal(void);
    31 extern void __thread_signal_termination(struct thread*);
     31extern void __thread_signal_termination(struct thread_desc*);
    3232
    3333void CtxInvokeCoroutine(
    3434      void (*main)(void *),
    35       struct coroutine *(*get_coroutine)(void *),
     35      struct coroutine_desc *(*get_coroutine)(void *),
    3636      void *this
    3737) {
    3838      // LIB_DEBUG_PRINTF("Invoke Coroutine : Received %p (main %p, get_c %p)\n", this, main, get_coroutine);
    3939
    40       struct coroutine* cor = get_coroutine( this );
     40      struct coroutine_desc* cor = get_coroutine( this );
    4141
    4242      if(cor->state == Primed) {
     
    5757void CtxInvokeThread(
    5858      void (*main)(void *),
    59       struct thread *(*get_thread)(void *),
     59      struct thread_desc *(*get_thread)(void *),
    6060      void *this
    6161) {
    6262      __suspend_internal();
    6363
    64       struct thread* thrd = get_thread( this );
    65       struct coroutine* cor = &thrd->c;
     64      struct thread_desc* thrd = get_thread( this );
     65      struct coroutine_desc* cor = &thrd->c;
    6666      cor->state = Active;
    6767
     
    7979void CtxStart(
    8080      void (*main)(void *),
    81       struct coroutine *(*get_coroutine)(void *),
     81      struct coroutine_desc *(*get_coroutine)(void *),
    8282      void *this,
    8383      void (*invoke)(void *)
  • src/libcfa/concurrency/invoke.h

    r5a3ac84 r9b443c7f  
    3535
    3636      struct simple_thread_list {
    37             struct thread * head;
    38             struct thread ** tail;
     37            struct thread_desc * head;
     38            struct thread_desc ** tail;
    3939      };
    4040
     
    4848      extern "Cforall" {
    4949            void ?{}( struct simple_thread_list * );
    50             void append( struct simple_thread_list *, struct thread * );
    51             struct thread * pop_head( struct simple_thread_list * );
     50            void append( struct simple_thread_list *, struct thread_desc * );
     51            struct thread_desc * pop_head( struct simple_thread_list * );
    5252
    5353            void ?{}(spinlock * this);
     
    7171      enum coroutine_state { Halted, Start, Inactive, Active, Primed };
    7272
    73       struct coroutine {
     73      struct coroutine_desc {
    7474            struct coStack_t stack;
    7575            const char *name;                         // textual name for coroutine/task, initialized by uC++ generated code
    7676            int errno_;                               // copy of global UNIX variable errno
    7777            enum coroutine_state state;       // current execution status for coroutine
    78             struct coroutine *starter;        // first coroutine to resume this one
    79             struct coroutine *last;                   // last coroutine to resume this one
     78            struct coroutine_desc *starter;           // first coroutine to resume this one
     79            struct coroutine_desc *last;                      // last coroutine to resume this one
    8080      };
    8181
    82       struct thread {
    83             struct coroutine c;                 // coroutine body used to store context
     82      struct thread_desc {
     83            struct coroutine_desc c;                 // coroutine body used to store context
    8484            struct signal_once terminated;      // indicate if execuation state is not halted
    85             struct thread * next;               // instrusive link field for threads
     85            struct thread_desc * next;               // instrusive link field for threads
    8686      };
    8787
  • src/libcfa/concurrency/kernel

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // threads --
     8// kernel --
    99//
    1010// Author           : Thierry Delisle
     
    4949struct FinishAction {
    5050        FinishOpCode action_code;
    51         thread * thrd;
     51        thread_desc * thrd;
    5252        spinlock * lock;
    5353};
     
    6262        struct processorCtx_t * runner;
    6363        cluster * cltr;
    64         coroutine * current_coroutine;
    65         thread * current_thread;
     64        coroutine_desc * current_coroutine;
     65        thread_desc * current_thread;
    6666        pthread_t kernel_thread;
    6767       
  • src/libcfa/concurrency/kernel.c

    r5a3ac84 r9b443c7f  
    4343KERNEL_STORAGE(cluster, systemCluster);
    4444KERNEL_STORAGE(processor, systemProcessor);
    45 KERNEL_STORAGE(thread, mainThread);
     45KERNEL_STORAGE(thread_desc, mainThread);
    4646KERNEL_STORAGE(machine_context_t, mainThread_context);
    4747
    4848cluster * systemCluster;
    4949processor * systemProcessor;
    50 thread * mainThread;
     50thread_desc * mainThread;
    5151
    5252//-----------------------------------------------------------------------------
     
    5555thread_local processor * this_processor;
    5656
    57 processor * get_this_processor() {
    58         return this_processor;
    59 }
    60 
    61 coroutine * this_coroutine(void) {
     57coroutine_desc * this_coroutine(void) {
    6258        return this_processor->current_coroutine;
    6359}
    6460
    65 thread * this_thread(void) {
     61thread_desc * this_thread(void) {
    6662        return this_processor->current_thread;
    6763}
     
    10399}
    104100
    105 void ?{}( coroutine * this, current_stack_info_t * info) {
     101void ?{}( coroutine_desc * this, current_stack_info_t * info) {
    106102        (&this->stack){ info };
    107103        this->name = "Main Thread";
     
    110106}
    111107
    112 void ?{}( thread * this, current_stack_info_t * info) {
     108void ?{}( thread_desc * this, current_stack_info_t * info) {
    113109        (&this->c){ info };
    114110}
     
    179175        LIB_DEBUG_PRINTF("Kernel : core %p starting\n", this);
    180176
    181         thread * readyThread = NULL;
     177        thread_desc * readyThread = NULL;
    182178        for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    183179        {
     
    206202// runThread runs a thread by context switching
    207203// from the processor coroutine to the target thread
    208 void runThread(processor * this, thread * dst) {
    209         coroutine * proc_cor = get_coroutine(this->runner);
    210         coroutine * thrd_cor = get_coroutine(dst);
     204void runThread(processor * this, thread_desc * dst) {
     205        coroutine_desc * proc_cor = get_coroutine(this->runner);
     206        coroutine_desc * thrd_cor = get_coroutine(dst);
    211207       
    212208        //Reset the terminating actions here
     
    297293//-----------------------------------------------------------------------------
    298294// Scheduler routines
    299 void ScheduleThread( thread * thrd ) {
     295void ScheduleThread( thread_desc * thrd ) {
    300296        assertf( thrd->next == NULL, "Expected null got %p", thrd->next );
    301297       
     
    305301}
    306302
    307 thread * nextThread(cluster * this) {
     303thread_desc * nextThread(cluster * this) {
    308304        lock( &this->lock );
    309         thread * head = pop_head( &this->ready_queue );
     305        thread_desc * head = pop_head( &this->ready_queue );
    310306        unlock( &this->lock );
    311307        return head;
     
    317313
    318314void ScheduleInternal( spinlock * lock ) {
    319         get_this_processor()->finish.action_code = Release;
    320         get_this_processor()->finish.lock = lock;
     315        this_processor->finish.action_code = Release;
     316        this_processor->finish.lock = lock;
    321317        suspend();
    322318}
    323319
    324 void ScheduleInternal( thread * thrd ) {
    325         get_this_processor()->finish.action_code = Schedule;
    326         get_this_processor()->finish.thrd = thrd;
     320void ScheduleInternal( thread_desc * thrd ) {
     321        this_processor->finish.action_code = Schedule;
     322        this_processor->finish.thrd = thrd;
    327323        suspend();
    328324}
    329325
    330 void ScheduleInternal( spinlock * lock, thread * thrd ) {
    331         get_this_processor()->finish.action_code = Release_Schedule;
    332         get_this_processor()->finish.lock = lock;
    333         get_this_processor()->finish.thrd = thrd;
     326void ScheduleInternal( spinlock * lock, thread_desc * thrd ) {
     327        this_processor->finish.action_code = Release_Schedule;
     328        this_processor->finish.lock = lock;
     329        this_processor->finish.thrd = thrd;
    334330        suspend();
    335331}
     
    343339        // SKULLDUGGERY: the mainThread steals the process main thread
    344340        // which will then be scheduled by the systemProcessor normally
    345         mainThread = (thread *)&mainThread_storage;
     341        mainThread = (thread_desc *)&mainThread_storage;
    346342        current_stack_info_t info;
    347343        mainThread{ &info };
     
    440436                this->condition = true;
    441437
    442                 thread * it;
     438                thread_desc * it;
    443439                while( it = pop_head( &this->blocked) ) {
    444440                        ScheduleThread( it );
     
    455451}
    456452
    457 void append( simple_thread_list * this, thread * t ) {
     453void append( simple_thread_list * this, thread_desc * t ) {
    458454        assert(this->tail != NULL);
    459455        *this->tail = t;
     
    461457}
    462458
    463 thread * pop_head( simple_thread_list * this ) {
    464         thread * head = this->head;
     459thread_desc * pop_head( simple_thread_list * this ) {
     460        thread_desc * head = this->head;
    465461        if( head ) {
    466462                this->head = head->next;
  • src/libcfa/concurrency/kernel_private.h

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // threads --
     8// kernel_private.h --
    99//
    1010// Author           : Thierry Delisle
     
    1919
    2020#include "kernel"
    21 #include "threads"
     21#include "thread"
    2222
    2323//-----------------------------------------------------------------------------
    2424// Scheduler
    25 void ScheduleThread( thread * );
    26 thread * nextThread(cluster * this);
     25void ScheduleThread( thread_desc * );
     26thread_desc * nextThread(cluster * this);
    2727
    2828void ScheduleInternal();
    2929void ScheduleInternal(spinlock * lock);
    30 void ScheduleInternal(thread * thrd);
    31 void ScheduleInternal(spinlock * lock, thread * thrd);
     30void ScheduleInternal(thread_desc * thrd);
     31void ScheduleInternal(spinlock * lock, thread_desc * thrd);
    3232
    3333//-----------------------------------------------------------------------------
     
    3535struct processorCtx_t {
    3636        processor * proc;
    37         coroutine c;
     37        coroutine_desc c;
    3838};
    3939
     
    4242void main(processorCtx_t *);
    4343void start(processor * this);
    44 void runThread(processor * this, thread * dst);
     44void runThread(processor * this, thread_desc * dst);
    4545void finishRunning(processor * this);
    4646void spin(processor * this, unsigned int * spin_count);
     
    5353}
    5454
    55 extern void ThreadCtxSwitch(coroutine * src, coroutine * dst);
     55extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst);
    5656
    5757#endif //KERNEL_PRIVATE_H
  • src/libcfa/concurrency/monitor

    r5a3ac84 r9b443c7f  
    2222#include "stdlib"
    2323
    24 struct __monitor_t {
     24struct monitor_desc {
    2525        spinlock lock;
    26         thread * owner;
     26        thread_desc * owner;
    2727        simple_thread_list entry_queue;
    2828        unsigned int recursion;
    2929};
    3030
    31 static inline void ?{}(__monitor_t * this) {
     31static inline void ?{}(monitor_desc * this) {
    3232        this->owner = 0;
    3333        this->recursion = 0;
     
    3535
    3636//Basic entering routine
    37 void enter(__monitor_t *);
    38 void leave(__monitor_t *);
     37void enter(monitor_desc *);
     38void leave(monitor_desc *);
    3939
    4040//Array entering routine
    41 void enter(__monitor_t **, int count);
    42 void leave(__monitor_t **, int count);
     41void enter(monitor_desc **, int count);
     42void leave(monitor_desc **, int count);
    4343
    4444struct monitor_guard_t {
    45         __monitor_t ** m;
     45        monitor_desc ** m;
    4646        int count;
    4747};
    4848
    49 static inline int ?<?(__monitor_t* lhs, __monitor_t* rhs) {
     49static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) {
    5050        return ((intptr_t)lhs) < ((intptr_t)rhs);
    5151}
    5252
    53 static inline void ?{}( monitor_guard_t * this, __monitor_t ** m ) {
     53static inline void ?{}( monitor_guard_t * this, monitor_desc ** m ) {
    5454        this->m = m;
    5555        this->count = 1;
     
    5757}
    5858
    59 static inline void ?{}( monitor_guard_t * this, __monitor_t ** m, int count ) {
     59static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) {
    6060        this->m = m;
    6161        this->count = count;
  • src/libcfa/concurrency/monitor.c

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // __monitor_t.c --
     8// monitor_desc.c --
    99//
    1010// Author           : Thierry Delisle
     
    1919#include "kernel_private.h"
    2020
    21 void enter(__monitor_t * this) {
     21void enter(monitor_desc * this) {
    2222        lock( &this->lock );
    23         thread * thrd = this_thread();
     23        thread_desc * thrd = this_thread();
    2424
    2525        if( !this->owner ) {
     
    4545}
    4646
    47 void leave(__monitor_t * this) {
     47void leave(monitor_desc * this) {
    4848        lock( &this->lock );
    4949
    50         thread * thrd = this_thread();
     50        thread_desc * thrd = this_thread();
    5151        assert( thrd == this->owner );
    5252
     
    5555
    5656        //If we left the last level of recursion it means we are changing who owns the monitor
    57         thread * new_owner = 0;
     57        thread_desc * new_owner = 0;
    5858        if( this->recursion == 0) {
    5959                //Get the next thread in the list
     
    7272}
    7373
    74 void enter(__monitor_t ** monitors, int count) {
     74void enter(monitor_desc ** monitors, int count) {
    7575        for(int i = 0; i < count; i++) {
    7676                // printf("%d\n", i);
     
    7979}
    8080
    81 void leave(__monitor_t ** monitors, int count) {
     81void leave(monitor_desc ** monitors, int count) {
    8282        for(int i = count - 1; i >= 0; i--) {
    8383                // printf("%d\n", i);
  • src/libcfa/concurrency/thread

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // threads --
     8// thread --
    99//
    1010// Author           : Thierry Delisle
     
    2121#include "invoke.h"
    2222
    23 #include "coroutines"
     23#include "coroutine"
    2424
    2525//-----------------------------------------------------------------------------
     
    2929trait is_thread(dtype T) {
    3030      void main(T* this);
    31       thread* get_thread(T* this);
     31      thread_desc* get_thread(T* this);
    3232};
    3333
    34 #define DECL_THREAD(X) thread* get_thread(X* this) { return &this->t; } void main(X* this)
     34#define DECL_THREAD(X) thread_desc* get_thread(X* this) { return &this->t; } void main(X* this)
    3535
    3636forall( dtype T | is_thread(T) )
    37 static inline coroutine* get_coroutine(T* this) {
     37static inline coroutine_desc* get_coroutine(T* this) {
    3838        return &get_thread(this)->c;
    3939}
    4040
    41 static inline coroutine* get_coroutine(thread* this) {
     41static inline coroutine_desc* get_coroutine(thread_desc* this) {
    4242        return &this->c;
    4343}
    4444
    45 thread * this_thread(void);
     45thread_desc * this_thread(void);
    4646
    4747//-----------------------------------------------------------------------------
    4848// Ctors and dtors
    49 void ?{}(thread* this);
    50 void ^?{}(thread* this);
     49void ?{}(thread_desc* this);
     50void ^?{}(thread_desc* this);
    5151
    5252//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/thread.c

    r5a3ac84 r9b443c7f  
    66// file "LICENCE" distributed with Cforall.
    77//
    8 // threads.c --
     8// thread.c --
    99//
    1010// Author           : Thierry Delisle
     
    1515//
    1616
    17 #include "threads"
     17#include "thread"
    1818
    1919#include "kernel_private.h"
     
    2828}
    2929
    30 extern processor * get_this_processor();
     30extern thread_local processor * this_processor;
    3131
    3232//-----------------------------------------------------------------------------
     
    4141// Thread ctors and dtors
    4242
    43 void ?{}(thread* this) {
     43void ?{}(thread_desc* this) {
    4444        (&this->c){};
    4545        this->c.name = "Anonymous Coroutine";
     
    4848}
    4949
    50 void ^?{}(thread* this) {
     50void ^?{}(thread_desc* this) {
    5151        ^(&this->c){};
    5252}
     
    7474forall( dtype T | is_thread(T) )
    7575void start( T* this ) {
    76         coroutine* thrd_c = get_coroutine(this);
    77         thread*  thrd_h = get_thread   (this);
     76        coroutine_desc* thrd_c = get_coroutine(this);
     77        thread_desc*  thrd_h = get_thread   (this);
    7878        thrd_c->last = this_coroutine();
    79         get_this_processor()->current_coroutine = thrd_c;
     79        this_processor->current_coroutine = thrd_c;
    8080
    8181        LIB_DEBUG_PRINTF("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
     
    9494
    9595void yield( void ) {
    96         ScheduleInternal( get_this_processor()->current_thread );
     96        ScheduleInternal( this_processor->current_thread );
    9797}
    9898
    99 void ThreadCtxSwitch(coroutine* src, coroutine* dst) {
     99void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    100100        // set state of current coroutine to inactive
    101101        src->state = Inactive;
     
    107107        // set new coroutine that the processor is executing
    108108        // and context switch to it
    109         get_this_processor()->current_coroutine = dst; 
     109        this_processor->current_coroutine = dst;
    110110        CtxSwitch( src->stack.context, dst->stack.context );
    111         get_this_processor()->current_coroutine = src; 
     111        this_processor->current_coroutine = src;
    112112
    113113        // set state of new coroutine to active
     
    116116}
    117117
    118 // C Helper to signal the termination of a thread
     118// C Helper to signal the termination of a thread_desc
    119119// Used in invoke.c
    120120extern "C" {
    121         void __thread_signal_termination( thread * this ) {
     121        void __thread_signal_termination( thread_desc * this ) {
    122122                this->c.state = Halted;
    123123                LIB_DEBUG_PRINTF("Thread end : %p\n", this);
  • src/main.cc

    r5a3ac84 r9b443c7f  
    3232#include "GenPoly/CopyParams.h"
    3333#include "GenPoly/InstantiateGeneric.h"
     34#include "Concurrency/Keywords.h"
    3435#include "CodeGen/Generate.h"
    3536#include "CodeGen/FixNames.h"
     
    236237                OPTPRINT( "mutate" )
    237238                ControlStruct::mutate( translationUnit );
     239                OPTPRINT( "Concurrency" )
     240                Concurrency::applyKeywords( translationUnit );
    238241                OPTPRINT( "fixNames" )
    239242                CodeGen::fixNames( translationUnit );
  • src/tests/coroutine.c

    r5a3ac84 r9b443c7f  
    11#include <fstream>
    2 #include <coroutines>
     2#include <coroutine>
    33
    44struct Fibonacci {
    55      int fn; // used for communication
    6       coroutine c;
     6      coroutine_desc c;
    77};
    88
     
    1111}
    1212
    13 coroutine* get_coroutine(Fibonacci* this) {
     13coroutine_desc* get_coroutine(Fibonacci* this) {
    1414      return &this->c;
    1515}
     
    4747#ifdef MORE_DEBUG     
    4848      Fibonacci *pf1 = &f1, *pf2 = &f2;
    49       coroutine *cf1 = &f1.c, *cf2 = &f2.c;
     49      coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c;
    5050      covptr_t  *vf1 = vtable(pf1), *vf2 = vtable(pf2);
    51       coroutine *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);
     51      coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);
    5252      Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2);
    5353
  • src/tests/monitor.c

    r5a3ac84 r9b443c7f  
    22#include <kernel>
    33#include <monitor>
    4 #include <threads>
     4#include <thread>
    55
    66struct global_t {
    77        int value;
    8         __monitor_t m;
     8        monitor_desc m;
    99};
    1010
     
    1616
    1717void increment( /*mutex*/ global_t * this ) {
    18         __monitor_t * mon = &this->m;
     18        monitor_desc * mon = &this->m;
    1919        monitor_guard_t g1 = { &mon };
    2020        {
     
    2727}
    2828
    29 struct MyThread { thread t; };
     29struct MyThread { thread_desc t; };
    3030
    3131DECL_THREAD(MyThread);
  • src/tests/multi-monitor.c

    r5a3ac84 r9b443c7f  
    22#include <kernel>
    33#include <monitor>
    4 #include <threads>
     4#include <thread>
    55
    66static int global12, global23, global13;
    77
    8 static __monitor_t m1, m2, m3;
     8static monitor_desc m1, m2, m3;
    99
    10 void increment( /*mutex*/ __monitor_t * p1, /*mutex*/ __monitor_t * p2, int * value ) {
    11         __monitor_t * mons[] = { p1, p2 };
     10void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) {
     11        monitor_desc * mons[] = { p1, p2 };
    1212        monitor_guard_t g = { mons, 2 };
    1313        *value += 1;
     
    1515
    1616struct MyThread {
    17         thread t;
     17        thread_desc t;
    1818        int target;
    1919};
  • src/tests/test.py

    r5a3ac84 r9b443c7f  
    250250parser = argparse.ArgumentParser(description='Script which runs cforall tests')
    251251parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='no')
    252 parser.add_argument('--concurrent', help='Run concurrent tests', type=yes_no, default='no')
     252parser.add_argument('--concurrent', help='Run concurrent tests', type=yes_no, default='yes')
    253253parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
    254254parser.add_argument('--list', help='List all test available', action='store_true')
  • src/tests/thread.c

    r5a3ac84 r9b443c7f  
    22#include <kernel>
    33#include <stdlib>
    4 #include <threads>
     4#include <thread>
    55
    6 struct First { thread t; signal_once* lock; };
    7 struct Second { thread t; signal_once* lock; };
     6struct First { thread_desc t; signal_once* lock; };
     7struct Second { thread_desc t; signal_once* lock; };
    88
    99DECL_THREAD(First);
Note: See TracChangeset for help on using the changeset viewer.