- Timestamp:
- Apr 22, 2016, 1:42:36 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 67b1180
- Parents:
- dc2e7e0 (diff), 6812d89 (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:
- src
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cc
rdc2e7e0 rfbfb38e 69 69 PointerType *destAsPointer = dynamic_cast< PointerType* >( dest ); 70 70 if ( destAsPointer && basicType->isInteger() ) { 71 // cost = Cost( 1, 0, 0 );72 cost = Cost ::infinity;71 // necessary for, e.g. unsigned long => void* 72 cost = Cost( 1, 0, 0 ); 73 73 } else { 74 74 ConversionCost::visit( basicType ); … … 89 89 } else if ( castResult < 0 ) { 90 90 cost = Cost::infinity; 91 //cost = Cost( 1, 0, 0 );92 91 } // if 93 92 } // if 94 93 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) { 95 94 if ( destAsBasic->isInteger() ) { 96 // cost = Cost( 1, 0, 0 );97 cost = Cost ::infinity;95 // necessary for, e.g. void* => unsigned long 96 cost = Cost( 1, 0, 0 ); 98 97 } // if 99 98 } -
src/SymTab/Indexer.cc
rdc2e7e0 rfbfb38e 511 511 } 512 512 513 bool Indexer::hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const {513 bool Indexer::hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const { 514 514 if ( ! tables ) return false; 515 if ( tables->scope < scope ) return false; 515 516 516 517 IdTable::const_iterator decls = tables->idTable.find( id ); … … 524 525 } 525 526 526 return tables->base.hasIncompatibleCDecl( id, mangleName );527 return tables->base.hasIncompatibleCDecl( id, mangleName, scope ); 527 528 } 528 529 … … 617 618 DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope ); 618 619 if ( ! existing || ! addedIdConflicts( existing, decl ) ) { 619 // this ensures that no two declarations with the same unmangled name both have C linkage620 if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName ) ) {620 // this ensures that no two declarations with the same unmangled name at the same scope both have C linkage 621 if ( decl->get_linkage() == LinkageSpec::C && hasIncompatibleCDecl( name, mangleName, scope ) ) { 621 622 throw SemanticError( "invalid overload of C function ", decl ); 622 623 } // NOTE this is broken in Richard's original code in such a way that it never triggers (it … … 783 784 using std::cerr; 784 785 785 cerr << "===idTable===" << std::endl; 786 if ( tables ) dump( tables->idTable, os ); 787 cerr << "===typeTable===" << std::endl; 788 if ( tables ) dump( tables->typeTable, os ); 789 cerr << "===structTable===" << std::endl; 790 if ( tables ) dump( tables->structTable, os ); 791 cerr << "===enumTable===" << std::endl; 792 if ( tables ) dump( tables->enumTable, os ); 793 cerr << "===unionTable===" << std::endl; 794 if ( tables ) dump( tables->unionTable, os ); 795 cerr << "===contextTable===" << std::endl; 796 if ( tables ) dump( tables->traitTable, os ); 786 if ( tables ) { 787 os << "--- scope " << tables->scope << " ---" << std::endl; 788 789 os << "===idTable===" << std::endl; 790 dump( tables->idTable, os ); 791 os << "===typeTable===" << std::endl; 792 dump( tables->typeTable, os ); 793 os << "===structTable===" << std::endl; 794 dump( tables->structTable, os ); 795 os << "===enumTable===" << std::endl; 796 dump( tables->enumTable, os ); 797 os << "===unionTable===" << std::endl; 798 dump( tables->unionTable, os ); 799 os << "===contextTable===" << std::endl; 800 dump( tables->traitTable, os ); 801 802 tables->base.print( os, indent ); 803 } else { 804 os << "--- end ---" << std::endl; 805 } 806 797 807 } 798 808 } // namespace SymTab -
src/SymTab/Indexer.h
rdc2e7e0 rfbfb38e 99 99 DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const; 100 100 /// returns true if there exists a declaration with C linkage and the given name with a different mangled name 101 bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const;101 bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const; 102 102 // equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope) 103 103 NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const; -
src/SymTab/Validate.cc
rdc2e7e0 rfbfb38e 515 515 } 516 516 rtt->get_parameters().clear(); 517 cloneAll(typeInst->get_parameters(), rtt->get_parameters()); 517 cloneAll( typeInst->get_parameters(), rtt->get_parameters() ); 518 mutateAll( rtt->get_parameters(), *this ); // recursively fix typedefs on parameters 518 519 } // if 519 520 delete typeInst; -
src/driver/cfa.cc
rdc2e7e0 rfbfb38e 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 6 14:04:22201613 // Update Count : 13 212 // Last Modified On : Wed Apr 20 18:31:28 2016 13 // Update Count : 133 14 14 // 15 15 … … 310 310 nargs += 1; 311 311 } // if 312 args[nargs] = "-fgnu89-inline"; 313 nargs += 1; 312 314 args[nargs] = ( *new string( string("-B") + Bprefix + "/" ) ).c_str(); 313 315 nargs += 1; -
src/examples/io.c
rdc2e7e0 rfbfb38e 11 11 // Created On : Wed Mar 2 16:56:02 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Apr 6 14:58:27201614 // Update Count : 1513 // Last Modified On : Wed Apr 13 23:03:14 2016 14 // Update Count : 22 15 15 // 16 16 … … 36 36 37 37 ifstream in; // create / open file 38 open( &in, "i nput.data", "r" );38 open( &in, "io.data", "r" ); 39 39 40 40 &in | &c // character … … 59 59 | fc | dc | ldc | endl // complex without separator 60 60 | s1 | s2 | endl; 61 sout | endl; 62 sepSet( sout, " " ); 63 64 sout 65 // opening delimiters 66 | "v(" | 27 67 | "v[" | 27 68 | "v{" | 27 69 | "$" | 27 70 | "£" | 27 71 | "¥" | 27 72 | "¿" | 27 73 | "«" | 27 74 | endl 75 // closing delimiters 76 | 25 | "," 77 | 25 | "." 78 | 25 | ":" 79 | 25 | ";" 80 | 25 | "!" 81 | 25 | "?" 82 | 25 | ")" 83 | 25 | "]" 84 | 25 | "}" 85 | 25 | "%" 86 | 25 | "¢" 87 | 25 | "»" 88 | endl 89 // opening-closing delimiters 90 | 25 | "'" | 27 91 | 25 | "`" | 27 92 | 25 | "\"" | 27 93 | 25 | "\f" | 27 94 | 25 | "\n" | 27 95 | 25 | "\r" | 27 96 | 25 | "\t" | 27 97 | 25 | "\v" | 27 98 | endl; 61 99 } 62 100 -
src/examples/swap.c
rdc2e7e0 rfbfb38e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 16:15:11 201613 // Update Count : 6 512 // Last Modified On : Thu Apr 21 08:10:41 2016 13 // Update Count : 69 14 14 // 15 15 … … 24 24 25 25 signed int i1 = -1, i2 = -2; 26 sout | "signed int\t\t" | i1 | ' ' |i2 | "\t\t\tswap ";26 sout | "signed int\t\t" | i1 | i2 | "\t\t\tswap "; 27 27 swap( &i1, &i2 ); 28 sout | '\t' | i1 | ' ' |i2 | endl;28 sout | '\t' | i1 | i2 | endl; 29 29 30 30 unsigned int ui1 = 1, ui2 = 2; 31 sout | "unsigned int\t\t" | ui1 | ' ' |ui2 | "\t\t\tswap ";31 sout | "unsigned int\t\t" | ui1 | ui2 | "\t\t\tswap "; 32 32 swap( &ui1, &ui2 ); 33 sout | '\t' | ui1 | ' ' |ui2 | endl;33 sout | '\t' | ui1 | ui2 | endl; 34 34 35 35 signed long int li1 = -1, li2 = -2; 36 sout | "signed long int\t\t" | li1 | ' ' |li2 | "\t\t\tswap ";36 sout | "signed long int\t\t" | li1 | li2 | "\t\t\tswap "; 37 37 swap( &li1, &li2 ); 38 sout | '\t' | li1 | ' ' |li2 | endl;38 sout | '\t' | li1 | li2 | endl; 39 39 40 40 unsigned long int uli1 = 1, uli2 = 2; 41 sout | "unsigned long int\t" | uli1 | ' ' |uli2 | "\t\t\tswap ";41 sout | "unsigned long int\t" | uli1 | uli2 | "\t\t\tswap "; 42 42 swap( &uli1, &uli2 ); 43 sout | '\t' | uli1 | ' ' |uli2 | endl;43 sout | '\t' | uli1 | uli2 | endl; 44 44 45 45 signed long long int lli1 = -1, lli2 = -2; 46 sout | "signed long long int\t" | lli1 | ' ' |lli2 | "\t\t\tswap ";46 sout | "signed long long int\t" | lli1 | lli2 | "\t\t\tswap "; 47 47 swap( &lli1, &lli2 ); 48 sout | '\t' | lli1 | ' ' |lli2 | endl;48 sout | '\t' | lli1 | lli2 | endl; 49 49 50 50 unsigned long long int ulli1 = 1, ulli2 = 2; 51 sout | "unsigned long long int\t" | ulli1 | ' ' |ulli2 | "\t\t\tswap ";51 sout | "unsigned long long int\t" | ulli1 | ulli2 | "\t\t\tswap "; 52 52 swap( &ulli1, &ulli2 ); 53 sout | '\t' | ulli1 | ' ' |ulli2 | endl;53 sout | '\t' | ulli1 | ulli2 | endl; 54 54 55 55 float f1 = 1.5, f2 = 2.5; 56 sout | "float\t\t\t" | f1 | ' ' | f2 | "\t\tswap ";56 sout | "float\t\t\t" | f1 | f2 | "\t\t\tswap "; 57 57 swap( &f1, &f2 ); 58 sout | '\t' | f1 | ' ' |f2 | endl;58 sout | '\t' | f1 | f2 | endl; 59 59 60 60 double d1 = 1.5, d2 = 2.5; 61 sout | "double\t\t\t" | d1 | ' ' | d2 | "\t\tswap ";61 sout | "double\t\t\t" | d1 | d2 | "\t\t\tswap "; 62 62 swap( &d1, &d2 ); 63 sout | '\t' | d1 | ' ' |d2 | endl;63 sout | '\t' | d1 | d2 | endl; 64 64 65 65 long double ld1 = 1.5, ld2 = 2.5; 66 sout | "long double\t\t" | ld1 | ' ' | ld2 | "\t\tswap ";66 sout | "long double\t\t" | ld1 | ld2 | "\t\t\tswap "; 67 67 swap( &ld1, &ld2 ); 68 sout | '\t' | ld1 | ' ' |ld2 | endl;68 sout | '\t' | ld1 | ld2 | endl; 69 69 70 70 float _Complex fc1 = 1.5f+1.5if, fc2 = 2.5f+2.5if; 71 sout | "float _Complex\t\t" | fc1 | ' ' |fc2 | "\tswap ";71 sout | "float _Complex\t\t" | fc1 | fc2 | "\tswap "; 72 72 swap( &fc1, &fc2 ); 73 sout | '\t' | fc1 | ' ' |fc2 | endl;73 sout | '\t' | fc1 | fc2 | endl; 74 74 75 75 double _Complex dc1 = 1.5d+1.5id, dc2 = 2.5d+2.5id; 76 sout | "double _Complex\t\t" | dc1 | ' ' |dc2 | "\tswap ";76 sout | "double _Complex\t\t" | dc1 | dc2 | "\tswap "; 77 77 swap( &dc1, &dc2 ); 78 sout | '\t' | dc1 | ' ' |dc2 | endl;78 sout | '\t' | dc1 | dc2 | endl; 79 79 80 80 long double _Complex ldc1 = 1.5d+1.5il, ldc2 = 2.5d+2.5il; 81 sout | "long double _Complex\t" | ldc1 | ' ' |ldc2 | "\tswap ";81 sout | "long double _Complex\t" | ldc1 | ldc2 | "\tswap "; 82 82 swap( &ldc1, &ldc2 ); 83 sout | '\t' | ldc1 | ' ' |ldc2 | endl;83 sout | '\t' | ldc1 | ldc2 | endl; 84 84 85 85 struct S { int i, j; } s1 = { 1, 2 }, s2 = { 2, 1 }; 86 ofstream * ?|?( ofstream * os, S s ) { return os | s.i | ' ' |s.j; }87 sout | "struct S\t\t" | s1 | " 86 ofstream * ?|?( ofstream * os, S s ) { return os | s.i | s.j; } 87 sout | "struct S\t\t" | s1 | "," | s2 | "\t\tswap "; 88 88 swap( &s1, &s2 ); 89 sout | '\t' | s1 | " 89 sout | '\t' | s1 | "," | s2 | endl; 90 90 } // main 91 91 -
src/libcfa/Makefile.am
rdc2e7e0 rfbfb38e 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Wed Apr 6 21:10:44201614 ## Update Count : 12 313 ## Last Modified On : Tue Apr 19 22:30:17 2016 14 ## Update Count : 124 15 15 ############################################################################### 16 16 … … 60 60 ${CC} ${CFLAGS} -c -o $@ $< 61 61 62 libs = limits stdlib iostream fstream iterator rational62 libs = limits stdlib math iostream fstream iterator rational 63 63 libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c} 64 64 -
src/libcfa/Makefile.in
rdc2e7e0 rfbfb38e 83 83 libcfa_a_AR = $(AR) $(ARFLAGS) 84 84 libcfa_a_LIBADD = 85 am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) iostream.$(OBJEXT) \ 86 fstream.$(OBJEXT) iterator.$(OBJEXT) rational.$(OBJEXT) 85 am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) math.$(OBJEXT) \ 86 iostream.$(OBJEXT) fstream.$(OBJEXT) iterator.$(OBJEXT) \ 87 rational.$(OBJEXT) 87 88 am_libcfa_a_OBJECTS = libcfa-prelude.$(OBJEXT) $(am__objects_1) 88 89 libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS) … … 213 214 MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} \ 214 215 ${addprefix ${libdir}/,${lib_LIBRARIES}} ${includedir}/* 215 libs = limits stdlib iostream fstream iterator rational216 libs = limits stdlib math iostream fstream iterator rational 216 217 libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c} 217 218 cheaders = # expat … … 299 300 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa-prelude.Po@am__quote@ 300 301 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Po@am__quote@ 302 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/math.Po@am__quote@ 301 303 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rational.Po@am__quote@ 302 304 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdlib.Po@am__quote@ -
src/libcfa/fstream
rdc2e7e0 rfbfb38e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 5 22:37:12201613 // Update Count : 8 212 // Last Modified On : Tue Apr 19 20:44:10 2016 13 // Update Count : 84 14 14 // 15 15 … … 22 22 struct ofstream { 23 23 void *file; 24 _BoolsepDefault;25 _BoolsepOnOff;24 int sepDefault; 25 int sepOnOff; 26 26 char separator[separateSize]; 27 27 }; // ofstream -
src/libcfa/rational.c
rdc2e7e0 rfbfb38e 11 11 // Created On : Wed Apr 6 17:54:28 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : T ue Apr 12 21:26:42201614 // Update Count : 2 113 // Last Modified On : Thu Apr 21 07:33:03 2016 14 // Update Count : 22 15 15 // 16 16 … … 18 18 #include "fstream" 19 19 #include "stdlib" 20 #include "math" // floor 20 21 21 22 -
src/libcfa/stdlib
rdc2e7e0 rfbfb38e 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 13 14:45:53201613 // Update Count : 8512 // Last Modified On : Thu Apr 21 07:55:21 2016 13 // Update Count : 95 14 14 // 15 15 … … 28 28 #endif // ! EXIT_FAILURE 29 29 void exit( int rc ); 30 void abort( void ); 30 31 } // extern "C" 31 32 32 33 //--------------------------------------- 33 34 34 extern "C" { 35 void * malloc( size_t ); // use default C routine for void * 36 } // extern "C" 35 extern "C" { void * malloc( size_t ); } // use default C routine for void * 37 36 forall( otype T ) T * malloc( void ); 38 37 forall( otype T ) T * malloc( char fill ); 39 38 forall( otype T ) T * malloc( T * ptr, size_t size ); 40 39 forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill ); 41 extern "C" { 42 void * calloc( size_t nmemb, size_t size ); // use default C routine for void * 43 } // extern "C" 40 extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void * 44 41 forall( otype T ) T * calloc( size_t nmemb ); 45 extern "C" { 46 void * realloc( void * ptr, size_t size ); // use default C routine for void * 47 } // extern "C" 42 extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void * 48 43 forall( otype T ) T * realloc( T * ptr, size_t size ); 49 44 forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill ); 50 45 51 46 forall( otype T ) T * aligned_alloc( size_t alignment ); 52 forall( otype T ) T * memalign( size_t alignment ); // deprecated47 forall( otype T ) T * memalign( size_t alignment ); 53 48 forall( otype T ) int posix_memalign( T ** ptr, size_t alignment ); 54 49 55 forall( otype T ) T * memset( T * ptr, unsigned char fill ); // use default value '\0' for fill 56 forall( otype T ) T * memset( T * ptr ); // remove when default value available 50 extern "C" { 51 void * memset( void * ptr, int fill, size_t size ); 52 void free( void * ptr ); 53 } // extern "C" 57 54 58 55 //--------------------------------------- … … 100 97 101 98 char abs( char ); 102 extern "C" { 103 int abs( int ); // use default C routine for int 104 } // extern "C" 99 extern "C" { int abs( int ); } // use default C routine for int 105 100 long int abs( long int ); 106 101 long long int abs( long long int ); … … 108 103 double abs( double ); 109 104 long double abs( long double ); 110 float _Complex abs( float _Complex ); 111 double _Complex abs( double _Complex ); 112 long double _Complex abs( long double _Complex ); 113 114 //--------------------------------------- 115 116 float floor( float ); 117 extern "C" { 118 double floor( double ); // use C routine for double 119 } // extern "C" 120 long double floor( long double ); 121 122 float ceil( float ); 123 extern "C" { 124 double ceil( double ); // use C routine for double 125 } // extern "C" 126 long double ceil( long double ); 105 float abs( float _Complex ); 106 double abs( double _Complex ); 107 long double abs( long double _Complex ); 127 108 128 109 //--------------------------------------- -
src/libcfa/stdlib.c
rdc2e7e0 rfbfb38e 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 13 14:49:58201613 // Update Count : 1 5512 // Last Modified On : Thu Apr 21 07:58:29 2016 13 // Update Count : 165 14 14 // 15 15 … … 24 24 #include <malloc.h> // malloc_usable_size 25 25 #include <math.h> // fabsf, fabs, fabsl 26 #include <complex.h> // _Complex_I , cabsf, cabs, cabsl26 #include <complex.h> // _Complex_I 27 27 } // extern "C" 28 28 … … 34 34 //printf( "malloc3\n" ); 35 35 T * ptr = (T *)malloc( sizeof(T) ); 36 return memset( ptr );36 return memset( ptr, (int)fill, sizeof(T) ); 37 37 } // malloc 38 38 … … 78 78 } // posix_memalign 79 79 80 forall( otype T ) T * memset( T * ptr, unsigned char fill ) { // use default value '\0' for fill81 //printf( "memset1\n" );82 return (T *)memset( ptr, (int)fill, malloc_usable_size( ptr ) );83 } // memset84 forall( otype T ) T * memset( T * ptr ) { // remove when default value available85 //printf( "memset2\n" );86 return (T *)memset( ptr, 0, malloc_usable_size( ptr ) );87 } // memset88 89 80 //--------------------------------------- 90 81 91 82 int ato( const char * ptr ) { 92 83 int i; 93 if ( sscanf( ptr, "%d", &i ) == EOF ) {} // check return code84 if ( sscanf( ptr, "%d", &i ) == EOF ) {} 94 85 return i; 95 86 } 96 87 unsigned int ato( const char * ptr ) { 97 88 unsigned int ui; 98 if ( sscanf( ptr, "%u", &ui ) == EOF ) {} // check return code89 if ( sscanf( ptr, "%u", &ui ) == EOF ) {} 99 90 return ui; 100 91 } 101 92 long int ato( const char * ptr ) { 102 93 long int li; 103 if ( sscanf( ptr, "%ld", &li ) == EOF ) {} // check return code94 if ( sscanf( ptr, "%ld", &li ) == EOF ) {} 104 95 return li; 105 96 } 106 97 unsigned long int ato( const char * ptr ) { 107 98 unsigned long int uli; 108 if ( sscanf( ptr, "%lu", &uli ) == EOF ) {} // check return code99 if ( sscanf( ptr, "%lu", &uli ) == EOF ) {} 109 100 return uli; 110 101 } 111 102 long long int ato( const char * ptr ) { 112 103 long long int lli; 113 if ( sscanf( ptr, "%lld", &lli ) == EOF ) {} // check return code104 if ( sscanf( ptr, "%lld", &lli ) == EOF ) {} 114 105 return lli; 115 106 } 116 107 unsigned long long int ato( const char * ptr ) { 117 108 unsigned long long int ulli; 118 if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {} // check return code109 if ( sscanf( ptr, "%llu", &ulli ) == EOF ) {} 119 110 return ulli; 120 111 } … … 122 113 float ato( const char * ptr ) { 123 114 float f; 124 if ( sscanf( ptr, "%f", &f ) == EOF ) {} // check return code115 if ( sscanf( ptr, "%f", &f ) == EOF ) {} 125 116 return f; 126 117 } 127 118 double ato( const char * ptr ) { 128 119 double d; 129 if ( sscanf( ptr, "%lf", &d ) == EOF ) {} // check return code120 if ( sscanf( ptr, "%lf", &d ) == EOF ) {} 130 121 return d; 131 122 } 132 123 long double ato( const char * ptr ) { 133 124 long double ld; 134 if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {} // check return code125 if ( sscanf( ptr, "%Lf", &ld ) == EOF ) {} 135 126 return ld; 136 127 } … … 138 129 float _Complex ato( const char * ptr ) { 139 130 float re, im; 140 if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {} // check return code131 if ( sscanf( ptr, "%g%gi", &re, &im ) == EOF ) {} 141 132 return re + im * _Complex_I; 142 133 } 143 134 double _Complex ato( const char * ptr ) { 144 135 double re, im; 145 if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {} // check return code136 if ( sscanf( ptr, "%lf%lfi", &re, &im ) == EOF ) {} 146 137 return re + im * _Complex_I; 147 138 } 148 139 long double _Complex ato( const char * ptr ) { 149 140 long double re, im; 150 if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {} // check return code141 if ( sscanf( ptr, "%Lf%Lfi", &re, &im ) == EOF ) {} 151 142 return re + im * _Complex_I; 152 143 } … … 230 221 long int abs( long int v ) { return labs( v ); } 231 222 long long int abs( long long int v ) { return llabs( v ); } 232 float abs( float v ) { return fabsf( v ); } 233 double abs( double v ) { return fabs( v ); } 234 long double abs( long double v ) { return fabsl( v ); } 235 float _Complex abs( float _Complex v ) { return cabsf( v ); } 236 double _Complex abs( double _Complex v ) { return cabs( v ); } 237 long double _Complex abs( long double _Complex v ) { return cabsl( v ); } 238 239 //--------------------------------------- 240 241 float floor( float v ) { return floorf( v ); } 242 long double floor( long double v ) { return floorl( v ); } 243 244 float ceil( float v ) { return ceilf( v ); } 245 long double ceil( long double v ) { return ceill( v ); } 223 float abs( float x ) { return fabsf( x ); } 224 double abs( double x ) { return fabs( x ); } 225 long double abs( long double x ) { return fabsl( x ); } 226 float abs( float _Complex x ) { return cabsf( x ); } 227 double abs( double _Complex x ) { return cabs( x ); } 228 long double abs( long double _Complex x ) { return cabsl( x ); } 246 229 247 230 //---------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.