diff --git a/C/adtdefs.c b/C/adtdefs.c index ad2019bec..f9af62f28 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -804,14 +804,14 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p)); if (p == NULL) { - FUNC_WRITE_UNLOCK(fe); + WRITE_UNLOCK(fe); return NULL; } if (cur_mod == TermProlog) p->ModuleOfPred = 0L; else p->ModuleOfPred = cur_mod; - TRUE_FUNC_WRITE_LOCK(fe); + //TRUE_FUNC_WRITE_LOCK(fe); INIT_LOCK(p->PELock); p->KindOfPE = PEProp; p->ArityOfPE = fe->ArityOfFE; @@ -861,7 +861,7 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) if (!ExpandPredHash()) { Yap_FreeCodeSpace((ADDR)p); WRITE_UNLOCK(PredHashRWLock); - TRUE_FUNC_WRITE_UNLOCK(fe); + FUNC_WRITE_UNLOCK(fe); return NULL; } /* retry hashing */ @@ -887,7 +887,7 @@ Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) fe->PropsOfFE = AbsPredProp(p); p->NextOfPE = NIL; } - TRUE_FUNC_WRITE_UNLOCK(fe); + FUNC_WRITE_UNLOCK(fe); { Yap_inform_profiler_of_clause(&(p->OpcodeOfPred), &(p->OpcodeOfPred)+1, p, GPROF_NEW_PRED_FUNC); if (!(p->PredFlags & (CPredFlag|AsmPredFlag))) { diff --git a/C/c_interface.c b/C/c_interface.c index ad9eee0bd..60541b76e 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2307,7 +2307,7 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi) } else { LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal } - { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL DONE %d", out) ; } + { __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL DONE %d", out) ; } return out; } diff --git a/C/pl-yap.c b/C/pl-yap.c index 6a4b9c307..c06477016 100755 --- a/C/pl-yap.c +++ b/C/pl-yap.c @@ -926,12 +926,12 @@ Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags r = buf; fd = Sopenmem(&r, &sz, "w"); fd->encoding = ENC_UTF8; - { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0+%s=(%p) %p", l, buf, LCL0, &LCL0 ); } + { __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0+%s=(%p) %p", l, buf, LCL0, &LCL0 ); } if ( PL_write_term(fd, l, 1200, flags) && Sputcode(EOS, fd) >= 0 && Sflush(fd) >= 0 ) { - { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I LCL0+%s=(%p) %p", buf, LCL0, &LCL0 ); } + { __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I LCL0+%s=(%p) %p", buf, LCL0, &LCL0 ); } size = Stell64(fd); *length = size-1; char *bf = malloc(*length+1); diff --git a/C/sysbits.c b/C/sysbits.c index 0c1e9bd61..6f05edf16 100755 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -1807,7 +1807,7 @@ Yap_volume_header(char *file) char * Yap_getcwd(const char *cwd, size_t cwdlen) { - return PL_cwd(cwd, cwdlen); + return PL_cwd((char *)cwd, cwdlen); } /****** diff --git a/CXX/yapi.cpp b/CXX/yapi.cpp index cbe92ed57..d1161814d 100644 --- a/CXX/yapi.cpp +++ b/CXX/yapi.cpp @@ -277,7 +277,7 @@ char *YAPTerm::text(void) { if (!(os = Yap_HandleToString(t, sze, &length, &enc, 0))) { { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "IIa LCL0+t=(%p) %x", LCL0, LCL0[-15]) ; } RECOVER_MACHINE_REGS(); - return NULL; + return (char *)NULL; } { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II LCL0+t=(%p) %x", LCL0, LCL0[-15]) ; } RECOVER_MACHINE_REGS(); @@ -403,12 +403,12 @@ PredEntry *YAPPredicate::getPred( Term t, Term **outp ) { Term m = CurrentModule ; t = Yap_StripModule(t, &m); if (IsVarTerm(t) || IsNumTerm(t)) { - ap = NULL; - if (outp) *outp = NULL; + ap = (PredEntry *)NULL; + if (outp) *outp = (Term *)NULL; } if (IsAtomTerm(t)) { ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m)); - if (outp) *outp = NULL; + if (outp) *outp = (Term *)NULL; } else if (IsPairTerm(t)) { ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE)); if (outp) *outp = HR; @@ -418,8 +418,8 @@ PredEntry *YAPPredicate::getPred( Term t, Term **outp ) { } else { Functor f = FunctorOfTerm(t); if (IsExtensionFunctor(f)) { - ap = NULL; - if (outp) *outp = NULL; + ap = (PredEntry *)NULL; + if (outp) *outp = (Term *)NULL; } ap = RepPredProp(PredPropByFunc(f, m)); if (outp) *outp = RepAppl(t)+1; @@ -525,7 +525,7 @@ void YAPQuery::close() CACHE_REGS if (EX && !(this->q_flags & (PL_Q_CATCH_EXCEPTION))) { - EX = NULL; + EX = (struct DB_TERM *)NULL; } /* need to implement backtracking here */ if (this->q_open != 1 || this->q_state == 0) { @@ -599,7 +599,7 @@ YAPEngine::YAPEngine( char *savedState, YAPCallback *cb): _callback(0) { // a single engine can be active #if __ANDROID__ - if (assetManager == NULL) + if (assetManager == (AAssetManager *)NULL) return; Yap_DisplayWithJava = displayWithJava; Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096); diff --git a/CXX/yapi.hh b/CXX/yapi.hh index d2350ff40..44812c8ef 100644 --- a/CXX/yapi.hh +++ b/CXX/yapi.hh @@ -20,16 +20,20 @@ #include -extern "C" { - -#ifdef __cplusplus -#define old_cplusplus __cplusplus -#undef __cplusplus -#endif +#ifndef __ANDROID__ +#if USE_GMP +#include +#endif +#endif + +extern "C" { + +#ifdef __ANDROID__ +#define old_cplusplus __cplusplus +#undef __cplusplus #if USE_GMP #include #endif -#ifdef old_cplusplus #define __cplusplus old_cplusplus #undef old_cplusplus #endif @@ -341,7 +345,7 @@ private: /// /// It is just a call to getPred inline YAPPredicate(Term t) { - ap = getPred( t , NULL ); + ap = getPred( t , (Term **)NULL ); } /// Cast constructor for predicates, @@ -397,7 +401,7 @@ public: inline YAPPredicate(char *s) { Term t, tp; t = YAP_ReadBuffer(s,&tp); - ap = getPred( t, NULL ); + ap = getPred( t, (Term **)NULL ); } @@ -407,7 +411,7 @@ public: inline YAPPredicate(char *s, Term **outp) { Term t, tp; t = YAP_ReadBuffer(s,&tp); - ap = getPred( t, NULL ); + ap = getPred( t, (Term **)NULL ); } /// meta-call this predicate, with arguments ts[] @@ -516,21 +520,20 @@ public: class YAPEngine { private: YAPCallback *_callback; - char **buf; YAP_init_args init_args; public: - YAPEngine(char *savedState = NULL, + YAPEngine(char *savedState = (char *)NULL, size_t stackSize = 0, size_t trailSize = 0, size_t maxStackSize = 0, size_t maxTrailSize = 0, - char *libDir = NULL, - char *bootFile = NULL, - char *goal = NULL, - char *topLevel = NULL, + char *libDir = (char *)NULL, + char *bootFile = (char *)NULL, + char *goal = (char *)NULL, + char *topLevel = (char *)NULL, bool script = FALSE, bool fastBoot = FALSE, - YAPCallback *callback=NULL); /// construct a new engine, including aaccess to callbacks + YAPCallback *callback=(YAPCallback *)NULL); /// construct a new engine, including aaccess to callbacks ~YAPEngine() { delYAPCallback(); } /// kill engine void delYAPCallback() { _callback = 0; } /// remove current callback void setYAPCallback(YAPCallback *cb) { delYAPCallback(); _callback = cb; __android_log_print(ANDROID_LOG_INFO, __FILE__, "after loading startup %p",cb); } /// set a new callback diff --git a/H/Yap.h b/H/Yap.h index 313dac24f..765001f5e 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -287,6 +287,12 @@ typedef pthread_rwlock_t rwlock_t; #include #endif +#define FUNC_READ_LOCK(X) READ_LOCK((X)->FRWLock) +#define FUNC_READ_UNLOCK(X) READ_UNLOCK((X)->FRWLock) +#define FUNC_WRITE_LOCK(X) WRITE_LOCK((X)->FRWLock) +#define FUNC_WRITE_UNLOCK(X) WRITE_UNLOCK((X)->FRWLock) + + /************************************************************************************************* use an auxiliary function for ranges *************************************************************************************************/ @@ -453,6 +459,19 @@ extern ADDR Yap_HeapBase; extern int Yap_output_msg; #endif + +#if __ANDROID__ +#include +#include +#include +#else +inline void __android_log_print(int i, const char loc[], const char msg[], ...) {} +#define ANDROID_LOG_INFO 0 +#define ANDROID_LOG_ERROR 0 +#define ANDROID_LOG_DEBUG 0 +#endif + + /************************************************************************************************* variables concerned with atoms table *************************************************************************************************/ @@ -690,7 +709,6 @@ typedef struct scratch_block_struct { #endif /* YAPOR || TABLING */ - /************************************************************************************************* GLOBAL and LOCAL variables *************************************************************************************************/ diff --git a/H/YapText.h b/H/YapText.h index 8dd61f75f..87e412103 100644 --- a/H/YapText.h +++ b/H/YapText.h @@ -370,7 +370,7 @@ Yap_ListOfAtomsToAtom(Term t0 USES_REGS) inp.type = YAP_STRING_ATOMS; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return NULL; + return (Atom)NULL; return out.val.a; } @@ -406,7 +406,7 @@ Yap_ListOfCodesToAtom(Term t0 USES_REGS) inp.type = YAP_STRING_CODES; out.type = YAP_STRING_ATOM; if (!Yap_CVT_Text(&inp, &out PASS_REGS)) - return NULL; + return (Atom)NULL; return out.val.a; } @@ -870,7 +870,7 @@ Yap_ConcatAtoms(Term t1, Term t2 USES_REGS) inpv[1].sz = 0; out.type = YAP_STRING_ATOM; if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)) - return NULL; + return (Atom)NULL; return out.val.a; } @@ -886,7 +886,7 @@ Yap_ConcatAtomics(Term t1, Term t2 USES_REGS) inpv[1].sz = 0; out.type = YAP_STRING_ATOM; if (!Yap_Concat_Text(2, inpv, &out PASS_REGS)) - return NULL; + return (Atom)NULL; return out.val.a; } @@ -921,8 +921,8 @@ Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, size_t max USES_REGS) outv[0].sz = 0; outv[1].type = YAP_STRING_ATOM; outv[1].sz = 0; - if (!Yap_Splice_Text(2, cuts, &inp, NULL, outv PASS_REGS)) - return NULL; + if (!Yap_Splice_Text(2, cuts, &inp, (encoding_t *)NULL, outv PASS_REGS)) + return (Atom)NULL; ats[0] = outv[0].val.a; ats[1] = outv[1].val.a; return ats[0]; @@ -941,8 +941,8 @@ Yap_SubtractHeadAtom(Term t1, Term th USES_REGS) outv[1].type = YAP_STRING_ATOM; outv[1].val.t = 0; outv[1].sz = 0; - if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS)) - return NULL; + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) + return (Atom)NULL; return outv[1].val.a; } @@ -959,8 +959,8 @@ Yap_SubtractTailAtom(Term t1, Term th USES_REGS) outv[0].sz = 0; outv[1].type = YAP_STRING_ATOM; outv[1].val.t = th; - if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS)) - return NULL; + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) + return (Atom)NULL; return outv[0].val.a; } @@ -977,7 +977,7 @@ Yap_SpliceString(Term t1, Term ts[], size_t cut, size_t max USES_REGS) outv[1].sz = 0; cuts[0] = cut; cuts[1] = max; - if (!Yap_Splice_Text(2, cuts, &inp, NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, cuts, &inp, (encoding_t *)NULL, outv PASS_REGS)) return 0L; ts[0] = outv[0].val.t; ts[1] = outv[1].val.t; @@ -997,7 +997,7 @@ Yap_SubtractHeadString(Term t1, Term th USES_REGS) outv[1].type = YAP_STRING_STRING; outv[1].val.t = 0; outv[1].sz = 0; - if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) return 0L; return outv[1].val.t; } @@ -1014,7 +1014,7 @@ Yap_SubtractTailString(Term t1, Term th USES_REGS) outv[0].sz = 0; outv[1].type = YAP_STRING_STRING; outv[1].val.t = th; - if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS)) + if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, (encoding_t *)NULL, outv PASS_REGS)) return 0L; return outv[0].val.t; } diff --git a/H/Yatom.h b/H/Yatom.h index 58bbd881d..48dc9845a 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -1267,7 +1267,7 @@ Yap_GetTranslationProp(Atom at) while (p0 && p->KindOfPE != TranslationProperty) p = RepTranslationProp(p0 = p->NextOfPE); READ_UNLOCK(ae->ARWLock); - if (p0 == NIL) return NULL; + if (p0 == NIL) return (TranslationEntry *)NULL; return p; } diff --git a/H/clause.h b/H/clause.h index 62edb98f1..ba8e95774 100644 --- a/H/clause.h +++ b/H/clause.h @@ -202,7 +202,7 @@ INLINE_ONLY EXTERN inline CELL * EXO_OFFSET_TO_ADDRESS(struct index_t *it, BITS32 off) { if (off == 0L) - return NULL; + return (CELL *)NULL; return (it->cls)+(off-1)*it->arity; } diff --git a/H/pl-shared.h b/H/pl-shared.h index e601f8b35..500ad706f 100755 --- a/H/pl-shared.h +++ b/H/pl-shared.h @@ -345,7 +345,7 @@ OpenList(int n USES_REGS) BACKUP_H(); while (HR+2*n > ASP-1024) { - if (!Yap_dogc( 0, NULL PASS_REGS )) { + if (!Yap_dogc( 0, (Term *)NULL PASS_REGS )) { RECOVER_H(); return FALSE; }