diff --git a/H/HEAPFIELDS b/H/HEAPFIELDS index b23b305c2..61c73faea 100644 --- a/H/HEAPFIELDS +++ b/H/HEAPFIELDS @@ -28,11 +28,11 @@ START_HEAP /* memory management */ -UInt Yap_HoleSize void void -struct malloc_state *Yap_av void void +UInt Yap_HoleSize #if USE_DL_MALLOC -struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES] void void -UInt Yap_NOfMemoryHoles void void +struct malloc_state *Yap_av +struct memory_hole Yap_MemoryHoles[MAX_DLMALLOC_HOLES] +UInt Yap_NOfMemoryHoles #if defined(YAPOR) || defined(THREADS) lockvar DLMallocLock MkLock #endif diff --git a/H/Yap.h b/H/Yap.h index 1c6190f3d..3f6d4a6c4 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -256,6 +256,11 @@ INLINE_ONLY inline EXTERN size_t strnlen(const char *s, size_t maxlen) { /* #define RANDOMIZE_START_ADDRESS 1 */ + + +extern size_t Yap_page_size; + + #ifdef USE_SYSTEM_MALLOC #define HEAP_INIT_BASE 0L #define AtomBase NULL @@ -480,6 +485,11 @@ extern bool Yap_AccessAsset(const char *name, int mode); extern bool Yap_AssetIsFile(const char *name); extern bool Yap_AssetIsDir(const char *name); extern int64_t Yap_AssetSize(const char *name); + +#else + +#define __android_log_print(...) + #endif /************************************************************************************************* diff --git a/H/YapGFlagInfo.h b/H/YapGFlagInfo.h index 73f5f9f43..392198980 100644 --- a/H/YapGFlagInfo.h +++ b/H/YapGFlagInfo.h @@ -33,7 +33,7 @@ Set or read system properties for _Param_: YAP_FLAG(ADDRESS_BITS_FLAG, "address_bits", false, nat, BITNESS, NULL), /** `address_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 ` An integer: if this amount of atoms has been created since the last @@ -337,7 +337,8 @@ only if the query contains variables. The alternative, default in SWI-Prolog is goal succeeded while leaving choicepoints. */ YAP_FLAG(QUASI_QUOTATIONS_FLAG, "quasi_quotations", true, booleanFlag, "true", 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. */ YAP_FLAG(REPORT_ERROR_FLAG, "report_error", true, booleanFlag, "true", NULL), diff --git a/H/YapHeap.h b/H/YapHeap.h index 143867121..745d9c29c 100755 --- a/H/YapHeap.h +++ b/H/YapHeap.h @@ -61,7 +61,7 @@ typedef struct memory_hole { ADDR start; ADDR end; } memory_hole_type; -#endif +#endif // USE_DL_MALLOC typedef struct swi_reverse_hash { ADDR key; @@ -155,6 +155,7 @@ typedef struct thandle { this is the data base: everything here should be possible to restore ********************/ #if YAPOR + typedef struct various_codes { /* memory allocation and management */ special_functors funcs; diff --git a/H/YapText.h b/H/YapText.h index eb31a9b07..a69dd9726 100644 --- a/H/YapText.h +++ b/H/YapText.h @@ -1320,6 +1320,34 @@ static inline Term Yap_StringToNumber(Term t0 USES_REGS) { 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 Term Yap_UTF8ToString(const char *s USES_REGS) { return MkStringTerm(s); } diff --git a/H/Yapproto.h b/H/Yapproto.h index 3b19651d0..5403cf271 100755 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -176,7 +176,7 @@ void Yap_InitDBPreds(void); /* errors.c */ #if DEBUG -void Yap_PrintPredName(struct pred_entry *ap); +const char *Yap_PrintPredName(struct pred_entry *ap); #endif void Yap_RestartYap(int); void Yap_exit(int); @@ -308,6 +308,7 @@ void Yap_CloseReadline(void); bool Yap_InitReadline(Term t); void Yap_InitItDeepenPreds(void); struct AliasDescS *Yap_InitStandardAliases(void); +struct vfs *Yap_InitAssetManager(void); /* load_foreign.c */ void Yap_InitLoadForeign(void); @@ -355,7 +356,7 @@ void Yap_InitReadUtil(void); /* qly.c */ void Yap_InitQLY(void); -int Yap_Restore(const char *, const char *); +YAP_file_type_t Yap_Restore(const char *, const char *); void Yap_InitQLYR(void); /* range.c */ diff --git a/H/dlmalloc.h b/H/dlmalloc.h index 1df96e7ef..9a63ab058 100644 --- a/H/dlmalloc.h +++ b/H/dlmalloc.h @@ -176,6 +176,7 @@ extern "C" { or other mallocs available that do this. */ +#define DEBUG_DLMALLOC 1 #if DEBUG_DLMALLOC #include #else