Changeset ef3ac46 for libcfa/src
- Timestamp:
- Apr 27, 2021, 10:07:25 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f451177
- Parents:
- 8840228
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r8840228 ref3ac46 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Apr 24 10:03:54202113 // Update Count : 13 2912 // Last Modified On : Tue Apr 27 18:01:03 2021 13 // Update Count : 1330 14 14 // 15 15 … … 145 145 } // ?|? 146 146 147 #if defined( __SIZEOF_INT128__ )147 #if defined( __SIZEOF_INT128__ ) 148 148 // UINT64_MAX 18_446_744_073_709_551_615_ULL 149 149 #define P10_UINT64 10_000_000_000_000_000_000_ULL // 19 zeroes 150 150 151 151 static inline void base10_128( ostype & os, unsigned int128 val ) { 152 #if defined(__GNUC__) && __GNUC_PREREQ(7,0)// gcc version >= 7152 #if defined(__GNUC__) && __GNUC_PREREQ(7,0) // gcc version >= 7 153 153 if ( val > P10_UINT64 ) { 154 #else154 #else 155 155 if ( (uint64_t)(val >> 64) != 0 || (uint64_t)val > P10_UINT64 ) { // patch gcc 5 & 6 -O3 bug 156 #endif // __GNUC_PREREQ(7,0)156 #endif // __GNUC_PREREQ(7,0) 157 157 base10_128( os, val / P10_UINT64 ); // recursive 158 158 fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) ); … … 187 187 (ostype &)(os | ullli); ends( os ); 188 188 } // ?|? 189 #endif // __SIZEOF_INT128__189 #endif // __SIZEOF_INT128__ 190 190 191 191 #define PrintWithDP( os, format, val, ... ) \ … … 361 361 setPrt$( os, false ); // turn off 362 362 setNL$( os, true ); 363 flush( os );364 363 return sepOff( os ); // prepare for next line 365 364 } // nl … … 808 807 809 808 810 forall( istype & | istream( istype ) ) {809 forall( istype & | basic_istream( istype ) ) { 811 810 istype & ?|?( istype & is, bool & b ) { 812 811 char val[6]; … … 918 917 } // ?|? 919 918 920 #if defined( __SIZEOF_INT128__ )919 #if defined( __SIZEOF_INT128__ ) 921 920 istype & ?|?( istype & is, int128 & llli ) { 922 921 return (istype &)(is | (unsigned int128 &)llli); … … 944 943 (istype &)(is | ullli); ends( is ); 945 944 } // ?|? 946 #endif // __SIZEOF_INT128__945 #endif // __SIZEOF_INT128__ 947 946 948 947 istype & ?|?( istype & is, float & f ) { … … 1035 1034 return is; 1036 1035 } // nlOff 1037 1036 } // distribution 1037 1038 forall( istype & | istream( istype ) ) { 1038 1039 istype & acquire( istype & is ) { 1039 1040 acquire( is ); // call void returning … … 1044 1045 // *********************************** manipulators *********************************** 1045 1046 1046 forall( istype & | istream( istype ) ) {1047 forall( istype & | basic_istream( istype ) ) { 1047 1048 istype & ?|?( istype & is, _Istream_Cstr f ) { 1048 1049 // skip xxx … … 1092 1093 1093 1094 #define InputFMTImpl( T, CODE ) \ 1094 forall( istype & | istream( istype ) ) { \1095 forall( istype & | basic_istream( istype ) ) { \ 1095 1096 istype & ?|?( istype & is, _Istream_Manip(T) f ) { \ 1096 1097 enum { size = 16 }; \ … … 1125 1126 InputFMTImpl( long double, "Lf" ) 1126 1127 1127 forall( istype & | istream( istype ) ) {1128 forall( istype & | basic_istream( istype ) ) { 1128 1129 istype & ?|?( istype & is, _Istream_Manip(float _Complex) fc ) { 1129 1130 float re, im; -
libcfa/src/iostream.hfa
r8840228 ref3ac46 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 25 11:22:03202113 // Update Count : 39 712 // Last Modified On : Tue Apr 27 17:59:21 2021 13 // Update Count : 398 14 14 // 15 15 … … 49 49 void ends( ostype & ); // end of output statement 50 50 int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 51 int flush( ostype & );52 51 }; // basic_ostream 53 52 54 53 trait ostream( ostype & | basic_ostream( ostype ) ) { 54 int flush( ostype & ); 55 55 bool fail( ostype & ); // operation failed? 56 56 void open( ostype &, const char name[], const char mode[] ); … … 97 97 ostype & ?|?( ostype &, unsigned long long int ); 98 98 void ?|?( ostype &, unsigned long long int ); 99 #if defined( __SIZEOF_INT128__ )99 #if defined( __SIZEOF_INT128__ ) 100 100 ostype & ?|?( ostype &, int128 ); 101 101 void ?|?( ostype &, int128 ); 102 102 ostype & ?|?( ostype &, unsigned int128 ); 103 103 void ?|?( ostype &, unsigned int128 ); 104 #endif // __SIZEOF_INT128__104 #endif // __SIZEOF_INT128__ 105 105 106 106 ostype & ?|?( ostype &, float ); … … 121 121 void ?|?( ostype &, const char [] ); 122 122 // ostype & ?|?( ostype &, const char16_t * ); 123 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous123 #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 124 124 // ostype & ?|?( ostype &, const char32_t * ); 125 #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 )125 #endif // ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) 126 126 // ostype & ?|?( ostype &, const wchar_t * ); 127 127 ostype & ?|?( ostype &, const void * ); … … 294 294 295 295 296 trait istream( istype & ) { 296 trait basic_istream( istype & ) { 297 bool getANL( istype & ); // get scan newline (on/off) 297 298 void nlOn( istype & ); // read newline 298 299 void nlOff( istype & ); // scan newline 299 bool getANL( istype & ); // get scan newline (on/off)300 300 301 301 void ends( istype & os ); // end of output statement 302 int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); 303 istype & ungetc( istype &, char ); 304 int eof( istype & ); 305 }; // basic_istream 306 307 trait istream( istype & | basic_istream( istype ) ) { 302 308 bool fail( istype & ); 303 int eof( istype & );304 309 void open( istype & is, const char name[] ); 305 310 void close( istype & is ); 306 311 istype & read( istype &, char *, size_t ); 307 istype & ungetc( istype &, char ); 308 int fmt( istype &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) )); 309 void acquire( istype & ); 312 void acquire( istype & ); // concurrent access 310 313 }; // istream 311 314 … … 314 317 }; // readable 315 318 316 forall( istype & | istream( istype ) ) {319 forall( istype & | basic_istream( istype ) ) { 317 320 istype & ?|?( istype &, bool & ); 318 321 void ?|?( istype &, bool & ); … … 341 344 istype & ?|?( istype &, unsigned long long int & ); 342 345 void ?|?( istype &, unsigned long long int & ); 343 #if defined( __SIZEOF_INT128__ )346 #if defined( __SIZEOF_INT128__ ) 344 347 istype & ?|?( istype &, int128 & ); 345 348 void ?|?( istype &, int128 & ); 346 349 istype & ?|?( istype &, unsigned int128 & ); 347 350 void ?|?( istype &, unsigned int128 & ); 348 #endif // __SIZEOF_INT128__351 #endif // __SIZEOF_INT128__ 349 352 350 353 istype & ?|?( istype &, float & ); … … 372 375 istype & nlOn( istype & ); 373 376 istype & nlOff( istype & ); 377 } // distribution 378 379 forall( istype & | istream( istype ) ) { 374 380 istype & acquire( istype & ); 375 381 } // distribution … … 402 408 _Istream_Cstr & wdi( unsigned int w, _Istream_Cstr & fmt ) { fmt.wd = w; return fmt; } 403 409 } // distribution 404 forall( istype & | istream( istype ) ) {410 forall( istype & | basic_istream( istype ) ) { 405 411 istype & ?|?( istype & is, _Istream_Cstr f ); 406 412 void ?|?( istype & is, _Istream_Cstr f ); … … 415 421 _Istream_Char & ignore( _Istream_Char & fmt ) { fmt.ignore = true; return fmt; } 416 422 } // distribution 417 forall( istype & | istream( istype ) ) {423 forall( istype & | basic_istream( istype ) ) { 418 424 istype & ?|?( istype & is, _Istream_Char f ); 419 425 void ?|?( istype & is, _Istream_Char f ); … … 434 440 _Istream_Manip(T) & wdi( unsigned int w, _Istream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \ 435 441 } /* distribution */ \ 436 forall( istype & | istream( istype ) ) { \442 forall( istype & | basic_istream( istype ) ) { \ 437 443 istype & ?|?( istype & is, _Istream_Manip(T) f ); \ 438 444 void ?|?( istype & is, _Istream_Manip(T) f ); \
Note: See TracChangeset
for help on using the changeset viewer.