Changeset a505021 for libcfa/src
- Timestamp:
- Feb 21, 2020, 3:36:36 PM (6 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:
- c7a900a
- Parents:
- 8c50aed (diff), c744563a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- libcfa/src
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/assert.cfa
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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/coroutine.cfa
r8c50aed ra505021 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}; -
libcfa/src/concurrency/coroutine.hfa
r8c50aed ra505021 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 //----------------------------------------------------------------------------- -
libcfa/src/concurrency/kernel.cfa
r8c50aed ra505021 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 … … 210 210 static void * CtxInvokeProcessor(void * arg); 211 211 212 void ?{}(processor & this, const char * name, cluster & cltr) with( this ) {212 void ?{}(processor & this, const char name[], cluster & cltr) with( this ) { 213 213 this.name = name; 214 214 this.cltr = &cltr; … … 244 244 } 245 245 246 void ?{}(cluster & this, const char * name, Duration preemption_rate) with( this ) {246 void ?{}(cluster & this, const char name[], Duration preemption_rate) with( this ) { 247 247 this.name = name; 248 248 this.preemption_rate = preemption_rate; … … 459 459 } 460 460 461 static void Abort( int ret, const char * func) {461 static void Abort( int ret, const char func[] ) { 462 462 if ( ret ) { // pthread routines return errno values 463 463 abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) ); … … 960 960 __cfaabi_dbg_debug_do( 961 961 extern "C" { 962 void __cfaabi_dbg_record(__spinlock_t & this, const char * prev_name) {962 void __cfaabi_dbg_record(__spinlock_t & this, const char prev_name[]) { 963 963 this.prev_name = prev_name; 964 964 this.prev_thrd = kernelTLS.this_thread; -
libcfa/src/concurrency/kernel.hfa
r8c50aed ra505021 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 … … 101 101 }; 102 102 103 void ?{}(processor & this, const char * name, struct cluster & cltr);103 void ?{}(processor & this, const char name[], struct cluster & cltr); 104 104 void ^?{}(processor & this); 105 105 106 106 static inline void ?{}(processor & this) { this{ "Anonymous Processor", *mainCluster}; } 107 107 static inline void ?{}(processor & this, struct cluster & cltr) { this{ "Anonymous Processor", cltr}; } 108 static inline void ?{}(processor & this, const char * name) { this{name, *mainCluster }; }108 static inline void ?{}(processor & this, const char name[]) { this{name, *mainCluster }; } 109 109 110 110 static inline [processor *&, processor *& ] __get( processor & this ) /*__attribute__((const))*/ { return this.node.[next, prev]; } … … 144 144 extern Duration default_preemption(); 145 145 146 void ?{} (cluster & this, const char * name, Duration preemption_rate);146 void ?{} (cluster & this, const char name[], Duration preemption_rate); 147 147 void ^?{}(cluster & this); 148 148 149 149 static inline void ?{} (cluster & this) { this{"Anonymous Cluster", default_preemption()}; } 150 150 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; } 151 static inline void ?{} (cluster & this, const char * name) { this{name, default_preemption()}; }151 static inline void ?{} (cluster & this, const char name[]) { this{name, default_preemption()}; } 152 152 153 153 static inline [cluster *&, cluster *& ] __get( cluster & this ) /*__attribute__((const))*/ { return this.node.[next, prev]; } -
libcfa/src/exception.c
r8c50aed ra505021 248 248 } 249 249 250 #if defined(PIC) 251 #warning Exceptions not yet supported when using Position-Independent Code 252 __attribute__((noinline)) 253 void __cfaabi_ehm__try_terminate(void (*try_block)(), 254 void (*catch_block)(int index, exception_t * except), 255 __attribute__((unused)) int (*match_block)(exception_t * except)) { 256 abort(); 257 } 258 #else // PIC 250 #pragma GCC push_options 251 #pragma GCC optimize("O0") 252 259 253 // This is our personality routine. For every stack frame annotated with 260 254 // ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding. … … 431 425 432 426 // Setup the personality routine and exception table. 427 #ifdef __PIC__ 428 asm volatile (".cfi_personality 0x9b,CFA.ref.__gcfa_personality_v0"); 429 asm volatile (".cfi_lsda 0x1b, .LLSDACFA2"); 430 #else 433 431 asm volatile (".cfi_personality 0x3,__gcfa_personality_v0"); 434 432 asm volatile (".cfi_lsda 0x3, .LLSDACFA2"); 433 #endif 435 434 436 435 // Label which defines the start of the area for which the handler is setup. … … 464 463 // have a single call to the try routine. 465 464 465 #ifdef __PIC__ 466 #if defined( __i386 ) || defined( __x86_64 ) 467 asm ( 468 // HEADER 469 ".LFECFA1:\n" 470 " .globl __gcfa_personality_v0\n" 471 " .section .gcc_except_table,\"a\",@progbits\n" 472 // TABLE HEADER (important field is the BODY length at the end) 473 ".LLSDACFA2:\n" 474 " .byte 0xff\n" 475 " .byte 0xff\n" 476 " .byte 0x1\n" 477 " .uleb128 .LLSDACSECFA2-.LLSDACSBCFA2\n" 478 // BODY (language specific data) 479 // This uses language specific data and can be modified arbitrarily 480 // We use handled area offset, handled area length, 481 // handler landing pad offset and 1 (action code, gcc seems to use 0). 482 ".LLSDACSBCFA2:\n" 483 " .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n" 484 " .uleb128 .TRYEND-.TRYSTART\n" 485 " .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n" 486 " .uleb128 1\n" 487 ".LLSDACSECFA2:\n" 488 // TABLE FOOTER 489 " .text\n" 490 " .size __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n" 491 ); 492 493 // Somehow this piece of helps with the resolution of debug symbols. 494 __attribute__((unused)) static const int dummy = 0; 495 496 asm ( 497 // Add a hidden symbol which points at the function. 498 " .hidden CFA.ref.__gcfa_personality_v0\n" 499 " .weak CFA.ref.__gcfa_personality_v0\n" 500 // No clue what this does specifically 501 " .section .data.rel.local.CFA.ref.__gcfa_personality_v0,\"awG\",@progbits,CFA.ref.__gcfa_personality_v0,comdat\n" 502 " .align 8\n" 503 " .type CFA.ref.__gcfa_personality_v0, @object\n" 504 " .size CFA.ref.__gcfa_personality_v0, 8\n" 505 "CFA.ref.__gcfa_personality_v0:\n" 506 #if defined( __x86_64 ) 507 " .quad __gcfa_personality_v0\n" 508 #else // then __i386 509 " .long __gcfa_personality_v0\n" 510 #endif 511 ); 512 #else 513 #error Exception Handling: unknown architecture for position independent code. 514 #endif // __i386 || __x86_64 515 #else // __PIC__ 466 516 #if defined( __i386 ) || defined( __x86_64 ) 467 517 asm ( … … 491 541 " .size __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n" 492 542 " .ident \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n" 493 //" .section .note.GNU-stack,\"x\",@progbits\n"543 " .section .note.GNU-stack,\"x\",@progbits\n" 494 544 ); 545 #else 546 #error Exception Handling: unknown architecture for position dependent code. 495 547 #endif // __i386 || __x86_64 496 #endif // PIC 548 #endif // __PIC__ 549 550 #pragma GCC pop_options -
libcfa/src/fstream.cfa
r8c50aed ra505021 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
r8c50aed ra505021 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 : Mon Feb 17 08:29:23 2020 13 // Update Count : 175 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 );69 int fmt( ofstream &, const char format[], ... ) ;68 ofstream & write( ofstream &, const char data[], size_t size ); 69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 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 ); 98 98 ifstream & ungetc( ifstream & is, char c ); 99 int fmt( ifstream &, const char format[], ... ) ;99 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); 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
r8c50aed ra505021 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at Jul 13 15:25:05 201913 // Update Count : 2712 // Last Modified On : Sun Feb 9 09:56:54 2020 13 // Update Count : 31 14 14 // 15 15 … … 24 24 25 25 static inline { 26 // constructor 26 // constructor, zero_t/one_t are unnecessary because of relationship with signed/unsigned int 27 27 void ?{}( Int & this ) { mpz_init( this.mpz ); } 28 28 void ?{}( Int & this, Int init ) { mpz_init_set( this.mpz, init.mpz ); } 29 void ?{}( Int & this, zero_t ) { mpz_init_set_si( this.mpz, 0 ); }30 void ?{}( Int & this, one_t ) { mpz_init_set_si( this.mpz, 1 ); }31 29 void ?{}( Int & this, signed long int init ) { mpz_init_set_si( this.mpz, init ); } 32 30 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(); }31 void ?{}( Int & this, const char val[] ) { if ( mpz_init_set_str( this.mpz, val, 0 ) ) abort(); } 34 32 void ^?{}( Int & this ) { mpz_clear( this.mpz ); } 35 33 … … 37 35 Int ?`mp( signed long int init ) { return (Int){ init }; } 38 36 Int ?`mp( unsigned long int init ) { return (Int){ init }; } 39 Int ?`mp( const char * init) { return (Int){ init }; }37 Int ?`mp( const char init[] ) { return (Int){ init }; } 40 38 41 39 // assignment … … 43 41 Int ?=?( Int & lhs, long int rhs ) { mpz_set_si( lhs.mpz, rhs ); return lhs; } 44 42 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; }43 Int ?=?( Int & lhs, const char rhs[] ) { if ( mpz_set_str( lhs.mpz, rhs, 0 ) ) { abort | "invalid string conversion"; } return lhs; } 46 44 47 45 char ?=?( char & lhs, Int rhs ) { char val = mpz_get_si( rhs.mpz ); lhs = val; return lhs; } … … 265 263 forall( dtype ostype | ostream( ostype ) ) { 266 264 ostype & ?|?( ostype & os, Int mp ) { 267 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );265 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 268 266 gmp_printf( "%Zd", mp.mpz ); 269 267 sepOn( os ); -
libcfa/src/heap.cfa
r8c50aed ra505021 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
r8c50aed ra505021 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 : Mon Feb 17 10:18:53 2020 13 // Update Count : 166 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 } 241 } 242 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 ); 239 } // if 243 240 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 244 __cfaabi_backtrace( signalAbort ? 4 : 3 ); 241 242 __cfaabi_backtrace( signalAbort ? 4 : 2 ); 245 243 246 244 __cabi_libc.abort(); // print stack trace in handler -
libcfa/src/iostream.cfa
r8c50aed ra505021 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 : Thu Feb 20 15:53:23 2020 13 // Update Count : 829 14 14 // 15 15 … … 19 19 #include <stdio.h> 20 20 #include <stdbool.h> // true/false 21 #include <stdint.h> // UINT64_MAX 21 22 //#include <string.h> // strlen, strcmp 22 23 extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); … … 35 36 forall( dtype ostype | ostream( ostype ) ) { 36 37 ostype & ?|?( ostype & os, zero_t ) { 37 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );38 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 38 39 fmt( os, "%d", 0n ); 39 40 return os; … … 44 45 45 46 ostype & ?|?( ostype & os, one_t ) { 46 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );47 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 47 48 fmt( os, "%d", 1n ); 48 49 return os; … … 53 54 54 55 ostype & ?|?( ostype & os, bool b ) { 55 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );56 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 56 57 fmt( os, "%s", b ? "true" : "false" ); 57 58 return os; … … 63 64 ostype & ?|?( ostype & os, char c ) { 64 65 fmt( os, "%c", c ); 65 if ( c == '\n' ) setNL( os, true );66 if ( c == '\n' ) $setNL( os, true ); 66 67 return sepOff( os ); 67 68 } // ?|? … … 71 72 72 73 ostype & ?|?( ostype & os, signed char sc ) { 73 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );74 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 74 75 fmt( os, "%hhd", sc ); 75 76 return os; … … 80 81 81 82 ostype & ?|?( ostype & os, unsigned char usc ) { 82 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );83 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 83 84 fmt( os, "%hhu", usc ); 84 85 return os; … … 89 90 90 91 ostype & ?|?( ostype & os, short int si ) { 91 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );92 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 92 93 fmt( os, "%hd", si ); 93 94 return os; … … 98 99 99 100 ostype & ?|?( ostype & os, unsigned short int usi ) { 100 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );101 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 101 102 fmt( os, "%hu", usi ); 102 103 return os; … … 107 108 108 109 ostype & ?|?( ostype & os, int i ) { 109 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );110 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 110 111 fmt( os, "%d", i ); 111 112 return os; … … 116 117 117 118 ostype & ?|?( ostype & os, unsigned int ui ) { 118 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );119 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 119 120 fmt( os, "%u", ui ); 120 121 return os; … … 125 126 126 127 ostype & ?|?( ostype & os, long int li ) { 127 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );128 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 128 129 fmt( os, "%ld", li ); 129 130 return os; … … 134 135 135 136 ostype & ?|?( ostype & os, unsigned long int uli ) { 136 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );137 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 137 138 fmt( os, "%lu", uli ); 138 139 return os; … … 143 144 144 145 ostype & ?|?( ostype & os, long long int lli ) { 145 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );146 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 146 147 fmt( os, "%lld", lli ); 147 148 return os; … … 152 153 153 154 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 154 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );155 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 155 156 fmt( os, "%llu", ulli ); 156 157 return os; … … 159 160 (ostype &)(os | ulli); ends( os ); 160 161 } // ?|? 162 163 #if defined( __SIZEOF_INT128__ ) 164 // UINT64_MAX 18_446_744_073_709_551_615_ULL 165 #define P10_UINT64 10_000_000_000_000_000_000_ULL // 19 zeroes 166 167 static void base10_128( ostype & os, unsigned int128 val ) { 168 if ( val > UINT64_MAX ) { 169 base10_128( os, val / P10_UINT64 ); // recursive 170 fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) ); 171 } else { 172 fmt( os, "%lu", (uint64_t)val ); 173 } // if 174 } // base10_128 175 176 static void base10_128( ostype & os, int128 val ) { 177 if ( val < 0 ) { 178 fmt( os, "-" ); // leading negative sign 179 val = -val; 180 } // if 181 base10_128( os, (unsigned int128)val ); // print zero/positive value 182 } // base10_128 183 184 ostype & ?|?( ostype & os, int128 llli ) { 185 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 186 base10_128( os, llli ); 187 return os; 188 } // ?|? 189 void & ?|?( ostype & os, int128 llli ) { 190 (ostype &)(os | llli); ends( os ); 191 } // ?|? 192 193 ostype & ?|?( ostype & os, unsigned int128 ullli ) { 194 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 195 base10_128( os, ullli ); 196 return os; 197 } // ?|? 198 void & ?|?( ostype & os, unsigned int128 ullli ) { 199 (ostype &)(os | ullli); ends( os ); 200 } // ?|? 201 #endif // __SIZEOF_INT128__ 161 202 162 203 #define PrintWithDP( os, format, val, ... ) \ … … 175 216 176 217 ostype & ?|?( ostype & os, float f ) { 177 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );218 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 178 219 PrintWithDP( os, "%g", f ); 179 220 return os; … … 184 225 185 226 ostype & ?|?( ostype & os, double d ) { 186 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );227 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 187 228 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 188 229 return os; … … 193 234 194 235 ostype & ?|?( ostype & os, long double ld ) { 195 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );236 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 196 237 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 197 238 return os; … … 202 243 203 244 ostype & ?|?( ostype & os, float _Complex fc ) { 204 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );245 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 205 246 // os | crealf( fc ) | nonl; 206 247 PrintWithDP( os, "%g", crealf( fc ) ); … … 214 255 215 256 ostype & ?|?( ostype & os, double _Complex dc ) { 216 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );257 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 217 258 // os | creal( dc ) | nonl; 218 259 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 226 267 227 268 ostype & ?|?( ostype & os, long double _Complex ldc ) { 228 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );269 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 229 270 // os | creall( ldc ) || nonl; 230 271 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 237 278 } // ?|? 238 279 239 ostype & ?|?( ostype & os, const char * str) {280 ostype & ?|?( ostype & os, const char str[] ) { 240 281 enum { Open = 1, Close, OpenClose }; 241 282 static const unsigned char mask[256] @= { … … 257 298 // first character IS NOT spacing or closing punctuation => add left separator 258 299 unsigned char ch = str[0]; // must make unsigned 259 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {260 fmt( os, "%s", sepGetCur( os ) );300 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 301 fmt( os, "%s", $sepGetCur( os ) ); 261 302 } // if 262 303 263 304 // if string starts line, must reset to determine open state because separator is off 264 sepReset( os );// reset separator305 $sepReset( os ); // reset separator 265 306 266 307 // last character IS spacing or opening punctuation => turn off separator for next item 267 308 size_t len = strlen( str ); 268 309 ch = str[len - 1]; // must make unsigned 269 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {310 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 270 311 sepOn( os ); 271 312 } else { 272 313 sepOff( os ); 273 314 } // if 274 if ( ch == '\n' ) setNL( os, true ); // check *AFTER*sepPrt call above as it resets NL flag315 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag 275 316 return write( os, str, len ); 276 317 } // ?|? 277 void ?|?( ostype & os, const char * str ) { 318 319 void ?|?( ostype & os, const char str[] ) { 278 320 (ostype &)(os | str); ends( os ); 279 321 } // ?|? 280 322 281 323 // ostype & ?|?( ostype & os, const char16_t * str ) { 282 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );324 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 283 325 // fmt( os, "%ls", str ); 284 326 // return os; … … 287 329 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 288 330 // ostype & ?|?( ostype & os, const char32_t * str ) { 289 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );331 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 290 332 // fmt( os, "%ls", str ); 291 333 // return os; … … 294 336 295 337 // ostype & ?|?( ostype & os, const wchar_t * str ) { 296 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );338 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 297 339 // fmt( os, "%ls", str ); 298 340 // return os; … … 300 342 301 343 ostype & ?|?( ostype & os, const void * p ) { 302 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );344 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 303 345 fmt( os, "%p", p ); 304 346 return os; … … 315 357 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 316 358 (ostype &)(manip( os )); 317 if ( getPrt( os ) ) ends( os );// something printed ?318 setPrt( os, false ); // turn off359 if ( $getPrt( os ) ) ends( os ); // something printed ? 360 $setPrt( os, false ); // turn off 319 361 } // ?|? 320 362 … … 329 371 ostype & nl( ostype & os ) { 330 372 (ostype &)(os | '\n'); 331 setPrt( os, false ); // turn off332 setNL( os, true );373 $setPrt( os, false ); // turn off 374 $setNL( os, true ); 333 375 flush( os ); 334 376 return sepOff( os ); // prepare for next line … … 336 378 337 379 ostype & nonl( ostype & os ) { 338 setPrt( os, false ); // turn off380 $setPrt( os, false ); // turn off 339 381 return os; 340 382 } // nonl … … 375 417 ostype & ?|?( ostype & os, T arg, Params rest ) { 376 418 (ostype &)(os | arg); // print first argument 377 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator419 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 378 420 (ostype &)(os | rest); // print remaining arguments 379 sepSetCur( os, sepGet( os ) ); // switch to regular separator421 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 380 422 return os; 381 423 } // ?|? … … 383 425 // (ostype &)(?|?( os, arg, rest )); ends( os ); 384 426 (ostype &)(os | arg); // print first argument 385 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator427 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 386 428 (ostype &)(os | rest); // print remaining arguments 387 sepSetCur( os, sepGet( os ) ); // switch to regular separator429 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 388 430 ends( os ); 389 431 } // ?|? … … 414 456 forall( dtype ostype | ostream( ostype ) ) { \ 415 457 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 416 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \458 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 417 459 \ 418 460 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 463 505 \ 464 506 if ( ! f.flags.pc ) { /* no precision */ \ 465 /* printf( "%s\n", &fmtstr[star] ); */ \466 507 fmtstr[sizeof(IFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 508 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \ 467 509 fmt( os, &fmtstr[star], f.wd, f.val ); \ 468 510 } else { /* precision */ \ 469 511 fmtstr[sizeof(IFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 470 /* printf( "%s \n", &fmtstr[star]); */ \512 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \ 471 513 fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \ 472 514 } /* if */ \ … … 486 528 IntegralFMTImpl( signed long long int, 'd', "% *ll ", "% *.*ll " ) 487 529 IntegralFMTImpl( unsigned long long int, 'u', "% *ll ", "% *.*ll " ) 530 531 532 #if defined( __SIZEOF_INT128__ ) 533 // Default prefix for non-decimal prints is 0b, 0, 0x. 534 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \ 535 forall( dtype ostype | ostream( ostype ) ) \ 536 static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \ 537 if ( fmt.val > UINT64_MAX ) { \ 538 fmt.val /= P10_UINT64; \ 539 base10_128( os, fmt ); /* recursive */ \ 540 _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \ 541 fmt2.flags.nobsdp = true; \ 542 printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all ); \ 543 sepOff( os ); \ 544 (ostype &)(os | fmt2); \ 545 } else { \ 546 printf( "fmt %c %lld %d\n", fmt.base, fmt.val, fmt.all ); \ 547 (ostype &)(os | fmt); \ 548 } /* if */ \ 549 } /* base10_128 */ \ 550 forall( dtype ostype | ostream( ostype ) ) { \ 551 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 552 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 553 \ 554 if ( f.base == 'b' | f.base == 'o' | f.base == 'x' | f.base == 'X' ) { \ 555 unsigned long long int msig = (unsigned long long int)(f.val >> 64); \ 556 unsigned long long int lsig = (unsigned long long int)(f.val); \ 557 _Ostream_Manip(SIGNED long long int) fmt @= { msig, f.wd, f.pc, f.base, { .all : f.all } }; \ 558 _Ostream_Manip(unsigned long long int) fmt2 @= { lsig, 0, 0, f.base, { .all : 0 } }; \ 559 if ( msig == 0 ) { \ 560 fmt.val = lsig; \ 561 (ostype &)(os | fmt); \ 562 } else { \ 563 fmt2.flags.pad0 = fmt2.flags.nobsdp = true; \ 564 if ( f.base == 'b' ) { \ 565 if ( f.wd > 64 ) fmt.wd = f.wd - 64; \ 566 fmt2.wd = 64; \ 567 (ostype &)(os | fmt | "" | fmt2); \ 568 } else if ( f.base == 'o' ) { \ 569 fmt.val = (unsigned long long int)fmt.val >> 2; \ 570 if ( f.wd > 21 ) fmt.wd = f.wd - 21; \ 571 fmt2.wd = 1; \ 572 fmt2.val = ((msig & 0x3) << 1) + 1; \ 573 (ostype &)(os | fmt | "" | fmt2); \ 574 sepOff( os ); \ 575 fmt2.wd = 21; \ 576 fmt2.val = lsig & 0x7fffffffffffffff; \ 577 (ostype &)(os | fmt2); \ 578 } else { \ 579 if ( f.flags.left ) { \ 580 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \ 581 fmt.wd = 16; \ 582 } else { \ 583 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \ 584 fmt2.wd = 16; \ 585 } /* if */ \ 586 (ostype &)(os | fmt | "" | fmt2); \ 587 } /* if */ \ 588 } /* if */ \ 589 } else { \ 590 base10_128( os, f ); \ 591 } /* if */ \ 592 return os; \ 593 } /* ?|? */ \ 594 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 595 } // distribution 596 597 IntegralFMTImpl128( int128, signed, 'd', "% *ll ", "% *.*ll " ) 598 IntegralFMTImpl128( unsigned int128, unsigned, 'u', "% *ll ", "% *.*ll " ) 599 #endif // __SIZEOF_INT128__ 488 600 489 601 //*********************************** floating point *********************************** … … 513 625 forall( dtype ostype | ostream( ostype ) ) { \ 514 626 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 515 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \627 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 516 628 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 517 629 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 536 648 return os; \ 537 649 } /* ?|? */ \ 650 \ 538 651 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 539 652 } // distribution … … 555 668 } // if 556 669 557 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );670 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 558 671 559 672 #define CFMTNP "% * " … … 571 684 return os; 572 685 } // ?|? 686 573 687 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 574 688 } // distribution … … 592 706 } // if 593 707 594 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );708 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 595 709 596 710 #define SFMTNP "% * " … … 616 730 return os; 617 731 } // ?|? 732 618 733 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 619 734 } // distribution … … 735 850 } // ?|? 736 851 737 // istype & ?|?( istype & is, const char * fmt) {852 // istype & ?|?( istype & is, const char fmt[] ) { 738 853 // fmt( is, fmt, "" ); 739 854 // return is; -
libcfa/src/iostream.hfa
r8c50aed ra505021 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 : Thu Feb 20 15:30:56 2020 13 // Update Count : 337 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 … … 98 98 ostype & ?|?( ostype &, unsigned long long int ); 99 99 void ?|?( ostype &, unsigned long long int ); 100 #if defined( __SIZEOF_INT128__ ) 101 ostype & ?|?( ostype &, int128 ); 102 void ?|?( ostype &, int128 ); 103 ostype & ?|?( ostype &, unsigned int128 ); 104 void ?|?( ostype &, unsigned int128 ); 105 #endif // __SIZEOF_INT128__ 100 106 101 107 ostype & ?|?( ostype &, float ); … … 113 119 void ?|?( ostype &, long double _Complex ); 114 120 115 ostype & ?|?( ostype &, const char *);116 void ?|?( ostype &, const char *);121 ostype & ?|?( ostype &, const char [] ); 122 void ?|?( ostype &, const char [] ); 117 123 // ostype & ?|?( ostype &, const char16_t * ); 118 124 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous … … 206 212 IntegralFMTDecl( signed long long int, 'd' ) 207 213 IntegralFMTDecl( unsigned long long int, 'u' ) 214 #if defined( __SIZEOF_INT128__ ) 215 IntegralFMTDecl( int128, 'd' ) 216 IntegralFMTDecl( unsigned int128, 'u' ) 217 #endif 208 218 209 219 //*********************************** floating point *********************************** … … 256 266 257 267 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 } }; }268 _Ostream_Manip(const char *) bin( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'b', { .all : 0 } }; } 269 _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'o', { .all : 0 } }; } 270 _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ s, 1, 0, 'x', { .all : 0 } }; } 271 _Ostream_Manip(const char *) wd( unsigned int w, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, w, 0, 's', { .all : 0 } }; } 272 _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 273 _Ostream_Manip(const char *) & wd( unsigned int w, _Ostream_Manip(const char *) & fmt ) { fmt.wd = w; return fmt; } 264 274 _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 291 int fail( istype & ); 282 292 int eof( istype & ); 283 void open( istype & is, const char * name);293 void open( istype & is, const char name[] ); 284 294 void close( istype & is ); 285 295 istype & read( istype &, char *, size_t ); … … 316 326 istype & ?|?( istype &, long double _Complex & ); 317 327 318 // istype & ?|?( istype &, const char *);328 // istype & ?|?( istype &, const char [] ); 319 329 istype & ?|?( istype &, char * ); 320 330 … … 343 353 static inline { 344 354 _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 } }; }355 _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr){ 0p, scanset, -1, { .all : 0 } }; } 356 _Istream_Cstr incl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : false } }; } 357 _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; } 358 _Istream_Cstr excl( const char scanset[], char * s ) { return (_Istream_Cstr){ s, scanset, -1, { .flags.inex : true } }; } 359 _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; } 360 _Istream_Cstr ignore( const char s[] ) { return (_Istream_Cstr)@{ s, 0p, -1, { .flags.ignore : true } }; } 351 361 _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 } }; }362 _Istream_Cstr wdi( unsigned int w, char s[] ) { return (_Istream_Cstr)@{ s, 0p, w, { .all : 0 } }; } 353 363 _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; } 354 364 } // distribution -
libcfa/src/math.hfa
r8c50aed ra505021 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/rational.cfa
r8c50aed ra505021 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 12 18:12:08 201913 // Update Count : 18 412 // Last Modified On : Sat Feb 8 17:56:36 2020 13 // Update Count : 187 14 14 // 15 15 … … 56 56 } // rational 57 57 58 void ?{}( Rational(RationalImpl) & r, zero_t ) { 59 r{ (RationalImpl){0}, (RationalImpl){1} }; 60 } // rational 61 62 void ?{}( Rational(RationalImpl) & r, one_t ) { 63 r{ (RationalImpl){1}, (RationalImpl){1} }; 64 } // rational 58 65 59 66 // getter for numerator/denominator -
libcfa/src/startup.cfa
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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
r8c50aed ra505021 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) -------------------------
Note:
See TracChangeset
for help on using the changeset viewer.