small fixes

This commit is contained in:
Vitor Santos Costa 2016-07-31 10:31:22 -05:00
parent 43993f2b08
commit 4477350d08
14 changed files with 690 additions and 601 deletions

View File

@ -67,22 +67,22 @@
#include "inline-only.h" #include "inline-only.h"
INLINE_ONLY int IsVarTerm (Term); INLINE_ONLY bool IsVarTerm (Term);
INLINE_ONLY int INLINE_ONLY bool
IsVarTerm (Term t) IsVarTerm (Term t)
{ {
return (int) (Signed (t) >= 0); return Signed (t) >= 0;
} }
INLINE_ONLY int IsNonVarTerm (Term); INLINE_ONLY bool IsNonVarTerm (Term);
INLINE_ONLY int INLINE_ONLY bool
IsNonVarTerm (Term t) IsNonVarTerm (Term t)
{ {
return (int) (Signed (t) < 0); return Signed (t) < 0;
} }
@ -107,12 +107,12 @@ AbsPair (Term * p)
INLINE_ONLY Int IsPairTerm (Term); INLINE_ONLY bool IsPairTerm (Term);
INLINE_ONLY Int INLINE_ONLY bool
IsPairTerm (Term t) IsPairTerm (Term t)
{ {
return (Int) (BitOn (PairBit, (t))); return BitOn (PairBit, (t));
} }
@ -137,22 +137,22 @@ AbsAppl (Term * p)
INLINE_ONLY Int IsApplTerm (Term); INLINE_ONLY bool IsApplTerm (Term);
INLINE_ONLY Int INLINE_ONLY bool
IsApplTerm (Term t) IsApplTerm (Term t)
{ {
return (Int) (BitOn (ApplBit, (t))); return BitOn (ApplBit, (t));
} }
INLINE_ONLY Int IsAtomOrIntTerm (Term); INLINE_ONLY bool IsAtomOrIntTerm (Term);
INLINE_ONLY Int INLINE_ONLY bool
IsAtomOrIntTerm (Term t) IsAtomOrIntTerm (Term t)
{ {
return (Int) (!(Unsigned (t) & CompBits)); return !(Unsigned (t) & CompBits);
} }

View File

@ -243,9 +243,9 @@ OOPS
#include <stddef.h> #include <stddef.h>
#endif #endif
INLINE_ONLY inline EXTERN int IsFloatTerm(Term); INLINE_ONLY inline EXTERN bool IsFloatTerm(Term);
INLINE_ONLY inline EXTERN int IsFloatTerm(Term t) { INLINE_ONLY inline EXTERN bool IsFloatTerm(Term t) {
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble); return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
} }
@ -269,10 +269,11 @@ INLINE_ONLY inline EXTERN Int LongIntOfTerm(Term t) {
return (Int)(RepAppl(t)[1]); return (Int)(RepAppl(t)[1]);
} }
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term); INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term);
INLINE_ONLY inline EXTERN int IsLongIntTerm(Term t) { INLINE_ONLY inline EXTERN bool IsLongIntTerm(Term t) {
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt); return IsApplTerm(t) &&
FunctorOfTerm(t) == FunctorLongInt;
} }
/****************************************************/ /****************************************************/
@ -325,10 +326,11 @@ INLINE_ONLY inline EXTERN const char *StringOfTerm(Term t) {
return (const char *)(RepAppl(t) + 2); return (const char *)(RepAppl(t) + 2);
} }
INLINE_ONLY inline EXTERN int IsStringTerm(Term); INLINE_ONLY inline EXTERN bool IsStringTerm(Term);
INLINE_ONLY inline EXTERN int IsStringTerm(Term t) { INLINE_ONLY inline EXTERN bool IsStringTerm(Term t) {
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorString); return IsApplTerm(t) &&
FunctorOfTerm(t) == FunctorString;
} }
/****************************************************/ /****************************************************/
@ -357,10 +359,11 @@ typedef struct {
#endif #endif
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term); INLINE_ONLY inline EXTERN bool IsBigIntTerm(Term);
INLINE_ONLY inline EXTERN int IsBigIntTerm(Term t) { INLINE_ONLY inline EXTERN bool IsBigIntTerm(Term t) {
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt); return IsApplTerm(t) &&
FunctorOfTerm(t) == FunctorBigInt;
} }
#ifdef USE_GMP #ifdef USE_GMP
@ -379,11 +382,12 @@ INLINE_ONLY inline EXTERN void MPZ_SET(mpz_t dest, MP_INT *src) {
dest->_mp_d = src->_mp_d; dest->_mp_d = src->_mp_d;
} }
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term); INLINE_ONLY inline EXTERN bool IsLargeIntTerm(Term);
INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) { INLINE_ONLY inline EXTERN bool IsLargeIntTerm(Term t) {
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && return IsApplTerm(t) &&
(FunctorOfTerm(t) >= FunctorLongInt))); ((FunctorOfTerm(t) <= FunctorBigInt) &&
(FunctorOfTerm(t) >= FunctorLongInt));
} }
INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term); INLINE_ONLY inline EXTERN UInt Yap_SizeOfBigInt(Term);
@ -407,18 +411,20 @@ INLINE_ONLY inline EXTERN int IsLargeIntTerm(Term t) {
/* extern Functor FunctorLongInt; */ /* extern Functor FunctorLongInt; */
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term); INLINE_ONLY inline EXTERN bool IsLargeNumTerm(Term);
INLINE_ONLY inline EXTERN int IsLargeNumTerm(Term t) { INLINE_ONLY inline EXTERN bool IsLargeNumTerm(Term t) {
return (int)(IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && return IsApplTerm(t) &&
(FunctorOfTerm(t) >= FunctorDouble))); ((FunctorOfTerm(t) <= FunctorBigInt) &&
(FunctorOfTerm(t) >= FunctorDouble));
} }
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term, CELL); INLINE_ONLY inline EXTERN bool IsExternalBlobTerm(Term, CELL);
INLINE_ONLY inline EXTERN int IsExternalBlobTerm(Term t, CELL tag) { INLINE_ONLY inline EXTERN bool IsExternalBlobTerm(Term t, CELL tag) {
return (int)(IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt && return IsApplTerm(t) &&
RepAppl(t)[1] == tag); FunctorOfTerm(t) == FunctorBigInt &&
RepAppl(t)[1] == tag;
} }
INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term); INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term);
@ -428,63 +434,69 @@ INLINE_ONLY inline EXTERN void *ExternalBlobFromTerm(Term t) {
return (void *)(base + 1); return (void *)(base + 1);
} }
INLINE_ONLY inline EXTERN int IsNumTerm(Term); INLINE_ONLY inline EXTERN bool IsNumTerm(Term);
INLINE_ONLY inline EXTERN int IsNumTerm(Term t) { INLINE_ONLY inline EXTERN bool IsNumTerm(Term t) {
return (int)((IsIntTerm(t) || IsLargeNumTerm(t))); return (IsIntTerm(t) || IsLargeNumTerm(t));
} }
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term); INLINE_ONLY inline EXTERN bool IsAtomicTerm(Term);
INLINE_ONLY inline EXTERN Int IsAtomicTerm(Term t) { INLINE_ONLY inline EXTERN bool IsAtomicTerm(Term t) {
return (Int)(IsAtomOrIntTerm(t) || IsLargeNumTerm(t) || IsStringTerm(t)); return IsAtomOrIntTerm(t) ||
IsLargeNumTerm(t) ||
IsStringTerm(t);
} }
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor); INLINE_ONLY inline EXTERN bool IsExtensionFunctor(Functor);
INLINE_ONLY inline EXTERN Int IsExtensionFunctor(Functor f) { INLINE_ONLY inline EXTERN bool IsExtensionFunctor(Functor f) {
return (Int)(f <= FunctorString); return f <= FunctorString;
} }
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor); INLINE_ONLY inline EXTERN bool IsBlobFunctor(Functor);
INLINE_ONLY inline EXTERN Int IsBlobFunctor(Functor f) { INLINE_ONLY inline EXTERN bool IsBlobFunctor(Functor f) {
return (Int)((f <= FunctorString && f >= FunctorDBRef)); return (f <= FunctorString &&
f >= FunctorDBRef);
} }
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term); INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term);
INLINE_ONLY inline EXTERN Int IsPrimitiveTerm(Term t) { INLINE_ONLY inline EXTERN bool IsPrimitiveTerm(Term t) {
return (Int)((IsAtomOrIntTerm(t) || return (IsAtomOrIntTerm(t) ||
(IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t))))); (IsApplTerm(t) &&
IsBlobFunctor(FunctorOfTerm(t))));
} }
#ifdef TERM_EXTENSIONS #ifdef TERM_EXTENSIONS
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor); INLINE_ONLY inline EXTERN bool IsAttachFunc(Functor);
INLINE_ONLY inline EXTERN Int IsAttachFunc(Functor f) { return (Int)(FALSE); } INLINE_ONLY inline EXTERN bool IsAttachFunc(Functor f) { return (Int)(FALSE); }
#define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS) #define IsAttachedTerm(t) __IsAttachedTerm(t PASS_REGS)
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term USES_REGS); INLINE_ONLY inline EXTERN bool __IsAttachedTerm(Term USES_REGS);
INLINE_ONLY inline EXTERN Int __IsAttachedTerm(Term t USES_REGS) { INLINE_ONLY inline EXTERN bool __IsAttachedTerm(Term t USES_REGS) {
return (Int)((IsVarTerm(t) && IsAttVar(VarOfTerm(t)))); return (IsVarTerm(t) &&
IsAttVar(VarOfTerm(t)));
} }
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term); INLINE_ONLY inline EXTERN bool GlobalIsAttachedTerm(Term);
INLINE_ONLY inline EXTERN Int GlobalIsAttachedTerm(Term t) { INLINE_ONLY inline EXTERN bool GlobalIsAttachedTerm(Term t) {
return (Int)((IsVarTerm(t) && GlobalIsAttVar(VarOfTerm(t)))); return (IsVarTerm(t) &&
GlobalIsAttVar(VarOfTerm(t)));
} }
#define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS) #define SafeIsAttachedTerm(t) __SafeIsAttachedTerm((t)PASS_REGS)
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term USES_REGS); INLINE_ONLY inline EXTERN bool __SafeIsAttachedTerm(Term USES_REGS);
INLINE_ONLY inline EXTERN Int __SafeIsAttachedTerm(Term t USES_REGS) { INLINE_ONLY inline EXTERN bool __SafeIsAttachedTerm(Term t USES_REGS) {
return (Int)(IsVarTerm(t) && IsAttVar(VarOfTerm(t))); return IsVarTerm(t) && IsAttVar(VarOfTerm(t));
} }
INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *); INLINE_ONLY inline EXTERN exts ExtFromCell(CELL *);
@ -523,13 +535,13 @@ INLINE_ONLY inline EXTERN void *Yap_BlobInfo(Term t) {
#ifdef YAP_H #ifdef YAP_H
INLINE_ONLY inline EXTERN int unify_extension(Functor, CELL, CELL *, CELL); INLINE_ONLY inline EXTERN bool unify_extension(Functor, CELL, CELL *, CELL);
EXTERN int unify_extension(Functor, CELL, CELL *, CELL); EXTERN bool unify_extension(Functor, CELL, CELL *, CELL);
int Yap_gmp_tcmp_big_big(Term, Term); int Yap_gmp_tcmp_big_big(Term, Term);
INLINE_ONLY inline EXTERN int unify_extension(Functor f, CELL d0, CELL *pt0, INLINE_ONLY inline EXTERN bool unify_extension(Functor f, CELL d0, CELL *pt0,
CELL d1) { CELL d1) {
switch (BlobOfFunctor(f)) { switch (BlobOfFunctor(f)) {
case db_ref_e: case db_ref_e:
@ -555,7 +567,7 @@ INLINE_ONLY inline EXTERN int unify_extension(Functor f, CELL d0, CELL *pt0,
); );
} }
} }
return (FALSE); return false;
} }
static inline CELL Yap_IntP_key(CELL *pt) { static inline CELL Yap_IntP_key(CELL *pt) {

13
H/Yap.h
View File

@ -17,6 +17,9 @@
#define YAP_H 1 #define YAP_H 1
#define USE_MYDDAS 1
#define USE_MYDDAS_SQLITE3 1
#if defined(YAPOR) #if defined(YAPOR)
// #error Do not explicitly define YAPOR // #error Do not explicitly define YAPOR
#endif /* YAPOR */ #endif /* YAPOR */
@ -256,6 +259,11 @@ INLINE_ONLY inline EXTERN size_t strnlen(const char *s, size_t maxlen) {
/* #define RANDOMIZE_START_ADDRESS 1 */ /* #define RANDOMIZE_START_ADDRESS 1 */
extern size_t Yap_page_size;
#ifdef USE_SYSTEM_MALLOC #ifdef USE_SYSTEM_MALLOC
#define HEAP_INIT_BASE 0L #define HEAP_INIT_BASE 0L
#define AtomBase NULL #define AtomBase NULL
@ -480,6 +488,11 @@ extern bool Yap_AccessAsset(const char *name, int mode);
extern bool Yap_AssetIsFile(const char *name); extern bool Yap_AssetIsFile(const char *name);
extern bool Yap_AssetIsDir(const char *name); extern bool Yap_AssetIsDir(const char *name);
extern int64_t Yap_AssetSize(const char *name); extern int64_t Yap_AssetSize(const char *name);
#else
#define __android_log_print(...)
#endif #endif
/************************************************************************************************* /*************************************************************************************************

View File

@ -33,7 +33,7 @@ Set or read system properties for _Param_:
YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS,
NULL), /** `address_bits` NULL), /** `address_bits`
Number of address bits in the machine, either 64 or 32 bits */ Number of address bits in the machine, either 64 or 32 bits */
YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000", YAP_FLAG(AGC_MARGIN_FLAG, "agc_margin", true, nat, "10000",
agc_threshold), /**`agc_margin ` agc_threshold), /**`agc_margin `
An integer: if this amount of atoms has been created since the last An integer: if this amount of atoms has been created since the last
@ -234,7 +234,7 @@ source mode is disabled.
YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), /**< home ` YAP_FLAG(HOME_FLAG, "home", false, isatom, YAP_ROOTDIR, NULL), /**< home `
the root of the YAP installation, by default `/usr/local` in Unix or the root of the YAP installation, by default `/usr/local` in Unix or
`c:\Yap` in Windows system. Can only be set at configure tien `c:\Yap` in Windows system. Can only be set at configure time
*/ */
YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS, YAP_FLAG(HOST_TYPE_FLAG, "host_type", false, isatom, HOST_ALIAS,
NULL), /**< host_type ` NULL), /**< host_type `
@ -337,7 +337,8 @@ only if the query contains variables. The alternative, default in SWI-Prolog is
goal succeeded while leaving choicepoints. */ goal succeeded while leaving choicepoints. */
YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, "true", YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, "true",
NULL), NULL),
YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false", Yap_InitReadline), /**< `readline(boolean, changeable)` YAP_FLAG(READLINE_FLAG, "readline", true, booleanFlag, "false" , Yap_InitReadline), /**< `readline(boolean, changeable)`
}
enable the use of the readline library for console interactions, true by default if readline was found. */ enable the use of the readline library for console interactions, true by default if readline was found. */
YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", NULL), YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", NULL),

