This file is indexed.

/usr/include/Yap/or.sbaamiops.h is in yap 6.2.2-6.

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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/************************************************************************
**                                                                     **
**                   The YapTab/YapOr/OPTYap systems                   **
**                                                                     **
** YapTab extends the Yap Prolog engine to support sequential tabling  **
** YapOr extends the Yap Prolog engine to support or-parallelism       **
** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
**                                                                     **
**                                                                     **
**      Yap Prolog was developed at University of Porto, Portugal      **
**                                                                     **
************************************************************************/

#ifdef SCCS
static char     SccsId[] = "%W% %G%";
#endif /* SCCS */

#define  IsArrayReference(a) ((a)->array_access_func == FunctorArrayAccess)

/* dereferencing macros */

/************************************************************

Dereferencing macros

*************************************************************/

/* For DEREFD, D has both the input and the exit argument */
/* A is only used locally */

#define deref_head(D,Label)  if (IsVarTerm(D)) goto Label

#define deref_body(D,A,LabelUnk,LabelNonVar)                 \
		do {                                         \
                   if(!IsVarTerm(D)) goto LabelNonVar;       \
		LabelUnk:                                    \
                   (A) = (CELL *)(D);                        \
                   (D) = *(CELL *)(D);                       \
		   } while (0 != (D))

#define derefa_body(D,A,LabelUnk,LabelNonVar)                \
		do {                                         \
                   (A) = (CELL *)(D);                        \
                   (D) = *(CELL *)(D);                       \
                   if(!IsVarTerm(D)) goto LabelNonVar;       \
		LabelUnk:                                    \
		   } while (0 != (D))

#if UNIQUE_TAG_FOR_PAIRS

/* If you have an unique tag for pairs you can use these macros which will
   speed up detection of dereferenced pairs, but will be slow
   for the other cases.

   The only instruction where this seems useful is 
   switch_list_nl
*/

#define deref_list_head(D,Label)  if (!IsPairTerm(D)) goto Label

#define deref_list_body(D,A,LabelList,LabelNonVar)           \
		do {                                         \
		   if (!IsVarTerm(D)) goto LabelNonVar;      \
                   (A) = (CELL *)(D);                        \
                   (D) = *(A);                               \
		   if (0 == (D)) break;                      \
		   if (IsPairTerm(D)) goto LabelList;        \
		} while (TRUE);

#endif /* UNIQUE_TAG_FOR_PAIRS */

EXTERN inline Term Deref(Term a)
{
   while(IsVarTerm(a)) {
	Term *b = (Term *) a;
	a = *b;
	if(a==0) return (Term)b;
   }
   return(a);
}

EXTERN inline Term Derefa(CELL *b)
{
  Term a = *b;
 restart:
  if (!IsVarTerm(a)) {
    return(a);
  } else if (a == 0) {
    return((CELL)b);
  } else {
    b = (CELL *)a;
    a = *b;
    goto restart;
  }
}

/************************************************************

TRAIL VARIABLE

A contains the address of the variable that is to be trailed

*************************************************************/


/* #define TRAIL(A)	if ((A) < HBREG || (A) > B) TrailTerm(TR++) = Unsigned(A)
 */

#define RESET_VARIABLE(V)       (*(CELL *)(V) = 0)

inline EXTERN void
AlignGlobalForDouble(void)
{
  /* Force Alignment for floats. Note that garbage collector may
     break the alignment; */
  if (!DOUBLE_ALIGNED(H)) {
    RESET_VARIABLE(H);
    H++;
  }
}

#ifdef YAPOR

#define DO_TRAIL(TERM, VAL)      \
{                                \
  register tr_fr_ptr r;          \
  r = TR;                        \
  TR = r + 1;                    \
  TrailTerm(r) = (CELL) (TERM);  \
  TrailVal(r) = (VAL);           \
}

#define DO_MATRAIL(TERM, OLDVAL, NEWVAL)    \
{                                \
  register tr_fr_ptr r = TR+1;          \
  TrailTerm(TR) = (OLDVAL);  /* disgusting hack */                \
  TrailTerm(r) = AbsAppl(TERM);  \
  TrailVal(r) = (NEWVAL);        \
  TR = r+1;     \
}

#define TRAIL_REF(REF)     TrailTerm(TR++) = AbsPair(((CELL *)(REF)))

/* convert to offset */
#define STACK_TO_SBA(A) (CELL *)(((char *)(A)+sba_offset))

#define IN_SBA(A) ((CELL)((char *)(A)-binding_array) < sba_size) 

#define SBA_TO_STACK(A) (CELL *)(((char *)(A)-sba_offset))

