Changeset 3ecfa13
- Timestamp:
- Feb 8, 2020, 3:21:45 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8c9da33
- Parents:
- 0f5da65 (diff), 74330e7 (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. - Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/assert.cfa
r0f5da65 r3ecfa13 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 21 17:09:26 201913 // Update Count : 512 // Last Modified On : Tue Feb 4 13:00:18 2020 13 // Update Count : 6 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
r0f5da65 r3ecfa13 10 10 // Created On : Thu Mar 30 12:30:01 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 21 17:16:30 201913 // Update Count : 1 012 // Last Modified On : Tue Feb 4 13:03:16 2020 13 // Update Count : 11 14 14 // 15 15 … … 27 27 28 28 extern "C" { 29 30 void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) { 29 void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) { 31 30 // ensure all data is written 32 31 for ( int count = 0, retcode; count < len; count += retcode ) { -
libcfa/src/bits/debug.hfa
r0f5da65 r3ecfa13 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 21 17:06:58 201913 // Update Count : 812 // Last Modified On : Tue Feb 4 12:29:21 2020 13 // Update Count : 9 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 * caller24 #define __cfaabi_dbg_ctx_param2 , const char * caller23 #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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 11 15:42:24 201813 // Update Count : 1 012 // Last Modified On : Tue Feb 4 13:03:19 2020 13 // Update Count : 11 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
r0f5da65 r3ecfa13 87 87 CtxInvokeStub: 88 88 movq %rbx, %rdi 89 jmp *%r12 89 movq %r12, %rsi 90 jmp *%r13 90 91 .size CtxInvokeStub, .-CtxInvokeStub 91 92 -
libcfa/src/concurrency/coroutine.cfa
r0f5da65 r3ecfa13 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Dec 5 14:37:29 201913 // Update Count : 1 512 // Last Modified On : Tue Feb 4 12:29:25 2020 13 // Update Count : 16 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 __suspend_internal(void) { 190 suspend(); 191 } 192 193 void __leave_coroutine( coroutine_desc * src ) { 189 void __leave_coroutine( struct coroutine_desc * src ) { 194 190 coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter; 195 191 … … 207 203 CoroutineCtxSwitch( src, starter ); 208 204 } 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 } 209 217 } 210 218 -
libcfa/src/concurrency/coroutine.hfa
r0f5da65 r3ecfa13 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 3 22:47:58 201913 // Update Count : 1 012 // Last Modified On : Tue Feb 4 12:29:26 2020 13 // Update Count : 11 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 forall(dtype T | is_coroutine(T)) 64 void CtxInvokeCoroutine(T * this); 63 void CtxInvokeCoroutine(void (*main)(void *), void * this); 65 64 66 forall(dtype T | is_coroutine(T))67 void CtxStart(T * this, void ( *invoke)(T*));65 forall(dtype T) 66 void CtxStart(void (*main)(T &), struct coroutine_desc * cor, T & this, void (*invoke)(void (*main)(void *), void *)); 68 67 69 68 extern void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__)); … … 129 128 130 129 if( unlikely(dst->context.SP == 0p) ) { 130 TL_GET( this_thread )->curr_cor = dst; 131 131 __stack_prepare(&dst->stack, 65000); 132 CtxStart(&cor, CtxInvokeCoroutine); 132 CtxStart(main, dst, cor, CtxInvokeCoroutine); 133 TL_GET( this_thread )->curr_cor = src; 133 134 } 134 135 -
libcfa/src/concurrency/invoke.c
r0f5da65 r3ecfa13 29 29 // Called from the kernel when starting a coroutine or task so must switch back to user mode. 30 30 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 ); 31 extern void __leave_coroutine ( struct coroutine_desc * ); 32 extern struct coroutine_desc * __finish_coroutine(void); 33 extern void __leave_thread_monitor(); 35 34 extern void disable_interrupts() OPTIONAL_THREAD; 36 35 extern void enable_interrupts( __cfaabi_dbg_ctx_param ); … … 38 37 void CtxInvokeCoroutine( 39 38 void (*main)(void *), 40 struct coroutine_desc *(*get_coroutine)(void *),41 39 void *this 42 40 ) { 43 struct coroutine_desc* cor = get_coroutine( this ); 41 // Finish setting up the coroutine by setting its state 42 struct coroutine_desc * cor = __finish_coroutine(); 44 43 45 if(cor->state == Primed) { 46 __suspend_internal(); 47 } 48 49 cor->state = Active; 50 44 // Call the main of the coroutine 51 45 main( this ); 52 46 … … 83 77 84 78 void CtxInvokeThread( 85 void (*dtor)(void *),86 79 void (*main)(void *), 87 struct thread_desc *(*get_thread)(void *),88 80 void *this 89 81 ) { 90 // Fetch the thread handle from the user defined thread structure91 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 risk95 __finish_creation( thrd );96 97 82 // Officially start the thread by enabling preemption 98 83 enable_interrupts( __cfaabi_dbg_ctx ); … … 108 93 // The order of these 4 operations is very important 109 94 //Final suspend, should never return 110 __leave_thread_monitor( thrd);95 __leave_thread_monitor(); 111 96 __cabi_abort( "Resumed dead thread" ); 112 97 } 113 98 114 115 99 void CtxStart( 116 100 void (*main)(void *), 117 struct coroutine_desc * (*get_coroutine)(void *),101 struct coroutine_desc * cor, 118 102 void *this, 119 103 void (*invoke)(void *) 120 104 ) { 121 struct coroutine_desc * cor = get_coroutine( this );122 105 struct __stack_t * stack = cor->stack.storage; 123 106 … … 138 121 139 122 fs->dummyReturn = NULL; 140 fs->argument[0] = this; // argument to invoke 123 fs->argument[0] = main; // argument to invoke 124 fs->argument[1] = this; // argument to invoke 141 125 fs->rturn = invoke; 142 126 … … 156 140 fs->dummyReturn = NULL; 157 141 fs->rturn = CtxInvokeStub; 158 fs->fixedRegisters[0] = this; 159 fs->fixedRegisters[1] = invoke; 142 fs->fixedRegisters[0] = main; 143 fs->fixedRegisters[1] = this; 144 fs->fixedRegisters[2] = invoke; 160 145 161 146 #elif defined( __ARM_ARCH ) 162 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) 163 148 struct FakeStack { 164 149 float fpRegs[16]; // floating point registers -
libcfa/src/concurrency/kernel.cfa
r0f5da65 r3ecfa13 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jan 30 22:55:50202013 // Update Count : 5 612 // Last Modified On : Tue Feb 4 13:03:15 2020 13 // Update Count : 58 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; 492 493 __stack_prepare( &dst->stack, 65000 ); 493 CtxStart( &this->runner, CtxInvokeCoroutine);494 CtxStart(main, dst, this->runner, CtxInvokeCoroutine); 494 495 495 496 verify( ! kernelTLS.preemption_state.enabled ); … … 505 506 CtxSwitch( &src->context, &dst->context ); 506 507 // when CtxSwitch returns we are back in the src coroutine 508 509 mainThread->curr_cor = &mainThread->self_cor; 507 510 508 511 // set state of new coroutine to active … … 978 981 __cfaabi_dbg_debug_do( 979 982 extern "C" { 980 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {983 void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) { 981 984 this.prev_name = prev_name; 982 985 this.prev_thrd = kernelTLS.this_thread; -
libcfa/src/concurrency/kernel.hfa
r0f5da65 r3ecfa13 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:54:51 201913 // Update Count : 1812 // Last Modified On : Tue Feb 4 12:29:26 2020 13 // Update Count : 22 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
r0f5da65 r3ecfa13 88 88 // Threads 89 89 extern "C" { 90 forall(dtype T | is_thread(T)) 91 void CtxInvokeThread(T * this); 90 void CtxInvokeThread(void (*main)(void *), void * this); 92 91 } 93 92 -
libcfa/src/concurrency/monitor.cfa
r0f5da65 r3ecfa13 243 243 // last routine called by a thread. 244 244 // Should never return 245 void __leave_thread_monitor( thread_desc * thrd ) { 245 void __leave_thread_monitor() { 246 thread_desc * thrd = TL_GET( this_thread ); 246 247 monitor_desc * this = &thrd->self_mon; 247 248 -
libcfa/src/concurrency/thread.cfa
r0f5da65 r3ecfa13 58 58 void ?{}( scoped(T)& this ) with( this ) { 59 59 handle{}; 60 __thrd_start(handle );60 __thrd_start(handle, main); 61 61 } 62 62 … … 64 64 void ?{}( scoped(T)& this, P params ) with( this ) { 65 65 handle{ params }; 66 __thrd_start(handle );66 __thrd_start(handle, main); 67 67 } 68 68 … … 75 75 // Starting and stopping threads 76 76 forall( dtype T | is_thread(T) ) 77 void __thrd_start( T & this) {77 void __thrd_start( T & this, void (*main_p)(T &) ) { 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(&this, CtxInvokeThread); 82 CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread); 83 83 84 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP]; 84 85 verify( this_thrd->context.SP ); 85 CtxSwitch( &curr_thrd->context, &this_thrd->context );86 // CtxSwitch( &curr_thrd->context, &this_thrd->context ); 86 87 87 88 ScheduleThread(this_thrd); 88 89 enable_interrupts( __cfaabi_dbg_ctx ); 89 }90 91 extern "C" {92 // KERNEL ONLY93 void __finish_creation(thread_desc * this) {94 // set new coroutine that the processor is executing95 // and context switch to it96 verify( kernelTLS.this_thread != this );97 verify( kernelTLS.this_thread->context.SP );98 CtxSwitch( &this->context, &kernelTLS.this_thread->context );99 }100 90 } 101 91 -
libcfa/src/concurrency/thread.hfa
r0f5da65 r3ecfa13 54 54 55 55 forall( dtype T | is_thread(T) ) 56 void __thrd_start( T & this );56 void __thrd_start( T & this, void (*)(T &) ); 57 57 58 58 //----------------------------------------------------------------------------- -
libcfa/src/fstream.cfa
r0f5da65 r3ecfa13 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 29 06:56:46 201913 // Update Count : 3 5512 // Last Modified On : Fri Feb 7 19:01:01 2020 13 // Update Count : 363 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; 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 ) ); 40 41 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 = 0; }59 60 void ?{}( ofstream & os, const char * name, const char * mode) {58 void ?{}( ofstream & os ) { os.$file = 0p; } 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 ) {124 if ( file == 0p ) { 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 = 0; }192 193 void ?{}( ifstream & is, const char * name, const char * mode) {191 void ?{}( ifstream & is ) { is.$file = 0p; } 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 == 0 || ferror( (FILE *)(is.file) );210 return is.$file == 0p || 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 ) {220 if ( file == 0p ) { 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
r0f5da65 r3ecfa13 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 29 06:56:02 201913 // Update Count : 1 6812 // Last Modified On : Fri Feb 7 19:00:51 2020 13 // Update Count : 174 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 13 15:25:05 201913 // Update Count : 2 712 // Last Modified On : Fri Feb 7 22:10:30 2020 13 // Update Count : 29 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 8 21:01:31 201913 // Update Count : 64 712 // Last Modified On : Tue Feb 4 10:04:51 2020 13 // Update Count : 648 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
r0f5da65 r3ecfa13 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 30 17:47:32202013 // Update Count : 1 5612 // Last Modified On : Sat Feb 8 08:40:34 2020 13 // Update Count : 163 14 14 // 15 15 … … 29 29 #include "bits/signal.hfa" // sigHandler_? 30 30 #include "startup.hfa" // STARTUP_PRIORITY_CORE 31 #include <assert.h> 31 32 32 33 //============================================================================================= … … 40 41 41 42 typedef void (* generic_fptr_t)(void); 42 generic_fptr_t interpose_symbol( const char * symbol, const char * version) {43 generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) { 43 44 const char * error; 44 45 … … 145 146 extern "C" { 146 147 void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) { 147 abort( false, NULL ); // FIX ME: 0p does not work148 abort( false, "%s", "" ); 148 149 } 149 150 … … 161 162 162 163 void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; } 163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}164 void kernel_abort_msg( void * data, char buffer[], int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 164 165 // See concurrency/kernel.cfa for strong definition used in multi-processor mode. 165 166 int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; } … … 169 170 170 171 static void __cfaabi_backtrace( int start ) { 171 enum { 172 Frames = 50, // maximum number of stack frames 173 }; 172 enum { Frames = 50, }; // maximum number of stack frames 174 173 int last = kernel_abort_lastframe(); // skip last N stack frames 175 174 176 175 void * array[Frames]; 177 176 size_t size = backtrace( array, Frames ); 178 char ** messages = backtrace_symbols( array, size ); 177 char ** messages = backtrace_symbols( array, size ); // does not demangle names 179 178 180 179 *index( messages[0], '(' ) = '\0'; // find executable name … … 184 183 char * name = 0p, * offset_begin = 0p, * offset_end = 0p; 185 184 186 for ( char * p = messages[i]; *p; ++p ) {// find parantheses and +offset185 for ( char * p = messages[i]; *p; p += 1 ) { // find parantheses and +offset 187 186 //__cfaabi_bits_print_nolock( "X %s\n", p); 188 187 if ( *p == '(' ) { … … 228 227 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 229 228 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 } 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 ); 241 239 } 242 240 -
libcfa/src/iostream.cfa
r0f5da65 r3ecfa13 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 13 08:07:59 201913 // Update Count : 82 112 // Last Modified On : Fri Feb 7 18:48:38 2020 13 // Update Count : 825 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 void ?|?( ostype & os, const char * str ) { 277 278 void ?|?( ostype & os, const char str[] ) { 278 279 (ostype &)(os | str); ends( os ); 279 280 } // ?|? 280 281 281 282 // ostype & ?|?( ostype & os, const char16_t * str ) { 282 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );283 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 283 284 // fmt( os, "%ls", str ); 284 285 // return os; … … 287 288 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 288 289 // ostype & ?|?( ostype & os, const char32_t * str ) { 289 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );290 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 290 291 // fmt( os, "%ls", str ); 291 292 // return os; … … 294 295 295 296 // ostype & ?|?( ostype & os, const wchar_t * str ) { 296 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );297 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 297 298 // fmt( os, "%ls", str ); 298 299 // return os; … … 300 301 301 302 ostype & ?|?( ostype & os, const void * p ) { 302 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );303 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 303 304 fmt( os, "%p", p ); 304 305 return os; … … 315 316 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 316 317 (ostype &)(manip( os )); 317 if ( getPrt( os ) ) ends( os );// something printed ?318 setPrt( os, false ); // turn off318 if ( $getPrt( os ) ) ends( os ); // something printed ? 319 $setPrt( os, false ); // turn off 319 320 } // ?|? 320 321 … … 329 330 ostype & nl( ostype & os ) { 330 331 (ostype &)(os | '\n'); 331 setPrt( os, false ); // turn off332 setNL( os, true );332 $setPrt( os, false ); // turn off 333 $setNL( os, true ); 333 334 flush( os ); 334 335 return sepOff( os ); // prepare for next line … … 336 337 337 338 ostype & nonl( ostype & os ) { 338 setPrt( os, false ); // turn off339 $setPrt( os, false ); // turn off 339 340 return os; 340 341 } // nonl … … 375 376 ostype & ?|?( ostype & os, T arg, Params rest ) { 376 377 (ostype &)(os | arg); // print first argument 377 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator378 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 378 379 (ostype &)(os | rest); // print remaining arguments 379 sepSetCur( os, sepGet( os ) ); // switch to regular separator380 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 380 381 return os; 381 382 } // ?|? … … 383 384 // (ostype &)(?|?( os, arg, rest )); ends( os ); 384 385 (ostype &)(os | arg); // print first argument 385 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator386 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 386 387 (ostype &)(os | rest); // print remaining arguments 387 sepSetCur( os, sepGet( os ) ); // switch to regular separator388 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 388 389 ends( os ); 389 390 } // ?|? … … 414 415 forall( dtype ostype | ostream( ostype ) ) { \ 415 416 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 416 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \417 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 417 418 \ 418 419 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 513 514 forall( dtype ostype | ostream( ostype ) ) { \ 514 515 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 515 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \516 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 516 517 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 517 518 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 536 537 return os; \ 537 538 } /* ?|? */ \ 539 \ 538 540 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 539 541 } // distribution … … 555 557 } // if 556 558 557 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );559 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 558 560 559 561 #define CFMTNP "% * " … … 571 573 return os; 572 574 } // ?|? 575 573 576 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 574 577 } // distribution … … 592 595 } // if 593 596 594 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );597 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 595 598 596 599 #define SFMTNP "% * " … … 616 619 return os; 617 620 } // ?|? 621 618 622 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 619 623 } // distribution … … 735 739 } // ?|? 736 740 737 // istype & ?|?( istype & is, const char * fmt) {741 // istype & ?|?( istype & is, const char fmt[] ) { 738 742 // fmt( is, fmt, "" ); 739 743 // return is; -
libcfa/src/iostream.hfa
r0f5da65 r3ecfa13 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 12 12:08:38 201913 // Update Count : 33 412 // Last Modified On : Fri Feb 7 17:53:52 2020 13 // Update Count : 336 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
r0f5da65 r3ecfa13 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 13 11:02:15 201813 // Update Count : 11 612 // Last Modified On : Tue Feb 4 10:27:11 2020 13 // Update Count : 117 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Jul 24 16:21:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 13:16:45 201913 // Update Count : 2912 // Last Modified On : Tue Feb 4 13:03:18 2020 13 // Update Count : 30 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
r0f5da65 r3ecfa13 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 31 23:09:32 201713 // Update Count : 1 312 // Last Modified On : Tue Feb 4 12:58:49 2020 13 // Update Count : 15 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Jul 18 07:26:04 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:15:29202013 // Update Count : 512 // Last Modified On : Fri Feb 7 19:05:08 2020 13 // Update Count : 6 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Jul 18 07:45:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:15:39202013 // Update Count : 512 // Last Modified On : Fri Feb 7 19:05:18 2020 13 // Update Count : 6 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Jul 18 07:55:44 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:15:47202013 // Update Count : 512 // Last Modified On : Fri Feb 7 19:05:35 2020 13 // Update Count : 6 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
r0f5da65 r3ecfa13 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:15:58202013 // Update Count : 1 412 // Last Modified On : Fri Feb 7 19:05:27 2020 13 // Update Count : 15 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
r0f5da65 r3ecfa13 10 10 // Created On : Thu Feb 8 23:48:16 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 07:16:05202013 // Update Count : 512 // Last Modified On : Fri Feb 7 19:05:41 2020 13 // Update Count : 6 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
r0f5da65 r3ecfa13 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Nov 20 17:22:47 201913 // Update Count : 48 512 // Last Modified On : Tue Feb 4 08:27:08 2020 13 // Update Count : 486 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
r0f5da65 r3ecfa13 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 29 23:08:02 201913 // Update Count : 40 012 // Last Modified On : Tue Feb 4 08:27:01 2020 13 // Update Count : 401 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
r0f5da65 r3ecfa13 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 17:27:40202013 // Update Count : 6912 // Last Modified On : Tue Feb 4 08:24:18 2020 13 // Update Count : 70 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
r0f5da65 r3ecfa13 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 6 12:50:16202013 // Update Count : 65 312 // Last Modified On : Tue Feb 4 08:24:32 2020 13 // Update Count : 654 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
r0f5da65 r3ecfa13 3302 3302 VISIT_START( node ); 3303 3303 3304 indexerAdd Struct( node->name );3304 indexerAddUnion( node->name ); 3305 3305 3306 3306 { … … 3317 3317 VISIT_START( node ); 3318 3318 3319 indexerAdd Struct( node->name );3319 indexerAddUnion( node->name ); 3320 3320 3321 3321 { … … 3332 3332 MUTATE_START( node ); 3333 3333 3334 indexerAdd Struct( node->name );3334 indexerAddUnion( node->name ); 3335 3335 3336 3336 { -
src/Concurrency/Keywords.cc
r0f5da65 r3ecfa13 716 716 new UntypedExpr( 717 717 new NameExpr( "__thrd_start" ), 718 { new VariableExpr( param ) }718 { new VariableExpr( param ), new NameExpr("main") } 719 719 ) 720 720 ) -
src/Parser/ParseNode.h
r0f5da65 r3ecfa13 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 07:46:01 201913 // Update Count : 8 8812 // Last Modified On : Fri Feb 7 17:56:02 2020 13 // Update Count : 891 14 14 // 15 15 … … 449 449 * out++ = result; 450 450 } else { 451 assertf(false, "buildList unknown type");451 SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented." ); 452 452 } // if 453 453 } catch( SemanticErrorException & e ) { -
src/Parser/lex.ll
r0f5da65 r3ecfa13 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Sat Feb 1 07:16:44202013 * Update Count : 72 412 * Last Modified On : Fri Feb 7 19:02:43 2020 13 * Update Count : 725 14 14 */ 15 15 … … 330 330 /* identifier */ 331 331 {identifier} { IDENTIFIER_RETURN(); } 332 "``"{identifier} "``" {// CFA333 yytext[yyleng - 2] = '\0'; yytext += 2;// SKULLDUGGERY: remove backquotes (ok to shorten?)332 "``"{identifier} { // CFA 333 yytext[yyleng] = '\0'; yytext += 2; // SKULLDUGGERY: remove backquotes (ok to shorten?) 334 334 IDENTIFIER_RETURN(); 335 335 } -
src/main.cc
r0f5da65 r3ecfa13 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 17:55:53 201913 // Update Count : 6 2712 // Last Modified On : Sat Feb 8 08:33:50 2020 13 // Update Count : 633 14 14 // 15 15 … … 105 105 106 106 static void backtrace( int start ) { // skip first N stack frames 107 enum { Frames = 50 };107 enum { Frames = 50, }; // maximum number of stack frames 108 108 void * array[Frames]; 109 int size = ::backtrace( array, Frames );109 size_t 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 ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {116 for ( unsigned 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 } // choose 193 cerr << "Computation error " << msg << " at location " << sfp->si_addr << endl 194 << "Possible cause is constant-expression evaluation invalid." << endl; 195 backtrace( 2 ); // skip first 2 stack frames 196 abort(); // cause core dump for debugging 197 } // sigFpeHandler 198 182 199 static void sigAbortHandler( SIGPARMS ) { 183 200 backtrace( 6 ); // skip first 6 stack frames … … 193 210 Signal( SIGSEGV, sigSegvBusHandler, SA_SIGINFO ); 194 211 Signal( SIGBUS, sigSegvBusHandler, SA_SIGINFO ); 212 Signal( SIGFPE, sigFpeHandler, SA_SIGINFO ); 195 213 Signal( SIGABRT, sigAbortHandler, SA_SIGINFO ); 196 214 -
tests/expression.cfa
r0f5da65 r3ecfa13 1 1 struct S { int i; }; 2 void ?{}( S & s, int i ) { }2 void ?{}( S & s, int i ) { s.i = 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 ;12 [int] t = { 3 }; 13 13 * [int] pt = &t; 14 int i = 3, j = 4;14 int i = 1, j = 2; 15 15 16 16 // operators 17 17 18 ! 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
r0f5da65 r3ecfa13 10 10 // Created On : Wed Aug 10 07:29:39 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Oct 25 17:41:51 201913 // Update Count : 712 // Last Modified On : Wed Feb 5 16:49:48 2020 13 // Update Count : 9 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
r0f5da65 r3ecfa13 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 1 00:02:22202013 // Update Count : 2 412 // Last Modified On : Fri Feb 7 19:07:07 2020 13 // Update Count : 25 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.