*** empty log message ***

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1298 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
rslopes 2005-05-27 22:27:59 +00:00
parent 6dbf25e54c
commit f9dd4ebdf7
11 changed files with 4965 additions and 49 deletions

114
H/Atoms.h Normal file
View File

@ -0,0 +1,114 @@
/*************************************************************************
* *
* YAP Prolog %W% %G%
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Atoms.h.m4 *
* Last rev: 19/2/88 *
* mods: *
* comments: atom properties header file for YAP *
* *
*************************************************************************/
#undef EXTERN
#ifndef ADTDEFS_C
#define EXTERN static
#else
#define EXTERN
#endif
/********* operations for atoms ****************************************/
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
associated with them a struct of type AtomEntry
The two functions
RepAtom : Atom -> *AtomEntry
AbsAtom : *AtomEntry -> Atom
are used to encapsulate the implementation of atoms
*/
typedef struct AtomEntryStruct *Atom;
typedef struct PropEntryStruct *Prop;
/* I can only define the structure after I define the actual atoms */
/* atom structure */
typedef struct AtomEntryStruct
{
Atom NextOfAE; /* used to build hash chains */
Prop PropsOfAE; /* property list for this atom */
#if defined(YAPOR) || defined(THREADS)
rwlock_t ARWLock;
#endif
char StrOfAE[MIN_ARRAY]; /* representation of atom as a string */
}
AtomEntry;
/* Props and Atoms are stored in chains, ending with a NIL */
#if USE_OFFSETS
# define EndOfPAEntr(P) ( Addr(P) == AtomBase)
#else
# define EndOfPAEntr(P) ( Addr(P) == NIL )
#endif
#define AtomName(at) RepAtom(at)->StrOfAE
/* ********************** Properties **********************************/
#if USE_OFFSETS
#define USE_OFFSETS_IN_PROPS 1
#else
#define USE_OFFSETS_IN_PROPS 0
#endif
typedef SFLAGS PropFlags;
/* basic property entry structure */
typedef struct PropEntryStruct
{
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
} PropEntry;
/* ************************* Functors **********************************/
/* Functor data type
abstype Functor = atom # int
with MkFunctor(a,n) = ...
and NameOfFunctor(f) = ...
and ArityOfFunctor(f) = ... */
#define MaxArity 255
#define FunctorProperty ((PropFlags)(0xbb00))
/* functor property */
typedef struct FunctorEntryStruct
{
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS)
rwlock_t FRWLock;
#endif
} FunctorEntry;
typedef FunctorEntry *Functor;

188
H/Tags_24bits.h Normal file
View File

@ -0,0 +1,188 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_24bits.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Tag Scheme for machines with 24 bits adresses (m68000) *
* version: $Id: Tags_24bits.h,v 1.1 2005-05-27 22:27:06 rslopes Exp $ *
*************************************************************************/
/* Version for 24 bit addresses (68000)
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1000 numeric value
floats 1m1001 floating point value
pairs 1mr10. ptr to pair
aplied functor 1mr01. ptr to functor followed by args
ref 0mr000 address of cell
undefined 0mr000 pointing to itself
*/
#define AllTagBits 0xfc000000L
#define TagBits 0xbc000000L
#define MaskAdr 0x03ffffffL
#define AdrHiBit 0x02000000L
#define NumberTag 0xa0000000L
#define FloatTag 0xa4000000L
#define AtomTag 0x84000000L
#define PairTag 0x90000000L
#define ApplTag 0x88000000L
#define RefTag 0x80000000L
#define MaskBits 6
#define PairBit 0x10000000L
#define ApplBit 0x08000000L
#define CompBits 0x18000000L
#define NumberMask 0xb8000000L
#define MAX_ABS_INT /* 0xfe00000LL */ ((((UInt)(1<<7))-1) << SHIFT_HIGH_TAG)
#define TagOf(X) (Unsigned(X) & TagBits)
#define NonTagPart(X) (Signed(X) & MaskAdr)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V))
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0x00000000L
inline EXTERN int IsVarTerm (Term);
inline EXTERN int
IsVarTerm (Term t)
{
return (int) (Signed (t) >= 0);
}
inline EXTERN int IsNonVarTerm (Term);
inline EXTERN int
IsNonVarTerm (Term t)
{
return (int) (Signed (t) < 0);
}
inline EXTERN Term *RepPair (Term);
inline EXTERN Term *
RepPair (Term t)
{
return (Term *) (NonTagPart (t));
}
inline EXTERN Term AbsPair (Term *);
inline EXTERN Term
AbsPair (Term * p)
{
return (Term) (TAGGEDA (PairTag, (p)));
}
inline EXTERN Int IsPairTerm (Term);
inline EXTERN Int
IsPairTerm (Term t)
{
return (Int) (BitOn (PairBit, (t)));
}
inline EXTERN Term *RepAppl (Term);
inline EXTERN Term *
RepAppl (Term t)
{
return (Term *) (NonTagPart (t));
}
inline EXTERN Term AbsAppl (Term *);
inline EXTERN Term
AbsAppl (Term * p)
{
return (Term) (TAGGEDA (ApplTag, (p)));
}
inline EXTERN Int IsApplTerm (Term);
inline EXTERN Int
IsApplTerm (Term t)
{
return (Int) (BitOn (ApplBit, (t)));
}
inline EXTERN Int IsAtomOrIntTerm (Term);
inline EXTERN Int
IsAtomOrIntTerm (Term t)
{
return (Int) (!(Unsigned (t) & CompBits));
}
inline EXTERN Term AdjustPtr (Term t, Term off);
inline EXTERN Term
AdjustPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
inline EXTERN Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
static inline Int
IntOfTerm (Term t)
{
Int n;
n = (Unsigned (t) & MaskPrim) >> 2;
if (Unsigned (t) & AdrHiBit)
n |= 0xfc000000;
return (n);
}

204
H/Tags_32LowTag.h Normal file
View File

