Changeset 10e90cb


Ignore:
Timestamp:
Jun 6, 2017, 2:50:57 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
c6d2e93
Parents:
8ca3a72 (diff), c5ac6d5 (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:/u/cforall/software/cfa/cfa-cc

Location:
src
Files:
3 added
1 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r8ca3a72 r10e90cb  
    267267        }
    268268
    269         void CodeGenerator::visit( TraitDecl * traitDecl ) {}
     269        void CodeGenerator::visit( __attribute__((unused)) TraitDecl * traitDecl ) {}
    270270
    271271        void CodeGenerator::visit( TypedefDecl * typeDecl ) {
     
    328328        }
    329329
    330         void CodeGenerator::visit( ConstructorInit * init ){
     330        void CodeGenerator::visit( __attribute__((unused)) ConstructorInit * init ){
    331331                assertf( ! genC, "ConstructorInit nodes should not reach code generation." );
    332332                // xxx - generate something reasonable for constructor/destructor pairs
     
    962962        }
    963963
    964         void CodeGenerator::visit( NullStmt * nullStmt ) {
     964        void CodeGenerator::visit( __attribute__((unused)) NullStmt * nullStmt ) {
    965965                //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
    966966                output << "/* null statement */ ;";
  • src/CodeTools/TrackLoc.cc

    r8ca3a72 r10e90cb  
    8585                }
    8686
    87                 void postvisit(BaseSyntaxNode * node) {
     87                void postvisit( __attribute__((unused)) BaseSyntaxNode * node ) {
    8888                        parents.pop();
    8989                }
  • src/Common/Assert.cc

    r8ca3a72 r10e90cb  
    2121extern const char * __progname;                                                 // global name of running executable (argv[0])
    2222
    23 #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\""
     23#define CFA_ASSERT_FMT "*CFA assertion error* \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
    2424
    2525// called by macro assert in assert.h
    2626void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    27         fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file );
     27        fprintf( stderr, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    2828        abort();
    2929}
     
    3131// called by macro assertf
    3232void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    33         fprintf( stderr, CFA_ASSERT_FMT ": ", __progname, function, line, file );
     33        fprintf( stderr, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
    3434        va_list args;
    3535        va_start( args, fmt );
  • src/Common/PassVisitor.h

    r8ca3a72 r10e90cb  
    231231        std::list< Statement* > *       get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); }
    232232        std::list< Statement* > *       get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); }
     233        bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); }
    233234};
    234235
  • src/Common/PassVisitor.impl.h

    r8ca3a72 r10e90cb  
    33#define VISIT_START( node )  \
    44        call_previsit( node ); \
    5 
    6 #define VISIT_END( node )                \
     5        if( visit_children() ) { \
     6
     7#define VISIT_END( node )            \
     8        }                              \
    79        return call_postvisit( node ); \
    810
    911#define MUTATE_START( node )  \
    1012        call_premutate( node ); \
     13        if( visit_children() ) { \
    1114
    1215#define MUTATE_END( type, node )                \
     16        }                                         \
    1317        return call_postmutate< type * >( node ); \
    1418
  • src/Common/PassVisitor.proto.h

    r8ca3a72 r10e90cb  
    2323
    2424template<typename pass_type, typename node_type>
    25 static inline void previsit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {}
     25static inline void previsit_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) node_type * node, __attribute__((unused)) long unused ) {}
    2626
    2727
     
    3232
    3333template<typename pass_type, typename node_type>
    34 static inline void postvisit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {}
     34static inline void postvisit_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) node_type * node, __attribute__((unused)) long unused ) {}
    3535
    3636// Mutate
     
    4141
    4242template<typename pass_type, typename node_type>
    43 static inline void premutate_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {}
     43static inline void premutate_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) node_type * node, __attribute__((unused)) long unused ) {}
    4444
    4545
     
    7171
    7272// Fields
    73 #define FIELD_PTR( type, name )                                                                                                                  \
    74 template<typename pass_type>                                                                                                                     \
    75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) ->decltype( &pass.name ) { return &pass.name; }          \
    76                                                                                                                                                  \
    77 template<typename pass_type>                                                                                                                     \
     73#define FIELD_PTR( type, name )                                                                                                        \
     74template<typename pass_type>                                                                                                           \
     75static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) ->decltype( &pass.name ) { return &pass.name; }  \
     76                                                                                                                                       \
     77template<typename pass_type>                                                                                                           \
    7878static inline type * name##_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) long unused ) { return nullptr;}    \
    7979
     
    8181FIELD_PTR( std::list< Statement* >, stmtsToAddBefore )
    8282FIELD_PTR( std::list< Statement* >, stmtsToAddAfter  )
     83FIELD_PTR( bool, skip_children )
  • src/Concurrency/Keywords.cc

    r8ca3a72 r10e90cb  
    6565                FunctionDecl * forwardDeclare( StructDecl * );
    6666                ObjectDecl * addField( StructDecl * );
    67                 void addRoutines( StructDecl *, ObjectDecl *, FunctionDecl * );
     67                void addRoutines( ObjectDecl *, FunctionDecl * );
    6868
    6969                virtual bool is_target( StructDecl * decl ) = 0;
     
    247247        void ConcurrentSueKeyword::visit(StructDecl * decl) {
    248248                Visitor::visit(decl);
    249                 if( decl->get_name() == type_name ) {
     249                if( decl->get_name() == type_name && decl->has_body() ) {
    250250                        assert( !type_decl );
    251251                        type_decl = decl;
     
    264264                FunctionDecl * func = forwardDeclare( decl );
    265265                ObjectDecl * field = addField( decl );
    266                 addRoutines( decl, field, func );
     266                addRoutines( field, func );
    267267        }
    268268
     
    359359        }
    360360
    361         void ConcurrentSueKeyword::addRoutines( StructDecl * decl, ObjectDecl * field, FunctionDecl * func ) {
     361        void ConcurrentSueKeyword::addRoutines( ObjectDecl * field, FunctionDecl * func ) {
    362362                CompoundStmt * statement = new CompoundStmt( noLabels );
    363363                statement->push_back(
  • src/GenPoly/Box.cc

    r8ca3a72 r10e90cb  
    101101                        void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    102102                        /// wraps a function application with a new temporary for the out-parameter return value
    103                         Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg );
     103                        Expression *addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg );
    104104                        /// Replaces all the type parameters of a generic type with their concrete equivalents under the current environment
    105105                        void replaceParametersWithConcrete( ApplicationExpr *appExpr, std::list< Expression* >& params );
     
    134134                  public:
    135135                        template< typename DeclClass >
    136                         DeclClass *handleDecl( DeclClass *decl, Type *type );
     136                        DeclClass *handleDecl( DeclClass *decl );
    137137                        template< typename AggDecl >
    138138                        AggDecl * handleAggDecl( AggDecl * aggDecl );
     
    663663                }
    664664
    665                 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ) {
     665                Expression *Pass1::addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg ) {
    666666                        // Create temporary to hold return value of polymorphic function and produce that temporary as a result
    667667                        // using a comma expression.
     
    730730                        Type *concrete = replaceWithConcrete( appExpr, dynType );
    731731                        // add out-parameter for return value
    732                         return addRetParam( appExpr, function, concrete, arg );
     732                        return addRetParam( appExpr, concrete, arg );
    733733                }
    734734
     
    737737//                      if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
    738738                        if ( isDynRet( function, tyVars ) ) {
    739                                 ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg );
     739                                ret = addRetParam( appExpr, function->get_returnVals().front()->get_type(), arg );
    740740                        } // if
    741741                        std::string mangleName = mangleAdapterName( function, tyVars );
     
    12801280
    12811281                template< typename DeclClass >
    1282                 DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) {
     1282                DeclClass * Pass2::handleDecl( DeclClass *decl ) {
    12831283                        DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) );
    12841284
     
    12941294
    12951295                DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) {
    1296                         functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl, functionDecl->get_functionType() ) );
     1296                        functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl ) );
    12971297                        FunctionType * ftype = functionDecl->get_functionType();
    12981298                        if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) {
     
    13191319
    13201320                ObjectDecl * Pass2::mutate( ObjectDecl *objectDecl ) {
    1321                         return handleDecl( objectDecl, objectDecl->get_type() );
     1321                        return handleDecl( objectDecl );
    13221322                }
    13231323
     
    13421342                        addToTyVarMap( typeDecl, scopeTyVars );
    13431343                        if ( typeDecl->get_base() ) {
    1344                                 return handleDecl( typeDecl, typeDecl->get_base() );
     1344                                return handleDecl( typeDecl );
    13451345                        } else {
    13461346                                return Parent::mutate( typeDecl );
     
    13491349
    13501350                TypedefDecl * Pass2::mutate( TypedefDecl *typedefDecl ) {
    1351                         return handleDecl( typedefDecl, typedefDecl->get_base() );
     1351                        return handleDecl( typedefDecl );
    13521352                }
    13531353
  • src/InitTweak/FixGlobalInit.cc

    r8ca3a72 r10e90cb  
    125125
    126126        // only modify global variables
    127         void GlobalFixer::visit( FunctionDecl *functionDecl ) {}
    128         void GlobalFixer::visit( StructDecl *aggregateDecl ) {}
    129         void GlobalFixer::visit( UnionDecl *aggregateDecl ) {}
    130         void GlobalFixer::visit( EnumDecl *aggregateDecl ) {}
    131         void GlobalFixer::visit( TraitDecl *aggregateDecl ) {}
    132         void GlobalFixer::visit( TypeDecl *typeDecl ) {}
     127        void GlobalFixer::visit( __attribute__((unused)) FunctionDecl *functionDecl ) {}
     128        void GlobalFixer::visit( __attribute__((unused)) StructDecl *aggregateDecl ) {}
     129        void GlobalFixer::visit( __attribute__((unused)) UnionDecl *aggregateDecl ) {}
     130        void GlobalFixer::visit( __attribute__((unused)) EnumDecl *aggregateDecl ) {}
     131        void GlobalFixer::visit( __attribute__((unused)) TraitDecl *aggregateDecl ) {}
     132        void GlobalFixer::visit( __attribute__((unused)) TypeDecl *typeDecl ) {}
    133133
    134134} // namespace InitTweak
  • src/InitTweak/FixInit.cc

    r8ca3a72 r10e90cb  
    110110
    111111                        // don't go into other functions
    112                         virtual void visit( FunctionDecl *decl ) override {}
     112                        virtual void visit( __attribute__((unused)) FunctionDecl *decl ) override {}
    113113
    114114                  protected:
  • src/InitTweak/InitTweak.cc

    r8ca3a72 r10e90cb  
    9292                InitImpl( Initializer * init ) : init( init ) {}
    9393
    94                 virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     94                virtual std::list< Expression * > next( __attribute((unused)) std::list< Expression * > & indices ) {
    9595                        // this is wrong, but just a placeholder for now
    9696                        // if ( ! flattened ) flatten( indices );
     
    248248        }
    249249
    250         Statement * ExprImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) {
     250        Statement * ExprImpl::buildListInit( __attribute((unused)) UntypedExpr * dst, __attribute((unused)) std::list< Expression * > & indices ) {
    251251                return NULL;
    252252        }
     
    475475                ConstExprChecker() : isConstExpr( true ) {}
    476476
    477                 virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }
    478                 virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; }
     477                virtual void visit( __attribute((unused)) ApplicationExpr *applicationExpr ) { isConstExpr = false; }
     478                virtual void visit( __attribute((unused)) UntypedExpr *untypedExpr ) { isConstExpr = false; }
    479479                virtual void visit( NameExpr *nameExpr ) {
    480480                        // xxx - temporary hack, because 0 and 1 really should be constexprs, even though they technically aren't in Cforall today
     
    487487                        if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false;
    488488                }
    489                 virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
    490                 virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
    491                 virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }
    492                 virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }
     489                virtual void visit( __attribute((unused)) LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
     490                virtual void visit( __attribute((unused)) UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
     491                virtual void visit( __attribute((unused)) MemberExpr *memberExpr ) { isConstExpr = false; }
     492                virtual void visit( __attribute((unused)) VariableExpr *variableExpr ) { isConstExpr = false; }
    493493                // these might be okay?
    494494                // virtual void visit( SizeofExpr *sizeofExpr );
     
    501501                // virtual void visit( LogicalExpr *logicalExpr );
    502502                // virtual void visit( ConditionalExpr *conditionalExpr );
    503                 virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; }
    504                 virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; }
    505                 virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; }
    506                 virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
    507                 virtual void visit( UntypedTupleExpr *tupleExpr ) { isConstExpr = false; }
    508                 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }
    509                 virtual void visit( TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
     503                virtual void visit( __attribute((unused)) TypeExpr *typeExpr ) { isConstExpr = false; }
     504                virtual void visit( __attribute((unused)) AsmExpr *asmExpr ) { isConstExpr = false; }
     505                virtual void visit( __attribute((unused)) UntypedValofExpr *valofExpr ) { isConstExpr = false; }
     506                virtual void visit( __attribute((unused)) CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }
     507                virtual void visit( __attribute((unused)) UntypedTupleExpr *tupleExpr ) { isConstExpr = false; }
     508                virtual void visit( __attribute((unused)) TupleExpr *tupleExpr ) { isConstExpr = false; }
     509                virtual void visit( __attribute((unused)) TupleAssignExpr *tupleExpr ) { isConstExpr = false; }
    510510
    511511                bool isConstExpr;
  • src/Parser/ParseNode.h

    r8ca3a72 r10e90cb  
    6161        }
    6262
    63         virtual void print( std::ostream &os, int indent = 0 ) const {}
    64         virtual void printList( std::ostream &os, int indent = 0 ) const {}
     63        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
     64        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    6565
    6666        static int indent_by;
     
    113113        ExpressionNode * set_extension( bool exten ) { extension = exten; return this; }
    114114
    115         virtual void print( std::ostream &os, int indent = 0 ) const override {}
    116         void printOneLine( std::ostream &os, int indent = 0 ) const {}
     115        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {}
     116        void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    117117
    118118        template<typename T>
     
    283283        }
    284284
    285         virtual void print( std::ostream &os, int indent = 0 ) const override;
    286         virtual void printList( std::ostream &os, int indent = 0 ) const override;
     285        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
     286        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override;
    287287
    288288        Declaration * build() const;
     
    363363        virtual StatementNode * append_last_case( StatementNode * );
    364364
    365         virtual void print( std::ostream &os, int indent = 0 ) const override {}
    366         virtual void printList( std::ostream &os, int indent = 0 ) const override {}
     365        virtual void print( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {}
     366        virtual void printList( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {}
    367367  private:
    368368        std::unique_ptr<Statement> stmt;
  • src/ResolvExpr/CommonType.cc

    r8ca3a72 r10e90cb  
    4343
    4444                void getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer );
    45                 template< typename RefType > void handleRefType( RefType *inst, Type *other );
    4645
    4746                Type *result;
     
    126125        }
    127126
    128         void CommonType::visit( VoidType *voidType ) {
    129         }
     127        void CommonType::visit( __attribute((unused)) VoidType *voidType ) {}
    130128
    131129        void CommonType::visit( BasicType *basicType ) {
     
    189187        }
    190188
    191         void CommonType::visit( ArrayType *arrayType ) {
    192         }
    193 
    194         void CommonType::visit( FunctionType *functionType ) {
    195         }
    196 
    197         template< typename RefType > void CommonType::handleRefType( RefType *inst, Type *other ) {
    198         }
    199 
    200         void CommonType::visit( StructInstType *aggregateUseType ) {
    201         }
    202 
    203         void CommonType::visit( UnionInstType *aggregateUseType ) {
    204         }
     189        void CommonType::visit( __attribute((unused)) ArrayType *arrayType ) {}
     190        void CommonType::visit( __attribute((unused)) FunctionType *functionType ) {}
     191        void CommonType::visit( __attribute((unused)) StructInstType *aggregateUseType ) {}
     192        void CommonType::visit( __attribute((unused)) UnionInstType *aggregateUseType ) {}
    205193
    206194        void CommonType::visit( EnumInstType *enumInstType ) {
     
    214202        }
    215203
    216         void CommonType::visit( TraitInstType *aggregateUseType ) {
     204        void CommonType::visit( __attribute((unused)) TraitInstType *aggregateUseType ) {
    217205        }
    218206
     
    239227        }
    240228
    241         void CommonType::visit( TupleType *tupleType ) {
    242         }
    243 
    244         void CommonType::visit( VarArgsType *varArgsType ) {
    245         }
     229        void CommonType::visit( __attribute((unused)) TupleType *tupleType ) {}
     230        void CommonType::visit( __attribute((unused)) VarArgsType *varArgsType ) {}
    246231
    247232        void CommonType::visit( ZeroType *zeroType ) {
  • src/ResolvExpr/ConversionCost.cc

    r8ca3a72 r10e90cb  
    149149        };
    150150
    151         void ConversionCost::visit(VoidType *voidType) {
     151        void ConversionCost::visit( __attribute((unused)) VoidType *voidType ) {
    152152                cost = Cost::infinity;
    153153        }
     
    186186        }
    187187
    188         void ConversionCost::visit(ArrayType *arrayType) {
    189         }
    190 
    191         void ConversionCost::visit(FunctionType *functionType) {
    192         }
     188        void ConversionCost::visit(__attribute((unused)) ArrayType *arrayType) {}
     189        void ConversionCost::visit(__attribute((unused)) FunctionType *functionType) {}
    193190
    194191        void ConversionCost::visit(StructInstType *inst) {
     
    208205        }
    209206
    210         void ConversionCost::visit(EnumInstType *inst) {
     207        void ConversionCost::visit( __attribute((unused)) EnumInstType *inst ) {
    211208                static Type::Qualifiers q;
    212209                static BasicType integer( q, BasicType::SignedInt );
     
    217214        }
    218215
    219         void ConversionCost::visit(TraitInstType *inst) {
     216        void ConversionCost::visit( __attribute((unused)) TraitInstType *inst) {
    220217        }
    221218
     
    239236        }
    240237
    241         void ConversionCost::visit(TupleType *tupleType) {
     238        void ConversionCost::visit( __attribute((unused)) TupleType *tupleType) {
    242239                Cost c;
    243240                if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
     
    259256        }
    260257
    261         void ConversionCost::visit(VarArgsType *varArgsType) {
     258        void ConversionCost::visit( __attribute((unused)) VarArgsType *varArgsType) {
    262259                if ( dynamic_cast< VarArgsType* >( dest ) ) {
    263260                        cost = Cost::zero;
     
    265262        }
    266263
    267         void ConversionCost::visit(ZeroType *zeroType) {
     264        void ConversionCost::visit( __attribute((unused)) ZeroType *zeroType) {
    268265                if ( dynamic_cast< ZeroType* >( dest ) ) {
    269266                        cost = Cost::zero;
     
    281278        }
    282279
    283         void ConversionCost::visit(OneType *oneType) {
     280        void ConversionCost::visit( __attribute((unused)) OneType *oneType) {
    284281                if ( dynamic_cast< OneType* >( dest ) ) {
    285282                        cost = Cost::zero;
  • src/ResolvExpr/PtrsAssignable.cc

    r8ca3a72 r10e90cb  
    6363        }
    6464
    65         PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env ) : dest( dest ), result( 0 ), env( env ) {
    66         }
     65        PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env ) : dest( dest ), result( 0 ), env( env ) {}
    6766
    68         void PtrsAssignable::visit( VoidType *voidType ) {
     67        void PtrsAssignable::visit( __attribute((unused)) VoidType *voidType ) {
    6968                if ( dynamic_cast< FunctionType* >( dest ) ) {
    7069                        result = 0;
     
    7473        }
    7574
    76         void PtrsAssignable::visit( BasicType *basicType ) {
    77         }
    78 
    79         void PtrsAssignable::visit( PointerType *pointerType ) {
    80         }
    81 
    82         void PtrsAssignable::visit( ArrayType *arrayType ) {
    83         }
    84 
    85         void PtrsAssignable::visit( FunctionType *functionType ) {
     75        void PtrsAssignable::visit( __attribute__((unused)) BasicType *basicType ) {}
     76        void PtrsAssignable::visit( __attribute__((unused)) PointerType *pointerType ) {}
     77        void PtrsAssignable::visit( __attribute__((unused)) ArrayType *arrayType ) {}
     78        void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {
    8679                result = -1;
    8780        }
    8881
    89         void PtrsAssignable::visit( StructInstType *inst ) {
    90                 // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
    91         }
    92 
    93         void PtrsAssignable::visit( UnionInstType *inst ) {
    94                 // I don't think we should be doing anything here, but I'm willing to admit that I might be wrong
    95         }
     82        void PtrsAssignable::visit(  __attribute__((unused)) StructInstType *inst ) {}
     83        void PtrsAssignable::visit(  __attribute__((unused)) UnionInstType *inst ) {}
    9684
    9785        void PtrsAssignable::visit( EnumInstType *inst ) {
     
    10391        }
    10492
    105         void PtrsAssignable::visit( TraitInstType *inst ) {
    106                 // I definitely don't think we should be doing anything here
    107         }
    108 
     93        void PtrsAssignable::visit(  __attribute__((unused)) TraitInstType *inst ) {}
    10994        void PtrsAssignable::visit( TypeInstType *inst ) {
    11095                EqvClass eqvClass;
     
    116101        }
    117102
    118         void PtrsAssignable::visit( TupleType *tupleType ) {
    119 ///  // This code doesn't belong here, but it might be useful somewhere else
    120 ///   if ( TupleType *destAsTuple = dynamic_cast< TupleType* >( dest ) ) {
    121 ///     int ret = 0;
    122 ///     std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin();
    123 ///     std::list< Type* >::const_iterator destIt = destAsTuple->get_types().begin();
    124 ///     while ( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) {
    125 ///       int assignResult = ptrsAssignable( *srcIt++, *destIt++ );
    126 ///       if ( assignResult == 0 ) {
    127 ///         result = assignResult;
    128 ///         return;
    129 ///       } else if ( assignResult < 0 ) {
    130 ///         ret = -1;
    131 ///       } else if ( ret > 0 ) {
    132 ///         ret += assignResult;
    133 ///       }
    134 ///     }
    135 ///     if ( srcIt == tupleType->get_types().end() && destIt == destAsTuple->get_types().end() ) {
    136 ///       result = ret;
    137 ///     } else {
    138 ///       result = 0;
    139 ///     }
    140 ///   }
    141         }
    142 
    143         void PtrsAssignable::visit( VarArgsType *varArgsType ) {
    144         }
    145 
    146         void PtrsAssignable::visit( ZeroType *zeroType ) {
    147         }
    148        
    149         void PtrsAssignable::visit( OneType *oneType ) {
    150         }
     103        void PtrsAssignable::visit(  __attribute__((unused)) TupleType *tupleType ) {}
     104        void PtrsAssignable::visit(  __attribute__((unused)) VarArgsType *varArgsType ) {}
     105        void PtrsAssignable::visit(  __attribute__((unused)) ZeroType *zeroType ) {}
     106        void PtrsAssignable::visit(  __attribute__((unused)) OneType *oneType ) {}
    151107       
    152108} // namespace ResolvExpr
  • src/ResolvExpr/PtrsCastable.cc

    r8ca3a72 r10e90cb  
    9292        }
    9393
    94         void PtrsCastable::visit(VoidType *voidType) {
     94        void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) {
    9595                result = objectCast( dest, env, indexer );
    9696        }
    9797
    98         void PtrsCastable::visit(BasicType *basicType) {
     98        void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) {
    9999                result = objectCast( dest, env, indexer );
    100100        }
    101101
    102         void PtrsCastable::visit(PointerType *pointerType) {
     102        void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) {
    103103                result = objectCast( dest, env, indexer );
    104104        }
    105105
    106         void PtrsCastable::visit(ArrayType *arrayType) {
     106        void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) {
    107107                result = objectCast( dest, env, indexer );
    108108        }
    109109
    110         void PtrsCastable::visit(FunctionType *functionType) {
     110        void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) {
    111111                // result = -1;
    112112                result = functionCast( dest, env, indexer );
    113113        }
    114114
    115         void PtrsCastable::visit(StructInstType *inst) {
     115        void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) {
    116116                result = objectCast( dest, env, indexer );
    117117        }
    118118
    119         void PtrsCastable::visit(UnionInstType *inst) {
     119        void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) {
    120120                result = objectCast( dest, env, indexer );
    121121        }
    122122
    123         void PtrsCastable::visit(EnumInstType *inst) {
     123        void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) {
    124124                if ( dynamic_cast< EnumInstType* >( dest ) ) {
    125125                        result = 1;
     
    144144        }
    145145
    146         void PtrsCastable::visit(TupleType *tupleType) {
     146        void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) {
    147147                result = objectCast( dest, env, indexer );
    148148        }
    149149
    150         void PtrsCastable::visit(VarArgsType *varArgsType) {
     150        void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) {
    151151                result = objectCast( dest, env, indexer );
    152152        }
    153153
    154         void PtrsCastable::visit(ZeroType *zeroType) {
     154        void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) {
    155155                result = objectCast( dest, env, indexer );
    156156        }
    157157
    158         void PtrsCastable::visit(OneType *oneType) {
     158        void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) {
    159159                result = objectCast( dest, env, indexer );
    160160        }
  • src/ResolvExpr/TypeMap.h

    r8ca3a72 r10e90cb  
    110110                        }
    111111
    112                         virtual void visit( VoidType *voidType ) {
     112                        virtual void visit( __attribute__((unused)) VoidType *voidType ) {
    113113                                findAndReplace( typeMap.voidValue );
    114114                        }
     
    138138                        }
    139139
    140                         virtual void visit( FunctionType *functionType ) {
     140                        virtual void visit( __attribute__((unused)) FunctionType *functionType ) {
    141141                                findAndReplace( typeMap.functionPointerValue );
    142142                        }
  • src/ResolvExpr/typeops.h

    r8ca3a72 r10e90cb  
    132132        }
    133133
    134         template< typename Container1, typename Container2 >
    135         bool typesCompatibleList( Container1 &c1, Container2 &c2, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    136                 typename Container1::iterator i1 = c1.begin();
    137                 typename Container2::iterator i2 = c2.begin();
    138                 for ( ; i1 != c1.end() && i2 != c2.end(); ++i1, ++i2 ) {
    139                         if ( ! typesCompatible( *i1, *i2, indexer ) ) {
    140                                 return false;
    141                         } // if
    142                 }
    143                 return ( i1 == c1.end() ) && ( i2 == c2.end() );
    144         }
    145 
    146134        /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.
    147135        Type * extractResultType( FunctionType * functionType );
  • src/SymTab/ImplementationType.cc

    r8ca3a72 r10e90cb  
    6161        }
    6262
    63         void ImplementationType::visit(VoidType *voidType) {
    64         }
    65 
    66         void ImplementationType::visit(BasicType *basicType) {
    67         }
     63        void ImplementationType::visit( __attribute__((unused)) VoidType *voidType ) {}
     64        void ImplementationType::visit( __attribute__((unused)) BasicType *basicType ) {}
    6865
    6966        void ImplementationType::visit(PointerType *pointerType) {
     
    8986        }
    9087
    91         void ImplementationType::visit(StructInstType *aggregateUseType) {
    92         }
    93 
    94         void ImplementationType::visit(UnionInstType *aggregateUseType) {
    95         }
    96 
    97         void ImplementationType::visit(EnumInstType *aggregateUseType) {
    98         }
    99 
    100         void ImplementationType::visit(TraitInstType *aggregateUseType) {
    101         }
     88        void ImplementationType::visit( __attribute__((unused)) StructInstType * aggregateUseType ) {}
     89        void ImplementationType::visit( __attribute__((unused)) UnionInstType * aggregateUseType ) {}
     90        void ImplementationType::visit( __attribute__((unused)) EnumInstType * aggregateUseType ) {}
     91        void ImplementationType::visit( __attribute__((unused)) TraitInstType * aggregateUseType ) {}
    10292
    10393        void ImplementationType::visit(TypeInstType *inst) {
     
    120110        }
    121111
    122         void ImplementationType::visit(VarArgsType *varArgsType) {
    123         }
    124 
    125         void ImplementationType::visit(ZeroType *zeroType) {
    126         }
    127 
    128         void ImplementationType::visit(OneType *oneType) {
    129         }
     112        void ImplementationType::visit( __attribute__((unused)) VarArgsType *varArgsType ) {}
     113        void ImplementationType::visit( __attribute__((unused)) ZeroType *zeroType ) {}
     114        void ImplementationType::visit( __attribute__((unused)) OneType *oneType ) {}
    130115} // namespace SymTab
    131116
  • src/SynTree/Statement.cc

    r8ca3a72 r10e90cb  
    3030Statement::Statement( std::list<Label> _labels ) : labels( _labels ) {}
    3131
    32 void Statement::print( std::ostream &, int indent ) const {}
     32void Statement::print( __attribute__((unused)) std::ostream &, __attribute__((unused)) int indent ) const {}
    3333
    3434Statement::~Statement() {}
     
    365365NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {}
    366366
    367 void NullStmt::print( std::ostream &os, int indent ) const {
     367void NullStmt::print( std::ostream &os, __attribute__((unused)) int indent ) const {
    368368        os << "Null Statement" << endl ;
    369369}
  • src/SynTree/Type.h

    r8ca3a72 r10e90cb  
    334334        virtual void print( std::ostream & os, int indent = 0 ) const;
    335335
    336         virtual void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const {}
     336        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
    337337  protected:
    338338        virtual std::string typeString() const = 0;
  • src/SynTree/Visitor.cc

    r8ca3a72 r10e90cb  
    122122}
    123123
    124 void Visitor::visit( BranchStmt *branchStmt ) {
     124void Visitor::visit( __attribute__((unused)) BranchStmt *branchStmt ) {
    125125}
    126126
     
    143143}
    144144
    145 void Visitor::visit( NullStmt *nullStmt ) {
     145void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) {
    146146}
    147147
     
    445445
    446446
    447 void Visitor::visit( Subrange *subrange ) {}
    448 
    449 
    450 void Visitor::visit( Constant *constant ) {}
     447void Visitor::visit( __attribute__((unused)) Subrange *subrange ) {}
     448
     449
     450void Visitor::visit( __attribute__((unused)) Constant *constant ) {}
    451451// Local Variables: //
    452452// tab-width: 4 //
  • src/driver/cc1.cc

    r8ca3a72 r10e90cb  
    8484
    8585
    86 void sigTermHandler( int signal ) {
     86void sigTermHandler( __attribute__((unused)) int signal ) {
    8787        if ( tmpfilefd != -1 ) {                                                        // RACE, file created ?
    8888                rmtmpfile();                                                                    // remove
     
    469469
    470470
    471 int main( const int argc, const char * const argv[], const char * const env[] ) {
     471int main( const int argc, const char * const argv[], __attribute__((unused)) const char * const env[] ) {
    472472#ifdef __DEBUG_H__
    473473        for ( int i = 0; env[i] != NULL; i += 1 ) {
  • src/driver/cfa.cc

    r8ca3a72 r10e90cb  
    271271                args[nargs] = "-ldl";
    272272                nargs += 1;
     273                args[nargs] = "-lrt";
     274                nargs += 1;
    273275                args[nargs] = "-Xlinker";
    274276                nargs += 1;
  • src/libcfa/Makefile.am

    r8ca3a72 r10e90cb  
    5454# not all platforms support concurrency, add option do disable it
    5555if BUILD_CONCURRENCY
    56 libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/signal.c
     56libsrc += concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c
    5757endif
    5858
  • src/libcfa/Makefile.in

    r8ca3a72 r10e90cb  
    4646
    4747# not all platforms support concurrency, add option do disable it
    48 @BUILD_CONCURRENCY_TRUE@am__append_4 = concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/signal.c
     48@BUILD_CONCURRENCY_TRUE@am__append_4 = concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c concurrency/invoke.c concurrency/preemption.c
    4949subdir = src/libcfa
    5050DIST_COMMON = $(am__nobase_cfa_include_HEADERS_DIST) \
     
    104104        concurrency/kernel.c concurrency/monitor.c \
    105105        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
    106         concurrency/invoke.c concurrency/signal.c
     106        concurrency/invoke.c concurrency/preemption.c
    107107am__dirstamp = $(am__leading_dot)dirstamp
    108108@BUILD_CONCURRENCY_TRUE@am__objects_1 = concurrency/libcfa_d_a-coroutine.$(OBJEXT) \
     
    122122@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-alarm.$(OBJEXT) \
    123123@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-invoke.$(OBJEXT) \
    124 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-signal.$(OBJEXT)
     124@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_d_a-preemption.$(OBJEXT)
    125125am__objects_4 = libcfa_d_a-libcfa-prelude.$(OBJEXT) \
    126126        libcfa_d_a-interpose.$(OBJEXT) \
     
    138138        concurrency/kernel.c concurrency/monitor.c \
    139139        concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \
    140         concurrency/invoke.c concurrency/signal.c
     140        concurrency/invoke.c concurrency/preemption.c
    141141@BUILD_CONCURRENCY_TRUE@am__objects_5 = concurrency/libcfa_a-coroutine.$(OBJEXT) \
    142142@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-thread.$(OBJEXT) \
     
    154154@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-alarm.$(OBJEXT) \
    155155@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-invoke.$(OBJEXT) \
    156 @BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-signal.$(OBJEXT)
     156@BUILD_CONCURRENCY_TRUE@        concurrency/libcfa_a-preemption.$(OBJEXT)
    157157am__objects_8 = libcfa_a-libcfa-prelude.$(OBJEXT) \
    158158        libcfa_a-interpose.$(OBJEXT) \
     
    445445concurrency/libcfa_d_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
    446446        concurrency/$(DEPDIR)/$(am__dirstamp)
    447 concurrency/libcfa_d_a-signal.$(OBJEXT): concurrency/$(am__dirstamp) \
     447concurrency/libcfa_d_a-preemption.$(OBJEXT):  \
     448        concurrency/$(am__dirstamp) \
    448449        concurrency/$(DEPDIR)/$(am__dirstamp)
    449450libcfa-d.a: $(libcfa_d_a_OBJECTS) $(libcfa_d_a_DEPENDENCIES) $(EXTRA_libcfa_d_a_DEPENDENCIES)
     
    473474concurrency/libcfa_a-invoke.$(OBJEXT): concurrency/$(am__dirstamp) \
    474475        concurrency/$(DEPDIR)/$(am__dirstamp)
    475 concurrency/libcfa_a-signal.$(OBJEXT): concurrency/$(am__dirstamp) \
     476concurrency/libcfa_a-preemption.$(OBJEXT):  \
     477        concurrency/$(am__dirstamp) \
    476478        concurrency/$(DEPDIR)/$(am__dirstamp)
    477479libcfa.a: $(libcfa_a_OBJECTS) $(libcfa_a_DEPENDENCIES) $(EXTRA_libcfa_a_DEPENDENCIES)
     
    488490        -rm -f concurrency/libcfa_a-kernel.$(OBJEXT)
    489491        -rm -f concurrency/libcfa_a-monitor.$(OBJEXT)
    490         -rm -f concurrency/libcfa_a-signal.$(OBJEXT)
     492        -rm -f concurrency/libcfa_a-preemption.$(OBJEXT)
    491493        -rm -f concurrency/libcfa_a-thread.$(OBJEXT)
    492494        -rm -f concurrency/libcfa_d_a-alarm.$(OBJEXT)
     
    495497        -rm -f concurrency/libcfa_d_a-kernel.$(OBJEXT)
    496498        -rm -f concurrency/libcfa_d_a-monitor.$(OBJEXT)
    497         -rm -f concurrency/libcfa_d_a-signal.$(OBJEXT)
     499        -rm -f concurrency/libcfa_d_a-preemption.$(OBJEXT)
    498500        -rm -f concurrency/libcfa_d_a-thread.$(OBJEXT)
    499501        -rm -f containers/libcfa_a-maybe.$(OBJEXT)
     
    537539@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@
    538540@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@
    539 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-signal.Po@am__quote@
     541@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-preemption.Po@am__quote@
    540542@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@
    541543@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-alarm.Po@am__quote@
     
    544546@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@
    545547@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-monitor.Po@am__quote@
    546 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-signal.Po@am__quote@
     548@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po@am__quote@
    547549@AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@
    548550@AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-maybe.Po@am__quote@
     
    869871@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-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
    870872
    871 concurrency/libcfa_d_a-signal.o: concurrency/signal.c
    872 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-signal.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-signal.Tpo -c -o concurrency/libcfa_d_a-signal.o `test -f 'concurrency/signal.c' || echo '$(srcdir)/'`concurrency/signal.c
    873 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-signal.Tpo concurrency/$(DEPDIR)/libcfa_d_a-signal.Po
    874 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/signal.c' object='concurrency/libcfa_d_a-signal.o' libtool=no @AMDEPBACKSLASH@
    875 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    876 @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-signal.o `test -f 'concurrency/signal.c' || echo '$(srcdir)/'`concurrency/signal.c
    877 
    878 concurrency/libcfa_d_a-signal.obj: concurrency/signal.c
    879 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-signal.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-signal.Tpo -c -o concurrency/libcfa_d_a-signal.obj `if test -f 'concurrency/signal.c'; then $(CYGPATH_W) 'concurrency/signal.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/signal.c'; fi`
    880 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-signal.Tpo concurrency/$(DEPDIR)/libcfa_d_a-signal.Po
    881 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/signal.c' object='concurrency/libcfa_d_a-signal.obj' libtool=no @AMDEPBACKSLASH@
    882 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    883 @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-signal.obj `if test -f 'concurrency/signal.c'; then $(CYGPATH_W) 'concurrency/signal.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/signal.c'; fi`
     873concurrency/libcfa_d_a-preemption.o: concurrency/preemption.c
     874@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-preemption.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo -c -o concurrency/libcfa_d_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     875@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po
     876@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_d_a-preemption.o' libtool=no @AMDEPBACKSLASH@
     877@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     878@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-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     879
     880concurrency/libcfa_d_a-preemption.obj: concurrency/preemption.c
     881@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-preemption.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo -c -o concurrency/libcfa_d_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
     882@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_d_a-preemption.Po
     883@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_d_a-preemption.obj' libtool=no @AMDEPBACKSLASH@
     884@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     885@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-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
    884886
    885887libcfa_a-libcfa-prelude.obj: libcfa-prelude.c
     
    11631165@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-invoke.obj `if test -f 'concurrency/invoke.c'; then $(CYGPATH_W) 'concurrency/invoke.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/invoke.c'; fi`
    11641166
    1165 concurrency/libcfa_a-signal.o: concurrency/signal.c
    1166 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-signal.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-signal.Tpo -c -o concurrency/libcfa_a-signal.o `test -f 'concurrency/signal.c' || echo '$(srcdir)/'`concurrency/signal.c
    1167 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-signal.Tpo concurrency/$(DEPDIR)/libcfa_a-signal.Po
    1168 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/signal.c' object='concurrency/libcfa_a-signal.o' libtool=no @AMDEPBACKSLASH@
    1169 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1170 @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-signal.o `test -f 'concurrency/signal.c' || echo '$(srcdir)/'`concurrency/signal.c
    1171 
    1172 concurrency/libcfa_a-signal.obj: concurrency/signal.c
    1173 @am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-signal.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-signal.Tpo -c -o concurrency/libcfa_a-signal.obj `if test -f 'concurrency/signal.c'; then $(CYGPATH_W) 'concurrency/signal.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/signal.c'; fi`
    1174 @am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-signal.Tpo concurrency/$(DEPDIR)/libcfa_a-signal.Po
    1175 @AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/signal.c' object='concurrency/libcfa_a-signal.obj' libtool=no @AMDEPBACKSLASH@
    1176 @AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1177 @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-signal.obj `if test -f 'concurrency/signal.c'; then $(CYGPATH_W) 'concurrency/signal.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/signal.c'; fi`
     1167concurrency/libcfa_a-preemption.o: concurrency/preemption.c
     1168@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-preemption.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo -c -o concurrency/libcfa_a-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     1169@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_a-preemption.Po
     1170@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_a-preemption.o' libtool=no @AMDEPBACKSLASH@
     1171@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1172@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-preemption.o `test -f 'concurrency/preemption.c' || echo '$(srcdir)/'`concurrency/preemption.c
     1173
     1174concurrency/libcfa_a-preemption.obj: concurrency/preemption.c
     1175@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-preemption.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo -c -o concurrency/libcfa_a-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
     1176@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-preemption.Tpo concurrency/$(DEPDIR)/libcfa_a-preemption.Po
     1177@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='concurrency/preemption.c' object='concurrency/libcfa_a-preemption.obj' libtool=no @AMDEPBACKSLASH@
     1178@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1179@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-preemption.obj `if test -f 'concurrency/preemption.c'; then $(CYGPATH_W) 'concurrency/preemption.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/preemption.c'; fi`
    11781180install-nobase_cfa_includeHEADERS: $(nobase_cfa_include_HEADERS)
    11791181        @$(NORMAL_INSTALL)
  • src/libcfa/concurrency/alarm.c

    r8ca3a72 r10e90cb  
     1//                              -*- Mode: CFA -*-
     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// alarm.c --
     9//
     10// Author           : Thierry Delisle
     11// Created On       : Fri Jun 2 11:31:25 2017
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
     15//
     16
     17extern "C" {
     18#include <time.h>
     19#include <sys/time.h>
     20}
     21
     22#include "alarm.h"
     23#include "kernel_private.h"
     24#include "preemption.h"
     25
     26//=============================================================================================
     27// Clock logic
     28//=============================================================================================
     29
     30__cfa_time_t __kernel_get_time() {
     31        timespec curr;
     32        clock_gettime( CLOCK_REALTIME, &curr );
     33        return ((__cfa_time_t)curr.tv_sec * TIMEGRAN) + curr.tv_nsec;
     34}
     35
     36void __kernel_set_timer( __cfa_time_t alarm ) {
     37        itimerval val;
     38        val.it_value.tv_sec = alarm / TIMEGRAN;                 // seconds
     39        val.it_value.tv_usec = (alarm % TIMEGRAN) / ( TIMEGRAN / 1_000_000L ); // microseconds
     40        val.it_interval.tv_sec = 0;
     41        val.it_interval.tv_usec = 0;
     42        setitimer( ITIMER_REAL, &val, NULL );
     43}
     44
     45//=============================================================================================
     46// Alarm logic
     47//=============================================================================================
     48
     49void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) {
     50        this->thrd = thrd;
     51        this->alarm = alarm;
     52        this->period = period;
     53        this->next = 0;
     54        this->set = false;
     55        this->kernel_alarm = false;
     56}
     57
     58void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 ) {
     59        this->proc = proc;
     60        this->alarm = alarm;
     61        this->period = period;
     62        this->next = 0;
     63        this->set = false;
     64        this->kernel_alarm = true;
     65}
     66
     67void ^?{}( alarm_node_t * this ) {
     68        if( this->set ) {
     69                unregister_self( this );
     70        }
     71}
     72
     73static inline void insert_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t p ) {
     74        assert( !n->next );
     75        if( p == this->tail ) {
     76                this->tail = &n->next;
     77        }
     78        else {
     79                n->next = *p;
     80        }
     81        *p = n;
     82}
     83
     84void insert( alarm_list_t * this, alarm_node_t * n ) {
     85        alarm_node_t ** it = &this->head;
     86        while( (*it) && (n->alarm > (*it)->alarm) ) {
     87                it = &(*it)->next;
     88        }
     89
     90        insert_at( this, n, it );
     91}
     92
     93alarm_node_t * pop( alarm_list_t * this ) {
     94        alarm_node_t * head = this->head;
     95        if( head ) {
     96                this->head = head->next;
     97                if( !head->next ) {
     98                        this->tail = &this->head;
     99                }
     100                head->next = NULL;
     101        }
     102        return head;
     103}
     104
     105static inline void remove_at( alarm_list_t * this, alarm_node_t * n, __alarm_it_t it ) {
     106        assert( it );
     107        assert( (*it)->next == n );
     108
     109        (*it)->next = n->next;
     110        if( !n-> next ) {
     111                this->tail = it;
     112        }
     113        n->next = NULL;
     114}
     115
     116static inline void remove( alarm_list_t * this, alarm_node_t * n ) {
     117        alarm_node_t ** it = &this->head;
     118        while( (*it) && (*it)->next != n ) {
     119                it = &(*it)->next;
     120        }
     121
     122        if( *it ) { remove_at( this, n, it ); }
     123}
     124
     125void register_self( alarm_node_t * this ) {
     126        disable_interrupts();
     127        assert( !systemProcessor->pending_alarm );
     128        lock( &systemProcessor->alarm_lock );
     129        {
     130                insert( &systemProcessor->alarms, this );
     131                if( systemProcessor->pending_alarm ) {
     132                        tick_preemption();
     133                }
     134        }
     135        unlock( &systemProcessor->alarm_lock );
     136        this->set = true;
     137        enable_interrupts();
     138}
     139
     140void unregister_self( alarm_node_t * this ) {
     141        disable_interrupts();
     142        lock( &systemProcessor->alarm_lock );
     143        remove( &systemProcessor->alarms, this );
     144        unlock( &systemProcessor->alarm_lock );
     145        disable_interrupts();
     146        this->set = false;
     147}
  • src/libcfa/concurrency/kernel

    r8ca3a72 r10e90cb  
    2828//-----------------------------------------------------------------------------
    2929// Locks
     30bool try_lock( spinlock * );
    3031void lock( spinlock * );
    3132void unlock( spinlock * );
     
    8586
    8687        struct FinishAction finish;
     88
     89        struct alarm_node_t * preemption_alarm;
     90        unsigned int preemption;
     91
     92        unsigned short disable_preempt_count;
     93
     94        bool pending_preemption;
    8795};
    8896
     
    94102
    95103// Local Variables: //
    96 // mode: c //
    97 // tab-width: 4 //
     104// mode: CFA //
     105// tab-width: 6 //
    98106// End: //
  • src/libcfa/concurrency/kernel.c

    r8ca3a72 r10e90cb  
    3636//CFA Includes
    3737#include "libhdr.h"
     38#include "preemption.h"
    3839
    3940//Private includes
     
    4748KERNEL_STORAGE(processorCtx_t, systemProcessorCtx);
    4849KERNEL_STORAGE(cluster, systemCluster);
    49 KERNEL_STORAGE(processor, systemProcessor);
     50KERNEL_STORAGE(system_proc_t, systemProcessor);
    5051KERNEL_STORAGE(thread_desc, mainThread);
    5152KERNEL_STORAGE(machine_context_t, mainThread_context);
    5253
    5354cluster * systemCluster;
    54 processor * systemProcessor;
     55system_proc_t * systemProcessor;
    5556thread_desc * mainThread;
    5657
     
    118119// Processor coroutine
    119120void ?{}(processorCtx_t * this, processor * proc) {
    120         (&this->__cor){};
     121        (&this->__cor){ "Processor" };
    121122        this->proc = proc;
    122123        proc->runner = this;
     
    139140        (&this->terminated){};
    140141        this->is_terminated = false;
     142        this->preemption_alarm = NULL;
     143        this->preemption = default_preemption();
     144        this->disable_preempt_count = 1;                //Start with interrupts disabled
     145        this->pending_preemption = false;
    141146
    142147        start( this );
     
    149154        (&this->terminated){};
    150155        this->is_terminated = false;
     156        this->disable_preempt_count = 0;
     157        this->pending_preemption = false;
    151158
    152159        this->runner = runner;
    153160        LIB_DEBUG_PRINT_SAFE("Kernel : constructing processor context %p\n", runner);
    154161        runner{ this };
     162}
     163
     164void ?{}(system_proc_t * this, cluster * cltr, processorCtx_t * runner) {
     165        (&this->alarms){};
     166        (&this->alarm_lock){};
     167        this->pending_alarm = false;
     168
     169        (&this->proc){ cltr, runner };
    155170}
    156171
     
    178193void main(processorCtx_t * runner) {
    179194        processor * this = runner->proc;
     195
    180196        LIB_DEBUG_PRINT_SAFE("Kernel : core %p starting\n", this);
    181197
    182         thread_desc * readyThread = NULL;
    183         for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    184198        {
    185                 readyThread = nextThread( this->cltr );
    186 
    187                 if(readyThread)
     199                // Setup preemption data
     200                preemption_scope scope = { this };
     201
     202                LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);
     203
     204                thread_desc * readyThread = NULL;
     205                for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    188206                {
    189                         runThread(this, readyThread);
    190 
    191                         //Some actions need to be taken from the kernel
    192                         finishRunning(this);
    193 
    194                         spin_count = 0;
    195                 }
    196                 else
    197                 {
    198                         spin(this, &spin_count);
    199                 }               
    200         }
    201 
    202         LIB_DEBUG_PRINT_SAFE("Kernel : core %p unlocking thread\n", this);
     207                        readyThread = nextThread( this->cltr );
     208
     209                        if(readyThread)
     210                        {
     211                                runThread(this, readyThread);
     212
     213                                //Some actions need to be taken from the kernel
     214                                finishRunning(this);
     215
     216                                spin_count = 0;
     217                        }
     218                        else
     219                        {
     220                                spin(this, &spin_count);
     221                        }
     222                }
     223
     224                LIB_DEBUG_PRINT_SAFE("Kernel : core %p stopping\n", this);
     225        }
     226
    203227        signal( &this->terminated );
    204228        LIB_DEBUG_PRINT_SAFE("Kernel : core %p terminated\n", this);
     
    299323        LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this);
    300324       
    301         // pthread_attr_t attributes;
    302         // pthread_attr_init( &attributes );
    303 
    304325        pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
    305 
    306         // pthread_attr_destroy( &attributes );
    307326
    308327        LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);       
     
    316335        assertf( thrd->next == NULL, "Expected null got %p", thrd->next );
    317336       
    318         lock( &systemProcessor->cltr->lock );
    319         append( &systemProcessor->cltr->ready_queue, thrd );
    320         unlock( &systemProcessor->cltr->lock );
     337        lock( &systemProcessor->proc.cltr->lock );
     338        append( &systemProcessor->proc.cltr->ready_queue, thrd );
     339        unlock( &systemProcessor->proc.cltr->lock );
    321340}
    322341
     
    367386}
    368387
     388//=============================================================================================
     389// Kernel Setup logic
     390//=============================================================================================
    369391//-----------------------------------------------------------------------------
    370392// Kernel boot procedures
     
    379401        mainThread{ &info };
    380402
     403        LIB_DEBUG_PRINT_SAFE("Kernel : Main thread ready\n");
     404
     405        // Enable preemption
     406        kernel_start_preemption();
     407
    381408        // Initialize the system cluster
    382409        systemCluster = (cluster *)&systemCluster_storage;
    383410        systemCluster{};
    384411
     412        LIB_DEBUG_PRINT_SAFE("Kernel : System cluster ready\n");
     413
    385414        // Initialize the system processor and the system processor ctx
    386415        // (the coroutine that contains the processing control flow)
    387         systemProcessor = (processor *)&systemProcessor_storage;
     416        systemProcessor = (system_proc_t *)&systemProcessor_storage;
    388417        systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx_storage };
    389418
    390419        // Add the main thread to the ready queue
    391         // once resume is called on systemProcessor->ctx the mainThread needs to be scheduled like any normal thread
     420        // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
    392421        ScheduleThread(mainThread);
    393422
    394423        //initialize the global state variables
    395         this_processor = systemProcessor;
     424        this_processor = &systemProcessor->proc;
    396425        this_processor->current_thread = mainThread;
    397426        this_processor->current_coroutine = &mainThread->cor;
     
    400429        // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
    401430        // mainThread is on the ready queue when this call is made.
    402         resume(systemProcessor->runner);
     431        resume( systemProcessor->proc.runner );
    403432
    404433
     
    414443        // When its coroutine terminates, it return control to the mainThread
    415444        // which is currently here
    416         systemProcessor->is_terminated = true;
     445        systemProcessor->proc.is_terminated = true;
    417446        suspend();
    418447
     
    421450        // Destroy the system processor and its context in reverse order of construction
    422451        // These were manually constructed so we need manually destroy them
    423         ^(systemProcessor->runner){};
     452        ^(systemProcessor->proc.runner){};
    424453        ^(systemProcessor){};
    425454
     
    484513}
    485514
     515//=============================================================================================
     516// Kernel Utilities
     517//=============================================================================================
    486518//-----------------------------------------------------------------------------
    487519// Locks
     
    491523void ^?{}( spinlock * this ) {
    492524
     525}
     526
     527bool try_lock( spinlock * this ) {
     528        return this->lock == 0 && __sync_lock_test_and_set_4( &this->lock, 1 ) == 0;
    493529}
    494530
  • src/libcfa/concurrency/kernel_private.h

    r8ca3a72 r10e90cb  
    2121#include "thread"
    2222
     23#include "alarm.h"
     24
    2325//-----------------------------------------------------------------------------
    2426// Scheduler
     
    3537//-----------------------------------------------------------------------------
    3638// Processor
    37 struct processorCtx_t {
     39coroutine processorCtx_t {
    3840        processor * proc;
    39         coroutine_desc __cor;
    4041};
    41 
    42 DECL_COROUTINE(processorCtx_t);
    4342
    4443void main(processorCtx_t *);
     
    4746void finishRunning(processor * this);
    4847void spin(processor * this, unsigned int * spin_count);
     48
     49struct system_proc_t {
     50        processor proc;
     51
     52        alarm_list_t alarms;
     53        spinlock alarm_lock;
     54
     55        bool pending_alarm;
     56};
     57
     58extern cluster * systemCluster;
     59extern system_proc_t * systemProcessor;
     60extern thread_local processor * this_processor;
     61
     62static inline void disable_interrupts() {
     63        __attribute__((unused)) unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, 1, __ATOMIC_SEQ_CST );
     64        assert( prev != (unsigned short) -1 );
     65}
     66
     67static inline void enable_interrupts_noRF() {
     68        unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     69        assert( prev != (unsigned short) 0 );
     70}
     71
     72static inline void enable_interrupts() {
     73        unsigned short prev = __atomic_fetch_add_2( &this_processor->disable_preempt_count, -1, __ATOMIC_SEQ_CST );
     74        assert( prev != (unsigned short) 0 );
     75        if( prev == 1 && this_processor->pending_preemption ) {
     76                ScheduleInternal( this_processor->current_thread );
     77                this_processor->pending_preemption = false;
     78        }
     79}
    4980
    5081//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/monitor

    r8ca3a72 r10e90cb  
    9292uintptr_t front( condition * this );
    9393
     94struct __acceptable_t {
     95        void (*func)(void);
     96        unsigned short count;
     97        monitor_desc * monitors[1];
     98};
     99
     100void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) );
     101
    94102#endif //MONITOR_H
  • src/libcfa/concurrency/monitor.c

    r8ca3a72 r10e90cb  
    212212        ScheduleInternal( locks, count, threads, thread_count );
    213213
     214
    214215        //WE WOKE UP
    215216
     
    312313        ScheduleInternal( locks, count, &signallee, 1 );
    313314
     315
     316
     317
    314318        LIB_DEBUG_PRINT_SAFE( "Back from signal block\n" );
    315319
     
    330334        );
    331335        return this->blocked.head->user_info;
     336}
     337
     338//-----------------------------------------------------------------------------
     339// Internal scheduling
     340void __accept_internal( unsigned short count, __acceptable_t * acceptables, void (*func)(void) ) {
     341        // thread_desc * this = this_thread();
     342
     343        // unsigned short count = this->current_monitor_count;
     344        // unsigned int recursions[ count ];            //Save the current recursion levels to restore them later
     345        // spinlock *   locks     [ count ];            //We need to pass-in an array of locks to ScheduleInternal
     346
     347        // lock_all( this->current_monitors, locks, count );
     348
     349
     350
     351
     352
     353        // // // Everything is ready to go to sleep
     354        // // ScheduleInternal( locks, count, threads, thread_count );
     355
     356
     357        // //WE WOKE UP
     358
     359
     360        // //We are back, restore the owners and recursions
     361        // lock_all( locks, count );
     362        // restore_recursion( this->monitors, recursions, count );
     363        // unlock_all( locks, count );
    332364}
    333365
  • src/main.cc

    r8ca3a72 r10e90cb  
    146146} // sigSegvBusHandler
    147147
    148 void sigAbortHandler( int sig_num ) {
     148void sigAbortHandler( __attribute__((unused)) int sig_num ) {
    149149        backtrace( 6 );                                                                         // skip first 6 stack frames
    150150        signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
  • src/tests/test.py

    r8ca3a72 r10e90cb  
    197197                        # fetch return code and error from the diff command
    198198                        retcode, error = diff(".expect/%s.txt" % test.path, ".out/%s.log" % test.name, dry_run)
     199
     200        else:
     201                with open (out_file, "r") as myfile:
     202                        error = myfile.read()
     203
     204               
    199205        # clean the executable
    200206        sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
Note: See TracChangeset for help on using the changeset viewer.