View File

@ -61,7 +61,7 @@ typedef struct memory_hole {
ADDR start; ADDR start;
ADDR end; ADDR end;
} memory_hole_type; } memory_hole_type;
#endif #endif // USE_DL_MALLOC
typedef struct swi_reverse_hash { typedef struct swi_reverse_hash {
ADDR key; ADDR key;
@ -154,7 +154,15 @@ typedef struct thandle {
/******************* /*******************
this is the data base: everything here should be possible to restore this is the data base: everything here should be possible to restore
********************/ ********************/
#if __INIT_C__
#define EXTERNAL
#else
#define EXTERNAL extern
#endif
#if YAPOR #if YAPOR
typedef struct various_codes { typedef struct various_codes {
/* memory allocation and management */ /* memory allocation and management */
special_functors funcs; special_functors funcs;
@ -172,15 +180,11 @@ typedef struct various_codes {
/* memory allocation and management */ /* memory allocation and management */
special_functors funcs; special_functors funcs;
#include "tatoms.h"
} all_heap_codes; } all_heap_codes;
#if __INIT_C__ #include "tatoms.h"
#define EXTERNAL
#else
#define EXTERNAL extern
#endif
#include "h0struct.h" #include "h0struct.h"

View File

@ -170,9 +170,10 @@ INLINE_ONLY inline EXTERN Term MkVarTerm__(USES_REGS1) {
return (Term)((*HR = 0, HR++)); return (Term)((*HR = 0, HR++));
} }
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *); INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *);
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *t) { return (int)(*(t) == 0); } INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *t) { return (int)(*(t) ==
0); }
#else #else
@ -184,10 +185,10 @@ INLINE_ONLY inline EXTERN Term MkVarTerm__(USES_REGS1) {
return (Term)((*HR = (CELL)HR, HR++)); return (Term)((*HR = (CELL)HR, HR++));
} }
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *); INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *);
INLINE_ONLY inline EXTERN int IsUnboundVar(Term *t) { INLINE_ONLY inline EXTERN bool IsUnboundVar(Term *t) {
return (int)(*(t) == (Term)(t)); return *(t) == (Term)(t);
} }
#endif #endif
@ -234,10 +235,10 @@ INLINE_ONLY inline EXTERN Atom AtomOfTerm(Term t) {
#endif #endif
INLINE_ONLY inline EXTERN int IsAtomTerm(Term); INLINE_ONLY inline EXTERN bool IsAtomTerm(Term);
INLINE_ONLY inline EXTERN int IsAtomTerm(Term t) { INLINE_ONLY inline EXTERN bool IsAtomTerm(Term t) {
return (int)(CHKTAG((t), AtomTag)); return CHKTAG((t), AtomTag);
} }
INLINE_ONLY inline EXTERN Term MkIntTerm(Int); INLINE_ONLY inline EXTERN Term MkIntTerm(Int);
@ -257,10 +258,10 @@ INLINE_ONLY inline EXTERN Term MkIntConstant(Int n) {
return (Term)(NONTAGGED(NumberTag, (n))); return (Term)(NONTAGGED(NumberTag, (n)));
} }
INLINE_ONLY inline EXTERN int IsIntTerm(Term); INLINE_ONLY inline EXTERN bool IsIntTerm(Term);
INLINE_ONLY inline EXTERN int IsIntTerm(Term t) { INLINE_ONLY inline EXTERN bool IsIntTerm(Term t) {
return (int)(CHKTAG((t), NumberTag)); return CHKTAG((t), NumberTag);
} }
INLINE_ONLY EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS); INLINE_ONLY EXTERN inline Term MkPairTerm__(Term head, Term tail USES_REGS);
@ -312,9 +313,9 @@ INLINE_ONLY inline EXTERN Term __MkIntegerTerm(Int n USES_REGS) {
} }
#endif #endif
INLINE_ONLY inline EXTERN int IsIntegerTerm(Term); INLINE_ONLY inline EXTERN bool IsIntegerTerm(Term);
INLINE_ONLY inline EXTERN int IsIntegerTerm(Term t) { INLINE_ONLY inline EXTERN bool IsIntegerTerm(Term t) {
return (int)(IsIntTerm(t) || IsLongIntTerm(t)); return (int)(IsIntTerm(t) || IsLongIntTerm(t));
} }

View File

@ -17,6 +17,11 @@
#include "YapTermConfig.h" #include "YapTermConfig.h"
#include "config.h" #include "config.h"
typedef void *Functor;
typedef void *Atom;
#endif
#if HAVE_STDINT_H #if HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
@ -24,11 +29,6 @@
#include <inttypes.h> #include <inttypes.h>
#endif #endif
typedef void *Functor;
typedef void *Atom;
#endif
#define ALIGN_BY_TYPE(X, TYPE) \ #define ALIGN_BY_TYPE(X, TYPE) \
(((CELL)(X) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1)) (((CELL)(X) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1))
@ -43,85 +43,61 @@ typedef void *Atom;
/* defines integer types Int and UInt (unsigned) with the same size as a ptr /* defines integer types Int and UInt (unsigned) with the same size as a ptr
** and integer types Short and UShort with half the size of a ptr */ ** and integer types Short and UShort with half the size of a ptr */
#if HAVE_INTTYPES_H #if defined(PRIdPTR)
#include <inttypes.h>
#define Int_FORMAT "%" PRIdPTR #define Int_FORMAT "%" PRIdPTR
#define UInt_ANYFORMAT "%" PRIuPTR #define Int_ANYFORMAT "%" PRIuPTR
#define UInt_FORMAT "%" PRIuPTR #define UInt_FORMAT "%" PRIuPTR
#define Int_F PRIdPTR
#define Int_ANYF PRIuPTR
#define UInt_F PRIuPTR
typedef intptr_t Int; typedef intptr_t Int;
typedef uintptr_t UInt; typedef uintptr_t UInt;
#elif SIZEOF_INT_P == 4 #elif defined(_WIN64)
#if SIZEOF_LONGINT == 4 typedef int64_t Int;
typedef uint64_t UInt;
#define Int_FORMAT "%I64d"
#define UInt_FORMAT "%I64u"
#define Int_F "I64d"
#define UInt_F "I64u"
#elif defined(_WIN32)
typedef int32_t Int;
typedef uint32_t UInt;
#define Int_FORMAT "%I32d"
#define UInt_FORMAT "%I32u"
#define Int_F "I32d"
#define UInt_F "I32u"
#elif SIZEOF_LONGINT == SIZEOF_INT_P
typedef long int Int;
typedef unsigned long int UInt;
#define Int_FORMAT "%ld"
#define UInt_FORMAT "%uld"
#define Int_F "ld"
#define UInt_F "uld"
#elif SIZEOF_INT == SIZEOF_INT_P
typedef int Int;
typedef unsigned int UInt;
#define Int_FORMAT "%l" #define Int_FORMAT "%l"
#define UInt_FORMAT "%ul" #define UInt_FORMAT "%ul"
#define Int_F "l"
#define UInt_F "ul"
#elif SIZEOF_LONG_INT == 4
/* typedef long int Int;*/
/* typedef unsigned long int UInt; */
#if _WIN32 || __ANDROID__
#define Int_FORMAT "%d"
#define UInt_FORMAT "%u"
#else
#define Int_FORMAT "%ld"
#define UInt_FORMAT "%lu"
#endif
#else #else
#error Yap require integer types of the same size as a pointer #error Yap require integer types of the same size as a pointer
#endif #endif
#if SIZEOF_SHORT_INT == 2
/* */ typedef short int Short; /* */ typedef short int Short;
/* */ typedef unsigned short int UShort; /* */ typedef unsigned short int UShort;
#else typedef UInt CELL;
#error Yap requires integer types half the size of a pointer
#endif
#elif SIZEOF_INT_P == 8
#if SIZEOF_INT == 8
#define Int_FORMAT "%d"
#define UInt_FORMAT "%u"
#elif SIZEOF_LONG_INT == 8
#define Int_FORMAT "%ld"
#define UInt_FORMAT "%lu"
#elif SIZEOF_LONG_LONG_INT == 8
#define Int_FORMAT "%I64d"
#define UInt_FORMAT "%I64u"
#else
#error Yap requires integer types of the same size as a pointer
#endif
#if SIZEOF_SHORT_INT == 4
/* */ typedef short int Short;
/* */ typedef unsigned short int UShort;
#elif SIZEOF_INT == 4
/* */ typedef int Short;
/* */ typedef unsigned int UShort;
#else
#error Yap requires integer types half the size of a pointer
#endif
#else
#error Yap requires pointers of size 4 or 8
#endif
typedef uintptr_t CELL;
typedef uint16_t BITS16; typedef uint16_t BITS16;
typedef int16_t SBITS16; typedef int16_t SBITS16;
@ -135,9 +111,9 @@ typedef uint32_t BITS32;
type casting macros type casting macros
*************************************************************************************************/ *************************************************************************************************/
typedef uintptr_t Term; typedef UInt Term;
typedef intptr_t yhandle_t; typedef Int yhandle_t;
typedef double Float; typedef double Float;

