Changes in / [5a3ac84:9b443c7f]
- Files:
-
- 4 added
- 4 deleted
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
Jenkins/FullBuild
r5a3ac84 r9b443c7f 20 20 21 21 parallel ( 22 gcc_6_x64: { trigger_build( 'gcc-6', 'x64' ) },23 gcc_6_x86: { trigger_build( 'gcc-6', 'x86' ) },24 gcc_5_x64: { trigger_build( 'gcc-5', 'x64' ) },25 gcc_5_x86: { trigger_build( 'gcc-5', 'x86' ) },26 gcc_4_x64: { trigger_build( 'gcc-4.9', 'x64' ) },27 gcc_4_x86: { trigger_build( 'gcc-4.9', 'x86' ) },28 clang_x64: { trigger_build( 'clang', 'x64' ) },29 clang_x86: { trigger_build( 'clang', 'x86' ) },22 gcc_6_x64: { trigger_build( 'gcc-6', 'x64', true ) }, 23 gcc_6_x86: { trigger_build( 'gcc-6', 'x86', true ) }, 24 gcc_5_x64: { trigger_build( 'gcc-5', 'x64', false ) }, 25 gcc_5_x86: { trigger_build( 'gcc-5', 'x86', false ) }, 26 gcc_4_x64: { trigger_build( 'gcc-4.9', 'x64', false ) }, 27 gcc_4_x86: { trigger_build( 'gcc-4.9', 'x86', false ) }, 28 clang_x64: { trigger_build( 'clang', 'x64', false ) }, 29 clang_x86: { trigger_build( 'clang', 'x86', false ) }, 30 30 ) 31 31 … … 62 62 //=========================================================================================================== 63 63 64 def trigger_build(String cc, String arch ) {64 def trigger_build(String cc, String arch, Boolean publish) { 65 65 def result = build job: 'Cforall/master', \ 66 66 parameters: [ \ … … 82 82 [$class: 'BooleanParameterValue', \ 83 83 name: 'pPublish', \ 84 value: true], \84 value: publish], \ 85 85 [$class: 'BooleanParameterValue', \ 86 86 name: 'pSilent', \ -
Jenkinsfile
r5a3ac84 r9b443c7f 13 13 14 14 compiler = null 15 arch_name = '' 15 16 architecture = '' 16 17 … … 130 131 [$class: 'BooleanParameterDefinition', \ 131 132 description: 'If true, jenkins also builds documentation', \ 132 name: 'pBuildDocumentation', 133 name: 'pBuildDocumentation', \ 133 134 defaultValue: true, \ 134 135 ], \ … … 136 137 description: 'If true, jenkins also publishes results', \ 137 138 name: 'pPublish', \ 138 defaultValue: true, \139 defaultValue: false, \ 139 140 ], \ 140 141 [$class: 'BooleanParameterDefinition', \ 141 142 description: 'If true, jenkins will not send emails', \ 142 name: 'pSilent', \143 name: 'pSilent', \ 143 144 defaultValue: false, \ 144 145 ], \ … … 147 148 148 149 compiler = compiler_from_params( pCompiler ) 149 architecture = architecture_from_params( pArchitecture ) 150 arch_name = pArchitecture 151 architecture = architecture_from_params( arch_name ) 150 152 151 153 do_alltests = (pRunAllTests == 'true') … … 156 158 157 159 echo """Compiler : ${compiler.cc_name} (${compiler.cpp_cc}/${compiler.cfa_cc}) 158 Architecture : ${architecture} 160 Architecture : ${arch_name} 161 Arc Flags : ${architecture} 159 162 Run All Tests : ${ pRunAllTests.toString() } 160 163 Run Benchmark : ${ pRunBenchmark.toString() } … … 287 290 288 291 //Write the commit id to Benchmark 289 writeFile file: 'bench.csv', text:'data=' + gitRefNewValue + ',' 292 writeFile file: 'bench.csv', text:'data=' + gitRefNewValue + ',' + arch_name + ',' 290 293 291 294 //Append bench results -
doc/proposals/concurrency/thePlan.md
r5a3ac84 r9b443c7f 7 7 8 8 _Phase 2_ : Minimum Viable Product 9 Monitor type and enter/leave mutex member routines9 done - Monitor type and enter/leave mutex member routines 10 10 Monitors as a language feature (not calling enter/leave by hand) 11 11 Internal scheduling -
src/CodeGen/CodeGenerator.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 5 17:13:33201713 // Update Count : 47 512 // Last Modified On : Mon Mar 13 23:56:59 2017 13 // Update Count : 477 14 14 // 15 15 … … 895 895 896 896 void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) { 897 if ( decl->get_storageClasses(). any()) {897 if ( decl->get_storageClasses().val != 0 ) { 898 898 DeclarationNode::print_StorageClass( output, decl->get_storageClasses() ); 899 899 } // if -
src/Common/utility.h
r5a3ac84 r9b443c7f 265 265 reverse_iterate_t< T > reverseIterate( T & ref ) { 266 266 return reverse_iterate_t< T >( ref ); 267 } 268 269 template< typename OutType, typename Range, typename Functor > 270 OutType map_range( const Range& range, Functor&& functor ) { 271 OutType out; 272 273 std::transform( 274 begin( range ), 275 end( range ), 276 std::back_inserter( out ), 277 std::forward< Functor >( functor ) 278 ); 279 280 return out; 267 281 } 268 282 -
src/Concurrency/Keywords.cc
r5a3ac84 r9b443c7f 1 // -*- Mode: CPP -*- 2 // 3 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 4 // 5 // The contents of this file are covered under the licence agreement in the 6 // file "LICENCE" distributed with Cforall. 7 // 8 // Keywords.cc -- 9 // 10 // Author : Thierry Delisle 11 // Created On : Mon Mar 13 12:41:22 2017 12 // Last Modified By : 13 // Last Modified On : 14 // Update Count : 0 15 // 16 17 #include "Concurrency/Keywords.h" 18 19 #include "SynTree/Declaration.h" 20 #include "SynTree/Expression.h" 21 #include "SynTree/Initializer.h" 22 #include "SynTree/Mutator.h" 23 #include "SynTree/Statement.h" 24 #include "SynTree/Type.h" 25 #include "SynTree/Visitor.h" 26 27 namespace Concurrency { 28 29 namespace { 30 const std::list<Label> noLabels; 31 DeclarationNode::StorageClasses noStorage; 32 Type::Qualifiers noQualifiers; 33 } 34 35 //============================================================================================= 36 // Visitors declaration 37 //============================================================================================= 38 39 //----------------------------------------------------------------------------- 40 //Handles thread type declarations : 41 // thread Mythread { struct MyThread { 42 // int data; int data; 43 // a_struct_t more_data; a_struct_t more_data; 44 // => thread_desc __thrd_d; 45 // }; }; 46 // static inline thread_desc * get_thread( MyThread * this ) { return &this->__thrd_d; } 47 // void main( MyThread * this ); 48 // 49 class ThreadKeyword final : public Mutator { 50 public: 51 52 static void implement( std::list< Declaration * > & translationUnit ) {} 53 }; 54 55 //----------------------------------------------------------------------------- 56 //Handles coroutine type declarations : 57 // coroutine MyCoroutine { struct MyCoroutine { 58 // int data; int data; 59 // a_struct_t more_data; a_struct_t more_data; 60 // => coroutine_desc __cor_d; 61 // }; }; 62 // static inline coroutine_desc * get_coroutine( MyCoroutine * this ) { return &this->__cor_d; } 63 // void main( MyCoroutine * this ); 64 // 65 class CoroutineKeyword final : public Mutator { 66 public: 67 68 static void implement( std::list< Declaration * > & translationUnit ) {} 69 }; 70 71 //----------------------------------------------------------------------------- 72 //Handles monitor type declarations : 73 // monitor MyMonitor { struct MyMonitor { 74 // int data; int data; 75 // a_struct_t more_data; a_struct_t more_data; 76 // => monitor_desc __mon_d; 77 // }; }; 78 // static inline monitor_desc * get_coroutine( MyMonitor * this ) { return &this->__cor_d; } 79 // void main( MyMonitor * this ); 80 // 81 class MonitorKeyword final : public Mutator { 82 public: 83 84 static void implement( std::list< Declaration * > & translationUnit ) {} 85 }; 86 87 //----------------------------------------------------------------------------- 88 //Handles mutex routines definitions : 89 // void foo( A * mutex a, B * mutex b, int i ) { void foo( A * a, B * b, int i ) { 90 // monitor_desc * __monitors[] = { get_monitor(a), get_monitor(b) }; 91 // monitor_guard_t __guard = { __monitors, 2 }; 92 // /*Some code*/ => /*Some code*/ 93 // } } 94 // 95 class MutexKeyword final : public Visitor { 96 public: 97 98 using Visitor::visit; 99 virtual void visit( FunctionDecl *functionDecl ) override final; 100 virtual void visit( StructDecl *functionDecl ) override final; 101 102 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* ); 103 void validate( DeclarationWithType * ); 104 void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &); 105 106 static void implement( std::list< Declaration * > & translationUnit ) { 107 MutexKeyword impl; 108 acceptAll( translationUnit, impl ); 109 } 110 111 private: 112 StructDecl* monitor_decl = nullptr; 113 }; 114 115 //============================================================================================= 116 // General entry routine 117 //============================================================================================= 118 void applyKeywords( std::list< Declaration * > & translationUnit ) { 119 ThreadKeyword ::implement( translationUnit ); 120 CoroutineKeyword ::implement( translationUnit ); 121 MonitorKeyword ::implement( translationUnit ); 122 MutexKeyword ::implement( translationUnit ); 123 } 124 125 //============================================================================================= 126 // Mutex keyword implementation 127 //============================================================================================= 128 void MutexKeyword::visit(FunctionDecl* decl) { 129 std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl ); 130 if( mutexArgs.empty() ) return; 131 132 for(auto arg : mutexArgs) { 133 validate( arg ); 134 } 135 136 CompoundStmt* body = decl->get_statements(); 137 if( ! body ) return; 138 139 assert(monitor_decl); 140 addStatments( body, mutexArgs ); 141 } 142 143 void MutexKeyword::visit(StructDecl* decl) { 144 if( decl->get_name() == "monitor_desc" ) { 145 assert( !monitor_decl ); 146 monitor_decl = decl; 147 } 148 } 149 150 std::list<DeclarationWithType*> MutexKeyword::findMutexArgs( FunctionDecl* decl ) { 151 std::list<DeclarationWithType*> mutexArgs; 152 153 for( auto arg : decl->get_functionType()->get_parameters()) { 154 //Find mutex arguments 155 Type* ty = arg->get_type(); 156 if( ! ty->get_qualifiers().isMutex ) continue; 157 158 //Append it to the list 159 mutexArgs.push_back( arg ); 160 } 161 162 return mutexArgs; 163 } 164 165 void MutexKeyword::validate( DeclarationWithType * arg ) { 166 Type* ty = arg->get_type(); 167 168 //Makes sure it's not a copy 169 PointerType* pty = dynamic_cast< PointerType * >( ty ); 170 if( ! pty ) throw SemanticError( "Mutex argument must be of pointer/reference type ", arg ); 171 172 //Make sure the we are pointing directly to a type 173 Type* base = pty->get_base(); 174 if( dynamic_cast< PointerType * >( base ) ) throw SemanticError( "Mutex argument have exactly one level of indirection ", arg ); 175 176 //Make sure that typed isn't mutex 177 if( ! base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg ); 178 } 179 180 void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) { 181 182 ObjectDecl * monitors = new ObjectDecl( 183 "__monitors", 184 noStorage, 185 LinkageSpec::Cforall, 186 nullptr, 187 new ArrayType( 188 noQualifiers, 189 new PointerType( 190 noQualifiers, 191 new StructInstType( 192 noQualifiers, 193 monitor_decl 194 ) 195 ), 196 new ConstantExpr( Constant::from_ulong( args.size() ) ), 197 false, 198 false 199 ), 200 new ListInit( 201 map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){ 202 return new SingleInit( new UntypedExpr( 203 new NameExpr( "get_monitor" ), 204 { new VariableExpr( var ) } 205 ) ); 206 }) 207 ) 208 ); 209 210 //in reverse order : 211 // monitor_guard_t __guard = { __monitors, # }; 212 body->push_front( 213 new DeclStmt( noLabels, new ObjectDecl( 214 "__guard", 215 noStorage, 216 LinkageSpec::Cforall, 217 nullptr, 218 new StructInstType( 219 noQualifiers, 220 "monitor_guard_t" 221 ), 222 new ListInit( 223 { 224 new SingleInit( new VariableExpr( monitors ) ), 225 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 226 } 227 ) 228 )) 229 ); 230 231 //monitor_desc * __monitors[] = { a, b }; 232 body->push_front( new DeclStmt( noLabels, monitors) ); 233 } 234 }; -
src/Concurrency/Keywords.h
r5a3ac84 r9b443c7f 1 // -*- Mode: CPP -*- 2 // 3 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo 4 // 5 // The contents of this file are covered under the licence agreement in the 6 // file "LICENCE" distributed with Cforall. 7 // 8 // Keywords.h -- 9 // 10 // Author : Thierry Delisle 11 // Created On : Fri Mar 10 15:16:42 2017 12 // Last Modified By : 13 // Last Modified On : 14 // Update Count : 0 15 // 16 17 #ifndef KEYWORDS_H 18 #define KEYWORDS_H 19 20 #include <list> 21 22 #include "SynTree/Declaration.h" 23 24 namespace Concurrency { 25 void applyKeywords( std::list< Declaration * > & translationUnit ); 26 }; 27 28 #endif //KEYWORDS_H -
src/GenPoly/Box.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:45:59 201713 // Update Count : 33 012 // Last Modified On : Tue Mar 14 07:45:29 2017 13 // Update Count : 334 14 14 // 15 15 … … 299 299 // because each unit generates copies of the default routines for each aggregate. 300 300 FunctionDecl *layoutDecl = new FunctionDecl( layoutofName( typeDecl ), 301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static Class),301 functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static ), 302 302 LinkageSpec::AutoGen, layoutFnType, new CompoundStmt( noLabels ), 303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) );303 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ); 304 304 layoutDecl->fixUniqueId(); 305 305 return layoutDecl; -
src/InitTweak/FixGlobalInit.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Mon May 04 15:14:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:14:19201713 // Update Count : 1 412 // Last Modified On : Mon Mar 13 23:58:27 2017 13 // Update Count : 16 14 14 // 15 15 … … 87 87 dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) ); 88 88 } 89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );89 initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 90 90 initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) ); 91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );91 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 92 92 destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) ); 93 93 } … … 143 143 // compile-command: "make install" // 144 144 // End: // 145 -
src/InitTweak/FixInit.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:51:40201713 // Update Count : 5912 // Last Modified On : Tue Mar 14 08:05:28 2017 13 // Update Count : 63 14 14 // 15 15 … … 678 678 assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() ); 679 679 if ( Statement * ctor = ctorInit->get_ctor() ) { 680 if ( objDecl->get_storageClasses() [ DeclarationNode::Static ]) {680 if ( objDecl->get_storageClasses().is_static ) { 681 681 // originally wanted to take advantage of gcc nested functions, but 682 682 // we get memory errors with this approach. To remedy this, the static … … 704 704 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 705 705 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators ); 706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::Cforall, 0, boolType, boolInitExpr );706 ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr ); 707 707 isUninitializedVar->fixUniqueId(); 708 708 … … 731 731 732 732 // void __objName_dtor_atexitN(...) {...} 733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );733 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) ); 734 734 dtorCaller->fixUniqueId(); 735 735 dtorCaller->get_statements()->push_back( dtorStmt ); … … 764 764 // create a new object which is never used 765 765 static UniqueName dummyNamer( "_dummy" ); 766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static Class), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );766 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::StorageClasses( DeclarationNode::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } ); 767 767 return dummy; 768 768 } … … 821 821 void InsertDtors::visit( ObjectDecl * objDecl ) { 822 822 // remember non-static destructed objects so that their destructors can be inserted later 823 if ( ! objDecl->get_storageClasses() [ DeclarationNode::Static ]) {823 if ( ! objDecl->get_storageClasses().is_static ) { 824 824 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 825 825 // a decision should have been made by the resolver, so ctor and init are not both non-NULL -
src/InitTweak/GenInit.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:51:38201713 // Update Count : 1 7912 // Last Modified On : Mon Mar 13 23:59:09 2017 13 // Update Count : 180 14 14 // 15 15 … … 186 186 // C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension. 187 187 if ( ! inFunction ) return; 188 if ( storageClasses [ DeclarationNode::StaticClass]) return;188 if ( storageClasses.is_static ) return; 189 189 190 190 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { -
src/InitTweak/InitTweak.cc
r5a3ac84 r9b443c7f 260 260 (objDecl->get_init() == NULL || 261 261 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) 262 && ! objDecl->get_storageClasses() [ DeclarationNode::Extern ];262 && ! objDecl->get_storageClasses().is_extern; 263 263 } 264 264 -
src/Parser/DeclarationNode.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 17:28:56201713 // Update Count : 9 3712 // Last Modified On : Tue Mar 14 14:45:52 2017 13 // Update Count : 973 14 14 // 15 15 … … 90 90 newnode->type = maybeClone( type ); 91 91 newnode->storageClasses = storageClasses; 92 newnode->funcSpecs = funcSpecs; 92 93 newnode->bitfieldWidth = maybeClone( bitfieldWidth ); 93 newnode->funcSpecs = funcSpecs;94 94 newnode->enumeratorValue.reset( maybeClone( enumeratorValue.get() ) ); 95 95 newnode->hasEllipsis = hasEllipsis; … … 117 117 118 118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) { 119 if ( storageClasses. any() ) { // function specifiers?119 if ( storageClasses.val != 0 ) { // storage classes ? 120 120 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) { 121 121 if ( storageClasses[i] ) { … … 127 127 128 128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) { 129 if ( funcSpec. any() ) { // function specifiers?129 if ( funcSpec.val != 0 ) { // function specifiers ? 130 130 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) { 131 131 if ( funcSpec[i] ) { … … 202 202 203 203 204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses [ sc ] = true;204 DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) { 205 DeclarationNode * newnode = new DeclarationNode; 206 newnode->storageClasses = sc; 207 207 return newnode; 208 208 } // DeclarationNode::newStorageClass 209 209 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifierfs ) {211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs [ fs ] = true;210 DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) { 211 DeclarationNode * newnode = new DeclarationNode; 212 newnode->funcSpecs = fs; 213 213 return newnode; 214 214 } // DeclarationNode::newFuncSpecifier 215 215 216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) {216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifiers tq ) { 217 217 DeclarationNode * newnode = new DeclarationNode; 218 218 newnode->type = new TypeData(); 219 newnode->type->typeQualifiers [ tq ] = true;219 newnode->type->typeQualifiers = tq; 220 220 return newnode; 221 221 } // DeclarationNode::newQualifier … … 457 457 458 458 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 459 const Type Data::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization460 461 if ( (qsrc & qdst).any() ) { // common qualifier?462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find common qualifiers459 const TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization 460 461 if ( (qsrc.val & qdst.val) != 0 ) { // duplicates ? 462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates 463 463 if ( qsrc[i] && qdst[i] ) { 464 464 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] ); … … 469 469 470 470 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 471 if ( (funcSpecs & src->funcSpecs).any() ) { // common specifier?472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find common specifier471 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 472 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates 473 473 if ( funcSpecs[i] && src->funcSpecs[i] ) { 474 474 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] ); … … 477 477 } // if 478 478 479 if ( storageClasses != 0 && src->storageClasses!= 0 ) { // any reason to check ?480 if ( (storageClasses & src->storageClasses).any()) { // duplicates ?479 if ( storageClasses.val != 0 && src->storageClasses.val != 0 ) { // any reason to check ? 480 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 481 481 for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates 482 482 if ( storageClasses[i] && src->storageClasses[i] ) { … … 485 485 } // for 486 486 // src is the new item being added and has a single bit 487 } else if ( ! src->storageClasses [ Threadlocal ]) { // conflict ?488 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses. to_ulong()) - 1] +489 " & " + storageClassNames[ffs( src->storageClasses. to_ulong()) - 1] );490 src->storageClasses. reset(); // FIX to preserve invariant of one basic storage specifier487 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 488 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] + 489 " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] ); 490 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 491 491 } // if 492 492 } // if … … 496 496 497 497 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 498 funcSpecs = funcSpecs | q->funcSpecs;499 storageClasses = storageClasses | q->storageClasses;498 funcSpecs.val = funcSpecs.val | q->funcSpecs.val; 499 storageClasses.val = storageClasses.val | q->storageClasses.val; 500 500 501 501 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 520 520 src = nullptr; 521 521 } else { 522 dst->typeQualifiers |= src->typeQualifiers;522 dst->typeQualifiers.val |= src->typeQualifiers.val; 523 523 } // if 524 524 } // addQualifiersToType … … 578 578 switch ( dst->kind ) { 579 579 case TypeData::Unknown: 580 src->typeQualifiers |= dst->typeQualifiers;580 src->typeQualifiers.val |= dst->typeQualifiers.val; 581 581 dst = src; 582 582 src = nullptr; 583 583 break; 584 584 case TypeData::Basic: 585 dst->typeQualifiers |= src->typeQualifiers;585 dst->typeQualifiers.val |= src->typeQualifiers.val; 586 586 if ( src->kind != TypeData::Unknown ) { 587 587 assert( src->kind == TypeData::Basic ); … … 619 619 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 620 620 } // if 621 dst->base->typeQualifiers |= src->typeQualifiers;621 dst->base->typeQualifiers.val |= src->typeQualifiers.val; 622 622 src = nullptr; 623 623 break; … … 651 651 type->aggInst.hoistType = o->type->enumeration.body; 652 652 } // if 653 type->typeQualifiers |= o->type->typeQualifiers;653 type->typeQualifiers.val |= o->type->typeQualifiers.val; 654 654 } else { 655 655 type = o->type; … … 807 807 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 808 808 } // if 809 p->type->base->typeQualifiers |= type->typeQualifiers;809 p->type->base->typeQualifiers.val |= type->typeQualifiers.val; 810 810 break; 811 811 … … 844 844 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 845 845 } // if 846 lastArray->base->typeQualifiers |= type->typeQualifiers;846 lastArray->base->typeQualifiers.val |= type->typeQualifiers.val; 847 847 break; 848 848 default: … … 1058 1058 // inline _Noreturn int g( int i ); // allowed 1059 1059 // inline _Noreturn int i; // disallowed 1060 if ( type->kind != TypeData::Function && funcSpecs. any()) {1060 if ( type->kind != TypeData::Function && funcSpecs.val != 0 ) { 1061 1061 throw SemanticError( "invalid function specifier for ", this ); 1062 1062 } // if … … 1068 1068 // inlne _Noreturn struct S { ... }; // disallowed 1069 1069 // inlne _Noreturn enum E { ... }; // disallowed 1070 if ( funcSpecs. any()) {1070 if ( funcSpecs.val != 0 ) { 1071 1071 throw SemanticError( "invalid function specifier for ", this ); 1072 1072 } // if -
src/Parser/ParseNode.h
r5a3ac84 r9b443c7f 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 08:10:53201713 // Update Count : 7 2612 // Last Modified On : Tue Mar 14 16:53:19 2017 13 // Update Count : 757 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset>22 21 #include <iterator> 23 22 #include <memory> … … 204 203 // These must remain in the same order as the corresponding DeclarationNode names. 205 204 206 enum StorageClass { Extern, Static, Auto, Register, Threadlocal, NoStorageClass, 207 ExternClass = 1 << Extern, StaticClass = 1 << Static, AutoClass = 1 << Auto, RegisterClass = 1 << Register, ThreadlocalClass = 1 << Threadlocal }; 208 enum FuncSpecifier { Inline, Noreturn, Fortran, NoFuncSpecifier, 209 InlineSpec = 1 << Inline, NoreturnSpec = 1 << Noreturn, FortranSpec = 1 << Fortran }; 210 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier }; 205 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 }; 206 union StorageClasses { 207 unsigned int val; 208 struct { 209 bool is_extern : 1; 210 bool is_static : 1; 211 bool is_auto : 1; 212 bool is_register : 1; 213 bool is_threadlocal : 1; 214 }; 215 StorageClasses() : val( 0 ) {} 216 StorageClasses( unsigned int val ) : val( val ) {} 217 bool operator[]( unsigned int i ) const { return val & (1 << i); } 218 }; // StorageClasses 219 220 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 }; 221 union FuncSpecifiers { 222 unsigned int val; 223 struct { 224 bool is_inline : 1; 225 bool is_noreturn : 1; 226 bool is_fortran : 1; 227 }; 228 FuncSpecifiers() : val( 0 ) {} 229 FuncSpecifiers( unsigned int val ) : val( val ) {} 230 bool operator[]( unsigned int i ) const { return val & (1 << i); } 231 }; // FuncSpecifiers 232 233 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NoTypeQualifier = 6 }; 234 union TypeQualifiers { 235 unsigned int val; 236 struct { 237 bool is_const : 1; 238 bool is_restrict : 1; 239 bool is_volatile : 1; 240 bool is_lvalue : 1; 241 bool is_mutex : 1; 242 bool is_atomic : 1; 243 }; 244 TypeQualifiers() : val( 0 ) {} 245 TypeQualifiers( unsigned int val ) : val( val ) {} 246 bool operator[]( unsigned int i ) const { return val & (1 << i); } 247 }; // TypeQualifiers 248 211 249 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 212 250 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 228 266 static const char * builtinTypeNames[]; 229 267 230 static DeclarationNode * newStorageClass( StorageClass );231 static DeclarationNode * newFuncSpecifier( FuncSpecifier );232 static DeclarationNode * newTypeQualifier( TypeQualifier );268 static DeclarationNode * newStorageClass( StorageClasses ); 269 static DeclarationNode * newFuncSpecifier( FuncSpecifiers ); 270 static DeclarationNode * newTypeQualifier( TypeQualifiers ); 233 271 static DeclarationNode * newBasicType( BasicType ); 234 272 static DeclarationNode * newComplexType( ComplexType ); … … 326 364 TypeData * type; 327 365 328 typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses;329 366 StorageClasses storageClasses; 330 367 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses ); 331 368 332 typedef std::bitset< DeclarationNode::NoFuncSpecifier > FuncSpecifiers;333 369 FuncSpecifiers funcSpecs; 334 370 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs ); -
src/Parser/TypeData.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 08:08:21201713 // Update Count : 5 3812 // Last Modified On : Tue Mar 14 15:01:44 2017 13 // Update Count : 548 14 14 // 15 15 … … 26 26 using namespace std; 27 27 28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ { 29 29 switch ( kind ) { 30 30 case Unknown: … … 50 50 function.newStyle = false; 51 51 break; 52 // Enum is an Aggregate, so both structures are initialized together. 53 case Enum: 54 // enumeration = new Enumeration_t; 55 enumeration.name = nullptr; 56 enumeration.constants = nullptr; 57 enumeration.body = false; 52 58 case Aggregate: 53 59 // aggregate = new Aggregate_t; … … 63 69 aggInst.params = nullptr; 64 70 aggInst.hoistType = false;; 65 break;66 case Enum:67 // enumeration = new Enumeration_t;68 enumeration.name = nullptr;69 enumeration.constants = nullptr;70 enumeration.body = false;71 71 break; 72 72 case Symbolic: … … 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 495 Type::Qualifiers q; 496 q.isConst = td->typeQualifiers [ DeclarationNode::Const ];497 q.isVolatile = td->typeQualifiers [ DeclarationNode::Volatile ];498 q.isRestrict = td->typeQualifiers [ DeclarationNode::Restrict ];499 q.isLvalue = td->typeQualifiers [ DeclarationNode::Lvalue ];500 q.isAtomic = td->typeQualifiers [ DeclarationNode::Atomic ];;496 q.isConst = td->typeQualifiers.is_const; 497 q.isVolatile = td->typeQualifiers.is_volatile; 498 q.isRestrict = td->typeQualifiers.is_restrict; 499 q.isLvalue = td->typeQualifiers.is_lvalue; 500 q.isAtomic = td->typeQualifiers.is_atomic; 501 501 return q; 502 502 } // buildQualifiers -
src/Parser/TypeData.h
r5a3ac84 r9b443c7f 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 8 22:28:33201713 // Update Count : 1 7412 // Last Modified On : Tue Mar 14 16:51:26 2017 13 // Update Count : 181 14 14 // 15 15 16 16 #ifndef TYPEDATA_H 17 17 #define TYPEDATA_H 18 19 #include <bitset>20 18 21 19 #include "ParseNode.h" … … 77 75 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 78 76 79 typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers; 80 TypeQualifiers typeQualifiers; 77 DeclarationNode::TypeQualifiers typeQualifiers; 81 78 DeclarationNode * forall; 82 79 -
src/SymTab/Autogen.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:42:44201713 // Update Count : 5 112 // Last Modified On : Tue Mar 14 07:45:00 2017 13 // Update Count : 54 14 14 // 15 15 … … 162 162 // because each unit generates copies of the default routines for each aggregate. 163 163 // DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static Class);164 DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::Static ); 165 165 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 166 166 FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ), 167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) );167 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ); 168 168 decl->fixUniqueId(); 169 169 return decl; … … 720 720 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 721 721 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );722 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 723 723 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );724 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 725 725 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );726 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 727 727 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline Spec) ) );728 std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::Inline ) ) ); 729 729 typeParams.push_back( newDecl ); 730 730 done.insert( ty->get_baseType() ); -
src/SymTab/Autogen.h
r5a3ac84 r9b443c7f 58 58 assert( type ); 59 59 Type * castType = type->clone(); 60 castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true );60 castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 61 61 castType->set_isLvalue( true ); // xxx - might not need this 62 62 dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) ); -
src/SymTab/Indexer.cc
r5a3ac84 r9b443c7f 10 10 // Created On : Sun May 17 21:37:33 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:45:32201713 // Update Count : 1 612 // Last Modified On : Tue Mar 14 08:07:34 2017 13 // Update Count : 17 14 14 // 15 15 … … 738 738 ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added ); 739 739 ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing ); 740 if ( ! newobj->get_storageClasses() [ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ]) {740 if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) { 741 741 throw SemanticError( "duplicate object definition for ", added ); 742 742 } // if -
src/SymTab/Validate.cc
r5a3ac84 r9b443c7f 323 323 ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i ); 324 324 assert( obj ); 325 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false ), enumDecl->get_name() ) );325 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) ); 326 326 } // for 327 327 Parent::visit( enumDecl ); -
src/SynTree/Type.h
r5a3ac84 r9b443c7f 25 25 public: 26 26 struct Qualifiers { 27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic) {}27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {} 28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {} 29 29 30 30 Qualifiers &operator&=( const Qualifiers &other ); … … 45 45 bool isLvalue; 46 46 bool isAtomic; 47 bool isMutex; 47 48 }; 48 49 … … 511 512 isLvalue &= other.isLvalue; 512 513 isAtomic &= other.isAtomic; 514 isMutex &= other.isMutex; 513 515 return *this; 514 516 } … … 520 522 isLvalue |= other.isLvalue; 521 523 isAtomic |= other.isAtomic; 524 isMutex |= other.isMutex; 522 525 return *this; 523 526 } … … 528 531 if ( other.isRestrict ) isRestrict = 0; 529 532 if ( other.isAtomic ) isAtomic = 0; 533 if ( other.isMutex ) isMutex = 0; 530 534 return *this; 531 535 } -
src/Tuples/TupleAssignment.cc
r5a3ac84 r9b443c7f 199 199 Type * type = InitTweak::getPointerBase( castType ); 200 200 assert( type ); 201 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true );201 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 202 202 type->set_isLvalue( true ); // xxx - might not need this 203 203 expr = new CastExpr( expr, castType ); -
src/Tuples/TupleExpansion.cc
r5a3ac84 r9b443c7f 305 305 Type * makeTupleType( const std::list< Expression * > & exprs ) { 306 306 // produce the TupleType which aggregates the types of the exprs 307 TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true ) );307 TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) ); 308 308 Type::Qualifiers &qualifiers = tupleType->get_qualifiers(); 309 309 for ( Expression * expr : exprs ) { -
src/benchmark/CorCtxSwitch.c
r5a3ac84 r9b443c7f 1 1 #include <fstream> 2 2 #include <stdlib> 3 #include <thread s>3 #include <thread> 4 4 5 5 #include <unistd.h> // sysconf … … 24 24 25 25 struct GreatSuspender { 26 coroutine c;26 coroutine_desc c; 27 27 }; 28 28 -
src/benchmark/ThrdCtxSwitch.c
r5a3ac84 r9b443c7f 1 1 #include <fstream> 2 2 #include <stdlib> 3 #include <thread s>3 #include <thread> 4 4 5 5 #include <unistd.h> // sysconf -
src/benchmark/bench.c
r5a3ac84 r9b443c7f 2 2 #include <fstream> 3 3 #include <stdlib> 4 #include <thread s>4 #include <thread> 5 5 6 6 #include <unistd.h> // sysconf … … 86 86 //======================================= 87 87 88 struct CoroutineDummy { coroutine c; };88 struct CoroutineDummy { coroutine_desc c; }; 89 89 DECL_COROUTINE(CoroutineDummy); 90 90 void main(CoroutineDummy * this) {} … … 119 119 struct CoroutineResume { 120 120 int N; 121 coroutine c;121 coroutine_desc c; 122 122 }; 123 123 … … 150 150 //======================================= 151 151 152 struct ThreadDummy { thread t; };152 struct ThreadDummy { thread_desc t; }; 153 153 DECL_THREAD(ThreadDummy); 154 154 void main(ThreadDummy * this) {} … … 180 180 int N; 181 181 long long result; 182 thread t;182 thread_desc t; 183 183 }; 184 184 -
src/benchmark/csv-data.c
r5a3ac84 r9b443c7f 1 1 #include <fstream> 2 2 #include <stdlib> 3 #include <thread s>3 #include <thread> 4 4 5 5 extern "C" { … … 26 26 27 27 struct GreatSuspender { 28 coroutine c;28 coroutine_desc c; 29 29 }; 30 30 -
src/examples/multicore.c
r5a3ac84 r9b443c7f 1 1 #include <kernel> 2 #include <thread s>2 #include <thread> 3 3 4 struct MyThread { thread t; };4 struct MyThread { thread_desc t; }; 5 5 6 6 DECL_THREAD(MyThread); -
src/libcfa/Makefile.am
r5a3ac84 r9b443c7f 45 45 # not all platforms support concurrency, add option do disable it 46 46 if BUILD_CONCURRENCY 47 headers += containers/vector concurrency/coroutine s concurrency/threadsconcurrency/kernel concurrency/monitor47 headers += containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor 48 48 endif 49 49 -
src/libcfa/Makefile.in
r5a3ac84 r9b443c7f 43 43 44 44 # not all platforms support concurrency, add option do disable it 45 @BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutine s concurrency/threadsconcurrency/kernel concurrency/monitor45 @BUILD_CONCURRENCY_TRUE@am__append_3 = containers/vector concurrency/coroutine concurrency/thread concurrency/kernel concurrency/monitor 46 46 47 47 # not all platforms support concurrency, add option do disable it … … 99 99 am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c \ 100 100 math.c iostream.c fstream.c iterator.c rational.c assert.c \ 101 containers/vector.c concurrency/coroutine s.c \102 concurrency/thread s.c concurrency/kernel.c \101 containers/vector.c concurrency/coroutine.c \ 102 concurrency/thread.c concurrency/kernel.c \ 103 103 concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \ 104 104 concurrency/invoke.c 105 105 am__dirstamp = $(am__leading_dot)dirstamp 106 106 @BUILD_CONCURRENCY_TRUE@am__objects_1 = containers/libcfa_d_a-vector.$(OBJEXT) \ 107 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-coroutine s.$(OBJEXT) \108 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-thread s.$(OBJEXT) \107 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-coroutine.$(OBJEXT) \ 108 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-thread.$(OBJEXT) \ 109 109 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-kernel.$(OBJEXT) \ 110 110 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_d_a-monitor.$(OBJEXT) … … 124 124 am__libcfa_a_SOURCES_DIST = libcfa-prelude.c limits.c stdlib.c math.c \ 125 125 iostream.c fstream.c iterator.c rational.c assert.c \ 126 containers/vector.c concurrency/coroutine s.c \127 concurrency/thread s.c concurrency/kernel.c \126 containers/vector.c concurrency/coroutine.c \ 127 concurrency/thread.c concurrency/kernel.c \ 128 128 concurrency/monitor.c concurrency/CtxSwitch-@MACHINE_TYPE@.S \ 129 129 concurrency/invoke.c 130 130 @BUILD_CONCURRENCY_TRUE@am__objects_5 = \ 131 131 @BUILD_CONCURRENCY_TRUE@ containers/libcfa_a-vector.$(OBJEXT) \ 132 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-coroutine s.$(OBJEXT) \133 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-thread s.$(OBJEXT) \132 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-coroutine.$(OBJEXT) \ 133 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-thread.$(OBJEXT) \ 134 134 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-kernel.$(OBJEXT) \ 135 135 @BUILD_CONCURRENCY_TRUE@ concurrency/libcfa_a-monitor.$(OBJEXT) … … 175 175 am__nobase_cfa_include_HEADERS_DIST = limits stdlib math iostream \ 176 176 fstream iterator rational assert containers/vector \ 177 concurrency/coroutine s concurrency/threadsconcurrency/kernel \177 concurrency/coroutine concurrency/thread concurrency/kernel \ 178 178 concurrency/monitor ${shell echo stdhdr/*} \ 179 179 concurrency/invoke.h … … 397 397 @$(MKDIR_P) concurrency/$(DEPDIR) 398 398 @: > concurrency/$(DEPDIR)/$(am__dirstamp) 399 concurrency/libcfa_d_a-coroutine s.$(OBJEXT): \399 concurrency/libcfa_d_a-coroutine.$(OBJEXT): \ 400 400 concurrency/$(am__dirstamp) \ 401 401 concurrency/$(DEPDIR)/$(am__dirstamp) 402 concurrency/libcfa_d_a-thread s.$(OBJEXT): concurrency/$(am__dirstamp) \402 concurrency/libcfa_d_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \ 403 403 concurrency/$(DEPDIR)/$(am__dirstamp) 404 404 concurrency/libcfa_d_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \ … … 417 417 containers/libcfa_a-vector.$(OBJEXT): containers/$(am__dirstamp) \ 418 418 containers/$(DEPDIR)/$(am__dirstamp) 419 concurrency/libcfa_a-coroutines.$(OBJEXT): \ 420 concurrency/$(am__dirstamp) \ 419 concurrency/libcfa_a-coroutine.$(OBJEXT): concurrency/$(am__dirstamp) \ 421 420 concurrency/$(DEPDIR)/$(am__dirstamp) 422 concurrency/libcfa_a-thread s.$(OBJEXT): concurrency/$(am__dirstamp) \421 concurrency/libcfa_a-thread.$(OBJEXT): concurrency/$(am__dirstamp) \ 423 422 concurrency/$(DEPDIR)/$(am__dirstamp) 424 423 concurrency/libcfa_a-kernel.$(OBJEXT): concurrency/$(am__dirstamp) \ … … 436 435 -rm -f *.$(OBJEXT) 437 436 -rm -f concurrency/CtxSwitch-@MACHINE_TYPE@.$(OBJEXT) 438 -rm -f concurrency/libcfa_a-coroutine s.$(OBJEXT)437 -rm -f concurrency/libcfa_a-coroutine.$(OBJEXT) 439 438 -rm -f concurrency/libcfa_a-invoke.$(OBJEXT) 440 439 -rm -f concurrency/libcfa_a-kernel.$(OBJEXT) 441 440 -rm -f concurrency/libcfa_a-monitor.$(OBJEXT) 442 -rm -f concurrency/libcfa_a-thread s.$(OBJEXT)443 -rm -f concurrency/libcfa_d_a-coroutine s.$(OBJEXT)441 -rm -f concurrency/libcfa_a-thread.$(OBJEXT) 442 -rm -f concurrency/libcfa_d_a-coroutine.$(OBJEXT) 444 443 -rm -f concurrency/libcfa_d_a-invoke.$(OBJEXT) 445 444 -rm -f concurrency/libcfa_d_a-kernel.$(OBJEXT) 446 445 -rm -f concurrency/libcfa_d_a-monitor.$(OBJEXT) 447 -rm -f concurrency/libcfa_d_a-thread s.$(OBJEXT)446 -rm -f concurrency/libcfa_d_a-thread.$(OBJEXT) 448 447 -rm -f containers/libcfa_a-vector.$(OBJEXT) 449 448 -rm -f containers/libcfa_d_a-vector.$(OBJEXT) … … 471 470 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-stdlib.Po@am__quote@ 472 471 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/CtxSwitch-@MACHINE_TYPE@.Po@am__quote@ 473 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine s.Po@am__quote@472 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-coroutine.Po@am__quote@ 474 473 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-invoke.Po@am__quote@ 475 474 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-kernel.Po@am__quote@ 476 475 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-monitor.Po@am__quote@ 477 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread s.Po@am__quote@478 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine s.Po@am__quote@476 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_a-thread.Po@am__quote@ 477 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po@am__quote@ 479 478 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-invoke.Po@am__quote@ 480 479 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-kernel.Po@am__quote@ 481 480 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-monitor.Po@am__quote@ 482 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread s.Po@am__quote@481 @AMDEP_TRUE@@am__include@ @am__quote@concurrency/$(DEPDIR)/libcfa_d_a-thread.Po@am__quote@ 483 482 @AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_a-vector.Po@am__quote@ 484 483 @AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/libcfa_d_a-vector.Po@am__quote@ … … 649 648 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_d_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi` 650 649 651 concurrency/libcfa_d_a-coroutine s.o: concurrency/coroutines.c652 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo -c -o concurrency/libcfa_d_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c653 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po654 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_d_a-coroutines.o' libtool=no @AMDEPBACKSLASH@655 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 656 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine s.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c657 658 concurrency/libcfa_d_a-coroutine s.obj: concurrency/coroutines.c659 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Tpo -c -o concurrency/libcfa_d_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`660 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutines.Po661 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_d_a-coroutines.obj' libtool=no @AMDEPBACKSLASH@662 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 663 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine s.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`664 665 concurrency/libcfa_d_a-thread s.o: concurrency/threads.c666 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo -c -o concurrency/libcfa_d_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c667 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-threads.Po668 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_d_a-threads.o' libtool=no @AMDEPBACKSLASH@669 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 670 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread s.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c671 672 concurrency/libcfa_d_a-thread s.obj: concurrency/threads.c673 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-threads.Tpo -c -o concurrency/libcfa_d_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`674 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_d_a-threads.Po675 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_d_a-threads.obj' libtool=no @AMDEPBACKSLASH@676 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 677 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread s.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`650 concurrency/libcfa_d_a-coroutine.o: concurrency/coroutine.c 651 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo -c -o concurrency/libcfa_d_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 652 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po 653 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_d_a-coroutine.o' libtool=no @AMDEPBACKSLASH@ 654 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 655 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 656 657 concurrency/libcfa_d_a-coroutine.obj: concurrency/coroutine.c 658 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo -c -o concurrency/libcfa_d_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 659 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_d_a-coroutine.Po 660 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_d_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@ 661 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 662 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 663 664 concurrency/libcfa_d_a-thread.o: concurrency/thread.c 665 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo -c -o concurrency/libcfa_d_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 666 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_d_a-thread.Po 667 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_d_a-thread.o' libtool=no @AMDEPBACKSLASH@ 668 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 669 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 670 671 concurrency/libcfa_d_a-thread.obj: concurrency/thread.c 672 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo -c -o concurrency/libcfa_d_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 673 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_d_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_d_a-thread.Po 674 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_d_a-thread.obj' libtool=no @AMDEPBACKSLASH@ 675 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 676 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 678 677 679 678 concurrency/libcfa_d_a-kernel.o: concurrency/kernel.c … … 845 844 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o containers/libcfa_a-vector.obj `if test -f 'containers/vector.c'; then $(CYGPATH_W) 'containers/vector.c'; else $(CYGPATH_W) '$(srcdir)/containers/vector.c'; fi` 846 845 847 concurrency/libcfa_a-coroutine s.o: concurrency/coroutines.c848 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo -c -o concurrency/libcfa_a-coroutines.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c849 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutines.Po850 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_a-coroutines.o' libtool=no @AMDEPBACKSLASH@851 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 852 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine s.o `test -f 'concurrency/coroutines.c' || echo '$(srcdir)/'`concurrency/coroutines.c853 854 concurrency/libcfa_a-coroutine s.obj: concurrency/coroutines.c855 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutines.Tpo -c -o concurrency/libcfa_a-coroutines.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`856 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine s.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutines.Po857 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine s.c' object='concurrency/libcfa_a-coroutines.obj' libtool=no @AMDEPBACKSLASH@858 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 859 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine s.obj `if test -f 'concurrency/coroutines.c'; then $(CYGPATH_W) 'concurrency/coroutines.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutines.c'; fi`860 861 concurrency/libcfa_a-thread s.o: concurrency/threads.c862 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread s.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-threads.Tpo -c -o concurrency/libcfa_a-threads.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c863 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_a-threads.Po864 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_a-threads.o' libtool=no @AMDEPBACKSLASH@865 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 866 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread s.o `test -f 'concurrency/threads.c' || echo '$(srcdir)/'`concurrency/threads.c867 868 concurrency/libcfa_a-thread s.obj: concurrency/threads.c869 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread s.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-threads.Tpo -c -o concurrency/libcfa_a-threads.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`870 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread s.Tpo concurrency/$(DEPDIR)/libcfa_a-threads.Po871 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread s.c' object='concurrency/libcfa_a-threads.obj' libtool=no @AMDEPBACKSLASH@872 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 873 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread s.obj `if test -f 'concurrency/threads.c'; then $(CYGPATH_W) 'concurrency/threads.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/threads.c'; fi`846 concurrency/libcfa_a-coroutine.o: concurrency/coroutine.c 847 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 848 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po 849 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.o' libtool=no @AMDEPBACKSLASH@ 850 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 851 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.o `test -f 'concurrency/coroutine.c' || echo '$(srcdir)/'`concurrency/coroutine.c 852 853 concurrency/libcfa_a-coroutine.obj: concurrency/coroutine.c 854 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-coroutine.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 855 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-coroutine.Tpo concurrency/$(DEPDIR)/libcfa_a-coroutine.Po 856 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/coroutine.c' object='concurrency/libcfa_a-coroutine.obj' libtool=no @AMDEPBACKSLASH@ 857 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 858 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-coroutine.obj `if test -f 'concurrency/coroutine.c'; then $(CYGPATH_W) 'concurrency/coroutine.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/coroutine.c'; fi` 859 860 concurrency/libcfa_a-thread.o: concurrency/thread.c 861 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 862 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po 863 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.o' libtool=no @AMDEPBACKSLASH@ 864 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 865 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.o `test -f 'concurrency/thread.c' || echo '$(srcdir)/'`concurrency/thread.c 866 867 concurrency/libcfa_a-thread.obj: concurrency/thread.c 868 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_a-thread.obj -MD -MP -MF concurrency/$(DEPDIR)/libcfa_a-thread.Tpo -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 869 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) concurrency/$(DEPDIR)/libcfa_a-thread.Tpo concurrency/$(DEPDIR)/libcfa_a-thread.Po 870 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='concurrency/thread.c' object='concurrency/libcfa_a-thread.obj' libtool=no @AMDEPBACKSLASH@ 871 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 872 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-thread.obj `if test -f 'concurrency/thread.c'; then $(CYGPATH_W) 'concurrency/thread.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/thread.c'; fi` 874 873 875 874 concurrency/libcfa_a-kernel.o: concurrency/kernel.c -
src/libcfa/concurrency/invoke.c
r5a3ac84 r9b443c7f 29 29 30 30 extern void __suspend_internal(void); 31 extern void __thread_signal_termination(struct thread *);31 extern void __thread_signal_termination(struct thread_desc*); 32 32 33 33 void CtxInvokeCoroutine( 34 34 void (*main)(void *), 35 struct coroutine *(*get_coroutine)(void *),35 struct coroutine_desc *(*get_coroutine)(void *), 36 36 void *this 37 37 ) { 38 38 // LIB_DEBUG_PRINTF("Invoke Coroutine : Received %p (main %p, get_c %p)\n", this, main, get_coroutine); 39 39 40 struct coroutine * cor = get_coroutine( this );40 struct coroutine_desc* cor = get_coroutine( this ); 41 41 42 42 if(cor->state == Primed) { … … 57 57 void CtxInvokeThread( 58 58 void (*main)(void *), 59 struct thread *(*get_thread)(void *),59 struct thread_desc *(*get_thread)(void *), 60 60 void *this 61 61 ) { 62 62 __suspend_internal(); 63 63 64 struct thread * thrd = get_thread( this );65 struct coroutine * cor = &thrd->c;64 struct thread_desc* thrd = get_thread( this ); 65 struct coroutine_desc* cor = &thrd->c; 66 66 cor->state = Active; 67 67 … … 79 79 void CtxStart( 80 80 void (*main)(void *), 81 struct coroutine *(*get_coroutine)(void *),81 struct coroutine_desc *(*get_coroutine)(void *), 82 82 void *this, 83 83 void (*invoke)(void *) -
src/libcfa/concurrency/invoke.h
r5a3ac84 r9b443c7f 35 35 36 36 struct simple_thread_list { 37 struct thread * head;38 struct thread ** tail;37 struct thread_desc * head; 38 struct thread_desc ** tail; 39 39 }; 40 40 … … 48 48 extern "Cforall" { 49 49 void ?{}( struct simple_thread_list * ); 50 void append( struct simple_thread_list *, struct thread * );51 struct thread * pop_head( struct simple_thread_list * );50 void append( struct simple_thread_list *, struct thread_desc * ); 51 struct thread_desc * pop_head( struct simple_thread_list * ); 52 52 53 53 void ?{}(spinlock * this); … … 71 71 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 72 72 73 struct coroutine {73 struct coroutine_desc { 74 74 struct coStack_t stack; 75 75 const char *name; // textual name for coroutine/task, initialized by uC++ generated code 76 76 int errno_; // copy of global UNIX variable errno 77 77 enum coroutine_state state; // current execution status for coroutine 78 struct coroutine *starter; // first coroutine to resume this one79 struct coroutine *last; // last coroutine to resume this one78 struct coroutine_desc *starter; // first coroutine to resume this one 79 struct coroutine_desc *last; // last coroutine to resume this one 80 80 }; 81 81 82 struct thread {83 struct coroutine c; // coroutine body used to store context82 struct thread_desc { 83 struct coroutine_desc c; // coroutine body used to store context 84 84 struct signal_once terminated; // indicate if execuation state is not halted 85 struct thread * next; // instrusive link field for threads85 struct thread_desc * next; // instrusive link field for threads 86 86 }; 87 87 -
src/libcfa/concurrency/kernel
r5a3ac84 r9b443c7f 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // threads--8 // kernel -- 9 9 // 10 10 // Author : Thierry Delisle … … 49 49 struct FinishAction { 50 50 FinishOpCode action_code; 51 thread * thrd;51 thread_desc * thrd; 52 52 spinlock * lock; 53 53 }; … … 62 62 struct processorCtx_t * runner; 63 63 cluster * cltr; 64 coroutine * current_coroutine;65 thread * current_thread;64 coroutine_desc * current_coroutine; 65 thread_desc * current_thread; 66 66 pthread_t kernel_thread; 67 67 -
src/libcfa/concurrency/kernel.c
r5a3ac84 r9b443c7f 43 43 KERNEL_STORAGE(cluster, systemCluster); 44 44 KERNEL_STORAGE(processor, systemProcessor); 45 KERNEL_STORAGE(thread , mainThread);45 KERNEL_STORAGE(thread_desc, mainThread); 46 46 KERNEL_STORAGE(machine_context_t, mainThread_context); 47 47 48 48 cluster * systemCluster; 49 49 processor * systemProcessor; 50 thread * mainThread;50 thread_desc * mainThread; 51 51 52 52 //----------------------------------------------------------------------------- … … 55 55 thread_local processor * this_processor; 56 56 57 processor * get_this_processor() { 58 return this_processor; 59 } 60 61 coroutine * this_coroutine(void) { 57 coroutine_desc * this_coroutine(void) { 62 58 return this_processor->current_coroutine; 63 59 } 64 60 65 thread * this_thread(void) {61 thread_desc * this_thread(void) { 66 62 return this_processor->current_thread; 67 63 } … … 103 99 } 104 100 105 void ?{}( coroutine * this, current_stack_info_t * info) {101 void ?{}( coroutine_desc * this, current_stack_info_t * info) { 106 102 (&this->stack){ info }; 107 103 this->name = "Main Thread"; … … 110 106 } 111 107 112 void ?{}( thread * this, current_stack_info_t * info) {108 void ?{}( thread_desc * this, current_stack_info_t * info) { 113 109 (&this->c){ info }; 114 110 } … … 179 175 LIB_DEBUG_PRINTF("Kernel : core %p starting\n", this); 180 176 181 thread * readyThread = NULL;177 thread_desc * readyThread = NULL; 182 178 for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ ) 183 179 { … … 206 202 // runThread runs a thread by context switching 207 203 // from the processor coroutine to the target thread 208 void runThread(processor * this, thread * dst) {209 coroutine * proc_cor = get_coroutine(this->runner);210 coroutine * thrd_cor = get_coroutine(dst);204 void runThread(processor * this, thread_desc * dst) { 205 coroutine_desc * proc_cor = get_coroutine(this->runner); 206 coroutine_desc * thrd_cor = get_coroutine(dst); 211 207 212 208 //Reset the terminating actions here … … 297 293 //----------------------------------------------------------------------------- 298 294 // Scheduler routines 299 void ScheduleThread( thread * thrd ) {295 void ScheduleThread( thread_desc * thrd ) { 300 296 assertf( thrd->next == NULL, "Expected null got %p", thrd->next ); 301 297 … … 305 301 } 306 302 307 thread * nextThread(cluster * this) {303 thread_desc * nextThread(cluster * this) { 308 304 lock( &this->lock ); 309 thread * head = pop_head( &this->ready_queue );305 thread_desc * head = pop_head( &this->ready_queue ); 310 306 unlock( &this->lock ); 311 307 return head; … … 317 313 318 314 void ScheduleInternal( spinlock * lock ) { 319 get_this_processor()->finish.action_code = Release;320 get_this_processor()->finish.lock = lock;315 this_processor->finish.action_code = Release; 316 this_processor->finish.lock = lock; 321 317 suspend(); 322 318 } 323 319 324 void ScheduleInternal( thread * thrd ) {325 get_this_processor()->finish.action_code = Schedule;326 get_this_processor()->finish.thrd = thrd;320 void ScheduleInternal( thread_desc * thrd ) { 321 this_processor->finish.action_code = Schedule; 322 this_processor->finish.thrd = thrd; 327 323 suspend(); 328 324 } 329 325 330 void ScheduleInternal( spinlock * lock, thread * thrd ) {331 get_this_processor()->finish.action_code = Release_Schedule;332 get_this_processor()->finish.lock = lock;333 get_this_processor()->finish.thrd = thrd;326 void ScheduleInternal( spinlock * lock, thread_desc * thrd ) { 327 this_processor->finish.action_code = Release_Schedule; 328 this_processor->finish.lock = lock; 329 this_processor->finish.thrd = thrd; 334 330 suspend(); 335 331 } … … 343 339 // SKULLDUGGERY: the mainThread steals the process main thread 344 340 // which will then be scheduled by the systemProcessor normally 345 mainThread = (thread *)&mainThread_storage;341 mainThread = (thread_desc *)&mainThread_storage; 346 342 current_stack_info_t info; 347 343 mainThread{ &info }; … … 440 436 this->condition = true; 441 437 442 thread * it;438 thread_desc * it; 443 439 while( it = pop_head( &this->blocked) ) { 444 440 ScheduleThread( it ); … … 455 451 } 456 452 457 void append( simple_thread_list * this, thread * t ) {453 void append( simple_thread_list * this, thread_desc * t ) { 458 454 assert(this->tail != NULL); 459 455 *this->tail = t; … … 461 457 } 462 458 463 thread * pop_head( simple_thread_list * this ) {464 thread * head = this->head;459 thread_desc * pop_head( simple_thread_list * this ) { 460 thread_desc * head = this->head; 465 461 if( head ) { 466 462 this->head = head->next; -
src/libcfa/concurrency/kernel_private.h
r5a3ac84 r9b443c7f 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // threads--8 // kernel_private.h -- 9 9 // 10 10 // Author : Thierry Delisle … … 19 19 20 20 #include "kernel" 21 #include "thread s"21 #include "thread" 22 22 23 23 //----------------------------------------------------------------------------- 24 24 // Scheduler 25 void ScheduleThread( thread * );26 thread * nextThread(cluster * this);25 void ScheduleThread( thread_desc * ); 26 thread_desc * nextThread(cluster * this); 27 27 28 28 void ScheduleInternal(); 29 29 void ScheduleInternal(spinlock * lock); 30 void ScheduleInternal(thread * thrd);31 void ScheduleInternal(spinlock * lock, thread * thrd);30 void ScheduleInternal(thread_desc * thrd); 31 void ScheduleInternal(spinlock * lock, thread_desc * thrd); 32 32 33 33 //----------------------------------------------------------------------------- … … 35 35 struct processorCtx_t { 36 36 processor * proc; 37 coroutine c;37 coroutine_desc c; 38 38 }; 39 39 … … 42 42 void main(processorCtx_t *); 43 43 void start(processor * this); 44 void runThread(processor * this, thread * dst);44 void runThread(processor * this, thread_desc * dst); 45 45 void finishRunning(processor * this); 46 46 void spin(processor * this, unsigned int * spin_count); … … 53 53 } 54 54 55 extern void ThreadCtxSwitch(coroutine * src, coroutine* dst);55 extern void ThreadCtxSwitch(coroutine_desc * src, coroutine_desc * dst); 56 56 57 57 #endif //KERNEL_PRIVATE_H -
src/libcfa/concurrency/monitor
r5a3ac84 r9b443c7f 22 22 #include "stdlib" 23 23 24 struct __monitor_t{24 struct monitor_desc { 25 25 spinlock lock; 26 thread * owner;26 thread_desc * owner; 27 27 simple_thread_list entry_queue; 28 28 unsigned int recursion; 29 29 }; 30 30 31 static inline void ?{}( __monitor_t* this) {31 static inline void ?{}(monitor_desc * this) { 32 32 this->owner = 0; 33 33 this->recursion = 0; … … 35 35 36 36 //Basic entering routine 37 void enter( __monitor_t*);38 void leave( __monitor_t*);37 void enter(monitor_desc *); 38 void leave(monitor_desc *); 39 39 40 40 //Array entering routine 41 void enter( __monitor_t**, int count);42 void leave( __monitor_t**, int count);41 void enter(monitor_desc **, int count); 42 void leave(monitor_desc **, int count); 43 43 44 44 struct monitor_guard_t { 45 __monitor_t** m;45 monitor_desc ** m; 46 46 int count; 47 47 }; 48 48 49 static inline int ?<?( __monitor_t* lhs, __monitor_t* rhs) {49 static inline int ?<?(monitor_desc* lhs, monitor_desc* rhs) { 50 50 return ((intptr_t)lhs) < ((intptr_t)rhs); 51 51 } 52 52 53 static inline void ?{}( monitor_guard_t * this, __monitor_t** m ) {53 static inline void ?{}( monitor_guard_t * this, monitor_desc ** m ) { 54 54 this->m = m; 55 55 this->count = 1; … … 57 57 } 58 58 59 static inline void ?{}( monitor_guard_t * this, __monitor_t** m, int count ) {59 static inline void ?{}( monitor_guard_t * this, monitor_desc ** m, int count ) { 60 60 this->m = m; 61 61 this->count = count; -
src/libcfa/concurrency/monitor.c
r5a3ac84 r9b443c7f 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // __monitor_t.c --8 // monitor_desc.c -- 9 9 // 10 10 // Author : Thierry Delisle … … 19 19 #include "kernel_private.h" 20 20 21 void enter( __monitor_t* this) {21 void enter(monitor_desc * this) { 22 22 lock( &this->lock ); 23 thread * thrd = this_thread();23 thread_desc * thrd = this_thread(); 24 24 25 25 if( !this->owner ) { … … 45 45 } 46 46 47 void leave( __monitor_t* this) {47 void leave(monitor_desc * this) { 48 48 lock( &this->lock ); 49 49 50 thread * thrd = this_thread();50 thread_desc * thrd = this_thread(); 51 51 assert( thrd == this->owner ); 52 52 … … 55 55 56 56 //If we left the last level of recursion it means we are changing who owns the monitor 57 thread * new_owner = 0;57 thread_desc * new_owner = 0; 58 58 if( this->recursion == 0) { 59 59 //Get the next thread in the list … … 72 72 } 73 73 74 void enter( __monitor_t** monitors, int count) {74 void enter(monitor_desc ** monitors, int count) { 75 75 for(int i = 0; i < count; i++) { 76 76 // printf("%d\n", i); … … 79 79 } 80 80 81 void leave( __monitor_t** monitors, int count) {81 void leave(monitor_desc ** monitors, int count) { 82 82 for(int i = count - 1; i >= 0; i--) { 83 83 // printf("%d\n", i); -
src/main.cc
r5a3ac84 r9b443c7f 32 32 #include "GenPoly/CopyParams.h" 33 33 #include "GenPoly/InstantiateGeneric.h" 34 #include "Concurrency/Keywords.h" 34 35 #include "CodeGen/Generate.h" 35 36 #include "CodeGen/FixNames.h" … … 236 237 OPTPRINT( "mutate" ) 237 238 ControlStruct::mutate( translationUnit ); 239 OPTPRINT( "Concurrency" ) 240 Concurrency::applyKeywords( translationUnit ); 238 241 OPTPRINT( "fixNames" ) 239 242 CodeGen::fixNames( translationUnit ); -
src/tests/coroutine.c
r5a3ac84 r9b443c7f 1 1 #include <fstream> 2 #include <coroutine s>2 #include <coroutine> 3 3 4 4 struct Fibonacci { 5 5 int fn; // used for communication 6 coroutine c;6 coroutine_desc c; 7 7 }; 8 8 … … 11 11 } 12 12 13 coroutine * get_coroutine(Fibonacci* this) {13 coroutine_desc* get_coroutine(Fibonacci* this) { 14 14 return &this->c; 15 15 } … … 47 47 #ifdef MORE_DEBUG 48 48 Fibonacci *pf1 = &f1, *pf2 = &f2; 49 coroutine *cf1 = &f1.c, *cf2 = &f2.c;49 coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c; 50 50 covptr_t *vf1 = vtable(pf1), *vf2 = vtable(pf2); 51 coroutine *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);51 coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2); 52 52 Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2); 53 53 -
src/tests/monitor.c
r5a3ac84 r9b443c7f 2 2 #include <kernel> 3 3 #include <monitor> 4 #include <thread s>4 #include <thread> 5 5 6 6 struct global_t { 7 7 int value; 8 __monitor_tm;8 monitor_desc m; 9 9 }; 10 10 … … 16 16 17 17 void increment( /*mutex*/ global_t * this ) { 18 __monitor_t* mon = &this->m;18 monitor_desc * mon = &this->m; 19 19 monitor_guard_t g1 = { &mon }; 20 20 { … … 27 27 } 28 28 29 struct MyThread { thread t; };29 struct MyThread { thread_desc t; }; 30 30 31 31 DECL_THREAD(MyThread); -
src/tests/multi-monitor.c
r5a3ac84 r9b443c7f 2 2 #include <kernel> 3 3 #include <monitor> 4 #include <thread s>4 #include <thread> 5 5 6 6 static int global12, global23, global13; 7 7 8 static __monitor_tm1, m2, m3;8 static monitor_desc m1, m2, m3; 9 9 10 void increment( /*mutex*/ __monitor_t * p1, /*mutex*/ __monitor_t* p2, int * value ) {11 __monitor_t* mons[] = { p1, p2 };10 void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) { 11 monitor_desc * mons[] = { p1, p2 }; 12 12 monitor_guard_t g = { mons, 2 }; 13 13 *value += 1; … … 15 15 16 16 struct MyThread { 17 thread t;17 thread_desc t; 18 18 int target; 19 19 }; -
src/tests/test.py
r5a3ac84 r9b443c7f 250 250 parser = argparse.ArgumentParser(description='Script which runs cforall tests') 251 251 parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='no') 252 parser.add_argument('--concurrent', help='Run concurrent tests', type=yes_no, default=' no')252 parser.add_argument('--concurrent', help='Run concurrent tests', type=yes_no, default='yes') 253 253 parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true') 254 254 parser.add_argument('--list', help='List all test available', action='store_true') -
src/tests/thread.c
r5a3ac84 r9b443c7f 2 2 #include <kernel> 3 3 #include <stdlib> 4 #include <thread s>4 #include <thread> 5 5 6 struct First { thread t; signal_once* lock; };7 struct Second { thread t; signal_once* lock; };6 struct First { thread_desc t; signal_once* lock; }; 7 struct Second { thread_desc t; signal_once* lock; }; 8 8 9 9 DECL_THREAD(First);
Note: See TracChangeset
for help on using the changeset viewer.