Changes in / [3ecfa13:0f5da65]
- Files:
-
- 41 edited
-
libcfa/src/assert.cfa (modified) (3 diffs)
-
libcfa/src/bits/debug.cfa (modified) (2 diffs)
-
libcfa/src/bits/debug.hfa (modified) (3 diffs)
-
libcfa/src/bits/locks.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/CtxSwitch-x86_64.S (modified) (1 diff)
-
libcfa/src/concurrency/coroutine.cfa (modified) (4 diffs)
-
libcfa/src/concurrency/coroutine.hfa (modified) (5 diffs)
-
libcfa/src/concurrency/invoke.c (modified) (6 diffs)
-
libcfa/src/concurrency/kernel.cfa (modified) (8 diffs)
-
libcfa/src/concurrency/kernel.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/kernel_private.hfa (modified) (1 diff)
-
libcfa/src/concurrency/monitor.cfa (modified) (1 diff)
-
libcfa/src/concurrency/thread.cfa (modified) (3 diffs)
-
libcfa/src/concurrency/thread.hfa (modified) (1 diff)
-
libcfa/src/fstream.cfa (modified) (12 diffs)
-
libcfa/src/fstream.hfa (modified) (6 diffs)
-
libcfa/src/gmp.hfa (modified) (5 diffs)
-
libcfa/src/heap.cfa (modified) (3 diffs)
-
libcfa/src/interpose.cfa (modified) (8 diffs)
-
libcfa/src/iostream.cfa (modified) (39 diffs)
-
libcfa/src/iostream.hfa (modified) (8 diffs)
-
libcfa/src/math.hfa (modified) (2 diffs)
-
libcfa/src/startup.cfa (modified) (2 diffs)
-
libcfa/src/stdhdr/assert.h (modified) (2 diffs)
-
libcfa/src/stdhdr/bfdlink.h (modified) (1 diff)
-
libcfa/src/stdhdr/hwloc.h (modified) (1 diff)
-
libcfa/src/stdhdr/krb5.h (modified) (1 diff)
-
libcfa/src/stdhdr/math.h (modified) (1 diff)
-
libcfa/src/stdhdr/sys/ucontext.h (modified) (1 diff)
-
libcfa/src/stdlib.cfa (modified) (4 diffs)
-
libcfa/src/stdlib.hfa (modified) (2 diffs)
-
libcfa/src/time.cfa (modified) (2 diffs)
-
libcfa/src/time.hfa (modified) (2 diffs)
-
src/Common/PassVisitor.impl.h (modified) (3 diffs)
-
src/Concurrency/Keywords.cc (modified) (1 diff)
-
src/Parser/ParseNode.h (modified) (2 diffs)
-
src/Parser/lex.ll (modified) (2 diffs)
-
src/main.cc (modified) (5 diffs)
-
tests/expression.cfa (modified) (3 diffs)
-
tests/labelledExit.cfa (modified) (2 diffs)
-
tests/quotedKeyword.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/assert.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 13:00:18 202013 // Update Count : 612 // Last Modified On : Thu Nov 21 17:09:26 2019 13 // Update Count : 5 14 14 // 15 15 … … 26 26 27 27 // called by macro assert in assert.h 28 void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[]) {28 void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { 29 29 __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file ); 30 30 abort(); … … 32 32 33 33 // called by macro assertf 34 void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) {34 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { 35 35 __cfaabi_bits_acquire(); 36 36 __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file ); -
libcfa/src/bits/debug.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Thu Mar 30 12:30:01 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 13:03:16 202013 // Update Count : 1 112 // Last Modified On : Thu Nov 21 17:16:30 2019 13 // Update Count : 10 14 14 // 15 15 … … 27 27 28 28 extern "C" { 29 void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) { 29 30 void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) { 30 31 // ensure all data is written 31 32 for ( int count = 0, retcode; count < len; count += retcode ) { -
libcfa/src/bits/debug.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 12:29:21 202013 // Update Count : 912 // Last Modified On : Thu Nov 21 17:06:58 2019 13 // Update Count : 8 14 14 // 15 15 … … 21 21 #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__ 22 22 #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__ 23 #define __cfaabi_dbg_ctx_param const char caller[]24 #define __cfaabi_dbg_ctx_param2 , const char caller[]23 #define __cfaabi_dbg_ctx_param const char * caller 24 #define __cfaabi_dbg_ctx_param2 , const char * caller 25 25 #else 26 26 #define __cfaabi_dbg_debug_do(...) … … 38 38 #include <stdio.h> 39 39 40 extern void __cfaabi_bits_write( int fd, const char buffer[], int len );40 extern void __cfaabi_bits_write( int fd, const char *buffer, int len ); 41 41 extern void __cfaabi_bits_acquire(); 42 42 extern void __cfaabi_bits_release(); -
libcfa/src/bits/locks.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:19 202013 // Update Count : 1 112 // Last Modified On : Sat Aug 11 15:42:24 2018 13 // Update Count : 10 14 14 // 15 15 … … 54 54 55 55 #ifdef __CFA_DEBUG__ 56 void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]);56 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name); 57 57 #else 58 58 #define __cfaabi_dbg_record(x, y) -
libcfa/src/concurrency/CtxSwitch-x86_64.S
r3ecfa13 r0f5da65 87 87 CtxInvokeStub: 88 88 movq %rbx, %rdi 89 movq %r12, %rsi 90 jmp *%r13 89 jmp *%r12 91 90 .size CtxInvokeStub, .-CtxInvokeStub 92 91 -
libcfa/src/concurrency/coroutine.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 12:29:25 202013 // Update Count : 1 612 // Last Modified On : Thu Dec 5 14:37:29 2019 13 // Update Count : 15 14 14 // 15 15 … … 89 89 } 90 90 91 void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize ) with( this ) {91 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) { 92 92 (this.context){0p, 0p}; 93 93 (this.stack){storage, storageSize}; … … 187 187 // is not inline (We can't inline Cforall in C) 188 188 extern "C" { 189 void __leave_coroutine( struct coroutine_desc * src ) { 189 void __suspend_internal(void) { 190 suspend(); 191 } 192 193 void __leave_coroutine( coroutine_desc * src ) { 190 194 coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter; 191 195 … … 203 207 CoroutineCtxSwitch( src, starter ); 204 208 } 205 206 struct coroutine_desc * __finish_coroutine(void) {207 struct coroutine_desc * cor = kernelTLS.this_thread->curr_cor;208 209 if(cor->state == Primed) {210 suspend();211 }212 213 cor->state = Active;214 215 return cor;216 }217 209 } 218 210 -
libcfa/src/concurrency/coroutine.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:29:26 202013 // Update Count : 1 112 // Last Modified On : Tue Dec 3 22:47:58 2019 13 // Update Count : 10 14 14 // 15 15 … … 35 35 // void ^?{}( coStack_t & this ); 36 36 37 void ?{}( coroutine_desc & this, const char name[], void * storage, size_t storageSize );37 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ); 38 38 void ^?{}( coroutine_desc & this ); 39 39 … … 41 41 static inline void ?{}( coroutine_desc & this, size_t stackSize) { this{ "Anonymous Coroutine", 0p, stackSize }; } 42 42 static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize ) { this{ "Anonymous Coroutine", storage, storageSize }; } 43 static inline void ?{}( coroutine_desc & this, const char name[]) { this{ name, 0p, 0 }; }44 static inline void ?{}( coroutine_desc & this, const char name[], size_t stackSize ) { this{ name, 0p, stackSize }; }43 static inline void ?{}( coroutine_desc & this, const char * name) { this{ name, 0p, 0 }; } 44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, 0p, stackSize }; } 45 45 46 46 //----------------------------------------------------------------------------- … … 61 61 // Start coroutine routines 62 62 extern "C" { 63 void CtxInvokeCoroutine(void (*main)(void *), void * this); 63 forall(dtype T | is_coroutine(T)) 64 void CtxInvokeCoroutine(T * this); 64 65 65 forall(dtype T)66 void CtxStart(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void*));66 forall(dtype T | is_coroutine(T)) 67 void CtxStart(T * this, void ( *invoke)(T *)); 67 68 68 69 extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__)); … … 128 129 129 130 if( unlikely(dst->context.SP == 0p) ) { 130 TL_GET( this_thread )->curr_cor = dst;131 131 __stack_prepare(&dst->stack, 65000); 132 CtxStart(main, dst, cor, CtxInvokeCoroutine); 133 TL_GET( this_thread )->curr_cor = src; 132 CtxStart(&cor, CtxInvokeCoroutine); 134 133 } 135 134 -
libcfa/src/concurrency/invoke.c
r3ecfa13 r0f5da65 29 29 // Called from the kernel when starting a coroutine or task so must switch back to user mode. 30 30 31 extern void __leave_coroutine ( struct coroutine_desc * ); 32 extern struct coroutine_desc * __finish_coroutine(void); 33 extern void __leave_thread_monitor(); 31 extern void __suspend_internal(void); 32 extern void __leave_coroutine( struct coroutine_desc * ); 33 extern void __finish_creation( struct thread_desc * ); 34 extern void __leave_thread_monitor( struct thread_desc * this ); 34 35 extern void disable_interrupts() OPTIONAL_THREAD; 35 36 extern void enable_interrupts( __cfaabi_dbg_ctx_param ); … … 37 38 void CtxInvokeCoroutine( 38 39 void (*main)(void *), 40 struct coroutine_desc *(*get_coroutine)(void *), 39 41 void *this 40 42 ) { 41 // Finish setting up the coroutine by setting its state 42 struct coroutine_desc * cor = __finish_coroutine(); 43 struct coroutine_desc* cor = get_coroutine( this ); 43 44 44 // Call the main of the coroutine 45 if(cor->state == Primed) { 46 __suspend_internal(); 47 } 48 49 cor->state = Active; 50 45 51 main( this ); 46 52 … … 77 83 78 84 void CtxInvokeThread( 85 void (*dtor)(void *), 79 86 void (*main)(void *), 87 struct thread_desc *(*get_thread)(void *), 80 88 void *this 81 89 ) { 90 // Fetch the thread handle from the user defined thread structure 91 struct thread_desc* thrd = get_thread( this ); 92 93 // First suspend, once the thread arrives here, 94 // the function pointer to main can be invalidated without risk 95 __finish_creation( thrd ); 96 82 97 // Officially start the thread by enabling preemption 83 98 enable_interrupts( __cfaabi_dbg_ctx ); … … 93 108 // The order of these 4 operations is very important 94 109 //Final suspend, should never return 95 __leave_thread_monitor( );110 __leave_thread_monitor( thrd ); 96 111 __cabi_abort( "Resumed dead thread" ); 97 112 } 98 113 114 99 115 void CtxStart( 100 116 void (*main)(void *), 101 struct coroutine_desc * cor,117 struct coroutine_desc *(*get_coroutine)(void *), 102 118 void *this, 103 119 void (*invoke)(void *) 104 120 ) { 121 struct coroutine_desc * cor = get_coroutine( this ); 105 122 struct __stack_t * stack = cor->stack.storage; 106 123 … … 121 138 122 139 fs->dummyReturn = NULL; 123 fs->argument[0] = main; // argument to invoke 124 fs->argument[1] = this; // argument to invoke 140 fs->argument[0] = this; // argument to invoke 125 141 fs->rturn = invoke; 126 142 … … 140 156 fs->dummyReturn = NULL; 141 157 fs->rturn = CtxInvokeStub; 142 fs->fixedRegisters[0] = main; 143 fs->fixedRegisters[1] = this; 144 fs->fixedRegisters[2] = invoke; 158 fs->fixedRegisters[0] = this; 159 fs->fixedRegisters[1] = invoke; 145 160 146 161 #elif defined( __ARM_ARCH ) 147 #error ARM needs to be upgrade to use to parameters like X86/X64 (A.K.A. : I broke this and do not know how to fix it) 162 148 163 struct FakeStack { 149 164 float fpRegs[16]; // floating point registers -
libcfa/src/concurrency/kernel.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Feb 4 13:03:15202013 // Update Count : 5 812 // Last Modified On : Thu Jan 30 22:55:50 2020 13 // Update Count : 56 14 14 // 15 15 … … 209 209 210 210 static void start(processor * this); 211 void ?{}(processor & this, const char name[], cluster & cltr) with( this ) {211 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) { 212 212 this.name = name; 213 213 this.cltr = &cltr; … … 238 238 } 239 239 240 void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) {240 void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) { 241 241 this.name = name; 242 242 this.preemption_rate = preemption_rate; … … 441 441 } 442 442 443 static void Abort( int ret, const char func[]) {443 static void Abort( int ret, const char * func ) { 444 444 if ( ret ) { // pthread routines return errno values 445 445 abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) ); … … 469 469 ); 470 470 471 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 471 Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 472 472 473 473 Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" ); … … 490 490 verify( ! kernelTLS.preemption_state.enabled ); 491 491 492 kernelTLS.this_thread->curr_cor = dst;493 492 __stack_prepare( &dst->stack, 65000 ); 494 CtxStart( main, dst,this->runner, CtxInvokeCoroutine);493 CtxStart(&this->runner, CtxInvokeCoroutine); 495 494 496 495 verify( ! kernelTLS.preemption_state.enabled ); … … 506 505 CtxSwitch( &src->context, &dst->context ); 507 506 // when CtxSwitch returns we are back in the src coroutine 508 509 mainThread->curr_cor = &mainThread->self_cor;510 507 511 508 // set state of new coroutine to active … … 981 978 __cfaabi_dbg_debug_do( 982 979 extern "C" { 983 void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) {980 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) { 984 981 this.prev_name = prev_name; 985 982 this.prev_thrd = kernelTLS.this_thread; -
libcfa/src/concurrency/kernel.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:29:26 202013 // Update Count : 2212 // Last Modified On : Wed Dec 4 07:54:51 2019 13 // Update Count : 18 14 14 // 15 15 … … 150 150 }; 151 151 152 void ?{}(processor & this, const char name[], struct cluster & cltr);152 void ?{}(processor & this, const char * name, struct cluster & cltr); 153 153 void ^?{}(processor & this); 154 154 155 155 static inline void ?{}(processor & this) { this{ "Anonymous Processor", *mainCluster}; } 156 156 static inline void ?{}(processor & this, struct cluster & cltr) { this{ "Anonymous Processor", cltr}; } 157 static inline void ?{}(processor & this, const char name[]) { this{name, *mainCluster }; }157 static inline void ?{}(processor & this, const char * name) { this{name, *mainCluster }; } 158 158 159 159 static inline [processor *&, processor *& ] __get( processor & this ) { … … 195 195 extern Duration default_preemption(); 196 196 197 void ?{} (cluster & this, const char name[], Duration preemption_rate);197 void ?{} (cluster & this, const char * name, Duration preemption_rate); 198 198 void ^?{}(cluster & this); 199 199 200 200 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption()}; } 201 201 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; } 202 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption()}; }202 static inline void ?{} (cluster & this, const char * name) { this{name, default_preemption()}; } 203 203 204 204 static inline [cluster *&, cluster *& ] __get( cluster & this ) { -
libcfa/src/concurrency/kernel_private.hfa
r3ecfa13 r0f5da65 88 88 // Threads 89 89 extern "C" { 90 void CtxInvokeThread(void (*main)(void *), void * this); 90 forall(dtype T | is_thread(T)) 91 void CtxInvokeThread(T * this); 91 92 } 92 93 -
libcfa/src/concurrency/monitor.cfa
r3ecfa13 r0f5da65 243 243 // last routine called by a thread. 244 244 // Should never return 245 void __leave_thread_monitor() { 246 thread_desc * thrd = TL_GET( this_thread ); 245 void __leave_thread_monitor( thread_desc * thrd ) { 247 246 monitor_desc * this = &thrd->self_mon; 248 247 -
libcfa/src/concurrency/thread.cfa
r3ecfa13 r0f5da65 58 58 void ?{}( scoped(T)& this ) with( this ) { 59 59 handle{}; 60 __thrd_start(handle , main);60 __thrd_start(handle); 61 61 } 62 62 … … 64 64 void ?{}( scoped(T)& this, P params ) with( this ) { 65 65 handle{ params }; 66 __thrd_start(handle , main);66 __thrd_start(handle); 67 67 } 68 68 … … 75 75 // Starting and stopping threads 76 76 forall( dtype T | is_thread(T) ) 77 void __thrd_start( T & this, void (*main_p)(T &)) {77 void __thrd_start( T& this ) { 78 78 thread_desc * this_thrd = get_thread(this); 79 79 thread_desc * curr_thrd = TL_GET( this_thread ); 80 80 81 81 disable_interrupts(); 82 CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread); 83 82 CtxStart(&this, CtxInvokeThread); 84 83 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP]; 85 84 verify( this_thrd->context.SP ); 86 //CtxSwitch( &curr_thrd->context, &this_thrd->context );85 CtxSwitch( &curr_thrd->context, &this_thrd->context ); 87 86 88 87 ScheduleThread(this_thrd); 89 88 enable_interrupts( __cfaabi_dbg_ctx ); 89 } 90 91 extern "C" { 92 // KERNEL ONLY 93 void __finish_creation(thread_desc * this) { 94 // set new coroutine that the processor is executing 95 // and context switch to it 96 verify( kernelTLS.this_thread != this ); 97 verify( kernelTLS.this_thread->context.SP ); 98 CtxSwitch( &this->context, &kernelTLS.this_thread->context ); 99 } 90 100 } 91 101 -
libcfa/src/concurrency/thread.hfa
r3ecfa13 r0f5da65 54 54 55 55 forall( dtype T | is_thread(T) ) 56 void __thrd_start( T & this , void (*)(T &));56 void __thrd_start( T & this ); 57 57 58 58 //----------------------------------------------------------------------------- -
libcfa/src/fstream.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:01:01 202013 // Update Count : 3 6312 // Last Modified On : Fri Nov 29 06:56:46 2019 13 // Update Count : 355 14 14 // 15 15 … … 32 32 33 33 void ?{}( ofstream & os, void * file ) { 34 os.$file = file; 35 os.$sepDefault = true; 36 os.$sepOnOff = false; 37 os.$nlOnOff = true; 38 os.$prt = false; 39 os.$sawNL = false; 40 $sepSetCur( os, sepGet( os ) ); 34 os.file = file; 35 os.sepDefault = true; 36 os.sepOnOff = false; 37 os.nlOnOff = true; 38 os.prt = false; 39 os.sawNL = false; 41 40 sepSet( os, " " ); 41 sepSetCur( os, sepGet( os ) ); 42 42 sepSetTuple( os, ", " ); 43 43 } // ?{} 44 44 45 45 // private 46 bool $sepPrt( ofstream & os ) { $setNL( os, false ); return os.$sepOnOff; }47 void $sepReset( ofstream & os ) { os.$sepOnOff = os.$sepDefault; }48 void $sepReset( ofstream & os, bool reset ) { os.$sepDefault = reset; os.$sepOnOff = os.$sepDefault; }49 const char * $sepGetCur( ofstream & os ) { return os.$sepCur; }50 void $sepSetCur( ofstream & os, const char sepCur[] ) { os.$sepCur = sepCur; }51 bool $getNL( ofstream & os ) { return os.$sawNL; }52 void $setNL( ofstream & os, bool state ) { os.$sawNL = state; }53 bool $getANL( ofstream & os ) { return os.$nlOnOff; }54 bool $getPrt( ofstream & os ) { return os.$prt; }55 void $setPrt( ofstream & os, bool state ) { os.$prt = state; }46 bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; } 47 void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; } 48 void sepReset( ofstream & os, bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; } 49 const char * sepGetCur( ofstream & os ) { return os.sepCur; } 50 void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; } 51 bool getNL( ofstream & os ) { return os.sawNL; } 52 void setNL( ofstream & os, bool state ) { os.sawNL = state; } 53 bool getANL( ofstream & os ) { return os.nlOnOff; } 54 bool getPrt( ofstream & os ) { return os.prt; } 55 void setPrt( ofstream & os, bool state ) { os.prt = state; } 56 56 57 57 // public 58 void ?{}( ofstream & os ) { os. $file = 0p; }59 60 void ?{}( ofstream & os, const char name[], const char mode[]) {58 void ?{}( ofstream & os ) { os.file = 0; } 59 60 void ?{}( ofstream & os, const char * name, const char * mode ) { 61 61 open( os, name, mode ); 62 62 } // ?{} 63 63 64 void ?{}( ofstream & os, const char name[]) {64 void ?{}( ofstream & os, const char * name ) { 65 65 open( os, name, "w" ); 66 66 } // ?{} … … 70 70 } // ^?{} 71 71 72 void sepOn( ofstream & os ) { os. $sepOnOff = ! $getNL( os ); }73 void sepOff( ofstream & os ) { os. $sepOnOff = false; }72 void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); } 73 void sepOff( ofstream & os ) { os.sepOnOff = false; } 74 74 75 75 bool sepDisable( ofstream & os ) { 76 bool temp = os. $sepDefault;77 os. $sepDefault = false;78 $sepReset( os );76 bool temp = os.sepDefault; 77 os.sepDefault = false; 78 sepReset( os ); 79 79 return temp; 80 80 } // sepDisable 81 81 82 82 bool sepEnable( ofstream & os ) { 83 bool temp = os. $sepDefault;84 os. $sepDefault = true;85 if ( os. $sepOnOff ) $sepReset( os );// start of line ?83 bool temp = os.sepDefault; 84 os.sepDefault = true; 85 if ( os.sepOnOff ) sepReset( os ); // start of line ? 86 86 return temp; 87 87 } // sepEnable 88 88 89 void nlOn( ofstream & os ) { os. $nlOnOff = true; }90 void nlOff( ofstream & os ) { os. $nlOnOff = false; }91 92 const char * sepGet( ofstream & os ) { return os. $separator; }93 void sepSet( ofstream & os, const char s[]) {89 void nlOn( ofstream & os ) { os.nlOnOff = true; } 90 void nlOff( ofstream & os ) { os.nlOnOff = false; } 91 92 const char * sepGet( ofstream & os ) { return os.separator; } 93 void sepSet( ofstream & os, const char * s ) { 94 94 assert( s ); 95 strncpy( os. $separator, s, sepSize - 1 );96 os. $separator[sepSize - 1] = '\0';95 strncpy( os.separator, s, sepSize - 1 ); 96 os.separator[sepSize - 1] = '\0'; 97 97 } // sepSet 98 98 99 const char * sepGetTuple( ofstream & os ) { return os. $tupleSeparator; }100 void sepSetTuple( ofstream & os, const char s[]) {99 const char * sepGetTuple( ofstream & os ) { return os.tupleSeparator; } 100 void sepSetTuple( ofstream & os, const char * s ) { 101 101 assert( s ); 102 strncpy( os. $tupleSeparator, s, sepSize - 1 );103 os. $tupleSeparator[sepSize - 1] = '\0';102 strncpy( os.tupleSeparator, s, sepSize - 1 ); 103 os.tupleSeparator[sepSize - 1] = '\0'; 104 104 } // sepSet 105 105 106 106 void ends( ofstream & os ) { 107 if ( $getANL( os ) ) nl( os );108 else $setPrt( os, false ); // turn off107 if ( getANL( os ) ) nl( os ); 108 else setPrt( os, false ); // turn off 109 109 if ( &os == &exit ) exit( EXIT_FAILURE ); 110 110 if ( &os == &abort ) abort(); … … 112 112 113 113 int fail( ofstream & os ) { 114 return os. $file == 0 || ferror( (FILE *)(os.$file) );114 return os.file == 0 || ferror( (FILE *)(os.file) ); 115 115 } // fail 116 116 117 117 int flush( ofstream & os ) { 118 return fflush( (FILE *)(os. $file) );118 return fflush( (FILE *)(os.file) ); 119 119 } // flush 120 120 121 void open( ofstream & os, const char name[], const char mode[]) {121 void open( ofstream & os, const char * name, const char * mode ) { 122 122 FILE * file = fopen( name, mode ); 123 123 #ifdef __CFA_DEBUG__ 124 if ( file == 0 p) {124 if ( file == 0 ) { 125 125 abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 126 126 } // if … … 129 129 } // open 130 130 131 void open( ofstream & os, const char name[]) {131 void open( ofstream & os, const char * name ) { 132 132 open( os, name, "w" ); 133 133 } // open 134 134 135 135 void close( ofstream & os ) { 136 if ( (FILE *)(os. $file) == stdout || (FILE *)(os.$file) == stderr ) return;137 138 if ( fclose( (FILE *)(os. $file) ) == EOF ) {136 if ( (FILE *)(os.file) == stdout || (FILE *)(os.file) == stderr ) return; 137 138 if ( fclose( (FILE *)(os.file) ) == EOF ) { 139 139 abort | IO_MSG "close output" | nl | strerror( errno ); 140 140 } // if 141 141 } // close 142 142 143 ofstream & write( ofstream & os, const char data[], size_t size ) {143 ofstream & write( ofstream & os, const char * data, size_t size ) { 144 144 if ( fail( os ) ) { 145 145 abort | IO_MSG "attempt write I/O on failed stream"; 146 146 } // if 147 147 148 if ( fwrite( data, 1, size, (FILE *)(os. $file) ) != size ) {148 if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) { 149 149 abort | IO_MSG "write" | nl | strerror( errno ); 150 150 } // if … … 155 155 va_list args; 156 156 va_start( args, format ); 157 int len = vfprintf( (FILE *)(os. $file), format, args );157 int len = vfprintf( (FILE *)(os.file), format, args ); 158 158 if ( len == EOF ) { 159 if ( ferror( (FILE *)(os. $file) ) ) {159 if ( ferror( (FILE *)(os.file) ) ) { 160 160 abort | IO_MSG "invalid write"; 161 161 } // if … … 163 163 va_end( args ); 164 164 165 $setPrt( os, true );// called in output cascade166 $sepReset( os );// reset separator165 setPrt( os, true ); // called in output cascade 166 sepReset( os ); // reset separator 167 167 return len; 168 168 } // fmt … … 184 184 // private 185 185 void ?{}( ifstream & is, void * file ) { 186 is. $file = file;187 is. $nlOnOff = false;186 is.file = file; 187 is.nlOnOff = false; 188 188 } // ?{} 189 189 190 190 // public 191 void ?{}( ifstream & is ) { is.$file = 0p; }192 193 void ?{}( ifstream & is, const char name[], const char mode[]) {191 void ?{}( ifstream & is ) { is.file = 0; } 192 193 void ?{}( ifstream & is, const char * name, const char * mode ) { 194 194 open( is, name, mode ); 195 195 } // ?{} 196 196 197 void ?{}( ifstream & is, const char name[]) {197 void ?{}( ifstream & is, const char * name ) { 198 198 open( is, name, "r" ); 199 199 } // ?{} … … 203 203 } // ^?{} 204 204 205 void nlOn( ifstream & os ) { os. $nlOnOff = true; }206 void nlOff( ifstream & os ) { os. $nlOnOff = false; }207 bool getANL( ifstream & os ) { return os. $nlOnOff; }205 void nlOn( ifstream & os ) { os.nlOnOff = true; } 206 void nlOff( ifstream & os ) { os.nlOnOff = false; } 207 bool getANL( ifstream & os ) { return os.nlOnOff; } 208 208 209 209 int fail( ifstream & is ) { 210 return is. $file == 0p || ferror( (FILE *)(is.$file) );210 return is.file == 0 || ferror( (FILE *)(is.file) ); 211 211 } // fail 212 212 213 213 int eof( ifstream & is ) { 214 return feof( (FILE *)(is. $file) );214 return feof( (FILE *)(is.file) ); 215 215 } // eof 216 216 217 void open( ifstream & is, const char name[], const char mode[]) {217 void open( ifstream & is, const char * name, const char * mode ) { 218 218 FILE * file = fopen( name, mode ); 219 219 #ifdef __CFA_DEBUG__ 220 if ( file == 0 p) {220 if ( file == 0 ) { 221 221 abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 222 222 } // if 223 223 #endif // __CFA_DEBUG__ 224 is. $file = file;225 } // open 226 227 void open( ifstream & is, const char name[]) {224 is.file = file; 225 } // open 226 227 void open( ifstream & is, const char * name ) { 228 228 open( is, name, "r" ); 229 229 } // open 230 230 231 231 void close( ifstream & is ) { 232 if ( (FILE *)(is. $file) == stdin ) return;233 234 if ( fclose( (FILE *)(is. $file) ) == EOF ) {232 if ( (FILE *)(is.file) == stdin ) return; 233 234 if ( fclose( (FILE *)(is.file) ) == EOF ) { 235 235 abort | IO_MSG "close input" | nl | strerror( errno ); 236 236 } // if … … 242 242 } // if 243 243 244 if ( fread( data, size, 1, (FILE *)(is. $file) ) == 0 ) {244 if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) { 245 245 abort | IO_MSG "read" | nl | strerror( errno ); 246 246 } // if … … 253 253 } // if 254 254 255 if ( ungetc( c, (FILE *)(is. $file) ) == EOF ) {255 if ( ungetc( c, (FILE *)(is.file) ) == EOF ) { 256 256 abort | IO_MSG "ungetc" | nl | strerror( errno ); 257 257 } // if … … 263 263 264 264 va_start( args, format ); 265 int len = vfscanf( (FILE *)(is. $file), format, args );265 int len = vfscanf( (FILE *)(is.file), format, args ); 266 266 if ( len == EOF ) { 267 if ( ferror( (FILE *)(is. $file) ) ) {267 if ( ferror( (FILE *)(is.file) ) ) { 268 268 abort | IO_MSG "invalid read"; 269 269 } // if -
libcfa/src/fstream.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:00:51 202013 // Update Count : 1 7412 // Last Modified On : Fri Nov 29 06:56:02 2019 13 // Update Count : 168 14 14 // 15 15 … … 24 24 enum { sepSize = 16 }; 25 25 struct ofstream { 26 void * $file;27 bool $sepDefault;28 bool $sepOnOff;29 bool $nlOnOff;30 bool $prt; // print text31 bool $sawNL;32 const char * $sepCur;33 char $separator[sepSize];34 char $tupleSeparator[sepSize];26 void * file; 27 bool sepDefault; 28 bool sepOnOff; 29 bool nlOnOff; 30 bool prt; // print text 31 bool sawNL; 32 const char * sepCur; 33 char separator[sepSize]; 34 char tupleSeparator[sepSize]; 35 35 }; // ofstream 36 36 37 37 // private 38 bool $sepPrt( ofstream & );39 void $sepReset( ofstream & );40 void $sepReset( ofstream &, bool );41 const char * $sepGetCur( ofstream & );42 void $sepSetCur( ofstream &, const char []);43 bool $getNL( ofstream & );44 void $setNL( ofstream &, bool );45 bool $getANL( ofstream & );46 bool $getPrt( ofstream & );47 void $setPrt( ofstream &, bool );38 bool sepPrt( ofstream & ); 39 void sepReset( ofstream & ); 40 void sepReset( ofstream &, bool ); 41 const char * sepGetCur( ofstream & ); 42 void sepSetCur( ofstream &, const char * ); 43 bool getNL( ofstream & ); 44 void setNL( ofstream &, bool ); 45 bool getANL( ofstream & ); 46 bool getPrt( ofstream & ); 47 void setPrt( ofstream &, bool ); 48 48 49 49 // public … … 56 56 57 57 const char * sepGet( ofstream & ); 58 void sepSet( ofstream &, const char []);58 void sepSet( ofstream &, const char * ); 59 59 const char * sepGetTuple( ofstream & ); 60 void sepSetTuple( ofstream &, const char []);60 void sepSetTuple( ofstream &, const char * ); 61 61 62 62 void ends( ofstream & os ); 63 63 int fail( ofstream & ); 64 64 int flush( ofstream & ); 65 void open( ofstream &, const char name[], const char mode[]);66 void open( ofstream &, const char name[]);65 void open( ofstream &, const char * name, const char * mode ); 66 void open( ofstream &, const char * name ); 67 67 void close( ofstream & ); 68 ofstream & write( ofstream &, const char data[], size_t size );68 ofstream & write( ofstream &, const char * data, size_t size ); 69 69 int fmt( ofstream &, const char format[], ... ); 70 70 71 71 void ?{}( ofstream & os ); 72 void ?{}( ofstream & os, const char name[], const char mode[]);73 void ?{}( ofstream & os, const char name[]);72 void ?{}( ofstream & os, const char * name, const char * mode ); 73 void ?{}( ofstream & os, const char * name ); 74 74 void ^?{}( ofstream & os ); 75 75 … … 82 82 83 83 struct ifstream { 84 void * $file;85 bool $nlOnOff;84 void * file; 85 bool nlOnOff; 86 86 }; // ifstream 87 87 … … 92 92 int fail( ifstream & is ); 93 93 int eof( ifstream & is ); 94 void open( ifstream & is, const char name[], const char mode[]);95 void open( ifstream & is, const char name[]);94 void open( ifstream & is, const char * name, const char * mode ); 95 void open( ifstream & is, const char * name ); 96 96 void close( ifstream & is ); 97 97 ifstream & read( ifstream & is, char * data, size_t size ); … … 100 100 101 101 void ?{}( ifstream & is ); 102 void ?{}( ifstream & is, const char name[], const char mode[]);103 void ?{}( ifstream & is, const char name[]);102 void ?{}( ifstream & is, const char * name, const char * mode ); 103 void ?{}( ifstream & is, const char * name ); 104 104 void ^?{}( ifstream & is ); 105 105 -
libcfa/src/gmp.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 22:10:30 202013 // Update Count : 2 912 // Last Modified On : Sat Jul 13 15:25:05 2019 13 // Update Count : 27 14 14 // 15 15 … … 31 31 void ?{}( Int & this, signed long int init ) { mpz_init_set_si( this.mpz, init ); } 32 32 void ?{}( Int & this, unsigned long int init ) { mpz_init_set_ui( this.mpz, init ); } 33 void ?{}( Int & this, const char val[]) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); }33 void ?{}( Int & this, const char * val ) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); } 34 34 void ^?{}( Int & this ) { mpz_clear( this.mpz ); } 35 35 … … 37 37 Int ?`mp( signed long int init ) { return (Int){ init }; } 38 38 Int ?`mp( unsigned long int init ) { return (Int){ init }; } 39 Int ?`mp( const char init[]) { return (Int){ init }; }39 Int ?`mp( const char * init ) { return (Int){ init }; } 40 40 41 41 // assignment … … 43 43 Int ?=?( Int & lhs, long int rhs ) { mpz_set_si( lhs.mpz, rhs ); return lhs; } 44 44 Int ?=?( Int & lhs, unsigned long int rhs ) { mpz_set_ui( lhs.mpz, rhs ); return lhs; } 45 Int ?=?( Int & lhs, const char rhs[]) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; }45 Int ?=?( Int & lhs, const char * rhs ) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; } 46 46 47 47 char ?=?( char & lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); lhs = val; return lhs; } … … 265 265 forall( dtype ostype | ostream( ostype ) ) { 266 266 ostype & ?|?( ostype & os, Int mp ) { 267 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );267 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 268 268 gmp_printf( "%Zd", mp.mpz ); 269 269 sepOn( os ); -
libcfa/src/heap.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 10:04:51 202013 // Update Count : 64 812 // Last Modified On : Sun Dec 8 21:01:31 2019 13 // Update Count : 647 14 14 // 15 15 … … 380 380 381 381 382 static inline void checkHeader( bool check, const char name[], void * addr ) {382 static inline void checkHeader( bool check, const char * name, void * addr ) { 383 383 if ( unlikely( check ) ) { // bad address ? 384 384 abort( "Attempt to %s storage %p with address outside the heap.\n" … … 418 418 419 419 420 static inline bool headers( const char name[]__attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {420 static inline bool headers( const char * name __attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) { 421 421 header = headerAddr( addr ); 422 422 -
libcfa/src/interpose.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 8 08:40:34202013 // Update Count : 1 6312 // Last Modified On : Thu Jan 30 17:47:32 2020 13 // Update Count : 156 14 14 // 15 15 … … 29 29 #include "bits/signal.hfa" // sigHandler_? 30 30 #include "startup.hfa" // STARTUP_PRIORITY_CORE 31 #include <assert.h>32 31 33 32 //============================================================================================= … … 41 40 42 41 typedef void (* generic_fptr_t)(void); 43 generic_fptr_t interpose_symbol( const char symbol[], const char version[]) {42 generic_fptr_t interpose_symbol( const char * symbol, const char * version ) { 44 43 const char * error; 45 44 … … 146 145 extern "C" { 147 146 void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) { 148 abort( false, "%s", "" );147 abort( false, NULL ); // FIX ME: 0p does not work 149 148 } 150 149 … … 162 161 163 162 void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; } 164 void kernel_abort_msg( void * data, char buffer[], int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 165 164 // See concurrency/kernel.cfa for strong definition used in multi-processor mode. 166 165 int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; } … … 170 169 171 170 static void __cfaabi_backtrace( int start ) { 172 enum { Frames = 50, }; // maximum number of stack frames 171 enum { 172 Frames = 50, // maximum number of stack frames 173 }; 173 174 int last = kernel_abort_lastframe(); // skip last N stack frames 174 175 175 176 void * array[Frames]; 176 177 size_t size = backtrace( array, Frames ); 177 char ** messages = backtrace_symbols( array, size ); // does not demangle names178 char ** messages = backtrace_symbols( array, size ); 178 179 179 180 *index( messages[0], '(' ) = '\0'; // find executable name … … 183 184 char * name = 0p, * offset_begin = 0p, * offset_end = 0p; 184 185 185 for ( char * p = messages[i]; *p; p += 1 ) {// find parantheses and +offset186 for ( char * p = messages[i]; *p; ++p ) { // find parantheses and +offset 186 187 //__cfaabi_bits_print_nolock( "X %s\n", p); 187 188 if ( *p == '(' ) { … … 227 228 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 228 229 229 assert( fmt ); 230 va_list args; 231 va_start( args, fmt ); 232 233 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 234 va_end( args ); 235 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 236 237 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 238 __cfaabi_dbg_write( "\n", 1 ); 230 if ( fmt ) { 231 va_list args; 232 va_start( args, fmt ); 233 234 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 235 va_end( args ); 236 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 237 238 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 239 __cfaabi_dbg_write( "\n", 1 ); 240 } 239 241 } 240 242 -
libcfa/src/iostream.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 18:48:38 202013 // Update Count : 82 512 // Last Modified On : Sat Jul 13 08:07:59 2019 13 // Update Count : 821 14 14 // 15 15 … … 35 35 forall( dtype ostype | ostream( ostype ) ) { 36 36 ostype & ?|?( ostype & os, zero_t ) { 37 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );37 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 38 38 fmt( os, "%d", 0n ); 39 39 return os; … … 44 44 45 45 ostype & ?|?( ostype & os, one_t ) { 46 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );46 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 47 47 fmt( os, "%d", 1n ); 48 48 return os; … … 53 53 54 54 ostype & ?|?( ostype & os, bool b ) { 55 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );55 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 56 56 fmt( os, "%s", b ? "true" : "false" ); 57 57 return os; … … 63 63 ostype & ?|?( ostype & os, char c ) { 64 64 fmt( os, "%c", c ); 65 if ( c == '\n' ) $setNL( os, true );65 if ( c == '\n' ) setNL( os, true ); 66 66 return sepOff( os ); 67 67 } // ?|? … … 71 71 72 72 ostype & ?|?( ostype & os, signed char sc ) { 73 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );73 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 74 74 fmt( os, "%hhd", sc ); 75 75 return os; … … 80 80 81 81 ostype & ?|?( ostype & os, unsigned char usc ) { 82 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );82 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 83 83 fmt( os, "%hhu", usc ); 84 84 return os; … … 89 89 90 90 ostype & ?|?( ostype & os, short int si ) { 91 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );91 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 92 92 fmt( os, "%hd", si ); 93 93 return os; … … 98 98 99 99 ostype & ?|?( ostype & os, unsigned short int usi ) { 100 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );100 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 101 101 fmt( os, "%hu", usi ); 102 102 return os; … … 107 107 108 108 ostype & ?|?( ostype & os, int i ) { 109 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );109 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 110 110 fmt( os, "%d", i ); 111 111 return os; … … 116 116 117 117 ostype & ?|?( ostype & os, unsigned int ui ) { 118 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );118 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 119 119 fmt( os, "%u", ui ); 120 120 return os; … … 125 125 126 126 ostype & ?|?( ostype & os, long int li ) { 127 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );127 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 128 128 fmt( os, "%ld", li ); 129 129 return os; … … 134 134 135 135 ostype & ?|?( ostype & os, unsigned long int uli ) { 136 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );136 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 137 137 fmt( os, "%lu", uli ); 138 138 return os; … … 143 143 144 144 ostype & ?|?( ostype & os, long long int lli ) { 145 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );145 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 146 146 fmt( os, "%lld", lli ); 147 147 return os; … … 152 152 153 153 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 154 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );154 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 155 155 fmt( os, "%llu", ulli ); 156 156 return os; … … 175 175 176 176 ostype & ?|?( ostype & os, float f ) { 177 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );177 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 178 178 PrintWithDP( os, "%g", f ); 179 179 return os; … … 184 184 185 185 ostype & ?|?( ostype & os, double d ) { 186 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );186 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 187 187 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 188 188 return os; … … 193 193 194 194 ostype & ?|?( ostype & os, long double ld ) { 195 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );195 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 196 196 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 197 197 return os; … … 202 202 203 203 ostype & ?|?( ostype & os, float _Complex fc ) { 204 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );204 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 205 205 // os | crealf( fc ) | nonl; 206 206 PrintWithDP( os, "%g", crealf( fc ) ); … … 214 214 215 215 ostype & ?|?( ostype & os, double _Complex dc ) { 216 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );216 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 217 217 // os | creal( dc ) | nonl; 218 218 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 226 226 227 227 ostype & ?|?( ostype & os, long double _Complex ldc ) { 228 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );228 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 229 229 // os | creall( ldc ) || nonl; 230 230 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 237 237 } // ?|? 238 238 239 ostype & ?|?( ostype & os, const char str[]) {239 ostype & ?|?( ostype & os, const char * str ) { 240 240 enum { Open = 1, Close, OpenClose }; 241 241 static const unsigned char mask[256] @= { … … 257 257 // first character IS NOT spacing or closing punctuation => add left separator 258 258 unsigned char ch = str[0]; // must make unsigned 259 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {260 fmt( os, "%s", $sepGetCur( os ) );259 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 260 fmt( os, "%s", sepGetCur( os ) ); 261 261 } // if 262 262 263 263 // if string starts line, must reset to determine open state because separator is off 264 $sepReset( os );// reset separator264 sepReset( os ); // reset separator 265 265 266 266 // last character IS spacing or opening punctuation => turn off separator for next item 267 267 size_t len = strlen( str ); 268 268 ch = str[len - 1]; // must make unsigned 269 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {269 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 270 270 sepOn( os ); 271 271 } else { 272 272 sepOff( os ); 273 273 } // if 274 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag274 if ( ch == '\n' ) setNL( os, true ); // check *AFTER* sepPrt call above as it resets NL flag 275 275 return write( os, str, len ); 276 276 } // ?|? 277 278 void ?|?( ostype & os, const char str[] ) { 277 void ?|?( ostype & os, const char * str ) { 279 278 (ostype &)(os | str); ends( os ); 280 279 } // ?|? 281 280 282 281 // ostype & ?|?( ostype & os, const char16_t * str ) { 283 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );282 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 284 283 // fmt( os, "%ls", str ); 285 284 // return os; … … 288 287 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 289 288 // ostype & ?|?( ostype & os, const char32_t * str ) { 290 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );289 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 291 290 // fmt( os, "%ls", str ); 292 291 // return os; … … 295 294 296 295 // ostype & ?|?( ostype & os, const wchar_t * str ) { 297 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );296 // if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 298 297 // fmt( os, "%ls", str ); 299 298 // return os; … … 301 300 302 301 ostype & ?|?( ostype & os, const void * p ) { 303 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );302 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 304 303 fmt( os, "%p", p ); 305 304 return os; … … 316 315 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 317 316 (ostype &)(manip( os )); 318 if ( $getPrt( os ) ) ends( os );// something printed ?319 $setPrt( os, false ); // turn off317 if ( getPrt( os ) ) ends( os ); // something printed ? 318 setPrt( os, false ); // turn off 320 319 } // ?|? 321 320 … … 330 329 ostype & nl( ostype & os ) { 331 330 (ostype &)(os | '\n'); 332 $setPrt( os, false ); // turn off333 $setNL( os, true );331 setPrt( os, false ); // turn off 332 setNL( os, true ); 334 333 flush( os ); 335 334 return sepOff( os ); // prepare for next line … … 337 336 338 337 ostype & nonl( ostype & os ) { 339 $setPrt( os, false ); // turn off338 setPrt( os, false ); // turn off 340 339 return os; 341 340 } // nonl … … 376 375 ostype & ?|?( ostype & os, T arg, Params rest ) { 377 376 (ostype &)(os | arg); // print first argument 378 $sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator377 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 379 378 (ostype &)(os | rest); // print remaining arguments 380 $sepSetCur( os, sepGet( os ) ); // switch to regular separator379 sepSetCur( os, sepGet( os ) ); // switch to regular separator 381 380 return os; 382 381 } // ?|? … … 384 383 // (ostype &)(?|?( os, arg, rest )); ends( os ); 385 384 (ostype &)(os | arg); // print first argument 386 $sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator385 sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 387 386 (ostype &)(os | rest); // print remaining arguments 388 $sepSetCur( os, sepGet( os ) ); // switch to regular separator387 sepSetCur( os, sepGet( os ) ); // switch to regular separator 389 388 ends( os ); 390 389 } // ?|? … … 415 414 forall( dtype ostype | ostream( ostype ) ) { \ 416 415 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 417 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \416 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 418 417 \ 419 418 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 514 513 forall( dtype ostype | ostream( ostype ) ) { \ 515 514 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 516 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \515 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 517 516 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 518 517 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 537 536 return os; \ 538 537 } /* ?|? */ \ 539 \540 538 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 541 539 } // distribution … … 557 555 } // if 558 556 559 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );557 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 560 558 561 559 #define CFMTNP "% * " … … 573 571 return os; 574 572 } // ?|? 575 576 573 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 577 574 } // distribution … … 595 592 } // if 596 593 597 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );594 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 598 595 599 596 #define SFMTNP "% * " … … 619 616 return os; 620 617 } // ?|? 621 622 618 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 623 619 } // distribution … … 739 735 } // ?|? 740 736 741 // istype & ?|?( istype & is, const char fmt[]) {737 // istype & ?|?( istype & is, const char * fmt ) { 742 738 // fmt( is, fmt, "" ); 743 739 // return is; -
libcfa/src/iostream.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 17:53:52 202013 // Update Count : 33 612 // Last Modified On : Fri Jul 12 12:08:38 2019 13 // Update Count : 334 14 14 // 15 15 … … 24 24 trait ostream( dtype ostype ) { 25 25 // private 26 bool $sepPrt( ostype & ); // get separator state (on/off)27 void $sepReset( ostype & ); // set separator state to default state28 void $sepReset( ostype &, bool ); // set separator and default state29 const char * $sepGetCur( ostype & );// get current separator string30 void $sepSetCur( ostype &, const char []); // set current separator string31 bool $getNL( ostype & );// check newline32 void $setNL( ostype &, bool ); // saw newline33 bool $getANL( ostype & ); // get auto newline (on/off)34 bool $getPrt( ostype & ); // get fmt called in output cascade35 void $setPrt( ostype &, bool ); // set fmt called in output cascade26 bool sepPrt( ostype & ); // get separator state (on/off) 27 void sepReset( ostype & ); // set separator state to default state 28 void sepReset( ostype &, bool ); // set separator and default state 29 const char * sepGetCur( ostype & ); // get current separator string 30 void sepSetCur( ostype &, const char * ); // set current separator string 31 bool getNL( ostype & ); // check newline 32 void setNL( ostype &, bool ); // saw newline 33 bool getANL( ostype & ); // get auto newline (on/off) 34 bool getPrt( ostype & ); // get fmt called in output cascade 35 void setPrt( ostype &, bool ); // set fmt called in output cascade 36 36 // public 37 37 void sepOn( ostype & ); // turn separator state on … … 43 43 44 44 const char * sepGet( ostype & ); // get separator string 45 void sepSet( ostype &, const char []); // set separator to string (15 character maximum)45 void sepSet( ostype &, const char * ); // set separator to string (15 character maximum) 46 46 const char * sepGetTuple( ostype & ); // get tuple separator string 47 void sepSetTuple( ostype &, const char [] );// set tuple separator to string (15 character maximum)47 void sepSetTuple( ostype &, const char * ); // set tuple separator to string (15 character maximum) 48 48 49 49 void ends( ostype & os ); // end of output statement 50 50 int fail( ostype & ); 51 51 int flush( ostype & ); 52 void open( ostype & os, const char name[], const char mode[]);52 void open( ostype & os, const char * name, const char * mode ); 53 53 void close( ostype & os ); 54 ostype & write( ostype &, const char [], size_t );54 ostype & write( ostype &, const char *, size_t ); 55 55 int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 56 56 }; // ostream … … 113 113 void ?|?( ostype &, long double _Complex ); 114 114 115 ostype & ?|?( ostype &, const char []);116 void ?|?( ostype &, const char []);115 ostype & ?|?( ostype &, const char * ); 116 void ?|?( ostype &, const char * ); 117 117 // ostype & ?|?( ostype &, const char16_t * ); 118 118 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 256 256 257 257 static inline { 258 _Ostream_Manip(const char *) bin( const char s[]) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; }259 _Ostream_Manip(const char *) oct( const char s[]) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; }260 _Ostream_Manip(const char *) hex( const char s[]) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; }261 _Ostream_Manip(const char *) wd( unsigned int w, const char s[]) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; }262 _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char s[]) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; }258 _Ostream_Manip(const char *) bin( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; } 259 _Ostream_Manip(const char *) oct( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; } 260 _Ostream_Manip(const char *) hex( const char * s ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; } 261 _Ostream_Manip(const char *) wd( unsigned int w, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; } 262 _Ostream_Manip(const char *) wd( unsigned int w, unsigned char pc, const char * s ) { return (_Ostream_Manip(const char *))@{ s, w, pc, 's', { .flags.pc : true } }; } 263 263 _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; } 264 264 _Ostream_Manip(const char *) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } … … 281 281 int fail( istype & ); 282 282 int eof( istype & ); 283 void open( istype & is, const char name[]);283 void open( istype & is, const char * name ); 284 284 void close( istype & is ); 285 285 istype & read( istype &, char *, size_t ); … … 316 316 istype & ?|?( istype &, long double _Complex & ); 317 317 318 // istype & ?|?( istype &, const char []);318 // istype & ?|?( istype &, const char * ); 319 319 istype & ?|?( istype &, char * ); 320 320 … … 343 343 static inline { 344 344 _Istream_Cstr skip( unsigned int n ) { return (_Istream_Cstr){ 0p, 0p, n, { .all : 0 } }; } 345 _Istream_Cstr skip( const char scanset[]) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; }346 _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; }347 _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; }348 _Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; }349 _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; }350 _Istream_Cstr ignore( const char s[]) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; }345 _Istream_Cstr skip( const char * scanset ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; } 346 _Istream_Cstr incl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; } 347 _Istream_Cstr & incl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; } 348 _Istream_Cstr excl( const char * scanset, char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; } 349 _Istream_Cstr & excl( const char * scanset, _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; } 350 _Istream_Cstr ignore( const char * s ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; } 351 351 _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; } 352 _Istream_Cstr wdi( unsigned int w, char s[]) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; }352 _Istream_Cstr wdi( unsigned int w, char * s ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; } 353 353 _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; } 354 354 } // distribution -
libcfa/src/math.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 10:27:11 202013 // Update Count : 11 712 // Last Modified On : Fri Jul 13 11:02:15 2018 13 // Update Count : 116 14 14 // 15 15 … … 51 51 static inline long double fdim( long double x, long double y ) { return fdiml( x, y ); } 52 52 53 static inline float nan( const char tag[]) { return nanf( tag ); }54 // extern "C" { double nan( const char []); }55 static inline long double nan( const char tag[]) { return nanl( tag ); }53 static inline float nan( const char * tag ) { return nanf( tag ); } 54 // extern "C" { double nan( const char * ); } 55 static inline long double nan( const char * tag ) { return nanl( tag ); } 56 56 57 57 //---------------------- Exponential ---------------------- -
libcfa/src/startup.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Jul 24 16:21:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:18 202013 // Update Count : 3012 // Last Modified On : Fri Dec 13 13:16:45 2019 13 // Update Count : 29 14 14 // 15 15 … … 41 41 struct __spinlock_t; 42 42 extern "C" { 43 void __cfaabi_dbg_record(struct __spinlock_t & this, const char prev_name[]) __attribute__(( weak )) {}43 void __cfaabi_dbg_record(struct __spinlock_t & this, const char * prev_name) __attribute__(( weak )) {} 44 44 } 45 45 -
libcfa/src/stdhdr/assert.h
r3ecfa13 r0f5da65 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:58:49 202013 // Update Count : 1 512 // Last Modified On : Mon Jul 31 23:09:32 2017 13 // Update Count : 13 14 14 // 15 15 … … 27 27 #define assertf( expr, fmt, ... ) ((expr) ? ((void)0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) 28 28 29 void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((noreturn, format( printf, 5, 6) ));29 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn, format( printf, 5, 6) )); 30 30 #endif 31 31 -
libcfa/src/stdhdr/bfdlink.h
r3ecfa13 r0f5da65 10 10 // Created On : Tue Jul 18 07:26:04 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:08202013 // Update Count : 612 // Last Modified On : Sat Feb 1 07:15:29 2020 13 // Update Count : 5 14 14 // 15 15 16 16 // include file uses the CFA keyword "with". 17 17 #if ! defined( with ) // nesting ? 18 #define with ``with // make keyword an identifier18 #define with ``with`` // make keyword an identifier 19 19 #define __CFA_BFDLINK_H__ 20 20 #endif -
libcfa/src/stdhdr/hwloc.h
r3ecfa13 r0f5da65 10 10 // Created On : Tue Jul 18 07:45:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:18202013 // Update Count : 612 // Last Modified On : Sat Feb 1 07:15:39 2020 13 // Update Count : 5 14 14 // 15 15 16 16 // include file uses the CFA keyword "thread". 17 17 #if ! defined( thread ) // nesting ? 18 #define thread ``thread // make keyword an identifier18 #define thread ``thread`` // make keyword an identifier 19 19 #define __CFA_HWLOC_H__ 20 20 #endif -
libcfa/src/stdhdr/krb5.h
r3ecfa13 r0f5da65 10 10 // Created On : Tue Jul 18 07:55:44 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:35202013 // Update Count : 612 // Last Modified On : Sat Feb 1 07:15:47 2020 13 // Update Count : 5 14 14 // 15 15 16 16 // include file uses the CFA keyword "enable". 17 17 #if ! defined( enable ) // nesting ? 18 #define enable ``enable // make keyword an identifier18 #define enable ``enable`` // make keyword an identifier 19 19 #define __CFA_KRB5_H__ 20 20 #endif -
libcfa/src/stdhdr/math.h
r3ecfa13 r0f5da65 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:27202013 // Update Count : 1 512 // Last Modified On : Sat Feb 1 07:15:58 2020 13 // Update Count : 14 14 14 // 15 15 16 16 extern "C" { 17 17 #if ! defined( exception ) // nesting ? 18 #define exception ``exception // make keyword an identifier18 #define exception ``exception`` // make keyword an identifier 19 19 #define __CFA_MATH_H__ 20 20 #endif -
libcfa/src/stdhdr/sys/ucontext.h
r3ecfa13 r0f5da65 10 10 // Created On : Thu Feb 8 23:48:16 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:05:41202013 // Update Count : 612 // Last Modified On : Sat Feb 1 07:16:05 2020 13 // Update Count : 5 14 14 // 15 15 16 16 #if ! defined( ftype ) // nesting ? 17 #define ftype ``ftype // make keyword an identifier17 #define ftype ``ftype`` // make keyword an identifier 18 18 #define __CFA_UCONTEXT_H__ 19 19 #endif -
libcfa/src/stdlib.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:27:08 202013 // Update Count : 48 612 // Last Modified On : Wed Nov 20 17:22:47 2019 13 // Update Count : 485 14 14 // 15 15 … … 107 107 //--------------------------------------- 108 108 109 float _Complex strto( const char sptr[], char ** eptr ) {109 float _Complex strto( const char * sptr, char ** eptr ) { 110 110 float re, im; 111 111 char * eeptr; … … 118 118 } // strto 119 119 120 double _Complex strto( const char sptr[], char ** eptr ) {120 double _Complex strto( const char * sptr, char ** eptr ) { 121 121 double re, im; 122 122 char * eeptr; … … 129 129 } // strto 130 130 131 long double _Complex strto( const char sptr[], char ** eptr ) {131 long double _Complex strto( const char * sptr, char ** eptr ) { 132 132 long double re, im; 133 133 char * eeptr; -
libcfa/src/stdlib.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:27:01 202013 // Update Count : 40 112 // Last Modified On : Fri Nov 29 23:08:02 2019 13 // Update Count : 400 14 14 // 15 15 … … 193 193 194 194 static inline { 195 int strto( const char sptr[], char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); }196 unsigned int strto( const char sptr[], char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); }197 long int strto( const char sptr[], char ** eptr, int base ) { return strtol( sptr, eptr, base ); }198 unsigned long int strto( const char sptr[], char ** eptr, int base ) { return strtoul( sptr, eptr, base ); }199 long long int strto( const char sptr[], char ** eptr, int base ) { return strtoll( sptr, eptr, base ); }200 unsigned long long int strto( const char sptr[], char ** eptr, int base ) { return strtoull( sptr, eptr, base ); }201 202 float strto( const char sptr[], char ** eptr ) { return strtof( sptr, eptr ); }203 double strto( const char sptr[], char ** eptr ) { return strtod( sptr, eptr ); }204 long double strto( const char sptr[], char ** eptr ) { return strtold( sptr, eptr ); }205 } // distribution 206 207 float _Complex strto( const char sptr[], char ** eptr );208 double _Complex strto( const char sptr[], char ** eptr );209 long double _Complex strto( const char sptr[], char ** eptr );195 int strto( const char * sptr, char ** eptr, int base ) { return (int)strtol( sptr, eptr, base ); } 196 unsigned int strto( const char * sptr, char ** eptr, int base ) { return (unsigned int)strtoul( sptr, eptr, base ); } 197 long int strto( const char * sptr, char ** eptr, int base ) { return strtol( sptr, eptr, base ); } 198 unsigned long int strto( const char * sptr, char ** eptr, int base ) { return strtoul( sptr, eptr, base ); } 199 long long int strto( const char * sptr, char ** eptr, int base ) { return strtoll( sptr, eptr, base ); } 200 unsigned long long int strto( const char * sptr, char ** eptr, int base ) { return strtoull( sptr, eptr, base ); } 201 202 float strto( const char * sptr, char ** eptr ) { return strtof( sptr, eptr ); } 203 double strto( const char * sptr, char ** eptr ) { return strtod( sptr, eptr ); } 204 long double strto( const char * sptr, char ** eptr ) { return strtold( sptr, eptr ); } 205 } // distribution 206 207 float _Complex strto( const char * sptr, char ** eptr ); 208 double _Complex strto( const char * sptr, char ** eptr ); 209 long double _Complex strto( const char * sptr, char ** eptr ); 210 210 211 211 static inline { 212 int ato( const char sptr[]) { return (int)strtol( sptr, 0p, 10 ); }213 unsigned int ato( const char sptr[]) { return (unsigned int)strtoul( sptr, 0p, 10 ); }214 long int ato( const char sptr[]) { return strtol( sptr, 0p, 10 ); }215 unsigned long int ato( const char sptr[]) { return strtoul( sptr, 0p, 10 ); }216 long long int ato( const char sptr[]) { return strtoll( sptr, 0p, 10 ); }217 unsigned long long int ato( const char sptr[]) { return strtoull( sptr, 0p, 10 ); }218 219 float ato( const char sptr[]) { return strtof( sptr, 0p ); }220 double ato( const char sptr[]) { return strtod( sptr, 0p ); }221 long double ato( const char sptr[]) { return strtold( sptr, 0p ); }222 223 float _Complex ato( const char sptr[]) { return strto( sptr, 0p ); }224 double _Complex ato( const char sptr[]) { return strto( sptr, 0p ); }225 long double _Complex ato( const char sptr[]) { return strto( sptr, 0p ); }212 int ato( const char * sptr ) { return (int)strtol( sptr, 0p, 10 ); } 213 unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0p, 10 ); } 214 long int ato( const char * sptr ) { return strtol( sptr, 0p, 10 ); } 215 unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0p, 10 ); } 216 long long int ato( const char * sptr ) { return strtoll( sptr, 0p, 10 ); } 217 unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0p, 10 ); } 218 219 float ato( const char * sptr ) { return strtof( sptr, 0p ); } 220 double ato( const char * sptr ) { return strtod( sptr, 0p ); } 221 long double ato( const char * sptr ) { return strtold( sptr, 0p ); } 222 223 float _Complex ato( const char * sptr ) { return strto( sptr, 0p ); } 224 double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); } 225 long double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); } 226 226 } // distribution 227 227 -
libcfa/src/time.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:24:18202013 // Update Count : 7012 // Last Modified On : Sun Jan 5 17:27:40 2020 13 // Update Count : 69 14 14 // 15 15 … … 129 129 } // dd_mm_yy 130 130 131 size_t strftime( char buf[], size_t size, const char fmt[], Time time ) with( time ) {131 size_t strftime( char * buf, size_t size, const char * fmt, Time time ) with( time ) { 132 132 time_t s = tn / TIMEGRAN; 133 133 tm tm; -
libcfa/src/time.hfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:24:32202013 // Update Count : 65 412 // Last Modified On : Mon Jan 6 12:50:16 2020 13 // Update Count : 653 14 14 // 15 15 … … 191 191 } // dmy 192 192 193 size_t strftime( char buf[], size_t size, const char fmt[], Time time );193 size_t strftime( char * buf, size_t size, const char * fmt, Time time ); 194 194 195 195 //------------------------- timeval (cont) ------------------------- -
src/Common/PassVisitor.impl.h
r3ecfa13 r0f5da65 3302 3302 VISIT_START( node ); 3303 3303 3304 indexerAdd Union( node->name );3304 indexerAddStruct( node->name ); 3305 3305 3306 3306 { … … 3317 3317 VISIT_START( node ); 3318 3318 3319 indexerAdd Union( node->name );3319 indexerAddStruct( node->name ); 3320 3320 3321 3321 { … … 3332 3332 MUTATE_START( node ); 3333 3333 3334 indexerAdd Union( node->name );3334 indexerAddStruct( node->name ); 3335 3335 3336 3336 { -
src/Concurrency/Keywords.cc
r3ecfa13 r0f5da65 716 716 new UntypedExpr( 717 717 new NameExpr( "__thrd_start" ), 718 { new VariableExpr( param ) , new NameExpr("main")}718 { new VariableExpr( param ) } 719 719 ) 720 720 ) -
src/Parser/ParseNode.h
r3ecfa13 r0f5da65 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 17:56:02 202013 // Update Count : 8 9112 // Last Modified On : Mon Dec 16 07:46:01 2019 13 // Update Count : 888 14 14 // 15 15 … … 449 449 * out++ = result; 450 450 } else { 451 SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented.");451 assertf(false, "buildList unknown type"); 452 452 } // if 453 453 } catch( SemanticErrorException & e ) { -
src/Parser/lex.ll
r3ecfa13 r0f5da65 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Fri Feb 7 19:02:43202013 * Update Count : 72 512 * Last Modified On : Sat Feb 1 07:16:44 2020 13 * Update Count : 724 14 14 */ 15 15 … … 330 330 /* identifier */ 331 331 {identifier} { IDENTIFIER_RETURN(); } 332 "``"{identifier} {// CFA333 yytext[yyleng ] = '\0'; yytext += 2;// SKULLDUGGERY: remove backquotes (ok to shorten?)332 "``"{identifier}"``" { // CFA 333 yytext[yyleng - 2] = '\0'; yytext += 2; // SKULLDUGGERY: remove backquotes (ok to shorten?) 334 334 IDENTIFIER_RETURN(); 335 335 } -
src/main.cc
r3ecfa13 r0f5da65 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 8 08:33:50 202013 // Update Count : 6 3312 // Last Modified On : Mon Dec 16 17:55:53 2019 13 // Update Count : 627 14 14 // 15 15 … … 105 105 106 106 static void backtrace( int start ) { // skip first N stack frames 107 enum { Frames = 50 , }; // maximum number of stack frames107 enum { Frames = 50 }; 108 108 void * array[Frames]; 109 size_t size = ::backtrace( array, Frames );109 int size = ::backtrace( array, Frames ); 110 110 char ** messages = ::backtrace_symbols( array, size ); // does not demangle names 111 111 … … 114 114 115 115 // skip last 2 stack frames after main 116 for ( unsignedint i = start; i < size - 2 && messages != nullptr; i += 1 ) {116 for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) { 117 117 char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr; 118 118 … … 180 180 } // sigSegvBusHandler 181 181 182 static void sigFpeHandler( SIGPARMS ) {183 const char * msg;184 185 switch ( sfp->si_code ) {186 case FPE_INTDIV: case FPE_FLTDIV: msg = "divide by zero"; break;187 case FPE_FLTOVF: msg = "overflow"; break;188 case FPE_FLTUND: msg = "underflow"; break;189 case FPE_FLTRES: msg = "inexact result"; break;190 case FPE_FLTINV: msg = "invalid operation"; break;191 default: msg = "unknown";192 } // choose193 cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl194 << "Possible cause is constant-expression evaluation invalid." << endl;195 backtrace( 2 ); // skip first 2 stack frames196 abort(); // cause core dump for debugging197 } // sigFpeHandler198 199 182 static void sigAbortHandler( SIGPARMS ) { 200 183 backtrace( 6 ); // skip first 6 stack frames … … 210 193 Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO ); 211 194 Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO ); 212 Signal( SIGFPE, sigFpeHandler, SA_SIGINFO );213 195 Signal( SIGABRT, sigAbortHandler, SA_SIGINFO ); 214 196 -
tests/expression.cfa
r3ecfa13 r0f5da65 1 1 struct S { int i; }; 2 void ?{}( S & s, int i ) { s.i = i;}2 void ?{}( S & s, int i ) {} 3 3 int ?`mary( int ); 4 4 int ?`mary( S ); … … 10 10 int a[3] = { 0, 0, 0 }; 11 11 S s = { 3 }, * ps = &s; 12 [int] t = { 3 };12 [int] t; 13 13 * [int] pt = &t; 14 int i = 1, j = 2;14 int i = 3, j = 4; 15 15 16 16 // operators 17 17 18 ! i;18 ! i; 19 19 ~i; 20 20 +i; … … 26 26 ps--; 27 27 28 i +j;29 i -j;30 i *j;28 i+j; 29 i-j; 30 i*j; 31 31 32 i /j;33 i %j;34 i ^j;35 i &j;36 i |j;37 i <j;38 i >j;39 i =j;32 i/j; 33 i%j; 34 i^j; 35 i&j; 36 i|j; 37 i<j; 38 i>j; 39 i=j; 40 40 41 i ==j;42 i !=j;43 i <<j;44 i >>j;45 i <=j;46 i >=j;47 i &&j;48 i ||j;41 i==j; 42 i!=j; 43 i<<j; 44 i>>j; 45 i<=j; 46 i>=j; 47 i&&j; 48 i||j; 49 49 ps->i; 50 50 51 i *=j;52 i /=j;53 i %=j;54 i +=j;55 i -=j;56 i &=j;57 i |=j;58 i ^=j;59 i <<=j;60 i >>=j;51 i*=j; 52 i/=j; 53 i%=j; 54 i+=j; 55 i-=j; 56 i&=j; 57 i|=j; 58 i^=j; 59 i<<=j; 60 i>>=j; 61 61 62 i ? i :j;62 i?i:j; 63 63 64 64 // postfix function call -
tests/labelledExit.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed Aug 10 07:29:39 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 5 16:49:48 202013 // Update Count : 912 // Last Modified On : Fri Oct 25 17:41:51 2019 13 // Update Count : 7 14 14 // 15 15 … … 162 162 163 163 // computed goto 164 {165 void *array[] = { &&foo, &&bar, &&hack };166 foo: bar: hack:167 &&foo;168 &&bar;169 goto *array[i];170 }164 // { 165 // void *array[] = { &&foo, &&bar, &&hack }; 166 // foo: bar: hack: 167 // &&foo; 168 // &&bar; 169 // goto *array[i]; 170 // } 171 171 172 172 Q: if ( i > 5 ) { -
tests/quotedKeyword.cfa
r3ecfa13 r0f5da65 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:07:07202013 // Update Count : 2 512 // Last Modified On : Sat Feb 1 00:02:22 2020 13 // Update Count : 24 14 14 // 15 15 … … 17 17 18 18 struct { 19 int ``otype ;20 int ``struct ;19 int ``otype``; 20 int ``struct``; 21 21 } st = { 10, 10 }; 22 22 23 typedef int ``forall ;24 ``forall xxx = 10;23 typedef int ``forall``; 24 ``forall`` xxx = 10; 25 25 26 int ``_Alignas , ``_Alignof, ``__alignof, ``__alignof__, ``asm, ``__asm, ``__asm__, ``_At, ``_Atomic, ``__attribute,27 ``__attribute__ , ``auto, ``_Bool, ``break, ``case, ``catch, ``catchResume, ``char, ``choose, ``_Complex, ``__complex,28 ``__complex__ , ``const, ``__const, ``__const__, ``continue, ``default, ``disable, ``do, ``double, ``dtype, ``else,29 ``enable , ``enum, ``__extension__, ``extern, ``fallthru, ``finally, ``float, ``__float128, ``for, ``forall, ``fortran,30 ``ftype , ``_Generic, ``goto, ``if, ``_Imaginary, ``__imag, ``__imag__, ``inline, ``__inline, ``__inline__, ``int,31 ``__int128 , ``__label__, ``long, ``lvalue, ``_Noreturn, ``__builtin_offsetof, ``otype, ``register, ``restrict,32 ``__restrict , ``__restrict__, ``return, ``short, ``signed, ``__signed, ``__signed__, ``sizeof, ``static,33 ``_Static_assert , ``struct, ``switch, ``_Thread_local, ``throw, ``throwResume, ``trait, ``try, ``typedef,34 ``typeof , ``__typeof, ``__typeof__, ``union, ``unsigned, ``__builtin_va_list, ``void, ``volatile, ``__volatile,35 ``__volatile__ , ``while;26 int ``_Alignas``, ``_Alignof``, ``__alignof``, ``__alignof__``, ``asm``, ``__asm``, ``__asm__``, ``_At``, ``_Atomic``, ``__attribute``, 27 ``__attribute__``, ``auto``, ``_Bool``, ``break``, ``case``, ``catch``, ``catchResume``, ``char``, ``choose``, ``_Complex``, ``__complex``, 28 ``__complex__``, ``const``, ``__const``, ``__const__``, ``continue``, ``default``, ``disable``, ``do``, ``double``, ``dtype``, ``else``, 29 ``enable``, ``enum``, ``__extension__``, ``extern``, ``fallthru``, ``finally``, ``float``, ``__float128``, ``for``, ``forall``, ``fortran``, 30 ``ftype``, ``_Generic``, ``goto``, ``if``, ``_Imaginary``, ``__imag``, ``__imag__``, ``inline``, ``__inline``, ``__inline__``, ``int``, 31 ``__int128``, ``__label__``, ``long``, ``lvalue``, ``_Noreturn``, ``__builtin_offsetof``, ``otype``, ``register``, ``restrict``, 32 ``__restrict``, ``__restrict__``, ``return``, ``short``, ``signed``, ``__signed``, ``__signed__``, ``sizeof``, ``static``, 33 ``_Static_assert``, ``struct``, ``switch``, ``_Thread_local``, ``throw``, ``throwResume``, ``trait``, ``try``, ``typedef``, 34 ``typeof``, ``__typeof``, ``__typeof__``, ``union``, ``unsigned``, ``__builtin_va_list``, ``void``, ``volatile``, ``__volatile``, 35 ``__volatile__``, ``while``; 36 36 37 37 int main() { 38 int ``if = 0;39 ``catch = 1;40 st.``otype = 2;41 st.``struct = 3;42 ``throw = 4;43 sout | ``catch + st.``otype + st.``struct + ``throw;38 int ``if`` = 0; 39 ``catch`` = 1; 40 st.``otype`` = 2; 41 st.``struct`` = 3; 42 ``throw`` = 4; 43 sout | ``catch`` + st.``otype`` + st.``struct`` + ``throw``; 44 44 } 45 45
Note:
See TracChangeset
for help on using the changeset viewer.