- Timestamp:
- Feb 26, 2018, 12:49:55 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:
- eddb399
- Parents:
- 17fc7a5 (diff), 2c39855 (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. - Location:
- src
- Files:
-
- 2 added
- 21 edited
-
Parser/DeclarationNode.cc (modified) (3 diffs)
-
Parser/ParseNode.h (modified) (4 diffs)
-
Parser/TypeData.cc (modified) (4 diffs)
-
Parser/TypeData.h (modified) (2 diffs)
-
Parser/lex.ll (modified) (2 diffs)
-
Parser/parser.yy (modified) (13 diffs)
-
benchmark/bench.h (modified) (2 diffs)
-
libcfa/Makefile.am (modified) (1 diff)
-
libcfa/Makefile.in (modified) (2 diffs)
-
libcfa/bits/cfatime.h (modified) (2 diffs)
-
libcfa/concurrency/coroutine.c (modified) (2 diffs)
-
libcfa/concurrency/kernel (modified) (2 diffs)
-
libcfa/concurrency/kernel.c (modified) (20 diffs)
-
libcfa/concurrency/kernel_private.h (modified) (2 diffs)
-
libcfa/concurrency/preemption.c (modified) (8 diffs)
-
libcfa/concurrency/preemption.h (modified) (1 diff)
-
libcfa/concurrency/thread.c (modified) (1 diff)
-
libcfa/exception.c (modified) (10 diffs)
-
libcfa/exception.h (modified) (5 diffs)
-
libcfa/stdhdr/math.h (modified) (1 diff)
-
prelude/builtins.c (modified) (1 diff)
-
tests/.expect/counter.txt (added)
-
tests/counter.c (added)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r17fc7a5 r45c43e5 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 20 09:21:52 201713 // Update Count : 103 112 // Last Modified On : Thu Feb 22 15:37:17 2018 13 // Update Count : 1033 14 14 // 15 15 … … 120 120 } // DeclarationNode::clone 121 121 122 bool DeclarationNode::get_hasEllipsis() const {123 return hasEllipsis;124 }125 126 122 void DeclarationNode::print( std::ostream &os, int indent ) const { 127 123 os << string( indent, ' ' ); … … 167 163 } 168 164 169 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body , bool newStyle) {165 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) { 170 166 DeclarationNode * newnode = new DeclarationNode; 171 167 newnode->name = name; 172 168 newnode->type = new TypeData( TypeData::Function ); 173 169 newnode->type->function.params = param; 174 newnode->type->function.newStyle = newStyle;175 170 newnode->type->function.body = body; 176 171 -
src/Parser/ParseNode.h
r17fc7a5 r45c43e5 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Nov 27 17:33:35 201713 // Update Count : 82 412 // Last Modified On : Thu Feb 22 17:49:31 2018 13 // Update Count : 827 14 14 // 15 15 … … 209 209 enum Length { Short, Long, LongLong, NoLength }; 210 210 static const char * lengthNames[]; 211 enum Aggregate { Struct, Union, Trait, Coroutine, Monitor, Thread, NoAggregate };211 enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate }; 212 212 static const char * aggregateNames[]; 213 213 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; … … 226 226 static DeclarationNode * newForall( DeclarationNode * ); 227 227 static DeclarationNode * newFromTypedef( std::string * ); 228 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body , bool newStyle = false);228 static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 229 229 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 230 230 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body ); … … 288 288 Type * buildType() const; 289 289 290 bool get_hasEllipsis() const;291 290 LinkageSpec::Spec get_linkage() const { return linkage; } 292 291 DeclarationNode * extractAggregate() const; -
src/Parser/TypeData.cc
r17fc7a5 r45c43e5 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 25 18:33:41 201713 // Update Count : 5 8712 // Last Modified On : Thu Feb 22 15:49:00 2018 13 // Update Count : 597 14 14 // 15 15 … … 54 54 function.oldDeclList = nullptr; 55 55 function.body = nullptr; 56 function.newStyle = false;57 56 function.withExprs = nullptr; 58 57 break; … … 195 194 newtype->function.oldDeclList = maybeClone( function.oldDeclList ); 196 195 newtype->function.body = maybeClone( function.body ); 197 newtype->function.newStyle = function.newStyle;198 196 newtype->function.withExprs = maybeClone( function.withExprs ); 199 197 break; … … 881 879 FunctionType * buildFunction( const TypeData * td ) { 882 880 assert( td->kind == TypeData::Function ); 883 bool hasEllipsis = td->function.params ? td->function.params->get_hasEllipsis() : true; 884 if ( ! td->function.params ) hasEllipsis = ! td->function.newStyle; 885 FunctionType * ft = new FunctionType( buildQualifiers( td ), hasEllipsis ); 881 FunctionType * ft = new FunctionType( buildQualifiers( td ), ! td->function.params || td->function.params->hasEllipsis ); 886 882 buildList( td->function.params, ft->get_parameters() ); 887 883 buildForall( td->forall, ft->get_forall() ); -
src/Parser/TypeData.h
r17fc7a5 r45c43e5 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 1 23:33:45 201713 // Update Count : 19 012 // Last Modified On : Thu Feb 22 15:21:23 2018 13 // Update Count : 191 14 14 // 15 15 … … 64 64 mutable DeclarationNode * oldDeclList; 65 65 StatementNode * body; 66 bool newStyle;67 66 ExpressionNode * withExprs; // expressions from function's with_clause 68 67 }; -
src/Parser/lex.ll
r17fc7a5 r45c43e5 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Oct 25 13:53:56 201713 * Update Count : 63 412 * Last Modified On : Thu Feb 22 18:11:27 2018 13 * Update Count : 637 14 14 */ 15 15 … … 232 232 enum { KEYWORD_RETURN(ENUM); } 233 233 __extension__ { KEYWORD_RETURN(EXTENSION); } // GCC 234 exception { KEYWORD_RETURN(EXCEPTION); } // CFA 234 235 extern { KEYWORD_RETURN(EXTERN); } 235 236 fallthru { KEYWORD_RETURN(FALLTHRU); } // CFA -
src/Parser/parser.yy
r17fc7a5 r45c43e5 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 15 17:12:31201813 // Update Count : 30 0612 // Last Modified On : Thu Feb 22 17:48:54 2018 13 // Update Count : 3028 14 14 // 15 15 … … 187 187 %token TYPEOF LABEL // GCC 188 188 %token ENUM STRUCT UNION 189 %token EXCEPTION // CFA 189 190 %token COROUTINE MONITOR THREAD // CFA 190 191 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA … … 314 315 %type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr 315 316 316 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list cfa_parameter_type_list_opt317 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt 317 318 318 319 %type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier … … 322 323 %type<decl> KR_declaration_list KR_declaration_list_opt 323 324 324 %type<decl> parameter_declaration parameter_list parameter_type_list 325 %type<decl> parameter_type_list_opt 325 %type<decl> parameter_declaration parameter_list parameter_type_list_opt 326 326 327 327 %type<decl> paren_identifier paren_type … … 779 779 | unary_expression assignment_operator assignment_expression 780 780 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 781 | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME782 { $$ = nullptr; }781 | unary_expression '=' '{' initializer_list comma_opt '}' 782 { throw SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME 783 783 ; 784 784 … … 849 849 | waitfor_statement 850 850 | exception_statement 851 | enable_disable_statement 852 { throw SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME 851 853 | asm_statement 852 854 ; … … 1064 1066 | RETURN comma_expression_opt ';' 1065 1067 { $$ = new StatementNode( build_return( $2 ) ); } 1066 | RETURN '{' initializer_list comma_opt '}' // FIX ME1067 { $$ = nullptr; }1068 | RETURN '{' initializer_list comma_opt '}' 1069 { throw SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME 1068 1070 | THROW assignment_expression_opt ';' // handles rethrow 1069 1071 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1193 1195 ; 1194 1196 1197 enable_disable_statement: 1198 enable_disable_key identifier_list compound_statement 1199 ; 1200 1201 enable_disable_key: 1202 ENABLE 1203 | DISABLE 1204 ; 1205 1195 1206 asm_statement: 1196 1207 ASM asm_volatile_opt '(' string_literal ')' ';' … … 1392 1403 DeclarationNode * ret = new DeclarationNode; 1393 1404 ret->type = maybeClone( $1->type->base ); 1394 $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr , true) );1405 $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr ) ); 1395 1406 } 1396 1407 ; … … 1422 1433 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1423 1434 { 1424 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 , true);1435 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); 1425 1436 } 1426 1437 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' 1427 1438 { 1428 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 , true);1439 $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); 1429 1440 } 1430 1441 ; … … 1881 1892 | UNION 1882 1893 { $$ = DeclarationNode::Union; } 1894 | EXCEPTION 1895 { $$ = DeclarationNode::Exception; } 1883 1896 | COROUTINE 1884 1897 { $$ = DeclarationNode::Coroutine; } … … 1990 2003 ; 1991 2004 1992 // Minimum of one parameter after which ellipsis is allowed only at the end. 1993 1994 cfa_parameter_type_list_opt: // CFA 2005 cfa_parameter_type_list_opt: // CFA, abstract + real 1995 2006 // empty 2007 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } 2008 | ELLIPSIS 1996 2009 { $$ = nullptr; } 1997 | cfa_parameter_type_list 1998 ; 1999 2000 cfa_parameter_type_list: // CFA, abstract + real 2001 cfa_abstract_parameter_list 2010 | cfa_abstract_parameter_list 2002 2011 | cfa_parameter_list 2003 2012 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list … … 2030 2039 // empty 2031 2040 { $$ = nullptr; } 2032 | parameter_type_list 2033 ; 2034 2035 parameter_type_list: 2036 parameter_list 2041 | ELLIPSIS 2042 { $$ = nullptr; } 2043 | parameter_list 2037 2044 | parameter_list pop ',' push ELLIPSIS 2038 2045 { $$ = $1->addVarArgs(); } -
src/benchmark/bench.h
r17fc7a5 r45c43e5 10 10 #if defined(__cforall) 11 11 } 12 #include <bits/cfatime.h> 12 13 #endif 14 13 15 14 16 static inline unsigned long long int Time() { … … 45 47 ( EndTime - StartTime ) / n; 46 48 47 unsigned int default_preemption() {49 __cfa_time_t default_preemption() { 48 50 return 0; 49 51 } -
src/libcfa/Makefile.am
r17fc7a5 r45c43e5 101 101 gmp \ 102 102 bits/align.h \ 103 bits/cfatime.h \ 103 104 bits/containers.h \ 104 105 bits/defs.h \ -
src/libcfa/Makefile.in
r17fc7a5 r45c43e5 264 264 concurrency/thread concurrency/kernel concurrency/monitor \ 265 265 ${shell find stdhdr -type f -printf "%p "} math gmp \ 266 bits/align.h bits/c ontainers.h bits/defs.h bits/debug.h \267 bits/ locks.h concurrency/invoke.h266 bits/align.h bits/cfatime.h bits/containers.h bits/defs.h \ 267 bits/debug.h bits/locks.h concurrency/invoke.h 268 268 HEADERS = $(nobase_cfa_include_HEADERS) 269 269 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) … … 437 437 gmp \ 438 438 bits/align.h \ 439 bits/cfatime.h \ 439 440 bits/containers.h \ 440 441 bits/defs.h \ -
src/libcfa/bits/cfatime.h
r17fc7a5 r45c43e5 48 48 // ctors 49 49 static inline void ?{}( __cfa_time_t & this ) { this.val = 0; } 50 static inline void ?{}( __cfa_time_t & this, const __cfa_time_t & rhs ) { this.val = rhs.val; } 50 51 static inline void ?{}( __cfa_time_t & this, zero_t zero ) { this.val = 0; } 51 52 … … 92 93 static inline __cfa_time_t from_us ( uint64_t val ) { __cfa_time_t ret; ret.val = val * 1_000ul; return ret; } 93 94 static inline __cfa_time_t from_ns ( uint64_t val ) { __cfa_time_t ret; ret.val = val * 1ul; return ret; } 95 96 static inline uint64_t to_s ( __cfa_time_t t ) { return t.val / 1_000_000_000ul; } 97 static inline uint64_t to_ms ( __cfa_time_t t ) { return t.val / 1_000_000ul; } 98 static inline uint64_t to_us ( __cfa_time_t t ) { return t.val / 1_000ul; } 99 static inline uint64_t to_ns ( __cfa_time_t t ) { return t.val / 1ul; } -
src/libcfa/concurrency/coroutine.c
r17fc7a5 r45c43e5 99 99 // Wrapper for co 100 100 void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 101 verify( preemption .enabled || this_processor->do_terminate );101 verify( preemption_state.enabled || this_processor->do_terminate ); 102 102 disable_interrupts(); 103 103 … … 117 117 118 118 enable_interrupts( __cfaabi_dbg_ctx ); 119 verify( preemption .enabled || this_processor->do_terminate );119 verify( preemption_state.enabled || this_processor->do_terminate ); 120 120 } //ctxSwitchDirect 121 121 -
src/libcfa/concurrency/kernel
r17fc7a5 r45c43e5 19 19 20 20 #include "invoke.h" 21 #include "bits/cfatime.h" 21 22 22 23 extern "C" { … … 48 49 49 50 // Preemption rate on this cluster 50 unsigned long long int preemption;51 __cfa_time_t preemption_rate; 51 52 }; 53 54 extern __cfa_time_t default_preemption(); 52 55 53 56 void ?{} (cluster & this); -
src/libcfa/concurrency/kernel.c
r17fc7a5 r45c43e5 60 60 // volatile thread_local unsigned short disable_preempt_count = 1; 61 61 62 volatile thread_local __cfa_kernel_preemption_ data_t preemption= { false, false, 1 };62 volatile thread_local __cfa_kernel_preemption_state_t preemption_state = { false, false, 1 }; 63 63 64 64 //----------------------------------------------------------------------------- … … 180 180 ready_queue_lock{}; 181 181 182 preemption = default_preemption();182 preemption_rate = default_preemption(); 183 183 } 184 184 … … 209 209 if(readyThread) 210 210 { 211 verify( !preemption .enabled );211 verify( !preemption_state.enabled ); 212 212 213 213 runThread(this, readyThread); 214 214 215 verify( !preemption .enabled );215 verify( !preemption_state.enabled ); 216 216 217 217 //Some actions need to be taken from the kernel … … 262 262 void finishRunning(processor * this) with( this->finish ) { 263 263 if( action_code == Release ) { 264 verify( !preemption .enabled );264 verify( !preemption_state.enabled ); 265 265 unlock( *lock ); 266 266 } … … 269 269 } 270 270 else if( action_code == Release_Schedule ) { 271 verify( !preemption .enabled );271 verify( !preemption_state.enabled ); 272 272 unlock( *lock ); 273 273 ScheduleThread( thrd ); 274 274 } 275 275 else if( action_code == Release_Multi ) { 276 verify( !preemption .enabled );276 verify( !preemption_state.enabled ); 277 277 for(int i = 0; i < lock_count; i++) { 278 278 unlock( *locks[i] ); … … 306 306 this_coroutine = NULL; 307 307 this_thread = NULL; 308 preemption .enabled = false;309 preemption .disable_count = 1;308 preemption_state.enabled = false; 309 preemption_state.disable_count = 1; 310 310 // SKULLDUGGERY: We want to create a context for the processor coroutine 311 311 // which is needed for the 2-step context switch. However, there is no reason … … 351 351 coroutine_desc * dst = get_coroutine(*this->runner); 352 352 353 verify( !preemption .enabled );353 verify( !preemption_state.enabled ); 354 354 355 355 create_stack(&dst->stack, dst->stack.size); 356 356 CtxStart(this->runner, CtxInvokeCoroutine); 357 357 358 verify( !preemption .enabled );358 verify( !preemption_state.enabled ); 359 359 360 360 dst->last = src; … … 382 382 src->state = Active; 383 383 384 verify( !preemption .enabled );384 verify( !preemption_state.enabled ); 385 385 } 386 386 … … 392 392 verify( thrd->self_cor.state != Halted ); 393 393 394 verify( !preemption .enabled );394 verify( !preemption_state.enabled ); 395 395 396 396 verifyf( thrd->next == NULL, "Expected null got %p", thrd->next ); … … 402 402 } 403 403 404 verify( !preemption .enabled );404 verify( !preemption_state.enabled ); 405 405 } 406 406 407 407 thread_desc * nextThread(cluster * this) with( *this ) { 408 verify( !preemption .enabled );408 verify( !preemption_state.enabled ); 409 409 lock( ready_queue_lock __cfaabi_dbg_ctx2 ); 410 410 thread_desc * head = pop_head( ready_queue ); 411 411 unlock( ready_queue_lock ); 412 verify( !preemption .enabled );412 verify( !preemption_state.enabled ); 413 413 return head; 414 414 } … … 416 416 void BlockInternal() { 417 417 disable_interrupts(); 418 verify( !preemption .enabled );418 verify( !preemption_state.enabled ); 419 419 returnToKernel(); 420 verify( !preemption .enabled );420 verify( !preemption_state.enabled ); 421 421 enable_interrupts( __cfaabi_dbg_ctx ); 422 422 } … … 427 427 this_processor->finish.lock = lock; 428 428 429 verify( !preemption .enabled );429 verify( !preemption_state.enabled ); 430 430 returnToKernel(); 431 verify( !preemption .enabled );431 verify( !preemption_state.enabled ); 432 432 433 433 enable_interrupts( __cfaabi_dbg_ctx ); … … 439 439 this_processor->finish.thrd = thrd; 440 440 441 verify( !preemption .enabled );441 verify( !preemption_state.enabled ); 442 442 returnToKernel(); 443 verify( !preemption .enabled );443 verify( !preemption_state.enabled ); 444 444 445 445 enable_interrupts( __cfaabi_dbg_ctx ); … … 453 453 this_processor->finish.thrd = thrd; 454 454 455 verify( !preemption .enabled );455 verify( !preemption_state.enabled ); 456 456 returnToKernel(); 457 verify( !preemption .enabled );457 verify( !preemption_state.enabled ); 458 458 459 459 enable_interrupts( __cfaabi_dbg_ctx ); … … 466 466 this_processor->finish.lock_count = count; 467 467 468 verify( !preemption .enabled );468 verify( !preemption_state.enabled ); 469 469 returnToKernel(); 470 verify( !preemption .enabled );470 verify( !preemption_state.enabled ); 471 471 472 472 enable_interrupts( __cfaabi_dbg_ctx ); … … 481 481 this_processor->finish.thrd_count = thrd_count; 482 482 483 verify( !preemption .enabled );483 verify( !preemption_state.enabled ); 484 484 returnToKernel(); 485 verify( !preemption .enabled );485 verify( !preemption_state.enabled ); 486 486 487 487 enable_interrupts( __cfaabi_dbg_ctx ); … … 489 489 490 490 void LeaveThread(__spinlock_t * lock, thread_desc * thrd) { 491 verify( !preemption .enabled );491 verify( !preemption_state.enabled ); 492 492 this_processor->finish.action_code = thrd ? Release_Schedule : Release; 493 493 this_processor->finish.lock = lock; … … 503 503 // Kernel boot procedures 504 504 void kernel_startup(void) { 505 verify( !preemption .enabled );505 verify( !preemption_state.enabled ); 506 506 __cfaabi_dbg_print_safe("Kernel : Starting\n"); 507 507 … … 548 548 __cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n"); 549 549 550 verify( !preemption .enabled );550 verify( !preemption_state.enabled ); 551 551 enable_interrupts( __cfaabi_dbg_ctx ); 552 verify( preemption .enabled );552 verify( preemption_state.enabled ); 553 553 } 554 554 … … 556 556 __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n"); 557 557 558 verify( preemption .enabled );558 verify( preemption_state.enabled ); 559 559 disable_interrupts(); 560 verify( !preemption .enabled );560 verify( !preemption_state.enabled ); 561 561 562 562 // SKULLDUGGERY: Notify the mainProcessor it needs to terminates. -
src/libcfa/concurrency/kernel_private.h
r17fc7a5 r45c43e5 78 78 // extern volatile thread_local unsigned short disable_preempt_count; 79 79 80 struct __cfa_kernel_preemption_ data_t {80 struct __cfa_kernel_preemption_state_t { 81 81 bool enabled; 82 82 bool in_progress; … … 84 84 }; 85 85 86 extern volatile thread_local __cfa_kernel_preemption_ data_t preemption;86 extern volatile thread_local __cfa_kernel_preemption_state_t preemption_state; 87 87 88 88 //----------------------------------------------------------------------------- -
src/libcfa/concurrency/preemption.c
r17fc7a5 r45c43e5 23 23 } 24 24 25 #include "bits/cfatime.h" 25 26 #include "bits/signal.h" 26 27 27 //TODO move to defaults 28 #define __CFA_DEFAULT_PREEMPTION__ 10 00029 30 //TODO move to defaults 31 __ attribute__((weak)) unsigned int default_preemption() {28 #if !defined(__CFA_DEFAULT_PREEMPTION__) 29 #define __CFA_DEFAULT_PREEMPTION__ 10`cfa_ms 30 #endif 31 32 __cfa_time_t default_preemption() __attribute__((weak)) { 32 33 return __CFA_DEFAULT_PREEMPTION__; 33 34 } … … 149 150 // Disable interrupts by incrementing the counter 150 151 void disable_interrupts() { 151 preemption .enabled = false;152 __attribute__((unused)) unsigned short new_val = preemption .disable_count + 1;153 preemption .disable_count = new_val;152 preemption_state.enabled = false; 153 __attribute__((unused)) unsigned short new_val = preemption_state.disable_count + 1; 154 preemption_state.disable_count = new_val; 154 155 verify( new_val < 65_000u ); // If this triggers someone is disabling interrupts without enabling them 155 156 } … … 161 162 thread_desc * thrd = this_thread; // Cache the thread now since interrupts can start happening after the atomic add 162 163 163 unsigned short prev = preemption .disable_count;164 preemption .disable_count -= 1;164 unsigned short prev = preemption_state.disable_count; 165 preemption_state.disable_count -= 1; 165 166 verify( prev != 0u ); // If this triggers someone is enabled already enabled interruptsverify( prev != 0u ); 166 167 167 168 // Check if we need to prempt the thread because an interrupt was missed 168 169 if( prev == 1 ) { 169 preemption .enabled = true;170 preemption_state.enabled = true; 170 171 if( proc->pending_preemption ) { 171 172 proc->pending_preemption = false; … … 181 182 // Don't execute any pending CtxSwitch even if counter reaches 0 182 183 void enable_interrupts_noPoll() { 183 unsigned short prev = preemption .disable_count;184 preemption .disable_count -= 1;184 unsigned short prev = preemption_state.disable_count; 185 preemption_state.disable_count -= 1; 185 186 verifyf( prev != 0u, "Incremented from %u\n", prev ); // If this triggers someone is enabled already enabled interrupts 186 187 if( prev == 1 ) { 187 preemption .enabled = true;188 preemption_state.enabled = true; 188 189 } 189 190 } … … 235 236 // If false : preemption is unsafe and marked as pending 236 237 static inline bool preemption_ready() { 237 bool ready = preemption .enabled && !preemption.in_progress; // Check if preemption is safe238 bool ready = preemption_state.enabled && !preemption_state.in_progress; // Check if preemption is safe 238 239 this_processor->pending_preemption = !ready; // Adjust the pending flag accordingly 239 240 return ready; … … 250 251 251 252 // Start with preemption disabled until ready 252 preemption .enabled = false;253 preemption .disable_count = 1;253 preemption_state.enabled = false; 254 preemption_state.disable_count = 1; 254 255 255 256 // Initialize the event kernel … … 294 295 this.proc->preemption_alarm = &this.alarm; 295 296 296 update_preemption( this.proc, from_us(this.proc->cltr->preemption));297 update_preemption( this.proc, this.proc->cltr->preemption_rate ); 297 298 } 298 299 … … 330 331 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread); 331 332 332 preemption .in_progress = true; // Sync flag : prevent recursive calls to the signal handler333 preemption_state.in_progress = true; // Sync flag : prevent recursive calls to the signal handler 333 334 signal_unblock( SIGUSR1 ); // We are about to CtxSwitch out of the signal handler, let other handlers in 334 preemption .in_progress = false; // Clear the in progress flag335 preemption_state.in_progress = false; // Clear the in progress flag 335 336 336 337 // Preemption can occur here -
src/libcfa/concurrency/preemption.h
r17fc7a5 r45c43e5 19 19 #include "kernel_private.h" 20 20 21 __attribute__((weak)) unsigned int default_preemption();22 21 void kernel_start_preemption(); 23 22 void kernel_stop_preemption(); -
src/libcfa/concurrency/thread.c
r17fc7a5 r45c43e5 98 98 99 99 void yield( void ) { 100 verify( preemption .enabled );100 verify( preemption_state.enabled ); 101 101 BlockInternal( this_thread ); 102 verify( preemption .enabled );102 verify( preemption_state.enabled ); 103 103 } 104 104 -
src/libcfa/exception.c
r17fc7a5 r45c43e5 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 9 14:41:55201813 // Update Count : 812 // Last Modified On : Thu Feb 22 18:17:34 2018 13 // Update Count : 11 14 14 // 15 15 … … 52 52 struct __cfaabi_ehm__try_resume_node * current_resume; 53 53 54 exception * current_exception;54 exception_t * current_exception; 55 55 int current_handler_index; 56 56 } shared_stack = {NULL, NULL, 0, 0}; … … 71 71 // This macro should be the only thing that needs to change across machines. Used in the personality function, way down 72 72 // in termination. 73 // struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception *)73 // struct _Unwind_Context * -> _Unwind_Reason_Code(*)(exception_t *) 74 74 #define MATCHER_FROM_CONTEXT(ptr_to_context) \ 75 (*(_Unwind_Reason_Code(**)(exception *))(_Unwind_GetCFA(ptr_to_context) + 8))75 (*(_Unwind_Reason_Code(**)(exception_t *))(_Unwind_GetCFA(ptr_to_context) + 8)) 76 76 77 77 78 78 // RESUMPTION ================================================================ 79 79 80 void __cfaabi_ehm__throw_resume(exception * except) {80 void __cfaabi_ehm__throw_resume(exception_t * except) { 81 81 82 82 __cfaabi_dbg_print_safe("Throwing resumption exception\n"); … … 106 106 107 107 void __cfaabi_ehm__try_resume_setup(struct __cfaabi_ehm__try_resume_node * node, 108 _Bool (*handler)(exception * except)) {108 _Bool (*handler)(exception_t * except)) { 109 109 node->next = shared_stack.top_resume; 110 110 node->handler = handler; … … 126 126 }; 127 127 128 #define NODE_TO_EXCEPT(node) ((exception *)(1 + (node)))128 #define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node))) 129 129 #define EXCEPT_TO_NODE(except) ((struct __cfaabi_ehm__node *)(except) - 1) 130 130 131 131 // Creates a copy of the indicated exception and sets current_exception to it. 132 static void __cfaabi_ehm__allocate_exception( exception * except ) {132 static void __cfaabi_ehm__allocate_exception( exception_t * except ) { 133 133 struct exception_context_t * context = this_exception_context(); 134 134 … … 151 151 152 152 // Delete the provided exception, unsetting current_exception if relivant. 153 static void __cfaabi_ehm__delete_exception( exception * except ) {153 static void __cfaabi_ehm__delete_exception( exception_t * except ) { 154 154 struct exception_context_t * context = this_exception_context(); 155 155 … … 179 179 // If this isn't a rethrow (*except==0), delete the provided exception. 180 180 void __cfaabi_ehm__cleanup_terminate( void * except ) { 181 if ( *(void**)except ) __cfaabi_ehm__delete_exception( *(exception **)except );181 if ( *(void**)except ) __cfaabi_ehm__delete_exception( *(exception_t **)except ); 182 182 } 183 183 … … 233 233 } 234 234 235 void __cfaabi_ehm__throw_terminate( exception * val ) {235 void __cfaabi_ehm__throw_terminate( exception_t * val ) { 236 236 __cfaabi_dbg_print_safe("Throwing termination exception\n"); 237 237 … … 348 348 // _Unwind_Reason_Code (*matcher)() = (_Unwind_Reason_Code (*)())lsd_info.LPStart + imatcher; 349 349 350 _Unwind_Reason_Code (*matcher)(exception *) =350 _Unwind_Reason_Code (*matcher)(exception_t *) = 351 351 MATCHER_FROM_CONTEXT(context); 352 352 int index = matcher(shared_stack.current_exception); … … 409 409 __attribute__((noinline)) 410 410 void __cfaabi_ehm__try_terminate(void (*try_block)(), 411 void (*catch_block)(int index, exception * except),412 __attribute__((unused)) int (*match_block)(exception * except)) {411 void (*catch_block)(int index, exception_t * except), 412 __attribute__((unused)) int (*match_block)(exception_t * except)) { 413 413 //! volatile int xy = 0; 414 414 //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy); -
src/libcfa/exception.h
r17fc7a5 r45c43e5 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Jun 26 15:11:00 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Th r Aug 17 15:44:00 201713 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 18:11:15 2018 13 // Update Count : 8 14 14 // 15 15 … … 22 22 23 23 struct __cfaabi_ehm__base_exception_t; 24 typedef struct __cfaabi_ehm__base_exception_t exception ;24 typedef struct __cfaabi_ehm__base_exception_t exception_t; 25 25 struct __cfaabi_ehm__base_exception_t_vtable { 26 26 const struct __cfaabi_ehm__base_exception_t_vtable * parent; … … 39 39 40 40 // Used in throw statement translation. 41 void __cfaabi_ehm__throw_terminate(exception * except) __attribute__((noreturn));41 void __cfaabi_ehm__throw_terminate(exception_t * except) __attribute__((noreturn)); 42 42 void __cfaabi_ehm__rethrow_terminate() __attribute__((noreturn)); 43 void __cfaabi_ehm__throw_resume(exception * except);43 void __cfaabi_ehm__throw_resume(exception_t * except); 44 44 45 45 // Function catches termination exceptions. 46 46 void __cfaabi_ehm__try_terminate( 47 47 void (*try_block)(), 48 void (*catch_block)(int index, exception * except),49 int (*match_block)(exception * except));48 void (*catch_block)(int index, exception_t * except), 49 int (*match_block)(exception_t * except)); 50 50 51 51 // Clean-up the exception in catch blocks. … … 55 55 struct __cfaabi_ehm__try_resume_node { 56 56 struct __cfaabi_ehm__try_resume_node * next; 57 _Bool (*handler)(exception * except);57 _Bool (*handler)(exception_t * except); 58 58 }; 59 59 … … 61 61 void __cfaabi_ehm__try_resume_setup( 62 62 struct __cfaabi_ehm__try_resume_node * node, 63 _Bool (*handler)(exception * except));63 _Bool (*handler)(exception_t * except)); 64 64 void __cfaabi_ehm__try_resume_cleanup( 65 65 struct __cfaabi_ehm__try_resume_node * node); -
src/libcfa/stdhdr/math.h
r17fc7a5 r45c43e5 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 5 20:38:18 201613 // Update Count : 1 212 // Last Modified On : Thu Feb 22 18:16:07 2018 13 // Update Count : 13 14 14 // 15 15 16 16 extern "C" { 17 #if ! defined( exception ) // nesting ? 18 #define exception `exception` // make keyword an identifier 19 #define __CFA_MATH_H__ 20 #endif 21 17 22 #include_next <math.h> // has internal check for multiple expansion 23 24 #if defined( exception ) && defined( __CFA_MATH_H__ ) // reset only if set 25 #undef exception 26 #undef __CFA_MATH_H__ 27 #endif 18 28 } // extern "C" 19 29 -
src/prelude/builtins.c
r17fc7a5 r45c43e5 23 23 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 24 24 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 25 26 // increment/decrement unification 27 28 static inline forall( dtype T | { T& ?+=?( T&, one_t ); } ) 29 T& ++? ( T& x ) { return x += 1; } 30 31 static inline forall( dtype T | sized(T) | { void ?{}( T&, T ); void ^?{}( T& ); T& ?+=?( T&, one_t ); } ) 32 T& ?++ ( T& x ) { T tmp = x; x += 1; return tmp; } 33 34 static inline forall( dtype T | { T& ?-=?( T&, one_t ); } ) 35 T& --? ( T& x ) { return x -= 1; } 36 37 static inline forall( dtype T | sized(T) | { void ?{}( T&, T ); void ^?{}( T& ); T& ?-=?( T&, one_t ); } ) 38 T& ?-- ( T& x ) { T tmp = x; x -= 1; return tmp; } 25 39 26 40 // exponentiation operator implementation
Note:
See TracChangeset
for help on using the changeset viewer.