- Timestamp:
- Jul 10, 2016, 4:35:32 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, 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:
- 4e06c1e, c13d970
- Parents:
- 07bc165
- Location:
- src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r07bc165 r6e4b913 11 11 ## Created On : Sun May 31 08:51:46 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Fri Feb 26 17:19:16201614 ## Update Count : 5713 ## Last Modified On : Fri Jul 8 12:22:25 2016 14 ## Update Count : 60 15 15 ############################################################################### 16 16 … … 46 46 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL 47 47 48 CXXFLAGS = -g -std=c++11 # remove default -O2 to allow better debugging 48 AM_CXXFLAGS = -g -std=c++11 49 49 50 50 MAINTAINERCLEANFILES += ${libdir}/${notdir ${cfa_cpplib_PROGRAMS}} -
src/Makefile.in
r07bc165 r6e4b913 272 272 CFA_BACKEND_CC = @CFA_BACKEND_CC@ 273 273 CFA_BINDIR = @CFA_BINDIR@ 274 CFA_FLAGS = @CFA_FLAGS@ 274 275 CFA_INCDIR = @CFA_INCDIR@ 275 276 CFA_LIBDIR = @CFA_LIBDIR@ … … 280 281 CXX = @CXX@ 281 282 CXXDEPMODE = @CXXDEPMODE@ 282 CXXFLAGS = -g -std=c++11 # remove default -O2 to allow better debugging283 CXXFLAGS = @CXXFLAGS@ 283 284 CYGPATH_W = @CYGPATH_W@ 284 285 DEFS = @DEFS@ … … 430 431 # need files Common/utility.h 431 432 driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -DDEBUG_ALL 433 AM_CXXFLAGS = -g -std=c++11 432 434 all: $(BUILT_SOURCES) 433 435 $(MAKE) $(AM_MAKEFLAGS) all-am -
src/driver/Makefile.in
r07bc165 r6e4b913 95 95 CFA_BACKEND_CC = @CFA_BACKEND_CC@ 96 96 CFA_BINDIR = @CFA_BINDIR@ 97 CFA_FLAGS = @CFA_FLAGS@ 97 98 CFA_INCDIR = @CFA_INCDIR@ 98 99 CFA_LIBDIR = @CFA_LIBDIR@ -
src/driver/cfa.cc
r07bc165 r6e4b913 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 5 20:56:18201613 // Update Count : 14 012 // Last Modified On : Thu Jul 7 08:56:01 2016 13 // Update Count : 144 14 14 // 15 15 … … 87 87 bool cpp_flag = false; // -E or -M flag, preprocessor only 88 88 bool std_flag = false; // -std= flag 89 bool debugging = false; // -g flag 90 (void) debugging; // remove unused variable warning 89 bool debugging __attribute(( unused )) = false; // -g flag 91 90 92 91 const char *args[argc + 100]; // cfa command line values, plus some space for additional flags … … 245 244 } // if 246 245 246 // add the CFA include-library paths, which allow direct access to header files without directory qualification 247 247 248 args[nargs] = "-I" CFA_INCDIR; 248 249 nargs += 1; -
src/examples/Makefile.in
r07bc165 r6e4b913 104 104 CFA_BACKEND_CC = @CFA_BACKEND_CC@ 105 105 CFA_BINDIR = @CFA_BINDIR@ 106 CFA_FLAGS = @CFA_FLAGS@ 106 107 CFA_INCDIR = @CFA_INCDIR@ 107 108 CFA_LIBDIR = @CFA_LIBDIR@ -
src/libcfa/Makefile.am
r07bc165 r6e4b913 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Tue Jul 5 20:52:31 201614 ## Update Count : 1 8513 ## Last Modified On : Fri Jul 8 23:05:11 2016 14 ## Update Count : 192 15 15 ############################################################################### 16 16 … … 26 26 # create extra forward types/declarations to reduce inclusion of library files 27 27 extras.cf : extras.regx extras.c 28 $(AM_V_GEN)@BACKEND_CC@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf28 $(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf 29 29 30 30 # create forward declarations for gcc builtins … … 51 51 52 52 libcfa-prelude.o : libcfa-prelude.c 53 $(AM_V_GEN)@BACKEND_CC@ -c -o $@ $<53 $(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -c -o $@ $< 54 54 55 CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t# TEMPORARY: does not build with -O255 CFLAGS = -quiet -g -Wall -Wno-unused-function @CFA_FLAGS@ -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2 56 56 CC = ${abs_top_srcdir}/src/driver/cfa 57 57 -
src/libcfa/Makefile.in
r07bc165 r6e4b913 132 132 CFA_BACKEND_CC = @CFA_BACKEND_CC@ 133 133 CFA_BINDIR = @CFA_BINDIR@ 134 CFA_FLAGS = @CFA_FLAGS@ 134 135 CFA_INCDIR = @CFA_INCDIR@ 135 136 CFA_LIBDIR = @CFA_LIBDIR@ 136 137 CFA_PREFIX = @CFA_PREFIX@ 137 CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t# TEMPORARY: does not build with -O2138 CFLAGS = -quiet -g -Wall -Wno-unused-function @CFA_FLAGS@ -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2 138 139 CPP = @CPP@ 139 140 CPPFLAGS = @CPPFLAGS@ … … 602 603 # create extra forward types/declarations to reduce inclusion of library files 603 604 extras.cf : extras.regx extras.c 604 $(AM_V_GEN)@BACKEND_CC@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf605 $(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf 605 606 606 607 # create forward declarations for gcc builtins … … 625 626 626 627 libcfa-prelude.o : libcfa-prelude.c 627 $(AM_V_GEN)@BACKEND_CC@ -c -o $@ $<628 $(AM_V_GEN)@BACKEND_CC@ @CFA_FLAGS@ -c -o $@ $< 628 629 629 630 # extensionless header files are overridden by -o flag in default makerule => explicitly override default rule to silently do nothing -
src/libcfa/extras.c
r07bc165 r6e4b913 1 1 #include <stddef.h> 2 2 #include <stdlib.h> 3 #include <stdio.h> -
src/libcfa/extras.regx
r07bc165 r6e4b913 1 typedef.* size_t 2 typedef.* ptrdiff_t 1 typedef.* size_t; 2 typedef.* ptrdiff_t; 3 extern.* abort\(.*\).* 4 extern.* atexit\(.*\).* 3 5 extern.* exit\(.*\).* 4 extern.* atexit\(.*\).* 5 extern.* abort\(.*\).* 6 extern.* free\(.*\).* 7 extern.*\*malloc\(.*\).* 8 extern.* printf\(.*\).* -
src/libcfa/limits.c
r07bc165 r6e4b913 10 10 // Created On : Wed Apr 6 18:06:52 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Apr 7 17:18:45201613 // Update Count : 1 112 // Last Modified On : Fri Jul 8 13:23:33 2016 13 // Update Count : 14 14 14 // 15 15 … … 20 20 const short int MIN = -32768; 21 21 const int MIN = -2147483648; 22 #if __WORDSIZE == 64 22 23 const long int MIN = -9223372036854775807L - 1L; 24 #else 25 const long int MIN = (int)MIN; 26 #endif // M64 23 27 const long long int MIN = -9223372036854775807LL - 1LL; 24 28 … … 27 31 const int MAX = 2147483647; 28 32 const unsigned int MAX = 4294967295_U; 33 #if __WORDSIZE == 64 29 34 const long int MAX = 9223372036854775807_L; 35 #else 36 const long int MAX = (int)MAX; 37 #endif // M64 30 38 const unsigned long int MAX = 4294967295_U; 31 39 const long long int MAX = 9223372036854775807_LL; -
src/libcfa/rational.c
r07bc165 r6e4b913 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 5 18:29:12201613 // Update Count : 2612 // Last Modified On : Sat Jul 9 11:18:04 2016 13 // Update Count : 40 14 14 // 15 15 … … 31 31 // alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm 32 32 static long int gcd( long int a, long int b ) { 33 33 for ( ;; ) { // Euclid's algorithm 34 34 long int r = a % b; 35 35 if ( r == 0 ) break; 36 36 a = b; 37 37 b = r; 38 38 } // for 39 39 return b; 40 40 } // gcd 41 41 42 42 static long int simplify( long int *n, long int *d ) { 43 43 if ( *d == 0 ) { 44 44 serr | "Invalid rational number construction: denominator cannot be equal to 0." | endl; 45 45 exit( EXIT_FAILURE ); 46 47 48 46 } // exit 47 if ( *d < 0 ) { *d = -*d; *n = -*n; } // move sign to numerator 48 return gcd( abs( *n ), *d ); // simplify 49 49 } // Rationalnumber::simplify 50 50 … … 53 53 54 54 void ?{}( Rational * r ) { 55 55 r{ 0, 1 }; 56 56 } // rational 57 57 58 58 void ?{}( Rational * r, long int n ) { 59 59 r{ n, 1 }; 60 60 } // rational 61 61 62 62 void ?{}( Rational * r, long int n, long int d ) { 63 64 63 long int t = simplify( &n, &d ); // simplify 64 r->numerator = n / t; 65 65 r->denominator = d / t; 66 66 } // rational … … 70 70 71 71 long int numerator( Rational r ) { 72 72 return r.numerator; 73 73 } // numerator 74 74 75 75 long int numerator( Rational r, long int n ) { 76 77 78 79 80 76 long int prev = r.numerator; 77 long int t = gcd( abs( n ), r.denominator ); // simplify 78 r.numerator = n / t; 79 r.denominator = r.denominator / t; 80 return prev; 81 81 } // numerator 82 82 83 83 long int denominator( Rational r ) { 84 84 return r.denominator; 85 85 } // denominator 86 86 87 87 long int denominator( Rational r, long int d ) { 88 89 90 91 92 88 long int prev = r.denominator; 89 long int t = simplify( &r.numerator, &d ); // simplify 90 r.numerator = r.numerator / t; 91 r.denominator = d / t; 92 return prev; 93 93 } // denominator 94 94 … … 97 97 98 98 int ?==?( Rational l, Rational r ) { 99 99 return l.numerator * r.denominator == l.denominator * r.numerator; 100 100 } // ?==? 101 101 102 102 int ?!=?( Rational l, Rational r ) { 103 103 return ! ( l == r ); 104 104 } // ?!=? 105 105 106 106 int ?<?( Rational l, Rational r ) { 107 107 return l.numerator * r.denominator < l.denominator * r.numerator; 108 108 } // ?<? 109 109 110 110 int ?<=?( Rational l, Rational r ) { 111 111 return l < r || l == r; 112 112 } // ?<=? 113 113 114 114 int ?>?( Rational l, Rational r ) { 115 115 return ! ( l <= r ); 116 116 } // ?>? 117 117 118 118 int ?>=?( Rational l, Rational r ) { 119 119 return ! ( l < r ); 120 120 } // ?>=? 121 121 … … 125 125 Rational -?( Rational r ) { 126 126 Rational t = { -r.numerator, r.denominator }; 127 127 return t; 128 128 } // -? 129 129 130 130 Rational ?+?( Rational l, Rational r ) { 131 131 if ( l.denominator == r.denominator ) { // special case 132 132 Rational t = { l.numerator + r.numerator, l.denominator }; 133 133 return t; 134 134 } else { 135 135 Rational t = { l.numerator * r.denominator + l.denominator * r.numerator, l.denominator * r.denominator }; 136 136 return t; 137 137 } // if 138 138 } // ?+? 139 139 140 140 Rational ?-?( Rational l, Rational r ) { 141 141 if ( l.denominator == r.denominator ) { // special case 142 142 Rational t = { l.numerator - r.numerator, l.denominator }; 143 143 return t; 144 144 } else { 145 145 Rational t = { l.numerator * r.denominator - l.denominator * r.numerator, l.denominator * r.denominator }; 146 146 return t; 147 147 } // if 148 148 } // ?-? 149 149 150 150 Rational ?*?( Rational l, Rational r ) { 151 151 Rational t = { l.numerator * r.numerator, l.denominator * r.denominator }; 152 152 return t; 153 153 } // ?*? 154 154 155 155 Rational ?/?( Rational l, Rational r ) { 156 156 if ( r.numerator < 0 ) { 157 157 r.numerator = -r.numerator; 158 158 r.denominator = -r.denominator; 159 159 } // if 160 160 Rational t = { l.numerator * r.denominator, l.denominator * r.numerator }; 161 161 return t; 162 162 } // ?/? 163 163 … … 169 169 } // widen 170 170 171 // http s://rosettacode.org/wiki/Convert_decimal_number_to_rational#C171 // http://www.ics.uci.edu/~eppstein/numth/frap.c 172 172 Rational narrow( double f, long int md ) { 173 173 if ( md <= 1 ) { // maximum fractional digits too small? … … 176 176 177 177 // continued fraction coefficients 178 long int a, h[3] = { 0, 1, 0 }, k[3] = { 1, 0, 0 }; 179 long int x, d, n = 1; 180 int i, neg = 0; 181 182 if ( f < 0 ) { neg = 1; f = -f; } 183 while ( f != floor( f ) ) { n <<= 1; f *= 2; } 184 d = f; 185 186 // continued fraction and check denominator each step 187 for (i = 0; i < 64; i++) { 188 a = n ? d / n : 0; 189 if (i && !a) break; 190 x = d; d = n; n = x % n; 191 x = a; 192 if (k[1] * a + k[0] >= md) { 193 x = (md - k[0]) / k[1]; 194 if ( ! (x * 2 >= a || k[1] >= md) ) break; 195 i = 65; 196 } // if 197 h[2] = x * h[1] + h[0]; h[0] = h[1]; h[1] = h[2]; 198 k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2]; 199 } // for 200 return (Rational){ neg ? -h[1] : h[1], k[1] }; 178 long int m00 = 1, m11 = 1, m01 = 0, m10 = 0; 179 long int ai, t; 180 181 // find terms until denom gets too big 182 for ( ;; ) { 183 ai = (long int)f; 184 if ( ! (m10 * ai + m11 <= md) ) break; 185 t = m00 * ai + m01; 186 m01 = m00; 187 m00 = t; 188 t = m10 * ai + m11; 189 m11 = m10; 190 m10 = t; 191 t = (double)ai; 192 if ( f == t ) break; // prevent division by zero 193 f = 1 / (f - t); 194 if ( f > (double)0x7FFFFFFF ) break; // representation failure 195 } 196 return (Rational){ m00, m10 }; 201 197 } // narrow 202 198 … … 207 203 istype * ?|?( istype *is, Rational *r ) { 208 204 long int t; 209 205 is | &(r->numerator) | &(r->denominator); 210 206 t = simplify( &(r->numerator), &(r->denominator) ); 211 212 213 207 r->numerator /= t; 208 r->denominator /= t; 209 return is; 214 210 } // ?|? 215 211 216 212 forall( dtype ostype | ostream( ostype ) ) 217 213 ostype * ?|?( ostype *os, Rational r ) { 218 214 return os | r.numerator | '/' | r.denominator; 219 215 } // ?|? 220 216 -
src/tests/.expect/extension.txt
r07bc165 r6e4b913 1 extern void *malloc(long unsigned int __size); 2 extern void free(void *__ptr); 1 3 extern void abort(void); 2 4 extern int atexit(void (*__func)(void)); 3 5 extern void exit(int __status); 6 extern int printf(const char *__restrict __format, ...); 4 7 __extension__ int __a__i_1; 5 8 __extension__ int __b__i_1; -
src/tests/.expect/gccExtensions.txt
r07bc165 r6e4b913 1 extern void *malloc(long unsigned int __size); 2 extern void free(void *__ptr); 1 3 extern void abort(void); 2 4 extern int atexit(void (*__func)(void)); 3 5 extern void exit(int __status); 6 extern int printf(const char *__restrict __format, ...); 4 7 int main(int __argc__i_1, const char **__argv__PPCc_1){ 5 8 asm ( "nop" : : : ); -
src/tests/Makefile.am
r07bc165 r6e4b913 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Jun 27 14:39:08201614 ## Update Count : 3 413 ## Last Modified On : Sat Jul 9 11:23:24 2016 14 ## Update Count : 35 15 15 ############################################################################### 16 16 17 17 # applies to both programs 18 CFLAGS = -g -Wall -Wno-unused-function # TEMPORARY: does not build with -O218 CFLAGS = -g -Wall -Wno-unused-function @CFA_FLAGS@ # TEMPORARY: does not build with -O2 19 19 CC = @CFA_BINDIR@/cfa 20 20 -
src/tests/Makefile.in
r07bc165 r6e4b913 114 114 CFA_BACKEND_CC = @CFA_BACKEND_CC@ 115 115 CFA_BINDIR = @CFA_BINDIR@ 116 CFA_FLAGS = @CFA_FLAGS@ 116 117 CFA_INCDIR = @CFA_INCDIR@ 117 118 CFA_LIBDIR = @CFA_LIBDIR@ … … 119 120 120 121 # applies to both programs 121 CFLAGS = -g -Wall -Wno-unused-function # TEMPORARY: does not build with -O2122 CFLAGS = -g -Wall -Wno-unused-function @CFA_FLAGS@ # TEMPORARY: does not build with -O2 122 123 CPP = @CPP@ 123 124 CPPFLAGS = @CPPFLAGS@ -
src/tests/avltree/avl.h
r07bc165 r6e4b913 4 4 extern "C" { 5 5 #define NULL 0 6 void free(void *);7 6 #define assert(cond) if (! (cond)) { printf("Assertion failed: (%s) at %s:%d\n", #cond, __FILE__, __LINE__); abort(); } 8 int printf(const char *, ...);9 7 } 10 8 -
src/tests/avltree/avl1.c
r07bc165 r6e4b913 1 1 #include "avl.h" 2 2 // #include "cwrap.h" 3 4 extern "C" {5 void * malloc(long int);6 }7 3 8 4 forall(otype K | Comparable(K), otype V) -
src/tests/avltree/avl_test.c
r07bc165 r6e4b913 3 3 4 4 extern "C" { 5 int printf(const char *, ...);6 5 int strcmp(const char *, const char *); 7 6 } -
src/tests/init_once.c
r07bc165 r6e4b913 10 10 // Created On : Tue Jun 14 15:43:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 5 16:40:07201613 // Update Count : 212 // Last Modified On : Sat Jul 9 11:30:29 2016 13 // Update Count : 3 14 14 // 15 15 … … 23 23 //*** setup 24 24 extern "C" { 25 typedef unsigned long int size_t;26 25 #define NULL 0 27 26 void * malloc(size_t); 28 27 void free(void *); 29 28 #define assert(cond) if (! (cond)) { printf("Assertion failed: (%s) at %s:%d\n", #cond, __FILE__, __LINE__); abort(); } 30 int printf(const char *, ...);31 29 void *memset(void *s, int c, size_t n); 32 30 }
Note: See TracChangeset
for help on using the changeset viewer.