Merge branch 'master' of /home/denys/src/yap/yap-6.3

This commit is contained in:
Denys Duchier 2011-08-09 15:03:54 +02:00
commit 31063fdc85
8 changed files with 101 additions and 43 deletions

View File

@ -25,6 +25,8 @@
#include <Yatom.h> #include <Yatom.h>
#include <clause.h> #include <clause.h>
#if DEBUG
#define NEXTOP(V,TYPE) ((yamop *)(&((V)->u.TYPE.next))) #define NEXTOP(V,TYPE) ((yamop *)(&((V)->u.TYPE.next)))
typedef enum { typedef enum {
@ -43,22 +45,9 @@ static size_t save_bytes(IOSTREAM *stream, void *ptr, size_t sz)
return Sfwrite(ptr, sz, 1, stream); return Sfwrite(ptr, sz, 1, stream);
} }
static size_t save_term(IOSTREAM *stream, Term t) static size_t restore_bytes(IOSTREAM *stream, void *ptr, size_t sz)
{ {
size_t len = Yap_ExportTerm(t, (char *)H, sizeof(CELL)*(ASP-H)); return Sfread(ptr, sz, 1, stream);
if (len <= 0) return 0;
return save_bytes(stream, (char *)H, len);
}
static size_t save_tag(IOSTREAM *stream, qlf_tag_t tag)
{
return save_bytes(stream, &tag, sizeof(qlf_tag_t));
}
static size_t save_pointer(IOSTREAM *stream, void *ptr)
{
void *p = ptr;
return save_bytes(stream, &p, sizeof(void *));
} }
static size_t save_uint(IOSTREAM *stream, UInt val) static size_t save_uint(IOSTREAM *stream, UInt val)
@ -67,12 +56,69 @@ static size_t save_uint(IOSTREAM *stream, UInt val)
return save_bytes(stream, &v, sizeof(UInt)); return save_bytes(stream, &v, sizeof(UInt));
} }
static UInt restore_uint(IOSTREAM *stream, context ctx)
{
UInt v;
restore_bytes(stream, &v, sizeof(UInt));
return v;
}
static size_t save_int(IOSTREAM *stream, Int val) static size_t save_int(IOSTREAM *stream, Int val)
{ {
Int v = val; Int v = val;
return save_bytes(stream, &v, sizeof(Int)); return save_bytes(stream, &v, sizeof(Int));
} }
static Int restore_int(IOSTREAM *stream, context ctx)
{
UInt v;
restore_bytes(stream, &v, sizeof(Int));
return v;
}
static size_t save_term(IOSTREAM *stream, Term t)
{
CELL *oldH = H;
H += 4096;
size_t len = Yap_ExportTerm(t, (char *)oldH, sizeof(CELL)*4096);
H = oldH;
if (len <= 0) return 0;
CHECK(save_uint(stream, len) );
return save_bytes(stream, (char *)H, len);
}
static Term
restore_term(IOSTREAM *stream, context *ql)
{
Term t;
CELL *horig = H;
CELL *start, *oldASP = ASP;
UInt len = read_uint(stream, ql);
start = ASP = H-(len/sizeof(CELL)+1);
restore_bytes(stream, start, len);
t = Yap_ImportTerm((char *)start);
return t;
}
static size_t save_tag(IOSTREAM *stream, qlf_tag_t tag)
{
return save_bytes(stream, &tag, sizeof(qlf_tag_t));
}
static qlf_tag_t
restore_tag(IOSTREAM *stream, context *ql)
{
return save_bytes(stream, &tag, sizeof(qlf_tag_t));
}
static size_t save_pointer(IOSTREAM *stream, void *ptr)
{
void *p = ptr;
return save_bytes(stream, &p, sizeof(void *));
}
static size_t save_atom(IOSTREAM *stream, Atom at) static size_t save_atom(IOSTREAM *stream, Atom at)
{ {
if (IsWideAtom(at)) { if (IsWideAtom(at)) {
@ -166,8 +212,9 @@ static size_t save_BlobTermInCode(IOSTREAM *stream, Term t)
return save_pointer(stream, (void *)RepAppl(t)); return save_pointer(stream, (void *)RepAppl(t));
} }
static size_t save_Opcode(IOSTREAM *stream, OPCODE op) static size_t save_Opcode(IOSTREAM *stream, op_numbers op)
{ {
fprintf(stderr,"%d\n",op);
return save_int(stream, Yap_op_from_opcode(op)); return save_int(stream, Yap_op_from_opcode(op));
} }
@ -237,8 +284,12 @@ save_code(IOSTREAM *stream, yamop *pc, yamop *max) {
static size_t static size_t
save_lu_clause(IOSTREAM *stream, LogUpdClause *cl) { save_lu_clause(IOSTREAM *stream, LogUpdClause *cl) {
CHECK(save_uint(stream, cl->ClSize));
CHECK(save_uint(stream, cl->ClFlags));
CHECK(save_tag(stream, QLF_START_CLAUSE)); CHECK(save_tag(stream, QLF_START_CLAUSE));
CHECK(save_term(stream, cl->ClSource->Entry)); if (!(cl->ClFlags & FactMask)) {
CHECK(save_term(stream, cl->ClSource->Entry));
}
return save_code(stream, cl->ClCode, (yamop *)cl->ClSource); return save_code(stream, cl->ClCode, (yamop *)cl->ClSource);
} }
@ -249,10 +300,12 @@ save_dynamic_clause(IOSTREAM *stream, DynamicClause *cl) {
} }
static size_t static size_t
save_static_clause(IOSTREAM *stream, StaticClause *cl) { save_static_clause(IOSTREAM *stream, StaticClause *cl, PredEntry *ap) {
CHECK(save_uint(stream, cl->ClSize));
CHECK(save_uint(stream, cl->ClFlags));
CHECK(save_tag(stream, QLF_START_CLAUSE)); CHECK(save_tag(stream, QLF_START_CLAUSE));
if (!(cl->ClFlags & FactMask)) { if (!(cl->ClFlags & FactMask) &&
// Yap_DebugPlWrite(cl->usc.ClSource->Entry);fprintf(stderr,"\n"); (ap->PredFlags & SourcePredFlag)) {
CHECK(save_term(stream, cl->usc.ClSource->Entry)); CHECK(save_term(stream, cl->usc.ClSource->Entry));
return save_code(stream, cl->ClCode, (yamop *)(cl->usc.ClSource)); return save_code(stream, cl->ClCode, (yamop *)(cl->usc.ClSource));
} else { } else {
@ -307,7 +360,7 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) {
StaticClause *cl = ClauseCodeToStaticClause(FirstC); StaticClause *cl = ClauseCodeToStaticClause(FirstC);
do { do {
CHECK(save_static_clause(stream, cl)); CHECK(save_static_clause(stream, cl, pp));
if (cl->ClCode == LastC) return 1; if (cl->ClCode == LastC) return 1;
cl = cl->ClNext; cl = cl->ClNext;
} while (TRUE); } while (TRUE);
@ -317,6 +370,7 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) {
static size_t static size_t
save_pred(IOSTREAM *stream, PredEntry *ap) { save_pred(IOSTREAM *stream, PredEntry *ap) {
return walk_clauses(stream, ap);
CHECK(save_Func(stream, ap->FunctorOfPred)); CHECK(save_Func(stream, ap->FunctorOfPred));
CHECK(save_uint(stream, ap->ArityOfPE)); CHECK(save_uint(stream, ap->ArityOfPE));
CHECK(save_uint(stream, ap->PredFlags)); CHECK(save_uint(stream, ap->PredFlags));
@ -354,8 +408,12 @@ p_save_module_preds( USES_REGS1 )
return save_module(stream, tmod) != 0; return save_module(stream, tmod) != 0;
} }
#endif
void Yap_InitQLY(void) void Yap_InitQLY(void)
{ {
#if DEBUG
Yap_InitCPred("$save_module_preds", 2, p_save_module_preds, SyncPredFlag|HiddenPredFlag|UserCPredFlag); Yap_InitCPred("$save_module_preds", 2, p_save_module_preds, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
#endif
} }

View File

@ -248,7 +248,7 @@ C_SOURCES= \
$(srcdir)/C/load_shl.c $(srcdir)/C/load_dyld.c \ $(srcdir)/C/load_shl.c $(srcdir)/C/load_dyld.c \
$(srcdir)/C/mavar.c $(srcdir)/C/modules.c $(srcdir)/C/other.c \ $(srcdir)/C/mavar.c $(srcdir)/C/modules.c $(srcdir)/C/other.c \
$(srcdir)/C/parser.c \ $(srcdir)/C/parser.c \
$(srcdir)/C/qly.c \ $(srcdir)/C/qlyw.c \
$(srcdir)/C/save.c $(srcdir)/C/scanner.c \ $(srcdir)/C/save.c $(srcdir)/C/scanner.c \
$(srcdir)/C/sort.c $(srcdir)/C/stdpreds.c $(srcdir)/C/sysbits.c \ $(srcdir)/C/sort.c $(srcdir)/C/stdpreds.c $(srcdir)/C/sysbits.c \
$(srcdir)/C/threads.c \ $(srcdir)/C/threads.c \
@ -358,7 +358,7 @@ ENGINE_OBJECTS = \
myddas_mysql.o myddas_odbc.o myddas_shared.o myddas_initialization.o \ myddas_mysql.o myddas_odbc.o myddas_shared.o myddas_initialization.o \
myddas_util.o myddas_statistics.o myddas_top_level.o \ myddas_util.o myddas_statistics.o myddas_top_level.o \
myddas_wkb2prolog.o modules.o other.o \ myddas_wkb2prolog.o modules.o other.o \
parser.o qly.o save.o scanner.o sort.o stdpreds.o \ parser.o qlyw.o save.o scanner.o sort.o stdpreds.o \
sysbits.o threads.o tracer.o \ sysbits.o threads.o tracer.o \
udi.o rtree.o rtree_udi.o\ udi.o rtree.o rtree_udi.o\
unify.o userpreds.o utilpreds.o \ unify.o userpreds.o utilpreds.o \
@ -444,8 +444,8 @@ init.o: $(srcdir)/C/init.c config.h
load_foreign.o: $(srcdir)/C/load_foreign.c config.h load_foreign.o: $(srcdir)/C/load_foreign.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/load_foreign.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/load_foreign.c -o $@
qly.o: $(srcdir)/C/qly.c config.h qlyw.o: $(srcdir)/C/qlyw.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/qly.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/qlyw.c -o $@
save.o: $(srcdir)/C/save.c config.h save.o: $(srcdir)/C/save.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/save.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/save.c -o $@

14
configure vendored
View File

@ -1472,7 +1472,7 @@ Optional Features:
--enable-dlcompat use dlcompat library for dynamic loading on Mac OS X --enable-dlcompat use dlcompat library for dynamic loading on Mac OS X
--enable-cplint=DIR enable the cplint library using the glu library in DIR/lib --enable-cplint=DIR enable the cplint library using the glu library in DIR/lib
--enable-clpbn-bp enable belief propagation solver in CLPBN. --enable-clpbn-bp enable belief propagation solver in CLPBN.
v --enable-myddas[=DIR] enable the MYDDAS library --enable-myddas[=DIR] enable the MYDDAS library
--enable-myddas-stats enable the MYDDAS library statistics support --enable-myddas-stats enable the MYDDAS library statistics support
--enable-myddas-top-level enable the MYDDAS top-level support to MySQL --enable-myddas-top-level enable the MYDDAS top-level support to MySQL
--enable-mimecharset=charset Default MIME charset to set on new messages --enable-mimecharset=charset Default MIME charset to set on new messages
@ -4936,11 +4936,11 @@ if test "$GCC" = "yes"
then then
if test "$debugyap" = "yes" if test "$debugyap" = "yes"
then then
CXXFLAGS="-O -g -Wall $CFLAGS" CXXFLAGS="-O -g -Wall $CXXFLAGS"
C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
else else
CXXFLAGS="-O3 -fomit-frame-pointer -Wall $CFLAGS" CXXFLAGS="-O3 -fomit-frame-pointer -Wall $CXXFLAGS"
C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
@ -4955,7 +4955,7 @@ then
sparc*) sparc*)
case "$target_os" in case "$target_os" in
*solaris2-9*) CFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFLAGS" *solaris2-9*) CFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFLAGS"
CXXFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFPPLAGS" CXXFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CXXFLAGS"
;; ;;
esac esac
;; ;;
@ -5004,7 +5004,7 @@ else
CFLAGS="-A -A $CFLAGS" CFLAGS="-A -A $CFLAGS"
elif test "$CC" = "cl" elif test "$CC" = "cl"
then then
CXXFLAGS="-/nologo $CFLAGS" CXXFLAGS="-/nologo $CXXFLAGS"
CFLAGS="/nologo $CFLAGS" CFLAGS="/nologo $CFLAGS"
CPP="/nologo /E" CPP="/nologo /E"
fi fi
@ -5014,10 +5014,10 @@ else
then then
if test "$debugyap" = "yes" if test "$debugyap" = "yes"
then then
CXXFLAGS="-Ae -g -O $CFLAGS" CXXFLAGS="-Ae -g -O $CXXFLAGS"
CFLAGS="-Ae -g -O $CFLAGS" CFLAGS="-Ae -g -O $CFLAGS"
else else
CXXFLAGS="-Ae +O3 +Onolimit $CFLAGS" CXXFLAGS="-Ae +O3 +Onolimit $CXXFLAGS"
CFLAGS="-Ae +O3 +Onolimit $CFLAGS" CFLAGS="-Ae +O3 +Onolimit $CFLAGS"
fi fi
fi fi

View File

@ -223,7 +223,7 @@ AC_ARG_WITH(cudd,
[yap_cv_cudd=no]) [yap_cv_cudd=no])
AC_ARG_ENABLE(myddas, AC_ARG_ENABLE(myddas,
v [ --enable-myddas[[=DIR]] enable the MYDDAS library], [ --enable-myddas[[=DIR]] enable the MYDDAS library],
if test "$enableval" = yes; then if test "$enableval" = yes; then
yap_cv_myddas=/usr yap_cv_myddas=/usr
elif test "$enableval" = no; then elif test "$enableval" = no; then
@ -500,11 +500,11 @@ if test "$GCC" = "yes"
then then
if test "$debugyap" = "yes" if test "$debugyap" = "yes"
then then
CXXFLAGS="-O -g -Wall $CFLAGS" CXXFLAGS="-O -g -Wall $CXXFLAGS"
C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
else else
CXXFLAGS="-O3 -fomit-frame-pointer -Wall $CFLAGS" CXXFLAGS="-O3 -fomit-frame-pointer -Wall $CXXFLAGS"
C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS" CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
@ -520,7 +520,7 @@ then
case "$target_os" in case "$target_os" in
*solaris[2-9]*) dnl *solaris[2-9]*) dnl
CFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFLAGS" CFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFLAGS"
CXXFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFPPLAGS" CXXFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CXXFLAGS"
;; ;;
esac esac
;; ;;
@ -569,7 +569,7 @@ else
CFLAGS="-A -A $CFLAGS" CFLAGS="-A -A $CFLAGS"
elif test "$CC" = "cl" elif test "$CC" = "cl"
then then
CXXFLAGS="-/nologo $CFLAGS" CXXFLAGS="-/nologo $CXXFLAGS"
CFLAGS="/nologo $CFLAGS" CFLAGS="/nologo $CFLAGS"
CPP="/nologo /E" CPP="/nologo /E"
fi fi
@ -579,10 +579,10 @@ else
then then
if test "$debugyap" = "yes" if test "$debugyap" = "yes"
then then
CXXFLAGS="-Ae -g -O $CFLAGS" CXXFLAGS="-Ae -g -O $CXXFLAGS"
CFLAGS="-Ae -g -O $CFLAGS" CFLAGS="-Ae -g -O $CFLAGS"
else else
CXXFLAGS="-Ae +O3 +Onolimit $CFLAGS" CXXFLAGS="-Ae +O3 +Onolimit $CXXFLAGS"
CFLAGS="-Ae +O3 +Onolimit $CFLAGS" CFLAGS="-Ae +O3 +Onolimit $CFLAGS"
fi fi
fi fi

View File

@ -57,7 +57,7 @@ gecode_yap.o: \
gecode_yap_cc_forward_auto_generated.icc \ gecode_yap_cc_forward_auto_generated.icc \
$(srcdir)/disjunctor.icc \ $(srcdir)/disjunctor.icc \
$(srcdir)/disjunctor.hh $(srcdir)/disjunctor.hh
$(CXX) -c $(CXXFLAGS) $(DISJUNCTOR) -o $@ $< $(CXX) -c -I. $(CXXFLAGS) $(DISJUNCTOR) -o $@ $<
@DO_SECOND_LD@gecode_yap.@SO@: gecode_yap.o @DO_SECOND_LD@gecode_yap.@SO@: gecode_yap.o
@DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) -lgecodeint -lgecodeset -lgecodesearch @EXTRA_LIBS_FOR_DLLS@ @DO_SECOND_LD@ @SHLIB_LD@ -o gecode_yap.@SO@ gecode_yap.o $(LDFLAGS) -lgecodeint -lgecodeset -lgecodesearch @EXTRA_LIBS_FOR_DLLS@

@ -1 +1 @@
Subproject commit a6f0f4ec7d5fd51ca8b268b8392da9b20bfd1b44 Subproject commit c9493b2c73e3c8ab8b8524a13352bf0f3ec545a9

@ -1 +1 @@
Subproject commit f1c3ef54f4d9431ba5b4188cb72ca3056d20b202 Subproject commit 17f0b15b0fb0af5fc558bc303e32d4f5e3bdce98

View File

@ -18,7 +18,7 @@
save_module(Mod) :- save_module(Mod) :-
atom_concat(Mod,'.qly',F), atom_concat(Mod,'.qly',F),
open(F,write,S), open(F, write, S, [type(binary)]),
'$save_module_preds'(S, Mod), '$save_module_preds'(S, Mod),
close(S). close(S).