Changeset f80e0218 for src/libcfa/stdlib.c
- Timestamp:
- Jun 30, 2016, 4:32:56 PM (9 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:
- ea29e73
- Parents:
- 1b5c81ed (diff), 84d4d6f (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/stdlib.c
r1b5c81ed rf80e0218 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 28 07:54:21 2016 13 // Update Count : 166 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 } … … 222 213 //--------------------------------------- 223 214 224 forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )225 [ T, T ] div( T t1, T t2 ) { /* return [ t1 / t2, t1 % t2 ]; */}215 // forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } ) 216 // [ T, T ] div( T t1, T t2 ) { return [ t1 / t2, t1 % t2 ]; } 226 217 227 218 //--------------------------------------- … … 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.