@ -0,0 +1,204 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32LowTag.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32LowTag.h,v 1.1 2005-05-27 22:27:06 rslopes Exp $ *
*************************************************************************/
#define TAG_LOW_BITS_32 1
/* Version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints m.....110 numeric value
atoms m.....010 offset of atom entry
pairs mr.....11 ptr to pair
aplied functor mr.....01 ptr to functor followed by args
ref mr.....00 address of cell
undefined mr.....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
*/
#define SHIFT_LOW_TAG 2
#define SHIFT_HIGH_TAG 2
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0x00000007L */ MKTAG(0x1,3)
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
#define LowBit /* 0x00000001L */ MKTAG(0x0,1)
#define HighTagBits /* 0x0000000cL */ MKTAG(0x1,0)
#define NumberTag /* 0x0000000dL */ MKTAG(0x1,2)
#define AtomTag /* 0x00000006L */ MKTAG(0x0,2)
/*
subtract the total for tag bits, plus 1 bit for GC, plus another
for sign
*/
#define MAX_ABS_INT ((Int)0x04000000L)
/*
UNIQUE_TAG_FOR_PAIR gives the representation for pair an
unique tag
This allows optimisation of switch_list
*/
#define UNIQUE_TAG_FOR_PAIRS 1
#define PairBits /* 0x00000003L */ MKTAG(0x0,3)
#define ApplBit /* 0x00000001L */ MKTAG(0x0,1)
#define PrimiBits /* 0x00000002L */ MKTAG(0x0,2)
#define NumberBits /* 0x0000000aL */ MKTAG(0x2,2)
#define NumberMask /* 0x0000000bL */ MKTAG(0x2,3)
#define TagOf(V) (Unsigned(V) & LowTagBits)
#define NonTagPart(V) ((Unsigned(V)>>1) & ~LowTagBits)
#define TAGGED(TAG,V) (((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)|(TAG))
#define NONTAGGED(TAG,V) ((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)
#define TAGGEDA(TAG,V) ((Unsigned(V) << 1)|(TAG))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xc0000000L
inline EXTERN int IsVarTerm (Term);
inline EXTERN int
IsVarTerm (Term t)
{
return (int) (!((t) & LowTagBits));
}
inline EXTERN int IsNonVarTerm (Term);
inline EXTERN int
IsNonVarTerm (Term t)
{
return (int) (((t) & LowTagBits));
}
inline EXTERN Term *RepPair (Term);
inline EXTERN Term *
RepPair (Term t)
{
return (Term *) ((t) - PairBits);
}
inline EXTERN Term AbsPair (Term *);
inline EXTERN Term
AbsPair (Term * p)
{
return (Term) (Unsigned (p) + PairBits);
}
inline EXTERN Int IsPairTerm (Term);
inline EXTERN Int
IsPairTerm (Term t)
{
return (Int) ((((t) & LowTagBits) == PairBits));
}
inline EXTERN Term *RepAppl (Term);
inline EXTERN Term *
RepAppl (Term t)
{
return (Term *) (((t) - ApplBit));
}
inline EXTERN Term AbsAppl (Term *);
inline EXTERN Term
AbsAppl (Term * p)
{
return (Term) (Unsigned (p) + ApplBit);
}
inline EXTERN Int IsApplTerm (Term);
inline EXTERN Int
IsApplTerm (Term t)
{
return (Int) ((((t) & LowTagBits) == ApplBit));
}
inline EXTERN Int IsAtomOrIntTerm (Term);
inline EXTERN Int
IsAtomOrIntTerm (Term t)
{
return (Int) ((((t) & LowTagBits) == 2));
}
inline EXTERN Term AdjustPtr (Term t, Term off);
inline EXTERN Term
AdjustPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
inline EXTERN Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
inline EXTERN Int IntOfTerm (Term);
inline EXTERN Int
IntOfTerm (Term t)
{
return (Int) (((Int) (t << 1)) >> (SHIFT_LOW_TAG + SHIFT_HIGH_TAG + 1));
}

320
H/Tags_32Ops.h Normal file
View File

@ -0,0 +1,320 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32Ops.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32Ops.h,v 1.1 2005-05-27 22:27:06 rslopes Exp $ *
*************************************************************************/
/*
Version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1....01 numeric value
atoms 1m0....01 offset of atom entry
pairs 1mr....11 ptr to pair
aplied functor 1mr....00 ptr to functor followed by args
undefined 0mr....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
This version speeds up access to lists and to compound
terms by using the XOR and NOT operations to build their tags. This
saves operations on RISC machines.
As a further optimisation, only pairs or compound terms have
the second lowest bit set. This allows one to recognise lists or
compound terms with a single operation.
The main problem is that the default value of the M and R bits for GC
are now 1 in compound terms and structures.
*/
#define TAGS_FAST_OPS 1
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0xb0000003L */ MKTAG(0x5,3)
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
#define LowBit /* 0x00000001L */ MKTAG(0x0,1)
#define HighTagBits /* 0xf0000000L */ MKTAG(0x7,0)
#define AdrHiBit /* 0x08000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
#define MaskAdr /* 0x1ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
#define MaskPrim /* 0x0ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
#define NumberTag /* 0xb0000001L */ MKTAG(0x5,2)
#define AtomTag /* 0x90000001L */ MKTAG(0x4,2)
#define MAX_ABS_INT /* 0xfe00000LL */ ((Int)0x04000000L)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xe0000000L
#define MaskBits 4
/*
UNIQUE_TAG_FOR_PAIR gives the representation for pair an
unique tag
This allows optimisation of switch_list
*/
#if defined(i386) || defined(sparc) || defined(_POWER) || defined(__sparc)
#define UNIQUE_TAG_FOR_PAIRS 1
#endif
#if UNIQUE_TAG_FOR_PAIRS
#define PairBit /* 0x00000001L */ 1
#define ApplBit /* 0x00000000L */ 0
#else
#define PairBit /* 0x00000000L */ 0
#define ApplBit /* 0x00000001L */ 1
#endif
#define TagOf(t) (Unsigned(t)&TagBits)
#define NonTagPart(X) (Signed(X) & MaskPrim)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* never forget to surround arguments to a macro by brackets */
inline EXTERN int IsVarTerm (Term);
inline EXTERN int
IsVarTerm (Term t)
{
return (int) (Signed (t) >= 0);
}
inline EXTERN int IsNonVarTerm (Term);
inline EXTERN int
IsNonVarTerm (Term t)
{
return (int) (Signed (t) < 0);
}
#if UNIQUE_TAG_FOR_PAIRS
inline EXTERN Term *RepPair (Term);
inline EXTERN Term *
RepPair (Term t)
{
return (Term *) ((~(t)));
}
inline EXTERN Term AbsPair (Term *);
inline EXTERN Term
AbsPair (Term * p)
{
return (Term) ((~Unsigned (p)));
}
inline EXTERN Int IsPairTerm (Term);
inline EXTERN Int
IsPairTerm (Term t)
{
return (Int) (((t) & PairBit));
}
inline EXTERN Term *RepAppl (Term);
inline EXTERN Term *
RepAppl (Term t)
{
return (Term *) ((-Signed (t)));
}
inline EXTERN Term AbsAppl (Term *);
inline EXTERN Term
AbsAppl (Term * p)
{
return (Term) ((-Signed (p)));
}
inline EXTERN Int IsApplTerm (Term);
inline EXTERN Int
IsApplTerm (Term t)
{
return (Int) ((!((t) & LowTagBits)));
}
#else
inline EXTERN Term *RepPair (Term);
inline EXTERN Term *
RepPair (Term t)
{
return (Term *) ((-Signed (t)));
}
inline EXTERN Term AbsPair (Term *);
inline EXTERN Term
AbsPair (Term * p)
{
return (Term) (((CELL) (-Signed (p))));
}
inline EXTERN Int IsPairTerm (Term);
inline EXTERN Int
IsPairTerm (Term t)
{
return (Int) ((!((t) & LowTagBits)));
}
inline EXTERN Term *RepAppl (Term);
inline EXTERN Term *
RepAppl (Term t)
{
return (Term *) ((~(t)));
}
inline EXTERN Term AbsAppl (Term *);
inline EXTERN Term
AbsAppl (Term * p)
{
return (Term) ((~Unsigned (p)));
}
inline EXTERN Int IsApplTerm (Term);
inline EXTERN Int
IsApplTerm (Term t)
{
return (Int) (((t) & ApplBit));
}
#endif
inline EXTERN Int IsAtomOrIntTerm (Term);
inline EXTERN Int
IsAtomOrIntTerm (Term t)
{
return (Int) (((Unsigned (t) & LowTagBits) == 0x2));
}
inline EXTERN Int IntOfTerm (Term);
inline EXTERN Int
IntOfTerm (Term t)
{
return (Int) ((Int) (Unsigned (t) << 3) >> 5);
}
#if UNIQUE_TAG_FOR_PAIRS
inline EXTERN Term AdjustPtr (Term t, Term off);
inline EXTERN Term
AdjustPtr (Term t, Term off)
{
return (Term) (((IsVarTerm (t)
|| IsAtomOrIntTerm (t)) ? (t) +
(off) : (IsPairTerm (t) ? (CELL)
AbsPair ((CELL *) ((CELL) RepPair (t) +
(off))) : (t) - (off))));
}
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
inline EXTERN Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) (IsVarTerm (t) ? (t) + (off) : (t) - (off));
}
#else
inline EXTERN Term AdjustPtr (Term t, Term off);
inline EXTERN Term
AdjustPtr (Term t, Term off)
{
return (Term) (((IsVarTerm (t)
|| IsAtomOrIntTerm (t)) ? (t) +
(off) : (IsApplTerm (t) ? (CELL)
AbsAppl ((CELL *) ((CELL) RepAppl (t) +
(off))) : (t) - (off))));
}
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
inline EXTERN Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) (IsVarTerm (t) ? (t) +
(off) : (IsApplTerm (t) ? (CELL)
AbsAppl ((CELL *) ((CELL) RepAppl (t) +
(off))) : (t) - (off)));
}
#endif

