From f0343fc62c14750aac41fe4f36d60cbd0b0b79a5 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Fri, 15 Jun 2018 13:55:31 +0100 Subject: [PATCH] merge droid --- C/stack.c | 112 +++++++++++++++++++-------------------- CXX/yapq.hh | 4 +- H/Yatom.h | 1 + H/inline-only.h | 4 +- include/VFS.h | 2 +- os/files.c | 6 +-- packages/myddas/myddas.h | 4 +- 7 files changed, 67 insertions(+), 66 deletions(-) diff --git a/C/stack.c b/C/stack.c index 675fa47c5..5066c4009 100644 --- a/C/stack.c +++ b/C/stack.c @@ -1391,12 +1391,12 @@ void Yap_dump_code_area_for_profiler(void) { while (pp != NULL) { /* if (pp->ArityOfPE) { - fprintf(stderr,"\%s/%d %p\n", + fprintf(stderr,"%%s/%d %p\n", RepAtom(NameOfFunctor(pp->FunctorOfPred))->StrOfAE, pp->ArityOfPE, pp); } else { - fprintf(stderr,"\%s %p\n", + fprintf(stderr,"%%s %p\n", RepAtom((Atom)(pp->FunctorOfPred))->StrOfAE, pp); }*/ @@ -1796,83 +1796,83 @@ void Yap_dump_stack(void) { /* check if handled */ if (handled_exception(PASS_REGS1)) return; -#if DEBU - fprintf(stderr, "\% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n", +#if DEBUG + fprintf(stderr, "%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n", P, CP, ASP, HR, TR, HeapTop); #endif - fprintf(stderr, "\% \n% =====================================\n\%\n"); - fprintf(stderr, "\% \n% YAP Status:\n"); - fprintf(stderr, "\% \n\% -------------------------------------\n\%\n"); - yap_error_descriptor_t errno = LOCAL_Error_TYPE; - yap_error_class_number classno = Yap_errorClass(errno); + fprintf(stderr, "%% \n%% =====================================\n%%\n"); + fprintf(stderr, "%% \n%% YAP Status:\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + yap_error_number errnb = LOCAL_Error_TYPE; + yap_error_class_number classno = Yap_errorClass(errnb); - fprintf(stderr, "\% Error STATUS: %s/%s\n\n", Yap_errorName(errno), + fprintf(stderr, "%% Error STATUS: %s/%s\n\n", Yap_errorName(errnb), Yap_errorName(classno)); - fprintf(stderr, "\% Execution mode\n"); + fprintf(stderr, "%% Execution mode\n"); if (LOCAL_PrologMode & BootMode) - fprintf(stderr, "\% Bootstrap\n"); + fprintf(stderr, "%% Bootstrap\n"); if (LOCAL_PrologMode & UserMode) - fprintf(stderr, "\% User Prolo\n"); + fprintf(stderr, "%% User Prolo\n"); if (LOCAL_PrologMode & CritMode) - fprintf(stderr, "\% Exclusive Access Mode\n"); + fprintf(stderr, "%% Exclusive Access Mode\n"); if (LOCAL_PrologMode & AbortMode) - fprintf(stderr, "\% Abort\n"); + fprintf(stderr, "%% Abort\n"); if (LOCAL_PrologMode & InterruptMode) - fprintf(stderr, "\% Interrupt\n"); + fprintf(stderr, "%% Interrupt\n"); if (LOCAL_PrologMode & InErrorMode) - fprintf(stderr, "\% Error\n"); + fprintf(stderr, "%% Error\n"); if (LOCAL_PrologMode & ConsoleGetcMode) - fprintf(stderr, "\% Prompt Console\n"); + fprintf(stderr, "%% Prompt Console\n"); if (LOCAL_PrologMode & ExtendStackMode) - fprintf(stderr, "\% Stack expansion \n"); + fprintf(stderr, "%% Stack expansion \n"); if (LOCAL_PrologMode & GrowHeapMode) - fprintf(stderr, "\% Data Base Expansion\n"); + fprintf(stderr, "%% Data Base Expansion\n"); if (LOCAL_PrologMode & GrowStackMode) - fprintf(stderr, "\% User Prolog\n"); + fprintf(stderr, "%% User Prolog\n"); if (LOCAL_PrologMode & GCMode) - fprintf(stderr, "\% Garbage Collection\n"); + fprintf(stderr, "%% Garbage Collection\n"); if (LOCAL_PrologMode & ErrorHandlingMode) - fprintf(stderr, "\% Error handler\n"); + fprintf(stderr, "%% Error handler\n"); if (LOCAL_PrologMode & CCallMode) - fprintf(stderr, "\% System Foreign Code\n"); + fprintf(stderr, "%% System Foreign Code\n"); if (LOCAL_PrologMode & UnifyMode) - fprintf(stderr, "\% Off-line Foreign Code\n"); + fprintf(stderr, "%% Off-line Foreign Code\n"); if (LOCAL_PrologMode & UserCCallMode) - fprintf(stderr, "\% User Foreig C\n"); + fprintf(stderr, "%% User Foreig C\n"); if (LOCAL_PrologMode & MallocMode) - fprintf(stderr, "\% Heap Allocaror\n"); + fprintf(stderr, "%% Heap Allocaror\n"); if (LOCAL_PrologMode & SystemMode) - fprintf(stderr, "\% Prolog Internals\n"); + fprintf(stderr, "%% Prolog Internals\n"); if (LOCAL_PrologMode & AsyncIntMode) - fprintf(stderr, "\% Async Interruot mode\n"); + fprintf(stderr, "%% Async Interruot mode\n"); if (LOCAL_PrologMode & InReadlineMode) - fprintf(stderr, "\% Readline Console\n"); + fprintf(stderr, "%% Readline Console\n"); if (LOCAL_PrologMode & TopGoalMode) - fprintf(stderr, "\% Creating new query\n"); - fprintf(stderr, "\% \n\% -------------------------------------\n\%\n"); - fprintf(stderr, "\% \n% YAP Program :\n"); - fprintf(stderr, "\% \n\% -------------------------------------\n\%\n"); - fprintf(stderr, "\% Program Position\n\n", Yap_errorName(errno), - Yap_errorName(classno); + fprintf(stderr, "%% Creating new query\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + fprintf(stderr, "%% \n%% YAP Program :\n"); + fprintf(stderr, "%% \n%% -------------------------------------\n%%\n"); + fprintf(stderr, "%% Program Position\n\n", Yap_errorName(errno), + Yap_errorName(classno)); Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256); - fprintf(stderr, "\% PC: %s\n", (char *)HR); + fprintf(stderr, "%% PC: %s\n", (char *)HR); Yap_detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, 256); - fprintf(stderr, "\% Continuation: %s\n", (char *)HR); + fprintf(stderr, "%% Continuation: %s\n", (char *)HR); Yap_detect_bug_location(B->cp_ap, FIND_PRED_FROM_ANYWHERE, 256); - fprintf(stderr, "\% Alternative: %s\n", (char *)HR); + fprintf(stderr, "%% Alternative: %s\n", (char *)HR); if (HR > ASP || HR > LCL0) { - fprintf(stderr, "\% YAP ERROR: Global Collided against Local (%p--%p)\n", + fprintf(stderr, "%% YAP ERROR: Global Collided against Local (%p--%p)\n", HR, ASP); } else if (HeapTop > (ADDR)LOCAL_GlobalBase) { fprintf(stderr, - "\% YAP ERROR: Code Space Collided against Global (%p--%p)\n", + "%% YAP ERROR: Code Space Collided against Global (%p--%p)\n", HeapTop, LOCAL_GlobalBase); } else { #if !USE_SYSTEM_MALLOC - fprintf(stderr, "\%ldKB of Code Space (%p--%p)\n", + fprintf(stderr, "%%ldKB of Code Space (%p--%p)\n", (long int)((CELL)HeapTop - (CELL)Yap_HeapBase) / 1024, Yap_HeapBase, HeapTop); #if USE_DL_MALLOC @@ -1885,14 +1885,14 @@ void Yap_dump_stack(void) { } #endif #endif - fprintf(stderr, "\% %luKB of Global Stack (%p--%p)\n", + fprintf(stderr, "%% %luKB of Global Stack (%p--%p)\n", (unsigned long int)(sizeof(CELL) * (HR - H0)) / 1024, H0, HR); - fprintf(stderr, "\% %luKB of Local Stack (%p--%p)\n", + fprintf(stderr, "%% %luKB of Local Stack (%p--%p)\n", (unsigned long int)(sizeof(CELL) * (LCL0 - ASP)) / 1024, ASP, LCL0); - fprintf(stderr, "\% %luKB of Trail (%p--%p)\n", + fprintf(stderr, "%% %luKB of Trail (%p--%p)\n", (unsigned long int)((ADDR)TR - LOCAL_TrailBase) / 1024, LOCAL_TrailBase, TR); - fprintf(stderr, "\% Performed %ld garbage collections\n", + fprintf(stderr, "%% Performed %ld garbage collections\n", (unsigned long int)LOCAL_GcCalls); #if LOW_LEVEL_TRACER { @@ -1907,20 +1907,20 @@ void Yap_dump_stack(void) { } } #endif - fprintf(stderr, "\% All Active Calls and\n"); - fprintf(stderr, "\% Goals With Alternatives Open (Global In " + fprintf(stderr, "%% All Active Calls and\n"); + fprintf(stderr, "%% Goals With Alternatives Open (Global In " "Use--Local In Use)\n%%\n"); while (b_ptr != NULL) { while (env_ptr && env_ptr <= (CELL *)b_ptr) { Yap_detect_bug_location(ipc, FIND_PRED_FROM_ENV, 256); if (env_ptr == (CELL *)b_ptr && (choiceptr)env_ptr[E_CB] > b_ptr) { b_ptr = b_ptr->cp_b; - fprintf(stderr, "\% %s\n", tp); + fprintf(stderr, "%% %s\n", tp); } else { fprintf(stderr, "%% %s\n", tp); } if (!max_count--) { - fprintf(stderr, "\% .....\n"); + fprintf(stderr, "%% .....\n"); return; } ipc = (yamop *)(env_ptr[E_CP]); @@ -1928,7 +1928,7 @@ void Yap_dump_stack(void) { } if (b_ptr) { if (!max_count--) { - fprintf(stderr, "\%\** .....\n"); + fprintf(stderr, "%%\** .....\n"); return; } if (b_ptr->cp_ap && /* tabling */ @@ -1937,7 +1937,7 @@ void Yap_dump_stack(void) { b_ptr->cp_ap->opc != Yap_opcode(_Nstop)) { /* we can safely ignore ; because there is always an upper env */ Yap_detect_bug_location(b_ptr->cp_ap, FIND_PRED_FROM_CP, 256); - fprintf(stderr, "\% %s (%luKB--%luKB)\n", tp, + fprintf(stderr, "%% %s (%luKB--%luKB)\n", tp, (unsigned long int)((b_ptr->cp_h - H0) * sizeof(CELL) / 1024), (unsigned long int)((ADDR)LCL0 - (ADDR)b_ptr) / 1024); } @@ -2002,7 +2002,7 @@ void DumpActiveGoals(USES_REGS1) { op_numbers opnum; if (!ONLOCAL(b_ptr) || b_ptr->cp_b == NULL) break; - fprintf(stderr, "\%p ", b_ptr); + fprintf(stderr, "%%p ", b_ptr); pe = Yap_PredForChoicePt(b_ptr, &opnum); if (opnum == _Nstop) { fprintf(stderr, " ********** C-Code Interface Boundary ***********\n"); @@ -2090,15 +2090,15 @@ void Yap_detect_bug_location(yamop *yap_pc, int where_from, int psize) { if ((cl = Yap_PredForCode(yap_pc, where_from, &pred_name, &pred_arity, &pred_module)) == 0) { /* system predicate */ - fprintf(stderr, "\%s", "meta-call"); + fprintf(stderr, "%%s", "meta-call"); } else if (pred_module == 0) { fprintf(stderr, "in prolog:%s/%lu", RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); } else if (cl < 0) { - fprintf(stderr, "\%s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE, + fprintf(stderr, "%%s:%s/%lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE, RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity); } else { - fprintf(stderr, "\%s:%s/%lu at clause %lu", + fprintf(stderr, "%%s:%s/%lu at clause %lu", RepAtom(AtomOfTerm(pred_module))->StrOfAE, RepAtom(pred_name)->StrOfAE, (unsigned long int)pred_arity, (unsigned long int)cl); diff --git a/CXX/yapq.hh b/CXX/yapq.hh index ad9c10e2d..c332af390 100644 --- a/CXX/yapq.hh +++ b/CXX/yapq.hh @@ -94,7 +94,7 @@ public: /// should be a callable /// goal. inline YAPQuery(const char *s) : YAPPredicate(s, goal, names, (nts = &ARG1)) { - __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %d", + __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %ld", LOCAL_CurSlot); openQuery(); @@ -114,7 +114,7 @@ public: /// It i; ///}; /// build a query from a term - YAPQuery(YAPTerm t) : YAPPredicate((goal = t.term()),(nts=Yap_XREGS+1)) { + YAPQuery(YAPTerm t) : YAPPredicate((goal = t.term()), nts) { BACKUP_MACHINE_REGS(); openQuery(); names = TermNil ; diff --git a/H/Yatom.h b/H/Yatom.h index 2f13a808f..eeb21a880 100755 --- a/H/Yatom.h +++ b/H/Yatom.h @@ -20,6 +20,7 @@ #ifndef YATOM_H #define YATOM_H 1 + INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p); INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a); diff --git a/H/inline-only.h b/H/inline-only.h index be5039198..cd2e7b8b2 100644 --- a/H/inline-only.h +++ b/H/inline-only.h @@ -1,11 +1,11 @@ #ifndef _YAP_INLINE_ONLY_H_ #define _YAP_INLINE_ONLY_H_ -#ifdef __GNUC__ +#if defined(__GNUC__ ) #define INLINE_ONLY __attribute__((gnu_inline,always_inline)) //#define INLINE_ONLY #else -#define INLINE_ONLY EXTERN +#define INLINE_ONLY #endif #endif diff --git a/include/VFS.h b/include/VFS.h index 8b9c8c24e..7bb62609c 100644 --- a/include/VFS.h +++ b/include/VFS.h @@ -109,7 +109,7 @@ typedef struct vfs { int (*writers)(int ch, int sno); /** VFS dep endent area */ - cell_size_t priv[4]; + void *priv; struct vfs *next; } VFS_t; diff --git a/os/files.c b/os/files.c index 28456234e..aecd48246 100644 --- a/os/files.c +++ b/os/files.c @@ -671,7 +671,7 @@ static Int list_directory(USES_REGS1) { #if __ANDROID__ { const char *dirName = buf + strlen("/assets/"); - AAssetManager *mgr = GLOBAL_VFS->priv[0].mgr; + AAssetManager *mgr = GLOBAL_VFS->priv; AAssetDir *de; const char *dp; @@ -680,8 +680,8 @@ static Int list_directory(USES_REGS1) { strerror(errno)); } while ((dp = AAssetDir_getNextFileName(de))) { - YAP_Term ti = YAP_MkAtomTerm(YAP_LookupAtom(dp)); - YAP_PutInSlot(sl, YAP_MkPairTerm(ti, YAP_GetFromSlot(sl))); + YAP_Term ti = MkAtomTerm(Yap_LookupAtom(dp)); + Yap_PutInHandle(sl, MkPairTerm(ti, Yap_GetFromHandle(sl))); } AAssetDir_close(de); } diff --git a/packages/myddas/myddas.h b/packages/myddas/myddas.h index 60f115269..07c83a45e 100644 --- a/packages/myddas/myddas.h +++ b/packages/myddas/myddas.h @@ -16,8 +16,8 @@ typedef struct myddas_global *MYDDAS_GLOBAL; #include "myddas_util.h" -static void Yap_InitMYDDAS_SQLITE3Preds(void); -static void Yap_InitBackMYDDAS_SQLITE3Preds(void); +//extern void Yap_InitMYDDAS_SQLITE3Preds(void); +//extern void Yap_InitBackMYDDAS_SQLITE3Preds(void); #ifdef MYDDAS_STATS typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;