View File

@ -28,8 +28,8 @@
* mirroring * mirroring
*/ */
#include "Yap.h"
#include "../utf8proc/utf8proc.h" #include "../utf8proc/utf8proc.h"
#include "Yap.h"
/* Character types for tokenizer and write.c */ /* Character types for tokenizer and write.c */
@ -141,7 +141,7 @@ INLINE_ONLY EXTERN inline char_kind_t chtype(Int ch) {
#define __android_log_print(...) #define __android_log_print(...)
#endif #endif
inline static utf8proc_ssize_t get_utf8(utf8proc_uint8_t *ptr, size_t n, inline static utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr, size_t n,
utf8proc_int32_t *valp) { utf8proc_int32_t *valp) {
return utf8proc_iterate(ptr, n, valp); return utf8proc_iterate(ptr, n, valp);
} }
@ -151,8 +151,8 @@ inline static utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr,
return utf8proc_encode_char(val, ptr); return utf8proc_encode_char(val, ptr);
} }
inline static utf8proc_uint8_t *skip_utf8(utf8proc_uint8_t *pt, inline static const utf8proc_uint8_t *skip_utf8(const utf8proc_uint8_t *pt,
utf8proc_ssize_t n) { utf8proc_ssize_t n) {
utf8proc_ssize_t i; utf8proc_ssize_t i;
utf8proc_int32_t b; utf8proc_int32_t b;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -164,11 +164,10 @@ inline static utf8proc_uint8_t *skip_utf8(utf8proc_uint8_t *pt,
return pt; return pt;
} }
inline static utf8proc_ssize_t utf8_nof( utf8proc_int32_t val) { inline static utf8proc_ssize_t utf8_nof(utf8proc_int32_t val) {
return utf8proc_charwidth(val); return utf8proc_charwidth(val);
} }
inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t *pt) { inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t *pt) {
utf8proc_ssize_t rc = 0; utf8proc_ssize_t rc = 0;
utf8proc_int32_t b; utf8proc_int32_t b;
@ -267,7 +266,8 @@ inline static int cmpn_utf8(const utf8proc_uint8_t *pt1,
// UTF16 // UTF16
#define LEAD_OFFSET ((uint32_t)0xD800 - (uint32_t)(0x10000 >> 10)) #define LEAD_OFFSET ((uint32_t)0xD800 - (uint32_t)(0x10000 >> 10))
#define SURROGATE_OFFSET ( (uint32_t)0x10000 - (uint32_t)(0xD800 << 10) - (uint32_t)0xDC00 ) #define SURROGATE_OFFSET \
((uint32_t)0x10000 - (uint32_t)(0xD800 << 10) - (uint32_t)0xDC00)
const char *Yap_tokRep(TokEntry *tokptr, encoding_t enc); const char *Yap_tokRep(TokEntry *tokptr, encoding_t enc);
@ -297,8 +297,8 @@ typedef enum {
YAP_STRING_WC = 0x20000, // output with write_canonical YAP_STRING_WC = 0x20000, // output with write_canonical
YAP_STRING_WITH_BUFFER = 0x40000, // output on existing buffer YAP_STRING_WITH_BUFFER = 0x40000, // output on existing buffer
YAP_STRING_MALLOC = 0x80000, // output on malloced buffer YAP_STRING_MALLOC = 0x80000, // output on malloced buffer
YAP_STRING_UPCASE = 0x100000, // output on malloced buffer YAP_STRING_UPCASE = 0x100000, // output on malloced buffer
YAP_STRING_DOWNCASE = 0x200000 // output on malloced buffer YAP_STRING_DOWNCASE = 0x200000 // output on malloced buffer
} enum_seq_type_t; } enum_seq_type_t;
typedef UInt seq_type_t; typedef UInt seq_type_t;
@ -313,6 +313,7 @@ typedef union {
const wchar_t *w0; const wchar_t *w0;
char *c; char *c;
unsigned char *uc; unsigned char *uc;
const unsigned char *uc0;
wchar_t *w; wchar_t *w;
Atom a; Atom a;
size_t l; size_t l;
@ -387,7 +388,7 @@ static inline seq_type_t mod_to_bqtype(Term mod USES_REGS) {
extern void *Yap_readText(void *buf, seq_tv_t *inp, encoding_t *enc, extern void *Yap_readText(void *buf, seq_tv_t *inp, encoding_t *enc,
int *minimal, size_t *lengp USES_REGS); int *minimal, size_t *lengp USES_REGS);
extern bool write_Text(void *inp, seq_tv_t *out, encoding_t enc, int minimal, extern bool write_Text(void *inp, seq_tv_t *out, encoding_t enc, int minimal,
size_t leng USES_REGS); size_t leng USES_REGS);
extern int Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS); extern int Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS);
extern void *Yap_Concat_Text(int n, seq_tv_t inp[], seq_tv_t *out USES_REGS); extern void *Yap_Concat_Text(int n, seq_tv_t inp[], seq_tv_t *out USES_REGS);
extern void *Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp, extern void *Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp,
@ -401,7 +402,7 @@ static inline Atom Yap_AtomicToLowAtom(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_ATOM|YAP_STRING_DOWNCASE; out.type = YAP_STRING_ATOM | YAP_STRING_DOWNCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.a; return out.val.a;
@ -413,7 +414,7 @@ static inline Atom Yap_AtomicToUpAtom(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_ATOM|YAP_STRING_UPCASE; out.type = YAP_STRING_ATOM | YAP_STRING_UPCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.a; return out.val.a;
@ -425,7 +426,7 @@ static inline Term Yap_AtomicToLowString(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_STRING|YAP_STRING_DOWNCASE; out.type = YAP_STRING_STRING | YAP_STRING_DOWNCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
@ -437,7 +438,7 @@ static inline Term Yap_AtomicToUpString(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_STRING|YAP_STRING_UPCASE; out.type = YAP_STRING_STRING | YAP_STRING_UPCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
@ -449,7 +450,7 @@ static inline Term Yap_AtomicToLowListOfCodes(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_CODES|YAP_STRING_DOWNCASE; out.type = YAP_STRING_CODES | YAP_STRING_DOWNCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
@ -461,7 +462,7 @@ static inline Term Yap_AtomicToUpListOfCodes(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_CODES|YAP_STRING_UPCASE; out.type = YAP_STRING_CODES | YAP_STRING_UPCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
@ -473,7 +474,7 @@ static inline Term Yap_AtomicToLowListOfAtoms(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_ATOMS|YAP_STRING_DOWNCASE; out.type = YAP_STRING_ATOMS | YAP_STRING_DOWNCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
@ -485,14 +486,12 @@ static inline Term Yap_AtomicToUpListOfAtoms(Term t0 USES_REGS) {
inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS | inp.type = YAP_STRING_STRING | YAP_STRING_CODES | YAP_STRING_ATOMS |
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
YAP_STRING_BIG | YAP_STRING_TERM; YAP_STRING_BIG | YAP_STRING_TERM;
out.type = YAP_STRING_ATOMS|YAP_STRING_UPCASE; out.type = YAP_STRING_ATOMS | YAP_STRING_UPCASE;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
} }
static inline size_t Yap_AtomicToLength(Term t0 USES_REGS) { static inline size_t Yap_AtomicToLength(Term t0 USES_REGS) {
seq_tv_t inp, out; seq_tv_t inp, out;
inp.val.t = t0; inp.val.t = t0;
@ -729,6 +728,20 @@ static inline Term Yap_UTF8ToListOfCodes(const char *s USES_REGS) {
return out.val.t; return out.val.t;
} }
static inline Atom Yap_UTF8ToAtom(const unsigned char *s USES_REGS) {
seq_tv_t inp, out;
inp.val.uc0 = s;
inp.sz = 0;
inp.type = YAP_STRING_CHARS;
inp.enc = ENC_ISO_UTF8;
out.type = YAP_STRING_ATOM;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L;
return out.val.a;
}
static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail, static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail,
encoding_t enc USES_REGS) { encoding_t enc USES_REGS) {
seq_tv_t inp, out; seq_tv_t inp, out;
@ -773,6 +786,7 @@ static inline Term Yap_WCharsToDiffListOfCodes(const wchar_t *s,
out.dif = tail; out.dif = tail;
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L; return 0L;
return out.val.t; return out.val.t;
} }
@ -1320,6 +1334,49 @@ static inline Term Yap_StringToNumber(Term t0 USES_REGS) {
return out.val.t; return out.val.t;
} }
static inline Atom Yap_TextToAtom(Term t0 USES_REGS) {
seq_tv_t inp, out;
inp.val.t = t0;
inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES |
YAP_STRING_ATOMS_CODES;
out.val.uc = NULL;
out.type = YAP_STRING_ATOM;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L;
return out.val.a;
}
static inline Term Yap_TextToString(Term t0 USES_REGS) {
seq_tv_t inp, out;
inp.val.t = t0;
inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES |
YAP_STRING_ATOMS_CODES;
out.val.uc = NULL;
out.type = YAP_STRING_STRING;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L;
return out.val.t;
}
static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) {
seq_tv_t inp, out;
inp.val.t = t0;
inp.type = YAP_STRING_ATOM | YAP_STRING_STRING | YAP_STRING_CODES |
YAP_STRING_ATOMS_CODES | YAP_STRING_MALLOC;
out.val.uc = NULL;
out.type = YAP_STRING_CHARS;
out.enc = ENC_ISO_UTF8;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return 0L;
return out.val.uc0;
}
static inline Term Yap_UTF8ToString(const char *s USES_REGS) { static inline Term Yap_UTF8ToString(const char *s USES_REGS) {
return MkStringTerm(s); return MkStringTerm(s);
} }

View File

@ -22,205 +22,205 @@
/* prototype file for Yap */ /* prototype file for Yap */
/* absmi.c */ /* absmi.c */
Int Yap_absmi(int); extern Int Yap_absmi(int);
int Yap_absmiEND(void); extern int Yap_absmiEND(void);
/* adtdefs.c */ /* adtdefs.c */
Term Yap_ArrayToList(Term *, size_t); extern Term Yap_ArrayToList(Term *, size_t);
int Yap_GetName(char *, UInt, Term); extern int Yap_GetName(char *, UInt, Term);
Term Yap_GetValue(Atom); extern Term Yap_GetValue(Atom);
int Yap_HasOp(Atom); extern int Yap_HasOp(Atom);
struct operator_entry * extern struct operator_entry *
Yap_GetOpPropForAModuleHavingALock(struct AtomEntryStruct *, Term); Yap_GetOpPropForAModuleHavingALock(struct AtomEntryStruct *, Term);
Atom Yap_LookupAtom(const char *); extern Atom Yap_LookupAtom(const char *);
Atom Yap_ULookupAtom(const unsigned char *); extern Atom Yap_ULookupAtom(const unsigned char *);
Atom Yap_LookupAtomWithLength(const char *, size_t); extern Atom Yap_LookupAtomWithLength(const char *, size_t);
Atom Yap_LookupUTF8Atom(const unsigned char *); extern Atom Yap_LookupUTF8Atom(const unsigned char *);
Atom Yap_LookupMaybeWideAtom(const wchar_t *); extern Atom Yap_LookupMaybeWideAtom(const wchar_t *);
Atom Yap_LookupMaybeWideAtomWithLength(const wchar_t *, size_t); extern Atom Yap_LookupMaybeWideAtomWithLength(const wchar_t *, size_t);
Atom Yap_FullLookupAtom(const char *); extern Atom Yap_FullLookupAtom(const char *);
void Yap_LookupAtomWithAddress(const char *, struct AtomEntryStruct *); extern void Yap_LookupAtomWithAddress(const char *, struct AtomEntryStruct *);
Prop Yap_NewPredPropByFunctor(struct FunctorEntryStruct *, Term); extern Prop Yap_NewPredPropByFunctor(struct FunctorEntryStruct *, Term);
Prop Yap_NewPredPropByAtom(struct AtomEntryStruct *, Term); extern Prop Yap_NewPredPropByAtom(struct AtomEntryStruct *, Term);
Prop Yap_PredPropByFunctorNonThreadLocal(struct FunctorEntryStruct *, Term); extern Prop Yap_PredPropByFunctorNonThreadLocal(struct FunctorEntryStruct *, Term);
Prop Yap_PredPropByAtomNonThreadLocal(struct AtomEntryStruct *, Term); extern Prop Yap_PredPropByAtomNonThreadLocal(struct AtomEntryStruct *, Term);
Functor Yap_UnlockedMkFunctor(struct AtomEntryStruct *, arity_t); extern Functor Yap_UnlockedMkFunctor(struct AtomEntryStruct *, arity_t);
Functor Yap_MkFunctor(Atom, arity_t); extern Functor Yap_MkFunctor(Atom, arity_t);
void Yap_MkFunctorWithAddress(Atom, unsigned int, FunctorEntry *); extern void Yap_MkFunctorWithAddress(Atom, unsigned int, FunctorEntry *);
void Yap_PutValue(Atom, Term); extern void Yap_PutValue(Atom, Term);
void Yap_ReleaseAtom(Atom); extern void Yap_ReleaseAtom(Atom);
int Yap_AtomIncreaseHold(Atom); extern int Yap_AtomIncreaseHold(Atom);
int Yap_AtomDecreaseHold(Atom); extern int Yap_AtomDecreaseHold(Atom);
struct operator_entry *Yap_OpPropForModule(Atom, Term); extern struct operator_entry *Yap_OpPropForModule(Atom, Term);
#ifdef SFUNC #ifdef SFUNC
Term MkSFTerm(Functor, int, Term *, Term); extern Term MkSFTerm(Functor, int, Term *, Term);
CELL *ArgsOfSFTerm(Term); extern CELL *ArgsOfSFTerm(Term);
#endif #endif
Prop Yap_GetPredPropByAtom(Atom, Term); extern Prop Yap_GetPredPropByAtom(Atom, Term);
Prop Yap_GetPredPropByFunc(Functor, Term); extern Prop Yap_GetPredPropByFunc(Functor, Term);
Prop Yap_GetPredPropByAtomInThisModule(Atom, Term); extern Prop Yap_GetPredPropByAtomInThisModule(Atom, Term);
Prop Yap_GetPredPropByFuncInThisModule(Functor, Term); extern Prop Yap_GetPredPropByFuncInThisModule(Functor, Term);
Prop Yap_GetPredPropHavingLock(Atom, unsigned int, Term); extern Prop Yap_GetPredPropHavingLock(Atom, unsigned int, Term);
Prop Yap_GetExpProp(Atom, unsigned int); extern Prop Yap_GetExpProp(Atom, unsigned int);
Prop Yap_GetExpPropHavingLock(struct AtomEntryStruct *, unsigned int); extern Prop Yap_GetExpPropHavingLock(struct AtomEntryStruct *, unsigned int);
/* agc.c */ /* agc.c */
void Yap_atom_gc(CACHE_TYPE1); extern void Yap_atom_gc(CACHE_TYPE1);
void Yap_init_agc(void); extern void Yap_init_agc(void);
/* alloc.c */ /* alloc.c */
void Yap_FreeCodeSpace(void *); extern void Yap_FreeCodeSpace(void *);
void *Yap_AllocAtomSpace(size_t); extern void *Yap_AllocAtomSpace(size_t);
void *Yap_AllocCodeSpace(size_t); extern void *Yap_AllocCodeSpace(size_t);
void *Yap_ReallocCodeSpace(void *, size_t); extern void *Yap_ReallocCodeSpace(void *, size_t);
ADDR Yap_AllocFromForeignArea(Int); extern ADDR Yap_AllocFromForeignArea(Int);
int Yap_ExtendWorkSpace(Int); extern int Yap_ExtendWorkSpace(Int);
void Yap_FreeAtomSpace(void *); extern void Yap_FreeAtomSpace(void *);
int Yap_FreeWorkSpace(void); extern int Yap_FreeWorkSpace(void);
void Yap_InitMemory(UInt, UInt, UInt); extern void Yap_InitMemory(UInt, UInt, UInt);
void Yap_InitExStacks(int, int, int); extern void Yap_InitExStacks(int, int, int);
/* amasm.c */ /* amasm.c */
OPCODE Yap_opcode(op_numbers); extern OPCODE Yap_opcode(op_numbers);
/* analyst.c */ /* analyst.c */
#ifdef ANALYST #ifdef ANALYST
void Yap_InitAnalystPreds(void); extern void Yap_InitAnalystPreds(void);
#endif /* ANALYST */ #endif /* ANALYST */
/* arrays.c */ /* arrays.c */
void Yap_InitArrayPreds(void); extern void Yap_InitArrayPreds(void);
/* atoms.c */ /* atoms.c */
void Yap_InitBackAtoms(void); extern void Yap_InitBackAtoms(void);
void Yap_InitAtomPreds(void); extern void Yap_InitAtomPreds(void);
/* attvar.c */ /* attvar.c */
void Yap_InitAttVarPreds(void); extern void Yap_InitAttVarPreds(void);
void Yap_MkEmptyWakeUp(Atom mod); extern void Yap_MkEmptyWakeUp(Atom mod);
/* bb.c */ /* bb.c */
void Yap_InitBBPreds(void); extern void Yap_InitBBPreds(void);
/* bignum.c */ /* bignum.c */
Term Yap_MkULLIntTerm(YAP_ULONG_LONG); extern Term Yap_MkULLIntTerm(YAP_ULONG_LONG);
int Yap_IsStringTerm(Term); extern int Yap_IsStringTerm(Term);
int Yap_IsWideStringTerm(Term); extern int Yap_IsWideStringTerm(Term);
Term Yap_RatTermToApplTerm(Term); extern Term Yap_RatTermToApplTerm(Term);
void Yap_InitBigNums(void); extern void Yap_InitBigNums(void);
Term Yap_AllocExternalDataInStack(CELL, size_t); extern Term Yap_AllocExternalDataInStack(CELL, size_t);
int Yap_CleanOpaqueVariable(CELL *); extern int Yap_CleanOpaqueVariable(CELL *);
CELL *Yap_HeapStoreOpaqueTerm(Term t); extern CELL *Yap_HeapStoreOpaqueTerm(Term t);
size_t Yap_OpaqueTermToString(Term t, char *str, size_t max); extern size_t Yap_OpaqueTermToString(Term t, char *str, size_t max);
/* c_interface.c */ /* c_interface.c */
#ifndef YAP_CPP_INTERFACE #ifndef YAP_CPP_INTERFACE
X_API Int YAP_Execute(struct pred_entry *, CPredicate); extern X_API Int YAP_Execute(struct pred_entry *, CPredicate);
X_API Int YAP_ExecuteFirst(struct pred_entry *, CPredicate); extern X_API Int YAP_ExecuteFirst(struct pred_entry *, CPredicate);
X_API Int YAP_ExecuteNext(struct pred_entry *, CPredicate); extern X_API Int YAP_ExecuteNext(struct pred_entry *, CPredicate);
X_API Int YAP_ExecuteOnCut(struct pred_entry *, CPredicate, struct cut_c_str *); extern X_API Int YAP_ExecuteOnCut(struct pred_entry *, CPredicate, struct cut_c_str *);
X_API Int YAP_RunGoalOnce(Term); extern X_API Int YAP_RunGoalOnce(Term);
#endif #endif
/* cdmgr.c */ /* cdmgr.c */
Term Yap_all_calls(void); extern Term Yap_all_calls(void);
Atom Yap_ConsultingFile(USES_REGS1); extern Atom Yap_ConsultingFile(USES_REGS1);
struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op); extern struct pred_entry *Yap_PredForChoicePt(choiceptr bptr, op_numbers *op);
void Yap_InitCdMgr(void); extern void Yap_InitCdMgr(void);
struct pred_entry *Yap_PredFromClause(Term t USES_REGS); extern struct pred_entry *Yap_PredFromClause(Term t USES_REGS);
bool Yap_discontiguous(struct pred_entry *ap, Term mode USES_REGS); extern bool Yap_discontiguous(struct pred_entry *ap, Term mode USES_REGS);
bool Yap_multiple(struct pred_entry *ap, Term mode USES_REGS); extern bool Yap_multiple(struct pred_entry *ap, Term mode USES_REGS);
void Yap_init_consult(int, const char *); extern void Yap_init_consult(int, const char *);
void Yap_end_consult(void); extern void Yap_end_consult(void);
void Yap_Abolish(struct pred_entry *); extern void Yap_Abolish(struct pred_entry *);
void Yap_BuildMegaClause(struct pred_entry *); extern void Yap_BuildMegaClause(struct pred_entry *);
void Yap_EraseMegaClause(yamop *, struct pred_entry *); extern void Yap_EraseMegaClause(yamop *, struct pred_entry *);
void Yap_ResetConsultStack(void); extern void Yap_ResetConsultStack(void);
void Yap_AssertzClause(struct pred_entry *, yamop *); extern void Yap_AssertzClause(struct pred_entry *, yamop *);
void Yap_HidePred(struct pred_entry *pe); extern void Yap_HidePred(struct pred_entry *pe);
int Yap_SetNoTrace(char *name, UInt arity, Term tmod); extern int Yap_SetNoTrace(char *name, UInt arity, Term tmod);
bool Yap_unknown(Term tflagvalue); extern bool Yap_unknown(Term tflagvalue);
struct pred_entry *Yap_MkLogPred(struct pred_entry *pe); extern struct pred_entry *Yap_MkLogPred(struct pred_entry *pe);
/* cmppreds.c */ /* cmppreds.c */
Int Yap_compare_terms(Term, Term); extern Int Yap_compare_terms(Term, Term);
Int Yap_acmp(Term, Term USES_REGS); extern Int Yap_acmp(Term, Term USES_REGS);
void Yap_InitCmpPreds(void); extern void Yap_InitCmpPreds(void);
/* compiler.c */ /* compiler.c */
yamop *Yap_cclause(Term, Int, Term, Term); extern yamop *Yap_cclause(Term, Int, Term, Term);
/* computils.c */ /* computils.c */
int Yap_DebugPutc(FILE *, wchar_t); extern int Yap_DebugPutc(FILE *, wchar_t);
int Yap_DebugPuts(FILE *, const char *); extern int Yap_DebugPuts(FILE *, const char *);
void Yap_DebugSetIFile(char *); extern void Yap_DebugSetIFile(char *);
void Yap_DebugEndline(void); extern void Yap_DebugEndline(void);
void Yap_DebugPlWrite(Term t); extern void Yap_DebugPlWrite(Term t);
void Yap_DebugPlWriteln(Term t); extern void Yap_DebugPlWriteln(Term t);
/* corout.c */ /* corout.c */
void Yap_InitCoroutPreds(void); extern void Yap_InitCoroutPreds(void);
#ifdef COROUTINING #ifdef COROUTINING
Term Yap_ListOfWokenGoals(void); extern Term Yap_ListOfWokenGoals(void);
void Yap_WakeUp(CELL *); extern void Yap_WakeUp(CELL *);
#endif #endif
/* dbase.c */ /* dbase.c */
struct pred_entry *Yap_FindLUIntKey(Int); extern struct pred_entry *Yap_FindLUIntKey(Int);
int Yap_DBTrailOverflow(void); extern int Yap_DBTrailOverflow(void);
CELL Yap_EvalMasks(Term, CELL *); extern CELL Yap_EvalMasks(Term, CELL *);
void Yap_InitBackDB(void); extern void Yap_InitBackDB(void);
void Yap_InitDBPreds(void); extern void Yap_InitDBPreds(void);
/* errors.c */ /* errors.c */
#if DEBUG #if DEBUG
void Yap_PrintPredName(struct pred_entry *ap); extern const char *Yap_PrintPredName(struct pred_entry *ap);
#endif #endif
void Yap_RestartYap(int); extern void Yap_RestartYap(int);
void Yap_exit(int); extern void Yap_exit(int);
bool Yap_Warning(const char *s, ...); extern bool Yap_Warning(const char *s, ...);
bool Yap_PrintWarning(Term t); extern bool Yap_PrintWarning(Term t);
bool Yap_HandleError__(const char *file, const char *function, int lineno, extern bool Yap_HandleError__(const char *file, const char *function, int lineno,
const char *s, ...); const char *s, ...);
#define Yap_HandleError(...) \ #define Yap_HandleError(...) \
Yap_HandleError__(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) Yap_HandleError__(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
int Yap_SWIHandleError(const char *, ...); extern int Yap_SWIHandleError(const char *, ...);
void Yap_InitErrorPreds(void); extern void Yap_InitErrorPreds(void);
/* eval.c */ /* eval.c */
void Yap_InitEval(void); extern void Yap_InitEval(void);
/* exec.c */ /* exec.c */
void Yap_fail_all(choiceptr bb USES_REGS); extern void Yap_fail_all(choiceptr bb USES_REGS);
Term Yap_ExecuteCallMetaCall(Term); extern Term Yap_ExecuteCallMetaCall(Term);
void Yap_InitExecFs(void); extern void Yap_InitExecFs(void);
bool Yap_JumpToEnv(Term); extern bool Yap_JumpToEnv(Term);
Term Yap_RunTopGoal(Term, bool); extern Term Yap_RunTopGoal(Term, bool);
bool Yap_execute_goal(Term, int, Term, bool); extern bool Yap_execute_goal(Term, int, Term, bool);
bool Yap_exec_absmi(bool, yap_reset_t); extern bool Yap_exec_absmi(bool, yap_reset_t);
void Yap_trust_last(void); extern void Yap_trust_last(void);
void Yap_PrepGoal(UInt, CELL *, choiceptr USES_REGS); extern void Yap_PrepGoal(UInt, CELL *, choiceptr USES_REGS);
bool Yap_execute_pred(struct pred_entry *ppe, CELL *pt, extern bool Yap_execute_pred(struct pred_entry *ppe, CELL *pt,
bool pass_exception USES_REGS); bool pass_exception USES_REGS);
int Yap_dogc(int extra_args, Term *tp USES_REGS); extern int Yap_dogc(int extra_args, Term *tp USES_REGS);
Term Yap_PredicateIndicator(Term t, Term mod); extern Term Yap_PredicateIndicator(Term t, Term mod);
bool Yap_Execute(Term t USES_REGS); extern bool Yap_Execute(Term t USES_REGS);
/* exo.c */ /* exo.c */
void Yap_InitExoPreds(void); extern void Yap_InitExoPreds(void);
void Yap_udi_Interval_init(void); extern void Yap_udi_Interval_init(void);
bool Yap_Reset(yap_reset_t mode); extern bool Yap_Reset(yap_reset_t mode);
/* foreign.c */ /* foreign.c */
char *Yap_FindExecutable(void); extern char *Yap_FindExecutable(void);
/* gprof.c */ /* gprof.c */
void Yap_InitLowProf(void); extern void Yap_InitLowProf(void);
#if LOW_PROF #if LOW_PROF
void Yap_inform_profiler_of_clause__(void *, void *, struct pred_entry *, extern void Yap_inform_profiler_of_clause__(void *, void *, struct pred_entry *,
gprof_info); gprof_info);
#define Yap_inform_profiler_of_clause(CODE0, CODEF, AP, MODE) \ #define Yap_inform_profiler_of_clause(CODE0, CODEF, AP, MODE) \
{ \ { \
@ -230,181 +230,182 @@ void Yap_inform_profiler_of_clause__(void *, void *, struct pred_entry *,
#else #else
#define Yap_inform_profiler_of_clause(CODE0, CODEF, AP, MODE) #define Yap_inform_profiler_of_clause(CODE0, CODEF, AP, MODE)
#endif #endif
void Yap_tell_gprof(yamop *); extern void Yap_tell_gprof(yamop *);
/* globals.c */ /* globals.c */
Term Yap_NewArena(UInt, CELL *); extern Term Yap_NewArena(UInt, CELL *);
CELL *Yap_GetFromArena(Term *, UInt, UInt); extern CELL *Yap_GetFromArena(Term *, UInt, UInt);
void Yap_InitGlobals(void); extern void Yap_InitGlobals(void);
Term Yap_SaveTerm(Term); extern Term Yap_SaveTerm(Term);
Term Yap_SetGlobalVal(Atom, Term); extern Term Yap_SetGlobalVal(Atom, Term);
Term Yap_GetGlobal(Atom); extern Term Yap_GetGlobal(Atom);
Int Yap_DeleteGlobal(Atom); extern Int Yap_DeleteGlobal(Atom);
void Yap_AllocateDefaultArena(Int, Int, int); extern void Yap_AllocateDefaultArena(Int, Int, int);
/* grow.c */ /* grow.c */
Int Yap_total_stack_shift_time(void); extern Int Yap_total_stack_shift_time(void);
void Yap_InitGrowPreds(void); extern void Yap_InitGrowPreds(void);
UInt Yap_InsertInGlobal(CELL *, UInt); extern UInt Yap_InsertInGlobal(CELL *, UInt);
int Yap_growheap(bool, size_t, void *); extern int Yap_growheap(bool, size_t, void *);
int Yap_growstack(size_t); extern int Yap_growstack(size_t);
int Yap_growtrail(size_t, bool); extern int Yap_growtrail(size_t, bool);
int Yap_growglobal(CELL **); extern int Yap_growglobal(CELL **);
int Yap_locked_growheap(bool, size_t, void *); extern int Yap_locked_growheap(bool, size_t, void *);
int Yap_locked_growstack(size_t); extern int Yap_locked_growstack(size_t);
int Yap_locked_growtrail(size_t, bool); extern int Yap_locked_growtrail(size_t, bool);
int Yap_locked_growglobal(CELL **); extern int Yap_locked_growglobal(CELL **);
CELL **Yap_shift_visit(CELL **, CELL ***, CELL ***); extern CELL **Yap_shift_visit(CELL **, CELL ***, CELL ***);
#ifdef THREADS #ifdef THREADS
void Yap_CopyThreadStacks(int, int, int); extern void Yap_CopyThreadStacks(int, int, int);
#endif #endif
/* heapgc.c */ /* heapgc.c */
Int Yap_total_gc_time(void); extern Int Yap_total_gc_time(void);
void Yap_init_gc(void); extern void Yap_init_gc(void);
bool Yap_is_gc_verbose(void); extern bool Yap_is_gc_verbose(void);
int Yap_gc(Int, CELL *, yamop *); extern int Yap_gc(Int, CELL *, yamop *);
int Yap_locked_gc(Int, CELL *, yamop *); extern int Yap_locked_gc(Int, CELL *, yamop *);
int Yap_gcl(UInt, Int, CELL *, yamop *); extern int Yap_gcl(UInt, Int, CELL *, yamop *);
int Yap_locked_gcl(UInt, Int, CELL *, yamop *); extern int Yap_locked_gcl(UInt, Int, CELL *, yamop *);
/* init.c */ /* init.c */
int Yap_IsOpType(char *); extern int Yap_IsOpType(char *);
void Yap_InitWorkspace(UInt, UInt, UInt, UInt, UInt, int, int, int); extern void Yap_InitWorkspace(UInt, UInt, UInt, UInt, UInt, int, int, int);
bool Yap_AddCallToFli(struct pred_entry *pe, CPredicate call); extern bool Yap_AddCallToFli(struct pred_entry *pe, CPredicate call);
bool Yap_AddRetryToFli(struct pred_entry *pe, CPredicate re); extern bool Yap_AddRetryToFli(struct pred_entry *pe, CPredicate re);
bool Yap_AddCutToFli(struct pred_entry *pe, CPredicate cut); extern bool Yap_AddCutToFli(struct pred_entry *pe, CPredicate cut);
const char *Yap_version(void); extern const char *Yap_version(void);
#ifdef YAPOR #ifdef YAPOR
void Yap_init_yapor_workers(void); extern void Yap_init_yapor_workers(void);
#endif /* YAPOR */ #endif /* YAPOR */
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
void Yap_KillStacks(int); extern void Yap_KillStacks(int);
#else #else
void Yap_KillStacks(int); extern void Yap_KillStacks(int);
#endif #endif
void Yap_InitYaamRegs(int); extern void Yap_InitYaamRegs(int);
void Yap_ReInitWTime(void); extern void Yap_ReInitWTime(void);
int Yap_OpDec(int, char *, Atom, Term); extern int Yap_OpDec(int, char *, Atom, Term);
void Yap_CloseScratchPad(void); extern void Yap_CloseScratchPad(void);
/* inlines.c */ /* inlines.c */
void Yap_InitInlines(void); extern void Yap_InitInlines(void);
int Yap_eq(Term, Term); extern int Yap_eq(Term, Term);
/* iopreds.c */ /* iopreds.c */
void Yap_InitPlIO(void); extern void Yap_InitPlIO(void);
void Yap_InitBackIO(void); extern void Yap_InitBackIO(void);
void Yap_InitIOPreds(void); extern void Yap_InitIOPreds(void);
extern void Yap_DebugPlWrite(Term t); extern void Yap_DebugPlWrite(Term t);
extern void Yap_DebugPlWriteln(Term t); extern void Yap_DebugPlWriteln(Term t);
extern void Yap_DebugErrorPutc(int n); extern void Yap_DebugErrorPutc(int n);
extern void Yap_DebugErrorPuts(const char *s); extern void Yap_DebugErrorPuts(const char *s);
extern void Yap_DebugWriteIndicator(struct pred_entry *ap); extern void Yap_DebugWriteIndicator(struct pred_entry *ap);
void Yap_PlWriteToStream(Term, int, int); extern void Yap_PlWriteToStream(Term, int, int);
void Yap_CloseReadline(void); extern void Yap_CloseReadline(void);
/* depth_lim.c */ /* depth_lim.c */
bool Yap_InitReadline(Term t); extern bool Yap_InitReadline(Term t);
void Yap_InitItDeepenPreds(void); extern void Yap_InitItDeepenPreds(void);
struct AliasDescS *Yap_InitStandardAliases(void); extern struct AliasDescS *Yap_InitStandardAliases(void);
extern struct vfs *Yap_InitAssetManager(void);
/* load_foreign.c */ /* load_foreign.c */
void Yap_InitLoadForeign(void); extern void Yap_InitLoadForeign(void);
/* mavar.c */ /* mavar.c */
void Yap_InitMaVarCPreds(void); extern void Yap_InitMaVarCPreds(void);
Term Yap_NewTimedVar(Term); extern Term Yap_NewTimedVar(Term);
Term Yap_NewEmptyTimedVar(void); extern Term Yap_NewEmptyTimedVar(void);
Term Yap_ReadTimedVar(Term); extern Term Yap_ReadTimedVar(Term);
Term Yap_UpdateTimedVar(Term, Term); extern Term Yap_UpdateTimedVar(Term, Term);
/* modules.c */ /* modules.c */
Term Yap_Module(Term); extern Term Yap_Module(Term);
Term Yap_Module_Name(struct pred_entry *); extern Term Yap_Module_Name(struct pred_entry *);
struct pred_entry *Yap_ModulePred(Term); extern struct pred_entry *Yap_ModulePred(Term);
void Yap_NewModulePred(Term, struct pred_entry *); extern void Yap_NewModulePred(Term, struct pred_entry *);
Term Yap_StripModule(Term, Term *); extern Term Yap_StripModule(Term, Term *);
Term Yap_YapStripModule(Term, Term *); extern Term Yap_YapStripModule(Term, Term *);
void Yap_InitModules(void); extern void Yap_InitModules(void);
void Yap_InitModulesC(void); extern void Yap_InitModulesC(void);
struct mod_entry *Yap_GetModuleEntry(Term tmod); extern struct mod_entry *Yap_GetModuleEntry(Term tmod);
Term Yap_GetModuleFromEntry(struct mod_entry *me); extern Term Yap_GetModuleFromEntry(struct mod_entry *me);
bool Yap_CharacterEscapes(Term mt); extern bool Yap_CharacterEscapes(Term mt);
bool Yap_constPred(struct pred_entry *pt); extern bool Yap_constPred(struct pred_entry *pt);
bool Yap_isSystemModule(Term mod); extern bool Yap_isSystemModule(Term mod);
#if HAVE_MPI #if HAVE_MPI
/* mpi.c */ /* mpi.c */
void Yap_InitMPI(void); extern void Yap_InitMPI(void);
#endif #endif
#if HAVE_MPE #if HAVE_MPE
/* mpe.c */ /* mpe.c */
void Yap_InitMPE(void); extern void Yap_InitMPE(void);
#endif #endif
/* other.c */ /* other.c */
Term Yap_MkApplTerm(Functor, arity_t, const Term *); extern Term Yap_MkApplTerm(Functor, arity_t, const Term *);
Term Yap_MkNewApplTerm(Functor, arity_t); extern Term Yap_MkNewApplTerm(Functor, arity_t);
Term Yap_MkNewPairTerm(void); extern Term Yap_MkNewPairTerm(void);
Term Yap_Globalise(Term); extern Term Yap_Globalise(Term);
/* readutil.c */ /* readutil.c */
void Yap_InitReadUtil(void); extern void Yap_InitReadUtil(void);
/* qly.c */ /* qly.c */
void Yap_InitQLY(void); extern void Yap_InitQLY(void);
int Yap_Restore(const char *, const char *); extern YAP_file_type_t Yap_Restore(const char *, const char *);
void Yap_InitQLYR(void); extern void Yap_InitQLYR(void);
/* range.c */ /* range.c */
void Yap_InitRange(void); extern void Yap_InitRange(void);
/* save.c */ /* save.c */
int Yap_SavedInfo(const char *, const char *, CELL *, CELL *, CELL *); extern int Yap_SavedInfo(const char *, const char *, CELL *, CELL *, CELL *);
int Yap_SavedStateRestore(char *, char *); extern int Yap_SavedStateRestore(char *, char *);
FILE *Yap_OpenRestore(const char *, const char *); extern FILE *Yap_OpenRestore(const char *, const char *);
void Yap_InitSavePreds(void); extern void Yap_InitSavePreds(void);
/* scanner.c */ /* scanner.c */
/* signals.c */ /* signals.c */
void Yap_InitSignalCPreds(void); extern void Yap_InitSignalCPreds(void);
void *Yap_InitSignals(int wid); extern void *Yap_InitSignals(int wid);
bool Yap_DisableInterrupts(int wid); extern bool Yap_DisableInterrupts(int wid);
bool Yap_EnableInterrupts(int wid); extern bool Yap_EnableInterrupts(int wid);
void Yap_InitSockets(void); extern void Yap_InitSockets(void);
/* sort.c */ /* sort.c */
void Yap_InitSortPreds(void); extern void Yap_InitSortPreds(void);
/* stack.c */ /* stack.c */
void Yap_InitStInfo(void); extern void Yap_InitStInfo(void);
void Yap_dump_stack(void); extern void Yap_dump_stack(void);
void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize); extern void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize);
#if !defined(YAPOR) && !defined(THREADS) #if !defined(YAPOR) && !defined(THREADS)
bool Yap_search_for_static_predicate_in_use(struct pred_entry *, bool); extern bool Yap_search_for_static_predicate_in_use(struct pred_entry *, bool);
#endif #endif
/* stdpreds.c */ /* stdpreds.c */
void Yap_InitBackCPreds(void); extern void Yap_InitBackCPreds(void);
void Yap_InitCPreds(void); extern void Yap_InitCPreds(void);
void Yap_show_statistics(void); extern void Yap_show_statistics(void);
int Yap_IsOpMaxPrio(Atom); extern int Yap_IsOpMaxPrio(Atom);
/* sysbits.c */ /* sysbits.c */
size_t Yap_InitPageSize(void); extern size_t Yap_InitPageSize(void);
bool Yap_set_fpu_exceptions(Term); extern bool Yap_set_fpu_exceptions(Term);
UInt Yap_cputime(void); extern UInt Yap_cputime(void);
uint64_t Yap_walltime(void); extern uint64_t Yap_walltime(void);
int Yap_dir_separator(int); extern int Yap_dir_separator(int);
int Yap_volume_header(char *); extern int Yap_volume_header(char *);
int Yap_signal_index(const char *); extern int Yap_signal_index(const char *);
#ifdef MAC #ifdef MAC
void Yap_SetTextFile(char *); extern void Yap_SetTextFile(char *);
#endif #endif
#if __ANDROID__ #if __ANDROID__
#include <android/asset_manager.h> #include <android/asset_manager.h>
@ -413,99 +414,103 @@ extern AAssetManager *Yap_assetManager;
extern void *Yap_openAssetFile(const char *path); extern void *Yap_openAssetFile(const char *path);
extern bool Yap_isAsset(const char *path); extern bool Yap_isAsset(const char *path);
#endif #endif
const char *Yap_getcwd(const char *, size_t); extern const char *Yap_getcwd(const char *, size_t);
void Yap_cputime_interval(Int *, Int *); extern void Yap_cputime_interval(Int *, Int *);
void Yap_systime_interval(Int *, Int *); extern void Yap_systime_interval(Int *, Int *);
void Yap_InitSysbits(int wid); extern void Yap_InitSysbits(int wid);
void Yap_InitSysPreds(void); extern void Yap_InitSysPreds(void);
void Yap_InitcTime(int); extern void Yap_InitcTime(int);
void Yap_InitTime(int); extern void Yap_InitTime(int);
double Yap_random(void); extern double Yap_random(void);
#ifdef _WIN32 #ifdef _WIN32
char *Yap_RegistryGetString(char *); extern char *Yap_RegistryGetString(char *);
void Yap_WinError(char *); extern void Yap_WinError(char *);
#endif #endif
const char *Yap_AbsoluteFile(const char *spec, char *obuf, bool ok); extern const char *Yap_AbsoluteFile(const char *spec, char *obuf, bool ok);
const char *Yap_AbsoluteFileInBuffer(const char *spec, char *outp, size_t sz, extern const char *Yap_AbsoluteFileInBuffer(const char *spec, char *outp, size_t sz,
bool ok); bool ok);
const char *Yap_findFile(const char *isource, const char *idef, extern const char *Yap_findFile(const char *isource, const char *idef,
const char *root, char *result, bool access, const char *root, char *result, bool access,
YAP_file_type_t ftype, bool expand_root, bool in_lib); YAP_file_type_t ftype, bool expand_root, bool in_lib);
/* threads.c */ /* threads.c */
void Yap_InitThreadPreds(void); extern void Yap_InitThreadPreds(void);
void Yap_InitFirstWorkerThreadHandle(void); extern void Yap_InitFirstWorkerThreadHandle(void);
int Yap_ThreadID(void); extern int Yap_ThreadID(void);
int Yap_NOfThreads(void); extern int Yap_NOfThreads(void);
#if THREADS #if THREADS
int Yap_InitThread(int); extern int Yap_InitThread(int);
#endif #endif
intptr_t system_thread_id(void); extern intptr_t system_thread_id(void);
/* tracer.c */ /* tracer.c */
#ifdef LOW_LEVEL_TRACER #ifdef LOW_LEVEL_TRACER
void Yap_InitLowLevelTrace(void); extern void Yap_InitLowLevelTrace(void);
#endif #endif
/* udi.c */ /* udi.c */
void Yap_udi_init(void); extern void Yap_udi_init(void);
void Yap_udi_abolish(struct pred_entry *); extern void Yap_udi_abolish(struct pred_entry *);
/* unify.c */ /* unify.c */
int Yap_rational_tree_loop(CELL *, CELL *, CELL **, CELL **); extern int Yap_rational_tree_loop(CELL *, CELL *, CELL **, CELL **);
void Yap_InitAbsmi(void); extern void Yap_InitAbsmi(void);
void Yap_InitUnify(void); extern void Yap_InitUnify(void);
void Yap_TrimTrail(void); extern void Yap_TrimTrail(void);
int Yap_Unifiable(Term d0, Term d1); extern int Yap_Unifiable(Term d0, Term d1);
int Yap_IUnify(register CELL d0, register CELL d1); extern int Yap_IUnify(register CELL d0, register CELL d1);
/* userpreds.c */ /* userpreds.c */
void Yap_InitUserCPreds(void); extern void Yap_InitUserCPreds(void);
void Yap_InitUserBacks(void); extern void Yap_InitUserBacks(void);
/* utilpreds.c */ /* utilpreds.c */
Term Yap_CopyTerm(Term); extern Term Yap_CopyTerm(Term);
int Yap_Variant(Term, Term); extern bool Yap_Variant(Term, Term);
size_t Yap_ExportTerm(Term, char *, size_t, UInt); extern size_t Yap_ExportTerm(Term, char *, size_t, UInt);
size_t Yap_SizeOfExportedTerm(char *); extern size_t Yap_SizeOfExportedTerm(char *);
Term Yap_ImportTerm(char *); extern Term Yap_ImportTerm(char *);
int Yap_IsListTerm(Term); extern bool Yap_IsListTerm(Term);
bool Yap_IsListOrPartialListTerm(Term); extern bool Yap_IsListOrPartialListTerm(Term);
Term Yap_CopyTermNoShare(Term); extern Term Yap_CopyTermNoShare(Term);
int Yap_SizeGroundTerm(Term, int); extern int Yap_SizeGroundTerm(Term, int);
int Yap_IsGroundTerm(Term); extern bool Yap_IsGroundTerm(Term);
int Yap_IsAcyclicTerm(Term); extern bool Yap_IsAcyclicTerm(Term);
void Yap_InitUtilCPreds(void); extern void Yap_InitUtilCPreds(void);
Int Yap_TermHash(Term, Int, Int, int); extern Int Yap_TermHash(Term, Int, Int, int);
Int Yap_NumberVars(Term, Int, int); extern Int Yap_NumberVars(Term, Int, bool);
Term Yap_TermVariables(Term t, UInt arity USES_REGS); extern Term Yap_TermVariables(Term t, UInt arity USES_REGS);
Term Yap_UnNumberTerm(Term, int); extern Term Yap_UnNumberTerm(Term, int);
Int Yap_SkipList(Term *, Term **); extern Int Yap_SkipList(Term *, Term **);
/* yap.c */ /* yap.c */
/* write.c */ /* write.c */
/* yap2swi.c */ /* yap2swi.c */
void Yap_swi_install(void); extern void Yap_swi_install(void);
void Yap_InitSWIHash(void); extern void Yap_InitSWIHash(void);
int Yap_get_stream_handle(Term, int, int, void *); extern int Yap_get_stream_handle(Term, int, int, void *);
Term Yap_get_stream_position(void *); extern Term Yap_get_stream_position(void *);
struct AtomEntryStruct *Yap_lookupBlob(void *blob, size_t len, void *type, extern struct AtomEntryStruct *Yap_lookupBlob(void *blob, size_t len, void *type,
int *newp); int *newp);
/* opt.preds.c */ /* opt.preds.c */
void Yap_init_optyap_preds(void); extern void Yap_init_optyap_preds(void);
/* pl-file.c */ /* pl-file.c */
// struct PL_local_data *Yap_InitThreadIO(int wid); // struct PL_local_data *Yap_InitThreadIO(int wid);
void Yap_flush(void); extern void Yap_flush(void);
/* pl-yap.c */ /* pl-yap.c */
Int Yap_source_line_no(void); extern Int Yap_source_line_no(void);
Atom Yap_source_file_name(void); extern Atom Yap_source_file_name(void);
void Yap_install_blobs(void); extern void Yap_install_blobs(void);
yamop *Yap_gcP(void); extern yamop *Yap_gcP(void);
#if USE_MYDDAS
extern void init_myddas(void);
#endif
#if !HAVE_STRNCAT #if !HAVE_STRNCAT
#define strncat(X, Y, Z) strcat(X, Y) #define strncat(X, Y, Z) strcat(X, Y)

View File

@ -252,15 +252,16 @@ INLINE_ONLY inline EXTERN bool IsWideAtom(Atom at) {
/** Module property: low-level data used to manage modes. /** Module property: low-level data used to manage modes.
Includes lists of pedicates, operators and other well-defIned properties. Includes lists of pedicates, operators and other well-defIned
properties.
*/ */
typedef struct mod_entry { typedef struct mod_entry {
Prop NextOfPE; /** chain of atom properties */ Prop NextOfPE; /** chain of atom properties */
PropFlags KindOfPE; /** kind of property */ PropFlags KindOfPE; /** kind of property */
struct pred_entry *PredForME; /** index in module table */ struct pred_entry *PredForME; /** index in module table */
struct operator_entry *OpForME; /** index in operator table */ struct operator_entry *OpForME; /** index in operator table */
Atom AtomOfME; /** module's name */ Atom AtomOfME; /** module's name */
Atom OwnerFile; /** module's owner file */ Atom OwnerFile; /** module's owner file */
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
rwlock_t ModRWLock; /** a read-write lock to protect the entry */ rwlock_t ModRWLock; /** a read-write lock to protect the entry */
#endif #endif
@ -331,7 +332,7 @@ INLINE_ONLY inline EXTERN bool IsModProperty(int flags) {
(UNKNOWN_ERROR | UNKNOWN_WARNING | UNKNOWN_FAIL | UNKNOWN_FAST_FAIL | \ (UNKNOWN_ERROR | UNKNOWN_WARNING | UNKNOWN_FAIL | UNKNOWN_FAST_FAIL | \
UNKNOWN_ABORT | UNKNOWN_HALT) UNKNOWN_ABORT | UNKNOWN_HALT)
Term Yap_getUnknownModule(ModEntry *m); Term Yap_getUnknownModule(ModEntry *m);
void Yap_setModuleFlags(ModEntry *n, ModEntry *o); void Yap_setModuleFlags(ModEntry *n, ModEntry *o);
/* operator property entry structure */ /* operator property entry structure */
@ -341,11 +342,11 @@ typedef struct operator_entry {
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
rwlock_t OpRWLock; /* a read-write lock to protect the entry */ rwlock_t OpRWLock; /* a read-write lock to protect the entry */
#endif #endif
Atom OpName; /* atom name */ Atom OpName; /* atom name */
Term OpModule; /* module of predicate */ Term OpModule; /* module of predicate */
struct operator_entry *OpNext; /* next in list of operators */ struct operator_entry *OpNext; /* next in list of operators */
struct operator_entry *NextForME; /* next in list of module operators */ struct operator_entry *NextForME; /* next in list of module operators */
BITS16 Prefix, Infix, Posfix; /**o precedences */ BITS16 Prefix, Infix, Posfix; /**o precedences */
} OpEntry; } OpEntry;
#if USE_OFFSETS_IN_PROPS #if USE_OFFSETS_IN_PROPS
@ -387,10 +388,10 @@ OpEntry *Yap_GetOpProp(Atom, op_type, Term CACHE_TYPE);
int Yap_IsPrefixOp(Atom, int *, int *); int Yap_IsPrefixOp(Atom, int *, int *);
int Yap_IsOp(Atom); int Yap_IsOp(Atom);
int Yap_IsInfixOp(Atom, int *, int *, int *); int Yap_IsInfixOp(Atom, int *, int *, int *);
int Yap_IsPosfixOp(Atom, int *, int *); int Yap_IsPosfixOp(Atom, int *, int *);
bool Yap_dup_op(OpEntry *op, ModEntry *she); bool Yap_dup_op(OpEntry *op, ModEntry *she);
/* defines related to operator specifications */ /* defines related to operator specifications */
#define MaskPrio 0x0fff #define MaskPrio 0x0fff
#define DcrlpFlag 0x1000 #define DcrlpFlag 0x1000
#define DcrrpFlag 0x2000 #define DcrrpFlag 0x2000
@ -678,8 +679,9 @@ INLINE_ONLY inline EXTERN Atom NameOfPred(PredEntry *pe) {
} }
} }
profile_data * extern const char *IndicatorOfPred(PredEntry *pe);
Yap_initProfiler(PredEntry *p);
profile_data *Yap_initProfiler(PredEntry *p);
/* Flags for code or dbase entry */ /* Flags for code or dbase entry */
/* There are several flags for code and data base entries */ /* There are several flags for code and data base entries */

View File

@ -17,21 +17,21 @@
/* allowed types for clauses */ /* allowed types for clauses */
typedef enum clause_type_enum { typedef enum clause_type_enum {
pair_clause = 0x01, pair_clause = 0x01,
struct_clause = 0x02, struct_clause = 0x02,
atom_clause = 0x04, atom_clause = 0x04,
int_clause = 0x08, int_clause = 0x08,
flt_clause = 0x10, flt_clause = 0x10,
lgint_clause = 0x20, lgint_clause = 0x20,
dbref_clause = 0x40 dbref_clause = 0x40
} clause_type; } clause_type;
/* Four types of Clauses */ /* Four types of Clauses */
#define MaxOptions 4 #define MaxOptions 4
/* Minimum number of clauses needed to build an hash table */ /* Minimum number of clauses needed to build an hash table */
/* must be a power of two */ /* must be a power of two */
#define MIN_HASH_ENTRIES 4 #define MIN_HASH_ENTRIES 4
#define HASH_SHIFT 6 #define HASH_SHIFT 6
@ -40,54 +40,52 @@ typedef enum clause_type_enum {
/* Used to store all important information about a clause */ /* Used to store all important information about a clause */
typedef struct StructClauseDef { typedef struct StructClauseDef {
Term Tag; /* if nonvar or nonlist, first argument */
yamop *Code; /* start of code for clause */ Term Tag; /* if nonvar or nonlist, first argument */
yamop *CurrentCode; /* start of code for clause */ yamop *Code; /* start of code for clause */
yamop *CurrentCode; /* start of code for clause */
union { union {
yamop *WorkPC; /* start of code for clause */ yamop *WorkPC; /* start of code for clause */
Term t_ptr; Term t_ptr;
CELL *c_sreg; CELL *c_sreg;
} ucd; } ucd;
} ClauseDef; } ClauseDef;
/* Relevant information for groups */ /* Relevant information for groups */
typedef struct { typedef struct {
ClauseDef *FirstClause; ClauseDef *FirstClause;
ClauseDef *LastClause; ClauseDef *LastClause;
UInt VarClauses; UInt VarClauses;
UInt AtomClauses; UInt AtomClauses;
UInt PairClauses; UInt PairClauses;
UInt StructClauses; UInt StructClauses;
UInt TestClauses; UInt TestClauses;
} GroupDef; } GroupDef;
/* switch_on_cons */ /* switch_on_cons */
typedef struct { typedef struct {
Term Tag; Term Tag;
union { union {
UInt Label; UInt Label;
yamop *labp; yamop *labp;
} u_a; } u_a;
} AtomSwiEntry; } AtomSwiEntry;
/* switch_on_func */ /* switch_on_func */
typedef struct { typedef struct {
Functor Tag; Functor Tag;
union { union {
UInt Label; UInt Label;
yamop *labp; yamop *labp;
} u_f; } u_f;
} FuncSwiEntry; } FuncSwiEntry;
/* switch_on_type */ /* switch_on_type */
typedef struct { typedef struct {
UInt PairEntry; UInt PairEntry;
UInt ConstEntry; UInt ConstEntry;
UInt FuncEntry; UInt FuncEntry;
UInt VarEntry; UInt VarEntry;
} TypeSwitch; } TypeSwitch;
#define MAX_REG_COPIES 32 #define MAX_REG_COPIES 32
@ -95,20 +93,16 @@ typedef struct {
typedef struct { typedef struct {
Int pos; Int pos;
Term val; Term val;
Term extra; Term extra;
} istack_entry; } istack_entry;
typedef enum { typedef enum { pc_entry, block_entry } add2index_entries;
pc_entry,
block_entry
} add2index_entries;
typedef struct { typedef struct {
add2index_entries flag; add2index_entries flag;
union { union {
struct { struct {
yamop**pi_pc; yamop **pi_pc;
yamop *code, *current_code, *work_pc; yamop *code, *current_code, *work_pc;
Term tag; Term tag;
} pce; } pce;
@ -121,8 +115,4 @@ typedef struct {
#define MAX_ISTACK_DEPTH 32 #define MAX_ISTACK_DEPTH 32
typedef enum { typedef enum { REFRESH, RECORDA, RECORDZ } expand_values;
REFRESH,
RECORDA,
RECORDZ
} expand_values;

46
H/qly.h
View File

@ -1,3 +1,4 @@
/************************************************************************* /*************************************************************************
* * * *
* YAP Prolog * * YAP Prolog *
@ -16,8 +17,8 @@
* * * *
*************************************************************************/ *************************************************************************/
#define EXPORT_ATOM_TABLE_SIZE (16*4096) #define EXPORT_ATOM_TABLE_SIZE (16 * 4096)
#define EXPORT_FUNCTOR_TABLE_SIZE (16*4096) #define EXPORT_FUNCTOR_TABLE_SIZE (16 * 4096)
#define EXPORT_OPCODE_TABLE_SIZE (4096) #define EXPORT_OPCODE_TABLE_SIZE (4096)
#define EXPORT_PRED_ENTRY_TABLE_SIZE (128) #define EXPORT_PRED_ENTRY_TABLE_SIZE (128)
#define EXPORT_DBREF_TABLE_SIZE (128) #define EXPORT_DBREF_TABLE_SIZE (128)
@ -29,7 +30,7 @@ typedef struct export_atom_hash_entry_struct {
typedef struct import_atom_hash_entry_struct { typedef struct import_atom_hash_entry_struct {
Atom oval; Atom oval;
Atom val; Atom val;
struct import_atom_hash_entry_struct *next; struct import_atom_hash_entry_struct *next;
} import_atom_hash_entry_t; } import_atom_hash_entry_t;
typedef struct export_functor_hash_entry_struct { typedef struct export_functor_hash_entry_struct {
@ -41,14 +42,14 @@ typedef struct export_functor_hash_entry_struct {
typedef struct import_functor_hash_entry_struct { typedef struct import_functor_hash_entry_struct {
Functor val; Functor val;
Functor oval; Functor oval;
struct import_functor_hash_entry_struct *next; struct import_functor_hash_entry_struct *next;
} import_functor_hash_entry_t; } import_functor_hash_entry_t;
typedef struct import_opcode_hash_entry_struct { typedef struct import_opcode_hash_entry_struct {
OPCODE val; OPCODE val;
int id; int id;
OPCODE oval; OPCODE oval;
struct import_opcode_hash_entry_struct *next; struct import_opcode_hash_entry_struct *next;
} import_opcode_hash_entry_t; } import_opcode_hash_entry_t;
typedef struct export_pred_entry_hash_entry_struct { typedef struct export_pred_entry_hash_entry_struct {
@ -64,7 +65,7 @@ typedef struct export_pred_entry_hash_entry_struct {
typedef struct import_pred_entry_hash_entry_struct { typedef struct import_pred_entry_hash_entry_struct {
PredEntry *val; PredEntry *val;
PredEntry *oval; PredEntry *oval;
struct import_pred_entry_hash_entry_struct *next; struct import_pred_entry_hash_entry_struct *next;
} import_pred_entry_hash_entry_t; } import_pred_entry_hash_entry_t;
typedef struct export_dbref_hash_entry_struct { typedef struct export_dbref_hash_entry_struct {
@ -77,7 +78,7 @@ typedef struct import_dbref_hash_entry_struct {
DBRef val; DBRef val;
DBRef oval; DBRef oval;
int count; int count;
struct import_dbref_hash_entry_struct *next; struct import_dbref_hash_entry_struct *next;
} import_dbref_hash_entry_t; } import_dbref_hash_entry_t;
typedef enum { typedef enum {
@ -101,15 +102,30 @@ typedef enum {
QLY_ATOM_BLOB = 17 QLY_ATOM_BLOB = 17
} qlf_tag_t; } qlf_tag_t;
#define STATIC_PRED_FLAGS (SourcePredFlag|DynamicPredFlag|LogUpdatePredFlag|CompiledPredFlag|MultiFileFlag|TabledPredFlag|MegaClausePredFlag|CountPredFlag|ProfiledPredFlag|ThreadLocalPredFlag|AtomDBPredFlag|ModuleTransparentPredFlag|NumberDBPredFlag|MetaPredFlag|SyncPredFlag|BackCPredFlag) #define STATIC_PRED_FLAGS \
#define EXTRA_PRED_FLAGS (QuasiQuotationPredFlag|NoTracePredFlag|NoSpyPredFlag) (SourcePredFlag | DynamicPredFlag | LogUpdatePredFlag | CompiledPredFlag | \
MultiFileFlag | TabledPredFlag | MegaClausePredFlag | CountPredFlag | \
ProfiledPredFlag | ThreadLocalPredFlag | AtomDBPredFlag | \
ModuleTransparentPredFlag | NumberDBPredFlag | MetaPredFlag | \
SyncPredFlag | BackCPredFlag)
#define EXTRA_PRED_FLAGS \
(QuasiQuotationPredFlag | NoTracePredFlag | NoSpyPredFlag)
#define SYSTEM_PRED_FLAGS (BackCPredFlag|UserCPredFlag|CArgsPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag) #define SYSTEM_PRED_FLAGS \
(BackCPredFlag | UserCPredFlag | CArgsPredFlag | AsmPredFlag | CPredFlag | \
BinaryPredFlag)
#define CHECK(F) { size_t r = (F); if (!r) return r; } #define CHECK(F) \
#define RCHECK(F) if(!(F)) { QLYR_ERROR(MISMATCH); return; } { \
size_t r = (F); \
if (!r) \
return r; \
}
#define RCHECK(F) \
if (!(F)) { \
QLYR_ERROR(MISMATCH); \
return; \
}
#define AllocTempSpace() (HR) #define AllocTempSpace() (HR)
#define EnoughTempSpace(sz) ((ASP-HR)*sizeof(CELL) > sz) #define EnoughTempSpace(sz) ((ASP - HR) * sizeof(CELL) > sz)

View File

@ -39,18 +39,21 @@
#endif /* YAP_H */ #endif /* YAP_H */
/* truth-values */
/* stdbool defines the booleam type, bool,
and the constants false and true */
#if HAVE_STDINT_H #if HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
#endif #endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* truth-values */
/* stdbool defines the booleam type, bool,
and the constants false and true */
#if HAVE_STDBOOL_H #if HAVE_STDBOOL_H
#include <stdbool.h> #include <stdbool.h>
#else #else
#ifndef true #ifndef true
typedef int _Bool; typedef int _Bool;
v
#define bool _Bool; #define bool _Bool;
#define false 0 #define false 0
@ -107,16 +110,25 @@ typedef bool YAP_Bool;
#else #else
/* Type definitions */ /* Type definitions */
#if defined(PRIdPTR)
#if _WIN64 typedef uintptr_t YAP_UInt;
typedef unsigned long long YAP_CELL; typedef intptr_t YAP_Int;
#elif _WIN64
typedef int64_t YAP_Int;
typedef uint64_t YAP_UInt;
#elif _WIN32
typedef int32_t YAP_Int;
typedef uint32_t YAP_UInt;
#else #else
typedef uintptr_t YAP_CELL; typedef long int YAP_Int;
typedef unsigned long int YAP_UInt;
#endif #endif
typedef YAP_UInt YAP_CELL;
typedef YAP_CELL YAP_Term; typedef YAP_CELL YAP_Term;
typedef YAP_CELL YAP_Arity; typedef size_t YAP_Arity;
typedef YAP_Term YAP_Module; typedef YAP_Term YAP_Module;
@ -124,17 +136,6 @@ typedef struct FunctorEntry *YAP_Functor;
typedef struct AtomEntry *YAP_Atom; typedef struct AtomEntry *YAP_Atom;
#if _WIN64
typedef long long int YAP_Int;
typedef unsigned long long int YAP_UInt;
#else
typedef long int YAP_Int;
typedef unsigned long int YAP_UInt;
#endif
typedef double YAP_Float; typedef double YAP_Float;
#ifndef TRUE #ifndef TRUE
@ -172,14 +173,16 @@ typedef struct YAP_thread_attr_struct {
#include <threads.h> #include <threads.h>
#endif #endif
typedef enum { YAP_BIN = 0x0001, typedef enum {
YAP_TEXT = 0x0002, YAP_BIN = 0x0001,
YAP_SAVED_STATE = 0x0004, YAP_TEXT = 0x0002,
YAP_OBJ = 0x0008, YAP_SAVED_STATE = 0x0004,
YAP_PL = 0x0010, YAP_OBJ = 0x0008,
YAP_BOOT_PL = 0x0030, YAP_PL = 0x0010,
YAP_QLY = 0x0040, YAP_BOOT_PL = 0x0030,
YAP_EXE = 0x0080 YAP_QLY = 0x0040,
YAP_EXE = 0x0080,
YAP_FOUND_BOOT_ERROR = 0x0100
} YAP_file_type_t; } YAP_file_type_t;
#define YAP_ANY_FILE (0x00ff) #define YAP_ANY_FILE (0x00ff)
@ -197,9 +200,9 @@ typedef enum {
YAP_TAG_FLOAT = 0x200, YAP_TAG_FLOAT = 0x200,
YAP_TAG_OPAQUE = 0x400, YAP_TAG_OPAQUE = 0x400,
YAP_TAG_APPL = 0x800, YAP_TAG_APPL = 0x800,
YAP_TAG_DBREF = 0x1000, YAP_TAG_DBREF = 0x1000,
YAP_TAG_STRING = 0x2000, YAP_TAG_STRING = 0x2000,
YAP_TAG_ARRAY = 0x4000 YAP_TAG_ARRAY = 0x4000
} YAP_tag_t; } YAP_tag_t;
#define YAP_BOOT_FROM_SAVED_CODE 1 #define YAP_BOOT_FROM_SAVED_CODE 1
@ -223,26 +226,26 @@ typedef enum {
typedef struct yap_boot_params { typedef struct yap_boot_params {
/* boot type as suggested by the user */ /* boot type as suggested by the user */
YAP_file_type_t initial_file_type; YAP_file_type_t boot_file_type;
/* if NON-NULL, path where we can find the saved state */ /* if NON-NULL, path where we can find the saved state */
const char *SavedState; const char *SavedState;
/* if NON-0, minimal size for Heap or Code Area */ /* if NON-0, minimal size for Heap or Code Area */
unsigned long int HeapSize; size_t HeapSize;
/* if NON-0, maximal size for Heap or Code Area */ /* if NON-0, maximal size for Heap or Code Area */
unsigned long int MaxHeapSize; size_t MaxHeapSize;
/* if NON-0, minimal size for Local+Global Stack */ /* if NON-0, minimal size for Local+Global Stack */
unsigned long int StackSize; size_t StackSize;
/* if NON-0, maximal size for Local+Global Stack */ /* if NON-0, maximal size for Local+Global Stack */
unsigned long int MaxStackSize; size_t MaxStackSize;
unsigned long int MaxGlobalSize; size_t MaxGlobalSize;
/* if NON-0, minimal size for Trail */ /* if NON-0, minimal size for Trail */
unsigned long int TrailSize; size_t TrailSize;
/* if NON-0, maximal size for Trail */ /* if NON-0, maximal size for Trail */
unsigned long int MaxTrailSize; size_t MaxTrailSize;
/* if NON-0, minimal size for AttributeVarStack */ /* if NON-0, minimal size for AttributeVarStack */
unsigned long int AttsSize; size_t AttsSize;
/* if NON-0, maximal size for AttributeVarStack */ /* if NON-0, maximal size for AttributeVarStack */
unsigned long int MaxAttsSize; size_t MaxAttsSize;
/* if NON-NULL, value for YAPLIBDIR */ /* if NON-NULL, value for YAPLIBDIR */
const char *YapLibDir; const char *YapLibDir;
/* if NON-NULL, name for a Prolog file to use when booting */ /* if NON-NULL, name for a Prolog file to use when booting */
@ -263,7 +266,7 @@ typedef struct yap_boot_params {
bool FastBoot; bool FastBoot;
/* the next field only interest YAPTAB */ /* the next field only interest YAPTAB */
/* if NON-0, maximum size for Table Space */ /* if NON-0, maximum size for Table Space */
unsigned long int MaxTableSpaceSize; size_t MaxTableSpaceSize;
/* the next three fields only interest YAPOR, but we keep them so that /* the next three fields only interest YAPOR, but we keep them so that
users don't need to recompile DLL in order to use YAPOR */ users don't need to recompile DLL in order to use YAPOR */
/* if NON-0, number of workers we want to have (default=1) */ /* if NON-0, number of workers we want to have (default=1) */
@ -307,7 +310,8 @@ typedef struct yap_boot_params {
} YAP_init_args; } YAP_init_args;
#ifdef YAP_H #ifdef YAP_H
Int Yap_InitDefaults(YAP_init_args *init_args, char saved_state[]); YAP_file_type_t Yap_InitDefaults(YAP_init_args *init_args, char saved_state[],
int Argc, char *Argv[]);
#endif #endif
/* this should be opaque to the user */ /* this should be opaque to the user */
@ -414,4 +418,11 @@ typedef enum yap_enum_reset_t {
YAP_RESET_FROM_RESTORE = 3 YAP_RESET_FROM_RESTORE = 3
} yap_reset_t; } yap_reset_t;
typedef bool (*YAP_ModInit_t)(void);
typedef struct {
YAP_ModInit_t f;
const char *s;
} YAP_delaymodule_t;
#endif /* _YAPDEFS_H */ #endif /* _YAPDEFS_H */

View File

@ -1,5 +1,3 @@
/// ///
/// @file YapErrors.h /// @file YapErrors.h
/// ///
@ -52,6 +50,9 @@ E(DOMAIN_ERROR_ARRAY_TYPE, DOMAIN_ERROR, "array_type")
E(DOMAIN_ERROR_CLOSE_OPTION, DOMAIN_ERROR, "close_option") E(DOMAIN_ERROR_CLOSE_OPTION, DOMAIN_ERROR, "close_option")
E(DOMAIN_ERROR_FILE_ERRORS, DOMAIN_ERROR, "file_errors") E(DOMAIN_ERROR_FILE_ERRORS, DOMAIN_ERROR, "file_errors")
E(DOMAIN_ERROR_FILE_TYPE, DOMAIN_ERROR, "file_type") E(DOMAIN_ERROR_FILE_TYPE, DOMAIN_ERROR, "file_type")
E(DOMAIN_ERROR_FORMAT_CONTROL_SEQUENCE, DOMAIN_ERROR, "format argument "
"domain")
E(DOMAIN_ERROR_FORMAT_OUTPUT, DOMAIN_ERROR, "format output")
E(DOMAIN_ERROR_GENERIC_ARGUMENT, DOMAIN_ERROR, "generic_argument") E(DOMAIN_ERROR_GENERIC_ARGUMENT, DOMAIN_ERROR, "generic_argument")
E(DOMAIN_ERROR_IO_MODE, DOMAIN_ERROR, "io_mode") E(DOMAIN_ERROR_IO_MODE, DOMAIN_ERROR, "io_mode")
E(DOMAIN_ERROR_MUTABLE, DOMAIN_ERROR, "mutable") E(DOMAIN_ERROR_MUTABLE, DOMAIN_ERROR, "mutable")