190
H/Tags_32bits.h Normal file
View File

@ -0,0 +1,190 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32bits.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32bits.h,v 1.1 2005-05-27 22:27:06 rslopes Exp $ *
*************************************************************************/
/* Original version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1....00 numeric value
atoms 1m0....00 offset of atom entry
pairs 1mr....01 ptr to pair
aplied functor 1mr....10 ptr to functor followed by args
ref 0mr....00 address of cell
undefined 0mr....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
*/
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0xe0000003L */ MKTAG(0x7,3)
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
#define HighTagBits /* 0xe0000000L */ MKTAG(0x7,0)
#define AdrHiBit /* 0x10000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
#define MaskAdr /* 0x1ffffffcL */ ((((UInt)1) << SHIFT_HIGH_TAG)-4)
#define MaskPrim /* 0x0ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
#define NumberTag /* 0xa0000000L */ MKTAG(0x5,0)
#define AtomTag /* 0x80000000L */ MKTAG(0x4,0)
#define PairTag /* 0x80000001L */ MKTAG(0x4,1)
#define ApplTag /* 0x80000002L */ MKTAG(0x4,2)
#define MAX_ABS_INT /* 0x04000000L */ (1 << (SHIFT_HIGH_TAG-3))
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xe0000000L
#define MaskBits 4
#define PairBit /* 0x00000001L */ 1
#define ApplBit /* 0x00000002L */ 2
#define NonTagPart(X) (Signed(X) & MaskPrim)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
inline EXTERN int IsVarTerm (Term);
inline EXTERN int
IsVarTerm (Term t)
{
return (int) (Signed (t) >= 0);
}
inline EXTERN int IsNonVarTerm (Term);
inline EXTERN int
IsNonVarTerm (Term t)
{
return (int) (Signed (t) < 0);
}
inline EXTERN Term *RepPair (Term);
inline EXTERN Term *
RepPair (Term t)
{
return (Term *) (NonTagPart (t));
}
inline EXTERN Term AbsPair (Term *);
inline EXTERN Term
AbsPair (Term * p)
{
return (Term) (TAGGEDA (PairTag, (p)));
}
inline EXTERN Int IsPairTerm (Term);
inline EXTERN Int
IsPairTerm (Term t)
{
return (Int) (BitOn (PairBit, (t)));
}
inline EXTERN Term *RepAppl (Term);
inline EXTERN Term *
RepAppl (Term t)
{
return (Term *) (NonTagPart (t));
}
inline EXTERN Term AbsAppl (Term *);
inline EXTERN Term
AbsAppl (Term * p)
{
return (Term) (TAGGEDA (ApplTag, (p)));
}
inline EXTERN Int IsApplTerm (Term);
inline EXTERN Int
IsApplTerm (Term t)
{
return (Int) (BitOn (ApplBit, (t)));
}
inline EXTERN int IsAtomOrIntTerm (Term);
inline EXTERN int
IsAtomOrIntTerm (Term t)
{
return (int) (((Unsigned (t) & LowTagBits) == 0));
}
inline EXTERN Term AdjustPtr (Term t, Term off);
inline EXTERN Term
AdjustPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
inline EXTERN Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
inline EXTERN Int IntOfTerm (Term);
inline EXTERN Int
IntOfTerm (Term t)
{
return (Int) (((Int) (t << 3)) >> (3 + 2));
}

193
H/Tags_64bits.h Normal file
View File

