Changeset adb6a4f1


Ignore:
Timestamp:
Jun 1, 2018, 7:53:55 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
d56cc219
Parents:
ecae5860 (diff), 262bd63 (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 plg2:software/cfa/cfa-cc

Location:
src
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    recae5860 radb6a4f1  
    6666
    6767        Type * AdjustExprType::postmutate( ArrayType * arrayType ) {
    68                 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base );
     68                PointerType *pointerType = new PointerType{ arrayType->get_qualifiers(), arrayType->base };
    6969                arrayType->base = nullptr;
    7070                delete arrayType;
     
    7373
    7474        Type * AdjustExprType::postmutate( FunctionType * functionType ) {
    75                 return new PointerType( Type::Qualifiers(), functionType );
     75                return new PointerType{ Type::Qualifiers(), functionType };
    7676        }
    7777
    7878        Type * AdjustExprType::postmutate( TypeInstType * typeInst ) {
    79                 EqvClass eqvClass;
    80                 if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    81                         if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    82                                 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    83                                 return pointerType;
     79                if ( const EqvClass* eqvClass = env.lookup( typeInst->get_name() ) ) {
     80                        if ( eqvClass->data.kind == TypeDecl::Ftype ) {
     81                                return new PointerType{ Type::Qualifiers(), typeInst };
    8482                        }
    8583                } else if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    8684                        if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
    8785                                if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
    88                                         PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    89                                         return pointerType;
     86                                        return new PointerType{ Type::Qualifiers(), typeInst };
    9087                                } // if
    9188                        } // if
  • src/ResolvExpr/Alternative.cc

    recae5860 radb6a4f1  
    2727
    2828namespace ResolvExpr {
    29         Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {}
     29        Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( nullptr ) {}
    3030
    3131        Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost )
     
    4848        }
    4949
    50         Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env ) {
     50        Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( std::move( other.env ) ) {
    5151                other.expr = nullptr;
    5252        }
     
    5858                cvtCost = other.cvtCost;
    5959                expr = other.expr;
    60                 env = other.env;
     60                env = std::move( other.env );
    6161                other.expr = nullptr;
    6262                return *this;
  • src/ResolvExpr/AlternativeFinder.cc

    recae5860 radb6a4f1  
    102102                void addAnonConversions( const Alternative & alt );
    103103                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    104                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     104                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string & name );
    105105                /// Adds alternatives for member expressions where the left side has tuple type
    106106                void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     
    307307
    308308                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->result ) ) {
    309                         NameExpr nameExpr( "" );
    310                         addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     309                        addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, "" );
    311310                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->result ) ) {
    312                         NameExpr nameExpr( "" );
    313                         addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     311                        addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, "" );
    314312                } // if
    315313        }
    316314
    317315        template< typename StructOrUnionType >
    318         void AlternativeFinder::Finder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
    319                 // by this point, member must be a name expr
    320                 NameExpr * nameExpr = dynamic_cast< NameExpr * >( member );
    321                 if ( ! nameExpr ) return;
    322                 const std::string & name = nameExpr->name;
     316        void AlternativeFinder::Finder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string & name ) {
    323317                std::list< Declaration* > members;
    324318                aggInst->lookup( name, members );
    325319
    326                 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
    327                         if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) {
    328                                 alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) );
    329                                 renameTypes( alternatives.back().expr );
    330                                 addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression.
     320                for ( Declaration * decl : members ) {
     321                        if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( decl ) ) {
     322                                // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so
     323                                // can't construct in place and use vector::back
     324                                Alternative newAlt( new MemberExpr( dwt, expr->clone() ), env, newCost );
     325                                renameTypes( newAlt.expr );
     326                                addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression.
     327                                alternatives.push_back( std::move(newAlt) );
    331328                        } else {
    332329                                assert( false );
     
    469466        }
    470467
    471         // /// Map of declaration uniqueIds (intended to be the assertions in an AssertionSet) to their parents and the number of times they've been included
    472         //typedef std::unordered_map< UniqueId, std::unordered_map< UniqueId, unsigned > > AssertionParentSet;
    473 
    474468        static const int recursionLimit = /*10*/ 4;  ///< Limit to depth of recursion satisfaction
    475         //static const unsigned recursionParentLimit = 1;  ///< Limit to the number of times an assertion can recursively use itself
    476469
    477470        void addToIndexer( AssertionSet &assertSet, SymTab::Indexer &indexer ) {
     
    484477
    485478        template< typename ForwardIterator, typename OutputIterator >
    486         void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, /*const AssertionParentSet &needParents,*/
    487                                                  int level, const SymTab::Indexer &indexer, OutputIterator out ) {
     479        void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, int level, const SymTab::Indexer &indexer, OutputIterator out ) {
    488480                if ( begin == end ) {
    489481                        if ( newNeed.empty() ) {
     
    503495                                        printAssertionSet( newNeed, std::cerr, 8 );
    504496                                )
    505                                 inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, /*needParents,*/ level+1, indexer, out );
     497                                inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
    506498                                return;
    507499                        }
     
    510502                ForwardIterator cur = begin++;
    511503                if ( ! cur->second.isUsed ) {
    512                         inferRecursive( begin, end, newAlt, openVars, decls, newNeed, /*needParents,*/ level, indexer, out );
     504                        inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
    513505                        return; // xxx - should this continue? previously this wasn't here, and it looks like it should be
    514506                }
     
    563555                                }
    564556
    565                                 //AssertionParentSet newNeedParents( needParents );
    566                                 // skip repeatingly-self-recursive assertion satisfaction
    567                                 // DOESN'T WORK: grandchild nodes conflict with their cousins
    568                                 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue;
    569 
    570557                                Expression *varExpr = data.combine( newerAlt.cvtCost );
    571558                                delete varExpr->get_result();
     
    585572                                // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    586573                                (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    587                                 inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/ level, indexer, out );
     574                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    588575                        } else {
    589576                                delete adjType;
     
    607594                addToIndexer( have, decls );
    608595                AssertionSet newNeed;
    609                 //AssertionParentSet needParents;
    610596                PRINT(
    611597                        std::cerr << "env is: " << std::endl;
     
    614600                )
    615601
    616                 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, /*needParents,*/ 0, indexer, out );
     602                inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    617603//      PRINT(
    618604//          std::cerr << "declaration 14 is ";
     
    10931079                AlternativeFinder funcOpFinder( indexer, env );
    10941080                // it's ok if there aren't any defined function ops
    1095                 funcOpFinder.maybeFind( opExpr);
     1081                funcOpFinder.maybeFind( opExpr );
    10961082                PRINT(
    10971083                        std::cerr << "known function ops:" << std::endl;
     
    11301116                                        }
    11311117                                } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( func->expr->result->stripReferences() ) ) { // handle ftype (e.g. *? on function pointer)
    1132                                         EqvClass eqvClass;
    1133                                         if ( func->env.lookup( typeInst->name, eqvClass ) && eqvClass.type ) {
    1134                                                 if ( FunctionType *function = dynamic_cast< FunctionType* >( eqvClass.type ) ) {
     1118                                        if ( const EqvClass *eqvClass = func->env.lookup( typeInst->name ) ) {
     1119                                                if ( FunctionType *function = dynamic_cast< FunctionType* >( eqvClass->type ) ) {
    11351120                                                        Alternative newFunc( *func );
    11361121                                                        referenceToRvalueConversion( newFunc.expr, newFunc.cost );
     
    13471332        }
    13481333
     1334        namespace {
     1335                /// Gets name from untyped member expression (member must be NameExpr)
     1336                const std::string& get_member_name( UntypedMemberExpr *memberExpr ) {
     1337                        NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() );
     1338                        assert( nameExpr );
     1339                        return nameExpr->get_name();
     1340                }
     1341        }
     1342
    13491343        void AlternativeFinder::Finder::postvisit( UntypedMemberExpr *memberExpr ) {
    13501344                AlternativeFinder funcFinder( indexer, env );
     
    13591353                        // find member of the given type
    13601354                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
    1361                                 addAggMembers( structInst, aggrExpr, cost, agg->env, memberExpr->get_member() );
     1355                                addAggMembers( structInst, aggrExpr, cost, agg->env, get_member_name(memberExpr) );
    13621356                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->get_result() ) ) {
    1363                                 addAggMembers( unionInst, aggrExpr, cost, agg->env, memberExpr->get_member() );
     1357                                addAggMembers( unionInst, aggrExpr, cost, agg->env, get_member_name(memberExpr) );
    13641358                        } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( aggrExpr->get_result() ) ) {
    13651359                                addTupleMembers( tupleType, aggrExpr, cost, agg->env, memberExpr->get_member() );
     
    13791373                        Cost cost = Cost::zero;
    13801374                        Expression * newExpr = data.combine( cost );
    1381                         alternatives.push_back( Alternative( newExpr, env, Cost::zero, cost ) );
     1375
     1376                        // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so
     1377                        // can't construct in place and use vector::back
     1378                        Alternative newAlt( newExpr, env, Cost::zero, cost );
    13821379                        PRINT(
    13831380                                std::cerr << "decl is ";
     
    13881385                                std::cerr << std::endl;
    13891386                        )
    1390                         renameTypes( alternatives.back().expr );
    1391                         addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression.
     1387                        renameTypes( newAlt.expr );
     1388                        addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression.
     1389                        alternatives.push_back( std::move(newAlt) );
    13921390                } // for
    13931391        }
  • src/ResolvExpr/CastCost.cc

    recae5860 radb6a4f1  
    4343        Cost castCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    4444                if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    45                         EqvClass eqvClass;
    46                         NamedTypeDecl *namedType;
    47                         if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
    48                                 if ( eqvClass.type ) {
    49                                         return castCost( src, eqvClass.type, indexer, env );
     45                        if ( const EqvClass* eqvClass = env.lookup( destAsTypeInst->get_name() ) ) {
     46                                if ( eqvClass->type ) {
     47                                        return castCost( src, eqvClass->type, indexer, env );
    5048                                } else {
    5149                                        return Cost::infinity;
    5250                                }
    53                         } else if ( ( namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) ) {
     51                        } else if ( NamedTypeDecl *namedType = indexer.lookupType( destAsTypeInst->get_name() ) ) {
    5452                                // all typedefs should be gone by this point
    5553                                TypeDecl *type = strict_dynamic_cast< TypeDecl* >( namedType );
  • src/ResolvExpr/ConversionCost.cc

    recae5860 radb6a4f1  
    4242        Cost conversionCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    4343                if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    44                         EqvClass eqvClass;
    45                         NamedTypeDecl *namedType;
    4644                        PRINT( std::cerr << "type inst " << destAsTypeInst->name; )
    47                         if ( env.lookup( destAsTypeInst->name, eqvClass ) ) {
    48                                 if ( eqvClass.type ) {
    49                                         return conversionCost( src, eqvClass.type, indexer, env );
     45                        if ( const EqvClass* eqvClass = env.lookup( destAsTypeInst->name ) ) {
     46                                if ( eqvClass->type ) {
     47                                        return conversionCost( src, eqvClass->type, indexer, env );
    5048                                } else {
    5149                                        return Cost::infinity;
    5250                                }
    53                         } else if ( ( namedType = indexer.lookupType( destAsTypeInst->name ) ) ) {
     51                        } else if ( NamedTypeDecl *namedType = indexer.lookupType( destAsTypeInst->name ) ) {
    5452                                PRINT( std::cerr << " found" << std::endl; )
    5553                                TypeDecl *type = dynamic_cast< TypeDecl* >( namedType );
     
    369367
    370368        void ConversionCost::postvisit( TypeInstType *inst ) {
    371                 EqvClass eqvClass;
    372                 NamedTypeDecl *namedType;
    373                 if ( env.lookup( inst->name, eqvClass ) ) {
    374                         cost = costFunc( eqvClass.type, dest, indexer, env );
     369                if ( const EqvClass *eqvClass = env.lookup( inst->name ) ) {
     370                        cost = costFunc( eqvClass->type, dest, indexer, env );
    375371                } else if ( TypeInstType *destAsInst = dynamic_cast< TypeInstType* >( dest ) ) {
    376372                        if ( inst->name == destAsInst->name ) {
    377373                                cost = Cost::zero;
    378374                        }
    379                 } else if ( ( namedType = indexer.lookupType( inst->name ) ) ) {
     375                } else if ( NamedTypeDecl *namedType = indexer.lookupType( inst->name ) ) {
    380376                        TypeDecl *type = dynamic_cast< TypeDecl* >( namedType );
    381377                        // all typedefs should be gone by this point
  • src/ResolvExpr/Occurs.cc

    recae5860 radb6a4f1  
    3838
    3939        Occurs::Occurs( std::string varName, const TypeEnvironment & env ) : result( false ), tenv( env ) {
    40                 EqvClass eqvClass;
    41                 if ( tenv.lookup( varName, eqvClass ) ) {
    42                         eqvVars = eqvClass.vars;
     40                if ( const EqvClass *eqvClass = tenv.lookup( varName ) ) {
     41                        eqvVars = eqvClass->vars;
    4342                } else {
    4443                        eqvVars.insert( varName );
     
    4746
    4847        void Occurs::previsit( TypeInstType * typeInst ) {
    49                 EqvClass eqvClass;
    50 ///   std::cerr << "searching for vars: ";
     48                ///   std::cerr << "searching for vars: ";
    5149///   std::copy( eqvVars.begin(), eqvVars.end(), std::ostream_iterator< std::string >( std::cerr, " " ) );
    5250///   std::cerr << std::endl;
    5351                if ( eqvVars.find( typeInst->get_name() ) != eqvVars.end() ) {
    5452                        result = true;
    55                 } else if ( tenv.lookup( typeInst->get_name(), eqvClass ) ) {
    56                         if ( eqvClass.type ) {
     53                } else if ( const EqvClass *eqvClass = tenv.lookup( typeInst->get_name() ) ) {
     54                        if ( eqvClass->type ) {
    5755///       std::cerr << typeInst->get_name() << " is bound to";
    5856///       eqvClass.type->print( std::cerr );
    5957///       std::cerr << std::endl;
    60                                 eqvClass.type->accept( *visitor );
     58                                eqvClass->type->accept( *visitor );
    6159                        } // if
    6260                } // if
  • src/ResolvExpr/PolyCost.cc

    recae5860 radb6a4f1  
    3939
    4040        void PolyCost::previsit(TypeInstType * typeInst) {
    41                 EqvClass eqvClass;
    42                 if ( tenv.lookup( typeInst->name, eqvClass ) ) {
    43                         if ( eqvClass.type ) {
    44                                 if ( TypeInstType * otherTypeInst = dynamic_cast< TypeInstType* >( eqvClass.type ) ) {
     41                if ( const EqvClass *eqvClass = tenv.lookup( typeInst->name ) ) {
     42                        if ( eqvClass->type ) {
     43                                if ( TypeInstType * otherTypeInst = dynamic_cast< TypeInstType* >( eqvClass->type ) ) {
    4544                                        if ( indexer.lookupType( otherTypeInst->name ) ) {
    4645                                                // bound to opaque type
  • src/ResolvExpr/PtrsAssignable.cc

    recae5860 radb6a4f1  
    5151                // std::cerr << "assignable: " << src << " | " << dest << std::endl;
    5252                if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    53                         EqvClass eqvClass;
    54                         if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
    55                                 return ptrsAssignable( src, eqvClass.type, env );
     53                        if ( const EqvClass *eqvClass = env.lookup( destAsTypeInst->get_name() ) ) {
     54                                return ptrsAssignable( src, eqvClass->type, env );
    5655                        } // if
    5756                } // if
     
    9594        void PtrsAssignable::postvisit(  __attribute__((unused)) TraitInstType *inst ) {}
    9695        void PtrsAssignable::postvisit( TypeInstType *inst ) {
    97                 EqvClass eqvClass;
    98                 if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) {
    99                         // T * = S * for any S depends on the type bound to T
    100                         result = ptrsAssignable( eqvClass.type, dest, env );
     96                if ( const EqvClass *eqvClass = env.lookup( inst->get_name() ) ) {
     97                        if ( eqvClass->type ) {
     98                                // T * = S * for any S depends on the type bound to T
     99                                result = ptrsAssignable( eqvClass->type, dest, env );
     100                        }
    101101                } // if
    102102        }
  • src/ResolvExpr/PtrsCastable.cc

    recae5860 radb6a4f1  
    5757                                return -1;
    5858                        } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) {
    59                                 EqvClass eqvClass;
    6059                                if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    6160                                        if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
     
    6463                                                } // if
    6564                                        } //if
    66                                 } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    67                                         if ( eqvClass.data.kind == TypeDecl::Ftype ) {
     65                                } else if ( const EqvClass *eqvClass = env.lookup( typeInst->get_name() ) ) {
     66                                        if ( eqvClass->data.kind == TypeDecl::Ftype ) {
    6867                                                return -1;
    6968                                        } // if
     
    7978        int ptrsCastable( Type *src, Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
    8079                if ( TypeInstType *destAsTypeInst = dynamic_cast< TypeInstType* >( dest ) ) {
    81                         EqvClass eqvClass;
    82                         if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) {
     80                        if ( const EqvClass *eqvClass = env.lookup( destAsTypeInst->get_name() ) ) {
    8381                                // xxx - should this be ptrsCastable?
    84                                 return ptrsAssignable( src, eqvClass.type, env );
     82                                return ptrsAssignable( src, eqvClass->type, env );
    8583                        } // if
    8684                } // if
  • src/ResolvExpr/TypeEnvironment.cc

    recae5860 radb6a4f1  
    1717#include <algorithm>                   // for copy, set_intersection
    1818#include <iterator>                    // for ostream_iterator, insert_iterator
    19 #include <utility>                     // for pair
     19#include <utility>                     // for pair, move
    2020
    2121#include "Common/utility.h"            // for maybeClone
     
    4444
    4545        void EqvClass::initialize( const EqvClass &src, EqvClass &dest ) {
     46                initialize( src, dest, src.type );
     47        }
     48
     49        void EqvClass::initialize( const EqvClass &src, EqvClass &dest, const Type *ty ) {
    4650                dest.vars = src.vars;
    47                 dest.type = maybeClone( src.type );
     51                dest.type = maybeClone( ty );
    4852                dest.allowWidening = src.allowWidening;
    4953                dest.data = src.data;
    5054        }
    5155
    52         EqvClass::EqvClass() : type( 0 ), allowWidening( true ) {
     56        EqvClass::EqvClass() : type( nullptr ), allowWidening( true ) {
    5357        }
    5458
    5559        EqvClass::EqvClass( const EqvClass &other ) {
    5660                initialize( other, *this );
     61        }
     62
     63        EqvClass::EqvClass( const EqvClass &other, const Type *ty ) {
     64                initialize( other, *this, ty );
    5765        }
    5866
     
    8290        }
    8391
    84         bool TypeEnvironment::lookup( const std::string &var, EqvClass &eqvClass ) const {
     92        const EqvClass* TypeEnvironment::lookup( const std::string &var ) const {
    8593                for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i ) {
    8694                        if ( i->vars.find( var ) != i->vars.end() ) {
    8795///       std::cout << var << " is in class ";
    8896///       i->print( std::cout );
    89                                 eqvClass = *i;
    90                                 return true;
     97                                return &*i;
    9198                        }
    9299///     std::cout << var << " is not in class ";
    93100///     i->print( std::cout );
    94101                } // for
    95                 return false;
     102                return nullptr;
     103        }
     104
     105        /// Removes any class from env that intersects eqvClass
     106        void filterOverlappingClasses( std::list<EqvClass> &env, const EqvClass &eqvClass ) {
     107                for ( auto i = env.begin(); i != env.end(); ) {
     108                        auto next = i;
     109                        ++next;
     110                        std::set<std::string> intersection;
     111                        std::set_intersection( i->vars.begin(), i->vars.end(), eqvClass.vars.begin(), eqvClass.vars.end(),
     112                                std::inserter( intersection, intersection.begin() ) );
     113                        if ( ! intersection.empty() ) { env.erase( i ); }
     114                        i = next;
     115                }
    96116        }
    97117
    98118        void TypeEnvironment::add( const EqvClass &eqvClass ) {
    99                 std::list< EqvClass >::iterator i = env.begin();
    100                 while ( i != env.end() ) {
    101                         std::list< EqvClass >::iterator next = i;
    102                         next++;
    103                         std::set< std::string > intersection;
    104                         std::set_intersection( i->vars.begin(), i->vars.end(), eqvClass.vars.begin(), eqvClass.vars.end(), std::inserter( intersection, intersection.begin() ) );
    105                         if ( ! intersection.empty() ) {
    106                                 env.erase( i );
    107                         } // if
    108                         i = next;
    109                 } // while
    110                 env.insert( env.end(), eqvClass );
     119                filterOverlappingClasses( env, eqvClass );
     120                env.push_back( eqvClass );
     121        }
     122
     123        void TypeEnvironment::add( EqvClass &&eqvClass ) {
     124                filterOverlappingClasses( env, eqvClass );
     125                env.push_back( std::move(eqvClass) );
    111126        }
    112127
     
    159174
    160175        void TypeEnvironment::print( std::ostream &os, Indenter indent ) const {
    161                 for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i ) {
    162                         i->print( os, indent );
     176                for ( const EqvClass & theClass : env ) {
     177                        theClass.print( os, indent );
    163178                } // for
    164179        }
  • src/ResolvExpr/TypeEnvironment.h

    recae5860 radb6a4f1  
    7373
    7474                void initialize( const EqvClass &src, EqvClass &dest );
     75                void initialize( const EqvClass &src, EqvClass &dest, const Type *ty );
    7576                EqvClass();
    7677                EqvClass( const EqvClass &other );
     78                EqvClass( const EqvClass &other, const Type *ty );
    7779                EqvClass &operator=( const EqvClass &other );
    7880                ~EqvClass();
     
    8284        class TypeEnvironment {
    8385          public:
    84                 bool lookup( const std::string &var, EqvClass &eqvClass ) const;
     86                const EqvClass* lookup( const std::string &var ) const;
    8587                void add( const EqvClass &eqvClass );
     88                void add( EqvClass &&eqvClass  );
    8689                void add( const Type::ForallList &tyDecls );
    8790                void add( const TypeSubstitution & sub );
  • src/ResolvExpr/Unify.cc

    recae5860 radb6a4f1  
    2020#include <set>                    // for set
    2121#include <string>                 // for string, operator==, operator!=, bas...
    22 #include <utility>                // for pair
     22#include <utility>                // for pair, move
    2323
    2424#include "Common/PassVisitor.h"   // for PassVisitor
     
    166166                        return false;
    167167                } // if
    168                 EqvClass curClass;
    169                 if ( env.lookup( typeInst->get_name(), curClass ) ) {
    170                         if ( curClass.type ) {
     168                if ( const EqvClass *curClass = env.lookup( typeInst->get_name() ) ) {
     169                        if ( curClass->type ) {
    171170                                Type *common = 0;
    172171                                // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
    173                                 std::unique_ptr< Type > newType( curClass.type->clone() );
     172                                std::unique_ptr< Type > newType( curClass->type->clone() );
    174173                                newType->get_qualifiers() = typeInst->get_qualifiers();
    175                                 if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
     174                                if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) {
    176175                                        if ( common ) {
    177176                                                common->get_qualifiers() = Type::Qualifiers();
    178                                                 delete curClass.type;
    179                                                 curClass.type = common;
    180                                                 env.add( curClass );
     177                                                env.add( EqvClass{ *curClass, common } );
    181178                                        } // if
    182179                                        return true;
     
    185182                                } // if
    186183                        } else {
    187                                 curClass.type = other->clone();
    188                                 curClass.type->get_qualifiers() = Type::Qualifiers();
    189                                 curClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;
    190                                 env.add( curClass );
     184                                EqvClass newClass { *curClass, other };
     185                                newClass.type->get_qualifiers() = Type::Qualifiers();
     186                                newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;
     187                                env.add( std::move(newClass) );
    191188                        } // if
    192189                } else {
     
    204201        bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {
    205202                bool result = true;
    206                 EqvClass class1, class2;
    207                 bool hasClass1 = false, hasClass2 = false;
     203                const EqvClass *class1 = env.lookup( var1->get_name() );
     204                const EqvClass *class2 = env.lookup( var2->get_name() );
    208205                bool widen1 = false, widen2 = false;
    209                 Type *type1 = 0, *type2 = 0;
    210 
    211                 if ( env.lookup( var1->get_name(), class1 ) ) {
    212                         hasClass1 = true;
    213                         if ( class1.type ) {
    214                                 if ( occurs( class1.type, var2->get_name(), env ) ) {
     206                Type *type1 = nullptr, *type2 = nullptr;
     207
     208                if ( class1 ) {
     209                        if ( class1->type ) {
     210                                if ( occurs( class1->type, var2->get_name(), env ) ) {
    215211                                        return false;
    216212                                } // if
    217                                 type1 = class1.type->clone();
    218                         } // if
    219                         widen1 = widenMode.widenFirst && class1.allowWidening;
    220                 } // if
    221                 if ( env.lookup( var2->get_name(), class2 ) ) {
    222                         hasClass2 = true;
    223                         if ( class2.type ) {
    224                                 if ( occurs( class2.type, var1->get_name(), env ) ) {
     213                                type1 = class1->type->clone();
     214                        } // if
     215                        widen1 = widenMode.widenFirst && class1->allowWidening;
     216                } // if
     217                if ( class2 ) {
     218                        if ( class2->type ) {
     219                                if ( occurs( class2->type, var1->get_name(), env ) ) {
    225220                                        return false;
    226221                                } // if
    227                                 type2 = class2.type->clone();
    228                         } // if
    229                         widen2 = widenMode.widenSecond && class2.allowWidening;
     222                                type2 = class2->type->clone();
     223                        } // if
     224                        widen2 = widenMode.widenSecond && class2->allowWidening;
    230225                } // if
    231226
     
    235230                        Type *common = 0;
    236231                        if ( unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, newWidenMode, indexer, common ) ) {
    237                                 class1.vars.insert( class2.vars.begin(), class2.vars.end() );
    238                                 class1.allowWidening = widen1 && widen2;
     232                                EqvClass newClass1 = *class1;
     233                                newClass1.vars.insert( class2->vars.begin(), class2->vars.end() );
     234                                newClass1.allowWidening = widen1 && widen2;
    239235                                if ( common ) {
    240236                                        common->get_qualifiers() = Type::Qualifiers();
    241                                         delete class1.type;
    242                                         class1.type = common;
     237                                        delete newClass1.type;
     238                                        newClass1.type = common;
    243239                                } // if
    244                                 env.add( class1 );
     240                                env.add( std::move(newClass1) );
    245241                        } else {
    246242                                result = false;
    247243                        } // if
    248                 } else if ( hasClass1 && hasClass2 ) {
     244                } else if ( class1 && class2 ) {
    249245                        if ( type1 ) {
    250                                 class1.vars.insert( class2.vars.begin(), class2.vars.end() );
    251                                 class1.allowWidening = widen1;
    252                                 env.add( class1 );
     246                                EqvClass newClass1 = *class1;
     247                                newClass1.vars.insert( class2->vars.begin(), class2->vars.end() );
     248                                newClass1.allowWidening = widen1;
     249                                env.add( std::move(newClass1) );
    253250                        } else {
    254                                 class2.vars.insert( class1.vars.begin(), class1.vars.end() );
    255                                 class2.allowWidening = widen2;
    256                                 env.add( class2 );
    257                         } // if
    258                 } else if ( hasClass1 ) {
    259                         class1.vars.insert( var2->get_name() );
    260                         class1.allowWidening = widen1;
    261                         env.add( class1 );
    262                 } else if ( hasClass2 ) {
    263                         class2.vars.insert( var1->get_name() );
    264                         class2.allowWidening = widen2;
    265                         env.add( class2 );
     251                                EqvClass newClass2 = *class2;
     252                                newClass2.vars.insert( class1->vars.begin(), class1->vars.end() );
     253                                newClass2.allowWidening = widen2;
     254                                env.add( std::move(newClass2) );
     255                        } // if
     256                } else if ( class1 ) {
     257                        EqvClass newClass1 = *class1;
     258                        newClass1.vars.insert( var2->get_name() );
     259                        newClass1.allowWidening = widen1;
     260                        env.add( std::move(newClass1) );
     261                } else if ( class2 ) {
     262                        EqvClass newClass2 = *class2;
     263                        newClass2.vars.insert( var1->get_name() );
     264                        newClass2.allowWidening = widen2;
     265                        env.add( std::move(newClass2) );
    266266                } else {
    267267                        EqvClass newClass;
     
    539539                void premutate( TypeInstType * ) { visit_children = false; }
    540540                Type * postmutate( TypeInstType * typeInst ) {
    541                         EqvClass eqvClass;
    542                         if ( tenv.lookup( typeInst->get_name(), eqvClass ) ) {
    543                                 if ( eqvClass.data.kind == TypeDecl::Ttype ) {
    544                                         // expand ttype parameter into its actual type
    545                                         if ( eqvClass.type ) {
    546                                                 delete typeInst;
    547                                                 return eqvClass.type->clone();
    548                                         }
     541                        if ( const EqvClass *eqvClass = tenv.lookup( typeInst->get_name() ) ) {
     542                                // expand ttype parameter into its actual type
     543                                if ( eqvClass->data.kind == TypeDecl::Ttype && eqvClass->type ) {
     544                                        delete typeInst;
     545                                        return eqvClass->type->clone();
    549546                                }
    550547                        }
  • src/SynTree/ReferenceToType.cc

    recae5860 radb6a4f1  
    5050
    5151namespace {
    52         void doLookup( const std::list< Declaration* > &members, const std::string &name, std::list< Declaration* > &foundDecls ) {
    53                 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
    54                         if ( (*i)->get_name() == name ) {
    55                                 foundDecls.push_back( *i );
     52        void doLookup( const std::list< Declaration * > & members, const std::string & name, std::list< Declaration* > & foundDecls ) {
     53                for ( Declaration * decl : members ) {
     54                        if ( decl->name == name ) {
     55                                foundDecls.push_back( decl );
    5656                        } // if
    5757                } // for
     
    6060
    6161StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes ) :
    62                 Parent( tq, baseStruct->get_name(), attributes ), baseStruct( baseStruct ) {}
     62                Parent( tq, baseStruct->name, attributes ), baseStruct( baseStruct ) {}
    6363
    6464std::string StructInstType::typeString() const { return "struct"; }
     
    8484void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const {
    8585        assert( baseStruct );
    86         doLookup( baseStruct->get_members(), name, foundDecls );
     86        doLookup( baseStruct->members, name, foundDecls );
    8787}
    8888
     
    103103
    104104UnionInstType::UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes ) :
    105                 Parent( tq, baseUnion->get_name(), attributes ), baseUnion( baseUnion ) {}
     105                Parent( tq, baseUnion->name, attributes ), baseUnion( baseUnion ) {}
    106106
    107107std::string UnionInstType::typeString() const { return "union"; }
     
    127127void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const {
    128128        assert( baseUnion );
    129         doLookup( baseUnion->get_members(), name, foundDecls );
     129        doLookup( baseUnion->members, name, foundDecls );
    130130}
    131131
  • src/benchmark/Makefile.am

    recae5860 radb6a4f1  
    9696        ctxswitch-cfa_coroutine.run     \
    9797        ctxswitch-cfa_thread.run        \
     98        ctxswitch-cfa_thread2.run       \
    9899        ctxswitch-upp_coroutine.run     \
    99100        ctxswitch-upp_thread.run        \
     101        -ctxswitch-kos_fibre.run        \
     102        -ctxswitch-kos_fibre2.run       \
    100103        ctxswitch-goroutine.run         \
    101104        ctxswitch-java_thread.run
    102105
     106ctxswitch-pthread$(EXEEXT):
     107        @@BACKEND_CC@ ctxswitch/pthreads.c     -DBENCH_N=50000000  -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     108
    103109ctxswitch-cfa_coroutine$(EXEEXT):
    104         @${CC}        ctxswitch/cfa_cor.c   -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     110        @${CC}        ctxswitch/cfa_cor.c      -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    105111
    106112ctxswitch-cfa_thread$(EXEEXT):
    107         @${CC}        ctxswitch/cfa_thrd.c  -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     113        @${CC}        ctxswitch/cfa_thrd.c     -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     114
     115ctxswitch-cfa_thread2$(EXEEXT):
     116        @${CC}        ctxswitch/cfa_thrd2.c    -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    108117
    109118ctxswitch-upp_coroutine$(EXEEXT):
    110         @u++          ctxswitch/upp_cor.cc  -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     119        @u++          ctxswitch/upp_cor.cc     -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    111120
    112121ctxswitch-upp_thread$(EXEEXT):
    113         @u++          ctxswitch/upp_thrd.cc -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    114 
    115 ctxswitch-pthread$(EXEEXT):
    116         @@BACKEND_CC@ ctxswitch/pthreads.c  -DBENCH_N=50000000  -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     122        @u++          ctxswitch/upp_thrd.cc    -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     123
     124ctxswitch-kos_fibre$(EXEEXT):
     125        @${CXX}       ctxswitch/kos_fibre.cpp  -DBENCH_N=50000000  -I. -I/home/tdelisle/software/KOS/src/ -g -O2 -lfibre -lpthread -lrt
     126
     127ctxswitch-kos_fibre2$(EXEEXT):
     128        @${CXX}       ctxswitch/kos_fibre2.cpp -DBENCH_N=50000000  -I. -I/home/tdelisle/software/KOS/src/ -g -O2 -lfibre -lpthread -lrt
    117129
    118130ctxswitch-goroutine$(EXEEXT):
  • src/benchmark/Makefile.in

    recae5860 radb6a4f1  
    509509        ctxswitch-cfa_coroutine.run     \
    510510        ctxswitch-cfa_thread.run        \
     511        ctxswitch-cfa_thread2.run       \
    511512        ctxswitch-upp_coroutine.run     \
    512513        ctxswitch-upp_thread.run        \
     514        -ctxswitch-kos_fibre.run        \
     515        -ctxswitch-kos_fibre2.run       \
    513516        ctxswitch-goroutine.run         \
    514517        ctxswitch-java_thread.run
    515518
     519ctxswitch-pthread$(EXEEXT):
     520        @@BACKEND_CC@ ctxswitch/pthreads.c     -DBENCH_N=50000000  -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     521
    516522ctxswitch-cfa_coroutine$(EXEEXT):
    517         @${CC}        ctxswitch/cfa_cor.c   -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     523        @${CC}        ctxswitch/cfa_cor.c      -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    518524
    519525ctxswitch-cfa_thread$(EXEEXT):
    520         @${CC}        ctxswitch/cfa_thrd.c  -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     526        @${CC}        ctxswitch/cfa_thrd.c     -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     527
     528ctxswitch-cfa_thread2$(EXEEXT):
     529        @${CC}        ctxswitch/cfa_thrd2.c    -DBENCH_N=50000000  -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    521530
    522531ctxswitch-upp_coroutine$(EXEEXT):
    523         @u++          ctxswitch/upp_cor.cc  -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     532        @u++          ctxswitch/upp_cor.cc     -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    524533
    525534ctxswitch-upp_thread$(EXEEXT):
    526         @u++          ctxswitch/upp_thrd.cc -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    527 
    528 ctxswitch-pthread$(EXEEXT):
    529         @@BACKEND_CC@ ctxswitch/pthreads.c  -DBENCH_N=50000000  -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     535        @u++          ctxswitch/upp_thrd.cc    -DBENCH_N=50000000  -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     536
     537ctxswitch-kos_fibre$(EXEEXT):
     538        @${CXX}       ctxswitch/kos_fibre.cpp  -DBENCH_N=50000000  -I. -I/home/tdelisle/software/KOS/src/ -g -O2 -lfibre -lpthread -lrt
     539
     540ctxswitch-kos_fibre2$(EXEEXT):
     541        @${CXX}       ctxswitch/kos_fibre2.cpp -DBENCH_N=50000000  -I. -I/home/tdelisle/software/KOS/src/ -g -O2 -lfibre -lpthread -lrt
    530542
    531543ctxswitch-goroutine$(EXEEXT):
     
    682694
    683695compile-io$(EXEEXT):
    684         @${CC} -quiet -fsyntax-only -w ../tests/io.c                                    @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     696        @${CC} -quiet -fsyntax-only -w ../tests/io1.c                           @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    685697
    686698compile-monitor$(EXEEXT):
    687         @${CC} -quiet -fsyntax-only -w ../tests/concurrent/monitor.c            @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     699        @${CC} -quiet -fsyntax-only -w ../tests/concurrent/monitor.c    @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    688700
    689701compile-operators$(EXEEXT):
     
    694706
    695707compile-typeof$(EXEEXT):
    696         @${CC} -quiet -fsyntax-only -w ../tests/typeof.c                                @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     708        @${CC} -quiet -fsyntax-only -w ../tests/typeof.c                        @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    697709
    698710# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • src/libcfa/concurrency/invoke.h

    recae5860 radb6a4f1  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 22:33:59 2018
    13 // Update Count     : 30
     12// Last Modified On : Sat May 19 08:23:21 2018
     13// Update Count     : 31
    1414//
    1515
     
    1818#include "bits/locks.h"
    1919
    20 #define TL_GET( member ) kernelTLS.member
    21 #define TL_SET( member, value ) kernelTLS.member = value;
    22 
    2320#ifdef __cforall
    2421extern "C" {
     
    2825#ifndef _INVOKE_H_
    2926#define _INVOKE_H_
     27
     28#ifdef __ARM_ARCH
     29        // function prototypes are only really used by these macros on ARM
     30        void disable_global_interrupts();
     31        void enable_global_interrupts();
     32
     33        #define TL_GET( member ) ( { __typeof__( kernelTLS.member ) target; \
     34                disable_global_interrupts(); \
     35                target = kernelTLS.member; \
     36                enable_global_interrupts(); \
     37                target; } )
     38        #define TL_SET( member, value ) disable_global_interrupts(); \
     39                kernelTLS.member = value; \
     40                enable_global_interrupts();
     41#else
     42        #define TL_GET( member ) kernelTLS.member
     43        #define TL_SET( member, value ) kernelTLS.member = value;
     44#endif
    3045
    3146        #ifdef __cforall
Note: See TracChangeset for help on using the changeset viewer.