/* put the binding in the SBA and force ptr to point there */
#define BIND_SHARED_VARIABLE(A, D) {               \
  CELL *ptr;                                       \
/*shared_binds++;*/ \
  if (IN_SBA(A)) {                                 \
    ptr = SBA_TO_STACK(A);                         \
    DO_TRAIL(ptr,D);	                           \
    *(A) = (D);                                    \
  } else {                                         \
    DO_TRAIL((A),D);	                           \
    ptr = STACK_TO_SBA(A);                         \
    *(A) = (CELL)ptr;                              \
    *ptr = (D);                                    \
  }                                                \
}

/* put the binding in the SBA and force ptr to point there */
#define MABIND_SHARED_VARIABLE(A, D) {             \
/*shared_binds++;*/                                \
  if (IN_SBA(A)) {                                 \
    CELL *sptr = SBA_TO_STACK(A);                  \
    DO_MATRAIL(sptr, *(A), D);                     \
    *(A) = (D);                                    \
  } else {                                         \
    CELL *ptr3;                                    \
    DO_MATRAIL((A), *(A), D);                      \
    ptr3 = STACK_TO_SBA(A);                        \
    *(A) = (CELL)ptr3;                             \
    *ptr3 = (D);                                   \
  }                                                \
}

extern int condit_binds, shared_binds, uncond_binds;

/* put the binding in the stacks even though it is conditional */
#define BIND_CONDITIONALLY(A, D) {                 \
  DO_TRAIL(A,D);	                           \
/*condit_binds++; */\
  *(A) = (D);                                      \
}

/* put the binding in the stacks even though it is conditional */
#define MABIND_CONDITIONALLY(A, D) {               \
  DO_MATRAIL(A,*(A),D);                            \
/*condit_binds++; */\
  *(A) = (D);                                      \
}
 
#define DO_CONDITIONAL_BINDING(A,D) {              \
  if (Unsigned((Int)(A)-(Int)(H_FZ)) >             \
      Unsigned((Int)(B_FZ)-(Int)(H_FZ)))           \
    { BIND_SHARED_VARIABLE(A, D); }                \
  else { BIND_CONDITIONALLY(A,D); }                \
}

#define DO_CONDITIONAL_MABINDING(A,D) {            \
  if (Unsigned((Int)(A)-(Int)(H_FZ)) >             \
      Unsigned((Int)(B_FZ)-(Int)(H_FZ)))           \
    { MABIND_SHARED_VARIABLE(A, D); }              \
  else { MABIND_CONDITIONALLY(A,D); }              \
}

#define Bind(A,D)          {                       \
 if (Unsigned((Int)(A)-(Int)(HBREG)) >             \
      Unsigned(BBREG)-(Int)(HBREG))                \
    { DO_CONDITIONAL_BINDING(A, D); }              \
 else /* uncond_binds++, */ *(A) = (D);            \
}

#define BIND(A,D,L)   Bind(A,D)

#define MaBind(A,D)        {                       \
 if (Unsigned((Int)(A)-(Int)(HBREG)) >             \
      Unsigned(BBREG)-(Int)(HBREG))                \
    { DO_CONDITIONAL_MABINDING(A, D); }            \
 else /* uncond_binds++, */ *(A) = (D);            \
}

/* I can't gain much here because of the frozen registers */
#define Bind_Global(A,D)   Bind(A,D)

#define Bind_Local(A,D)	   Bind(A,D)

#define BIND_GLOBAL(A,D,L)   Bind(A,D)

#define BIND_GLOBAL2(A,D,L1,L2)   Bind(A,D)

#define BIND_GLOBALCELL(A,D)   Bind(A,D); continue

#else /* YAPOR */
#ifdef TABLING
#define DO_TRAIL(TERM, VAL)      \
{                                \
  register tr_fr_ptr r;          \
  r = TR;                        \
  TR = r + 1;                    \
  TrailTerm(r) = (CELL) (TERM);  \
  TrailVal(r) = (VAL);           \
}

#define DO_MATRAIL(TERM, OLDVAL, VAL)    \
{                                \
  register tr_fr_ptr r = TR+1;          \
  TrailTerm(TR) = (OLDVAL);  /* disgusting hack */                \
  TR = r + 1;                    \
  TrailTerm(r) = AbsAppl((CELL *)(TERM));  \
  TrailVal(r) = (NEWVAL);        \
}
 
#define TRAIL(TERM, VAL)                          \
        if (Unsigned((Int)(TERM)-(Int)(HBREG)) >  \
            Unsigned((Int)(B)-(Int)(HBREG)))      \
        DO_TRAIL(TERM, VAL)

