From 72621e530c9047773984cb62b4846446a5e9b78b Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 22 Jun 2017 12:11:28 -0700 Subject: [PATCH] Add test case plus make changes so test case runs --- src/Collections/array.h | 20 +++++++++--------- src/Collections/structs.c | 11 ++++++---- src/Collections/structs.h | 17 ++++++++------- src/Makefile | 3 +++ src/Test/.buildconstraints.d | 4 ++++ src/Test/Makefile | 19 +++++++++++++++++ src/Test/buildconstraints | Bin 0 -> 9236 bytes src/Test/buildconstraints.c | 15 +++++++++++++ .../buildconstraints.dSYM/Contents/Info.plist | 20 ++++++++++++++++++ .../Contents/Resources/DWARF/buildconstraints | Bin 0 -> 12066 bytes src/Test/run.sh | 7 ++++++ src/common.h | 5 +++++ src/csolver.h | 4 ++++ src/mymemory.h | 7 ++++++ 14 files changed, 110 insertions(+), 22 deletions(-) create mode 100644 src/Test/.buildconstraints.d create mode 100644 src/Test/Makefile create mode 100755 src/Test/buildconstraints create mode 100644 src/Test/buildconstraints.c create mode 100644 src/Test/buildconstraints.dSYM/Contents/Info.plist create mode 100644 src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints create mode 100755 src/Test/run.sh diff --git a/src/Collections/array.h b/src/Collections/array.h index d084158..73d0c32 100644 --- a/src/Collections/array.h +++ b/src/Collections/array.h @@ -7,41 +7,41 @@ uint size; \ }; \ typedef struct Array ## name Array ## name; \ - inline Array ## name * allocArray ## name(uint size) { \ + static inline Array ## name * allocArray ## name(uint size) { \ Array ## name * tmp = (Array ## name *)ourmalloc(sizeof(type)); \ tmp->size = size; \ tmp->array = (type *) ourcalloc(1, sizeof(type) * size); \ return tmp; \ } \ - inline Array ## name * allocArrayInit ## name(type * array, uint size) { \ + static inline Array ## name * allocArrayInit ## name(type * array, uint size) { \ Array ## name * tmp = allocArray ## name(size); \ memcpy(tmp->array, array, size * sizeof(type)); \ return tmp; \ } \ - inline type getArray ## name(Array ## name * This, uint index) { \ + static inline type getArray ## name(Array ## name * This, uint index) { \ return This->array[index]; \ } \ - inline void setArray ## name(Array ## name * This, uint index, type item) { \ + static inline void setArray ## name(Array ## name * This, uint index, type item) { \ This->array[index]=item; \ } \ - inline uint getSizeArray ## name(Array ## name *This) { \ + static inline uint getSizeArray ## name(Array ## name *This) { \ return This->size; \ } \ - inline void deleteArray ## name(Array ## name *This) { \ + static inline void deleteArray ## name(Array ## name *This) { \ ourfree(This->array); \ ourfree(This); \ } \ - inline type * exposeCArray ## name(Array ## name * This) { \ + static inline type * exposeCArray ## name(Array ## name * This) { \ return This->array; \ } \ - inline void deleteInlineArray ## name(Array ## name *This) { \ + static inline void deleteInlineArray ## name(Array ## name *This) { \ ourfree(This->array); \ } \ - inline void allocInlineArray ## name(Array ## name * This, uint size) { \ + static inline void allocInlineArray ## name(Array ## name * This, uint size) { \ This->size = size; \ This->array = (type *) ourcalloc(1, sizeof(type) * size); \ } \ - inline void allocInlineArrayInit ## name(Array ## name * This, type *array, uint size) { \ + static inline void allocInlineArrayInit ## name(Array ## name * This, type *array, uint size) { \ allocInlineArray ##name(This, size); \ memcpy(This->array, array, size * sizeof(type)); \ } diff --git a/src/Collections/structs.c b/src/Collections/structs.c index 4da4995..f776830 100644 --- a/src/Collections/structs.c +++ b/src/Collections/structs.c @@ -1,11 +1,14 @@ #include "structs.h" #include "mymemory.h" -VectorImpl(Int, uint64_t, 4); +VectorImpl(Table, Table *, 4); +VectorImpl(Set, Set *, 4); VectorImpl(Boolean, Boolean *, 4); VectorImpl(Constraint, Constraint *, 4); -VectorImpl(Set, Set *, 4); +VectorImpl(Function, Function *, 4); +VectorImpl(Predicate, Predicate *, 4); VectorImpl(Element, Element *, 4); +VectorImpl(Order, Order *, 4); +VectorImpl(TableEntry, TableEntry *, 4); VectorImpl(ASTNode, ASTNode *, 4); -HashTableImpl(Void, void *, void *, Ptr_hash_function, Ptr_equals); -HashSetImpl(Void, void *, Ptr_hash_function, Ptr_equals); +VectorImpl(Int, uint64_t, 4); diff --git a/src/Collections/structs.h b/src/Collections/structs.h index 71ba4b0..fec9d75 100644 --- a/src/Collections/structs.h +++ b/src/Collections/structs.h @@ -9,17 +9,19 @@ ArrayDef(Element, Element *); ArrayDef(Boolean, Boolean *); ArrayDef(Set, Set *); -VectorDef(Int, uint64_t, 4); + +VectorDef(Table, Table *, 4); +VectorDef(Set, Set *, 4); VectorDef(Boolean, Boolean *, 4); VectorDef(Constraint, Constraint *, 4); -VectorDef(Set, Set *, 4); -VectorDef(Element, Element *, 4); -VectorDef(TableEntry, TableEntry *, 4); +VectorDef(Function, Function *, 4); VectorDef(Predicate, Predicate *, 4); -VectorDef(Table, Table *, 4); +VectorDef(Element, Element *, 4); VectorDef(Order, Order *, 4); -VectorDef(Function, Function *, 4); +VectorDef(TableEntry, TableEntry *, 4); VectorDef(ASTNode, ASTNode *, 4); +VectorDef(Int, uint64_t, 4); + inline unsigned int Ptr_hash_function(void * hash) { return (unsigned int)((uint64_t)hash >> 4); @@ -29,6 +31,5 @@ inline bool Ptr_equals(void * key1, void * key2) { return key1 == key2; } -HashTableDef(Void, void *, void *, Ptr_hash_function, Ptr_equals); -HashSetDef(Void, void *, Ptr_hash_function, Ptr_equals); + #endif diff --git a/src/Makefile b/src/Makefile index 1c4d358..35468a0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,6 +37,9 @@ ${OBJ_DIR}: debug: CFLAGS += -DCONFIG_DEBUG debug: all +test: all + make -C Test + PHONY += docs docs: $(C_SOURCES) $(HEADERS) doxygen diff --git a/src/Test/.buildconstraints.d b/src/Test/.buildconstraints.d new file mode 100644 index 0000000..836415d --- /dev/null +++ b/src/Test/.buildconstraints.d @@ -0,0 +1,4 @@ +buildconstraints: buildconstraints.c ../csolver.h ../classlist.h \ + ../mymemory.h ../config.h ../AST/ops.h ../Collections/structs.h \ + ../Collections/vector.h ../Collections/hashtable.h ../common.h \ + ../Collections/hashset.h ../Collections/array.h diff --git a/src/Test/Makefile b/src/Test/Makefile new file mode 100644 index 0000000..ca9a632 --- /dev/null +++ b/src/Test/Makefile @@ -0,0 +1,19 @@ +BASE := .. + +OBJECTS := $(patsubst %.c, %, $(wildcard *.c)) + +include $(BASE)/common.mk + +DEPS := $(join $(addsuffix ., $(dir $(OBJECTS))), $(addsuffix .d, $(notdir $(OBJECTS)))) + +CPPFLAGS += -I$(BASE) -I$(BASE)/AST -I$(BASE)/Collections + +all: $(OBJECTS) + +-include $(DEPS) + +%: %.c + $(CC) -MMD -MF $(@D)/.$(@F).d -o $@ $< $(CPPFLAGS) -L$(BASE)/bin/ -l_cons_comp + +clean:: + rm -f $(OBJECTS) $(DEPS) diff --git a/src/Test/buildconstraints b/src/Test/buildconstraints new file mode 100755 index 0000000000000000000000000000000000000000..92eefcc2e5711cc4bbe9a4698ec712b43bae99c5 GIT binary patch literal 9236 zcmeHNUuYaf7@wp~jcIKDR7ymJYe^&(yuCz8Qx&Cq+c^V0{rw0{WqK&b)S&S^k9-yLA;d~5nS#Bq3= zrKK5ei@>u^9XX#$pPFj!BFE#wjiNBc#wZ+F(9F3f7CczKg!vMCXfo7vN3{d*RJK$* z*~Lc4x$BiPZp{_u+tcOqB~*_92Lsv_-!A3w`FK{?CE<`S%$HPr=T(1T?a;xmf{ zw?5%8-?HNCQv|?G^Q{s42Iu9%>$!r(bA_2Axx#$c6(80d0^Agz@2=HY*HO8yM^jU& znpsSioVvd#ODT&TZqL`1%xIQVjrZfLzZznA=d?ceW##TvhkcJ;?iMqfzIFh8^*?m#lR0v^qAim1w$;x4wmjBAv1(7*NR z?A4@x0#$=HsgS7-@>ATSfX*dcE8=w5DIWl{}MrHFYk<&)(diHnvn9 z*h#uNuuInMvhI*|r>ytL8a&m3UaBdYD-VB3Dm7UhxB-SNUMM&3R;$%4UR^i8hxH7s zZ(!jqfAb4i_{q8X8LYQpeGKa=tZT5yV4KTi!GOqzkq+K%fgeHxNux$P-i@Cije_5+ z5ZK6jCoy#^ww~RX?e_A%`W-l-^l7Cnr3*?gDE+3=?*FFIkBE3H!SN&v1kjU0M8&iwp}!zoh;h(lE6v8S1Q?y6OOQQ zrr`XSrAqX4w;TM{i&{`}0Pwzy|Q)WCvRfzNG}lr{oUqEHQ6HGy?q=_!f-774JS6W=dr0?E!M(G( zKTiHz-x%HEZ(Tnw*RN^!%Dvd+@%MA%#%$h_;m!EB+fX%N12%8H(5BmRYP4xrIIfm) zat58EygRq3Il>i&V`eqi@XV|*=QR0W4~O=nC-16rws17pF|{e-dK$}=bGB9Q;>Jy; z%^Qw3Q?zL#yV|g&jg*`rb3WmY6b=txxL_^Jm~*AWuZ@f*NM;M#losZAY-S`eY$oDG K=I4=?gZ%{qc + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.buildconstraints + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints b/src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints new file mode 100644 index 0000000000000000000000000000000000000000..d4eacfca2dd42c6dddbc57c2ca459d0635c050c6 GIT binary patch literal 12066 zcmeHNZ)_Xo8Gr5g96J|ZoY>G*-G*UJ|3aKb*+@%QlC^0Y(Uy*+Ed#{iI7edY*s0Gh zEmS0$#>Cc5TB+7;3{fT(#0NSt#0R9(75K2Rt{qbawB3}kg32~D{)jQghE(?Zz4zYP zbrRN(ljgU5-{;T!yuW+yxx43m;=7ms{mzAYA$)a0hz4}<;tU7X=7F}N|HFUgtsm`M zw&L51u6^arC#U-SN-v^9kWYYq4suE+6aYII#wo%5zyw00HAIjtJ6!@$X7YRWYL4OH+DCM!kLw2P%7+f!BJ8BGpe zhiBo)t{75yL8Wl;%uy>lZWW-b#_LgdcentcjJMaO`IpY;?D7d$<2|bIcun1Q(fPVc zMNPAmyE~H`HZ!?9^Uzh}J*)6|&E0m9f38wdUe|7UUDxyu_Et>ddj7ZT%6pWZ%``{y z<+G$bGhWC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B<7oS1fawx`WkgYfSTP%%FY1g{x~}6U^Z95Hx>EGVu7w=F9E^j5 z?;dHV>#LyGo1n*6PBCa!;&_pmk5lwQ2$V;4Mt_V#H$)+N`3Xv5!-lOJ6DU}06heva z_GRrIiAAVyawFGtcXYOQw0Ctbo~bBGZn3c@IaJ7`a>Le`y?uAGVA)oxkRDCisbYH6 zN^eh=>nJmw9~;kPtwPc+q?3adzVVXLh171RKDwwja_gdUP2_N{?~deoQBl)W)-z7+ z;%J=e#2Fop>tVSNSwGObUf#^Sq0!xMm;u_2Htd$C#F>X1a#;xrsL^$s&OaH*Kgtdi*Wq z8)x^Un%g1NXIK2hr%|F7Ff;AXKwt!XXbWS|Qa;*;F%?!@6X0Gj%pF zz{pap9YSp4mYUb#2Hf-D=iK3Z@~gvCo&Uz6v?2n({baGxv~$~M!}_a9FqckTcH literal 0 HcmV?d00001 diff --git a/src/Test/run.sh b/src/Test/run.sh new file mode 100755 index 0000000..9741fe0 --- /dev/null +++ b/src/Test/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=../bin +# For Mac OSX +export DYLD_LIBRARY_PATH=../bin + +$@ diff --git a/src/common.h b/src/common.h index 9b78485..d9e6d43 100644 --- a/src/common.h +++ b/src/common.h @@ -17,6 +17,7 @@ #include #include "config.h" +/* extern int model_out; extern int model_err; extern int switch_alloc; @@ -27,6 +28,10 @@ extern int switch_alloc; #define model_print_err(fmt, ...) do { model_dprintf(model_err, fmt, ## __VA_ARGS__); } while (0) +*/ + +#define model_print printf + #define NEXTPOW2(x) (1<<(sizeof(uint)*8-__builtin_clz(x-1))) #ifdef CONFIG_DEBUG diff --git a/src/csolver.h b/src/csolver.h index 95809dd..495d386 100644 --- a/src/csolver.h +++ b/src/csolver.h @@ -34,6 +34,10 @@ struct CSolver { CSolver * allocCSolver(); +/** Delete solver instance. */ + +void deleteSolver(CSolver * This); + /** This function creates a set containing the elements passed in the array. */ Set * createSet(CSolver *, VarType type, uint64_t * elements, uint num); diff --git a/src/mymemory.h b/src/mymemory.h index 2fa964e..32dfa51 100644 --- a/src/mymemory.h +++ b/src/mymemory.h @@ -19,9 +19,16 @@ #include "config.h" +/* void * ourmalloc(size_t size); void ourfree(void *ptr); void * ourcalloc(size_t count, size_t size); void * ourrealloc(void *ptr, size_t size); +*/ + +static inline void * ourmalloc(size_t size) { return malloc(size); } +static inline void ourfree(void *ptr) { free(ptr); } +static inline void * ourcalloc(size_t count, size_t size) { return calloc(count, size); } +static inline void * ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); } #endif/* _MY_MEMORY_H */ -- 2.34.1