- Timestamp:
- Mar 16, 2017, 5:20:16 PM (8 years ago)
- 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, resolv-new, with_gc
- Children:
- 3743983
- Parents:
- 1fbab5a
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
r1fbab5a ref42b143 111 111 private: 112 112 StructDecl* monitor_decl = nullptr; 113 StructDecl* guard_decl = nullptr; 113 114 }; 114 115 … … 137 138 if( ! body ) return; 138 139 139 assert(monitor_decl);140 140 addStatments( body, mutexArgs ); 141 141 } … … 146 146 monitor_decl = decl; 147 147 } 148 else if( decl->get_name() == "monitor_guard_t" ) { 149 assert( !guard_decl ); 150 guard_decl = decl; 151 } 148 152 } 149 153 … … 175 179 176 180 //Make sure that typed isn't mutex 177 if( !base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );181 if( base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg ); 178 182 } 179 183 180 184 void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) { 185 assert(monitor_decl); 186 assert(guard_decl); 181 187 182 188 ObjectDecl * monitors = new ObjectDecl( … … 218 224 new StructInstType( 219 225 noQualifiers, 220 "monitor_guard_t"226 guard_decl 221 227 ), 222 228 new ListInit( … … 224 230 new SingleInit( new VariableExpr( monitors ) ), 225 231 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 226 } 232 }, 233 noDesignators, 234 true 227 235 ) 228 236 )) 229 237 ); 230 238 231 //monitor_desc * __monitors[] = { a, b};239 //monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 232 240 body->push_front( new DeclStmt( noLabels, monitors) ); 233 241 } -
src/SynTree/Type.h
r1fbab5a ref42b143 92 92 bool operator<=( Qualifiers other ) const { 93 93 return isConst <= other.isConst && isVolatile <= other.isVolatile && 94 isMutex == other.isMutex && isAtomic == other.isAtomic;94 isMutex >= other.isMutex && isAtomic == other.isAtomic; 95 95 } 96 96 bool operator>=( Qualifiers other ) const { 97 97 return isConst >= other.isConst && isVolatile >= other.isVolatile && 98 isMutex == other.isMutex && isAtomic == other.isAtomic;98 isMutex <= other.isMutex && isAtomic == other.isAtomic; 99 99 } 100 100 bool operator<( Qualifiers other ) const { -
src/main.cc
r1fbab5a ref42b143 241 241 OPTPRINT( "fixNames" ) 242 242 CodeGen::fixNames( translationUnit ); 243 OPTPRINT( " tweakInit" )243 OPTPRINT( "genInit" ) 244 244 InitTweak::genInit( translationUnit ); 245 245 OPTPRINT( "expandMemberTuples" ); -
src/tests/monitor.c
r1fbab5a ref42b143 13 13 } 14 14 15 monitor_desc * get_monitor( global_t * this ) { 16 return &this->m; 17 } 18 15 19 static global_t global; 16 20 17 void increment ( /*mutex*/ global_t *this ) {18 monitor_desc * mon = &this->m;19 monitor_guard_t g1 = { &mon }; 20 { 21 monitor_guard_t g2 = { &mon }; 22 {23 monitor_guard_t g3 = { &mon }; 24 this->value += 1; 25 } 26 }21 void increment3( global_t * mutex this ) { 22 this->value += 1; 23 } 24 25 void increment2( global_t * mutex this ) { 26 increment3( this ); 27 } 28 29 void increment( global_t * mutex this ) { 30 increment2( this ); 27 31 } 28 32 -
src/tests/multi-monitor.c
r1fbab5a ref42b143 6 6 static int global12, global23, global13; 7 7 8 static monitor_desc m1, m2, m3; 8 struct monitor_t { 9 monitor_desc m; 10 }; 9 11 10 void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) { 11 monitor_desc * mons[] = { p1, p2 }; 12 monitor_guard_t g = { mons, 2 }; 12 monitor_desc * get_monitor( monitor_t * this ) { 13 return &this->m; 14 } 15 16 static monitor_t m1, m2, m3; 17 18 void increment( monitor_t * mutex p1, monitor_t * mutex p2, int * value ) { 13 19 *value += 1; 14 20 }
Note: See TracChangeset
for help on using the changeset viewer.