diff --git a/C/heapgc.c b/C/heapgc.c index 83e2d875e..0e63cfd58 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -4130,9 +4130,11 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop USES_REGS) if (ASP - H < gc_margin/sizeof(CELL) || effectiveness < 20) { LeaveGCMode( PASS_REGS1 ); +#ifndef YAPOR if (gc_margin < 2*CalculateStackGap()) gc_margin = 2*CalculateStackGap(); return Yap_growstack(gc_margin); +#endif } /* * debug for(save_total=1; save_total<=N; ++save_total) diff --git a/C/utilpreds.c b/C/utilpreds.c index b71318f16..8cbce9246 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -1166,8 +1166,16 @@ CELL *CellDifH(CELL *hptr, CELL *hlow) return (CELL *)((char *)hptr-(char *)hlow); } -#define AdjustSizeAtom(X) ((char *)(((CELL)(X)+(8-1)) & ~(8-1))) +#define AdjustSizeAtom(X) (((CELL)(X)+(8-1)) & ~(8-1)) +static inline +CELL *AdjustSize(CELL *x, char *buf) +{ + UInt offset = (char *)x-buf; + return (CELL*)(buf+AdjustSizeAtom(offset)); +} + +/* export an atom from the symbol table to a buffer */ static inline Atom export_atom(Atom at, char **hpp, char *buf, size_t len) { @@ -1175,7 +1183,7 @@ Atom export_atom(Atom at, char **hpp, char *buf, size_t len) size_t sz; ptr = *hpp; - ptr = AdjustSizeAtom(ptr); + ptr = (char *)AdjustSize((CELL*)ptr, buf); p0 = ptr; if (IsWideAtom(at)) { @@ -1189,7 +1197,7 @@ Atom export_atom(Atom at, char **hpp, char *buf, size_t len) } else { *ptr++ = 0; sz = strlen(RepAtom(at)->StrOfAE); - if (sz +1 >= len) + if (sz + 1 + sizeof(wchar_t) >= len) return (Atom)NULL; strcpy(ptr, RepAtom(at)->StrOfAE); *hpp = ptr+(sz+1); @@ -1198,10 +1206,11 @@ Atom export_atom(Atom at, char **hpp, char *buf, size_t len) return (Atom)(p0-buf); } +/* place a buffer: first arity then the atom */ static inline Functor export_functor(Functor f, char **hpp, char *buf, size_t len) { - CELL *hptr = (UInt *)AdjustSizeAtom(*hpp); + CELL *hptr = AdjustSize((CELL *)*hpp, buf); UInt arity = ArityOfFunctor(f); if (2*sizeof(CELL) >= len) return NULL; @@ -1209,7 +1218,9 @@ Functor export_functor(Functor f, char **hpp, char *buf, size_t len) *hpp = (char *)(hptr+1); if (!export_atom(NameOfFunctor(f), hpp, buf, len)) return NULL; - /* increment so that it cannot be mistaken with a standard functor */ + /* increment so that it cannot be mistaken with a functor on the stack, + (increment is used as a tag ........01 + */ return (Functor)(((char *)hptr-buf)+1); } @@ -1228,9 +1239,10 @@ export_term_to_buffer(Term inpt, char *buf, char *bptr, CELL *t0 , CELL *tf, siz { char *td = bptr; CELL *bf = (CELL *)buf; - if (buf + len < (char *)((CELL *)td + (tf-t0))) + if (buf + len < (char *)((CELL *)td + (tf-t0))) { return FALSE; - memcpy((void *)td, (void *)t0, (tf-t0)* sizeof(CELL)); + } + memcpy((void *)td, (void *)t0, (tf-t0)* sizeof(CELL)); bf[0] = (td-buf); bf[1] = (tf-t0); bf[2] = inpt; @@ -1541,6 +1553,7 @@ static Atom AddAtom(Atom t, char *buf) { char *s = buf+(UInt)t; + if (!*s) { return Yap_LookupAtom(s+1); } else { @@ -1557,7 +1570,7 @@ FetchFunctor(CELL *pt, char *buf) UInt arity = *ptr++; Atom name, at; // and then an atom - ptr = (CELL *)AdjustSizeAtom((char*)ptr); + ptr = AdjustSize(ptr, buf); name = (Atom)((char *)ptr-buf); at = AddAtom(name, buf); *pt = (CELL)Yap_MkFunctor(at, arity); @@ -1627,7 +1640,7 @@ Yap_ImportTerm(char * buf) { return MkVarTerm(); if (IsAtomOrIntTerm(tinp)) { if (IsAtomTerm(tinp)) { - char *pt = AdjustSizeAtom((char *)(bc+3)); + char *pt = (char *)AdjustSize(bc+3, buf); return MkAtomTerm(Yap_LookupAtom(pt)); } else return tinp; @@ -4189,6 +4202,298 @@ p_subsumes( USES_REGS1 ) /* subsumes terms t1 and t2 */ } } + +static int term_subsumer_complex(register CELL *pt0, register CELL *pt0_end, register + CELL *pt1, CELL *npt USES_REGS) +{ + register CELL **to_visit = (CELL **)ASP; + tr_fr_ptr OLDTR = TR; + int out; + CELL *bindings = NULL, *tbindings = NULL; + HB = H; + + loop: + while (pt0 < pt0_end) { + register CELL d0, d1; + + ++ pt0; + ++ pt1; + d0 = Derefa(pt0); + d1 = Derefa(pt1); + if (d0 == d1) { + *npt++ = d0; + continue; + } else if (IsVarTerm(d0)) { + CELL *match, *omatch = NULL; + + match = VarOfTerm(d0); + if (match >= HB) { + while (match >= HB) { + /* chained to a sequence */ + if (Yap_eq(d1, match[1]) ) { + *npt++ = match[2]; + break; + } + omatch = match; + match = (CELL *)match[3]; + } + /* found a match */ + if (match >= HB) + continue; + /* could not find a match, add to end of chain */ + RESET_VARIABLE(H); /* key */ + H[1] = d1; /* comparison value */ + H[2] = (CELL)npt; /* new value */ + H[3] = (CELL)match; /* end of chain points back to first cell */ + omatch[3] = (CELL)H; + H+=4; + RESET_VARIABLE(npt); + npt++; + continue; + } + if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) { + goto trail_overflow; + } + RESET_VARIABLE(H); + H[1] = d1; + H[2] = (CELL)npt; + H[3] = d0; + Bind(VarOfTerm(d0), (CELL)H); + H+=4; + RESET_VARIABLE(npt); + npt++; + continue; + } else if (IsPairTerm(d0) && IsPairTerm(d1)) { + CELL *match = bindings; + + while (match) { + if (match[0] == d0 && match[1] == d1) { + *npt++ = match[2]; + break; + } + match = (CELL *)match[3]; + } + if (match) { + continue; + } + if (bindings) { + *tbindings = (CELL)H; + } else { + bindings = H; + } + H[0] = d0; + H[1] = d1; + H[2] = AbsPair(H+4); + H[3] = (CELL)NULL; + tbindings = H+3; + H+=4; + *npt++ = AbsPair(H); +#ifdef RATIONAL_TREES + /* now link the two structures so that no one else will */ + /* come here */ + to_visit -= 5; + to_visit[0] = pt0; + to_visit[1] = pt0_end; + to_visit[2] = pt1; + to_visit[3] = tbindings; + to_visit[4] = npt; +#else + /* store the terms to visit */ + if (pt0 < pt0_end) { + to_visit -= 4; + to_visit[0] = pt0; + to_visit[1] = pt0_end; + to_visit[2] = pt1; + to_visit[3] = npt; + } +#endif + pt0 = RepPair(d0) - 1; + pt0_end = RepPair(d0) + 1; + pt1 = RepPair(d1) - 1; + npt = H; + H += 2; + if (H > (CELL *)to_visit -1024) + goto stack_overflow; + continue; + } else if (IsApplTerm(d0) && IsApplTerm(d1)) { + CELL *ap2 = RepAppl(d0); + CELL *ap3 = RepAppl(d1); + Functor f = (Functor)(*ap2); + Functor f2 = (Functor)(*ap3); + if (f == f2) { + CELL *match = bindings; + + if (IsExtensionFunctor(f)) { + if (unify_extension(f, d0, ap2, d1)) { + *npt++ = d0; + continue; + } + } + while (match) { + if (match[0] == d0 && match[1] == d1) { + *npt++ = match[2]; + break; + } + match = (CELL *)match[3]; + } + if (match) { + continue; + } + if (bindings) { + *tbindings = (CELL)H; + } else { + bindings = H; + } + H[0] = d0; + H[1] = d1; + H[2] = AbsAppl(H+4); + H[3] = (CELL)NULL; + tbindings = H+3; + H+=4; + *npt++ = AbsAppl(H); +#ifdef RATIONAL_TREES + /* now link the two structures so that no one else will */ + /* come here */ + to_visit -= 5; + to_visit[0] = pt0; + to_visit[1] = pt0_end; + to_visit[2] = pt1; + to_visit[3] = tbindings; + to_visit[4] = npt; +#else + /* store the terms to visit */ + if (pt0 < pt0_end) { + to_visit -= 4; + to_visit[0] = pt0; + to_visit[1] = pt0_end; + to_visit[2] = pt1; + to_visit[3] = npt; + } +#endif + d0 = ArityOfFunctor(f); + pt0 = ap2; + pt0_end = ap2 + d0; + pt1 = ap3; + npt = H; + *npt++ = (CELL)f; + H += d0; + if (H > (CELL *)to_visit -1024) + goto stack_overflow; + continue; + } + } + RESET_VARIABLE(npt); + npt++; + } + /* Do we still have compound terms to visit */ + if (to_visit < (CELL **)ASP) { +#ifdef RATIONAL_TREES + pt0 = to_visit[0]; + pt0_end = to_visit[1]; + pt1 = to_visit[2]; + tbindings = to_visit[3]; + npt = to_visit[ 4]; + if (!tbindings) { + bindings = NULL; + } + to_visit += 5; +#else + pt0 = to_visit[0]; + pt0_end = to_visit[1]; + pt1 = to_visit[2]; + npt = to_visit[3]; + to_visit += 4; +#endif + goto loop; + } + out = 1; + + complete: + /* get rid of intermediate variables */ + while (TR != OLDTR) { + CELL *pt1 = (CELL *) TrailTerm(--TR); + RESET_VARIABLE(pt1); + } + HBREG = B->cp_h; + return out; + + stack_overflow: + out = -1; + goto complete; + + trail_overflow: + out = -2; + goto complete; + +} + +static Int +p_term_subsumer( USES_REGS1 ) /* term_subsumer terms t1 and t2 */ +{ + int out = 0; + + while (out != 1) { + Term t1 = Deref(ARG1); + Term t2 = Deref(ARG2); + CELL *oldH = H; + + if (t1 == t2) + return Yap_unify(ARG3,t1); + if (IsPairTerm(t1) && IsPairTerm(t2)) { + Term tf = AbsAppl(H); + H += 2; + HB = H; + if ((out = term_subsumer_complex(RepPair(t1)-1, + RepPair(t1)+1, + RepPair(t2)-1, H-2 PASS_REGS)) > 0) { + HB = B->cp_h; + return Yap_unify(ARG3,tf); + } + } else if (IsApplTerm(t1) && IsApplTerm(t2)) { + Functor f1; + + if ((f1 = FunctorOfTerm(t1)) == FunctorOfTerm(t2)) { + if (IsExtensionFunctor(f1)) { + if (unify_extension(f1, t1, RepAppl(t1), t2)) { + return Yap_unify(ARG3,t1); + } + } else { + Term tf = AbsAppl(H); + UInt ar = ArityOfFunctor(f1); + H[0] = (CELL)f1; + H += 1+ar; + HB = H; + if ((out = term_subsumer_complex(RepAppl(t1), + RepAppl(t1)+ArityOfFunctor(f1), + RepAppl(t2), H-ar PASS_REGS)) > 0) { + HB = B->cp_h; + return Yap_unify(ARG3,tf); + } + } + } + } + HB = B->cp_h; + if (out == 0) { + return Yap_unify(ARG3, MkVarTerm()); + } else { + H = oldH; + if (out == -1) { + if (!Yap_gcl((ASP-H)*sizeof(CELL), 0, ENV, gc_P(P,CP))) { + Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_subsumer"); + return FALSE; + } + } else { + /* Trail overflow */ + if (!Yap_growtrail(0, FALSE)) { + Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "in term_subsumer"); + return FALSE; + } + } + } + } + return FALSE; +} + #ifdef DEBUG static Int p_force_trail_expansion( USES_REGS1 ) @@ -4875,6 +5180,7 @@ void Yap_InitUtilCPreds(void) Yap_InitCPred("instantiated_term_hash", 4, p_instantiated_term_hash, 0); Yap_InitCPred("variant", 2, p_variant, 0); Yap_InitCPred("subsumes", 2, p_subsumes, 0); + Yap_InitCPred("term_subsumer", 3, p_term_subsumer, 0); Yap_InitCPred("variables_within_term", 3, p_variables_within_term, 0); Yap_InitCPred("new_variables_in_term", 3, p_new_variables_in_term, 0); Yap_InitCPred("export_term", 3, p_export_term, 0); diff --git a/H/TermExt.h b/H/TermExt.h index a30eae80d..ec8c08dd4 100644 --- a/H/TermExt.h +++ b/H/TermExt.h @@ -103,7 +103,7 @@ inline EXTERN blob_type BlobOfFunctor (Functor f); inline EXTERN blob_type BlobOfFunctor (Functor f) { - return (blob_type) (f); + return (blob_type) ((CELL)f); } typedef struct cp_frame { @@ -148,8 +148,8 @@ exts; #endif -#ifdef YAP_H +#ifdef YAP_H /* make sure that these data structures are the first thing to be allocated in the heap when we start the system */ #ifdef THREADS @@ -175,7 +175,9 @@ typedef struct special_functors_struct special_functors; #endif -inline EXTERN Float STD_PROTO (CpFloatUnaligned, (CELL *)); +#endif /* YAP_H */ + +inline extern Float CpFloatUnaligned(CELL *ptr); #if SIZEOF_DOUBLE == SIZEOF_LONG_INT @@ -214,7 +216,7 @@ CpFloatUnaligned(CELL *ptr) #if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT -inline EXTERN void STD_PROTO (AlignGlobalForDouble, ( USES_REGS1 )); +inline extern void AlignGlobalForDouble( USES_REGS1 ); #define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4) @@ -272,13 +274,16 @@ FloatOfTerm (Term t) #endif #endif -Term STD_PROTO (Yap_MkBlobStringTerm, (const char *, size_t len)); -Term STD_PROTO (Yap_MkBlobWideStringTerm, (const wchar_t *, size_t len)); -char *STD_PROTO (Yap_BlobStringOfTerm, (Term)); -wchar_t *STD_PROTO (Yap_BlobWideStringOfTerm, (Term)); -char *STD_PROTO (Yap_BlobStringOfTermAndLength, (Term, size_t *)); +#ifndef YAP_H +#include +#endif + +Term Yap_MkBlobStringTerm(const char *, size_t len); +Term Yap_MkBlobWideStringTerm(const wchar_t *, size_t len); +char *Yap_BlobStringOfTerm(Term); +wchar_t *Yap_BlobWideStringOfTerm(Term); +char *Yap_BlobStringOfTermAndLength(Term, size_t *); -#endif /* YAP_NOT_INSTALLED */ inline EXTERN int IsFloatTerm (Term); @@ -294,7 +299,6 @@ IsFloatTerm (Term t) /* extern Functor FunctorLongInt; */ -#ifdef YAP_H inline EXTERN Term MkLongIntTerm (Int); inline EXTERN Term @@ -308,7 +312,6 @@ MkLongIntTerm (Int i) return AbsAppl(H - 3); } -#endif inline EXTERN Int LongIntOfTerm (Term t); diff --git a/H/Yap.h b/H/Yap.h index 5ccf5903b..768906d2d 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -818,6 +818,12 @@ extern struct worker_local Yap_local; #include "dlocals.h" +/************************************************************************************************* + unification support +*************************************************************************************************/ + +#include "YapCompoundTerm.h" + /************************************************************************************************* unification routines *************************************************************************************************/ @@ -831,69 +837,6 @@ extern struct worker_local Yap_local; -/************************************************************************************************* - High level macros to access arguments -*************************************************************************************************/ - -inline EXTERN Term ArgOfTerm (int i, Term t); - -inline EXTERN Term -ArgOfTerm (int i, Term t) -{ - return (Term) (Derefa (RepAppl (t) + (i))); -} - - - -inline EXTERN Term HeadOfTerm (Term); - -inline EXTERN Term -HeadOfTerm (Term t) -{ - return (Term) (Derefa (RepPair (t))); -} - - - -inline EXTERN Term TailOfTerm (Term); - -inline EXTERN Term -TailOfTerm (Term t) -{ - return (Term) (Derefa (RepPair (t) + 1)); -} - - - - -inline EXTERN Term ArgOfTermCell (int i, Term t); - -inline EXTERN Term -ArgOfTermCell (int i, Term t) -{ - return (Term) ((CELL) (RepAppl (t) + (i))); -} - - - -inline EXTERN Term HeadOfTermCell (Term); - -inline EXTERN Term -HeadOfTermCell (Term t) -{ - return (Term) ((CELL) (RepPair (t))); -} - - - -inline EXTERN Term TailOfTermCell (Term); - -inline EXTERN Term -TailOfTermCell (Term t) -{ - return (Term) ((CELL) (RepPair (t) + 1)); -} - /************************************************************************************************* slots diff --git a/H/YapCompoundTerm.h b/H/YapCompoundTerm.h new file mode 100644 index 000000000..e8b1d3be1 --- /dev/null +++ b/H/YapCompoundTerm.h @@ -0,0 +1,115 @@ +/************************************************************************* +* * +* YAP Prolog %W% %G% * +* Yap Prolog was developed at NCCUP - Universidade do Porto * +* * +* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2012 * +* * +************************************************************************** +* * +* File: YapCompounTerm.h * +* mods: * +* comments: main header file for YAP * +* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ * +*************************************************************************/ + +/************************************************************************************************* + High level macros to access arguments +*************************************************************************************************/ + +#ifndef YAPCOMPOUNDTERM_H + +#define YAPCOMPOUNDTERM_H 1 + +EXTERN Int Yap_unify(Term a,Term b); + +EXTERN inline Term Deref(Term a); + +EXTERN inline Term Deref(Term a) +{ + while(IsVarTerm(a)) { + Term *b = (Term *) a; + a = *b; + if(a==((Term) b)) return a; + } + return(a); +} + +EXTERN inline Term Derefa(CELL *b); + +EXTERN inline Term +Derefa(CELL *b) +{ + Term a = *b; + restart: + if (!IsVarTerm(a)) { + return(a); + } else if (a == (CELL)b) { + return(a); + } else { + b = (CELL *)a; + a = *b; + goto restart; + } +} + +inline EXTERN Term ArgOfTerm (int i, Term t); + +inline EXTERN Term +ArgOfTerm (int i, Term t) +{ + return (Term) (Derefa (RepAppl (t) + (i))); +} + + + +inline EXTERN Term HeadOfTerm (Term); + +inline EXTERN Term +HeadOfTerm (Term t) +{ + return (Term) (Derefa (RepPair (t))); +} + + + +inline EXTERN Term TailOfTerm (Term); + +inline EXTERN Term +TailOfTerm (Term t) +{ + return (Term) (Derefa (RepPair (t) + 1)); +} + + + + +inline EXTERN Term ArgOfTermCell (int i, Term t); + +inline EXTERN Term +ArgOfTermCell (int i, Term t) +{ + return (Term) ((CELL) (RepAppl (t) + (i))); +} + + + +inline EXTERN Term HeadOfTermCell (Term); + +inline EXTERN Term +HeadOfTermCell (Term t) +{ + return (Term) ((CELL) (RepPair (t))); +} + + + +inline EXTERN Term TailOfTermCell (Term); + +inline EXTERN Term +TailOfTermCell (Term t) +{ + return (Term) ((CELL) (RepPair (t) + 1)); +} + +#endif /* YAPCOMPOUNDTERM_H */ diff --git a/H/YapTags.h b/H/YapTags.h index 3de5c6c25..f43d1e4e4 100644 --- a/H/YapTags.h +++ b/H/YapTags.h @@ -184,8 +184,6 @@ IsUnboundVar (Term * t) #else -#ifdef YAP_H - inline EXTERN Term MkVarTerm__ ( USES_REGS1 ); inline EXTERN Term @@ -194,8 +192,6 @@ MkVarTerm__ ( USES_REGS1 ) return (Term) ((*H = (CELL) H, H++)); } -#endif - inline EXTERN int IsUnboundVar (Term *); @@ -316,8 +312,7 @@ IsIntTerm (Term t) } -#ifdef YAP_H -EXTERN inline Term STD_PROTO (MkPairTerm__, (Term, Term CACHE_TYPE) ); +EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS ); EXTERN inline Term MkPairTerm__ (Term head, Term tail USES_REGS) @@ -330,7 +325,6 @@ MkPairTerm__ (Term head, Term tail USES_REGS) return (AbsPair (p)); } -#endif /* Needed to handle numbers: @@ -395,4 +389,6 @@ IntegerOfTerm (Term t) return (Int) (IsIntTerm (t) ? IntOfTerm (t) : LongIntOfTerm (t)); } +#ifndef YAP_H +#endif diff --git a/H/YapTerm.h b/H/YapTerm.h index 40f9a04f0..d9e7f1fb5 100644 --- a/H/YapTerm.h +++ b/H/YapTerm.h @@ -18,6 +18,7 @@ typedef void *Functor; typedef void *Atom; + #endif #ifndef EXTERN @@ -134,3 +135,4 @@ typedef unsigned long int YAP_ULONG_LONG; #define Unsigned(V) ((CELL) (V)) #define Signed(V) ((Int) (V)) + diff --git a/H/amiops.h b/H/amiops.h index f6a8e62de..0b14c43e5 100644 --- a/H/amiops.h +++ b/H/amiops.h @@ -87,35 +87,6 @@ Dereferencing macros #endif /* UNIQUE_TAG_FOR_PAIRS */ -EXTERN Term STD_PROTO(Deref,(Term)); -EXTERN Term STD_PROTO(Derefa,(CELL *)); - -EXTERN inline Term Deref(Term a) -{ - while(IsVarTerm(a)) { - Term *b = (Term *) a; - a = *b; - if(a==((Term) b)) return a; - } - return(a); -} - -EXTERN inline Term -Derefa(CELL *b) -{ - Term a = *b; - restart: - if (!IsVarTerm(a)) { - return(a); - } else if (a == (CELL)b) { - return(a); - } else { - b = (CELL *)a; - a = *b; - goto restart; - } -} - /************************************************************ TRAIL VARIABLE @@ -309,8 +280,6 @@ Unification Routines *************************************************************/ -EXTERN Int STD_PROTO(Yap_unify,(Term,Term)); - inline EXTERN void STD_PROTO(reset_trail,(tr_fr_ptr)); inline EXTERN void diff --git a/Makefile.in b/Makefile.in index a15e19674..0866f07a6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -122,8 +122,9 @@ INTERFACE_HEADERS = \ $(srcdir)/H/Tags_32LowTag.h \ $(srcdir)/H/Tags_64bits.h \ $(srcdir)/H/Tags_24bits.h \ - $(srcdir)/H/YapTerm.h \ + $(srcdir)/H/YapCompoundTerm.h \ $(srcdir)/include/YapRegs.h \ + $(srcdir)/H/YapTerm.h \ $(srcdir)/library/dialect/bprolog/fli/bprolog.h \ $(srcdir)/os/SWI-Stream.h @@ -409,7 +410,9 @@ all: parms.h startup.yss @ENABLE_WINCONSOLE@ pl-yap@EXEC_SUFFIX@ Makefile: $(srcdir)/Makefile.in -$(srcdir)/H/Yap.h: config.h YapTermConfig.h $(srcdir)/H/YapTags.h +$(srcdir)/H/Yap.h: config.h YapTermConfig.h \ + $(srcdir)/H/YapTags.h \ + $(srcdir)/H/YapCompoundTerm.h config.h: parms.h diff --git a/config.h.in b/config.h.in index 388312e6c..0cce26ee2 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,8 @@ +#ifndef YAP_CONFIG_H + +#define YAP_CONFIG_H + #include "parms.h" /* are dynamic arrays supported? */ @@ -347,5 +351,4 @@ #undef MAX_THREADS - - +#endif /* YAP_CONFIG_H */ \ No newline at end of file diff --git a/configure b/configure index f9bdcca15..82307a5a2 100755 --- a/configure +++ b/configure @@ -4998,6 +4998,45 @@ else INSTALL_MATLAB="" fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +my_save_cxxflags="$CXXFLAGS" +CXXFLAGS=-std=c++0x +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether CXX supports -std-c++0x" >&5 +$as_echo_n "checking whether CXX supports -std-c++0x... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + yap_cv_clpbn_bp=yes +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS="$my_save_cflags" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$yap_cv_clpbn_bp" = no then ENABLE_CLPBN_BP="@# " diff --git a/configure.in b/configure.in index 81732e741..7c2f89f18 100755 --- a/configure.in +++ b/configure.in @@ -501,6 +501,18 @@ else INSTALL_MATLAB="" fi +AC_LANG_PUSH([C++]) +my_save_cxxflags="$CXXFLAGS" +CXXFLAGS=-std=c++0x +AC_MSG_CHECKING([whether CXX supports -std-c++0x]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [yap_cv_clpbn_bp=yes], + [AC_MSG_RESULT([no])] +) +CXXFLAGS="$my_save_cflags" +AC_LANG_POP() + if test "$yap_cv_clpbn_bp" = no then ENABLE_CLPBN_BP="@# " diff --git a/docs/yap.tex b/docs/yap.tex index a97070270..ada1ed178 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -3430,6 +3430,15 @@ Same as @code{variant/2}, succeeds if @var{Term1} and @var{Term2} are variant te Succeed if @var{Submuser} subsumes @var{Subsuned} but does not bind any variable in @var{Subsumer}. +@item term_subsumer(?@var{T1}, ?@var{T2}, ?@var{Subsumer}) +@findex term_subsumer/2 +@syindex term_subsumer/2 +@cnindex term_subsumer/2 + +Succeed if @var{Subsumer} unifies with the least general +generalization over @var{T1} and +@var{T2}. + @item acyclic_term(?@var{Term}) @findex cyclic_term/1 @syindex cyclic_term/1 diff --git a/library/terms.yap b/library/terms.yap index 0fc3ef41b..5f2237056 100644 --- a/library/terms.yap +++ b/library/terms.yap @@ -18,6 +18,7 @@ :- module(terms, [ term_hash/2, term_hash/4, + term_subsumer/3, instantiated_term_hash/4, variant/2, unifiable/3, diff --git a/packages/prism/src/c/core/bpx.h b/packages/prism/src/c/core/bpx.h index f15f36704..5b128ea10 100644 --- a/packages/prism/src/c/core/bpx.h +++ b/packages/prism/src/c/core/bpx.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include typedef void *SYM_REC_PTR; diff --git a/pl/flags.yap b/pl/flags.yap index f2dc8c251..da0ed4b14 100644 --- a/pl/flags.yap +++ b/pl/flags.yap @@ -617,7 +617,7 @@ yap_flag(system_options,X) :- '$system_options'(readline) :- '$swi_current_prolog_flag'(readline, true). '$system_options'(tabling) :- - \+ '$undefined'('$c_table'(_,_), prolog). + \+ '$undefined'('$c_table'(_,_,_), prolog). '$system_options'(threads) :- \+ '$no_threads'. '$system_options'(wam_profiler) :-