Changes in / [9509d67a:c8ec58e]
- Files:
-
- 2 added
- 2 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/extras.c
r9509d67a rc8ec58e 3 3 #include <uchar.h> // char16_t, char32_t 4 4 #include <wchar.h> // wchar_t 5 #include <stdlib.h> // malloc, free, exit, atexit, abort5 #include <stdlib.h> // malloc, free, getenv, exit, atexit, abort, printf 6 6 #include <stdio.h> // printf 7 #include <string.h> // strlen, strcmp, strncmp -
libcfa/prelude/extras.regx2
r9509d67a rc8ec58e 1 1 extern void \*malloc[^;]*; 2 2 extern void free[^;]*; 3 extern char \*getenv[^;]*; 3 4 extern void exit[^;]*; 4 5 extern int atexit[^;]*; 5 6 extern void abort[^;]*; 6 7 extern int printf[^;]*; 8 int strcmp[^;]*; 9 int strncmp[^;]*; 10 size_t strlen[^;]*; -
libcfa/src/clock.hfa
r9509d67a rc8ec58e 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Apr 18 08:12:16 202113 // Update Count : 2812 // Last Modified On : Sat Sep 9 14:07:17 2023 13 // Update Count : 30 14 14 // 15 15 … … 91 91 // discontinuous jumps when the OS is not running the kernal thread. A duration is returned because the value is 92 92 // relative and cannot be converted to real-time (wall-clock) time. 93 Duration processor () {// non-monotonic duration of kernel thread93 Duration processor_cpu() { // non-monotonic duration of kernel thread 94 94 timespec ts; 95 95 clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ); 96 96 return (Duration){ ts }; 97 } // processor 97 } // processor_cpu 98 98 99 99 // Program CPU-time watch measures CPU time consumed by all processors (kernel threads) in the UNIX process. This 100 100 // watch is affected by discontinuous jumps when the OS is not running the kernel threads. A duration is returned 101 101 // because the value is relative and cannot be converted to real-time (wall-clock) time. 102 Duration program () {// non-monotonic duration of program CPU102 Duration program_cpu() { // non-monotonic duration of program CPU 103 103 timespec ts; 104 104 clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &ts ); 105 105 return (Duration){ ts }; 106 } // program 106 } // program_cpu 107 107 108 108 // Monotonic duration from machine boot and including system suspension. This watch is unaffected by discontinuous -
libcfa/src/concurrency/kernel/cluster.hfa
r9509d67a rc8ec58e 31 31 32 32 // warn normally all ints 33 #define warn_large_before warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'" PRId64 "ms \n", old_avg, old_avg, program ()`ms )34 #define warn_large_after warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'" PRId64 "ms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program ()`ms, ret, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg )33 #define warn_large_before warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'" PRId64 "ms \n", old_avg, old_avg, program_cpu()`ms ) 34 #define warn_large_after warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'" PRId64 "ms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program_cpu()`ms, ret, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ) 35 35 36 36 // 8X linear factor is just 8 * x … … 42 42 static inline __readyQ_avg_t __to_readyQ_avg(unsigned long long intsc) { if(unlikely(0 == intsc)) return 0.0; else return log2((__readyQ_avg_t)intsc); } 43 43 44 #define warn_large_before warnf( !strict || old_avg < 35.0, "Suspiciously large previous average: %'lf, %'" PRId64 "ms \n", old_avg, program ()`ms )45 #define warn_large_after warnf( !strict || ret < 35.3, "Suspiciously large new average after %'" PRId64 "ms cputime: %'lf from %'llu-%'llu (%'llu, %'llu) and %'lf\n", program ()`ms, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ); \44 #define warn_large_before warnf( !strict || old_avg < 35.0, "Suspiciously large previous average: %'lf, %'" PRId64 "ms \n", old_avg, program_cpu()`ms ) 45 #define warn_large_after warnf( !strict || ret < 35.3, "Suspiciously large new average after %'" PRId64 "ms cputime: %'lf from %'llu-%'llu (%'llu, %'llu) and %'lf\n", program_cpu()`ms, ret, currtsc, intsc, new_val, new_val / 1000000, old_avg ); \ 46 46 verify(ret >= 0) 47 47 -
libcfa/src/heap.cfa
r9509d67a rc8ec58e 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 2 18:48:30 202313 // Update Count : 161 412 // Last Modified On : Mon Sep 11 11:21:10 2023 13 // Update Count : 1615 14 14 // 15 15 … … 691 691 return stats; 692 692 } // collectStats 693 694 static inline void clearStats() { 695 lock( mgrLock ); 696 697 // Zero the heap master and all active thread heaps. 698 HeapStatisticsCtor( heapMaster.stats ); 699 for ( Heap * heap = heapMaster.heapManagersList; heap; heap = heap->nextHeapManager ) { 700 HeapStatisticsCtor( heap->stats ); 701 } // for 702 703 unlock( mgrLock ); 704 } // clearStats 693 705 #endif // __STATISTICS__ 694 706 … … 1556 1568 1557 1569 1570 // Zero the heap master and all active thread heaps. 1571 void malloc_stats_clear() { 1572 #ifdef __STATISTICS__ 1573 clearStats(); 1574 #else 1575 #define MALLOC_STATS_MSG "malloc_stats statistics disabled.\n" 1576 if ( write( STDERR_FILENO, MALLOC_STATS_MSG, sizeof( MALLOC_STATS_MSG ) - 1 /* size includes '\0' */ ) == -1 ) { 1577 abort( "**** Error **** write failed in malloc_stats" ); 1578 } // if 1579 #endif // __STATISTICS__ 1580 } // malloc_stats_clear 1581 1582 1558 1583 // Changes the file descriptor where malloc_stats() writes statistics. 1559 1584 int malloc_stats_fd( int fd __attribute__(( unused )) ) libcfa_public { -
libcfa/src/heap.hfa
r9509d67a rc8ec58e 10 10 // Created On : Tue May 26 11:23:55 2020 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 4 19:08:55 202213 // Update Count : 2 312 // Last Modified On : Mon Sep 11 11:18:18 2023 13 // Update Count : 24 14 14 // 15 15 … … 43 43 size_t malloc_mmap_start(); // crossover allocation size from sbrk to mmap 44 44 size_t malloc_unfreed(); // heap unfreed size (bytes) 45 void malloc_stats_clear(); // clear heap statistics 45 46 } // extern "C" 46 47 -
libcfa/src/iostream.cfa
r9509d67a rc8ec58e 1 1 2 // 2 3 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo … … 976 977 if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; } 977 978 // no maximum width necessary because text ignored => width is read width 978 if ( f.wd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.wd ); } 979 if ( f.wd != -1 ) { 980 // wd is buffer bytes available (for input chars + null terminator) 981 // rwd is count of input chars 982 int rwd = f.flags.rwd ? f.wd : (f.wd - 1); 983 start += sprintf( &fmtstr[start], "%d", rwd ); 984 } 979 985 980 986 if ( ! scanset ) { … … 993 999 } // if 994 1000 995 int check = f.wd - 1;1001 int check = f.wd - 2; 996 1002 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 997 1003 len = fmt( is, fmtstr, f.s ); -
src/ControlStruct/MultiLevelExit.cpp
r9509d67a rc8ec58e 10 10 // Created On : Mon Nov 1 13:48:00 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Sep 6 12:00:00 202313 // Update Count : 3 512 // Last Modified On : Fri Sep 8 17:04:00 2023 13 // Update Count : 36 14 14 // 15 15 … … 27 27 28 28 namespace { 29 30 /// The return context is used to remember if returns are allowed and if 31 /// not, why not. It is the nearest local control flow blocking construct. 32 enum ReturnContext { 33 MayReturn, 34 InTryWithHandler, 35 InResumeHandler, 36 InTerminateHandler, 37 InFinally, 38 }; 29 39 30 40 class Entry { … … 126 136 void previsit( const TryStmt * ); 127 137 void postvisit( const TryStmt * ); 138 void previsit( const CatchClause * ); 128 139 void previsit( const FinallyClause * ); 129 140 … … 134 145 vector<Entry> enclosing_control_structures; 135 146 Label break_label; 136 bool inFinally;147 ReturnContext ret_context; 137 148 138 149 template<typename LoopNode> … … 144 155 const list<ptr<Stmt>> & kids, bool caseClause ); 145 156 157 void enterSealedContext( ReturnContext ); 158 146 159 template<typename UnaryPredicate> 147 160 auto findEnclosingControlStructure( UnaryPredicate pred ) { … … 157 170 MultiLevelExitCore::MultiLevelExitCore( const LabelToStmt & lt ) : 158 171 target_table( lt ), break_label( CodeLocation(), "" ), 159 inFinally( false)172 ret_context( ReturnContext::MayReturn ) 160 173 {} 161 174 … … 488 501 489 502 void MultiLevelExitCore::previsit( const ReturnStmt * stmt ) { 490 if ( inFinally ) { 491 SemanticError( stmt->location, "'return' may not appear in a finally clause" ); 492 } 503 char const * context; 504 switch ( ret_context ) { 505 case ReturnContext::MayReturn: 506 return; 507 case ReturnContext::InTryWithHandler: 508 context = "try statement with a catch clause"; 509 break; 510 case ReturnContext::InResumeHandler: 511 context = "catchResume clause"; 512 break; 513 case ReturnContext::InTerminateHandler: 514 context = "catch clause"; 515 break; 516 case ReturnContext::InFinally: 517 context = "finally clause"; 518 break; 519 default: 520 assert(0); 521 } 522 SemanticError( stmt->location, toString( "'return' may not appear in a ", context ) ); 493 523 } 494 524 … … 500 530 GuardAction([this](){ enclosing_control_structures.pop_back(); } ); 501 531 } 532 533 // Try statements/try blocks are only sealed with a termination handler. 534 for ( auto clause : stmt->handlers ) { 535 if ( ast::Terminate == clause->kind ) { 536 return enterSealedContext( ReturnContext::InTryWithHandler ); 537 } 538 } 502 539 } 503 540 … … 512 549 } 513 550 551 void MultiLevelExitCore::previsit( const CatchClause * clause ) { 552 ReturnContext context = ( ast::Terminate == clause->kind ) 553 ? ReturnContext::InTerminateHandler : ReturnContext::InResumeHandler; 554 enterSealedContext( context ); 555 } 556 514 557 void MultiLevelExitCore::previsit( const FinallyClause * ) { 515 GuardAction([this, old = std::move( enclosing_control_structures)](){ enclosing_control_structures = std::move(old); }); 516 enclosing_control_structures = vector<Entry>(); 517 GuardValue( inFinally ) = true; 558 enterSealedContext( ReturnContext::InFinally ); 518 559 } 519 560 … … 617 658 } 618 659 660 void MultiLevelExitCore::enterSealedContext( ReturnContext enter_context ) { 661 GuardAction([this, old = std::move(enclosing_control_structures)](){ enclosing_control_structures = std::move(old); }); 662 enclosing_control_structures = vector<Entry>(); 663 GuardValue( ret_context ) = enter_context; 664 } 665 619 666 } // namespace 620 667 -
tests/concurrency/waituntil/locks.cfa
r9509d67a rc8ec58e 73 73 printf("done\n"); 74 74 } 75 -
tests/io/.expect/manipulatorsInput.arm64.txt
r9509d67a rc8ec58e 1 pre1 "123456", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 1 4 1 yyyyyyyyyyyyyyyyyyyy 2 5 2 abcxxx -
tests/io/.expect/manipulatorsInput.x64.txt
r9509d67a rc8ec58e 1 pre1 "123456", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 1 4 1 yyyyyyyyyyyyyyyyyyyy 2 5 2 abcxxx -
tests/io/.expect/manipulatorsInput.x86.txt
r9509d67a rc8ec58e 1 pre1 "123456", canary ok 2 pre2a "1234567", exception occurred, canary ok 3 pre2b "89", canary ok 1 4 1 yyyyyyyyyyyyyyyyyyyy 2 5 2 abcxxx -
tests/io/.in/manipulatorsInput.txt
r9509d67a rc8ec58e 1 123456 2 123456789 1 3 abc 2 4 abc -
tests/io/manipulatorsInput.cfa
r9509d67a rc8ec58e 15 15 16 16 int main() { 17 { 18 // Upfront checks to ensure buffer safety. Once these pass, the simpler `wdi(sizeof(s),s)` 19 // usage, as in the scanf alignment cases below, is justified. 20 struct { 21 char buf[8]; 22 char canary; 23 } data; 24 static_assert( sizeof(data.buf) == 8 ); 25 static_assert( &data.buf[8] == &data.canary ); // canary comes right after buf 26 27 void rep(const char* casename) { 28 data.canary = 42; 29 bool caught = false; 30 try { 31 sin | wdi( sizeof(data.buf), data.buf ); 32 } catch (cstring_length*) { 33 caught = true; 34 } 35 printf( "%s \"%s\"", casename, data.buf ); 36 if ( caught ) { 37 printf(", exception occurred"); 38 } 39 if ( data.canary == 42 ) { 40 printf(", canary ok"); 41 } else { 42 printf(", canary overwritten to %d", data.canary); 43 } 44 printf("\n"); 45 } 46 47 rep("pre1"); 48 rep("pre2a"); 49 rep("pre2b"); 50 scanf("\n"); // next test does not start with %s so does not tolerate leading whitespace 51 } 17 52 { 18 53 char s[] = "yyyyyyyyyyyyyyyyyyyy";
Note:
See TracChangeset
for help on using the changeset viewer.