YAP 7.1.0
Yap.h
Go to the documentation of this file.
1/*************************************************************************
2* *
3* YAP Prolog %W% %G% *
4* Yap Prolog was developed at NCCUP - Universidade do Porto *
5* *
6* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
7* *
8**************************************************************************
9* *
10* File: Yap.h *
11* mods: *
12* comments: main header file for YAP *
13* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ *
14*************************************************************************/
15
29#ifndef YAP_H
30
31#define YAP_H 1
32
33#include "YapConfig.h"
34
35#define USE_MYDDAS 1
36#define USE_MYDDAS_SQLITE3 1
37
38#if defined(YAPOR)
39// #error Do not explicitly define YAPOR
40#endif /* YAPOR */
41
42#if (defined(YAPOR_COPY) && \
43 (defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS))) || \
44 (defined(YAPOR_COW) && (defined(YAPOR_SBA) || defined(YAPOR_THREADS))) || \
45 (defined(YAPOR_SBA) && defined(YAPOR_THREADS))
46#error Do not define multiple or-parallel models
47#endif /* (YAPOR_COPY && (YAPOR_COW || YAPOR_SBA || YAPOR_THREADS)) || \
48 (YAPOR_COW && (YAPOR_SBA || YAPOR_THREADS)) || (YAPOR_SBA || \
49 YAPOR_THREADS) */
50
51#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) || \
52 defined(YAPOR_THREADS)
53#define YAPOR 1
54#define FIXED_STACKS 1
55#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA || YAPOR_THREADS */
56
57#if defined(TABLING) && \
58 (defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS))
59#error TABLING only works with YAPOR_COPY
60#endif /* TABLING && (YAPOR_COW || YAPOR_SBA || YAPOR_THREADS) */
61
62#if defined(THREADS) && \
63 (defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_COPY))
64#error THREADS only works with YAPOR_THREADS
65#endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */
66
67// Bad export from Python
68#ifndef COROUTINING
69#define COROUTINING 1
70#endif
71
72#ifndef RATIONAL_TREES
73#define RATIONAL_TREES 1
74#endif
75
76#ifndef CUT_C
77#define CUT_C 1
78#endif
79
80#define FunAdr(X) X
81
82#include "inline-only.h"
83#if defined(YAPOR) || defined(TABLING)
84#include "opt.config.h"
85#endif /* YAPOR || TABLING */
86#if HAVE_STDINT_H
87#include <stdint.h>
88#endif
89
90/*
91
92#define RATIONAL_TREES 1
93#define DEPTH_LIMIT 1
94#define COROUTINING 1
95#define ANALYST 1
96
97*/
98
99#define MULTI_ASSIGNMENT_VARIABLES 1
100
101#if defined(YAPOR) || defined(THREADS)
102#define MULTIPLE_STACKS 1
103#define PARALLEL_YAP 1
104#endif /* YAPOR || THREADS */
105
106#if defined(YAPOR) || defined(TABLING)
107#undef TRAILING_REQUIRES_BRANCH
108#endif /* YAPOR || TABLING */
109
110#if defined(TABLING) || defined(YAPOR_SBA)
111#define FROZEN_STACKS 1
112#endif /* TABLING || YAPOR_SBA */
113
114#if defined(THREADS) || defined(SUPPORT_CONDOR)
115#define USE_SYSTEM_MALLOC 1
116#endif /* THREADS || SUPPORT_CONDOR */
117
118#if defined(ANALYST) && defined(USE_THREADED_CODE)
119#undef USE_THREADED_CODE
120#endif /* ANALYST && USE_THREADED_CODE */
121
122#if defined(COROUTINING) && !defined(TERM_EXTENSIONS)
123#define TERM_EXTENSIONS 1
124#endif /* COROUTINING && !TERM_EXTENSIONS */
125
133#if !defined(nullptr) && !defined(HAVE_NULLPTR)
134#ifndef __cplusplus
135#define nullptr NULL
136#elif defined(__GNUC__)
137#define nullptr __null
138#elif defined(_WIN64)
139#define nullptr 0LL
140#else
141#define nullptr 0L
142#endif
143#endif /* defined(HAVE_NULLPTR) */
144
145
146#ifdef __MINGW32__
147#ifndef _WIN32
148#define _WIN32 1
149#endif /* _WIN32 */
150#endif /* __MINGW32__ */
151
152#if HAVE_GCC && !defined(__cplusplus)
153#define MIN_ARRAY 0
154#define DUMMY_FILLER_FOR_ABS_TYPE
155#else
156#define MIN_ARRAY 1
157#define DUMMY_FILLER_FOR_ABS_TYPE int dummy;
158#endif /* HAVE_GCC */
159
160/* funcions that return a generic pointer */
161typedef void *(*fptr_t)(void);
162
163/*************************************************************************************************
164 main exports in YapInterface.h
165*************************************************************************************************/
166
167extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR,
168 *Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP,*Yap_INPUT_STARTUP,*Yap_OUTPUT_STARTUP,
169 *Yap_BOOTFILE, *Yap_INCLUDEDIR;
170
171/* Basic exports */
172
173#include "YapDefs.h"
174
175#include "Atoms.h"
176
177
178
179/* expect controls the direction of branches */
180
181#ifdef HAVE___BUILTIN_EXPECT
182#define likely(x) __builtin_expect((x), 1)
183#define unlikely(x) __builtin_expect((x), 0)
184#else
185#define likely(x) (x)
186#define unlikely(x) (x)
187#endif
188
189#ifdef THREADS
190#if USE_PTHREAD_LOCKING
191#ifndef _XOPEN_SOURCE
192#define _XOPEN_SOURCE 600
193#endif /* !_XOPEN_SOURCE */
194#endif /* USE_PTHREAD_LOCKING */
195#include <pthread.h>
196#endif /* THREADS */
197
198/* null pointer */
199#define NIL 0
200
201/* Basic types */
202#if HAVE_SIGPROF && (defined(__linux__) || defined(__APPLE__))
203#define LOW_PROF 1
204#endif
205
206#if !defined(HAVE_STRNLEN)
207INLINE_ONLY EXTERN size_t strnlen(const char *s, size_t maxlen);
208
209INLINE_ONLY EXTERN size_t strnlen(const char *s, size_t maxlen) {
210 size_t i = 0;
211 while (s[i]) {
212 if (i == maxlen)
213 return i;
214 i++;
215 }
216 return i;
217}
218#endif
219
220/* #define FORCE_SECOND_QUADRANT 1 */
221
222#if defined(FORCE_SECOND_QUADRANT)
223#define IN_SECOND_QUADRANT 1
224#define MMAP_ADDR 0x42000000
225#endif /* FORCE_SECOND_QUADRANT */
226
227#if !defined(IN_SECOND_QUADRANT)
228#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
229 defined(mips) || defined(__mips64) || defined(__aarch64__) || \
230 (__DragonFly__)
231#if defined(YAPOR) && defined(__alpha)
232
233#define MMAP_ADDR 0x40000000
234#elif defined(mips)
235#define MMAP_ADDR 0x02000000
236#elif defined(__mips64)
237#define MMAP_ADDR 0x02000000
238#elif defined(__aarch64__)
239#define MMAP_ADDR 0x02000000
240#elif defined(__powerpc__)
241#define MMAP_ADDR 0x20000000
242#else
243#define MMAP_ADDR 0x10000000
244#endif /* YAPOR && __alpha */
245#elif __svr4__ || defined(__SVR4)
246#define MMAP_ADDR 0x02000000
247#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || mips || __mips64 || \
248 __APPLE__ || \
249 __DragonFly__ */
250#endif /* !IN_SECOND_QUADRANT */
251
252/* #define RANDOMIZE_START_ADDRESS 1 */
253
254extern size_t Yap_page_size;
255
256#ifdef USE_SYSTEM_MALLOC
257#define HEAP_INIT_BASE 0L
258#define AtomBase NULL
259#else /* !USE_SYSTEM_MALLOC */
260#if defined(MMAP_ADDR) && (defined(USE_MMAP) || USE_SHMAT) && \
261 !defined(__simplescalar__) && !defined(RANDOMIZE_START_ADDRESS)
262#define HEAP_INIT_BASE (MMAP_ADDR)
263#define AtomBase ((char *)MMAP_ADDR)
264#else
266#define HEAP_INIT_BASE ((CELL)Yap_HeapBase)
267#define AtomBase (Yap_HeapBase)
268#endif /* MMAP_ADDR && (USE_MMAP || USE_SHMAT) && !__simplescalar__ && \
269 !RANDOMIZE_START_ADDRESS */
270#endif /* USE_SYSTEM_MALLOC */
271
272#ifndef ALIGN_LONGS
273#define ALIGN_LONGS 1
274#endif
275
276#define K1 ((CELL)1024)
277#define K16 ((CELL)(1024 * 64))
278#define K64 ((CELL)(1024 * 64))
279#define M1 ((CELL)(1024 * 1024))
280#define M2 ((CELL)(2048 * 1024))
281
282#if ALIGN_LONGS
283typedef CELL SFLAGS;
284#else
285typedef BITS16 SFLAGS;
286#endif
287
288typedef char *ADDR;
289typedef CELL OFFSET;
290typedef unsigned char *CODEADDR;
291
292#define TermPtr(V) ((Term *)(V))
293#define Addr(V) ((ADDR)(V))
294
295#define CodePtr(V) ((CODEADDR)(V))
296#define CellPtr(V) ((CELL *)(V))
297#define OpCodePtr(V) ((OPCODE *)(V))
298#define OpRegPtr(V) ((OPREG *)(V))
299#define SmallPtr(V) ((SMALLUNSGN *)(V))
300#define WordPtr(V) ((BITS16 *)(V))
301#define DisplPtr(V) ((DISPREG *)(V))
302
303#if !defined(YAPOR) && !defined(THREADS)
304#include <nolocks.h>
305#else
306
307#ifndef _XOPEN_SOURCE
308#define _XOPEN_SOURCE 600
309#endif
310
311#include <locks_pthread.h>
312typedef pthread_mutex_t lockvar;
313typedef pthread_rwlock_t rwlock_t;
314#endif
315/*
316#elif defined(i386)|| defined(__x86_64__)
317typedef volatile int lockvar;
318#include <locks_x86.h>
319#elif defined(sparc) || defined(__sparc)
320typedef volatile int lockvar;
321#include <locks_sparc.h>
322#elif defined(__alpha)
323typedef volatile int lockvar;
324#include <locks_alpha.h>
325#else
326
327#ifndef _XOPEN_SOURCE
328#define _XOPEN_SOURCE 600
329#endif
330 */
331
332#define FUNC_READ_LOCK(X) READ_LOCK((X)->FRWLock)
333#define FUNC_READ_UNLOCK(X) READ_UNLOCK((X)->FRWLock)
334#define FUNC_WRITE_LOCK(X) WRITE_LOCK((X)->FRWLock)
335#define FUNC_WRITE_UNLOCK(X) WRITE_UNLOCK((X)->FRWLock)
336
337/*************************************************************************************************
338 use an auxiliary function for ranges
339*************************************************************************************************/
340
341#ifdef __GNUC__
342#define IN_BETWEEN(MIN, X, MAX) \
343 (Unsigned((Int)(X) - (Int)(MIN)) <= Unsigned((Int)(MAX) - (Int)(MIN)))
344
345#define OUTSIDE(MIN, X, MAX) \
346 (Unsigned((Int)(X) - (Int)(MIN)) > Unsigned((Int)(MAX) - (Int)(MIN)))
347#else
348#define IN_BETWEEN(MIN, X, MAX) \
349 ((void *)(X) >= (void *)(MIN) && (void *)(X) <= (void *)(MAX))
350
351#define OUTSIDE(MIN, X, MAX) \
352 ((void *)(X) < (void *)(MIN) || (void *)(X) > (void *)(MAX))
353#endif
354
355/*************************************************************************************************
356 prototypes
357*************************************************************************************************/
358
359#include "YapTags.h"
360
361#include "YapCompoundTerm.h"
362
363#define TermSize sizeof(Term)
364
365
366/*************************************************************************************************
367 Atoms
368*************************************************************************************************/
369
370#include "Atoms.h"
371
372/*************************************************************************************************
373 Coroutining
374*************************************************************************************************/
375
376#ifdef COROUTINING
377/* Support for co-routining */
378#include "corout.h"
379#endif
380
381/*************************************************************************************************
382 abstract machine registers
383*************************************************************************************************/
384
385#include "amidefs.h"
386
387#include "Regs.h"
388
389#include "Yapproto.h"
390
391
392/*************************************************************************************************
393 unification routines
394*************************************************************************************************/
395
396#ifdef YAPOR_SBA
397#include "or.sba_amiops.h"
398#include "or.sba_unify.h"
399#else
400#include "amiops.h"
401#endif /* YAPOR_SBA */
402
403/*************************************************************************************************
404 OPTYAP includes
405*************************************************************************************************/
406
407#if defined(YAPOR) || defined(TABLING)
408#include "opt.structs.h"
409
410#include "opt.proto.h"
411
412#include "opt.macros.h"
413
414#endif /* YAPOR || TABLING */
415
416/*************************************************************************************************
417 variables concerned with Error Handling
418*************************************************************************************************/
419
420#if HAVE_SETJMP_H
421#include <setjmp.h>
422#if defined(SIMICS)
423#define sigjmp_buf jmp_buf
424#define sigsetjmp(Env, Arg) setjmp(Env)
425#define siglongjmp(Env, Arg) longjmp(Env, Arg)
426#endif
427#endif
428
429/* Support for arrays */
430#include "arrays.h"
431
432#include "gprof.h"
433
434#include "YapError.h"
435
436#define MAX_EMPTY_WAKEUPS 16
437
438/*************************************************************************************************
439 variables related to memory allocation
440*************************************************************************************************/
441/* must be before TermExt.h */
442
443extern ADDR Yap_HeapBase;
444
445/* This is ok for Linux, should be ok for everyone */
446#define MAX_PATH 1024
447
448
449/*************************************************************************************************
450 Debugging Support
451*************************************************************************************************/
452
453#ifdef DEBUG
454extern int Yap_output_msg;
455#endif
456
457#if __ANDROID__
458
459#include <android/asset_manager.h>
460#include <android/asset_manager_jni.h>
461#include <android/log.h>
462#include <jni.h>
463
464extern AAssetManager *Yap_assetManager(void);
465
466extern void *Yap_openAssetFile(const char *path);
467extern bool Yap_isAsset(const char *path);
468extern bool Yap_AccessAsset(const char *name, int mode);
469extern bool Yap_AssetIsFile(const char *name);
470extern bool Yap_AssetIsDir(const char *name);
471extern int64_t Yap_AssetSize(const char *name);
472
473#else
474
475#define __android_log_print(...)
476
477#endif
478
479/*************************************************************************************************
480 variables concerned with atoms table
481*************************************************************************************************/
482
483#define MaxHash 3333
484#define MaxWideHash (MaxHash / 10 + 1)
485
486typedef enum e_restore_t {
487 FAIL_RESTORE = 0,
488 DO_EVERYTHING = 1,
489 DO_ONLY_CODE = 2,
490 YAP_BOOT_FROM_PROLOG = 4
491} restore_t;
492
493/*************************************************************************************************
494 common instructions codes
495*************************************************************************************************/
496
497#define MAX_PROMPT 256
498
499/*************************************************************************************************
500 number of modules
501*************************************************************************************************/
502
503#define DefaultMaxModules 256
504
505/*************************************************************************************************
506 Critical sections
507*************************************************************************************************/
508#ifdef YAPOR
509#define YAPEnterCriticalSection() \
510 { \
511 if (worker_id != GLOBAL_locks_who_locked_heap) { \
512 LOCK(GLOBAL_locks_heap_access); \
513 GLOBAL_locks_who_locked_heap = worker_id; \
514 } \
515 LOCAL_PrologMode |= CritMode; \
516 LOCAL_CritLocks++; \
517 }
518#define YAPLeaveCriticalSection() \
519 { \
520 LOCAL_CritLocks--; \
521 if (!LOCAL_CritLocks) { \
522 LOCAL_PrologMode &= ~CritMode; \
523 if (LOCAL_PrologMode & AbortMode) { \
524 LOCAL_PrologMode &= ~AbortMode; \
525 Yap_Error(ABORT_EVENT, 0, ""); \
526 } \
527 GLOBAL_locks_who_locked_heap = MAX_WORKERS; \
528 UNLOCK(GLOBAL_locks_heap_access); \
529 } \
530 }
531#elif defined(THREADS)
532#define YAPEnterCriticalSection() \
533 { \
534 /* LOCK(BGL); */ \
535 LOCAL_PrologMode |= CritMode; \
536 }
537#define YAPLeaveCriticalSection() \
538 { \
539 LOCAL_PrologMode &= ~CritMode; \
540 if (LOCAL_PrologMode & AbortMode) { \
541 LOCAL_PrologMode &= ~AbortMode; \
542 Yap_Error(ABORT_EVENT, 0, ""); \
543 Yap_RestartYap(1); \
544 } \
545 /* UNLOCK(BGL); */ \
546 }
547#else
548#define YAPEnterCriticalSection() \
549 { \
550 LOCAL_PrologMode |= \
551 CritMode; /* printf("%d, \
552 %s:%d\n",LOCAL_CritLocks+1,__FILE__,__LINE__);*/ \
553 LOCAL_CritLocks++; \
554 }
555#define YAPLeaveCriticalSection() \
556 { \
557 LOCAL_CritLocks--; \
558 /*printf("%d, %s:%d\n",LOCAL_CritLocks,__FILE__,__LINE__);*/ \
559 if (!LOCAL_CritLocks) { \
560 LOCAL_PrologMode &= ~CritMode; \
561 if (LOCAL_PrologMode & AbortMode) { \
562 LOCAL_PrologMode &= ~AbortMode; \
563 Yap_RestartYap(1); \
564 } \
565 } \
566 }
567#endif /* YAPOR */
568
569/* when we are calling the InitStaff procedures */
570#define AT_BOOT 0
571#define AT_RESTORE 1
572
573/*************************************************************************************************
574 mutable variables
575*************************************************************************************************/
576
577/* I assume that the size of this structure is a multiple of the size
578 of CELL!!! */
579typedef struct TIMED_MAVAR {
580 CELL value;
581 CELL clock;
582} timed_var;
583
584/*************************************************************************************************
585 execution mode
586*************************************************************************************************/
587
588typedef enum {
589 INTERPRETED = 0x1, /* interpreted */
590 MIXED_MODE_USER = 0x2, /* mixed mode only for user predicates */
591 MIXED_MODE_ALL = 0x4, /* mixed mode for all predicates */
592 COMPILE_USER = 0x8, /* compile all user predicates*/
593 COMPILE_ALL = 0x10 /* compile all predicates */
594} yap_exec_mode;
595
596#define MIXED_MODE (MIXED_MODE_USER | MIXED_MODE_ALL)
597
598#define COMPILED (COMPILE_USER | COMPILE_ALL)
599
600/************************/
601// queues are an example of collections of DB objects
602typedef struct queue_entry {
603 struct queue_entry *next;
604 struct DB_TERM *DBT;
605} QueueEntry;
607typedef struct idb_queue {
608 struct FunctorEntryStruct
609 *id; /* identify this as being pointed to by a DBRef */
610 SMALLUNSGN Flags; /* always required */
611#if PARALLEL_YAP
612 rwlock_t QRWLock; /* a simple lock to protect this entry */
613#endif
614 QueueEntry *FirstInQueue, *LastInQueue;
615} db_queue;
616
617void Yap_init_tqueue(db_queue *dbq);
618void Yap_destroy_tqueue(db_queue *dbq USES_REGS);
619bool Yap_enqueue_tqueue(db_queue *father_key, Term t USES_REGS);
620bool Yap_dequeue_tqueue(db_queue *father_key, Term t, bool first,
621 bool release USES_REGS);
622
623#ifdef THREADS
624
625typedef struct thread_mbox {
626 Term name;
627 pthread_mutex_t mutex;
628 pthread_cond_t cond;
629 struct idb_queue msgs;
630 int nmsgs, nclients; // if nclients < 0 mailbox has been closed.
631 bool open;
632 struct thread_mbox *next;
633} mbox_t;
634
635typedef struct thandle {
636 int in_use;
637 int zombie;
638 UInt ssize;
639 UInt tsize;
640 UInt sysize;
641 void *stack_address;
642 Term tdetach;
643 Term cmod, texit_mod;
644 struct DB_TERM *tgoal, *texit;
645 int id;
646 int ret;
647 REGSTORE *default_yaam_regs;
648 REGSTORE *current_yaam_regs;
649 struct pred_entry *local_preds;
650 pthread_t pthread_handle;
651 mbox_t mbox_handle;
652 int ref_count;
653#ifdef LOW_LEVEL_TRACER
654 long long int thread_inst_count;
655 int been_here1;
656 int been_here2;
657#endif
658#ifdef DEBUG
659 int been_here;
660#endif
661 pthread_mutex_t tlock;
662 pthread_mutex_t tlock_status;
663#if HAVE_GETHRTIME
664 hrtime_t start_of_w_times;
665 hrtime_t last_w_time;
666#endif
667#if HAVE_GETRUSAGE
668 struct timeval *start_of_timesp;
669 struct timeval *last_timep;
670 struct timeval *start_of_times_sysp;
671 struct timeval *last_time_sysp;
672#elif _WIN32
673 win64_time_t *start_of_timesp;
674 win64_time_t *last_timep;
675 win64_time_t *start_of_times_sysp;
676 win64_time_t *last_time_sysp;
677#endif
678} yap_thandle;
679#endif /* THREADS */
680
681#define GC_MAVARS_HASH_SIZE 512
682typedef struct gc_ma_hash_entry_struct {
683 UInt timestmp;
684#ifdef TABLING
685 tr_fr_ptr loc;
686 struct gc_ma_hash_entry_struct *more;
687#endif
688 CELL *addr;
689 struct gc_ma_hash_entry_struct *next;
691
692typedef int (*Agc_hook)(Atom);
694typedef struct scratch_block_struct {
695 char *ptr;
696 UInt sz, msz;
698
699/* scanner types */
700#include "ScannerTypes.h"
701
702/*************************************************************************************************
703 GLOBAL and LOCAL variables
704*************************************************************************************************/
705
706#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
707extern struct global_data *Yap_global;
708extern long Yap_worker_area_size;
709#else
710extern struct global_data Yap_Global;
711#define Yap_global (&Yap_Global)
712#endif
713
714#if defined(THREADS)
715extern struct worker_local *Yap_local[MAX_THREADS];
716#define REMOTE(wid) (Yap_local[wid])
717#elif defined(YAPOR)
718extern struct worker_local *Yap_local;
719#define REMOTE(wid) (Yap_local + wid)
720#else /* !THREADS && !YAPOR */
721extern struct worker_local Yap_local;
722#define REMOTE(wid) (&Yap_local)
723#endif
724
725#include "encoding.h"
726
727#include <stdio.h>
728#define YP_FILE FILE
729
730/*************************************************************************************************
731 unification support
732*************************************************************************************************/
733
734#include "YapHandles.h"
735
736// take care of signal handling within YAP
737
738#include "YapSignals.h"
739
740#define must_be_variable(t) if (!IsVarTerm(t)) Yap_ThrowError(UNINSTANTIATION_ERROR, v, NULL)
741
742INLINE_ONLY Term must_be_module(Term t) {
743 t = Deref(t);
744 if (IsVarTerm(t)) Yap_ThrowError(INSTANTIATION_ERROR, t, NULL);
745 if (!IsAtomTerm(t)) Yap_ThrowError(TYPE_ERROR_ATOM, t, NULL);
746 return t;
747}
748
749INLINE_ONLY Term must_be_integer(Term t) {
750 t = Deref(t);
751 if (IsVarTerm(t)) Yap_ThrowError(INSTANTIATION_ERROR, t, NULL);
752 if (!IsIntegerTerm(t)) Yap_ThrowError(TYPE_ERROR_INTEGER, t, NULL);
753 return t;
754}
755
756 INLINE_ONLY Term must_be_unbound(Term t) {
757 t = Deref(t);
758 if (!IsVarTerm(t)) Yap_ThrowError(UNINSTANTIATION_ERROR, t, NULL);
759 return t;
760}
761
762/*************************************************************************************************
763Global variables for JIT
764*************************************************************************************************/
765
766#if YAP_JIT
767#ifndef __cplusplus
768#ifndef _NATIVE
769#include "JIT.hpp"
770#endif
771#endif
772#endif
773
774#if DEBUGX
775inline static void LOG0(const char *f, int l, const char *fmt, ...) {
776 va_list ap;
777 va_start(ap, fmt);
778#if __ANDROID__
779 __android_log_print(ANDROID_LOG_INFO, "YAP ", fmt, ap);
780#else __WINDOWS__
781 FILE *fd;
782 fd = fopen("c:\\cygwin\\Log.txt", "a");
783 vfprintf(fd, fmt, ap);
784 fclose(fd);
785#endif
786 vfprintf(stderr, fmt, ap);
787 va_end(ap);
788}
789
790#define LOG(...) LOG0(__FILE__, __LINE__, __VA_ARGS__)
791
792#define REGS_LOG(...) CACHE_REGS LOG0(__FILE__, __LINE__, __VA_ARGS__)
793
794#else
795#define LOG(...)
796
797#define REGS_LOG(...)
798#endif
799
800// YAP lexicon
801
802#include "GitSHA1.h"
803
804extern bool Yap_Embedded, Yap_Server;
805
806#include "YapText.h"
807
808#endif /* YAP_H */
809
810
Definition: Yatom.h:689
Definition: Yap.h:681
Definition: Yap.h:606
Definition: Yatom.h:544
Definition: Yap.h:601