@ -0,0 +1,193 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32Ops.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_64bits.h,v 1.1 2005-05-27 22:27:06 rslopes Exp $ *
*************************************************************************/
#define TAG_64BITS 1
/* Version for 64 bit addresses machines,
Each term is represented internally as an unsigned 64 bit integer as
follows:
tag value
ints 0m1....001 numeric value
atoms 0m0....001 offset of atom entry
pairs 0mr....011 ptr to pair
aplied functor 0mr....101 ptr to functor followed by args
undefined 0mr....000 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
We rely on the fact that addresses are always multiple of 8.
*/
#define SHIFT_HIGH_TAG 62
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0x30000007L */ MKTAG(0x1,7)
#define LowTagBits /* 0x00000007L */ MKTAG(0x0,7)
#define HighTagBits /* 0x70000000L */ MKTAG(0x1,0)
#define AdrHiBit /* 0x08000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
#define MaskPrim /* 0x0ffffff8L */ ((((UInt)1) << (SHIFT_HIGH_TAG))-8)
#define NumberTag /* 0x30000001L */ MKTAG(0x1,1)
#define AtomTag /* 0x10000001L */ MKTAG(0x0,1)
#define MAX_ABS_INT /* 0xfe00000LL */ (((Int)1) << (63-(2+4)))
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xe000000000000000L
#define UNIQUE_TAG_FOR_PAIRS 1
#define PrimiBit /* 0x00000001L */ 1
#define PairBits /* 0x00000003L */ 3
#define ApplBits /* 0x00000005L */ 5
#define PrimiBits /* 0x70000004L */ MKTAG(0x7,7)
#define NumberMask /* 0x20000007L */ MKTAG(0x2,7)
#define TagOf(t) (Unsigned(t)&TagBits)
#define NonTagPart(X) (Signed(X) & MaskPrim)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<3)) /* SQRT(8) */
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<3) /* SQRT(8) */
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
inline EXTERN int IsVarTerm (Term);
inline EXTERN int
IsVarTerm (Term t)
{
return (int) ((!((t) & 0x1)));
}
inline EXTERN int IsNonVarTerm (Term);
inline EXTERN int
IsNonVarTerm (Term t)
{
return (int) (((t) & 0x1));
}
inline EXTERN Term *RepPair (Term);
inline EXTERN Term *
RepPair (Term t)
{
return (Term *) (((t) - PairBits));
}
inline EXTERN Term AbsPair (Term *);
inline EXTERN Term
AbsPair (Term * p)
{
return (Term) (((CELL) (p) + PairBits));
}
inline EXTERN Int IsPairTerm (Term);
inline EXTERN Int
IsPairTerm (Term t)
{
return (Int) (((t) & 0x2));
}
inline EXTERN Term *RepAppl (Term);
inline EXTERN Term *
RepAppl (Term t)
{
return (Term *) (((t) - ApplBits));
}
inline EXTERN Term AbsAppl (Term *);
inline EXTERN Term
AbsAppl (Term * p)
{
return (Term) (((CELL) (p) + ApplBits));
}
inline EXTERN Int IsApplTerm (Term);
inline EXTERN Int
IsApplTerm (Term t)
{
return (Int) ((((t) & 0x4)));
}
inline EXTERN Int IsAtomOrIntTerm (Term);
inline EXTERN Int
IsAtomOrIntTerm (Term t)
{
return (Int) ((((t) & LowTagBits) == 0x1));
}
inline EXTERN Term AdjustPtr (Term t, Term off);
inline EXTERN Term
AdjustPtr (Term t, Term off)
{
return (Term) (((t) + off));
}
inline EXTERN Term AdjustIDBPtr (Term t, Term off);
inline EXTERN Term
AdjustIDBPtr (Term t, Term off)
{
return (Term) ((t) + off);
}
inline EXTERN Int IntOfTerm (Term);
inline EXTERN Int
IntOfTerm (Term t)
{
return (Int) ((Int) (Unsigned (t) << 3) >> 6);
}

558
H/TermExt.h Normal file
View File

