Changeset f80e0218 for src/libcfa
- Timestamp:
- Jun 30, 2016, 4:32:56 PM (10 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, stuck-waitfor-destruct, 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. - Location:
- src/libcfa
- Files:
-
- 2 added
- 10 edited
-
Makefile.am (modified) (2 diffs)
-
Makefile.in (modified) (10 diffs)
-
fstream (modified) (2 diffs)
-
fstream.c (modified) (6 diffs)
-
iostream.c (modified) (24 diffs)
-
math (added)
-
math.c (added)
-
prelude.cf (modified) (3 diffs)
-
rational (modified) (2 diffs)
-
rational.c (modified) (5 diffs)
-
stdlib (modified) (5 diffs)
-
stdlib.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/Makefile.am
r1b5c81ed rf80e0218 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## Makefile.am -- 8 ## Makefile.am -- 9 9 ## 10 10 ## Author : Peter A. Buhr 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 : 1 2313 ## Last Modified On : Mon Jun 13 14:27:22 2016 14 ## Update Count : 166 15 15 ############################################################################### 16 16 … … 50 50 @BACKEND_CC@ -c -o $@ $< 51 51 52 CFLAGS = - g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O253 CC = ${abs_top_srcdir}/src/driver/cfa 52 CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2 53 CC = ${abs_top_srcdir}/src/driver/cfa 54 54 55 # extension-less header files are overridden by default make rules => explicitly override rule 55 headers = limits stdlib math iostream fstream iterator rational 56 libobjs = ${headers:=.o} 57 58 # extensionless header files are overridden by -o flag in default makerule => explicitly override default rule to silently do nothing 56 59 % : %.c 57 true60 @true 58 61 59 .c.o : ${abs_top_srcdir}/src/driver/cfa-cpp 60 ${CC} ${CFLAGS} -c -o $@ $< 62 ${libobjs} : ${abs_top_srcdir}/src/driver/cfa-cpp # add dependency to cfa-cpp so all libraries are rebuilt with new translator 61 63 62 libs = limits stdlib iostream fstream iterator rational 63 libcfa_a_SOURCES = libcfa-prelude.c ${libs:=.c} 64 libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} 64 65 65 cheaders = # expat 66 cfaheaders = # limits 67 include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders} 66 include_HEADERS = ${headers} 68 67 68 CLEANFILES = libcfa-prelude.c 69 69 MAINTAINERCLEANFILES += ${includedir}/* -
src/libcfa/Makefile.in
r1b5c81ed rf80e0218 81 81 AR = ar 82 82 ARFLAGS = cru 83 AM_V_AR = $(am__v_AR_@AM_V@) 84 am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) 85 am__v_AR_0 = @echo " AR " $@; 86 AM_V_at = $(am__v_at_@AM_V@) 87 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 88 am__v_at_0 = @ 83 89 libcfa_a_AR = $(AR) $(ARFLAGS) 84 90 libcfa_a_LIBADD = 85 am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) iostream.$(OBJEXT) \ 86 fstream.$(OBJEXT) iterator.$(OBJEXT) rational.$(OBJEXT) 91 am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) math.$(OBJEXT) \ 92 iostream.$(OBJEXT) fstream.$(OBJEXT) iterator.$(OBJEXT) \ 93 rational.$(OBJEXT) 87 94 am_libcfa_a_OBJECTS = libcfa-prelude.$(OBJEXT) $(am__objects_1) 88 95 libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS) … … 93 100 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 94 101 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 102 AM_V_CC = $(am__v_CC_@AM_V@) 103 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 104 am__v_CC_0 = @echo " CC " $@; 95 105 CCLD = $(CC) 96 106 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 107 AM_V_CCLD = $(am__v_CCLD_@AM_V@) 108 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 109 am__v_CCLD_0 = @echo " CCLD " $@; 110 AM_V_GEN = $(am__v_GEN_@AM_V@) 111 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 112 am__v_GEN_0 = @echo " GEN " $@; 97 113 SOURCES = $(libcfa_a_SOURCES) 98 114 DIST_SOURCES = $(libcfa_a_SOURCES) … … 105 121 ALLOCA = @ALLOCA@ 106 122 AMTAR = @AMTAR@ 123 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 107 124 AUTOCONF = @AUTOCONF@ 108 125 AUTOHEADER = @AUTOHEADER@ … … 110 127 AWK = @AWK@ 111 128 BACKEND_CC = @BACKEND_CC@ 112 CC = ${abs_top_srcdir}/src/driver/cfa 129 CC = ${abs_top_srcdir}/src/driver/cfa 113 130 CCDEPMODE = @CCDEPMODE@ 131 CFA_BACKEND_CC = @CFA_BACKEND_CC@ 114 132 CFA_BINDIR = @CFA_BINDIR@ 115 133 CFA_INCDIR = @CFA_INCDIR@ 116 134 CFA_LIBDIR = @CFA_LIBDIR@ 117 135 CFA_PREFIX = @CFA_PREFIX@ 118 CFLAGS = - g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2136 CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2 119 137 CPP = @CPP@ 120 138 CPPFLAGS = @CPPFLAGS@ … … 130 148 EGREP = @EGREP@ 131 149 EXEEXT = @EXEEXT@ 132 GCC_PATH = @GCC_PATH@133 150 GREP = @GREP@ 134 151 INSTALL = @INSTALL@ … … 213 230 MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} \ 214 231 ${addprefix ${libdir}/,${lib_LIBRARIES}} ${includedir}/* 215 libs = limits stdlibiostream fstream iterator rational216 lib cfa_a_SOURCES = libcfa-prelude.c ${libs:=.c}217 cheaders = # expat 218 cfaheaders = # limits 219 include_HEADERS = ${cheaders:=.h} ${libs} ${cfaheaders} 232 headers = limits stdlib math iostream fstream iterator rational 233 libobjs = ${headers:=.o} 234 libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} 235 include_HEADERS = ${headers} 236 CLEANFILES = libcfa-prelude.c 220 237 all: all-am 221 238 … … 283 300 -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) 284 301 libcfa.a: $(libcfa_a_OBJECTS) $(libcfa_a_DEPENDENCIES) $(EXTRA_libcfa_a_DEPENDENCIES) 285 -rm -f libcfa.a286 $( libcfa_a_AR) libcfa.a $(libcfa_a_OBJECTS) $(libcfa_a_LIBADD)287 $( RANLIB) libcfa.a302 $(AM_V_at)-rm -f libcfa.a 303 $(AM_V_AR)$(libcfa_a_AR) libcfa.a $(libcfa_a_OBJECTS) $(libcfa_a_LIBADD) 304 $(AM_V_at)$(RANLIB) libcfa.a 288 305 289 306 mostlyclean-compile: … … 298 315 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa-prelude.Po@am__quote@ 299 316 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Po@am__quote@ 317 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/math.Po@am__quote@ 300 318 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rational.Po@am__quote@ 301 319 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdlib.Po@am__quote@ 302 320 321 .c.o: 322 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 323 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 324 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 325 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 326 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< 327 303 328 .c.obj: 304 @am__fastdepCC_TRUE@ $( COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`305 @am__fastdepCC_TRUE@ $( am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po306 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@329 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 330 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 331 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 307 332 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 308 @am__fastdepCC_FALSE@ $( COMPILE) -c `$(CYGPATH_W) '$<'`333 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` 309 334 install-cfalibDATA: $(cfalib_DATA) 310 335 @$(NORMAL_INSTALL) … … 455 480 456 481 clean-generic: 482 -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 457 483 458 484 distclean-generic: … … 579 605 @BACKEND_CC@ -c -o $@ $< 580 606 581 # extension -less header files are overridden by default make rules => explicitly override rule607 # extensionless header files are overridden by -o flag in default makerule => explicitly override default rule to silently do nothing 582 608 % : %.c 583 true 584 585 .c.o : ${abs_top_srcdir}/src/driver/cfa-cpp 586 ${CC} ${CFLAGS} -c -o $@ $< 609 @true 610 611 ${libobjs} : ${abs_top_srcdir}/src/driver/cfa-cpp # add dependency to cfa-cpp so all libraries are rebuilt with new translator 587 612 588 613 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/libcfa/fstream
r1b5c81ed rf80e0218 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Apr 5 22:37:12201613 // Update Count : 8 212 // Last Modified On : Thu Apr 28 08:08:04 2016 13 // Update Count : 88 14 14 // 15 15 … … 23 23 void *file; 24 24 _Bool sepDefault; 25 _Bool sepOnOff;25 int sepOnOff; // FIX ME: type should be _Bool 26 26 char separator[separateSize]; 27 27 }; // ofstream -
src/libcfa/fstream.c
r1b5c81ed rf80e0218 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // fstream.c -- 7 // fstream.c -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Apr 6 17:55:27201613 // Update Count : 1 7611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Mon May 02 15:14:52 2016 13 // Update Count : 187 14 14 // 15 15 … … 75 75 if ( fclose( (FILE *)(os->file) ) == EOF ) { 76 76 perror( IO_MSG "close output" ); 77 } // if 77 } // if 78 78 } // close 79 79 … … 93 93 int prtfmt( ofstream * os, const char fmt[], ... ) { 94 94 va_list args; 95 96 95 va_start( args, fmt ); 97 96 int len = vfprintf( (FILE *)(os->file), fmt, args ); … … 103 102 } // if 104 103 va_end( args ); 104 105 sepReset( os ); // reset separator 105 106 return len; 106 107 } // prtfmt … … 139 140 if ( fclose( (FILE *)(is->file) ) == EOF ) { 140 141 perror( IO_MSG "close input" ); 141 } // if 142 } // if 142 143 } // close 143 144 … … 154 155 return is; 155 156 } // read 156 157 157 158 ifstream *ungetc( ifstream * is, char c ) { 158 159 if ( fail( is ) ) { -
src/libcfa/iostream.c
r1b5c81ed rf80e0218 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // iostream.c -- 7 // iostream.c -- 8 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Apr 6 16:13:29201613 // Update Count : 27812 // Last Modified On : Thu May 26 10:08:31 2016 13 // Update Count : 305 14 14 // 15 15 … … 21 21 #include <float.h> // DBL_DIG, LDBL_DIG 22 22 #include <complex.h> // creal, cimag 23 #include <ctype.h> // isspace, ispunct24 23 } 25 24 … … 34 33 ostype * ?|?( ostype *os, short int si ) { 35 34 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 36 sepReset( os );37 35 prtfmt( os, "%hd", si ); 38 36 return os; … … 42 40 ostype * ?|?( ostype *os, unsigned short int usi ) { 43 41 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 44 sepReset( os );45 42 prtfmt( os, "%hu", usi ); 46 43 return os; … … 50 47 ostype * ?|?( ostype *os, int i ) { 51 48 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 52 sepReset( os );53 49 prtfmt( os, "%d", i ); 54 50 return os; … … 58 54 ostype * ?|?( ostype *os, unsigned int ui ) { 59 55 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 60 sepReset( os );61 56 prtfmt( os, "%u", ui ); 62 57 return os; … … 66 61 ostype * ?|?( ostype *os, long int li ) { 67 62 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 68 sepReset( os );69 63 prtfmt( os, "%ld", li ); 70 64 return os; … … 74 68 ostype * ?|?( ostype *os, unsigned long int uli ) { 75 69 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 76 sepReset( os );77 70 prtfmt( os, "%lu", uli ); 78 71 return os; … … 82 75 ostype * ?|?( ostype *os, long long int lli ) { 83 76 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 84 sepReset( os );85 77 prtfmt( os, "%lld", lli ); 86 78 return os; … … 90 82 ostype * ?|?( ostype *os, unsigned long long int ulli ) { 91 83 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 92 sepReset( os );93 84 prtfmt( os, "%llu", ulli ); 94 85 return os; … … 98 89 ostype * ?|?( ostype *os, float f ) { 99 90 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 100 sepReset( os );101 91 prtfmt( os, "%g", f ); 102 92 return os; … … 106 96 ostype * ?|?( ostype *os, double d ) { 107 97 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 108 sepReset( os );109 98 prtfmt( os, "%.*lg", DBL_DIG, d ); 110 99 return os; … … 114 103 ostype * ?|?( ostype *os, long double ld ) { 115 104 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 116 sepReset( os );117 105 prtfmt( os, "%.*Lg", LDBL_DIG, ld ); 118 106 return os; … … 155 143 // opening delimiters 156 144 ['('] : Open, ['['] : Open, ['{'] : Open, 157 ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 145 ['$'] : Open, [(unsigned char)'£'] : Open, [(unsigned char)'¥'] : Open, 146 [(unsigned char)'¡'] : Open, [(unsigned char)'¿'] : Open, [(unsigned char)'«'] : Open, 158 147 // closing delimiters 159 148 [','] : Close, ['.'] : Close, [':'] : Close, [';'] : Close, ['!'] : Close, ['?'] : Close, … … 162 151 // opening-closing delimiters 163 152 ['\''] : OpenClose, ['`'] : OpenClose, ['"'] : OpenClose, 164 [' \f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace153 [' '] : OpenClose, ['\f'] : OpenClose, ['\n'] : OpenClose, ['\r'] : OpenClose, ['\t'] : OpenClose, ['\v'] : OpenClose, // isspace 165 154 }; // mask 166 155 167 int len = strlen( cp ); 168 // null string => no separator 169 if ( len == 0 ) { sepOff( os ); return os; } 156 if ( cp[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator 157 170 158 // first character IS NOT spacing or closing punctuation => add left separator 171 159 unsigned char ch = cp[0]; // must make unsigned … … 173 161 prtfmt( os, "%s", sepGet( os ) ); 174 162 } // if 163 164 // if string starts line, must reset to determine open state because separator is off 165 sepReset( os ); // reset separator 166 175 167 // last character IS spacing or opening punctuation => turn off separator for next item 176 unsigned int posn = len - 1;168 unsigned int len = strlen( cp ), posn = len - 1; 177 169 ch = cp[posn]; // must make unsigned 178 if ( mask[ ch ] == Open || mask[ ch ] == OpenClose ) { 170 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 171 sepOn( os ); 172 } else { 179 173 sepOff( os ); 180 } else {181 sepOn( os );182 174 } // if 183 175 return write( os, cp, len ); … … 187 179 ostype * ?|?( ostype *os, const void *p ) { 188 180 if ( sepPrt( os ) ) prtfmt( os, "%s", sepGet( os ) ); 189 sepReset( os );190 181 prtfmt( os, "%p", p ); 191 182 return os; … … 193 184 194 185 195 forall( dtype ostype | ostream( ostype ) ) 186 forall( dtype ostype | ostream( ostype ) ) 196 187 ostype * ?|?( ostype *os, ostype * (* manip)( ostype * ) ) { 197 188 return manip( os ); 198 189 } // ?|? 199 190 200 forall( dtype ostype | ostream( ostype ) ) 191 forall( dtype ostype | ostream( ostype ) ) 201 192 ostype * endl( ostype * os ) { 202 193 os | '\n'; … … 206 197 } // endl 207 198 208 forall( dtype ostype | ostream( ostype ) ) 199 forall( dtype ostype | ostream( ostype ) ) 209 200 ostype * sepOn( ostype * os ) { 210 201 sepOn( os ); … … 212 203 } // sepOn 213 204 214 forall( dtype ostype | ostream( ostype ) ) 205 forall( dtype ostype | ostream( ostype ) ) 215 206 ostype * sepOff( ostype * os ) { 216 207 sepOff( os ); … … 218 209 } // sepOff 219 210 220 forall( dtype ostype | ostream( ostype ) ) 211 forall( dtype ostype | ostream( ostype ) ) 221 212 ostype * sepEnable( ostype * os ) { 222 213 sepEnable( os ); … … 224 215 } // sepEnable 225 216 226 forall( dtype ostype | ostream( ostype ) ) 217 forall( dtype ostype | ostream( ostype ) ) 227 218 ostype * sepDisable( ostype * os ) { 228 219 sepDisable( os ); … … 344 335 } // ?|? 345 336 346 _Istream_cstrUC cstr( char * s ) { _Istream_cstrUC s = { s }; return s; }337 _Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; } 347 338 forall( dtype istype | istream( istype ) ) 348 339 istype * ?|?( istype * is, _Istream_cstrUC cstr ) { … … 351 342 } // cstr 352 343 353 _Istream_cstrC cstr( char * s , int size ) { _Istream_cstrC s = { s, size }; return s; }344 _Istream_cstrC cstr( char * str, int size ) { return (_Istream_cstrC){ str, size }; } 354 345 forall( dtype istype | istream( istype ) ) 355 346 istype * ?|?( istype * is, _Istream_cstrC cstr ) { -
src/libcfa/prelude.cf
r1b5c81ed rf80e0218 1 1 # 2 "prelude.cf" // needed for error messages from this file 2 // -*- Mode: C -*- 3 // 2 // -*- Mode: C -*- 3 // 4 4 // Copyright (C) Glen Ditchfield 1994, 1999 5 // 5 // 6 6 // prelude.cf -- Standard Cforall Preample for C99 7 // 7 // 8 8 // Author : Glen Ditchfield 9 9 // Created On : Sat Nov 29 07:23:41 2014 … … 117 117 forall( ftype FT ) lvalue FT *?( FT * ); 118 118 119 _Bool +?( _Bool ), -?( _Bool ), ~?( _Bool ); 120 signed int +?( signed int ), -?( signed int ), ~?( signed int ); 121 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int ); 122 signed long int +?( signed long int ), -?( signed long int ), ~?( signed long int ); 123 unsigned long int +?( unsigned long int ), -?( unsigned long int ), ~?( unsigned long int ); 124 signed long long int +?( signed long long int ), -?( signed long long int ), ~?( signed long long int ); 125 unsigned long long int +?( unsigned long long int ), -?( unsigned long long int ), ~?( unsigned long long int ); 119 _Bool +?( _Bool ), -?( _Bool ), ~?( _Bool ); 120 signed int +?( signed int ), -?( signed int ), ~?( signed int ); 121 unsigned int +?( unsigned int ), -?( unsigned int ), ~?( unsigned int ); 122 signed long int +?( signed long int ), -?( signed long int ), ~?( signed long int ); 123 unsigned long int +?( unsigned long int ), -?( unsigned long int ), ~?( unsigned long int ); 124 signed long long int +?( signed long long int ), -?( signed long long int ), ~?( signed long long int ); 125 unsigned long long int +?( unsigned long long int ), -?( unsigned long long int ), ~?( unsigned long long int ); 126 126 float +?( float ), -?( float ); 127 127 double +?( double ), -?( double ); … … 627 627 ?+=?( long double _Complex *, long double _Complex ), ?+=?( volatile long double _Complex *, long double _Complex ), 628 628 ?-=?( long double _Complex *, long double _Complex ), ?-=?( volatile long double _Complex *, long double _Complex ); 629 630 631 632 633 634 // ------------------------------------------------------------ 635 // 636 // Section ??? Constructors and Destructors 637 // 638 // ------------------------------------------------------------ 639 640 // default ctor 641 void ?{}( _Bool * ), ?{}( volatile _Bool * ); 642 void ?{}( char * ), ?{}( volatile char * ); 643 void ?{}( unsigned char * ), ?{}( volatile unsigned char * ); 644 void ?{}( char signed * ), ?{}( volatile char signed * ); 645 void ?{}( int short * ), ?{}( volatile int short * ); 646 void ?{}( int short unsigned * ), ?{}( volatile int short unsigned * ); 647 void ?{}( signed int * ), ?{}( volatile signed int * ); 648 void ?{}( unsigned int * ), ?{}( volatile unsigned int * ); 649 void ?{}( signed long int * ), ?{}( volatile signed long int * ); 650 void ?{}( unsigned long int * ), ?{}( volatile unsigned long int * ); 651 void ?{}( signed long long int * ), ?{}( volatile signed long long int * ); 652 void ?{}( unsigned long long int * ), ?{}( volatile unsigned long long int * ); 653 void ?{}( float * ), ?{}( volatile float * ); 654 void ?{}( double * ), ?{}( volatile double * ); 655 void ?{}( long double * ), ?{}( volatile long double * ); 656 void ?{}( float _Complex * ), ?{}( volatile float _Complex * ); 657 void ?{}( double _Complex * ), ?{}( volatile double _Complex * ); 658 void ?{}( long double _Complex * ), ?{}( volatile long double _Complex * ); 659 660 // copy ctor 661 void ?{}( _Bool *, _Bool ), ?{}( volatile _Bool *, _Bool ); 662 void ?{}( char *, char ), ?{}( volatile char *, char ); 663 void ?{}( unsigned char *, unsigned char ), ?{}( volatile unsigned char *, unsigned char ); 664 void ?{}( char signed *, char signed ), ?{}( volatile char signed *, char signed ); 665 void ?{}( int short *, int short ), ?{}( volatile int short *, int short ); 666 void ?{}( int short unsigned *, int short unsigned ), ?{}( volatile int short unsigned *, int short unsigned ); 667 void ?{}( signed int *, signed int), ?{}( volatile signed int *, signed int ); 668 void ?{}( unsigned int *, unsigned int), ?{}( volatile unsigned int *, unsigned int ); 669 void ?{}( signed long int *, signed long int), ?{}( volatile signed long int *, signed long int ); 670 void ?{}( unsigned long int *, unsigned long int), ?{}( volatile unsigned long int *, unsigned long int ); 671 void ?{}( signed long long int *, signed long long int), ?{}( volatile signed long long int *, signed long long int ); 672 void ?{}( unsigned long long int *, unsigned long long int), ?{}( volatile unsigned long long int *, unsigned long long int ); 673 void ?{}( float *, float), ?{}( volatile float *, float ); 674 void ?{}( double *, double), ?{}( volatile double *, double ); 675 void ?{}( long double *, long double), ?{}( volatile long double *, long double ); 676 void ?{}( float _Complex *, float _Complex), ?{}( volatile float _Complex *, float _Complex ); 677 void ?{}( double _Complex *, double _Complex), ?{}( volatile double _Complex *, double _Complex ); 678 void ?{}( long double _Complex *, long double _Complex), ?{}( volatile long double _Complex *, long double _Complex ); 679 680 // dtor 681 void ^?{}( _Bool * ), ^?{}( volatile _Bool * ); 682 void ^?{}( char * ), ^?{}( volatile char * ); 683 void ^?{}( char unsigned * ), ^?{}( volatile char unsigned * ); 684 void ^?{}( char signed * ), ^?{}( volatile char signed * ); 685 void ^?{}( int short * ), ^?{}( volatile int short * ); 686 void ^?{}( int short unsigned * ), ^?{}( volatile int short unsigned * ); 687 void ^?{}( signed int * ), ^?{}( volatile signed int * ); 688 void ^?{}( unsigned int * ), ^?{}( volatile unsigned int * ); 689 void ^?{}( signed long int * ), ^?{}( volatile signed long int * ); 690 void ^?{}( unsigned long int * ), ^?{}( volatile unsigned long int * ); 691 void ^?{}( signed long long int * ), ^?{}( volatile signed long long int * ); 692 void ^?{}( unsigned long long int * ), ^?{}( volatile unsigned long long int * ); 693 void ^?{}( float * ), ^?{}( volatile float * ); 694 void ^?{}( double * ), ^?{}( volatile double * ); 695 void ^?{}( long double * ), ^?{}( volatile long double * ); 696 void ^?{}( float _Complex * ), ^?{}( volatile float _Complex * ); 697 void ^?{}( double _Complex * ), ^?{}( volatile double _Complex * ); 698 void ^?{}( long double _Complex * ), ^?{}( volatile long double _Complex * ); 699 700 // // default ctor 701 // forall( dtype DT ) void ?{}( DT ** ); 702 // forall( dtype DT ) void ?{}( const DT ** ); 703 // forall( dtype DT ) void ?{}( volatile DT ** ); 704 // forall( dtype DT ) void ?{}( const volatile DT ** ); 705 706 // // copy ctor 707 // forall( dtype DT ) void ?{}( DT **, DT* ); 708 // forall( dtype DT ) void ?{}( const DT **, DT* ); 709 // forall( dtype DT ) void ?{}( volatile DT **, DT* ); 710 // forall( dtype DT ) void ?{}( const volatile DT **, DT* ); 711 712 // // dtor 713 // forall( dtype DT ) void ^?{}( DT ** ); 714 // forall( dtype DT ) void ^?{}( const DT ** ); 715 // forall( dtype DT ) void ^?{}( volatile DT ** ); 716 // forall( dtype DT ) void ^?{}( const volatile DT ** ); 717 718 // copied from assignment section 719 // copy constructors 720 forall( ftype FT ) void ?{}( FT **, FT * ); 721 forall( ftype FT ) void ?{}( FT * volatile *, FT * ); 722 723 forall( dtype DT ) void ?{}( DT * *, DT * ); 724 forall( dtype DT ) void ?{}( DT * volatile *, DT * ); 725 forall( dtype DT ) void ?{}( const DT * *, DT * ); 726 forall( dtype DT ) void ?{}( const DT * volatile *, DT * ); 727 forall( dtype DT ) void ?{}( const DT * *, const DT * ); 728 forall( dtype DT ) void ?{}( const DT * volatile *, const DT * ); 729 forall( dtype DT ) void ?{}( volatile DT * *, DT * ); 730 forall( dtype DT ) void ?{}( volatile DT * volatile *, DT * ); 731 forall( dtype DT ) void ?{}( volatile DT * *, volatile DT * ); 732 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile DT * ); 733 734 forall( dtype DT ) void ?{}( const volatile DT * *, DT * ); 735 forall( dtype DT ) void ?{}( const volatile DT * volatile *, DT * ); 736 forall( dtype DT ) void ?{}( const volatile DT * *, const DT * ); 737 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const DT * ); 738 forall( dtype DT ) void ?{}( const volatile DT * *, volatile DT * ); 739 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile DT * ); 740 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile DT * ); 741 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile DT * ); 742 743 forall( dtype DT ) void ?{}( DT * *, void * ); 744 forall( dtype DT ) void ?{}( DT * volatile *, void * ); 745 forall( dtype DT ) void ?{}( const DT * *, void * ); 746 forall( dtype DT ) void ?{}( const DT * volatile *, void * ); 747 forall( dtype DT ) void ?{}( const DT * *, const void * ); 748 forall( dtype DT ) void ?{}( const DT * volatile *, const void * ); 749 forall( dtype DT ) void ?{}( volatile DT * *, void * ); 750 forall( dtype DT ) void ?{}( volatile DT * volatile *, void * ); 751 forall( dtype DT ) void ?{}( volatile DT * *, volatile void * ); 752 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile void * ); 753 754 forall( dtype DT ) void ?{}( const volatile DT * *, void * ); 755 forall( dtype DT ) void ?{}( const volatile DT * volatile *, void * ); 756 forall( dtype DT ) void ?{}( const volatile DT * *, const void * ); 757 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const void * ); 758 forall( dtype DT ) void ?{}( const volatile DT * *, volatile void * ); 759 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile void * ); 760 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile void * ); 761 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile void * ); 762 763 forall( dtype DT ) void ?{}( void * *, DT * ); 764 forall( dtype DT ) void ?{}( void * volatile *, DT * ); 765 forall( dtype DT ) void ?{}( const void * *, DT * ); 766 forall( dtype DT ) void ?{}( const void * volatile *, DT * ); 767 forall( dtype DT ) void ?{}( const void * *, const DT * ); 768 forall( dtype DT ) void ?{}( const void * volatile *, const DT * ); 769 forall( dtype DT ) void ?{}( volatile void * *, DT * ); 770 forall( dtype DT ) void ?{}( volatile void * volatile *, DT * ); 771 forall( dtype DT ) void ?{}( volatile void * *, volatile DT * ); 772 forall( dtype DT ) void ?{}( volatile void * volatile *, volatile DT * ); 773 forall( dtype DT ) void ?{}( const volatile void * *, DT * ); 774 forall( dtype DT ) void ?{}( const volatile void * volatile *, DT * ); 775 forall( dtype DT ) void ?{}( const volatile void * *, const DT * ); 776 forall( dtype DT ) void ?{}( const volatile void * volatile *, const DT * ); 777 forall( dtype DT ) void ?{}( const volatile void * *, volatile DT * ); 778 forall( dtype DT ) void ?{}( const volatile void * volatile *, volatile DT * ); 779 forall( dtype DT ) void ?{}( const volatile void * *, const volatile DT * ); 780 forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile DT * ); 781 782 void ?{}( void * *, void * ); 783 void ?{}( void * volatile *, void * ); 784 void ?{}( const void * *, void * ); 785 void ?{}( const void * volatile *, void * ); 786 void ?{}( const void * *, const void * ); 787 void ?{}( const void * volatile *, const void * ); 788 void ?{}( volatile void * *, void * ); 789 void ?{}( volatile void * volatile *, void * ); 790 void ?{}( volatile void * *, volatile void * ); 791 void ?{}( volatile void * volatile *, volatile void * ); 792 void ?{}( const volatile void * *, void * ); 793 void ?{}( const volatile void * volatile *, void * ); 794 void ?{}( const volatile void * *, const void * ); 795 void ?{}( const volatile void * volatile *, const void * ); 796 void ?{}( const volatile void * *, volatile void * ); 797 void ?{}( const volatile void * volatile *, volatile void * ); 798 void ?{}( const volatile void * *, const volatile void * ); 799 void ?{}( const volatile void * volatile *, const volatile void * ); 800 801 //forall( dtype DT ) void ?{}( DT * *, forall( dtype DT2 ) const DT2 * ); 802 //forall( dtype DT ) void ?{}( DT * volatile *, forall( dtype DT2 ) const DT2 * ); 803 forall( dtype DT ) void ?{}( const DT * *, forall( dtype DT2 ) const DT2 * ); 804 forall( dtype DT ) void ?{}( const DT * volatile *, forall( dtype DT2 ) const DT2 * ); 805 //forall( dtype DT ) void ?{}( volatile DT * *, forall( dtype DT2 ) const DT2 * ); 806 //forall( dtype DT ) void ?{}( volatile DT * volatile *, forall( dtype DT2 ) const DT2 * ); 807 forall( dtype DT ) void ?{}( const volatile DT * *, forall( dtype DT2 ) const DT2 * ); 808 forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * ); 809 810 forall( ftype FT ) void ?{}( FT * *, forall( ftype FT2 ) FT2 * ); 811 forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * ); 812 813 // default ctors 814 forall( ftype FT ) void ?{}( FT * * ); 815 forall( ftype FT ) void ?{}( FT * volatile * ); 816 817 forall( dtype DT ) void ?{}( DT * *); 818 forall( dtype DT ) void ?{}( DT * volatile *); 819 forall( dtype DT ) void ?{}( const DT * *); 820 forall( dtype DT ) void ?{}( const DT * volatile *); 821 forall( dtype DT ) void ?{}( volatile DT * *); 822 forall( dtype DT ) void ?{}( volatile DT * volatile *); 823 forall( dtype DT ) void ?{}( const volatile DT * *); 824 forall( dtype DT ) void ?{}( const volatile DT * volatile *); 825 826 void ?{}( void * *); 827 void ?{}( void * volatile *); 828 void ?{}( const void * *); 829 void ?{}( const void * volatile *); 830 void ?{}( volatile void * *); 831 void ?{}( volatile void * volatile *); 832 void ?{}( const volatile void * *); 833 void ?{}( const volatile void * volatile *); 834 835 // dtors 836 forall( ftype FT ) void ^?{}( FT * * ); 837 forall( ftype FT ) void ^?{}( FT * volatile * ); 838 839 forall( dtype DT ) void ^?{}( DT * *); 840 forall( dtype DT ) void ^?{}( DT * volatile *); 841 forall( dtype DT ) void ^?{}( const DT * *); 842 forall( dtype DT ) void ^?{}( const DT * volatile *); 843 forall( dtype DT ) void ^?{}( volatile DT * *); 844 forall( dtype DT ) void ^?{}( volatile DT * volatile *); 845 forall( dtype DT ) void ^?{}( const volatile DT * *); 846 forall( dtype DT ) void ^?{}( const volatile DT * volatile *); 847 848 void ^?{}( void * *); 849 void ^?{}( void * volatile *); 850 void ^?{}( const void * *); 851 void ^?{}( const void * volatile *); 852 void ^?{}( volatile void * *); 853 void ^?{}( volatile void * volatile *); 854 void ^?{}( const volatile void * *); 855 void ^?{}( const volatile void * volatile *); -
src/libcfa/rational
r1b5c81ed rf80e0218 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Fri Apr 8 11:38:27201615 // Update Count : 1 514 // Last Modified On : Wed May 4 14:11:45 2016 15 // Update Count : 16 16 16 // 17 17 … … 28 28 29 29 // constructors 30 Rational rational();31 Rational rational(long int n );32 Rational rational(long int n, long int d );30 void ?{}( Rational * r ); 31 void ?{}( Rational * r, long int n ); 32 void ?{}( Rational * r, long int n, long int d ); 33 33 34 34 // getter/setter for numerator/denominator -
src/libcfa/rational.c
r1b5c81ed rf80e0218 11 11 // Created On : Wed Apr 6 17:54:28 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Apr 12 21:26:42201614 // Update Count : 2 113 // Last Modified On : Wed May 4 14:16:14 2016 14 // Update Count : 25 15 15 // 16 16 … … 18 18 #include "fstream" 19 19 #include "stdlib" 20 #include "math" // floor 20 21 21 22 … … 52 53 // constructors 53 54 54 Rational rational() {55 r eturn (Rational){ 0, 1 };55 void ?{}( Rational * r ) { 56 r{ 0, 1 }; 56 57 } // rational 57 58 58 Rational rational(long int n ) {59 r eturn (Rational){ n, 1 };59 void ?{}( Rational * r, long int n ) { 60 r{ n, 1 }; 60 61 } // rational 61 62 62 Rational rational(long int n, long int d ) {63 void ?{}( Rational * r, long int n, long int d ) { 63 64 long int t = simplify( &n, &d ); // simplify 64 return (Rational){ n / t, d / t }; 65 r->numerator = n / t; 66 r->denominator = d / t; 65 67 } // rational 66 68 … … 171 173 Rational narrow( double f, long int md ) { 172 174 if ( md <= 1 ) { // maximum fractional digits too small? 173 Rational t = rational( f, 1 ); // truncate fraction 174 return t; 175 return (Rational){ f, 1}; // truncate fraction 175 176 } // if 176 177 … … 198 199 k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2]; 199 200 } // for 200 Rational t = rational( neg ? -h[1] : h[1], k[1] ); 201 return t; 201 return (Rational){ neg ? -h[1] : h[1], k[1] }; 202 202 } // narrow 203 203 -
src/libcfa/stdlib
r1b5c81ed rf80e0218 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 : Wed Apr 27 22:03:29 2016 13 // Update Count : 96 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 ); … … 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
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.