#define MATRAIL(TERM, OVAL, VAL)                  \
        if (Unsigned((Int)(TERM)-(Int)(HBREG)) >  \
            Unsigned((Int)(B)-(Int)(HBREG)))      \
        DO_MATRAIL(TERM, OVAL, VAL)

#define TRAIL_GLOBAL(TERM, VAL)                   \
 	if ((TERM) < HBREG) DO_TRAIL(TERM, VAL)

#define TRAIL_LOCAL(TERM, VAL)                    \
 	if ((TERM) > (CELL *)B) DO_TRAIL(TERM, VAL)

#define TRAIL_REF(REF)     TrailTerm(TR++) = AbsPair(((CELL *)(REF)))

#define Bind(A,D)          { TRAIL(A,D); *(A) = (D); }

#define MaBind(A,D)        { MATRAIL(A,*(A),D); *(A) = (D); }

#define Bind_Global(A,D)   { TRAIL_GLOBAL(A,D); *(A) = (D); }

#define Bind_Local(A,D)	   { TRAIL_LOCAL(A,D); *(A) = (D); }

#else /* TABLING */

#ifdef i386

#define DO_TRAIL(A)                     \
{					\
  register tr_fr_ptr r; 		\
  r = TR;				\
  TR = r+1;				\
  TrailTerm(r) = (CELL)(A);		\
}


#define TRAIL(A)        if (Unsigned((Int)(A)-(Int)(HBREG)) >            \
 			    Unsigned((Int)(B)-(Int)(HBREG)))             \
				DO_TRAIL(A);

#define TRAIL_GLOBAL(A)	if ((A) < HBREG) DO_TRAIL(A);

#define TRAIL_LOCAL(A)	if ((A) > (CELL *)B) DO_TRAIL(A);


#elif __alpha

/* alpha machines have a move conditional instruction, which avoids a
   branch when jumping */
#define TRAIL(A)        TrailTerm(TR) = (CELL)(A);                       \
                        if (Unsigned((Int)(A)-(Int)(HBREG)) >            \
 			    Unsigned((Int)(B)-(Int)(HBREG)))             \
                            TR++

#define TRAIL_GLOBAL(A)	TR[0] = (CELL)(A); if ((A) < HBREG) TR++

#define TRAIL_LOCAL(A)	TR[0] = (CELL)(A); if ((A) > ((CELL *)(B)))  TR++

#else

#define DO_TRAIL(A)     TrailTerm(TR++) = (CELL)(A)

#define TRAIL(A)        if (Unsigned((Int)(A)-(Int)(HBREG)) >           \
 			    Unsigned((Int)(B)-(Int)(HBREG)))            \
                              DO_TRAIL(A)

#define TRAIL_GLOBAL(A)	if ((A) < HBREG) DO_TRAIL(A)

#define TRAIL_LOCAL(A)	if ((A) > ((CELL *)B))  DO_TRAIL(A)

#endif /* i386, _alpha */

#define TRAIL_REF(Ref)  (TrailTerm(TR++) = AbsPair(((CELL *)(Ref))))

/************************************************************

BINDING MACROS

A contains the address of the variable that is to be bound
D contains the value it will be bound to

*************************************************************/

#define Bind(A,D)          	 { TRAIL(A); *(A) = (D); }

#define Bind_Global(A,D)         { TRAIL_GLOBAL(A); *(A) = (D); }

#define Bind_Local(A,D)		 { TRAIL_LOCAL(A); *(A) = (D); }

/************************************************************

Binding Macros for Multiple Assignment Variables.

************************************************************/

#define MA_TRAIL(A)    if (Unsigned((Int)(A)-(Int)(HBREG)) >          \
 			    Unsigned((Int)(B)-(Int)(HBREG)))          \
                              { TrailTerm(TR++) = *(A);               \
                                TrailTerm(TR++) = AbsAppl(A);         \
                              }

#define MaBind(A,D)    { MA_TRAIL(A); *(A) = (D); }

#endif /* TABLING */
#endif /* YAPOR */

#ifdef YAPOR

/* these two fields are used for memory management with the
   clean_up_node instruction in the YAPOR/SBA implementation  */
#define CP_FREE(B)        ((int)((B)->cp_env))
#define CP_NEXT(B)        ((choiceptr)((B)->cp_cp))

#endif /* YAPOR */

#define DBIND(A,D,L)  BIND(A,D,L)

#define EQ_OK_IN_CMP 1
#define LT_OK_IN_CMP 2
#define GT_OK_IN_CMP 4