@ -0,0 +1,558 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: TermExt.h *
* mods: *
* comments: Extensions to standard terms for YAP *
* version: $Id: TermExt.h,v 1.1 2005-05-27 22:27:06 rslopes Exp $ *
*************************************************************************/
#ifdef USE_SYSTEM_MALLOC
#define SF_STORE (&(Yap_heap_regs->funcs))
#else
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
#endif
#if USE_OFFSETS
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
#else
#define AtomFoundVar AbsAtom(&(SF_STORE->AtFoundVar))
#define AtomNil AbsAtom(&(SF_STORE->AtNil))
#define AtomDot AbsAtom(&(SF_STORE->AtDot))
#endif
#define TermFoundVar MkAtomTerm(AtomFoundVar)
#define TermNil MkAtomTerm(AtomNil)
#define TermDot MkAtomTerm(AtomDot)
#if defined(IN_SECOND_QUADRANT) && !GC_NO_TAGS
typedef enum
{
db_ref_e = sizeof (Functor *) | RBIT,
long_int_e = 2 * sizeof (Functor *) | RBIT,
#ifdef USE_GMP
big_int_e = 3 * sizeof (Functor *) | RBIT,
double_e = 4 * sizeof (Functor *) | RBIT
#else
double_e = 3 * sizeof (Functor *) | RBIT
#endif
}
blob_type;
#else
typedef enum
{
db_ref_e = sizeof (Functor *),
long_int_e = 2 * sizeof (Functor *),
#ifdef USE_GMP
big_int_e = 3 * sizeof (Functor *),
double_e = 4 * sizeof (Functor *)
#else
double_e = 3 * sizeof (Functor *)
#endif
}
blob_type;
#endif
#define FunctorDBRef ((Functor)(db_ref_e))
#define FunctorLongInt ((Functor)(long_int_e))
#ifdef USE_GMP
#define FunctorBigInt ((Functor)(big_int_e))
#endif
#define FunctorDouble ((Functor)(double_e))
#define EndSpecials (double_e)
inline EXTERN blob_type BlobOfFunctor (Functor f);
inline EXTERN blob_type
BlobOfFunctor (Functor f)
{
return (blob_type) ((CELL) f);
}
#ifdef COROUTINING
typedef struct
{
/* what to do when someone tries to bind our term to someone else
in some predefined context */
void (*bind_op) (Term *, Term);
/* what to do if someone wants to copy our constraint */
int (*copy_term_op) (CELL *, CELL ***, CELL *);
/* copy the constraint into a term and back */
Term (*to_term_op) (CELL *);
int (*term_to_op) (Term, Term);
/* op called to do marking in GC */
void (*mark_op) (CELL *);
} ext_op;
/* known delays */
typedef enum
{
empty_ext = 0 * sizeof (ext_op), /* default op, this should never be called */
attvars_ext = 1 * sizeof (ext_op) /* support for attributed variables */
/* add your own extensions here */
/* keep this one */
}
exts;
/* array with the ops for your favourite extensions */
extern ext_op attas[attvars_ext + 1];
#endif
/* make sure that these data structures are the first thing to be allocated
in the heap when we start the system */
typedef struct special_functors_struct
{
AtomEntry AtFoundVar;
char AtFoundVarChars[8];
AtomEntry AtNil;
char AtNilChars[8];
AtomEntry AtDot;
char AtDotChars[8];
}
special_functors;
#if USE_SYSTEM_MALLOC
#define MAX_SPECIALS_TAG (4*4096)
#else
#define MAX_SPECIALS_TAG ((CELL)AtomBase)
#endif
#if SIZEOF_DOUBLE == SIZEOF_LONG_INT
#if GC_NO_TAGS
inline EXTERN Term MkFloatTerm (Float);
inline EXTERN Term
MkFloatTerm (Float dbl)
{
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
dbl, H[2] = (2 * sizeof (CELL) + EndSpecials), H +=
3, AbsAppl (H - 3)));
}
#else
inline EXTERN Term MkFloatTerm (Float);
inline EXTERN Term
MkFloatTerm (Float dbl)
{
return (Term) ((H[0] = (CELL) FunctorDouble, *(Float *) (H + 1) =
dbl, H[2] = ((2 * sizeof (CELL) + EndSpecials) | MBIT), H +=
3, AbsAppl (H - 3)));
}
#endif
inline EXTERN Float FloatOfTerm (Term t);
inline EXTERN Float
FloatOfTerm (Term t)
{
return (Float) (*(Float *) (RepAppl (t) + 1));
}
#define InitUnalignedFloat()
#else
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
inline EXTERN Float STD_PROTO (CpFloatUnaligned, (CELL *));
inline EXTERN void STD_PROTO (AlignGlobalForDouble, (void));
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4)
#ifdef i386
inline EXTERN Float
CpFloatUnaligned (CELL * ptr)
{
return *((Float *) (ptr + 1));
}
#else
/* first, need to address the alignment problem */
inline EXTERN Float
CpFloatUnaligned (CELL * ptr)
{
union
{
Float f;
CELL d[2];
} u;
u.d[0] = ptr[1];
u.d[1] = ptr[2];
return (u.f);
}
#endif
#if GC_NO_TAGS
inline EXTERN Term MkFloatTerm (Float);
inline EXTERN Term
MkFloatTerm (Float dbl)
{
return (Term) ((AlignGlobalForDouble (), H[0] =
(CELL) FunctorDouble, *(Float *) (H + 1) = dbl, H[3] =
(3 * sizeof (CELL) + EndSpecials), H +=
4, AbsAppl (H - 4)));
}
#else
inline EXTERN Term MkFloatTerm (Float);
inline EXTERN Term
MkFloatTerm (Float dbl)
{
return (Term) ((AlignGlobalForDouble (), H[0] =
(CELL) FunctorDouble, *(Float *) (H + 1) = dbl, H[3] =
((3 * sizeof (CELL) + EndSpecials) | MBIT), H +=
4, AbsAppl (H - 4)));
}
#endif
inline EXTERN Float FloatOfTerm (Term t);
inline EXTERN Float
FloatOfTerm (Term t)
{
return (Float) ((DOUBLE_ALIGNED (RepAppl (t)) ? *(Float *) (RepAppl (t) + 1)
: CpFloatUnaligned (RepAppl (t))));
}
/* no alignment problems for 64 bit machines */
#else
/* OOPS, YAP only understands Floats that are as large as cells or that
take two cells!!! */
#endif
#endif
inline EXTERN int IsFloatTerm (Term);
inline EXTERN int
IsFloatTerm (Term t)
{
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorDouble);
}
/* extern Functor FunctorLongInt; */
#if GC_NO_TAGS
inline EXTERN Term MkLongIntTerm (Int);
inline EXTERN Term
MkLongIntTerm (Int i)
{
return (Term) ((H[0] = (CELL) FunctorLongInt, H[1] = (CELL) (i), H[2] =
(2 * sizeof (CELL) + EndSpecials), H +=
3, AbsAppl (H - 3)));
}
#else
inline EXTERN Term MkLongIntTerm (Int);
inline EXTERN Term
MkLongIntTerm (Int i)
{
return (Term) ((H[0] = (CELL) FunctorLongInt, H[1] = (CELL) (i), H[2] =
((2 * sizeof (CELL) + EndSpecials) | MBIT), H +=
3, AbsAppl (H - 3)));
}
#endif
inline EXTERN Int LongIntOfTerm (Term t);
inline EXTERN Int
LongIntOfTerm (Term t)
{
return (Int) (RepAppl (t)[1]);
}
inline EXTERN int IsLongIntTerm (Term);
inline EXTERN int
IsLongIntTerm (Term t)
{
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorLongInt);
}
#ifdef USE_GMP
#include <stdio.h>
#include <gmp.h>
MP_INT *STD_PROTO (Yap_PreAllocBigNum, (void));
MP_INT *STD_PROTO (Yap_InitBigNum, (Int));
Term STD_PROTO (Yap_MkBigIntTerm, (MP_INT *));
MP_INT *STD_PROTO (Yap_BigIntOfTerm, (Term));
void STD_PROTO (Yap_CleanBigNum, (void));
inline EXTERN int IsBigIntTerm (Term);
inline EXTERN int
IsBigIntTerm (Term t)
{
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorBigInt);
}
inline EXTERN int IsLargeIntTerm (Term);
inline EXTERN int
IsLargeIntTerm (Term t)
{
return (int) (IsApplTerm (t)
&& ((FunctorOfTerm (t) <= FunctorBigInt)
&& (FunctorOfTerm (t) >= FunctorLongInt)));
}
#else
inline EXTERN int IsBigIntTerm (Term);
inline EXTERN int
IsBigIntTerm (Term t)
{
return (int) (FALSE);
}
inline EXTERN int IsLargeIntTerm (Term);
inline EXTERN int
IsLargeIntTerm (Term t)
{
return (int) (IsApplTerm (t) && FunctorOfTerm (t) == FunctorLongInt);
}
#endif
/* extern Functor FunctorLongInt; */
inline EXTERN int IsLargeNumTerm (Term);
inline EXTERN int
IsLargeNumTerm (Term t)
{
return (int) (IsApplTerm (t)
&& ((FunctorOfTerm (t) <= FunctorDouble)
&& (FunctorOfTerm (t) >= FunctorLongInt)));
}
inline EXTERN int IsNumTerm (Term);
inline EXTERN int
IsNumTerm (Term t)
{
return (int) ((IsIntTerm (t) || IsLargeNumTerm (t)));
}
inline EXTERN Int IsAtomicTerm (Term);
inline EXTERN Int
IsAtomicTerm (Term t)
{
return (Int) (IsAtomOrIntTerm (t) || IsLargeNumTerm (t));
}
inline EXTERN Int IsExtensionFunctor (Functor);
inline EXTERN Int
IsExtensionFunctor (Functor f)
{
return (Int) (f <= FunctorDouble);
}
inline EXTERN Int IsBlobFunctor (Functor);
inline EXTERN Int
IsBlobFunctor (Functor f)
{
return (Int) ((f <= FunctorDouble && f >= FunctorDBRef));
}
inline EXTERN Int IsPrimitiveTerm (Term);
inline EXTERN Int
IsPrimitiveTerm (Term t)
{
return (Int) ((IsAtomOrIntTerm (t)
|| (IsApplTerm (t) && IsBlobFunctor (FunctorOfTerm (t)))));
}
#ifdef TERM_EXTENSIONS
inline EXTERN Int IsAttachFunc (Functor);
inline EXTERN Int
IsAttachFunc (Functor f)
{
return (Int) (FALSE);
}
inline EXTERN Int IsAttachedTerm (Term);
inline EXTERN Int
IsAttachedTerm (Term t)
{
return (Int) ((IsVarTerm (t) && VarOfTerm (t) < H0));
}
inline EXTERN Int SafeIsAttachedTerm (Term);
inline EXTERN Int
SafeIsAttachedTerm (Term t)
{
return (Int) ((IsVarTerm (t) && VarOfTerm (t) < H0
&& VarOfTerm (t) >= (CELL *) Yap_GlobalBase));
}
inline EXTERN exts ExtFromCell (CELL *);
inline EXTERN exts
ExtFromCell (CELL * pt)
{
return (exts) (pt[1]);
}
#else
inline EXTERN Int IsAttachFunc (Functor);
inline EXTERN Int
IsAttachFunc (Functor f)
{
return (Int) (FALSE);
}
inline EXTERN Int IsAttachedTerm (Term);
inline EXTERN Int
IsAttachedTerm (Term t)
{
return (Int) (FALSE);
}
#endif
inline EXTERN int STD_PROTO (unify_extension, (Functor, CELL, CELL *, CELL));
EXTERN int STD_PROTO (unify_extension, (Functor, CELL, CELL *, CELL));
inline EXTERN int
unify_extension (Functor f, CELL d0, CELL * pt0, CELL d1)
{
switch (BlobOfFunctor (f))
{
case db_ref_e:
return (d0 == d1);
case long_int_e:
return (pt0[1] == RepAppl (d1)[1]);
#ifdef USE_GMP
case big_int_e:
return (mpz_cmp (Yap_BigIntOfTerm (d0), Yap_BigIntOfTerm (d1)) == 0);
#endif /* USE_GMP */
case double_e:
{
CELL *pt1 = RepAppl (d1);
return (pt0[1] == pt1[1]
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
&& pt0[2] == pt1[2]
#endif
);
}
}
return (FALSE);
}

