Changeset bd5b443 for libcfa/src
- Timestamp:
- Feb 20, 2020, 3:34:00 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:
- 46b11e2
- Parents:
- 40cac90
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r40cac90 rbd5b443 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 18:48:38 202013 // Update Count : 82 512 // Last Modified On : Thu Feb 20 15:30:58 2020 13 // Update Count : 827 14 14 // 15 15 … … 159 159 (ostype &)(os | ulli); ends( os ); 160 160 } // ?|? 161 162 #if defined( __SIZEOF_INT128__ ) 163 // UINT64_MAX 18_446_744_073_709_551_615_ULL 164 #define P10_UINT64 10_000_000_000_000_000_000_ULL // 19 zeroes 165 166 static void base10_128( ostype & os, unsigned int128 val ) { 167 if ( val > UINT64_MAX ) { 168 base10_128( os, val / P10_UINT64 ); // recursive 169 fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) ); 170 } else { 171 fmt( os, "%lu", (uint64_t)val ); 172 } // if 173 } // base10_128 174 175 static void base10_128( ostype & os, int128 val ) { 176 if ( val < 0 ) { 177 fmt( os, "-" ); // leading negative sign 178 val = -val; 179 } // if 180 base10_128( os, (unsigned int128)val ); // print zero/positive value 181 } // base10_128 182 183 ostype & ?|?( ostype & os, int128 llli ) { 184 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 185 base10_128( os, llli ); 186 return os; 187 } // ?|? 188 void & ?|?( ostype & os, int128 llli ) { 189 (ostype &)(os | llli); ends( os ); 190 } // ?|? 191 192 ostype & ?|?( ostype & os, unsigned int128 ullli ) { 193 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 194 base10_128( os, ullli ); 195 return os; 196 } // ?|? 197 void & ?|?( ostype & os, unsigned int128 ullli ) { 198 (ostype &)(os | ullli); ends( os ); 199 } // ?|? 200 #endif // __SIZEOF_INT128__ 161 201 162 202 #define PrintWithDP( os, format, val, ... ) \ … … 464 504 \ 465 505 if ( ! f.flags.pc ) { /* no precision */ \ 466 /* printf( "%s\n", &fmtstr[star] ); */ \467 506 fmtstr[sizeof(IFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 507 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \ 468 508 fmt( os, &fmtstr[star], f.wd, f.val ); \ 469 509 } else { /* precision */ \ 470 510 fmtstr[sizeof(IFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 471 /* printf( "%s \n", &fmtstr[star]); */ \511 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \ 472 512 fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \ 473 513 } /* if */ \ … … 487 527 IntegralFMTImpl( signed long long int, 'd', "% *ll ", "% *.*ll " ) 488 528 IntegralFMTImpl( unsigned long long int, 'u', "% *ll ", "% *.*ll " ) 529 530 531 #if defined( __SIZEOF_INT128__ ) 532 // Default prefix for non-decimal prints is 0b, 0, 0x. 533 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \ 534 forall( dtype ostype | ostream( ostype ) ) \ 535 static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \ 536 if ( fmt.val > UINT64_MAX ) { \ 537 fmt.val /= P10_UINT64; \ 538 base10_128( os, fmt ); /* recursive */ \ 539 _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \ 540 fmt2.flags.nobsdp = true; \ 541 printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all ); \ 542 sepOff( os ); \ 543 (ostype &)(os | fmt2); \ 544 } else { \ 545 printf( "fmt %c %lld %d\n", fmt.base, fmt.val, fmt.all ); \ 546 (ostype &)(os | fmt); \ 547 } /* if */ \ 548 } /* base10_128 */ \ 549 forall( dtype ostype | ostream( ostype ) ) { \ 550 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 551 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \ 552 \ 553 if ( f.base == 'b' | f.base == 'o' | f.base == 'x' | f.base == 'X' ) { \ 554 unsigned long long int msig = (unsigned long long int)(f.val >> 64); \ 555 unsigned long long int lsig = (unsigned long long int)(f.val); \ 556 _Ostream_Manip(SIGNED long long int) fmt @= { msig, f.wd, f.pc, f.base, { .all : f.all } }; \ 557 _Ostream_Manip(unsigned long long int) fmt2 @= { lsig, 0, 0, f.base, { .all : 0 } }; \ 558 if ( msig == 0 ) { \ 559 fmt.val = lsig; \ 560 (ostype &)(os | fmt); \ 561 } else { \ 562 fmt2.flags.pad0 = fmt2.flags.nobsdp = true; \ 563 if ( f.base == 'b' ) { \ 564 if ( f.wd > 64 ) fmt.wd = f.wd - 64; \ 565 fmt2.wd = 64; \ 566 (ostype &)(os | fmt | "" | fmt2); \ 567 } else if ( f.base == 'o' ) { \ 568 fmt.val = (unsigned long long int)fmt.val >> 2; \ 569 if ( f.wd > 21 ) fmt.wd = f.wd - 21; \ 570 fmt2.wd = 1; \ 571 fmt2.val = ((msig & 0x3) << 1) + 1; \ 572 (ostype &)(os | fmt | "" | fmt2); \ 573 sepOff( os ); \ 574 fmt2.wd = 21; \ 575 fmt2.val = lsig & 0x7fffffffffffffff; \ 576 (ostype &)(os | fmt2); \ 577 } else { \ 578 if ( f.flags.left ) { \ 579 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \ 580 fmt.wd = 16; \ 581 } else { \ 582 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \ 583 fmt2.wd = 16; \ 584 } /* if */ \ 585 (ostype &)(os | fmt | "" | fmt2); \ 586 } /* if */ \ 587 } /* if */ \ 588 } else { \ 589 base10_128( os, f ); \ 590 } /* if */ \ 591 return os; \ 592 } /* ?|? */ \ 593 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 594 } // distribution 595 596 IntegralFMTImpl128( int128, signed, 'd', "% *ll ", "% *.*ll " ) 597 IntegralFMTImpl128( unsigned int128, unsigned, 'u', "% *ll ", "% *.*ll " ) 598 #endif // __SIZEOF_INT128__ 489 599 490 600 //*********************************** floating point *********************************** -
libcfa/src/iostream.hfa
r40cac90 rbd5b443 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 17:53:52202013 // Update Count : 33 612 // Last Modified On : Thu Feb 20 15:30:56 2020 13 // Update Count : 337 14 14 // 15 15 … … 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 ); … … 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 ***********************************
Note: See TracChangeset
for help on using the changeset viewer.