/usr/include/Yap/clause.h is in yap 6.2.2-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | /*************************************************************************
* *
* 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: clause.h *
* Last rev: *
* mods: *
* comments: clause info *
* *
*************************************************************************/
#include "Yatom.h"
#include "YapHeap.h"
/* consulting files */
typedef union CONSULT_OBJ {
char *filename;
int mode;
Prop p;
UInt c;
} consult_obj;
/* Either we are assembling clauses or indexing code */
#define ASSEMBLING_CLAUSE 0
#define ASSEMBLING_INDEX 1
#define ASSEMBLING_EINDEX 2
#define NextDynamicClause(X) (((yamop *)X)->u.Otapl.d)
#define PredFirstClause 0
#define PredMiddleClause 1
#define PredLastClause 2
typedef struct logic_upd_index {
CELL ClFlags;
UInt ClRefCount;
#if defined(YAPOR) || defined(THREADS)
/* A lock for manipulating the clause */
// lockvar ClLock;
#endif
UInt ClSize;
struct logic_upd_index *ParentIndex;
struct logic_upd_index *SiblingIndex;
struct logic_upd_index *PrevSiblingIndex;
struct logic_upd_index *ChildIndex;
/* The instructions, at least one of the form sl */
PredEntry *ClPred;
yamop ClCode[MIN_ARRAY];
} LogUpdIndex;
/* The ordering of the first 3 fields should be compatible with dbrefs */
typedef struct logic_upd_clause {
Functor Id; /* allow pointers to this struct to id */
/* as dbref */
/* A set of flags describing info on the clause */
/* A set of flags describing info on the clause */
CELL ClFlags;
#if defined(YAPOR) || defined(THREADS)
/* A lock for manipulating the clause */
// lockvar ClLock;
#endif
UInt ClSize;
/* extra clause information for logical update indices and facts */
/* indices that may still backtrack to this clause */
UInt ClRefCount;
/* data for clauses with environments */
yamop *ClExt;
DBTerm *ClSource;
/* doubly linked list of clauses */
struct logic_upd_clause *ClPrev, *ClNext;
/* parent pointer */
PredEntry *ClPred;
UInt ClTimeStart, ClTimeEnd;
/* The instructions, at least one of the form sl */
yamop ClCode[MIN_ARRAY];
} LogUpdClause;
inline EXTERN int VALID_TIMESTAMP(UInt, struct logic_upd_clause *);
inline EXTERN int
VALID_TIMESTAMP(UInt timestamp, struct logic_upd_clause *cl)
{
return IN_BETWEEN(cl->ClTimeStart, timestamp, cl->ClTimeEnd);
}
typedef struct dynamic_clause {
/* A set of flags describing info on the clause */
CELL ClFlags;
#if defined(YAPOR) || defined(THREADS)
/* A lock for manipulating the clause */
lockvar ClLock;
#endif
UInt ClSize;
UInt ClRefCount;
yamop *ClPrevious; /* immediate update clause */
/* The instructions, at least one of the form sl */
yamop ClCode[MIN_ARRAY];
} DynamicClause;
typedef struct static_index {
/* A set of flags describing info on the clause */
CELL ClFlags;
UInt ClSize;
struct static_index *SiblingIndex;
struct static_index *ChildIndex;
/* The instructions, at least one of the form sl */
PredEntry *ClPred;
yamop ClCode[MIN_ARRAY];
} StaticIndex;
typedef struct static_clause {
/* A set of flags describing info on the clause */
CELL ClFlags;
UInt ClSize;
union {
DBTerm *ClSource;
PredEntry *ClPred;
} usc;
struct static_clause *ClNext;
/* The instructions, at least one of the form sl */
yamop ClCode[MIN_ARRAY];
} StaticClause;
typedef struct static_mega_clause {
/* A set of flags describing info on the clause */
CELL ClFlags;
UInt ClSize;
PredEntry *ClPred;
UInt ClItemSize;
struct static_mega_clause *ClNext;
/* The instructions, at least one of the form sl */
yamop ClCode[MIN_ARRAY];
} MegaClause;
typedef union clause_obj {
struct logic_upd_clause luc;
struct logic_upd_index lui;
struct dynamic_clause ic;
struct static_clause sc;
struct static_mega_clause mc;
struct static_index si;
} ClauseUnion;
typedef union clause_ptr {
struct logic_upd_clause *luc;
struct logic_upd_index *lui;
struct dynamic_clause *ic;
struct static_clause *sc;
struct static_mega_clause *mc;
struct static_index *si;
} ClausePointer;
typedef struct dbterm_list {
/* a list of dbterms associated with a clause */
DBTerm *dbterms;
yamop *clause_code;
PredEntry *p;
struct dbterm_list *next_dbl;
} DBTermList;
#define ClauseCodeToDynamicClause(p) ((DynamicClause *)((CODEADDR)(p)-(CELL)(((DynamicClause *)NULL)->ClCode)))
#define ClauseCodeToStaticClause(p) ((StaticClause *)((CODEADDR)(p)-(CELL)(((StaticClause *)NULL)->ClCode)))
#define ClauseCodeToLogUpdClause(p) ((LogUpdClause *)((CODEADDR)(p)-(CELL)(((LogUpdClause *)NULL)->ClCode)))
#define ClauseCodeToMegaClause(p) ((MegaClause *)((CODEADDR)(p)-(CELL)(((MegaClause *)NULL)->ClCode)))
#define ClauseCodeToLogUpdIndex(p) ((LogUpdIndex *)((CODEADDR)(p)-(CELL)(((LogUpdIndex *)NULL)->ClCode)))
#define ClauseCodeToStaticIndex(p) ((StaticIndex *)((CODEADDR)(p)-(CELL)(((StaticIndex *)NULL)->ClCode)))
#define ClauseFlagsToDynamicClause(p) ((DynamicClause *)(p))
#define ClauseFlagsToLogUpdClause(p) ((LogUpdClause *)((CODEADDR)(p)-(CELL)(&(((LogUpdClause *)NULL)->ClFlags))))
#define ClauseFlagsToLogUpdIndex(p) ((LogUpdIndex *)((CODEADDR)(p)-(CELL)(&(((LogUpdIndex *)NULL)->ClFlags))))
#define ClauseFlagsToStaticClause(p) ((StaticClause *)(p))
#define DynamicFlags(X) (ClauseCodeToDynamicClause(X)->ClFlags)
#define DynamicLock(X) (ClauseCodeToDynamicClause(X)->ClLock)
#if defined(YAPOR) || defined(THREADS)
#define INIT_CLREF_COUNT(X) (X)->ClRefCount = 0
#define INC_CLREF_COUNT(X) (X)->ClRefCount++
#define DEC_CLREF_COUNT(X) (X)->ClRefCount--
#define CL_IN_USE(X) ((X)->ClRefCount)
#else
#define INIT_CLREF_COUNT(X)
#define INC_CLREF_COUNT(X)
#define DEC_CLREF_COUNT(X)
#define CL_IN_USE(X) ((X)->ClFlags & InUseMask || (X)->ClRefCount)
#endif
/* amasm.c */
wamreg STD_PROTO(Yap_emit_x,(CELL));
COUNT STD_PROTO(Yap_compile_cmp_flags,(PredEntry *));
void STD_PROTO(Yap_InitComma,(void));
/* cdmgr.c */
void STD_PROTO(Yap_IPred,(PredEntry *, UInt, yamop *));
int STD_PROTO(Yap_addclause,(Term,yamop *,int,Term,Term*));
void STD_PROTO(Yap_add_logupd_clause,(PredEntry *,LogUpdClause *,int));
void STD_PROTO(Yap_kill_iblock,(ClauseUnion *,ClauseUnion *,PredEntry *));
void STD_PROTO(Yap_EraseStaticClause,(StaticClause *, Term));
ClauseUnion *STD_PROTO(Yap_find_owner_index,(yamop *, PredEntry *));
/* dbase.c */
void STD_PROTO(Yap_ErCl,(DynamicClause *));
void STD_PROTO(Yap_ErLogUpdCl,(LogUpdClause *));
void STD_PROTO(Yap_ErLogUpdIndex,(LogUpdIndex *));
Int STD_PROTO(Yap_Recordz,(Atom, Term));
/* exec.c */
Term STD_PROTO(Yap_cp_as_integer,(choiceptr));
/* index.c */
yamop *STD_PROTO(Yap_PredIsIndexable,(PredEntry *, UInt, yamop *));
yamop *STD_PROTO(Yap_ExpandIndex,(PredEntry *, UInt));
void STD_PROTO(Yap_CleanUpIndex,(struct logic_upd_index *));
void STD_PROTO(Yap_CleanKids,(struct logic_upd_index *));
void STD_PROTO(Yap_AddClauseToIndex,(PredEntry *,yamop *,int));
void STD_PROTO(Yap_RemoveClauseFromIndex,(PredEntry *,yamop *));
LogUpdClause *STD_PROTO(Yap_NthClause,(PredEntry *,Int));
LogUpdClause *STD_PROTO(Yap_FollowIndexingCode,(PredEntry *,yamop *, Term *, yamop *,yamop *));
#if USE_THREADED_CODE
#define OP_HASH_SIZE 2048
static inline int
rtable_hash_op(OPCODE opc, int hash_mask) {
return((((CELL)opc) >> 3) & hash_mask);
}
/* given an opcode find the corresponding opnumber. This should make
switches on ops a much easier operation */
static inline op_numbers
Yap_op_from_opcode(OPCODE opc)
{
int j = rtable_hash_op(opc,OP_HASH_SIZE-1);
while (OP_RTABLE[j].opc != opc) {
if (!OP_RTABLE[j].opc)
return _Nstop;
if (j == OP_HASH_SIZE-1) {
j = 0;
} else {
j++;
}
}
return OP_RTABLE[j].opnum;
}
#else
static inline op_numbers
Yap_op_from_opcode(OPCODE opc)
{
return((op_numbers)opc);
}
#endif /* USE_THREADED_CODE */
#if defined(YAPOR) || defined(THREADS)
static inline int same_lu_block(yamop **, yamop *);
static inline int
same_lu_block(yamop **paddr, yamop *p)
{
yamop *np = *paddr;
if (np != p) {
OPCODE jmp_op = Yap_opcode(_jump_if_nonvar);
while (np->opc == jmp_op) {
np = NEXTOP(np, xll);
if (np == p) return TRUE;
}
return FALSE;
} else {
return TRUE;
}
}
#endif
static inline Term
Yap_MkStaticRefTerm(StaticClause *cp)
{
Term t[1];
t[0] = MkIntegerTerm((Int)cp);
return Yap_MkApplTerm(FunctorStaticClause,1,t);
}
static inline StaticClause *
Yap_ClauseFromTerm(Term t)
{
return (StaticClause *)IntegerOfTerm(ArgOfTerm(1,t));
}
static inline Term
Yap_MkMegaRefTerm(PredEntry *ap,yamop *ipc)
{
Term t[2];
t[0] = MkIntegerTerm((Int)ap);
t[1] = MkIntegerTerm((Int)ipc);
return Yap_MkApplTerm(FunctorMegaClause,2,t);
}
static inline yamop *
Yap_MegaClauseFromTerm(Term t)
{
return (yamop *)IntegerOfTerm(ArgOfTerm(2,t));
}
static inline PredEntry *
Yap_MegaClausePredicateFromTerm(Term t)
{
return (PredEntry *)IntegerOfTerm(ArgOfTerm(1,t));
}
typedef enum {
FIND_PRED_FROM_ANYWHERE,
FIND_PRED_FROM_CP,
FIND_PRED_FROM_ENV
} find_pred_type;
Int STD_PROTO(Yap_PredForCode,(yamop *, find_pred_type, Atom *, UInt *, Term *));
PredEntry *STD_PROTO(Yap_PredEntryForCode,(yamop *, find_pred_type, CODEADDR *, CODEADDR *));
LogUpdClause *STD_PROTO(Yap_new_ludbe,(Term, PredEntry *, UInt));
Term STD_PROTO(Yap_LUInstance,(LogUpdClause *, UInt));
/* udi.c */
void STD_PROTO(Yap_udi_init,(void));
yamop *STD_PROTO(Yap_udi_search,(PredEntry *));
int STD_PROTO(Yap_new_udi_clause,(PredEntry *, yamop *, Term));
#ifdef DEBUG
void STD_PROTO(Yap_bug_location,(yamop *));
#endif
#if LOW_PROF
void STD_PROTO(Yap_InformOfRemoval,(CODEADDR));
void STD_PROTO(Yap_dump_code_area_for_profiler,(void));
#else
#define Yap_InformOfRemoval(X)
#endif
|