1287
H/Yap.h Normal file

File diff suppressed because it is too large Load Diff

1194
H/Yatom.h Normal file

File diff suppressed because it is too large Load Diff

710
H/sshift.h Normal file
View File

@ -0,0 +1,710 @@
/*************************************************************************
* *
* YAP Prolog %W% %G%
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: sshift.h *
* Last rev: 19/2/88 *
* mods: *
* comments: stack shifter functionality for YAP *
* *
*************************************************************************/
#define CharP(ptr) ((char *) (ptr))
inline EXTERN int IsHeapP (CELL *);
inline EXTERN int
IsHeapP (CELL * ptr)
{
return (int) ((ptr >= (CELL *) Yap_HeapBase && ptr <= (CELL *) HeapTop));
}
/* Adjusting cells and pointers to cells */
inline EXTERN CELL *PtoGloAdjust (CELL *);
inline EXTERN CELL *
PtoGloAdjust (CELL * ptr)
{
return (CELL *) (((CELL *) (CharP (ptr) + GDiff)));
}
inline EXTERN CELL *PtoDelayAdjust (CELL *);
inline EXTERN CELL *
PtoDelayAdjust (CELL * ptr)
{
return (CELL *) (((CELL *) (CharP (ptr) + DelayDiff)));
}
inline EXTERN tr_fr_ptr PtoTRAdjust (tr_fr_ptr);
inline EXTERN tr_fr_ptr
PtoTRAdjust (tr_fr_ptr ptr)
{
return (tr_fr_ptr) (((tr_fr_ptr) (CharP (ptr) + TrDiff)));
}
inline EXTERN CELL *CellPtoTRAdjust (CELL *);
inline EXTERN CELL *
CellPtoTRAdjust (CELL * ptr)
{
return (CELL *) (((CELL *) (CharP (ptr) + TrDiff)));
}
inline EXTERN CELL *PtoLocAdjust (CELL *);
inline EXTERN CELL *
PtoLocAdjust (CELL * ptr)
{
return (CELL *) (((CELL *) (CharP (ptr) + LDiff)));
}
inline EXTERN choiceptr ChoicePtrAdjust (choiceptr);
inline EXTERN choiceptr
ChoicePtrAdjust (choiceptr ptr)
{
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
}
#ifdef TABLING
inline EXTERN choiceptr ConsumerChoicePtrAdjust (choiceptr);
inline EXTERN choiceptr
ConsumerChoicePtrAdjust (choiceptr ptr)
{
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
}
inline EXTERN choiceptr GeneratorChoicePtrAdjust (choiceptr);
inline EXTERN choiceptr
GeneratorChoicePtrAdjust (choiceptr ptr)
{
return (choiceptr) (((choiceptr) (CharP (ptr) + LDiff)));
}
#endif /* TABLING */
inline EXTERN CELL GlobalAdjust (CELL);
inline EXTERN CELL
GlobalAdjust (CELL val)
{
return (CELL) ((val + GDiff));
}
inline EXTERN CELL DelayAdjust (CELL);
inline EXTERN CELL
DelayAdjust (CELL val)
{
return (CELL) ((val + DelayDiff));
}
inline EXTERN ADDR GlobalAddrAdjust (ADDR);
inline EXTERN ADDR
GlobalAddrAdjust (ADDR ptr)
{
return (ADDR) ((ptr + GDiff));
}
inline EXTERN ADDR DelayAddrAdjust (ADDR);
inline EXTERN ADDR
DelayAddrAdjust (ADDR ptr)
{
return (ADDR) ((ptr + DelayDiff));
}
inline EXTERN CELL LocalAdjust (CELL);
inline EXTERN CELL
LocalAdjust (CELL val)
{
return (CELL) ((val + LDiff));
}
inline EXTERN ADDR LocalAddrAdjust (ADDR);
inline EXTERN ADDR
LocalAddrAdjust (ADDR ptr)
{
return (ADDR) ((ptr + LDiff));
}
inline EXTERN CELL TrailAdjust (CELL);
inline EXTERN CELL
TrailAdjust (CELL val)
{
return (CELL) ((val + TrDiff));
}
inline EXTERN ADDR TrailAddrAdjust (ADDR);
inline EXTERN ADDR
TrailAddrAdjust (ADDR ptr)
{
return (ADDR) ((ptr + TrDiff));
}
inline EXTERN TokEntry *TokEntryAdjust (TokEntry *);
inline EXTERN TokEntry *
TokEntryAdjust (TokEntry * ptr)
{
return (TokEntry *) (((CELL) ptr + TrDiff));
}
inline EXTERN VarEntry *VarEntryAdjust (VarEntry *);
inline EXTERN VarEntry *
VarEntryAdjust (VarEntry * ptr)
{
return (VarEntry *) (((CELL) ptr + TrDiff));
}
/* heap data structures */
inline EXTERN Functor FuncAdjust (Functor);
inline EXTERN Functor
FuncAdjust (Functor f)
{
return (Functor) ((Functor) (CharP (f) + HDiff));
}
inline EXTERN CELL *CellPtoHeapAdjust (CELL *);
inline EXTERN CELL *
CellPtoHeapAdjust (CELL * ptr)
{
return (CELL *) (((CELL *) (CharP (ptr) + HDiff)));
}
#if USE_OFFSETS
inline EXTERN Atom AtomAdjust (Atom);
inline EXTERN Atom
AtomAdjust (Atom at)
{
return (Atom) ((at));
}
inline EXTERN Prop PropAdjust (Prop);
inline EXTERN Prop
PropAdjust (Prop p)
{
return (Prop) ((p));
}
#else
inline EXTERN Atom AtomAdjust (Atom);
inline EXTERN Atom
AtomAdjust (Atom at)
{
return (Atom) ((at == NULL ? (at) : (Atom) (CharP (at) + HDiff)));
}
inline EXTERN Prop PropAdjust (Prop);
inline EXTERN Prop
PropAdjust (Prop p)
{
return (Prop) ((p == NULL ? (p) : (Prop) (CharP (p) + HDiff)));
}
#endif
inline EXTERN Term AtomTermAdjust (Term);
inline EXTERN Term
AtomTermAdjust (Term at)
{
return (Term) ((at));
}
#if TAGS_FAST_OPS
inline EXTERN Term BlobTermAdjust (Term);
inline EXTERN Term
BlobTermAdjust (Term t)
{
return (Term) ((t - HDiff));
}
#else
inline EXTERN Term BlobTermAdjust (Term);
inline EXTERN Term
BlobTermAdjust (Term t)
{
return (Term) ((t + HDiff));
}
#endif
inline EXTERN AtomEntry *AtomEntryAdjust (AtomEntry *);
inline EXTERN AtomEntry *
AtomEntryAdjust (AtomEntry * at)
{
return (AtomEntry *) ((AtomEntry *) (CharP (at) + HDiff));
}
inline EXTERN union CONSULT_OBJ *ConsultObjAdjust (union CONSULT_OBJ *);
inline EXTERN union CONSULT_OBJ *
ConsultObjAdjust (union CONSULT_OBJ *co)
{
return (union CONSULT_OBJ *) ((union CONSULT_OBJ *) (CharP (co) + HDiff));
}
inline EXTERN DBRef DBRefAdjust (DBRef);
inline EXTERN DBRef
DBRefAdjust (DBRef dbr)
{
return (DBRef) ((DBRef) (CharP (dbr) + HDiff));
}
inline EXTERN DBRef *DBRefPAdjust (DBRef *);
inline EXTERN DBRef *
DBRefPAdjust (DBRef * dbrp)
{
return (DBRef *) ((DBRef *) (CharP (dbrp) + HDiff));
}
inline EXTERN DBTerm *DBTermAdjust (DBTerm *);
inline EXTERN DBTerm *
DBTermAdjust (DBTerm * dbtp)
{
return (DBTerm *) ((DBTerm *) (CharP (dbtp) + HDiff));
}
inline EXTERN struct static_index *SIndexAdjust (struct static_index *);
inline EXTERN struct static_index *
SIndexAdjust (struct static_index *si)
{
return (struct static_index
*) ((struct static_index *) (CharP (si) + HDiff));
}
inline EXTERN struct logic_upd_index *LUIndexAdjust (struct logic_upd_index
*);
inline EXTERN struct logic_upd_index *
LUIndexAdjust (struct logic_upd_index *lui)
{
return (struct logic_upd_index
*) ((struct logic_upd_index *) (CharP (lui) + HDiff));
}
inline EXTERN Term CodeAdjust (Term);
inline EXTERN Term
CodeAdjust (Term dbr)
{
return (Term) (((Term) (dbr) + HDiff));
}
inline EXTERN ADDR AddrAdjust (ADDR);
inline EXTERN ADDR
AddrAdjust (ADDR addr)
{
return (ADDR) ((ADDR) (CharP (addr) + HDiff));
}
inline EXTERN CODEADDR CodeAddrAdjust (CODEADDR);
inline EXTERN CODEADDR
CodeAddrAdjust (CODEADDR addr)
{
return (CODEADDR) ((CODEADDR) (CharP (addr) + HDiff));
}
inline EXTERN BlockHeader *BlockAdjust (BlockHeader *);
inline EXTERN BlockHeader *
BlockAdjust (BlockHeader * addr)
{
return (BlockHeader *) ((BlockHeader *) (CharP (addr) + HDiff));
}
inline EXTERN yamop *PtoOpAdjust (yamop *);
inline EXTERN yamop *
PtoOpAdjust (yamop * ptr)
{
return (yamop *) (((yamop *) (CharP (ptr) + HDiff)));
}
inline EXTERN CELL *PtoHeapCellAdjust (CELL *);
inline EXTERN CELL *
PtoHeapCellAdjust (CELL * ptr)
{
return (CELL *) (((CELL *) (CharP (ptr) + HDiff)));
}
inline EXTERN PredEntry *PtoPredAdjust (PredEntry *);
inline EXTERN PredEntry *
PtoPredAdjust (PredEntry * ptr)
{
return (PredEntry *) (((PredEntry *) (CharP (ptr) + HDiff)));
}
inline EXTERN ArrayEntry *PtoArrayEAdjust (ArrayEntry *);
inline EXTERN ArrayEntry *
PtoArrayEAdjust (ArrayEntry * ptr)
{
return (ArrayEntry *) (((ArrayEntry *) (CharP (ptr) + HDiff)));
}
inline EXTERN struct logic_upd_clause *PtoLUCAdjust (struct logic_upd_clause
*);
inline EXTERN struct logic_upd_clause *
PtoLUCAdjust (struct logic_upd_clause *ptr)
{
return (struct logic_upd_clause
*) (((struct logic_upd_clause *) (CharP (ptr) + HDiff)));
}
inline EXTERN struct static_clause *PtoStCAdjust (struct static_clause *);
inline EXTERN struct static_clause *
PtoStCAdjust (struct static_clause *ptr)
{
return (struct static_clause
*) (((struct static_upd_clause *) (CharP (ptr) + HDiff)));
}
#if USE_DL_MALLOC
inline EXTERN struct malloc_chunk *ChunkPtrAdjust (struct malloc_chunk *);
inline EXTERN struct malloc_chunk *
ChunkPtrAdjust (struct malloc_chunk *ptr)
{
return (struct malloc_chunk
*) (((struct malloc_chunk *) (CharP (ptr) + HDiff)));
}
#endif
#if PRECOMPUTE_REGADDRESS
inline EXTERN wamreg XAdjust (wamreg);
inline EXTERN wamreg
XAdjust (wamreg reg)
{
return (wamreg) ((wamreg) ((reg) + XDiff));
}
#else
inline EXTERN wamreg XAdjust (wamreg);
inline EXTERN wamreg
XAdjust (wamreg reg)
{
return (wamreg) ((reg));
}
#endif
inline EXTERN yslot YAdjust (yslot);
inline EXTERN yslot
YAdjust (yslot reg)
{
return (yslot) ((reg));
}
inline EXTERN int IsOldLocal (CELL);
inline EXTERN int
IsOldLocal (CELL reg)
{
return (int) (IN_BETWEEN (OldASP, reg, OldLCL0));
}
inline EXTERN int IsOldLocalPtr (CELL *);
inline EXTERN int
IsOldLocalPtr (CELL * ptr)
{
return (int) (IN_BETWEEN (OldASP, ptr, OldLCL0));
}
/* require because the trail might contain dangling pointers */
inline EXTERN int IsOldLocalInTR (CELL);
inline EXTERN int
IsOldLocalInTR (CELL reg)
{
return (int) (IN_BETWEEN (OldH, reg, OldLCL0));
}
inline EXTERN int IsOldLocalInTRPtr (CELL *);
inline EXTERN int
IsOldLocalInTRPtr (CELL * ptr)
{
return (int) (IN_BETWEEN (OldH, ptr, OldLCL0));
}
inline EXTERN int IsOldH (CELL);
inline EXTERN int
IsOldH (CELL reg)
{
return (int) ((CharP (reg) == CharP (OldH)));
}
inline EXTERN int IsOldGlobal (CELL);
inline EXTERN int
IsOldGlobal (CELL reg)
{
return (int) (IN_BETWEEN (OldH0, reg, OldH));
}
inline EXTERN int IsOldGlobalPtr (CELL *);
inline EXTERN int
IsOldGlobalPtr (CELL * ptr)
{
return (int) (IN_BETWEEN (OldH0, ptr, OldH));
}
inline EXTERN int IsOldDelay (CELL);
inline EXTERN int
IsOldDelay (CELL reg)
{
return (int) (IN_BETWEEN (OldGlobalBase, reg, OldH0));
}
inline EXTERN int IsOldDelayPtr (CELL *);
inline EXTERN int
IsOldDelayPtr (CELL * ptr)
{
return (int) (IN_BETWEEN (OldGlobalBase, ptr, OldH0));
}
inline EXTERN int IsOldTrail (CELL);
inline EXTERN int
IsOldTrail (CELL reg)
{
return (int) (IN_BETWEEN (OldTrailBase, reg, OldTR));
}
inline EXTERN int IsOldTrailPtr (CELL *);
inline EXTERN int
IsOldTrailPtr (CELL * ptr)
{
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
}
inline EXTERN int IsOldVarTableTrailPtr (struct VARSTRUCT *);
inline EXTERN int
IsOldVarTableTrailPtr (struct VARSTRUCT *ptr)
{
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
}
inline EXTERN int IsOldTokenTrailPtr (struct TOKEN *);
inline EXTERN int
IsOldTokenTrailPtr (struct TOKEN *ptr)
{
return (int) (IN_BETWEEN (OldTrailBase, ptr, OldTR));
}
inline EXTERN int IsOldCode (CELL);
inline EXTERN int
IsOldCode (CELL reg)
{
return (int) (IN_BETWEEN (OldHeapBase, reg, OldHeapTop));
}
inline EXTERN int IsOldCodeCellPtr (CELL *);
inline EXTERN int
IsOldCodeCellPtr (CELL * ptr)
{
return (int) (IN_BETWEEN (OldHeapBase, ptr, OldHeapTop));
}
inline EXTERN int IsGlobal (CELL);
inline EXTERN int
IsGlobal (CELL reg)
{
return (int) (IN_BETWEEN (Yap_GlobalBase, reg, H));
}
void STD_PROTO (Yap_AdjustStacksAndTrail, (void));
void STD_PROTO (Yap_AdjustRegs, (int));

