/************************************************************************* * * * 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.4 2008-01-30 10:35:43 vsc Exp $ * *************************************************************************/ #if SIZEOF_INT_P==4 && USE_LOW32_TAGS #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))<>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 #include "inline-only.h" INLINE_ONLY inline EXTERN int IsVarTerm (Term); INLINE_ONLY inline EXTERN int IsVarTerm (Term t) { return (int) (!((t) & LowTagBits)); } INLINE_ONLY inline EXTERN int IsNonVarTerm (Term); INLINE_ONLY inline EXTERN int IsNonVarTerm (Term t) { return (int) (((t) & LowTagBits)); } INLINE_ONLY inline EXTERN Term *RepPair (Term); INLINE_ONLY inline EXTERN Term * RepPair (Term t) { return (Term *) ((t) - PairBits); } INLINE_ONLY inline EXTERN Term AbsPair (Term *); INLINE_ONLY inline EXTERN Term AbsPair (Term * p) { return (Term) (Unsigned (p) + PairBits); } INLINE_ONLY inline EXTERN Int IsPairTerm (Term); INLINE_ONLY inline EXTERN Int IsPairTerm (Term t) { return (Int) ((((t) & LowTagBits) == PairBits)); } INLINE_ONLY inline EXTERN Term *RepAppl (Term); INLINE_ONLY inline EXTERN Term * RepAppl (Term t) { return (Term *) (((t) - ApplBit)); } INLINE_ONLY inline EXTERN Term AbsAppl (Term *); INLINE_ONLY inline EXTERN Term AbsAppl (Term * p) { return (Term) (Unsigned (p) + ApplBit); } INLINE_ONLY inline EXTERN Int IsApplTerm (Term); INLINE_ONLY inline EXTERN Int IsApplTerm (Term t) { return (Int) ((((t) & LowTagBits) == ApplBit)); } INLINE_ONLY inline EXTERN Int IsAtomOrIntTerm (Term); INLINE_ONLY inline EXTERN Int IsAtomOrIntTerm (Term t) { return (Int) ((((t) & LowTagBits) == 2)); } INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off); INLINE_ONLY inline EXTERN Term AdjustPtr (Term t, Term off) { return (Term) ((t) + off); } INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off); INLINE_ONLY inline EXTERN Term AdjustIDBPtr (Term t, Term off) { return (Term) ((t) + off); } INLINE_ONLY inline EXTERN Int IntOfTerm (Term); INLINE_ONLY inline EXTERN Int IntOfTerm (Term t) { return (Int) (((Int) (t << 1)) >> (SHIFT_LOW_TAG + SHIFT_HIGH_TAG + 1)); } #endif