From: bdemsky Date: Thu, 22 Jun 2017 19:11:28 +0000 (-0700) Subject: Add test case plus make changes so test case runs X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=72621e530c9047773984cb62b4846446a5e9b78b;p=satune.git Add test case plus make changes so test case runs --- 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 0000000..92eefcc Binary files /dev/null and b/src/Test/buildconstraints differ diff --git a/src/Test/buildconstraints.c b/src/Test/buildconstraints.c new file mode 100644 index 0000000..ef6ea46 --- /dev/null +++ b/src/Test/buildconstraints.c @@ -0,0 +1,15 @@ +#include "csolver.h" + +int main(int numargs, char ** argv) { + CSolver * solver=allocCSolver(); + uint64_t set1[]={0, 1, 2}; + Set * s=createSet(solver, 0, set1, 3); + Element * e1=getElementVar(solver, s); + Element * e2=getElementVar(solver, s); + Set * domain[]={s, s}; + Predicate *equals=createPredicateOperator(solver, EQUALS, domain, 2); + Element * inputs[]={e1, e2}; + Boolean * b=applyPredicate(solver, equals, inputs, 2); + addBoolean(solver, b); + deleteSolver(solver); +} diff --git a/src/Test/buildconstraints.dSYM/Contents/Info.plist b/src/Test/buildconstraints.dSYM/Contents/Info.plist new file mode 100644 index 0000000..737bf4f --- /dev/null +++ b/src/Test/buildconstraints.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + 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 0000000..d4eacfc Binary files /dev/null and b/src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints differ 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 */