View File

@ -91,15 +91,14 @@ CWD=$(PWD)
VERSION=Yap-4.5.7
#
TAG_HEADERS= Tags_32bits.h Tags_32Ops.h Tags_32LowTag.h\
Tags_64bits.h Tags_24bits.h
GHEADERS = TermExt.h Yap.h Atoms.h Yatom.h sshift.h $(TAG_HEADERS)
INTERFACE_HEADERS = $(srcdir)/include/c_interface.h $(srcdir)/include/yap_structs.h $(srcdir)/include/YapInterface.h
HEADERS = \
$(GHEADERS) $(INTERFACE_HEADERS) \
$(srcdir)/H/TermExt.h $(srcdir)/H/Atoms.h \
$(srcdir)/H/Tags_32bits.h $(srcdir)/H/Tags_32Ops.h \
$(srcdir)/H/Tags_32LowTag.h $(srcdir)/H/Tags_64bits.h \
$(srcdir)/H/Tags_24bits.h $(srcdir)/H/sshift.h \
$(srcdir)/H/Yap.h $(srcdir)/H/Yatom.h \
$(srcdir)/H/Heap.h \
$(srcdir)/H/Regs.h $(srcdir)/H/Yapproto.h \
$(srcdir)/H/absmi.h $(srcdir)/H/alloc.h \
@ -208,52 +207,11 @@ OBJECTS = yap.o $(LIB_OBJECTS)
all: Makefile $(GHEADERS) startup
all: Makefile startup
Makefile: $(srcdir)/Makefile.in
# Header files dependent on type abstraction, either implemented as
# inline functions or as macros.
Yap.h: $(srcdir)/m4/Yap.h.m4 Atoms.h TermExt.h $(srcdir)/H/Regs.h $(M4GENHDRS) $(TAG_HEADERS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Yap.h.m4 > Yap.h
$(INDENT) Yap.h
Tags_32bits.h: $(srcdir)/m4/Tags_32bits.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Tags_32bits.h.m4 > Tags_32bits.h
$(INDENT) Tags_32bits.h
Tags_32Ops.h: $(srcdir)/m4/Tags_32Ops.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Tags_32Ops.h.m4 > Tags_32Ops.h
$(INDENT) Tags_32Ops.h
Tags_32LowTag.h: $(srcdir)/m4/Tags_32LowTag.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Tags_32LowTag.h.m4 > Tags_32LowTag.h
$(INDENT) Tags_32LowTag.h
Tags_64bits.h: $(srcdir)/m4/Tags_64bits.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Tags_64bits.h.m4 > Tags_64bits.h
$(INDENT) Tags_64bits.h
Tags_24bits.h: $(srcdir)/m4/Tags_24bits.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Tags_24bits.h.m4 > Tags_24bits.h
$(INDENT) Tags_24bits.h
TermExt.h: $(srcdir)/m4/TermExt.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/TermExt.h.m4 > TermExt.h
$(INDENT) TermExt.h
Yatom.h: $(srcdir)/m4/Yatom.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Yatom.h.m4 > Yatom.h
$(INDENT) Yatom.h
Atoms.h: $(srcdir)/m4/Atoms.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/Atoms.h.m4 > Atoms.h
$(INDENT) Atoms.h
sshift.h: $(srcdir)/m4/sshift.h.m4 $(M4GENHDRS)
$(M4) $(M4GENHDRS) $(srcdir)/m4/sshift.h.m4 > sshift.h
$(INDENT) sshift.h
absmi.o: $(srcdir)/C/absmi.c
$(CC) -c $(CFLAGS) $(ABSMI_FLAGS) $(srcdir)/C/absmi.c -o $@
@ -581,7 +539,7 @@ depend: $(HEADERS) $(C_SOURCES)
fi
clean: clean_docs
rm -f *.o *~ $(GHEADERS) *.BAK *.a
rm -f *.o *~ *.BAK *.a
@INSTALL_DLLS@ (cd library/random; make clean)
@INSTALL_DLLS@ (cd library/regex; make clean)
@INSTALL_DLLS@ (cd library/system; make clean)